visgl / deck.gl

WebGL2 powered visualization framework
https://deck.gl
MIT License
12.06k stars 2.08k forks source link

[Bug] Cannot dynamically alternate between terrain ON/OFF #8450

Open ssaornil opened 7 months ago

ssaornil commented 7 months ago

Description

We are attempting to alternate dynamically between two modes of visualization, one with terrain ON and another one with terrain OFF.

We are using mapbox as our base map and we are adding some content using the MapboxOverlay in non-interleaved mode. We are using the TerrainLayer and the experimental TerrainExtension to "drape" the content to the terrain.

Regardless of the fact that mapbox and deck do not match completely (we are aware of that and we are disregarding that issue at the moment), we are unable to alternate between those two modes of terrain ON/OFF.

Flavors

Expected Behavior

We would expect to be able to switch between terrain ON/OFF using one of the following approaches or a combination of them:

  1. Toggle TerrainLayer visibility
  2. Adding/removing TerrainLayer
  3. Adding/removing TerrainExtension from the layers (either by redefining the layers or by cloning them)

Steps to Reproduce

Demo

In the above DEMO we are displaying the same content with mapbox and deck (using different styles). And there is a button to toggle between Terrain ON/OFF modes.

The deck layers are not visible when trying to start in the "Terrain ON" mode. START_WITH_TERRAIN= true . Alternating does nothing.

The deck content is not draped and it is also cropped when starting in the Terrain OFF mode and alternating to Terrain ON mode.

Environment

Logs

No response

ssaornil commented 7 months ago

We found an alternative that works.

Adding/removing the TerrainLayer and replacing the layers by clones with or without the TerrainExtension does not work, but if we create a new MapboxOverlay instance and use it to replace the previous one when toggling between terrain ON/OFF, then it works.

Here is a working demo.

I haven't found any place in the documentation that makes is clear that we cannot change extensions once the overlay instance is created. Maybe it would make sense to add it somewhere?