visgl / visgl/deck.gl

[Feat] Multi view terrain extension

Open
#9,474 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
TypeScript
Stars
14.6k
Forks
2.3k
Avg merge
2d 9h
Merged PRs (30d)
42

Description

Target Use Case

Hi, so in my project I modified terrain extension in a simple way to support multi-view for terrain extension and since this was marked as TODO I tought I will sent you what I did to see if that would be possible to add in the deck.gl library.

Proposal

So in terrain-effect.ts in preRender I modified my function to look like this :

`
preRender(opts: PreRenderOptions): void {
// @ts-expect-error pickZ only defined in picking pass
if (opts.pickZ) {
// Do not update if picking attributes
this.isDrapingEnabled = false;
return;
}

const { viewports } = opts;
const isPicking = opts.pass.startsWith('picking');
this.isPicking = isPicking;
this.isDrapingEnabled = true;

// TODO - support multiple views?

viewports.forEach((viewport) => {
  const layers = (
    isPicking ? this.terrainPickingPass : this.terrainPass
  ).getRenderableLayers(viewport, opts as TerrainPickingPassRenderOptions);

  const filteredLayers = layers.filter((l) => l.id.startsWith(viewport.id));

  const terrainLayers = filteredLayers.filter(
    (l) =>
      l.props.operation.includes('terrain') && l.id.startsWith(viewport.id)
  );
  if (terrainLayers.length === 0) {
    return;
  }

  if (!isPicking) {
    const offsetLayers = layers.filter(
      (l) => l.state['terrainDrawMode'] === 'offset'
    );
    if (offsetLayers.length > 0) {
      this._updateHeightMap(terrainLayers, viewport, opts);
    }
  }

  const drapeLayers = filteredLayers.filter(
    (l) => l.state['terrainDrawMode'] === 'drape'
  );
  this._updateTerrainCovers(terrainLayers, drapeLayers, viewport, opts);
});

}
`

So the way it works in my app is I set a viewport id for my main and my second screen and for the layers I start their name by the viewport id I want them to show in, and then I use it in the layer filter to show what I want in the good screen. So this is based on the same logic that a layer that you want to see in a screen should be prefixed by that screen id.
Maybe this isn't the cleanest solution but it works quite well.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in terrain-effect.ts at preRender and trace how viewports, terrain passes, and renderable layers are handled. Compare the current single-view behavior with the proposed multi-view filtering approach. Done means terrain offset and drape layers render correctly across multiple views without breaking picking behavior; no test file is mentioned in the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
computer-graphics
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.