Terrain

external class Terrain(terrainProviderPromise: Promise<TerrainProvider>)(source)

A helper to manage async operations of a terrain provider.

// Create
const viewer = new Viewer("cesiumContainer", {
terrain: new Terrain(CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
});
// 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}`);
});

Parameters

terrainProviderPromise

A promise which resolves to a terrain provider

See also

Constructors

Link copied to clipboard
constructor(terrainProviderPromise: Promise<TerrainProvider>)

Types

Link copied to clipboard
object Companion

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

Returns true when the terrain provider has been successfully created. Otherwise, returns false.

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.