-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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.