CesiumWidget 隐式创建。
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Object with the following properties:
|
Throws:
-
DeveloperError :options 和 options.canvas 是必需的。
Example:
// Create scene without anisotropic texture filtering
const scene = new Cesium.Scene({
canvas : canvas,
contextOptions : {
allowTextureFilterAnisotropic : false
}
});
See:
Members
Scene#logarithmicDepthBuffer 设置默认值。
此属性依赖于对 fragmentDepth 的支持。
-
Default Value:
false
atmosphere : Atmosphere
Scene#skyAtmosphere 混淆。
backgroundColor : Color
Scene#skyBox 为 undefined)时可见。
-
Default Value:
Color.BLACK
See:
readonly camera : Camera
-
Default Value:
false
-
Default Value:
true
一个用于确定执行哪些命令的函数。如下方示例所示,
该函数接收命令的 owner 作为参数,并返回一个布尔值,指示是否应执行该命令。
默认值为 undefined,表示执行所有命令。
-
Default Value:
undefined
Example:
// Do not execute any commands.
scene.debugCommandFilter = function(command) {
return false;
};
// Execute only the billboard's commands. That is, only draw the billboard.
const billboards = new Cesium.BillboardCollection();
scene.debugCommandFilter = function(command) {
return command.owner === billboards;
};
当 Scene.debugShowFrustums 为 true 时,此属性包含
每个视锥体所执行命令数量的统计信息。
totalCommands 是执行的命令总数(忽略重叠)。commandsInFrustums 是一个数组,包含
命令被冗余执行的次数,例如有多少个命令重叠了两个或三个视锥体。
-
Default Value:
undefined
当为 true 时,命令将以随机着色。这有助于
性能分析,以查看场景或模型的哪些部分是命令密集的,从而可以从批处理中受益。
-
Default Value:
false
指示哪个视锥体将显示深度信息。
-
Default Value:
1
显示每秒帧数以及帧之间的时间。
-
Default Value:
false
当为 true 时,绘制轮廓以显示相机视锥体的边界
-
Default Value:
false
当为 true 时,命令根据其重叠的视锥体进行着色。
最近视锥体中的命令染成红色,下一个最近的染成绿色,最远的视锥体中的命令染成蓝色。
如果一个命令重叠了多个视锥体,颜色分量将被组合,例如,重叠前两个视锥体的命令会染成黄色。
-
Default Value:
false
See:
See:
readonly ellipsoid : Ellipsoid
此值用于为多视锥体的每个视锥体创建近值和远值。仅当
Scene#logarithmicDepthBuffer 为 false 时使用。当 logarithmicDepthBuffer 为
true 时,请使用 Scene#logarithmicDepthFarToNearRatio。
-
Default Value:
1000.0
-
Default Value:
2.2
readonly groundPrimitives : PrimitiveCollection
-
Default Value:
false
-
Default Value:
true
readonly imageryLayers : ImageryLayerCollection
false 时,3D Tiles 将正常渲染。当为 true 时,已分类的 3D Tile 几何体会正常渲染,而
未分类的 3D Tile 几何体会以颜色乘以 Scene#invertClassificationColor 的方式渲染。
-
Default Value:
false
invertClassificationColor : Color
Scene#invertClassification 为 true 时,未分类 3D Tile 几何体的高亮颜色。
当颜色的 alpha 小于 1.0 时,3D Tiles 的未分类部分将无法与 3D Tiles 的已分类位置正确混合。
此外,当颜色的 alpha 小于 1.0 时,必须支持 WEBGL_depth_texture 和 EXT_frag_depth 这两个 WebGL 扩展。
-
Default Value:
Color.WHITE
Scene#invertClassification 则返回 true。
readonly lastRenderTime : JulianDate|undefined
undefined。
此值用于为多视锥体的每个视锥体创建近值和远值。仅当
Scene#logarithmicDepthBuffer 为 true 时使用。当 logarithmicDepthBuffer 为
false 时,请使用 Scene#farToNearRatio。
-
Default Value:
1e9
readonly mapMode2D : MapMode2D
readonly mapProjection : MapProjection
-
Default Value:
new GeographicProjection()
- glGet with
ALIASED_LINE_WIDTH_RANGE.
See:
- glGet with
GL_MAX_CUBE_MAP_TEXTURE_SIZE.
See:
Scene#requestRenderMode 为 true,此值定义了在请求渲染之前所允许的模拟时间
最大变化量。较小的值会增加渲染的帧数,较大的值会减少渲染的帧数。如果为 undefined,
模拟时间的变化将永远不会请求渲染。
此值会影响场景变化(如光照、实体属性更新和动画)的渲染速率。
-
Default Value:
0.0
See:
-
Default Value:
0.0
-
Default Value:
SceneMode.SCENE3D
moon : Moon|undefined
Moon。
-
Default Value:
undefined
morphComplete : Event
-
Default Value:
Event()
morphStart : Event
-
Default Value:
Event()
-
Default Value:
1.0
-
Default Value:
4
true。
-
Default Value:
1.75e6
Scene#pickPosition 函数则返回 true。
See:
true 时,启用使用深度缓冲区拾取半透明几何体的功能。请注意,要使此功能生效,Scene#useDepthPicking 也必须为 true。
启用时性能会下降,因为需要额外的绘制调用来为半透明几何体写入深度。
-
Default Value:
false
Example:
// picking the position of a translucent primitive
viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
const pickedFeature = viewer.scene.pick(movement.position);
if (!Cesium.defined(pickedFeature)) {
// nothing picked
return;
}
const worldPosition = viewer.scene.pickPosition(movement.position);
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
postProcessStages : PostProcessStageCollection
readonly postRender : Event
See:
readonly postUpdate : Event
readonly preRender : Event
See:
readonly preUpdate : Event
See:
readonly primitives : PrimitiveCollection
readonly renderError : Event
render 函数内部抛出异常时触发的事件。
Scene 实例和抛出的错误是传递给事件处理程序的仅有的两个参数。
默认情况下,在此事件触发后不会重新抛出异常,但可以通过设置
rethrowRenderErrors 属性来更改这一行为。
true 时,仅在场景内发生变化需要时才渲染帧。
启用后可提升应用程序的性能,但需要使用 Scene#requestRender
在此模式下显式渲染新帧。在 API 的其他部分对场景进行更改后,许多情况下都需要这样做。
-
Default Value:
false
See:
render 中发生的异常总是会被捕获,以触发
renderError 事件。如果此属性为 true,错误会在事件触发后重新抛出。
如果此属性为 false,render 函数在触发事件后会正常返回。
-
Default Value:
false
readonly screenSpaceCameraController : ScreenSpaceCameraController
shadowMap : ShadowMap
skyAtmosphere : SkyAtmosphere|undefined
-
Default Value:
undefined
skyBox : SkyBox|undefined
SkyBox。
-
Default Value:
undefined
See:
true。
sphericalHarmonicCoefficients : Array.<Cartesian3>
sun : Sun|undefined
Sun。
-
Default Value:
undefined
-
Default Value:
true
terrainProvider : TerrainProvider
readonly terrainProviderChanged : Event
true 时,启用使用深度缓冲区的拾取。
-
Default Value:
true
true 时,将场景分割为两个视口,分别显示左右眼的立体视图。
用于 cardboard 和 WebVR。
-
Default Value:
false
-
Default Value:
1.0
-
Default Value:
0.0
Methods
cartesianToCanvasCoordinates(position, result) → Cartesian2|undefined
| Name | Type | Description |
|---|---|---|
position |
Cartesian3 | 笛卡尔坐标中的位置。 |
result |
Cartesian2 | optional 一个可选对象,用于返回变换为 canvas 坐标的输入位置。 |
Returns:
undefined。
Example:
// Output the canvas position of longitude/latitude (0, 0) every time the mouse moves.
const scene = widget.scene;
const position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
const handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(movement) {
console.log(scene.cartesianToCanvasCoordinates(position));
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
clampToHeight(cartesian, objectsToExclude, width, result) → Cartesian3|undefined
undefined。可用于将
对象钳制到地球、3D Tiles 或场景中的图元上。
此函数仅钳制当前视图中渲染的地球瓦片和 3D Tiles。对于其他所有图元,无论其是否可见都会进行钳制。
| Name | Type | Default | Description |
|---|---|---|---|
cartesian |
Cartesian3 | 笛卡尔位置。 | |
objectsToExclude |
Array.<object> | optional 不进行钳制的图元、实体或 3D Tiles 要素的列表。 | |
width |
number |
0.1
|
optional 相交体的宽度(米)。 |
result |
Cartesian3 | optional 一个可选对象,用于返回钳制后的位置。 |
Returns:
undefined。
Throws:
-
DeveloperError :clampToHeight 仅在 3D 模式下受支持。
-
DeveloperError :clampToHeight 需要深度纹理支持。请检查 clampToHeightSupported。
Example:
// Clamp an entity to the underlying scene geometry
const position = entity.position.getValue(Cesium.JulianDate.now());
entity.position = viewer.scene.clampToHeight(position);
See:
clampToHeightMostDetailed(cartesians, objectsToExclude, width) → Promise.<Array.<(Cartesian3|undefined)>>
Cartesian3 位置的异步 Scene#clampToHeight 查询。
查询完成时返回一个已解析的 promise。每个位置都会原地修改。如果某个位置因为该位置没有可采样的几何体
或发生其他错误而无法钳制,则数组中的该元素会被设为 undefined。
| Name | Type | Default | Description |
|---|---|---|---|
cartesians |
Array.<Cartesian3> | 要使用钳制位置进行更新的笛卡尔位置。 | |
objectsToExclude |
Array.<object> | optional 不进行钳制的图元、实体或 3D Tiles 要素的列表。 | |
width |
number |
0.1
|
optional 相交体的宽度(米)。 |
Returns:
undefined。
Throws:
-
DeveloperError :clampToHeightMostDetailed 仅在 3D 模式下受支持。
-
DeveloperError :clampToHeightMostDetailed 需要深度纹理支持。请检查 clampToHeightSupported。
Example:
const cartesians = [
entities[0].position.getValue(Cesium.JulianDate.now()),
entities[1].position.getValue(Cesium.JulianDate.now())
];
const promise = viewer.scene.clampToHeightMostDetailed(cartesians);
promise.then(function(updatedCartesians) {
entities[0].position = updatedCartesians[0];
entities[1].position = updatedCartesians[1];
}
See:
一旦对象被销毁,就不应再使用;调用
isDestroyed 之外的任何函数
都会抛出 DeveloperError 异常。因此,
应像示例中那样将返回值(undefined)赋给该对象。
Throws:
-
DeveloperError :该对象已被销毁,即已调用 destroy()。
Example:
scene = scene && scene.destroy();
See:
primitive 属性,对应于位于
特定窗口坐标位置的所有图元。根据图元类型的不同,也可能设置其他属性,这些属性可用于进一步识别被拾取的对象。
列表中的图元按其在场景中的视觉顺序(从前到后)排列。
| Name | Type | Default | Description |
|---|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取的窗口坐标。 | |
limit |
number | optional 如果提供,则在收集到这么多拾取结果后停止穿透拾取。 | |
width |
number |
3
|
optional 拾取矩形的宽度。 |
height |
number |
3
|
optional 拾取矩形的高度。 |
Returns:
Throws:
-
DeveloperError :windowPosition 为 undefined。
Example:
const pickedObjects = scene.drillPick(new Cesium.Cartesian2(100.0, 200.0));
See:
| Name | Type | Description |
|---|---|---|
format |
string | 纹理格式。可以是格式名称或 WebGL 扩展名称,例如 s3tc 或 WEBGL_compressed_texture_s3tc。 |
Returns:
Returns:
true 如果此对象已被销毁;否则为 false。
See:
| Name | Type | Default | Description |
|---|---|---|---|
duration |
number |
2.0
|
optional 过渡动画完成所需的时间(秒)。 |
| Name | Type | Default | Description |
|---|---|---|---|
duration |
number |
2.0
|
optional 过渡动画完成所需的时间(秒)。 |
| Name | Type | Default | Description |
|---|---|---|---|
duration |
number |
2.0
|
optional 过渡动画完成所需的时间(秒)。 |
primitive 属性的对象,该属性表示在
特定窗口坐标处场景中的第一个(最顶层)图元;如果该位置没有任何内容,则返回 undefined。
根据图元类型的不同,也可能设置其他属性,这些属性可用于进一步识别被拾取的对象。
当拾取到 3D Tiles 瓦片集的一个要素时,pick 会返回一个 Cesium3DTileFeature 对象。
| Name | Type | Default | Description |
|---|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取的窗口坐标。 | |
width |
number |
3
|
optional 拾取矩形的宽度。 |
height |
number |
3
|
optional 拾取矩形的高度。 |
Returns:
undefined。
Example:
// On mouse over, color the feature yellow.
handler.setInputAction(function(movement) {
const feature = scene.pick(movement.endPosition);
if (feature instanceof Cesium.Cesium3DTileFeature) {
feature.color = Cesium.Color.YELLOW;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
| Name | Type | Default | Description |
|---|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取的窗口坐标。 | |
width |
number |
3
|
optional 拾取矩形的宽度。 |
height |
number |
3
|
optional 拾取矩形的高度。 |
Returns:
undefined。
Example:
// On mouse over, color the feature yellow.
handler.setInputAction(function(movement) {
const feature = scene.pickAsync(movement.endPosition).then(function(feature) {
if (feature instanceof Cesium.Cesium3DTileFeature) {
feature.color = Cesium.Color.YELLOW;
}
});
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
See:
pickMetadata(windowPosition, schemaId, className, propertyName) → MetadataValue|undefined
| Name | Type | Description |
|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取的窗口坐标。 |
schemaId |
string | undefined |
要从中拾取值的元数据 schema 的 ID。
如果为 undefined,则将从匹配给定类名称和属性名称的对象中拾取值,
而不考虑 schema ID。 |
className |
string | 要从中拾取值的元数据类的名称 |
propertyName |
string | 要从中拾取值的元数据属性的名称 |
Returns:
undefined
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
pickMetadataSchema(windowPosition) → MetadataSchema|undefined
| Name | Type | Description |
|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取的窗口坐标。 |
Returns:
undefined。
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
pickPosition(windowPosition, result) → Cartesian3
在 2D 中根据深度缓冲区重建的位置,可能与在 3D 和 Columbus 视图中重建的位置略有不同。 这是由于透视投影和正交投影的深度值分布不同所致。
将 Scene#pickTranslucentDepth 设为 true 可包含
半透明图元的深度;否则,此操作实际上会穿透半透明图元进行拾取。
| Name | Type | Description |
|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取的窗口坐标。 |
result |
Cartesian3 | optional 用于恢复结果的对象。 |
Returns:
Throws:
-
DeveloperError :不支持从深度缓冲区拾取。请检查 pickPositionSupported。
pickVoxel(windowPosition, width, height) → VoxelCell|undefined
VoxelCell,
如果该位置没有渲染体素,则返回 undefined。
| Name | Type | Default | Description |
|---|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取的窗口坐标。 | |
width |
number |
3
|
optional 拾取矩形的宽度。 |
height |
number |
3
|
optional 拾取矩形的高度。 |
Returns:
undefined。
Example:
On left click, report the value of the "color" property at that voxel sample.
handler.setInputAction(function(movement) {
const voxelCell = scene.pickVoxel(movement.position);
if (defined(voxelCell)) {
console.log(voxelCell.getProperty("color"));
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
CesiumWidget 会自动执行。
| Name | Type | Description |
|---|---|---|
time |
JulianDate | optional 要渲染的模拟时间。 |
undefined。输入位置的高度会被忽略。可用于将对象钳制到
地球、3D Tiles 或场景中的图元上。
此函数仅从当前视图中渲染的地球瓦片和 3D Tiles 采样高度。对于其他所有图元, 无论其是否可见都会采样高度。
| Name | Type | Default | Description |
|---|---|---|---|
position |
Cartographic | 用于采样高度的大地坐标位置。 | |
objectsToExclude |
Array.<object> | optional 不从中采样高度的图元、实体或 3D Tiles 要素的列表。 | |
width |
number |
0.1
|
optional 相交体的宽度(米)。 |
Returns:
undefined。
Throws:
-
DeveloperError :sampleHeight 仅在 3D 模式下受支持。
-
DeveloperError :sampleHeight 需要深度纹理支持。请检查 sampleHeightSupported。
Example:
const position = new Cesium.Cartographic(-1.31968, 0.698874);
const height = viewer.scene.sampleHeight(position);
console.log(height);
See:
sampleHeightMostDetailed(positions, objectsToExclude, width) → Promise.<Array.<(Cartographic|undefined)>>
Cartographic 位置的异步 Scene#sampleHeight 查询。
输入位置的高度会被忽略。查询完成时返回一个已解析的 promise。每个点的高度都会原地修改。
如果某个位置因为该位置没有可采样的几何体或发生其他错误而无法确定高度,
则该高度会被设为 undefined。
| Name | Type | Default | Description |
|---|---|---|---|
positions |
Array.<Cartographic> | 要使用采样高度进行更新的大地坐标位置。 | |
objectsToExclude |
Array.<object> | optional 不从中采样高度的图元、实体或 3D Tiles 要素的列表。 | |
width |
number |
0.1
|
optional 相交体的宽度(米)。 |
Returns:
undefined。
Throws:
-
DeveloperError :sampleHeightMostDetailed 仅在 3D 模式下受支持。
-
DeveloperError :sampleHeightMostDetailed 需要深度纹理支持。请检查 sampleHeightSupported。
Example:
const positions = [
new Cesium.Cartographic(-1.31968, 0.69887),
new Cesium.Cartographic(-1.10489, 0.83923)
];
const promise = viewer.scene.sampleHeightMostDetailed(positions);
promise.then(function(updatedPosition) {
// positions[0].height and positions[1].height have been updated.
// updatedPositions is just a reference to positions.
}
See:
setTerrain(terrain) → Terrain
| Name | Type | Description |
|---|---|---|
terrain |
Terrain | 地形提供者异步辅助对象 |
Returns:
Examples:
// Use Cesium World Terrain
scene.setTerrain(Cesium.Terrain.fromWorldTerrain());
// Use a custom terrain provider
const terrain = new Cesium.Terrain(Cesium.CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
scene.setTerrain(terrain);
terrain.errorEvent.addEventListener(error => {
alert(`Encountered an error while creating terrain! ${error}`);
});
