Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feat] Multi view terrain extension #9474

Open
HouleAdrien opened this issue Feb 28, 2025 · 0 comments
Open

[Feat] Multi view terrain extension #9474

HouleAdrien opened this issue Feb 28, 2025 · 0 comments
Labels

Comments

@HouleAdrien
Copy link

HouleAdrien commented Feb 28, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant