CesiumWidget 隐式创建。
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
包含以下属性的对象:
|
Throws:
-
DeveloperError : options 和 options.canvas 是必需的。
Example:
// 创建没有各向异性纹理过滤的场景
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:
// 不执行任何命令。
scene.debugCommandFilter = function(command) {
return false;
};
// 仅执行广告牌的命令。即仅绘制广告牌。
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 与
ALIASED_LINE_WIDTH_RANGE。
See:
- glGet 与
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:
// 拾取半透明图元的位置
viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
const pickedFeature = viewer.scene.pick(movement.position);
if (!Cesium.defined(pickedFeature)) {
// 未拾取到任何东西
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:
// 每次鼠标移动时输出经度/纬度 (0, 0) 的 canvas 位置。
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:
// 将实体贴合到基础场景几何体
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 查询,
使用场景中 3D Tilesets 的最大细节级别。返回查询完成时解决的 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 未定义。
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:
// 鼠标悬停时,将特征着色为黄色。
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:
// 鼠标悬停时,将特征着色为黄色。
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 |
要拾取值的元数据模式的 ID。
如果为 undefined,则将拾取与给定类和属性名称匹配的对象的值,而不考虑模式 ID。 |
className |
string | 要拾取值的元数据类的名称 |
propertyName |
string | 要拾取值的元数据属性的名称 |
Returns:
undefined
Experimental
此功能尚未完成,可能会在没有 Cesium 标准弃用策略的情况下进行更改。
pickMetadataSchema(windowPosition) → MetadataSchema|undefined
| Name | Type | Description |
|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取的窗口坐标。 |
Returns:
undefined。
Experimental
此功能尚未完成,可能会在没有 Cesium 标准弃用策略的情况下进行更改。
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:
左键单击时,报告该体素样本处 "color" 属性的值。
handler.setInputAction(function(movement) {
const voxelCell = scene.pickVoxel(movement.position);
if (defined(voxelCell)) {
console.log(voxelCell.getProperty("color"));
}
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);
Experimental
此功能尚未完成,可能会在没有 Cesium 标准弃用策略的情况下进行更改。
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 查询,
使用场景中 3D Tilesets 的最大细节级别。输入位置的高度将被忽略。
返回查询完成时解决的 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 和 positions[1].height 已更新。
// updatedPositions 只是对 positions 的引用。
}
See:
setTerrain(terrain) → Terrain
| Name | Type | Description |
|---|---|---|
terrain |
Terrain | 地形提供者异步辅助对象 |
Returns:
Examples:
// 使用 Cesium World Terrain
scene.setTerrain(Cesium.Terrain.fromWorldTerrain());
// 使用自定义地形提供者
const terrain = new Cesium.Terrain(Cesium.CesiumTerrainProvider.fromUrl("https://myTestTerrain.com"));
scene.setTerrain(terrain);
terrain.errorEvent.addEventListener(error => {
alert(`创建地形时遇到错误!${error}`);
});
