CesiumWidget.
contextOptionsParameter details:
The default value is:
{
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 can improve performance compared to the standard WebGL default value of true.
The other webgl properties match WebGLContextAttributes.'s WebGL default values.
allowTextureFilterAnisotropic is true by default, which allows anisotropic texture filtering when WebGL extensions are supported. Setting it to false can improve performance, but it will impair visual quality, especially for horizontal views.
| Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
The object has the following properties:
|
Throws:
-
DeveloperError : options Need to specify options, options.canvas.
Example:
//Create a scene.
var viewer=new new Cesium.Viewer('Container');
var scene = viewer.scene;
See:
Members
-
bloomEffect : BloomEffect
-
Get the floodlight effect of the scene, including floodlight intensity value, floodlight brightness threshold, etc.
-
readonlycamera : Camera
-
Get the camera object of the current scene.
-
Get the canvas element bound to the scene.
-
Create color correction objects
-
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 attribute is only used for debugging, not for production. When true, draw contour lines to show the range of the camera platform.
-
Default Value:
false -
The height of the GL drawing buffer.
See:
-
GL drawing buffer width.
See:
-
Get or set whether to draw the scene as a picture. When closed, draw directly to the color buffer, the picture effect is better, but some analysis functions are not available. The default value is true.
-
Whether to enable occlusion culling 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 shutter position of the current scene, the effective 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 the collection of all the stickers.
-
Whether to enable hdr in the current scene.
-
Default Value:
false -
Get the id of the current scene.
-
readonlyimageryLayers : ImageryLayerCollection
-
Get the current scene image layer collection.
-
Set or get the position of the image divider 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#invertClassificationistrue.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
-
Get the 3D oblique photogrammetric cache layer collection of the current scene.
-
Get the light source in the current scene.
-
Gets or sets whether to use the logarithmic depth buffer. When set to true, fewer truncated cones will be used in the hybrid multi-truncated cone. For details, please refer to the instructions on the Cesium official website.
-
readonlymapProjection : MapProjection
-
Get the map projection object, used in 2D or Columbus View mode, the default is latitude and longitude projection.
-
Default Value:
new GeographicProjection() -
Disable the depth test of billboards, labels and point objects by setting the camera viewing distance. For example, in order to prevent the terrain data from being cut, the depth test is always valid if the distance is set to 0, and the depth test is invalid 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 -
Get or set the multi-viewport mode of the current scene, the default is single-viewport.
-
Default Value:
0See:
-
Set the avoidance parameters of the layer. The parameter that can be set is: allowIconWithTextDisplay, set whether to enable the icon layer to follow the text layer to avoid. The default is true.
-
Turn on the vertex capture function, the default is false, set to true, then the capture is turned on.
-
Set the time interval for point cloud capture
-
Default Value:
200 -
When true, supports using the depth buffer to pick up semi-transparent geometry.
Scene#useDepthPickingmust also be true to support picking up the depth buffer. The performance is reduced during use. For semi-transparent geometric figures, additional drawing commands will be called to write depth.-
Default Value:
false -
readonlypostRender : Event
-
Get the event at the end of each frame of the current scene, and monitor the event to be triggered at the end of each frame.
-
readonlypreRender : Event
-
Get the event before each frame of the current scene is rendered, and listen for the event to be triggered before each frame is rendered.
-
readonlyprimitives : PrimitiveCollection
-
Get all primitive collections.
-
Get real-time rasterized objects.
-
readonlyscreenSpaceCameraController : ScreenSpaceCameraController
-
Get the camera operation object of the current scene.
-
shadowMap : ShadowMap
-
The shadow map in the scene. When enabled, the model, primitives, and earth can cast and receive shadows. By default, the light source of the shadow map is the sun.
-
skyBox : SkyBox
-
The
SkyBoxused to draw the stars.-
Default Value:
- Scene#backgroundColor
undefinedSee:
-
The url to the KTX file containing the specular environment map and convoluted mipmaps for image-based lighting of PBR models.
-
sphericalHarmonicCoefficients : Array.<Cartesian3>
-
The spherical harmonic coefficients for image-based lighting of PBR models.
-
sun : Sun
-
The
Sun.-
Default Value:
undefined -
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 in the current scene.
-
readonlyunderGlobe : UnderGlobe
-
Get the ground ball.
-
Get or set the depth of the underground scene, the default is 1000 meters (unit: meter).
-
Get or set whether to open the underground scene.
-
Default Value:
false -
Get or set the camera mode
-
Default Value:
WalkingMode.NONESee:
Methods
-
Add field data layer according to url path.
Name Type Description urlString The URL path of the field data. Returns:
Return 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 scene layer service.
Name Type Description urlString The URL path of the layer service. sceneNameString Scene name. layerNameString The layer name. -
addLightSource(lightSource) → Scene
-
Add a light source.
Name Type Description lightSourceLightSource light source. Returns:
The scene after adding a point light source. -
Add S3M grouping layer.
Name Type Description urlString The address of the configuration file published in the iserver. optionsObject The attribute object required by the layer. indexNumber Index. Returns:
Return promise asynchronous loading object -
Add 3D oblique photogrammetric cache layer (S3M, S3MB).
Name Type Description urlString The address of the configuration file published in the iserver. optionsObject optional The object has the following properties: Name Type Default Description subdomainsArray Used for subdomains, for example: ['t1','t2']. autoSetViewBoolean trueoptional Whether to automatically locate the scene nameString Specify the layer name. cullEnabledBoolean falseoptional Whether to cull the back side, the default is not cull, that is, double-sided rendering. indexNumber Index. Returns:
Return promise asynchronous loading 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; }); //Subdomain usage var config = { subdomainConfig: { urlScheme: "http://{s}.supermap.com:8090/iserver/services/3D-BIM/rest/realspace", subdomains: ['t1', 't2'] }, name: "BIM" }; var promise = scene.addS3MTilesLayerByScp('http://localhost:8090/iserver/services/3D-BIM/rest/realspace/datas/BIM/config', config); -
Add vector tile layer service. In order to ensure the stability of the version, the MVT layer created with this interface still maintains the original use and implementation method, but does not support the new interface in VectorTileMap. It is recommended to use the new implementation method addVectorTilesMap.
Name Type Description optionsObject The parameter object contains the following properties: Name Type Default Description urlString It is suitable for generating mvt data through SuperMap desktop software, which is published as rest style map service by iServer, only the service address is required. urlString The service address is applicable to WMTS services published by third parties. layerString The layer name is applicable to WMTS services published by third parties. canvasWidthNumber optional The side length of the texture used to draw the vector. The default is 512, the larger the finer, the smaller the higher the performance. tileWidthString The tile width is suitable for WMTS services released by third parties. tileHeightString The tile height is suitable for WMTS services released by third parties. formatString 'mvt'optional Applicable to WMTS services published by third parties. tilematrxsetString The name of the slicing matrix set is applicable to WMTS services published by third parties. maximumLevelNumber optional The maximum level of data. It is applicable to WMTS services published by third parties, and is calculated based on service parameters by default. minimumLevelNumber optional The smallest level of data. It is applicable to WMTS services published by third parties, and is calculated based on service parameters by default. mapboxStyleObject optional The mapBox style used. maximumTerrainLevelNumber optional The maximum terrain layer number that is allowed to load MVT layers (if not defined, all layers are loaded). minimumTerrainLevelNumber optional The minimum terrain layer number allowed to load MVT layers (if not defined, all layers are loaded). simplifyToleranceNumber optional The coordinate tolerance for geometric simplification, the unit is the slice coordinate system, and the value range is 0-4096. The larger the value, the more simplification is. The default is 0, no simplification. Example:
var layer = scene.addVectorTilesLayer({ url:"http://localhost:8090/iserver/services/map-mvt-test/....../maps/test"//地图服务 });See:
-
Create a new vector tile map.
Name Type Description optionsThe new map contains the following parameters: Name Type Default Description urlString It is suitable for generating mvt data through SuperMap desktop software, which is published as rest style map service by iServer, only the service address is required. layerString The layer name is applicable to WMTS services published by third parties. canvasWidthNumber optional The side length of the texture used to draw the vector. The default is 512, the larger the finer, the smaller the higher the performance. tileWidthString The tile width is suitable for WMTS services released by third parties. tileHeightString The tile height is suitable for WMTS services released by third parties. formatString 'mvt'optional Applicable to WMTS services published by third parties. tilematrxsetString The name of the slicing matrix set is applicable to WMTS services published by third parties. maximumLevelNumber optional The maximum level of data. It is applicable to WMTS services published by third parties, and is calculated based on service parameters by default. minimumLevelNumber optional The smallest level of data. It is applicable to WMTS services published by third parties, and is calculated based on service parameters by default. mapboxStyleObject optional The mapBox style used. maximumTerrainLevelNumber optional The maximum terrain layer number that is allowed to load MVT layers (if not defined, all layers are loaded). minimumTerrainLevelNumber optional The minimum terrain layer number allowed to load MVT layers (if not defined, all layers are loaded). labelScaleByDistanceNumber optional Set the text to scale with the distance. See:
-
cartesianToCanvasCoordinates(position, result) → Cartesian2
-
Convert 3D space coordinates to canvas coordinates (window coordinates).
Name Type Description positionCartesian3 3D spatial coordinates. resultCartesian2 optional Window coordinates, used to save the results. Returns:
Window coordinates.Example:
//The window coordinates with latitude and longitude (0,0) are output as 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
-
Clamps the given cartesian position to the scene geometry along the geodetic surface normal. Returns the clamped position or
undefinedif 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.
Name Type Default Description cartesianCartesian3 The cartesian position. objectsToExcludeArray.<Object> optional A list of primitives, entities, or 3D Tiles features to not clamp to. widthNumber 0.1optional Width of the intersection volume in meters. resultCartesian3 optional An optional object to return the clamped position. Returns:
The modified result parameter or a new Cartesian3 instance if one was not provided. This may beundefinedif 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.
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>>
-
Initiates an asynchronous
Scene#clampToHeightquery for an array ofCartesian3positions 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 cartesiansArray.<Cartesian3> The cartesian positions to update with clamped positions. objectsToExcludeArray.<Object> optional A list of primitives, entities, or 3D Tiles features to not clamp to. widthNumber 0.1optional Width of the intersection volume in meters. Returns:
A promise that resolves to the provided list of positions when the query has completed.Throws:
-
DeveloperError : clampToHeightMostDetailed is only supported in 3D mode.
-
DeveloperError : clampToHeightMostDetailed requires depth texture support. Check clampToHeightSupported.
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:
-
-
Whether the current scene supports texture compression format.
Name Type Description formatString Texture format. Format name or WebGL extension. For example: s3tc or WEBGL_compressed_texture_s3tc. Returns:
Whether the format is supported. -
Obtain the corresponding height according to the latitude and longitude coordinates.
Name Type Description lonNumber Longitude coordinates. latNumber Latitude coordinates. Returns:
Height value, unit: meter. -
Get the selected ID. What is returned is an array of objects, each object contains layer ID (layerID) and selected object ID (ids)
Returns:
id array -
Get the vector tile map according to the specified name.
Name Type Description nameString The name of the vector tile map Returns:
Map obtained -
getViewport(windowPosition) → BoundingRectangle
-
According to the window coordinates, get the current scene viewport.
Name Type Description windowPositionCartesian2 Window coordinates. Returns:
Viewport. -
Open all layers under iserver scene service
Name Type Description urlString Service url sceneNameString There are multiple scenes in the workspace, you need to specify the scene name; set to undefined, the first one is opened by default optionsObject optional The object has the following properties: Name Type Default Description subdomainsArray Used for subdomains, for example: ['t1','t2']. autoSetViewBoolean trueoptional Whether to automatically locate the scene Returns:
Return promise asynchronous loading objectExample:
var promise = scene.open('http://localhost:8090/iserver/services/3D-BIM3/rest/realspace'); promise.then(function(layers){}); //Subdomain and non-automatic positioning usage var promise = scene.open('http://{s}.supermap.com:8090/iserver/services/3D-BIM3/rest/realspace',undefined,{ subdomains: ['t1', 't2'],//子域 autoSetView : false //不自动定位 }); 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 +")"); }) -
Analyze PBR material parameters.
Example:
scene.parsePBRFromJson(urls); var conditions=[ ['${id}<=80',0], ['${id}<=90',1], ['${id}<=100',2], ]; -
Scene picking, returns the first primitive object corresponding to the window position in the scene, and returns undefined if there is no object at that position.
Name Type Default Description windowPositionCartesian2 Window coordinates. widthNumber 3optional Pick the rectangle width. heightNumber 3optional Pick the height of the rectangle. Returns:
The picked primitive object.Throws:
-
DeveloperError : windowPosition is undefined.
-
-
pickNormal(windowPosition) → Cartesian3
-
Used to pick up the normal, pass in the screen coordinates, and return to the normal. Combine the selected offset to achieve the effect of offset along the normal direction.
Name Type Description windowPositionCartesian2 Window coordinates to perform picking on. Picked screen coordinates. Returns:
Normal. The normal vector picked up; if the picked up is not an S3M model, it returns undefined. // -
pickPosition(windowPosition, result) → Cartesian3
-
Position picking, according to the window coordinates, pick the corresponding position from the depth buffer of the scene, and return to Cartesian coordinates. It needs to support depth texture.
Name Type Description windowPositionCartesian2 Window coordinates. resultCartesian3 optional Cartesian coordinates, save and return the result. Returns:
Returns the corresponding Cartesian coordinates (three-dimensional world coordinates).Throws:
-
DeveloperError : Picking from depth texture is not supported, please check pickPositionSupported. 2D is not supported. The orthogonal projection matrix is not invertible.
-
-
Window selection
Name Type Description startPointObject Box start point endPointObject Box end point Returns:
-
removeLightSource(lightSource) → Scene
-
Delete the light source.
Name Type Description lightSourceLightSource light source. Returns:
The scene after adding the light source. -
Remove the vector tile map with the specified name.
Name Type Description nameString Specify the name of the vector tile map to be removed. Returns:
-
Returns the height of scene geometry at the given cartographic position or
undefinedif 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.
Name Type Default Description positionCartographic The cartographic position to sample height from. objectsToExcludeArray.<Object> optional A list of primitives, entities, or 3D Tiles features to not sample height from. widthNumber 0.1optional Width of the intersection volume in meters. Returns:
The height. This may beundefinedif 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.
Example:
var position = new Cesium.Cartographic(-1.31968, 0.698874); var height = viewer.scene.sampleHeight(position); console.log(height);See:
-
-
Initiates an asynchronous
Scene#sampleHeightquery for an array ofCartographicpositions 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 positionsArray.<Cartographic> The cartographic positions to update with sampled heights. objectsToExcludeArray.<Object> optional A list of primitives, entities, or 3D Tiles features to not sample height from. widthNumber 0.1optional Width of the intersection volume in meters. Returns:
A promise that resolves to the provided list of positions when the query has completed.Throws:
-
DeveloperError : sampleHeightMostDetailed is only supported in 3D mode.
-
DeveloperError : sampleHeightMostDetailed requires depth texture support. Check sampleHeightSupported.
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. }See:
-
-
Set the display level control of MVT.
Name Type Description controlBoolean Whether to control the display level of MVT. levelNumber From the current perspective from near to far, the total number of levels displayed. For example, if it is set to 3, only the first three layers closest to the camera will be displayed, and the fourth and subsequent layers will not be displayed.
