管理地形提供者的异步操作的助手。 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 provider : TerrainProvider
地形提供者为地球提供表面几何形状。不要使用直到 The terrain provider providing surface geometry to a globe. Do not use until
Terrain.readyEvent 被提出。 is raised.
当地形提供者成功创建时返回 true。否则,返回 false。 Returns true when the terrain provider has been successfully created. Otherwise, returns false.
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.fromWorldBathymetry(options) → Terrain
| 名称 Name | 类型 Type | 说明 Description | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
可选 optional
具有以下属性的对象: Object with the following properties:
|
返回: Returns:
CesiumTerrainProvider 的异步辅助对象 An asynchronous helper object for a CesiumTerrainProvider
示例: Examples:
// Create Cesium World Bathymetry with default settings
const viewer = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldBathymetry)
});
// Create Cesium World Terrain with normals.
const viewer1 = new Cesium.Viewer("cesiumContainer", {
terrain: Cesium.Terrain.fromWorldBathymetry({
requestVertexNormals: true
});
});
// 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}`);
});
另见: See:
static Cesium.Terrain.fromWorldTerrain(options) → Terrain
| 名称 Name | 类型 Type | 说明 Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
可选 optional
具有以下属性的对象: Object with the following properties:
|
返回: Returns:
CesiumTerrainProvider 的异步辅助对象 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: 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: This:
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
provider |
TerrainProvider | 创建的地形提供者。 The created terrain provider. |
