CesiumWidget
隐式创建的。
contextOptions
parameter details:
The default values are:
{
webgl : {
alpha : false,
depth : true,
stencil : false,
antialias : true,
powerPreference: 'high-performance',
premultipliedAlpha : true,
preserveDrawingBuffer : false,
failIfMajorPerformanceCaveat : false
},
allowTextureFilterAnisotropic : true
}
The webgl
property corresponds to the WebGLContextAttributes
object used to create the WebGL context.
webgl.alpha
defaults to false, which can improve performance compared to the standard WebGL default
of true. If an application needs to composite Cesium above other HTML elements using alpha-blending, set
webgl.alpha
to true.
The other webgl
properties match the WebGL defaults for WebGLContextAttributes.
allowTextureFilterAnisotropic
defaults to true, which enables anisotropic texture filtering when the
WebGL extension is supported. Setting this to false will improve performance, but hurt visual quality, especially for horizon views.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | optional
具有以下属性的对象:
|
Throws:
-
DeveloperError :选项和选项.canvas是必需的。
Example:
// Create scene without anisotropic texture filtering
var scene = new Cesium.Scene({
canvas : canvas,
contextOptions : {
allowTextureFilterAnisotropic : false
}
});
See:
Members
backgroundColor : Color
Scene#skyBox
未定义。-
Default Value:
Color.BLACK
See:
readonly camera : Camera
-
Default Value:
false
-
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.
var 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
Displays depth information for the indicated frustum.
-
Default Value:
false
See:
See:
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
fog : Fog
-
Default Value:
2.2
globe : Globe
readonly groundPrimitives : PrimitiveCollection
-
Default Value:
true
-
Default Value:
true
readonly imageryLayers : ImageryLayerCollection
-
Default Value:
false
invertClassificationColor : Color
Scene#invertClassification
为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.
-
Default Value:
Color.WHITE
Scene#invertClassification
,则返回true
。readonly lastRenderTime : JulianDate
light : Light
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
为true
,则此值定义
请求渲染之前允许的模拟时间。较低的值会增加渲染的帧数
较高的值会减少渲染的帧数。如果是undefined
,则更改为
模拟时间永远不会请求渲染。
此值会影响场景中的更改(如照明、实体属性更新、,
和动画。-
Default Value:
0.0
See:
-
Default Value:
0.0
mode : SceneMode
-
Default Value:
SceneMode.SCENE3D
moon : Moon
-
Default Value:
undefined
morphComplete : Event
-
Default Value:
Event()
morphStart : Event
-
Default Value:
Event()
-
Default Value:
1.0
-
Default Value:
1.75e6
Scene#pickPosition
函数受支持,则返回true
。See:
true
时,启用使用深度缓冲区拾取半透明几何体。注意,Scene#useDepthPicking
也必须是真的,才能使其工作。
Render must be called between picks.
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) {
var pickedFeature = viewer.scene.pick(movement.position);
if (!Cesium.defined(pickedFeature)) {
// nothing picked
return;
}
viewer.scene.render();
var 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
函数内部引发错误时将引发的事件。
场景实例和抛出的错误是传递给事件处理程序的仅有的两个参数。
默认情况下,引发此事件后不会重新引发错误,但可以通过设置
rethrowRenderErrors
房产。true
时,渲染帧将仅在场景中的更改所确定的需要时发生。
启用可提高应用程序的性能,但需要使用Scene#requestRender
在此模式下显式渲染新帧。在许多情况下,在进行更改后,这是必需的
到API其他部分的场景。-
Default Value:
false
See:
render
中发生的异常总是被捕获,以便引发
renderError
事件。如果此属性为true,则错误为rethrown
在引发事件后。如果此属性为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 : Sun
Sun
。-
Default Value:
undefined
-
Default Value:
true
terrainProvider : TerrainProvider
readonly terrainProviderChanged : Event
true
时,使用深度缓冲启用拾取。-
Default Value:
true
true
时,将场景拆分为两个具有立体视图的视口,用于左眼和右眼。
用于纸板和网络虚拟现实。-
Default Value:
false
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.
var scene = widget.scene;
var ellipsoid = scene.globe.ellipsoid;
var position = Cesium.Cartesian3.fromDegrees(0.0, 0.0);
var 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平铺或基本体。
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 | 笛卡尔的位置。 | |
objectsToExclude |
Array.<Object> | optional 不钳制到的基本体、实体或三维平铺特征的列表。 | |
width |
Number |
0.1
|
optional 交叉口体积的宽度(米)。 |
result |
Cartesian3 | optional 返回夹紧位置的可选对象。 |
Returns:
undefined
。Throws:
-
DeveloperError :仅在3D模式下支持clampToHeight。
-
DeveloperError :claptoheight需要深度纹理支持。检查卡箍高度是否支持。
Example:
// Clamp an entity to the underlying scene geometry
var position = entity.position.getValue(Cesium.JulianDate.now());
entity.position = viewer.scene.clampToHeight(position);
See:
clampToHeightMostDetailed(cartesians, objectsToExclude, width) → Promise.<Array.<Cartesian3>>
Cartesian3
位置数组发起异步Scene#clampToHeight
查询
使用场景中三维平铺集的最大细节级别。返回在
查询完成。每个位置都会修改到位。如果由于没有几何图形而无法夹紧位置
可以在该位置采样,或者发生另一个错误,数组中的元素设置为未定义。Name | Type | Default | Description |
---|---|---|---|
cartesians |
Array.<Cartesian3> | 要使用钳制位置更新的笛卡尔位置。 | |
objectsToExclude |
Array.<Object> | optional 不钳制到的基本体、实体或三维平铺特征的列表。 | |
width |
Number |
0.1
|
optional 交叉口体积的宽度(米)。 |
Returns:
Throws:
-
DeveloperError :仅在3D模式下支持clampToHeightMostDetailed。
-
DeveloperError :clampToHeightMostDetailed需要深度纹理支持。检查卡箍高度是否支持。
Example:
var cartesians = [
entities[0].position.getValue(Cesium.JulianDate.now()),
entities[1].position.getValue(Cesium.JulianDate.now())
];
var promise = viewer.scene.clampToHeightMostDetailed(cartesians);
promise.then(function(updatedCartesians) {
entities[0].position = updatedCartesians[0];
entities[1].position = updatedCartesians[1];
}
See:
销毁此对象持有的WebGL资源。销毁一个对象允许确定性 释放WebGL资源,而不是依赖垃圾回收器销毁此对象。 一旦一个对象被销毁,就不应该使用它;调用除
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 :窗口位置未定义。
Example:
var 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 过渡动画完成的时间量(秒)。 |
When a feature of a 3D Tiles tileset is picked, pick
returns a Cesium3DTileFeature
object.
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) {
var feature = scene.pick(movement.endPosition);
if (feature instanceof Cesium.Cesium3DTileFeature) {
feature.color = Cesium.Color.YELLOW;
}
}, Cesium.ScreenSpaceEventType.MOUSE_MOVE);
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.
Name | Type | Description |
---|---|---|
windowPosition |
Cartesian2 | 要执行拾取的窗口坐标。 |
result |
Cartesian3 | optional 要在其上恢复结果的对象。 |
Returns:
Throws:
-
DeveloperError :不支持从深度缓冲区拾取。检查是否支持拾取位置。
CesiumWidget
或Viewer
自动执行。Name | Type | Description |
---|---|---|
time |
JulianDate | optional 要渲染的模拟时间。 |
undefined
要从中采样高度的场景几何体。忽略输入位置的高度。可用于夹持物体
场景中的球体、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 | 采样高度的制图位置。 | |
objectsToExclude |
Array.<Object> | optional 不从中采样高度的基本体、实体或三维分幅特征的列表。 | |
width |
Number |
0.1
|
optional 交叉口体积的宽度(米)。 |
Returns:
undefined
。Throws:
-
DeveloperError :sampleHeight仅在3D模式下受支持。
-
DeveloperError :sampleHeight需要深度纹理支持。检查支持的样本高度。
Example:
var position = new Cesium.Cartographic(-1.31968, 0.698874);
var height = viewer.scene.sampleHeight(position);
console.log(height);
See:
sampleHeightMostDetailed(positions, objectsToExclude, width) → Promise.<Array.<Cartographic>>
Cartographic
位置的数组启动异步Scene#sampleHeight
查询
使用场景中3D平铺集的最大细节级别。输入位置的高度将被忽略。
返回在查询完成时解析的承诺。每个点的高度都会进行适当的修改。
如果由于无法在该位置对几何体进行采样而无法确定高度,或者发生另一个错误,
高度设置为未定义。Name | Type | Default | Description |
---|---|---|---|
positions |
Array.<Cartographic> | 要随采样高度更新的地图位置。 | |
objectsToExclude |
Array.<Object> | optional 不从中采样高度的基本体、实体或三维分幅特征的列表。 | |
width |
Number |
0.1
|
optional 交叉口体积的宽度(米)。 |
Returns:
Throws:
-
DeveloperError :sampleHeightMostDetailed仅在3D模式下受支持。
-
DeveloperError :sampleHeightMostDetailed需要深度纹理支持。检查支持的样本高度。
Example:
var positions = [
new Cesium.Cartographic(-1.31968, 0.69887),
new Cesium.Cartographic(-1.10489, 0.83923)
];
var 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.
}