English中文

Terrain

new Cesium.Terrain(terrainProviderPromise)

管理地形提供者的异步操作的助手。 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

获取当地形提供程序遇到异步错误时引发的事件。通过订阅该事件,您将收到错误通知,并有可能从中恢复。向事件侦听器传递抛出的错误的实例。 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.
地形提供者为地球提供表面几何形状。不要使用直到 The terrain provider providing surface geometry to a globe. Do not use until Terrain.readyEvent 被提出。 is raised.

readonly ready : boolean

当地形提供者成功创建时返回 true。否则,返回 false。 Returns true when the terrain provider has been successfully created. Otherwise, returns false.
获取在成功创建地形提供程序时引发的事件。事件侦听器将传递创建的实例 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

创建一个 Creates a Terrain 实例为 instance for Cesium World Bathymetry.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
requestVertexNormals boolean false 可选 optional 指示客户端是否应从服务器请求附加照明信息(如果可用)的标志。 Flag that indicates if the client should request additional lighting information from the server if available.
返回: 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

创建一个 Creates a Terrain 实例为 instance for Cesium World Terrain.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
requestVertexNormals boolean false 可选 optional 指示客户端是否应从服务器请求附加照明信息(如果可用)的标志。 Flag that indicates if the client should request additional lighting information from the server if available.
requestWaterMask boolean false 可选 optional 指示客户端是否应从服务器请求每个图块水掩模(如果可用)的标志。 Flag that indicates if the client should request per tile water masks from the server if available.
返回: 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

Cesium.Terrain.ErrorEventCallback(err)

发生错误时调用的函数。 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.

Cesium.Terrain.ReadyEventCallback(provider)

创建提供者时调用的函数 A function that is called when the provider has been created
this: This:
名称 Name 类型 Type 说明 Description
provider TerrainProvider 创建的地形提供者。 The created terrain provider.
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.