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
是一个数组,其次数
命令是冗余执行的,例如,有多少命令重叠 2 或
三个平截体。
-
Default Value:
undefined
如果为 true
,则命令会随机着色。 这很有用
用于性能分析,以查看场景或模型的哪些部分是
command-dense,并且可以从批处理中受益。
-
Default Value:
false
指示哪个视锥体将显示深度信息。
-
Default Value:
1
显示每秒帧数和帧之间的时间。
-
Default Value:
false
如果为 true
,则绘制轮廓以显示摄像机视锥体的边界
-
Default Value:
false
如果为 true
,则命令根据 frustums 进行着色
重叠。 最接近的 frustum 中的命令呈红色,命令
次近的命令为绿色,最远的视锥体中的命令为
蓝。 如果命令与多个视锥体重叠,则颜色分量
组合在一起,例如,与前两个视锥体重叠的命令会带有颜色
黄色。
-
Default Value:
false
See:
See:
readonly ellipsoid : Ellipsoid
此值用于为多视锥体的每个视锥体创建 near 和 far 值。它只被使用
当 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 瓦片将正常渲染。如果为 true
,则分类的 3D 瓦片几何体将正常渲染,并且
未分类的 3D 瓦片几何体将使用颜色乘以 Scene#invertClassificationColor
进行渲染。
-
Default Value:
false
invertClassificationColor : Color
Scene#invertClassification
为 true
时,未分类的 3D 瓦片几何体的高亮颜色。
当颜色的 Alpha 小于 1.0 时,3D 瓦片的未分类部分将无法与 3D 瓦片的分类位置正确混合。
此外,当颜色的 Alpha 小于 1.0 时,必须支持 WEBGL_depth_texture 和 EXT_frag_depth WebGL 扩展。
-
Default Value:
Color.WHITE
Scene#invertClassification
,则返回 true
。
readonly lastRenderTime : JulianDate
此值用于为多视锥体的每个视锥体创建 near 和 far 值。它只被使用
当 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
,则此值定义
在请求渲染之前允许的模拟时间。较低的值会增加渲染的帧数
的值越高,渲染的帧数就越少。如果未定义
,则更改为
模拟时间永远不会请求渲染。
此值会影响场景中更改的渲染速率,例如光照、实体属性更新、
和动画。
-
Default Value:
0.0
See:
-
Default Value:
0.0
-
Default Value:
SceneMode.SCENE3D
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
-
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
,则将场景分割为两个视口,分别具有左眼和右眼的立体视图。
用于 cardboard 和 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:
未定义
。
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 瓦片。Clamps 到 所有其他基元,无论其可见性如何。
Name | Type | Default | Description |
---|---|---|---|
cartesian |
Cartesian3 | 笛卡尔位置。 | |
objectsToExclude |
Array.<Object> | optional 不固定到的基元、实体或 3D 瓦片特征的列表。 | |
width |
number |
0.1
|
optional 交叉口体积的宽度,以米为单位。 |
result |
Cartesian3 | optional 一个可选的对象,用于返回被固定的位置。 |
Returns:
未定义
。
Throws:
-
DeveloperError : clampToHeight is only supported in 3D mode.
-
DeveloperError : clampToHeight requires depth texture support. Check 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(cartesian, objectsToExclude, width) → Promise.<Array.<Cartesian3>>
Cartesian3
位置数组启动异步 Scene#clampToHeight
查询
使用场景中 3D 瓦片集的最大细节级别。返回一个 Promise,该 Promise 在
查询完成。每个位置都进行了就地修改。如果由于没有几何体而无法夹紧位置
可以在该位置采样,否则会发生其他错误,则数组中的元素将设置为 undefined。
Name | Type | Default | Description |
---|---|---|---|
cartesian |
Array.<Cartesian3> | 笛卡尔位置,以使用夹紧位置进行更新。 | |
objectsToExclude |
Array.<Object> | optional 不固定到的基元、实体或 3D 瓦片特征的列表。 | |
width |
number |
0.1
|
optional 交叉口体积的宽度,以米为单位。 |
Returns:
Throws:
-
DeveloperError : clampToHeightMostDetailed is only supported in 3D mode.
-
DeveloperError : clampToHeightMostDetailed requires depth texture support. Check 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 is 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 过渡动画完成的时间量(以秒为单位)。 |
选取 3D 瓦片集的特征时,pick
返回 Cesium3DTileFeature
对象。
Name | Type | Default | Description |
---|---|---|---|
windowPosition |
Cartesian2 | 窗口坐标以执行选取。 | |
width |
number |
3
|
optional 拾取矩形的宽度。 |
height |
number |
3
|
optional 选取矩形的高度。 |
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);
pickMetadata(windowPosition, schemaId, className, propertyName) → MetadataValue|undefined
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
,以包含
半透明基元;否则,这基本上会选择 Translucent Primitives。
Name | Type | Description |
---|---|---|
windowPosition |
Cartesian2 | 窗口坐标以执行选取。 |
result |
Cartesian3 | optional 要恢复结果的对象。 |
Returns:
Throws:
-
DeveloperError : Picking from the depth buffer is not supported. Check pickPositionSupported.
pickVoxel(windowPosition, width, height) → VoxelCell|undefined
VoxelCell
,
或 undefined(如果在该位置未渲染体素)。
Name | Type | Default | Description |
---|---|---|---|
windowPosition |
Cartesian2 | 窗口坐标以执行选取。 | |
width |
number |
3
|
optional 拾取矩形的宽度。 |
height |
number |
3
|
optional 选取矩形的高度。 |
Returns:
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
此功能不是最终的,在没有 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:
未定义
。
Throws:
-
DeveloperError : sampleHeight is only supported in 3D mode.
-
DeveloperError : sampleHeight requires depth texture support. Check 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>>
Cartographic
位置数组启动异步 Scene#sampleHeight
查询
使用场景中 3D 瓦片集的最大细节级别。将忽略输入位置的高度。
返回在查询完成时解析的 Promise。每个点高度都已就地修改。
如果由于无法在该位置对几何体进行采样而无法确定高度,或者发生其他错误,
高度设置为 undefined。
Name | Type | Default | Description |
---|---|---|---|
positions |
Array.<Cartographic> | 要使用采样高度更新的制图位置。 | |
objectsToExclude |
Array.<Object> | optional 不从中采样高度的基元、实体或 3D 瓦片特征的列表。 | |
width |
number |
0.1
|
optional 交叉口体积的宽度,以米为单位。 |
Returns:
Throws:
-
DeveloperError : sampleHeightMostDetailed is only supported in 3D mode.
-
DeveloperError : sampleHeightMostDetailed requires depth texture support. Check 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}`);
});