要构建 Cesium3DTilesTerrainProvider,请调用 To construct a Cesium3DTilesTerrainProvider, call
A Cesium3DTilesTerrainProvider.fromIonAssetId or Cesium3DTilesTerrainProvider.fromUrl。不要直接调用构造函数。 . Do not call the constructor directly.
TerrainProvider 以 3D Tiles 格式访问地形数据。 that accesses terrain data in a 3D Tiles format.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
options |
Cesium3DTilesTerrainProvider.ConstructorOptions | 可选 optional 描述初始化选项的对象 An object describing initialization options |
- TerrainProvider
- Cesium3DTilesTerrainProvider.fromUrl
- Cesium3DTilesTerrainProvider.fromIonAssetId // 创建带有顶点法线的 GTOPO30 try { constviewer = new Cesium.Viewer("cesiumContainer", {terrainProvider:await Cesium.Cesium3DTilesTerrainProvider.fromIonAssetId(2732686, { requestVertexNormals: true }) }); } catch (错误) { console.log(错误); } Cesium3DTilesTerrainProvider.fromIonAssetId // Create GTOPO30 with vertex normals try { const viewer = new Cesium.Viewer("cesiumContainer", { terrainProvider: await Cesium.Cesium3DTilesTerrainProvider.fromIonAssetId(2732686, { requestVertexNormals: true }) }); } catch (error) { console.log(error); }
实验性 Experimental
此功能不是最终版本,可能会在没有 Cesium 标准弃用政策的情况下进行更改。 This feature is not final and is subject to change without Cesium's standard deprecation policy.
另见: See:
成员 Members
availability : TileAvailability|undefined
获取一个对象,该对象可用于确定此提供者提供的地形的可用性,例如点和矩形中的地形。 Gets an object that can be used to determine availability of terrain from this provider, such as at points and in rectangles.
获取此地形提供程序处于活动状态时要显示的积分。通常,这用于证明地形的来源。 Gets the credit to display when this terrain provider is active. Typically this is used to credit the source of the terrain.
获取当地形提供程序遇到异步错误时引发的事件。通过订阅该事件,您将收到错误通知,并有可能从中恢复。事件监听器传递一个实例 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
TileProviderError.
获取一个值,该值指示请求的切片是否包含顶点法线。 Gets a value indicating whether or not the requested tiles include vertex normals.
获取一个值,该值指示提供程序是否包含水罩。水掩模指示地球的哪些区域是水而不是陆地,因此可以将它们渲染为带有动画波浪的反射表面。 Gets a value indicating whether or not the provider includes a water mask. The water mask indicates which areas of the globe are water rather than land, so they can be rendered as a reflective surface with animated waves.
获取提供者使用的切片方案。 Gets the tiling scheme used by the provider.
方法 Methods
static Cesium.Cesium3DTilesTerrainProvider.fromIonAssetId(assetId, options) → Promise.<CesiumTerrainProvider>
创建一个 Creates a
TerrainProvider 来自访问 Cesium 3D Tiles 格式地形数据的 Cesium ion 资产 ID from a Cesium ion asset ID that accesses terrain data in a Cesium 3D Tiles format
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
assetId |
number | Cesium离子资产 ID。 The Cesium ion asset id. |
options |
CesiumTerrainProvider.ConstructorOptions | 可选 optional 描述初始化选项的对象。 An object describing initialization options. |
返回: Returns:
抛出: Throws:
-
RuntimeError : layer.json does not specify a format
-
RuntimeError : layer.json specifies an unknown format
-
RuntimeError :layer.json 指定不支持的量化网格版本 : layer.json specifies an unsupported quantized-mesh version
-
RuntimeError :layer.json没有指定tiles属性,或者指定了一个空数组 : layer.json does not specify a tiles property, or specifies an empty array
-
RuntimeError :layer.json 未指定任何图块 URL 模板 : layer.json does not specify any tile URL templates
示例: Example:
// Create GTOPO30 with vertex normals
try {
const viewer = new Cesium.Viewer("cesiumContainer", {
terrainProvider: await Cesium.Cesium3DTilesTerrainProvider.fromIonAssetId(2732686, {
requestVertexNormals: true
})
});
} catch (error) {
console.log(error);
}
static Cesium.Cesium3DTilesTerrainProvider.fromUrl(url, options) → Promise.<Cesium3DTilesTerrainProvider>
创建一个 Creates a
TerrainProvider 访问 Cesium 3D Tiles 格式的地形数据。 that accesses terrain data in a Cesium 3D Tiles format.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
url |
Resource | string | Promise.<Resource> | Promise.<string> | Cesium地形服务器的URL。 The URL of the Cesium terrain server. |
options |
Cesium3DTilesTerrainProvider.ConstructorOptions | 可选 optional 描述初始化选项的对象。 An object describing initialization options. |
返回: Returns:
对地形提供者的承诺。 A promise that resolves to the terrain provider.
示例: Example:
// Create terrain with normals.
try {
const viewer = new Cesium.Viewer("cesiumContainer", {
terrainProvider: await Cesium.Cesium3DTilesTerrainProvider.fromUrl(
Cesium.IonResource.fromAssetId(3956), {
requestVertexNormals: true
})
});
} catch (error) {
console.log(error);
}
获取给定级别的图块中允许的最大几何误差。 Get the maximum geometric error allowed in a tile at a given level.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
level |
number | 获得最大几何误差的图块级别。 The tile level for which to get the maximum geometric error. |
返回: Returns:
最大几何误差。 The maximum geometric error.
确定图块的数据是否可供加载。 Determines whether data for a tile is available to be loaded.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
x |
number | 请求几何图形的图块的 X 坐标。 The X coordinate of the tile for which to request geometry. |
y |
number | 请求几何图形的图块的 Y 坐标。 The Y coordinate of the tile for which to request geometry. |
level |
number | 请求几何图形的图块的级别。 The level of the tile for which to request geometry. |
返回: Returns:
如果不支持或可用性未知,则未定义,否则 true 或 false。 Undefined if not supported or availability is unknown, otherwise true or false.
确保我们加载图块的可用性数据 Make sure we load availability data for a tile
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
_x |
number | 请求几何图形的图块的 X 坐标。 The X coordinate of the tile for which to request geometry. |
_y |
number | 请求几何图形的图块的 Y 坐标。 The Y coordinate of the tile for which to request geometry. |
_level |
number | 请求几何图形的图块的级别。 The level of the tile for which to request geometry. |
返回: Returns:
如果不需要加载任何内容,或者在加载所有必需的图块时解析的 Promise,则为未定义 Undefined if nothing need to be loaded or a Promise that resolves when all required tiles are loaded
requestTileGeometry(x, y, level, request) → Promise.<Cesium3DTilesTerrainData>|undefined
请求给定图块的几何形状。之前不应调用此函数 Requests the geometry for a given tile. This function should not be called before
Cesium3DTilesTerrainProvider#ready 返回真。结果必须包括地形数据,并且可以选择包括水掩模和哪些子图块可用的指示。 returns true. The result must include terrain data and may optionally include a water mask and an indication of which child tiles are available.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
x |
number | 请求几何图形的图块的 X 坐标。 The X coordinate of the tile for which to request geometry. |
y |
number | 请求几何图形的图块的 Y 坐标。 The Y coordinate of the tile for which to request geometry. |
level |
number | 请求几何图形的图块的级别。 The level of the tile for which to request geometry. |
request |
Request | 可选 optional 请求对象。仅供内部使用。 The request object. Intended for internal use only. |
返回: Returns:
对所要求的几何形状的承诺。如果此方法返回未定义而不是承诺,则表明已有太多请求处于待处理状态,稍后将重试该请求。 A promise for the requested geometry. If this method returns undefined instead of a promise, it is an indication that too many requests are already pending and the request will be retried later.
类型定义 Type Definitions
Cesium3DTilesTerrainProvider 构造函数的初始化选项 Initialization options for the Cesium3DTilesTerrainProvider constructor
属性: Properties:
| 名称 Name | 类型 Type | Attributes | 默认值 Default | 说明 Description |
|---|---|---|---|---|
requestVertexNormals |
boolean |
<可选> <optional> |
false | 指示客户端是否应从服务器请求附加照明信息的标志,以每个顶点法线的形式(如果可用)。 Flag that indicates if the client should request additional lighting information from the server, in the form of per vertex normals if available. |
requestWaterMask |
boolean |
<可选> <optional> |
false | 指示客户端是否应向服务器请求每块水掩模(如果可用)的标志。 Flag that indicates if the client should request per tile water masks from the server, if available. |
ellipsoid |
Ellipsoid |
<可选> <optional> |
Ellipsoid.default | 椭球体。如果未指定,则使用 WGS84 椭球。 The ellipsoid. If not specified, the WGS84 ellipsoid is used. |
credit |
Credit | string |
<可选> <optional> |
数据源的来源,显示在画布上。 A credit for the data source, which is displayed on the canvas. |
