A helper to manage async operations of a terrain provider.
Name | Type | Description |
---|---|---|
terrainProviderPromise |
Promise.<TerrainProvider> | A promise which resolves to a terrain provider |
Examples:
// Create
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: new Cesium.Terrain(Cesium.CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
});
// Handle loading events
const terrain = new Cesium.Terrain(Cesium.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}`);
});
See:
Members
readonly errorEvent : Event.<Terrain.ErrorEventCallback>
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.
readonly readyEvent : Event.<Terrain.ReadyEventCallback>
Gets an event that is raised when the terrain provider has been successfully created. Event listeners
are passed the created instance of
TerrainProvider
.
Methods
static Cesium.Terrain.fromWorldTerrain(options) → Terrain
Creates a
Terrain
instance for Cesium World Terrain.
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
Object with the following properties:
|
Returns:
An asynchronous helper object for a CesiumTerrainProvider
Examples:
// Create Cesium World Terrain with default settings
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldTerrain()
});
// Create Cesium World Terrain with water and normals.
const viewer1 = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldTerrain({
requestWaterMask: true,
requestVertexNormals: true
});
});
// Handle loading events
const terrain = Cesium.Terrain.fromWorldTerrain();
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}`);
});
See:
Type Definitions
A function that is called when an error occurs.
This:
Name | Type | Description |
---|---|---|
err |
Error | An object holding details about the error that occurred. |
A function that is called when the provider has been created
This:
Name | Type | Description |
---|---|---|
provider |
TerrainProvider | The created terrain provider. |