1. A concise explanation of the problem you’re experiencing.
I always encounter this error whenever I tried to turn on the 3D terrain then do panning or zooming then turn the 3D terrain off again. I am assuming that it might be because the terrain is still loading and then I abruptly turned it off since when I do panning or zoom it updates the terrain tiles. But I might be wrong as well, so I wanted to know your thoughts on this and how I can prevent this error on my application.
CesiumWidget.js:726 An error occurred while rendering. Rendering has stopped.
DeveloperError: This object was destroyed, i.e., destroy() was called.
Error
at new DeveloperError (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Core/DeveloperError.js:41:11)
at Imagery.throwOnDestroyed (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Core/destroyObject.js:41:11)
at TileImagery.freeResources (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Scene/TileImagery.js:31:23)
at GlobeSurfaceTile.freeResources (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Scene/GlobeSurfaceTile.js:207:20)
at QuadtreeTile.freeResources (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Scene/QuadtreeTile.js:468:15)
at invalidateAllTiles (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Scene/QuadtreePrimitive.js:234:25)
at QuadtreePrimitive.beginFrame (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Scene/QuadtreePrimitive.js:338:5)
at Globe.beginFrame (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Scene/Globe.js:938:13)
at render (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Scene/Scene.js:2956:17)
at tryAndCatchError (webpack-internal:///./src/sdk/cesium/packages/engine/Source/Scene/Scene.js:2973:5)
2. A minimal code example. If you’ve found a bug, this helps us reproduce and repair it.
I created 2 functions in order to turn on & off the 3D terrain. If the value that is passed on the setTerrain3d function is true, it will set a terrain otherwise it will remove it.
async enableTerrain3d() {
// this.viewer.terrainProvider = await Cesium.createWorldTerrainAsync();
let terrain = Cesium.Terrain.fromWorldTerrain();
this.viewer.scene.setTerrain(terrain);
terrain.errorEvent.addEventListener(error => {
alert(`Encountered an error while creating terrain! ${error}`);
});
this.viewer.scene.globe.depthTestAgainstTerrain = false;
},
setTerrain3d(value) {
if (value) {
this.enableTerrain3d();
} else {
this.viewer.scene.terrainProvider = new Cesium.EllipsoidTerrainProvider();
this.viewer.scene.globe.depthTestAgainstTerrain = true;
}
},
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
I need to smoothly enable or disable the 3D terrain without any error. Even if I do panning or zoom and then quickly turn on/off the 3D terrain, I wouldn’t get the error above.
4. The Cesium version you’re using, your operating system and browser.
1.109