Terrain
A helper to manage async operations of a terrain provider.
// Create
const viewer = new Viewer("cesiumContainer", {
terrain: new Terrain(CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
});
Content copied to clipboard
// Handle loading events
const terrain = new Terrain(CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
scene.setTerrain(terrain);
terrain.readyEvent.addEventListener(provider => {
scene.globe.enableLighting = true;
terrain.provider.errorEvent.addEventListener(error => {
alert(`Encountered an error while loading terrain tiles! ${error}`);
});
});
terrain.errorEvent.addEventListener(error => {
alert(`Encountered an error while creating terrain! ${error}`);
});
Content copied to clipboard
Parameters
terrainProviderPromise
A promise which resolves to a terrain provider
See also
Properties
Link copied to clipboard
Gets an event that is raised when the terrain provider encounters an asynchronous error. By subscribing to the event, you will be notified of the error and can potentially recover from it. Event listeners are passed an instance of the thrown error.
Link copied to clipboard
The terrain provider providing surface geometry to a globe. Do not use until Terrain.readyEvent is raised.
Link copied to clipboard
Gets an event that is raised when the terrain provider has been successfully created. Event listeners are passed the created instance of TerrainProvider.