Appearance
KBE3D / KBCore / Cesium / Terrain
类: Terrain
A helper to manage async operations of a terrain provider.
Examples
ts
// Create
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: new Cesium.Terrain(Cesium.CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
});ts
// 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}`);
});参数
A promise which resolves to a terrain provider
属性
errorEvent
readonlyerrorEvent:Event<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.
readyEvent
readonlyreadyEvent:Event<ReadyEventCallback>
Gets an event that is raised when the terrain provider has been successfully created. Event listeners are passed the created instance of TerrainProvider.
ready
readonlyready:boolean
Returns true when the terrain provider has been successfully created. Otherwise, returns false.
provider
readonlyprovider:TerrainProvider
The terrain provider providing surface geometry to a globe. Do not use until Terrain.readyEvent is raised.
方法
fromWorldTerrain()
staticfromWorldTerrain(options?: {requestVertexNormals?:boolean;requestWaterMask?:boolean; }):Terrain
Creates a Terrain instance for Cesium World Terrain.
参数
options?
Object with the following properties:
requestVertexNormals?
boolean
Flag that indicates if the client should request additional lighting information from the server if available.
requestWaterMask?
boolean
Flag that indicates if the client should request per tile water masks from the server if available.
返回
Terrain
An asynchronous helper object for a CesiumTerrainProvider
Examples
ts
// Create Cesium World Terrain with default settings
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldTerrain()
});ts
// Create Cesium World Terrain with water and normals.
const viewer1 = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldTerrain({
requestWaterMask: true,
requestVertexNormals: true
});
});ts
// 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}`);
});fromWorldBathymetry()
staticfromWorldBathymetry(options?: {requestVertexNormals?:boolean; }):Terrain
Creates a Terrain instance for Cesium World Bathymetry.
参数
options?
Object with the following properties:
requestVertexNormals?
boolean
Flag that indicates if the client should request additional lighting information from the server if available.
返回
Terrain
An asynchronous helper object for a CesiumTerrainProvider
Examples
ts
// Create Cesium World Bathymetry with default settings
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldBathymetry)
});ts
// Create Cesium World Terrain with normals.
const viewer1 = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldBathymetry({
requestVertexNormals: true
});
});ts
// Handle loading events
const bathymetry = Cesium.Terrain.fromWorldBathymetry();
scene.setTerrain(bathymetry);
bathymetry.readyEvent.addEventListener(provider => {
scene.globe.enableLighting = true;
bathymetry.provider.errorEvent.addEventListener(error => {
alert(`Encountered an error while loading bathymetric terrain tiles! ${error}`);
});
});
bathymetry.errorEvent.addEventListener(error => {
alert(`Encountered an error while creating bathymetric terrain! ${error}`);
});构造函数
构造函数
new Terrain(
terrainProviderPromise:Promise<TerrainProvider>):Terrain
参数
terrainProviderPromise
Promise<TerrainProvider>
返回
Terrain
