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 Need to specify options, options.canvas。
Example:
/create a scene
var viewer=new new SuperMap3D.Viewer('Container');
var scene = viewer.scene;
See:
Members
-
bloomEffect : BloomEffect
-
Obtain the bloom effect of the scene, including the bloom intensity value, bloom brightness threshold, etc.
-
readonlycamera : Camera
-
Get the camera object of the current scene.
-
Get the canvas element bound to the scene.
-
Create a color correction object
-
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 only for debugging, not for production. When true, outlines are drawn to show the range of the camera platform.
-
Default Value:
false -
depthOfFieldEffect : DepthOfFieldEffect
-
Gets the depth of field effect of the scene.
-
GL draw buffer height.
See:
-
GL draw buffer width.
See:
-
Get or set whether to draw the scene as a picture. When off, draws directly to the color buffer for better visuals, but some analysis features 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.
-
Set the viewing frustum tolerance value, the default value is 0.0, and the maximum value is 0.5
-
Default Value:
0.0 -
globe : Globe
-
Get the Earth object.
-
globeSplitPosition : Cartesian2
-
Gets or sets the position of the globe splitter within the viewport. Valid values are between 0.0 and 1.0.
-
readonlygroundPrimitives : PrimitiveCollection
-
Get a collection of all textured primitives.
-
Whether to enable hdr in the current scene.
-
Default Value:
false -
Get the id of the current scene.
-
readonlyimageryLayers : ImageryLayerCollection
-
Get the image layer collection of the current scene.
-
Set or get 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#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 tile cache layer collection of the current scene.
-
lightSource : LightSource
-
Get the light source in the current scene.
-
Get or set whether to use logarithmic depth buffer. When set to true, fewer truncated cones will be used in the mixed multi-truncated cones. For details, please refer to the description on Cesium's 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 depth testing of billboards, labels and point objects by setting the camera view distance. For example, to prevent terrain data from being clipped, if the distance is set to 0, the depth test will always be valid, and if the distance is set to less than 0, the depth test will be disabled. Modify the distance value by setting the disableDepthTestDistance property of the billboard, label and point objects.
-
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:
-
originOffset : Cartesian2
-
Set degree band offset, load map with degree band offset
-
Set the avoidance parameters of the layer. The parameters that can be set are: allowIconWithTextDisplay, set whether to enable the icon layer to follow the text layer to avoid. The default is true.
-
Enable the vertex capture function, the default is false, set it to true, then the capture is enabled.
-
Set the time interval for point cloud capture
-
Default Value:
200 -
When true, supports picking semi-transparent geometry using the depth buffer.
Scene#useDepthPickingmust also be true to support picking the depth buffer. There is a performance penalty when used, and for semi-transparent geometry, additional drawing commands will be invoked to write depth.-
Default Value:
false -
postProcessStages : PostProcessStageCollection
-
Post-processing effects applied to the final rendering.
-
readonlypostRender : Event
-
Get the event at the end of each frame rendering of the current scene, and listen to the event to be triggered at the end of each frame rendering.
-
readonlypreRender : Event
-
Get the event before each frame of the current scene is rendered, and listen to the event to be triggered before each frame is rendered.
-
readonlyprimitives : PrimitiveCollection
-
Get a collection of all primitives.
-
Get the real-time rasterized object.
-
scanEffect : ScanEffect
-
Get the scanline effect of the scene.
-
readonlyscreenSpaceCameraController : ScreenSpaceCameraController
-
Get the camera operation object of the current scene.
-
shadowMap : ShadowMap
-
Shadow maps in the scene. When enabled, models, primitives, and globes can cast and receive shadows. By default, the light source for shadow maps 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 -
sunlightAnalysis : SunlightAnalysis
-
Get sunlight analysis.
-
terrainProvider : TerrainProvider
-
Get or set 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.
-
Get or set the overall brightness of the PBR material model.
-
Default Value:
1.0 -
readonlyunderGlobe : UnderGlobe
-
Get the underground 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 camera mode
-
Default Value:
WalkingMode.NONESee:
-
Get or set the sharpness of water surface reflection, the smaller the value, the more blurred the reflection.
-
Default Value:
5.0
Methods
-
Add field data layer according to url path.
Name Type Description urlString The url path of field data. Returns:
Return the field data layer FieldLayer3D, and create a field layer object asynchronously.Return the field data layer FieldLayer3D, and create a field layer object asynchronously.Example:
var promise = viewer.scene.addFieldLayer("../data.nc"); SuperMap3D.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 urlString The url path of the layer service. sceneNameString Scene name. layerNameString layer name. -
addLightSource(lightSource) → Scene
-
Add a light source.
Name Type Description lightSourceLightSource light source. Returns:
The scene after adding a point light. -
Add S3M grouping layer.
Name Type Description urlString The address of the configuration file published in iserver. optionsObject The property object required by the layer. indexNumber Index Returns:
Return promise to load object asynchronously -
Add 3D tile layers (S3M, S3MB).
Name Type Description urlString The address of the configuration file published in iserver. optionsObject optional The object has the following properties: Name Type Default Description subdomainsArray For subdomains, eg: ['t1','t2']. nameString Specify a layer name. cullEnabledBoolean falseoptional Whether to cull the back side, the default is no cull, that is, double-sided rendering. indexNumber Index Returns:
Return promise to load object asynchronouslyExample:
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; }); //子域用法 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); -
Added vector tile layer service. In order to ensure the stability of the version, the MVT layer created by using this interface still maintains the original use and implementation method, but it 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, and publishing it as a rest-style map service through iServer, and only needs to provide the service address. urlString Service address, applicable to WMTS services published by third parties. layerString Layer name, suitable for WMTS services published by third parties. canvasWidthNumber optional The side length of the texture used to draw vectors. The default is 512, the larger the finer, the smaller the higher the performance. tileWidthString Tile width, suitable for WMTS services published by third parties. tileHeightString Tile height, suitable for WMTS services published by third parties. formatString 'mvt'optional Applicable to WMTS services published by third parties. tilematrxsetString The name of the slice matrix set, applicable to WMTS services published by third parties. maximumLevelNumber optional The maximum level of data. Applicable to WMTS services published by third parties, calculated based on service parameters by default. minimumLevelNumber optional The smallest level of data. Applicable to WMTS services published by third parties, calculated based on service parameters by default. mapboxStyleObject optional The mapBox style to use. maximumTerrainLevelNumber optional Maximum terrain layer number allowed to load MVT layers (if undefined all layers are loaded). minimumTerrainLevelNumber optional Minimum terrain layer number allowed to load MVT layers (if undefined all layers are loaded). simplifyToleranceNumber optional 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 powerful the simplification, the default is 0, no simplification. viewerObject optional Sets the globe that will be added to 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 optionsA new map contains the following parameters: Name Type Default Description urlString It is suitable for generating mvt data through SuperMap desktop software, and publishing it as a rest-style map service through iServer, and only needs to provide the service address. layerString Layer name, suitable for WMTS services published by third parties. canvasWidthNumber optional The side length of the texture used to draw vectors. The default is 512, the larger the finer, the smaller the higher the performance. tileWidthString Tile width, suitable for WMTS services published by third parties. tileHeightString Tile height, suitable for WMTS services published by third parties. formatString 'mvt'optional Applicable to WMTS services published by third parties. tilematrxsetString The name of the slice matrix set, applicable to WMTS services published by third parties. maximumLevelNumber optional The maximum level of data. Applicable to WMTS services published by third parties, calculated based on service parameters by default. minimumLevelNumber optional The smallest level of data. Applicable to WMTS services published by third parties, calculated based on service parameters by default. mapboxStyleObject optional The mapBox style to use. maximumTerrainLevelNumber optional Maximum terrain layer number allowed to load MVT layers (if undefined all layers are loaded). minimumTerrainLevelNumber optional Minimum terrain layer number allowed to load MVT layers (if undefined all layers are loaded). labelScaleByDistanceNumber optional Set text to scale with distance. customRequestHeadersObject optional Set custom request headers. realtimeBoolean optional Set whether to rasterize in real time. swipeEnabledBoolean optional Set whether to roll the blind. swipeRegionObject optional Set the shutter area. billboardModeBillboardMode optional Set the text label style. labelDepthTestEnabledBoolean optional It is used to control whether the MVT text/icon should do depth detection. The default is true, and the depth detection is enabled, otherwise, the depth detection is turned off. viewerObject optional Sets the globe that will be added. localIdeographFontFamilyBoolean optional Whether the MVT text annotation should be set to the default font. subdomainsArray | String Multiple subdomains. When the input parameter is an Array, it supports loading multiple subdomains. When the input parameter is a String, it only supports loading a single subdomain. crsString Supports loading data under the third-party coordinate systems EPSG:4490 or EPSG:3857, with the default value being EPSG:4490. See:
-
cartesianToCanvasCoordinates(position, result) → Cartesian2
-
Convert 3D space coordinates to canvas coordinates (window coordinates).
Name Type Description positionCartesian3 Three-dimensional space coordinates. resultCartesian2 optional Window coordinates, used to save the result. Returns:
Window coordinatesExample:
//Output the window coordinates with latitude and longitude (0,0) as the mouse moves. var scene = widget.scene; var ellipsoid = scene.globe.ellipsoid; var position = SuperMap3D.Cartesian3.fromDegrees(0.0, 0.0); var handler = new SuperMap3D.ScreenSpaceEventHandler(scene.canvas); handler.setInputAction(function(movement) { console.log(scene.cartesianToCanvasCoordinates(position)); }, SuperMap3D.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(SuperMap3D.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(SuperMap3D.JulianDate.now()), entities[1].position.getValue(SuperMap3D.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 altitude 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. Returns an array of objects, each object contains the layer ID (layerID) and the selected object ID (ids)
Returns:
id array -
Get a vector tile map with the specified name.
Name Type Description nameString The name of the vector tile map Returns:
Get the map -
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 the iserver scene service
Name Type Description urlString service url sceneNameString There are multiple scenes in the workspace, you need to specify the name of the scene; set to undefined, the first one is opened by default optionsObject optional The object has the following properties: Name Type Default Description subdomainsArray For subdomains, eg: ['t1','t2'] autoSetViewBoolean trueoptional Whether to automatically locate the scene Returns:
Return promise to load object asynchronouslyExample:
var promise = scene.open('http://localhost:8090/iserver/services/3D-BIM3/rest/realspace'); promise.then(function(layers){}); //Subdomain and no auto-target usage var promise = scene.open('http://{s}.supermap.com:8090/iserver/services/3D-BIM3/rest/realspace',undefined,{ subdomains: ['t1', 't2'],//Subdomain autoSetView : false //no auto-target usage }); promise.then(function(layers){}); -
Output the current scene with Base64 encoding.
Returns:
An asynchronous object holding a Base64 encoding.Example:
var promise = scene.outputSceneToFile(); SuperMap3D.when(promise,function(base64data){ $("#ID").css("background","url(" + base64data +")"); }) -
Parse PBR material parameters.
Example:
scene.parsePBRFromJson(urls); var conditions=[ ['${id}<=80',0], ['${id}<=90',1], ['${id}<=100',2], ]; -
Scene picking, return the first primitive object corresponding to the window position in the scene, if there is no object at this position, return undefined.
Name Type Default Description windowPositionCartesian2 window coordinates. widthNumber 3optional Pick up the rectangle width. heightNumber 3optional Pick up the height of the rectangle. Returns:
The picked primitive object.Throws:
-
DeveloperError : windowPosition undefination
-
-
pickNormal(windowPosition) → Cartesian3
-
It is used to pick up the normal, pass in the screen coordinates, and return the normal. Combining with the selected offset can 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 picked up normal vector; if the picked up is not an S3M model, undefined will be returned. // -
pickPosition(windowPosition, result) → Cartesian3
-
Position picking, according to the window coordinates, picks up the corresponding position from the depth buffer of the scene, returns Cartesian coordinates, and needs to support depth texture.
Name Type Description windowPositionCartesian2 window coordinates. resultCartesian3 optional Cartesian coordinates, save the returned result. Returns:
Returns the corresponding Cartesian coordinates (3D world coordinates).Throws:
-
DeveloperError : Picking from depth texture is not supported, please check pickPositionSupported. 2D is not supported. Orthographic projection matrices are not invertible.
-
-
box selection
Name Type Description startPointObject Frame the starting point. endPointObject Box select the end point. -
removeLightSource(lightSource) → Scene
-
Delete the light source.
Name Type Description lightSourceLightSource light source. Returns:
The scene after adding light sources. -
Removes a vector tile map by the specified name.
Name Type Description nameString Specifies the name of the vector tile map to remove. Returns:
Whether the removal was successful. -
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 SuperMap3D.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 SuperMap3D.Cartographic(-1.31968, 0.69887), new SuperMap3D.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 near to far from the current perspective, 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.
