CesiumWidget
.
contextOptions
parameter details:
The default values are:
{
webgl : {
alpha : false,
depth : true,
stencil : false,
antialias : true,
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
Object with the following properties:
|
Throws:
-
DeveloperError : options and options.canvas are required.
Example:
// Create scene without anisotropic texture filtering
var scene = new Cesium.Scene({
canvas : canvas,
contextOptions : {
allowTextureFilterAnisotropic : false
}
});
See:
Members
-
backgroundColor : Color
-
The background color, which is only visible if there is no sky box, i.e.,
Scene#skyBox
is undefined.-
Default Value:
Color.BLACK
See:
-
readonlycamera : Camera
-
Gets the camera.
-
Gets the canvas element to which this scene is bound.
-
Determines whether or not to instantly complete the scene transition animation on user input.
-
Default Value:
true
-
This property is for debugging only; it is not for production use.
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; };
-
This property is for debugging only; it is not for production use.
When
Scene.debugShowFrustums
istrue
, 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
-
This property is for debugging only; it is not for production use.
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
-
This property is for debugging only; it is not for production use.
Indicates which frustum will have depth information displayed.
-
Default Value:
1
-
This property is for debugging only; it is not for production use.
Displays frames per second and time between frames.
-
Default Value:
false
-
This property is for debugging only; it is not for production use.
When
true
, draws outlines to show the boundaries of the camera frustums-
Default Value:
false
-
This property is for debugging only; it is not for production use.
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
-
This property is for debugging only; it is not for production use.
Displays depth information for the indicated frustum.
-
Default Value:
false
-
The drawingBufferWidth of the underlying GL context.
See:
-
The drawingBufferHeight of the underlying GL context.
See:
-
The eye separation distance in meters for use with cardboard or WebVR.
-
The far-to-near ratio of the multi-frustum when using a normal depth buffer.
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
isfalse
. WhenlogarithmicDepthBuffer
istrue
, useScene#logarithmicDepthFarToNearRatio
.-
Default Value:
1000.0
-
The focal length for use when with cardboard or WebVR.
-
fog : Fog
-
Blends the atmosphere to geometry far from the camera for horizon views. Allows for additional performance improvements by rendering less geometry and dispatching less terrain requests.
-
When
true
, enables Fast Approximate Anti-aliasing even when order independent translucency is unsupported.-
Default Value:
true
-
globe : Globe
-
Gets or sets the depth-test ellipsoid.
-
readonlygroundPrimitives : PrimitiveCollection
-
Gets the collection of ground primitives.
-
Gets the unique identifier for this scene.
-
readonlyimageryLayers : ImageryLayerCollection
-
Gets the collection of image layers that will be rendered on the globe.
-
Gets or sets the position of the Imagery splitter within the viewport. Valid values are between 0.0 and 1.0.
-
When
false
, 3D Tiles will render normally. Whentrue
, classified 3D Tile geometry will render normally and unclassified 3D Tile geometry will render with the color multiplied byScene#invertClassificationColor
.-
Default Value:
false
-
invertClassificationColor : Color
-
The highlight color of unclassified 3D Tile geometry when
Scene#invertClassification
istrue
.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
-
readonlylastRenderTime : JulianDate
-
Gets the simulation time when the scene was last rendered. Returns undefined if the scene has not yet been rendered.
-
The far-to-near ratio of the multi-frustum when using a logarithmic depth buffer.
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
istrue
. WhenlogarithmicDepthBuffer
isfalse
, useScene#farToNearRatio
.-
Default Value:
1e9
-
Determines if the 2D map is rotatable or can be scrolled infinitely in the horizontal direction.
-
readonlymapProjection : MapProjection
-
Get the map projection to use in 2D and Columbus View modes.
-
Default Value:
new GeographicProjection()
-
The maximum aliased line width, in pixels, supported by this WebGL implementation. It will be at least one.
- glGet with
ALIASED_LINE_WIDTH_RANGE
.
See:
- glGet with
-
The maximum length in pixels of one edge of a cube map, supported by this WebGL implementation. It will be at least 16.
- glGet with
GL_MAX_CUBE_MAP_TEXTURE_SIZE
.
See:
- glGet with
-
If
Scene#requestRenderMode
istrue
, 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. Ifundefined
, 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.5
See:
-
The distance from the camera at which to disable the depth test of billboards, labels and points to, for example, prevent clipping against terrain. When set to zero, the depth test should always be applied. When less than zero, the depth test should never be applied. Setting the disableDepthTestDistance property of a billboard, label or point will override this value.
-
Default Value:
0.0
-
mode : SceneMode
-
Gets or sets the current mode of the scene.
-
Default Value:
SceneMode.SCENE3D
-
moon : Moon
-
The
Moon
-
Default Value:
undefined
-
morphComplete : Event
-
The event fired at the completion of a scene transition.
-
Default Value:
Event()
-
morphStart : Event
-
The event fired at the beginning of a scene transition.
-
Default Value:
Event()
-
The current morph transition time between 2D/Columbus View and 3D, with 0.0 being 2D or Columbus View and 1.0 being 3D.
-
Default Value:
1.0
-
Determines the uniform depth size in meters of each frustum of the multifrustum in 2D. If a primitive or model close to the surface shows z-fighting, decreasing this will eliminate the artifact, but decrease performance. On the other hand, increasing this will increase performance but may cause z-fighting among primitives close to the surface.
-
Default Value:
1.75e6
-
Gets whether or not the scene has order independent translucency enabled. Note that this only reflects the original construction option, and there are other factors that could prevent OIT from functioning on a given system configuration.
-
Returns true if the pickPosition function is supported.
-
When
true
, enables picking translucent geometry using the depth buffer. Note thatScene#useDepthPicking
must also be true for this enabling to work.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);
-
readonlypostRender : Event
-
Gets the event that will be raised immediately after the scene is rendered. Subscribers to the event receive the Scene instance as the first parameter and the current time as the second parameter.
-
readonlypostUpdate : Event
-
Gets the event that will be raised immediately after the scene is updated and before the scene is rendered. Subscribers to the event receive the Scene instance as the first parameter and the current time as the second parameter.
-
readonlypreRender : Event
-
Gets the event that will be raised after the scene is updated and immediately before the scene is rendered. Subscribers to the event receive the Scene instance as the first parameter and the current time as the second parameter.
-
readonlypreUpdate : Event
-
Gets the event that will be raised before the scene is updated or rendered. Subscribers to the event receive the Scene instance as the first parameter and the current time as the second parameter.
-
readonlyprimitives : PrimitiveCollection
-
Gets the collection of primitives.
-
readonlyrenderError : Event
-
Gets the event that will be raised when an error is thrown inside the
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 therethrowRenderErrors
property. -
When
true
, rendering a frame will only occur when needed as determined by changes within the scene. Enabling improves performance of the application, but requires usingScene#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.-
Default Value:
false
See:
-
Exceptions occurring in
render
are always caught in order to raise therenderError
event. If this property is true, the error is rethrown after the event is raised. If this property is false, therender
function returns normally after raising the event.-
Default Value:
false
-
Gets whether or not the scene is optimized for 3D only viewing.
-
readonlyscreenSpaceCameraController : ScreenSpaceCameraController
-
Gets the controller for camera input handling.
-
shadowMap : ShadowMap
-
The shadow map in the scene. When enabled, models, primitives, and the globe may cast and receive shadows. By default the light source of the shadow map is the sun.
-
skyAtmosphere : SkyAtmosphere
-
The sky atmosphere drawn around the globe.
-
Default Value:
undefined
-
skyBox : SkyBox
-
The
SkyBox
used to draw the stars.-
Default Value:
undefined
See:
-
sun : Sun
-
The
Sun
.-
Default Value:
undefined
-
Uses a bloom filter on the sun when enabled.
-
Default Value:
true
-
Gets the scalar used to exaggerate the terrain.
-
terrainProvider : TerrainProvider
-
The terrain provider providing surface geometry for the globe.
-
readonlyterrainProviderChanged : Event
-
Gets an event that's raised when the terrain provider is changed
-
When
true
, enables picking using the depth buffer.-
Default Value:
true
-
When
true
, splits the scene into two viewports with steroscopic views for the left and right eyes. Used for cardboard and WebVR.-
Default Value:
false
Methods
-
cartesianToCanvasCoordinates(position, result) → Cartesian2
-
Transforms a position in cartesian coordinates to canvas coordinates. This is commonly used to place an HTML element at the same screen position as an object in the scene.
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:
The modified result parameter or a new Cartesian2 instance if one was not provided. This may beundefined
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. 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);
-
Instantly completes an active transition.
-
Destroys the WebGL resources held by this object. Destroying an object allows for deterministic release of WebGL resources, instead of relying on the garbage collector to destroy this object.
Once an object is destroyed, it should not be used; calling any function other thanisDestroyed
will result in aDeveloperError
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:
-
-
Returns a list of objects, each containing a `primitive` property, for all primitives at a particular window coordinate position. Other properties may also be set depending on the type of primitive. The primitives in the list are ordered by their visual order in the scene (front to back).
Name Type Description windowPosition
Cartesian2 Window coordinates to perform picking on. limit
Number optional If supplied, stop drilling after collecting this many picks. Returns:
Array of objects, each containing 1 picked primitives.Throws:
-
DeveloperError : windowPosition is undefined.
Example:
var pickedObjects = scene.drillPick(new Cesium.Cartesian2(100.0, 200.0));
-
-
Determines if a compressed texture format is supported.
Name Type Description 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. Returns:
Whether or not the format is supported. -
Returns true if this object was destroyed; otherwise, false.
If this object was destroyed, it should not be used; calling any function other thanisDestroyed
will result in aDeveloperError
exception.Returns:
true
if this object was destroyed; otherwise,false
.See:
-
Asynchronously transitions the scene to 2D.
Name Type Default Description duration
Number 2.0
optional The amount of time, in seconds, for transition animations to complete. -
Asynchronously transitions the scene to 3D.
Name Type Default Description duration
Number 2.0
optional The amount of time, in seconds, for transition animations to complete. -
Asynchronously transitions the scene to Columbus View.
Name Type Default Description duration
Number 2.0
optional The amount of time, in seconds, for transition animations to complete. -
Returns an object with a `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.
When a feature of a 3D Tiles tileset is picked,
pick
returns aCesium3DTileFeature
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:
Object containing the picked primitive.Throws:
-
DeveloperError : windowPosition is undefined.
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
-
Returns the cartesian position reconstructed from the depth buffer and window position.
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
totrue
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:
The cartesian position.Throws:
-
DeveloperError : Picking from the depth buffer is not supported. Check pickPositionSupported.
-
-
Requests a new rendered frame when
Scene#requestRenderMode
is set totrue
. The render rate will not exceed theCesiumWidget#targetFrameRate
.