CesiumWidget 隐式创建的。
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象:
|
Throws:
-
DeveloperError : options and options.canvas are required.
Example:
// Create scene without anisotropic texture filtering
const scene = new Cesium.Scene({
canvas : canvas,
contextOptions : {
allowTextureFilterAnisotropic : false
}
});
See:
Members
Scene#logarithmicDepthBuffer 的默认值。
此属性依赖于支持 fragmentDepth。
atmosphere : Atmosphere
Scene#skyAtmosphere 混淆,后者负责渲染天空。
backgroundColor : Color
Scene#skyBox 为未定义时。
-
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
此值用于为多视锥体的每个视锥体创建近和远值。仅在 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
-
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
readonly postUpdate : Event
readonly preRender : Event
readonly preUpdate : Event
readonly primitives : PrimitiveCollection
readonly renderError : Event
render 函数内抛出错误时引发的事件。场景实例和抛出的错误是传递给事件处理程序的唯一两个参数。
默认情况下,错误在此事件引发后不会被再次抛出,但可以通过设置 rethrowRenderErrors 属性来更改。
true 时,仅在根据场景内的变化需要时才会渲染帧。
启用此选项将提高应用程序的性能,但需要在此模式下使用 Scene#requestRender
显式渲染新帧。在 API 的其他部分对场景进行更改后,在许多情况下这将是必要的。
-
Default Value:
false
See:
render 中发生的异常总是会被捕获,以便触发
renderError 事件。如果此属性为 true,在事件触发后会重新抛出错误。
如果此属性为 false,render 函数将在触发事件后正常返回。
-
Default Value:
false
readonly screenSpaceCameraController : ScreenSpaceCameraController
shadowMap : ShadowMap
skyAtmosphere : SkyAtmosphere
-
Default Value:
undefined
skyBox : SkyBox
SkyBox。
-
Default Value:
undefined
See:
true 如果支持镜面环境贴图。
sphericalHarmonicCoefficients : Array.<Cartesian3>
Sun。
-
Default Value:
undefined
-
Default Value:
true
terrainProvider : TerrainProvider
readonly terrainProviderChanged : Event
true 时,启用使用深度缓冲进行拾取。
-
Default Value:
true
true 时,将场景拆分为两个视口,左右眼具有立体视图。
用于纸板和 WebVR。
-
Default Value:
false
-
Default Value:
1.0
-
Default Value:
0.0
Methods
cartesianToCanvasCoordinates(position, result) → Cartesian2
| Name | Type | Description |
|---|---|---|
position |
Cartesian3 | 符卡尔坐标中的位置。 |
result |
Cartesian2 | optional 可选对象,用于返回转换为画布坐标的输入位置。 |
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 如果没有可夹紧到的场景几何。可以用于将对象夹紧到
地球、3D 瓦片或场景中的原始对象。
此函数仅夹紧到当前视图中渲染的地球瓦片和 3D 瓦片。仍然会夹紧到 所有其他原始对象,无论它们的可见性如何。
| Name | Type | Default | Description |
|---|---|---|---|
cartesian |
Cartesian3 | 笛卡尔位置。 | |
objectsToExclude |
Array.<Object> | optional 不用于夹紧的原始对象、实体或 3D 瓦片特征的列表。 | |
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>>
Scene#clampToHeight 查询,针对一组 Cartesian3 位置。
返回一个在查询完成时被解析的承诺。每个位置将在原地修改。
如果无法夹紧某个位置,因为该位置没有可用于采样的几何,或发生其他错误,则数组中的元素将被设置为未定义。
| Name | Type | Default | Description |
|---|---|---|---|
cartesians |
Array.<Cartesian3> | 要更新的笛卡尔位置,包含夹紧后的位置。 | |
objectsToExclude |
Array.<Object> | optional 不用于夹紧的原始对象、实体或 3D 瓦片特征的列表。 | |
width |
number |
0.1
|
optional 交叉体积的宽度,以米为单位。 |
Returns:
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:
| 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 过渡动画完成的时间,以秒为单位。 |
当选择 3D 瓦片集的一个特征时,pick 返回一个 Cesium3DTileFeature 对象。
| Name | Type | Default | Description |
|---|---|---|---|
windowPosition |
Cartesian2 | Window coordinates to perform picking on. | |
width |
number |
3
|
optional Width of the pick rectangle. |
height |
number |
3
|
optional Height of the pick rectangle. |
Returns:
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 | Description |
|---|---|---|
windowPosition |
Cartesian2 | 要进行拾取的窗口坐标。 |
schemaId |
string | undefined | 要从中拾取值的元数据模式的 ID。 如果此项为 `undefined`,则将从匹配给定类名和属性名称的对象中拾取值, 而不考虑模式 ID。 |
className |
string | 要从中拾取值的元数据类名称。 |
propertyName |
string | 要从中拾取值的元数据属性名称。 |
Returns:
Experimental
该功能尚未最终确定,可能会根据 Cesium 的标准弃用政策而发生变化
pickMetadataSchema(windowPosition) → MetadataSchema
| Name | Type | Description |
|---|---|---|
windowPosition |
Cartesian2 | 要进行拾取的窗口坐标。 |
Returns:
Experimental
该功能尚未最终确定,可能会根据 Cesium 的标准弃用政策而发生变化
pickPosition(windowPosition, result) → Cartesian3
从深度缓冲区在 2D 中重建的位置可能与在 3D 和哥伦布视图中重建的位置略有不同。 这是由于透视投影和正交投影的深度值分布的差异造成的。
设置 Scene#pickTranslucentDepth 为 true 以包括
半透明原始对象的深度;否则,这基本上是在半透明原始对象中进行拾取。
| Name | Type | Description |
|---|---|---|
windowPosition |
Cartesian2 | 要进行拾取的窗口坐标。 |
result |
Cartesian3 | optional 用于存储结果的对象。 |
Returns:
Throws:
-
DeveloperError : 不支持从深度缓冲区进行拾取。检查 pickPositionSupported。
pickVoxel(windowPosition, width, height) → VoxelCell|undefined
VoxelCell,
如果该位置未渲染任何体素,则返回未定义。
| Name | Type | Default | Description |
|---|---|---|---|
windowPosition |
Cartesian2 | 要进行拾取的窗口坐标。 | |
width |
number |
3
|
optional 拾取矩形的宽度。 |
height |
number |
3
|
optional 拾取矩形的高度。 |
Returns:
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 瓦片或场景中的原始对象。
此函数仅从当前视图中渲染的地球瓦片和 3D 瓦片采样高度。仍然会从所有其他 原始对象采样高度,无论它们的可见性如何。
| Name | Type | Default | Description |
|---|---|---|---|
position |
Cartographic | 要从中采样高度的地图位置。 | |
objectsToExclude |
Array.<Object> | optional 不用于采样高度的原始对象、实体或 3D 瓦片特征的列表。 | |
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>>
Scene#sampleHeight 查询,针对一组 Cartographic 位置。
输入位置的高度将被忽略。返回一个在查询完成时被解析的承诺。每个点的高度将在原地修改。
如果无法确定高度,因为该位置没有可用于采样的几何,或发生其他错误,则高度将被设置为未定义。
| Name | Type | Default | Description |
|---|---|---|---|
positions |
Array.<Cartographic> | 要更新的地图位置,包含采样后的高度。 | |
objectsToExclude |
Array.<Object> | optional 不用于采样高度的原始对象、实体或 3D 瓦片特征的列表。 | |
width |
number |
0.1
|
optional 交叉体积的宽度,以米为单位。 |
Returns:
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:
// 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}`);
});
