CesiumWidget
.
参数名称 | 类型 | 描述信息 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
object |
Object with the following properties:
|
Throws:
-
DeveloperError : options and options.canvas are required.
使用示例:
// Create scene without anisotropic texture filtering
const scene = new Cesium.Scene({
canvas : canvas,
contextOptions : {
allowTextureFilterAnisotropic : false
}
});
参考:
成员(属性)
Scene#logarithmicDepthBuffer
in newly constructed Scenes
This property relies on fragmentDepth being supported.
atmosphere : Atmosphere
Scene#skyAtmosphere
which is responsible for rendering the sky.
backgroundColor : Color
Scene#skyBox
is undefined.
-
默认值:
Color.BLACK
参考:
readonly camera : Camera
-
默认值:
false
true
if the Scene#clampToHeight
and Scene#clampToHeightMostDetailed
functions are supported.
-
默认值:
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.
-
默认值:
undefined
使用示例:
// 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.
-
默认值:
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.
-
默认值:
false
Indicates which frustum will have depth information displayed.
-
默认值:
1
Displays frames per second and time between frames.
-
默认值:
false
When true
, draws outlines to show the boundaries of the camera frustums
-
默认值:
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.
-
默认值:
false
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
.
-
默认值:
1000.0
-
默认值:
2.2
readonly groundPrimitives : PrimitiveCollection
-
默认值:
false
-
默认值:
true
readonly imageryLayers : ImageryLayerCollection
false
, 3D Tiles will render normally. When true
, classified 3D Tile geometry will render normally and
unclassified 3D Tile geometry will render with the color multiplied by Scene#invertClassificationColor
.
-
默认值:
false
invertClassificationColor : Color
Scene#invertClassification
is true
.
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.
Also, when the color's alpha is less than 1.0, the WEBGL_depth_texture and EXT_frag_depth WebGL extensions must be supported.
-
默认值:
Color.WHITE
true
if the Scene#invertClassification
is supported.
readonly lastRenderTime : JulianDate
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
.
-
默认值:
1e9
readonly mapMode2D : MapMode2D
readonly mapProjection : MapProjection
-
默认值:
new GeographicProjection()
- glGet with
ALIASED_LINE_WIDTH_RANGE
.
参考:
- glGet with
GL_MAX_CUBE_MAP_TEXTURE_SIZE
.
参考:
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.
-
默认值:
0.0
-
默认值:
SceneMode.SCENE3D
Moon
-
默认值:
undefined
morphComplete : Event
-
默认值:
Event()
morphStart : Event
-
默认值:
Event()
-
默认值:
1.0
-
默认值:
4
true
if the Scene's context supports MSAA.
-
默认值:
1.75e6
true
if the Scene#pickPosition
function is supported.
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.
-
默认值:
false
使用示例:
// 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
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
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.
-
默认值:
false
参考:
render
are always caught in order to raise the
renderError
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.
-
默认值:
false
readonly screenSpaceCameraController : ScreenSpaceCameraController
shadowMap : ShadowMap
skyAtmosphere : SkyAtmosphere
-
默认值:
undefined
skyBox : SkyBox
SkyBox
used to draw the stars.
-
默认值:
undefined
参考:
true
if specular environment maps are supported.
sphericalHarmonicCoefficients : Array.<Cartesian3>
Sun
.
-
默认值:
undefined
-
默认值:
true
terrainProvider : TerrainProvider
readonly terrainProviderChanged : Event
true
, enables picking using the depth buffer.
-
默认值:
true
true
, splits the scene into two viewports with steroscopic views for the left and right eyes.
Used for cardboard and WebVR.
-
默认值:
false
-
默认值:
1.0
-
默认值:
0.0
方法
cartesianToCanvasCoordinates(position, result) → Cartesian2
参数名称 | 类型 | 描述信息 |
---|---|---|
position |
Cartesian3 | The position in cartesian coordinates. |
result |
Cartesian2 | 可选 An optional object to return the input position transformed to canvas coordinates. |
返回值:
undefined
if the input position is near the center of the ellipsoid.
使用示例:
// 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
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.
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.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
cartesian |
Cartesian3 | The cartesian position. | |
objectsToExclude |
Array.<Object> | 可选 A list of primitives, entities, or 3D Tiles features to not clamp to. | |
width |
number |
0.1
|
可选 Width of the intersection volume in meters. |
result |
Cartesian3 | 可选 An optional object to return the clamped position. |
返回值:
undefined
if there was no scene geometry to clamp to.
Throws:
-
DeveloperError : clampToHeight is only supported in 3D mode.
-
DeveloperError : clampToHeight requires depth texture support. Check clampToHeightSupported.
使用示例:
// Clamp an entity to the underlying scene geometry
const position = entity.position.getValue(Cesium.JulianDate.now());
entity.position = viewer.scene.clampToHeight(position);
参考:
clampToHeightMostDetailed(cartesians, objectsToExclude, width) → Promise.<Array.<Cartesian3>>
Scene#clampToHeight
query for an array of Cartesian3
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.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
cartesians |
Array.<Cartesian3> | The cartesian positions to update with clamped positions. | |
objectsToExclude |
Array.<Object> | 可选 A list of primitives, entities, or 3D Tiles features to not clamp to. | |
width |
number |
0.1
|
可选 Width of the intersection volume in meters. |
返回值:
Throws:
-
DeveloperError : clampToHeightMostDetailed is only supported in 3D mode.
-
DeveloperError : clampToHeightMostDetailed requires depth texture support. Check clampToHeightSupported.
使用示例:
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];
}
参考:
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.
使用示例:
scene = scene && scene.destroy();
参考:
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
windowPosition |
Cartesian2 | Window coordinates to perform picking on. | |
limit |
number | 可选 If supplied, stop drilling after collecting this many picks. | |
width |
number |
3
|
可选 Width of the pick rectangle. |
height |
number |
3
|
可选 Height of the pick rectangle. |
返回值:
Throws:
-
DeveloperError : windowPosition is undefined.
使用示例:
const pickedObjects = scene.drillPick(new Cesium.Cartesian2(100.0, 200.0));
参考:
参数名称 | 类型 | 描述信息 |
---|---|---|
format |
string | The texture format. May be the name of the format or the WebGL extension name, e.g. s3tc or WEBGL_compressed_texture_s3tc. |
返回值:
If this object was destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception.
返回值:
true
if this object was destroyed; otherwise, false
.
参考:
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
duration |
number |
2.0
|
可选 The amount of time, in seconds, for transition animations to complete. |
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
duration |
number |
2.0
|
可选 The amount of time, in seconds, for transition animations to complete. |
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
duration |
number |
2.0
|
可选 The amount of time, in seconds, for transition animations to complete. |
When a feature of a 3D Tiles tileset is picked, pick
returns a Cesium3DTileFeature
object.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
windowPosition |
Cartesian2 | Window coordinates to perform picking on. | |
width |
number |
3
|
可选 Width of the pick rectangle. |
height |
number |
3
|
可选 Height of the pick rectangle. |
返回值:
使用示例:
// 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
参数名称 | 类型 | 描述信息 |
---|---|---|
windowPosition |
Cartesian2 | Window coordinates to perform picking on. |
schemaId |
string | undefined | The ID of the metadata schema to pick values from. If this is `undefined`, 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 |
返回值:
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
pickMetadataSchema(windowPosition) → MetadataSchema
参数名称 | 类型 | 描述信息 |
---|---|---|
windowPosition |
Cartesian2 | Window coordinates to perform picking on. |
返回值:
Experimental
This feature is not final and is subject to change without Cesium's standard deprecation policy.
pickPosition(windowPosition, result) → Cartesian3
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.
参数名称 | 类型 | 描述信息 |
---|---|---|
windowPosition |
Cartesian2 | Window coordinates to perform picking on. |
result |
Cartesian3 | 可选 The object on which to restore the result. |
返回值:
Throws:
-
DeveloperError : 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.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
windowPosition |
Cartesian2 | Window coordinates to perform picking on. | |
width |
number |
3
|
可选 Width of the pick rectangle. |
height |
number |
3
|
可选 Height of the pick rectangle. |
返回值:
使用示例:
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
will do it automatically.
参数名称 | 类型 | 描述信息 |
---|---|---|
time |
JulianDate | 可选 The simulation time at which to render. |
Scene#requestRenderMode
is set to true
.
The render rate will not exceed the CesiumWidget#targetFrameRate
.
undefined
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.
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.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
position |
Cartographic | The cartographic position to sample height from. | |
objectsToExclude |
Array.<Object> | 可选 A list of primitives, entities, or 3D Tiles features to not sample height from. | |
width |
number |
0.1
|
可选 Width of the intersection volume in meters. |
返回值:
undefined
if there was no scene geometry to sample height from.
Throws:
-
DeveloperError : sampleHeight is only supported in 3D mode.
-
DeveloperError : sampleHeight requires depth texture support. Check sampleHeightSupported.
使用示例:
const position = new Cesium.Cartographic(-1.31968, 0.698874);
const height = viewer.scene.sampleHeight(position);
console.log(height);
参考:
sampleHeightMostDetailed(positions, objectsToExclude, width) → Promise.<Array.<Cartographic>>
Scene#sampleHeight
query for an array of Cartographic
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.
参数名称 | 类型 | 默认值 | 描述信息 |
---|---|---|---|
positions |
Array.<Cartographic> | The cartographic positions to update with sampled heights. | |
objectsToExclude |
Array.<Object> | 可选 A list of primitives, entities, or 3D Tiles features to not sample height from. | |
width |
number |
0.1
|
可选 Width of the intersection volume in meters. |
返回值:
Throws:
-
DeveloperError : sampleHeightMostDetailed is only supported in 3D mode.
-
DeveloperError : sampleHeightMostDetailed requires depth texture support. Check sampleHeightSupported.
使用示例:
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.
}
参考:
setTerrain(terrain) → Terrain
参数名称 | 类型 | 描述信息 |
---|---|---|
terrain |
Terrain | The terrain provider async helper |
返回值:
使用示例s:
// 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}`);
});