CesiumWidget
.
contextOptions
参数详细信息:
默认值为:
{
webgl : {
alpha : false,
depth : true,
stencil : false,
antialias : true,
premultipliedAlpha : true,
preserveDrawingBuffer : false,
failIfMajorPerformanceCaveat : false
},
allowTextureFilterAnisotropic : true
}
The webgl attribute corresponds to the WebGLContextAttributes object used to create the WebGL environment.
Webgl.alpha defaults to false, which improves performance compared to the standard WebGL default value of true.
Other webgl attributes match the WebGL default values of WebGLContextAttributes.
allowTextureFilterAnisotropic defaults to true, which allows anisotropic texture filtering when WebGL extensions are supported. Setting to false improves performance but can compromise visual quality, especially for horizontal views.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
The object has the following properties:
|
Throws:
-
DeveloperError : options needs to specify options, options.canvas.
Example:
//Create a scene.
var viewer=new new Cesium.Viewer('Container');
var scene = viewer.scene;
See:
Members
-
readonlycamera : Camera
-
Get the camera object of the current scene.
-
Get the canvas element bound by the scene.
-
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 and not for production. When true, the outline is drawn to show the extent of the camera platform.
-
Default Value:
false
-
GL draws the buffer height.
See:
-
GL draws the buffer width.
See:
-
Whether occlusion culling is enabled in the current scene.
-
Default Value:
true
-
The eye separation distance in meters for use with cardboard or WebVR.
-
The focal length for use when with cardboard or WebVR.
-
globe : Globe
-
Get the Earth object.
-
globeSplitPosition : Cartesian2
-
Set or get the rollover position of the current scene. The valid value is 0.0~1.0. Gets or sets the position of the globe splitter within the viewport. Valid values are between 0.0 and 1.0.
-
readonlygroundPrimitives : PrimitiveCollection
-
Get all the collection of map features.
-
Whether hdr is enabled in the current scene.
-
Default Value:
true
-
Get the id of the current scene.
-
readonlyimageryLayers : ImageryLayerCollection
-
Get the current scene image layer collection.
-
Sets or retrieves the image divider position of the current scene.
-
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
-
readonlylayers : Layers
-
Gets the collection of 3D tile cache layers for the current scene.
-
Get the light source in the current scene.
-
readonlymapProjection : MapProjection
-
Get map projection object for 2D or Columbus View mode, default is latitude and longitude projection.
-
Default Value:
new GeographicProjection()
-
Depth testing of billboards, tags, and point objects is prohibited by setting the camera viewing distance. For example, to prevent clipping of terrain data, the depth test is always valid when the distance is set to 0, and the depth test is disabled if the distance is set to less than 0. Modify the distance value by setting the disableDepthTestDistance property of the billboard, label, and point object.
-
Default Value:
0.0
-
mode : SceneMode
-
Get the mode of the current scene.
-
Default Value:
SceneMode.SCENE3D
-
Gets or sets the multi-view mode of the current scene, the default single viewport.
-
Default Value:
0
-
When true, the use of depth buffers to pick up translucent geometry is supported.
Scene#useDepthPicking
must also be true to support picking depth buffers. Performance is degraded during use, and for translucent geometry, additional drawing commands are called to write depth.-
Default Value:
false
-
readonlypostRender : Event
-
Gets the event at the end of each frame of the current scene, and listens for this event to fire at the end of each frame.
-
readonlypreRender : Event
-
Gets the event before each frame of the current scene, and listens to the event before each frame is rendered.
-
readonlyprimitives : PrimitiveCollection
-
Get all the collection of primitives.
-
readonlyscreenSpaceCameraController : ScreenSpaceCameraController
-
Get the camera operation object of the current scene.
-
shadowMap : ShadowMap
-
The shadow map in the scene. When enabled, models, primitives, and Earth can cast and receive shadows. By default, the source of the shadow map is the sun.
-
terrainProvider : TerrainProvider
-
Gets or sets the terrain service provider object of the current scene.
-
readonlyterrainProviderChanged : Event
-
Get the current scene terrain service provider change event.
-
Whether to enable toneMapping for the current scene.
-
Get or set the depth of the underground scene, the default is 1000 meters (unit: meter).
-
Gets or sets whether to open the underground scene.
-
Default Value:
false
Methods
-
Add a field data layer based on the url path.
Name Type Description url
String The url path of the farm data. Returns:
Return to the field data layer FieldLayer3D and create the field layer object asynchronously.Example:
var promise = viewer.scene.addFieldLayer("../data.nc"); Cesium.when(promise,function(fieldLayer){ fieldLayer.particleVelocityFieldEffect.velocityScale = 100.0; fieldLayer.particleVelocityFieldEffect.particleSize = 2; fieldLayer.particleVelocityFieldEffect.paricleCountPerDegree = 1.5; scene.primitives.add(fieldLayer); fieldLayer.particleVelocityFieldEffect.colorTable = colorTable; var options = { longitude:'lon', latitude:'lat', uwnd:'uwnd', vwnd:'uwnd' } fieldLayer.NetCDFData = options; })
-
Add a scene layer service.
Name Type Description url
String The url path of the layer service. sceneName
String The name of the scene. layerName
String The layer name. -
addLightSource(lightSource) → Scene
-
Add a light source.
Name Type Description lightSource
LightSource light source. Returns:
The scene after adding a point source. -
Add an S3M grouping layer.
Name Type Description url
String The configuration file address published in the iserver. options
Object The required attribute object for the layer. index
Number index. Returns:
Return promise asynchronous load object -
Add a 3D tile cache layer (S3M, S3MB).
Name Type Default Description url
String The configuration file address published in the iserver. options
Object The required attribute object for the layer. index
Number index. options.name
String The layer name. options.cullEnabled
Boolean true
optional Whether it is double-sided rendering (back culling), the default is single-sided, that is, the back side is removed. Returns:
Return promise asynchronous load objectExample:
var promise = scene.addS3MTilesLayerByScp('http://localhost:8090/iserver/services/3D-zj/rest/realspace/datas/zj/config', {name : 'base'}); promise.then(function(layer){ layer.visible = false; });
-
cartesianToCanvasCoordinates(position, result) → Cartesian2
-
Convert 3D space coordinates to canvas coordinates (window coordinates).
Name Type Description position
Cartesian3 Three-dimensional space coordinates. result
Cartesian2 optional Window coordinates, used to save the results. Returns:
Window coordinates.Example:
//As the mouse moves, the window coordinates of latitude and longitude (0, 0) are output. 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);
-
Whether the current scene supports the texture compression format.
Name Type Description format
String Texture format. Format name or WebGL extension. For example: s3tc or WEBGL_compressed_texture_s3tc. Returns:
Whether the format is supported. -
The corresponding height is obtained according to the latitude and longitude coordinates.
Name Type Description lon
Number Longitude coordinates. lat
Number Latitude coordinates. Returns:
Height value in meters. -
getViewport(windowPosition) → BoundingRectangle
-
Gets the current scene viewport based on the window coordinates.
Name Type Description windowPosition
Cartesian2 Window coordinates. Returns:
Viewport. -
Open all layers under the iserver scene service.
Name Type Description url
String Service url. Returns:
Returns the promise asynchronous load object.Example:
var promise = scene.open('http://localhost:8090/iserver/services/3D-BIM3/rest/realspace'); promise.then(function(layers){});
-
Output the current scene to Base64 encoding.
Returns:
Holds a base64 encoded asynchronous object.Example:
var promise = scene.outputSceneToFile(); Cesium.when(promise,function(base64data){ $("#ID").css("background","url(" + base64data +")"); })
-
Scene picking returns the first primitive object corresponding to the window position in the scene, and returns undefined if there is no object at the position.
Name Type Default Description windowPosition
Cartesian2 Window coordinates. width
Number 3
optional Pick the width of the rectangle. height
Number 3
optional Pick the height of the rectangle. Returns:
The primitive object picked up.Throws:
-
DeveloperError : windowPosition is undefined.
-
-
pickPosition(windowPosition, result) → Cartesian3
-
Position picking, according to the window coordinates, picks up the corresponding position from the depth buffer of the scene, returns the Cartesian coordinates, and needs to support the depth texture.
Name Type Description windowPosition
Cartesian2 Window coordinates. result
Cartesian3 optional Cartesian coordinates, save the returned results. Returns:
Returns the corresponding Cartesian coordinates (3D world coordinates).Throws:
-
DeveloperError : Picking from deep textures is not supported, please check pickPositionSupported. 2D is not supported. The orthogonal projection matrix is irreversible.
-
-
removeLightSource(lightSource) → Scene
-
Delete the light source.
Name Type Description lightSource
LightSource light source. Returns:
The scene after adding the light source.