CesiumWidget
隐式创建。
contextOptions
参数详细信息:
默认值为:
{
webgl : {
alpha : false,
depth : true,
stencil : false,
antialias : true,
premultipliedAlpha : true,
preserveDrawingBuffer : false,
failIfMajorPerformanceCaveat : false
},
allowTextureFilterAnisotropic : true
}
webgl属性对应用于创建WebGL环境的WebGLContextAttributes对象。
webgl.alpha默认为false,与标准WebGL默认值为true相比,这可以提高性能。
其他webgl属性与WebGLContextAttributes.的WebGL默认值匹配。
allowTextureFilterAnisotropic默认为true,这允许在支持WebGL扩展时进行各向异性纹理过滤。设置为false可以提高性能,但会损害视觉质量,特别是对于水平视图。
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
对象具有以下属性:
|
Throws:
-
DeveloperError : options 需要指定options、options.canvas。
Example:
//创建一个场景。
var viewer=new new Cesium.Viewer('Container');
var scene = viewer.scene;
See:
Members
-
bloomEffect : BloomEffect
-
获取场景的泛光效果,包括泛光强度值,泛光亮度阈值等。
-
readonlycamera : Camera
-
获取当前场景的相机对象。
-
获取scene绑定的canvas元素。
-
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
-
该属性仅用于调试,不用于生产。当为true时,绘制轮廓线展示相机平台的范围。
-
Default Value:
false
-
GL绘制缓冲区高度。
See:
-
GL绘制缓冲区宽度。
See:
-
获取或者设置是否将场景绘制成图片。当关闭时,直接绘制到颜色缓冲区,画面效果更佳,但一些分析功能不可用。默认值为true。
-
当前场景是否开启遮挡剔除。
-
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
-
获取地球对象。
-
globeSplitPosition : Cartesian2
-
设置或获取当前场景的卷帘位置,有效值为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
-
获取所有贴地图元集合。
-
当前场景是否开启hdr。
-
Default Value:
false
-
获取当前场景的id。
-
readonlyimageryLayers : ImageryLayerCollection
-
获取当前场景影像图层集合。
-
设置或获取当前场景的影像分隔条位置。
-
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
-
获取当前场景的三维切片缓存图层集合。
-
获取当前场景中的光源。
-
获取或者设置是否使用对数深度缓冲区。当设置为true时,将会在混合多截锥中使用较少的截锥,详情可参见Cesium官网的说明。
-
readonlymapProjection : MapProjection
-
获取地图投影对象,用于2D或者Columbus View模式,默认为经纬度投影。
-
Default Value:
new GeographicProjection()
-
通过设置相机视角距离禁止布告板、标签和点对象的深度测试。例如,为了防止剪切地形数据,将距离设置为0则深度测试一直有效,将距离设置为小于0则深度测试失效。通过设置布告板、标签和点对象的disableDepthTestDistance属性修改距离值。
-
Default Value:
0.0
-
mode : SceneMode
-
获取当前场景的模式。
-
Default Value:
SceneMode.SCENE3D
-
获取或者设置当前场景的多视口模式,默认单视口。
-
Default Value:
0
-
设置点云捕捉的时间间隔
-
Default Value:
200
-
当为true时,支持使用深度缓冲区拾取半透明的几何图形。
Scene#useDepthPicking
也必须为true,支持拾取深度缓冲区。使用时性能有所下降,对于半透明的几何图形,将调用额外的绘图命令写入深度。-
Default Value:
false
-
readonlypostRender : Event
-
获取当前场景每帧渲染结束时的事件,监听该事件在每帧渲染结束时触发。
-
readonlypreRender : Event
-
获取当前场景每帧渲染前的事件,监听该事件在每帧渲染之前触发。
-
readonlyprimitives : PrimitiveCollection
-
获取所有图元集合。
-
获取实时栅格化对象。
-
readonlyscreenSpaceCameraController : ScreenSpaceCameraController
-
获取当前场景的相机操作对象。
-
shadowMap : ShadowMap
-
场景中的阴影贴图。启用时,模型、图元和地球可以投射和接收阴影。默认情况下,阴影贴图的光源是太阳。
-
terrainProvider : TerrainProvider
-
获取或者设置当前场景的地形服务provider对象。
-
readonlyterrainProviderChanged : Event
-
获取当前场景地形服务provider改变事件。
-
当前场景是否开启toneMapping。
-
获取地下球。
-
获取或者设置地下场景深度,默认1000米(单位:米)。
-
获取或者设置是否开启地下场景。
-
Default Value:
false
-
获取或者设置相机模式
-
Default Value:
WalkingMode.NONE
See:
Methods
-
根据url路径添加场数据图层。
Name Type Description url
String 场数据的url路径。 Returns:
返回场数据图层FieldLayer3D,异步创建场图层对象。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; })
-
添加场景图层服务。
Name Type Description url
String 图层服务的url路径。 sceneName
String 场景名称。 layerName
String 图层名称。 -
addLightSource(lightSource) → Scene
-
添加光源。
Name Type Description lightSource
LightSource 光源。 Returns:
添加点光源后后的场景。 -
添加S3M分组图层。
Name Type Description url
String iserver中发布的配置文件地址。 options
Object 图层所需属性对象。 index
Number 索引。 Returns:
返回promise异步加载对象 -
添加三维切片缓存图层(S3M、S3MB)。
Name Type Default Description url
String iserver中发布的配置文件地址。 options
Object 图层所需属性对象。 index
Number 索引。 options.name
String 图层名称。 options.cullEnabled
Boolean true
optional 是否双面渲染,默认为双面渲染。 Returns:
返回promise异步加载对象Example:
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; });
-
添加矢量瓦片图层服务。为了保证版本的稳定性,采用该接口创建的MVT图层依然保持原来的使用和实现方式,但不支持VectorTileMap中新增的接口,推荐使用新的实现方式addVectorTilesMap。
Name Type Description options
Object 参数对象包含以下属性: Name Type Default Description url
String 适用于通过SuperMap桌面软件生成mvt数据,经iServer发布为rest风格的地图服务,只需提供服务地址。 url
String 服务地址,适用于第三方发布的WMTS服务。 layer
String 图层名称,适用于第三方发布的WMTS服务。 canvasWidth
Number optional 用来绘制矢量的纹理边长。默认是512,越大越精细,越小性能越高。 tileWidth
String 瓦片宽度,适用于第三方发布的WMTS服务。 tileHeight
String 瓦片高度,适用于第三方发布的WMTS服务。 format
String 'mvt'
optional 适用于第三方发布的WMTS服务。 tilematrxset
String 切片矩阵集名称,适用于第三方发布的WMTS服务。 maximumLevel
Number optional 数据的最大层级。适用于第三方发布的WMTS服务,默认根据服务参数计算。 minimumLevel
Number optional 数据的最小层级。适用于第三方发布的WMTS服务,默认根据服务参数计算。 mapboxStyle
Object optional 使用的mapBox风格。 maximumTerrainLevel
Number optional 允许加载MVT图层的最大地形层号(如果未定义则所有层都加载)。 minimumTerrainLevel
Number optional 允许加载MVT图层的最小地形层号(如果未定义则所有层都加载)。 simplifyTolerance
Number optional 进行几何简化的坐标容限,单位为切片坐标系,值域为0-4096。值越大简化得越厉害,默认是0,不简化。 Example:
var layer = scene.addVectorTilesLayer({ url:"http://localhost:8090/iserver/services/map-mvt-test/....../maps/test"//地图服务 });
See:
-
新建一个矢量瓦片地图。
Name Type Description options
新建地图包含以下参数: Name Type Default Description url
String 适用于通过SuperMap桌面软件生成mvt数据,经iServer发布为rest风格的地图服务,只需提供服务地址。 layer
String 图层名称,适用于第三方发布的WMTS服务。 canvasWidth
Number optional 用来绘制矢量的纹理边长。默认是512,越大越精细,越小性能越高。 tileWidth
String 瓦片宽度,适用于第三方发布的WMTS服务。 tileHeight
String 瓦片高度,适用于第三方发布的WMTS服务。 format
String 'mvt'
optional 适用于第三方发布的WMTS服务。 tilematrxset
String 切片矩阵集名称,适用于第三方发布的WMTS服务。 maximumLevel
Number optional 数据的最大层级。适用于第三方发布的WMTS服务,默认根据服务参数计算。 minimumLevel
Number optional 数据的最小层级。适用于第三方发布的WMTS服务,默认根据服务参数计算。 mapboxStyle
Object optional 使用的mapBox风格。 maximumTerrainLevel
Number optional 允许加载MVT图层的最大地形层号(如果未定义则所有层都加载)。 minimumTerrainLevel
Number optional 允许加载MVT图层的最小地形层号(如果未定义则所有层都加载)。 See:
-
cartesianToCanvasCoordinates(position, result) → Cartesian2
-
转换三维空间坐标到canvas坐标(窗口坐标)。
Name Type Description position
Cartesian3 三维空间坐标。 result
Cartesian2 optional 窗口坐标,用于保存结果。 Returns:
窗口坐标。Example:
//随着鼠标移动输出经纬度为(0,0)的窗口坐标。 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);
-
当前场景是否支持纹理压缩格式。
Name Type Description format
String 纹理格式。格式名称或WebGL扩展名。例如:s3tc 或 WEBGL_compressed_texture_s3tc。 Returns:
该格式是否被支持。 -
根据经纬度坐标获取对应高度。
Name Type Description lon
Number 经度坐标。 lat
Number 纬度坐标。 Returns:
高度值,单位:米。 -
获取选中ID。返回的是对象数组,每个对象包含图层ID(layerID)和选中对象ID(ids)
Returns:
id数组 -
根据指定名称获取矢量瓦片地图。
Name Type Description name
String 矢量瓦片地图的名称 Returns:
获取的地图 -
getViewport(windowPosition) → BoundingRectangle
-
根据窗口坐标,获取当前场景视口。
Name Type Description windowPosition
Cartesian2 窗口坐标。 Returns:
视口。 -
打开iserver场景服务下所有图层
Name Type Description url
String 服务url sceneName
String 工作空间中有多个场景,需要指定场景名称 Returns:
返回promise异步加载对象Example:
var promise = scene.open('http://localhost:8090/iserver/services/3D-BIM3/rest/realspace'); promise.then(function(layers){});
-
将当前场景输出Base64编码。
Returns:
持有Base64编码的异步对象。Example:
var promise = scene.outputSceneToFile(); Cesium.when(promise,function(base64data){ $("#ID").css("background","url(" + base64data +")"); })
-
场景拾取,返回在场景中该窗口位置对应的第一个图元对象,如果该位置没有任何物体则返回undefined。
Name Type Default Description windowPosition
Cartesian2 窗口坐标。 width
Number 3
optional 拾取矩形宽度。 height
Number 3
optional 拾取矩形高度。 Returns:
拾取的图元对象。Throws:
-
DeveloperError : windowPosition 未定义。
-
-
pickPosition(windowPosition, result) → Cartesian3
-
位置拾取,根据窗口坐标,从场景的深度缓冲区中拾取相应的位置,返回笛卡尔坐标,需要支持深度纹理。
Name Type Description windowPosition
Cartesian2 窗口坐标。 result
Cartesian3 optional 笛卡尔坐标,保存返回结果。 Returns:
返回相应的笛卡尔坐标(三维世界坐标)。Throws:
-
DeveloperError : 不支持从深度纹理中拾取,请检查 pickPositionSupported。不支持2D。正交投影矩阵不可逆。
-
-
框选
Name Type Description startPoint
Object 框选起始点 endPoint
Object 框选终止点 Returns:
-
removeLightSource(lightSource) → Scene
-
删除光源。
Name Type Description lightSource
LightSource 光源。 Returns:
添加光源后后的场景。 -
按指定名称移除矢量瓦片地图。
Name Type Description name
String 指定拟移除的矢量瓦片地图的名称。 Returns: