CesiumWidget.
| 名称 Name | 类型 Type | 说明 Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
具有以下属性的对象: Object with the following properties:
|
抛出: Throws:
-
DeveloperError : options 和 options.canvas 是必需的。 : 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。 in newly constructed Scenes This property relies on fragmentDepth being supported.
-
默认值: Default Value:
false
atmosphere : Atmosphere
Scene#skyAtmosphere 它负责渲染天空。 which is responsible for rendering the sky.
backgroundColor : Color
Scene#skyBox is undefined.
-
默认值: Default Value:
Color.BLACK
另见: See:
readonly camera : Camera
-
默认值: Default Value:
false
true 如果 if the Scene#clampToHeight and Scene#clampToHeightMostDetailed 支持功能。 functions are supported.
-
默认值: Default Value:
true
确定执行哪些命令的函数。如下例所示,该函数接收命令的 A function that determines what commands are executed. As shown in the examples below, the function receives the command's owner 作为参数,并返回一个布尔值,指示是否应执行该命令。 as an argument, and returns a boolean indicating if the command should be executed.
默认为 The default is undefined,表示所有命令都已执行。 , indicating that all commands are executed.
-
默认值: 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;
};
When Scene.debugShowFrustums is true,这包含有关每个视锥体的命令执行数量统计信息的属性。 , this contains properties with statistics about the number of command execute per frustum.
totalCommands 是执行的命令总数,忽略重叠。 is the total number of commands executed, ignoring overlap. commandsInFrustums 是一个数组,其中包含命令冗余执行的次数,例如,有多少命令重叠两个或三个视锥体。 is an array with the number of times commands are executed redundantly, e.g., how many commands overlap two or three frustums.
-
默认值: Default Value:
undefined
When true,命令随机着色。这对于性能分析非常有用,可以查看场景或模型的哪些部分命令密集并且可以从批处理中受益。 , commands are randomly shaded. This is useful for performance analysis to see what parts of a scene or model are command-dense and could benefit from batching.
-
默认值: Default Value:
false
指示哪个视锥体将显示深度信息。 Indicates which frustum will have depth information displayed.
-
默认值: Default Value:
1
显示每秒帧数和帧之间的时间。 Displays frames per second and time between frames.
-
默认值: Default Value:
false
When true,绘制轮廓以显示相机视锥体的边界 , draws outlines to show the boundaries of the camera frustums
-
默认值: Default Value:
false
When true,命令根据它们重叠的截锥体进行着色。最近的视锥体中的命令为红色,次近的视锥体中的命令为绿色,最远的视锥体中的命令为蓝色。如果命令与多个视锥体重叠,则颜色分量将被组合,例如,与前两个视锥体重叠的命令被染成黄色。 , commands are shaded based on the frustums they overlap. Commands in the closest frustum are tinted red, commands in the next closest are green, and commands in the farthest frustum are blue. If a command overlaps more than one frustum, the color components are combined, e.g., a command overlapping the first two frustums is tinted yellow.
-
默认值: Default Value:
false
另见: See:
另见: See:
readonly ellipsoid : Ellipsoid
该值用于为多截锥体的每个截锥体创建近距值和远距值。它仅在以下情况下使用 This value is used to create the near and far values for each frustum of the multi-frustum. It is only used when Scene#logarithmicDepthBuffer is false。当 . When logarithmicDepthBuffer is
true, 使用 , use 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 将正常渲染。当 , 3D Tiles will render normally. When true,分类的 3D Tile 几何体将正常渲染,未分类的 3D Tile 几何体将使用颜色乘以 , classified 3D Tile geometry will render normally and unclassified 3D Tile geometry will render with the color multiplied by Scene#invertClassificationColor.
-
默认值: Default Value:
false
invertClassificationColor : Color
Scene#invertClassification is true.
当颜色的 Alpha 小于 1.0 时,3D 图块的未分类部分将无法与 3D 图块的分类位置正确混合。 When the color's alpha is less than 1.0, the unclassified portions of the 3D Tiles will not blend correctly with the classified positions of the 3D Tiles.
此外,当颜色的 alpha 小于 1.0 时,必须支持 WEBGL_depth_texture 和 EXT_frag_depth WebGL 扩展。 Also, when the color's alpha is less than 1.0, the WEBGL_depth_texture and EXT_frag_depth WebGL extensions must be supported.
-
默认值: Default Value:
Color.WHITE
另见: See:
readonly lastRenderTime : JulianDate|undefined
undefined
如果场景尚未渲染。 if the scene has not yet been rendered.
该值用于为多截锥体的每个截锥体创建近距值和远距值。它仅在以下情况下使用 This value is used to create the near and far values for each frustum of the multi-frustum. It is only used when Scene#logarithmicDepthBuffer is true。当 . When logarithmicDepthBuffer is
false, 使用 , use 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 is true,该值定义请求渲染之前允许的模拟时间的最大变化。较低的值会增加渲染的帧数,较高的值会减少渲染的帧数。如果 , this value defines the maximum change in simulation time allowed before a render is requested. Lower values increase the number of frames rendered and higher values decrease the number of frames rendered. If undefined,对模拟时间的更改永远不会请求渲染。该值会影响场景中变化(例如光照、实体属性更新和动画)的渲染速率。 , changes to the simulation time will never request a render. This value impacts the rate of rendering for changes in the scene like lighting, entity property updates, and animations.
-
默认值: 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 如果场景的上下文支持 MSAA。 if the Scene's context supports MSAA.
-
默认值: Default Value:
1.75e6
另见: See:
true,允许使用深度缓冲区拾取半透明几何体。请注意 , enables picking translucent geometry using the depth buffer. Note that Scene#useDepthPicking 也必须如此才能使其发挥作用。 must also be true for enabling this to work.
启用后性能会下降。有额外的绘制调用来写入半透明几何体的深度。 There is a decrease in performance when enabled. There are extra draw calls to write depth for translucent geometry.
-
默认值: 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
另见: See:
readonly preRender : Event
另见: See:
readonly preUpdate : Event
另见: See:
readonly primitives : PrimitiveCollection
readonly renderError : Event
render 功能。场景实例和抛出的错误是传递给事件处理程序的唯一两个参数。默认情况下,引发此事件后不会重新引发错误,但可以通过设置来更改 function. The Scene instance and the thrown error are the only two parameters passed to the event handler. By default, errors are not rethrown after this event is raised, but that can be changed by setting the rethrowRenderErrors property.
true,仅在需要时才会渲染帧,具体取决于场景内的变化。启用可提高应用程序的性能,但需要使用 , rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires using Scene#requestRender
在此模式下显式渲染新帧。在许多情况下,在 API 其他部分更改场景后,这是必要的。 to render a new frame explicitly in this mode. This will be necessary in many cases after making changes to the scene in other parts of the API.
-
默认值: Default Value:
false
另见: See:
render 总是被抓住以提高 are always caught in order to raise the
renderError 事件。如果此属性为 true,则在引发事件后将重新引发错误。如果该属性为 false,则 event. If this property is true, the error is rethrown after the event is raised. If this property is false, the render 函数在引发事件后正常返回。 function returns normally after raising the event.
-
默认值: Default Value:
false
true 如果 if the Scene#sampleHeight and Scene#sampleHeightMostDetailed 支持功能。 functions are supported.
readonly screenSpaceCameraController : ScreenSpaceCameraController
shadowMap : ShadowMap
skyAtmosphere : SkyAtmosphere|undefined
-
默认值: Default Value:
undefined
skyBox : SkyBox|undefined
SkyBox 用来画星星。 used to draw the stars.
-
默认值: Default Value:
undefined
另见: See:
true 是否支持镜面环境贴图。 if specular environment maps are supported.
另见: See:
sphericalHarmonicCoefficients : Array.<Cartesian3>
sun : Sun|undefined
Sun.
-
默认值: Default Value:
undefined
-
默认值: Default Value:
true
terrainProvider : TerrainProvider
readonly terrainProviderChanged : Event
true,允许使用深度缓冲区进行拾取。 , enables picking using the depth buffer.
-
默认值: Default Value:
true
true,将场景分成两个视口,为左眼和右眼提供立体视图。用于纸板和 WebVR。 , splits the scene into two viewports with steroscopic views for the left and right eyes. Used for cardboard and WebVR.
-
默认值: Default Value:
false
-
默认值: Default Value:
1.0
-
默认值: Default Value:
0.0
方法 Methods
cartesianToCanvasCoordinates(position, result) → Cartesian2|undefined
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
position |
Cartesian3 | 笛卡尔坐标中的位置。 The position in cartesian coordinates. |
result |
Cartesian2 | 可选 optional 一个可选对象,用于返回转换为画布坐标的输入位置。 An optional object to return the input position transformed to canvas coordinates. |
返回: Returns:
undefined 如果输入位置靠近椭球体的中心。 if the input position is near the center of the ellipsoid.
示例: 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或场景中的图元。 if there was no scene geometry to clamp to. May be used to clamp objects to the globe, 3D Tiles, or primitives in the scene.
此功能仅限制在当前视图中渲染的地球图块和 3D 图块。钳位到所有其他图元,无论其可见性如何。 This function only clamps to globe tiles and 3D Tiles that are rendered in the current view. Clamps to all other primitives regardless of their visibility.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
cartesian |
Cartesian3 | 笛卡尔位置。 The cartesian position. | |
objectsToExclude |
Array.<object> | 可选 optional 不钳制的图元、实体或 3D Tiles 功能的列表。 A list of primitives, entities, or 3D Tiles features to not clamp to. | |
width |
number |
0.1
|
可选 optional 交叉口体积的宽度(以米为单位)。 Width of the intersection volume in meters. |
result |
Cartesian3 | 可选 optional 用于返回夹紧位置的可选对象。 An optional object to return the clamped position. |
返回: Returns:
undefined 如果没有场景几何体可以夹紧。 if there was no scene geometry to clamp to.
抛出: Throws:
-
DeveloperError :clampToHeight 仅在 3D 模式下支持。 : clampToHeight is only supported in 3D mode.
-
DeveloperError :clampToHeight 需要深度纹理支持。检查clampToHeightSupported。 : 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(cartesians, objectsToExclude, width) → Promise.<Array.<(Cartesian3|undefined)>>
Scene#clampToHeight 查询数组 query for an array of Cartesian3 使用场景中 3D 图块集的最大细节级别进行定位。返回一个在查询完成时解决的承诺。每个位置都修改到位。如果某个位置由于无法在该位置采样几何体而无法夹紧,或者发生其他错误,则数组中的元素将设置为未定义。 positions using the maximum level of detail for 3D Tilesets in the scene. Returns a promise that is resolved when the query completes. Each position is modified in place. If a position cannot be clamped because no geometry can be sampled at that location, or another error occurs, the element in the array is set to undefined.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
cartesians |
Array.<Cartesian3> | 使用夹紧位置更新笛卡尔位置。 The cartesian positions to update with clamped positions. | |
objectsToExclude |
Array.<object> | 可选 optional 不钳制的图元、实体或 3D Tiles 功能的列表。 A list of primitives, entities, or 3D Tiles features to not clamp to. | |
width |
number |
0.1
|
可选 optional 交叉口体积的宽度(以米为单位)。 Width of the intersection volume in meters. |
返回: Returns:
undefined 如果无法夹紧。 if they cannot be clamped.
抛出: Throws:
-
DeveloperError :clampToHeightMostDetailed 仅在 3D 模式下受支持。 : clampToHeightMostDetailed is only supported in 3D mode.
-
DeveloperError :clampToHeightMostDetailed 需要深度纹理支持。检查clampToHeightSupported。 : 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:
一旦对象被销毁,就不应再使用;调用除 Once an object is destroyed, it should not be used; calling any function other than
isDestroyed 将导致 will result in a DeveloperError 例外。因此,分配返回值( exception. Therefore, assign the return value (undefined) 到对象,如示例中所做的那样。 ) to the object as done in the example.
抛出: Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
示例: Example:
scene = scene && scene.destroy();
另见: See:
primitive 属性,适用于特定窗口坐标位置的所有图元。还可以根据图元的类型来设置其他属性,并且可以使用其他属性来进一步识别所拾取的对象。列表中的图元按其在场景中的视觉顺序(从前到后)排序。 property, for all primitives at a particular window coordinate position. Other properties may also be set depending on the type of primitive and may be used to further identify the picked object. The primitives in the list are ordered by their visual order in the scene (front to back).
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取操作的窗口坐标。 Window coordinates to perform picking on. | |
limit |
number | 可选 optional 如果提供,请在收集这么多镐后停止钻孔。 If supplied, stop drilling after collecting this many picks. | |
width |
number |
3
|
可选 optional 选取矩形的宽度。 Width of the pick rectangle. |
height |
number |
3
|
可选 optional 选取矩形的高度。 Height of the pick rectangle. |
返回: 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。 The texture format. May be the name of the format or the WebGL extension name, e.g. s3tc or WEBGL_compressed_texture_s3tc. |
返回: Returns:
如果该对象被破坏,则不应使用它;调用除 If this object was destroyed, it should not be used; calling any function other than
isDestroyed 将导致 will result in a DeveloperError exception.
返回: Returns:
true 如果该物体被摧毁;否则, if this object was destroyed; otherwise, false.
另见: See:
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
duration |
number |
2.0
|
可选 optional 过渡动画完成所需的时间(以秒为单位)。 The amount of time, in seconds, for transition animations to complete. |
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
duration |
number |
2.0
|
可选 optional 过渡动画完成所需的时间(以秒为单位)。 The amount of time, in seconds, for transition animations to complete. |
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
duration |
number |
2.0
|
可选 optional 过渡动画完成所需的时间(以秒为单位)。 The amount of time, in seconds, for transition animations to complete. |
primitive 包含场景中特定窗口坐标处的第一个(顶部)基元的属性或 property that contains the first (top) primitive in the scene at a particular window coordinate or undefined 如果该位置没有任何东西。其他属性可能会根据基元的类型进行设置,并且可用于进一步识别拾取的对象。 if nothing is at the location. Other properties may potentially be set depending on the type of primitive and may be used to further identify the picked object.
当选择 3D Tiles 瓷砖集的某个功能时, When a feature of a 3D Tiles tileset is picked, pick 返回一个 returns a Cesium3DTileFeature object.
| 名称 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:
undefined 如果该位置没有任何东西。 if nothing is at the location.
示例: 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 | 用于执行拾取操作的窗口坐标。 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:
undefined 如果该位置没有任何东西。 if nothing is at the location.
示例: 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 | 用于执行拾取操作的窗口坐标。 Window coordinates to perform picking on. |
schemaId |
string | undefined |
要从中选取值的元数据架构的 ID。如果这是 The ID of the metadata schema to pick values from. If this is undefined,然后它将从对象中选取与给定类名称和属性名称匹配的值,而不管架构 ID。 , then it will pick the values from the object that match the given class- and property name, regardless of the schema ID. |
className |
string | 要从中选取值的元数据类的名称 The name of the metadata class to pick values from |
propertyName |
string | 要从中选取值的元数据属性的名称 The name of the metadata property to pick values from |
返回: Returns:
undefined 当在给定位置没有找到匹配的元数据时 when no matching metadata was found at the given position
实验性 Experimental
此功能不是最终版本,可能会在没有 Cesium 标准弃用政策的情况下进行更改。 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 | 用于执行拾取操作的窗口坐标。 Window coordinates to perform picking on. |
返回: Returns:
undefined 如果给定位置没有具有关联元数据的对象。 if there is no object with associated metadata at the given position.
实验性 Experimental
此功能不是最终版本,可能会在没有 Cesium 标准弃用政策的情况下进行更改。 This feature is not final and is subject to change without Cesium's standard deprecation policy.
pickPosition(windowPosition, result) → Cartesian3
从 2D 深度缓冲区重建的位置可能与 3D 和哥伦布视图中重建的位置略有不同。这是由于透视和正投影的深度值分布差异造成的。 The position reconstructed from the depth buffer in 2D may be slightly different from those reconstructed in 3D and Columbus view. This is caused by the difference in the distribution of depth values of perspective and orthographic projection.
Set Scene#pickTranslucentDepth to true 包括半透明图元的深度;否则,这本质上是通过半透明基元进行选择。 to include the depth of translucent primitives; otherwise, this essentially picks through translucent primitives.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
windowPosition |
Cartesian2 | 用于执行拾取操作的窗口坐标。 Window coordinates to perform picking on. |
result |
Cartesian3 | 可选 optional 要在其上恢复结果的对象。 The object on which to restore the result. |
返回: Returns:
抛出: Throws:
-
DeveloperError :不支持从深度缓冲区中选取。检查 pickPositionSupported。 : Picking from the depth buffer is not supported. Check pickPositionSupported.
pickVoxel(windowPosition, width, height) → VoxelCell|undefined
VoxelCell 对于在特定窗口坐标处渲染的体素样本,或者 for the voxel sample rendered at a particular window coordinate, or undefined 如果在该位置没有渲染体素。 if no voxel is rendered at that position.
| 名称 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:
undefined 如果在该位置没有渲染体素。 if no voxel is rendered at that position.
示例: 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 标准弃用政策的情况下进行更改。 This feature is not final and is subject to change without Cesium's standard deprecation policy.
CesiumWidget 会自动完成。 will do it automatically.
| 名称 Name | 类型 Type | 说明 Description |
|---|---|---|
time |
JulianDate | 可选 optional 渲染的模拟时间。 The simulation time at which to render. |
Scene#requestRenderMode 设置为 is set to true。渲染速率不会超过 . The render rate will not exceed the CesiumWidget#targetFrameRate.
另见: See:
undefined 如果没有场景几何体来采样高度。输入位置的高度将被忽略。可用于将对象固定到地球仪、3D Tiles或场景中的图元。 if there was no scene geometry to sample height from. The height of the input position is ignored. May be used to clamp objects to the globe, 3D Tiles, or primitives in the scene.
此函数仅对当前视图中渲染的地球图块和 3D 图块的高度进行采样。从所有其他图元的高度进行采样,无论其可见性如何。 This function only samples height from globe tiles and 3D Tiles that are rendered in the current view. Samples height from all other primitives regardless of their visibility.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
position |
Cartographic | 从制图位置到样本高度。 The cartographic position to sample height from. | |
objectsToExclude |
Array.<object> | 可选 optional 不从中采样高度的图元、实体或 3D Tiles 功能的列表。 A list of primitives, entities, or 3D Tiles features to not sample height from. | |
width |
number |
0.1
|
可选 optional 交叉口体积的宽度(以米为单位)。 Width of the intersection volume in meters. |
返回: Returns:
undefined 如果没有场景几何体来采样高度。 if there was no scene geometry to sample height from.
抛出: Throws:
-
DeveloperError :sampleHeight 仅在 3D 模式下支持。 : sampleHeight is only supported in 3D mode.
-
DeveloperError :sampleHeight 需要深度纹理支持。检查示例高度支持。 : 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|undefined)>>
Scene#sampleHeight 查询数组 query for an array of Cartographic 使用场景中 3D 图块集的最大细节级别进行定位。输入位置的高度被忽略。返回一个在查询完成时解决的承诺。每个点的高度都被适当修改。如果由于无法在该位置采样几何图形而无法确定高度,或者发生其他错误,则高度将设置为 positions using the maximum level of detail for 3D Tilesets in the scene. The height of the input positions is ignored. Returns a promise that is resolved when the query completes. Each point height is modified in place. If a height cannot be determined because no geometry can be sampled at that location, or another error occurs, the height is set to undefined.
| 名称 Name | 类型 Type | 默认值 Default | 说明 Description |
|---|---|---|---|
positions |
Array.<Cartographic> | 使用采样高度更新的制图位置。 The cartographic positions to update with sampled heights. | |
objectsToExclude |
Array.<object> | 可选 optional 不从中采样高度的图元、实体或 3D Tiles 功能的列表。 A list of primitives, entities, or 3D Tiles features to not sample height from. | |
width |
number |
0.1
|
可选 optional 交叉口体积的宽度(以米为单位)。 Width of the intersection volume in meters. |
返回: Returns:
undefined 如果无法确定高度。 if the height cannot be determined.
抛出: Throws:
-
DeveloperError :sampleHeightMostDetailed 仅在 3D 模式下受支持。 : sampleHeightMostDetailed is only supported in 3D mode.
-
DeveloperError :sampleHeightMostDetailed 需要深度纹理支持。检查示例高度支持。 : 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 | 地形提供者异步助手 The terrain provider async helper |
返回: 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}`);
});
