Class: Scene

Scene

new Scene()

三维场景类,它是所有三维图形对象和状态的容器,通常不直接创建场景,而是由Widget隐式创建。

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 Default Description
options.canvas Canvas

用于创建场景的HTML canvas元素。

options.contextOptions Object 可选

环境和WebGL创建属性,详见上述。

options.creditContainer Element 可选

用于显示服务描述信息的HTML元素。

options.mapProjection MapProjection new GeographicProjection() 可选

在二维和Columbus 视图模式下使用的地图投影。

options.orderIndependentTranslucency Boolean true 可选

如果此项设置为true,并且使用设备支持,将使用与顺序无关的半透明。

options.scene3DOnly Boolean false 可选

如果此项设置为true,将优化三维模式的内存使用和性能,但禁止使用二维或Columbus视图功能。

options.terrainExaggeration Number 1.0 可选

用于夸大地形的标量。请注意,设置地形夸张不会修改其它任何数据。

options.shadows Boolean false 可选

确定阴影是否由太阳投射形成。

options.mapMode2D MapMode2D MapMode2D.INFINITE_SCROLL 可选

确定二维地图是可旋转的或是可以在在水平方向上无限滚动。

See:
Throws:

options 需要指定options、options.canvas。

Type
DeveloperError
Example
//创建一个场景。
var viewer=new new SuperMap3D.Viewer('Container');
var scene = viewer.scene;

Members

backgroundColorColor

The background color, which is only visible if there is no sky box, i.e., Scene#skyBox is undefined.

Default Value:
Color.BLACK
See:

bloomEffectBloomEffect

获取场景的泛光效果,包括泛光强度值,泛光亮度阈值等。

readonly cameraCamera

获取当前场景的相机对象。

readonly canvasElement

获取scene绑定的canvas元素。

readonly clampToHeightSupportedBoolean

Returns true if the Scene#clampToHeight and Scene#clampToHeightMostDetailed functions are supported.

See:

colorCorrection

创建颜色校正对象

customRequestHeadersObject

自定义请求头

debugShowFrustumPlanesBoolean

该属性仅供调试,不可用于正式生产环境。

为true时,绘制轮廓以显示相机视锥体的边界。

Default Value:
false

debugShowFrustumsBoolean

该属性仅用于调试,不用于生产。当为true时,绘制轮廓线展示相机视锥体的范围。

Default Value:
false

depthOfFieldEffectDepthOfFieldEffect

获取场景的景深效果。

readonly drawingBufferHeightNumber

GL绘制缓冲区高度。

See:

readonly drawingBufferWidthNumber

GL绘制缓冲区宽度。

See:

enableCompositorBoolean

获取或者设置是否将场景绘制成图片。当关闭时,直接绘制到颜色缓冲区,画面效果更佳,但一些分析功能不可用。默认值为true。

enableOcclude

当前场景是否开启遮挡剔除。

Default Value:
true

eyeSeparationNumber

眼距以米为单位,适用于Cardboard或WebVR。

focalLengthNumber

用于Cardboard或WebVR时的焦距。

fogFog

获取高度雾。

frustumToleranceNumber

设置视锥体容限值,默认值为0.0,最大值为0.5

Default Value:
0.0

gammaNumber

获取或设置图层gamma值调节颜色。

Default Value:
2.2

globeGlobe

获取地球对象。

globeSplitPositionCartesian2

设置或获取当前场景的卷帘位置,有效值为0.0~1.0

readonly groundPrimitivesPrimitiveCollection

获取所有贴地图元集合。

hdrEnabled

当前场景是否开启hdr。

Default Value:
false

highDynamicRangeBoolean

Whether or not to use high dynamic range rendering.

Default Value:
true

highDynamicRangeSupportedBoolean

Whether or not high dynamic range rendering is supported.

Default Value:
true

readonly idString

获取当前场景的id。

readonly imageryLayersImageryLayerCollection

获取当前场景影像图层集合。

imagerySplitPositionNumber

设置或获取当前场景的影像分隔条位置。

invertClassificationBoolean

当为false时,3D Tiles将正常渲染。当为true时,分类的3D Tiles几何将正常渲染,未分类的3D Tiles几何将以颜色乘以Scene#invertClassificationColor渲染。

Default Value:
false

invertClassificationColorColor

Scene#invertClassificationtrue时,未分类3D Tiles几何体的高亮颜色。

当颜色的alpha值小于1.0时,3D Tiles的未分类部分将不能正确地与3D Tiles的分类位置混合。

同样,当颜色的alpha值小于1.0时,WEBGL_depth_texture和EXT_frag_depth WebGL扩展必须被支持。

Default Value:
Color.WHITE

readonly invertClassificationSupportedBoolean

Returns true if the Scene#invertClassification is supported.

See:

readonly lastRenderTimeJulianDate

Gets the simulation time when the scene was last rendered. Returns undefined if the scene has not yet been rendered.

readonly layersLayers

获取当前场景的三维瓦片图层集合。

lightSourceLightSource

获取当前场景中的光源。

localSceneGeoCenterCartographic

获取和设置使用局部坐标系场景时使用的场景中心点地理坐标。 此接口为了解决哥伦布视图下使用局部坐标系数据时,因为没有明确的地理坐标,所以无法计算正确的太阳光照和阴影问题。 注意:如果不是局部坐标系场景请不要设置此接口。

logarithmicDepthBufferBoolean

获取或者设置是否使用对数深度缓冲区。当设置为true时,将会在混合多截锥中使用较少的截锥,详情可参见Cesium官网的说明。

mapMode2DBoolean

确定二维地图是否可旋转,或是否在水平方向上可无限滚动。

readonly mapProjectionMapProjection

获取地图投影对象,用于2D或者Columbus View模式,默认为经纬度投影。

Default Value:
new GeographicProjection()

maximumRenderTimeChangeNumber

If Scene#requestRenderMode is true, 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. If undefined, 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:
  • Scene#requestRenderMode

minimumDisableDepthTestDistanceNumber

通过设置相机视角距离禁止布告板、标签和点对象的深度测试。例如,为了防止剪切地形数据,将距离设置为0则深度测试一直有效,将距离设置为小于0则深度测试失效。通过设置布告板、标签和点对象的disableDepthTestDistance属性修改距离值。

Default Value:
0.0

modeSceneMode

获取当前场景的模式。

Default Value:
SceneMode.SCENE3D

moonMoon

The Moon

Default Value:
undefined

multiViewportModeNumber

获取或者设置当前场景的多视口模式,默认单视口

Default Value:
0

overlapDisplayOptionsObject

设置图层的避让参数。 可设置的参数为:allowIconWithTextDisplay,设置是否开启图标图层跟随文字图层避让。默认为true.

pickPointEnabledBoolean

开启顶点捕捉功能,默认false,设置为true,则开启捕捉。

pickPointIntervalNumber

设置点云捕捉的时间间隔。

Default Value:
200

readonly pickPositionSupportedBoolean

深度拾取是否支持(深度纹理)。

pickTranslucentDepthBoolean

当为true时,支持使用深度缓冲区拾取半透明的几何图形。Scene#useDepthPicking也必须为true,支持拾取深度缓冲区。使用时性能有所下降,对于半透明的几何图形,将调用额外的绘图命令写入深度。

Default Value:
true
Example
// picking the position of a translucent primitive
viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {
     var pickedFeature = viewer.scene.pick(movement.position);
     if (!SuperMap3D.defined(pickedFeature)) {
         // nothing picked
         return;
     }
     viewer.scene.render();
     var worldPosition = viewer.scene.pickPosition(movement.position);
}, SuperMap3D.ScreenSpaceEventType.LEFT_CLICK);

postProcessStagesPostProcessStageCollection

应用于最终渲染的后处理效果。

readonly postRenderEvent

获取当前场景每帧渲染结束时的事件,监听该事件在每帧渲染结束时触发。

See:

readonly postUpdateEvent

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.

See:

readonly preRenderEvent

获取当前场景每帧渲染前的事件,监听该事件在每帧渲染之前触发。

See:

readonly preUpdateEvent

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.

See:

readonly primitivesPrimitiveCollection

获取所有图元集合。

rasterVectorCollectionObject

获取实时栅格化对象。

readonly sampleHeightSupportedBoolean

Returns true if the Scene#sampleHeight and Scene#sampleHeightMostDetailed functions are supported.

See:

scanEffectScanEffect

获取场景的扫描线效果。

readonly screenSpaceCameraControllerScreenSpaceCameraController

获取当前场景的相机操作对象。

shadowMapShadowMap

场景中的阴影贴图。启用时,模型、图元和地球可以投射和接收阴影。默认情况下,阴影贴图的光源是太阳。

showCalloutBoolean

获取或者设置是否显示牵引线

skyAtmosphereSkyAtmosphere

大气

Default Value:
undefined

skyBoxSkyBox

天空盒

Default Value:
undefined

readonly spatialGridSpatialGrid

获取空间网格对象.

specularEnvironmentMapsString

包含用于基于影像的PBR模型照明的环境光贴图和mipmap的KTX文件的URL。

readonly specularEnvironmentMapsSupportedBoolean

Returns true if specular environment maps are supported.

See:

sphericalHarmonicCoefficientsArray.<Cartesian3>

基于影像的PBR模型照明的球谐系数。

ssaoEffectSSAOEffect

获取场景的环境光遮蔽效果。

style3DBoolean

获取或者设置风格

sunSun

太阳

Default Value:
undefined

sunColorCartesian3

Gets or sets the color of the light emitted by the sun.

Default Value:
Cartesian3(1.8, 1.85, 2.0)

sunlightAnalysisSunlightAnalysis

获取日照分析

terrainProviderTerrainProvider

获取或者设置当前场景的地形服务provider对象。

readonly terrainProviderChangedEvent

获取当前场景地形服务provider改变事件。

toneMappingEnabled

当前场景是否开启toneMapping。

readonly toneMappingExposureNumber

获取或设置PBR材质模型整体亮度。

Default Value:
1.0

readonly underGlobeUnderGlobe

获取地下球。

undergroundDepthNumber

获取或者设置地下场景深度,默认1000米(单位:米)

undergroundModeBoolean

获取或者设置是否开启地下场景

Default Value:
false

useDepthPickingBoolean

当为true时,表示启用拾取深度缓冲区

Default Value:
true

vectorTileMapOrderInImagerLayersNumber

设置MVT与影像地图之间的显示顺序,范围为0到影像地图集合的数量。设置为0,mvt在所有影像的最底层显示;设置为Infinity,mvt在所有影像的最上层显示。

Default Value:
Infinity

volumetricCloudsVolumetricClouds

获取或设置体积云。(WebGPU暂不支持)

walkingModeNumber

获取或者设置相机模式。

Default Value:
WalkingMode.NONE
See:

readonly waterReflectionDistinctQualityNumber

获取或设置水面反射倒影清晰度,值越小越反射倒影模糊。

Default Value:
5.0

Methods

addFieldLayer(url){Promise}

根据url路径添加场数据图层。

Name Type Description
url String

场数据的url路径。

Returns:
Type Description
Promise 返回场数据图层FieldLayer3D,异步创建场图层对象。
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;
	})

addLayerService(url, sceneName, layerName)

添加场景图层服务。

Name Type Description
url String

图层服务的url路径。

sceneName String

场景名称。

layerName String

图层名称。

addLightSource(lightSource){Scene}

添加光源。

Name Type Description
lightSource LightSource

光源。

Returns:
Type Description
Scene 添加点光源后后的场景。

addS3MGroupLayer(url, options, index){Promise}

添加S3M分组图层。

Name Type Description
url String

iserver中发布的配置文件地址。

options Object

图层所需属性对象。

index Number

索引。

Returns:
Type Description
Promise 返回promise异步加载对象

addS3MTilesLayerByScp(url, index){Promise.<S3MTilesLayer>}

添加三维瓦片图层(S3M、S3MB)。

Name Type Default Description
url String

iserver中发布的配置文件地址。

options.subdomains Array

用于子域,例如:['t1','t2']。

options.name String

指定图层名称。

options.cullEnabled Boolean false 可选

是否剔除背面,默认为不剔除,即双面渲染。

index Number

索引。

Returns:
Type Description
Promise.<S3MTilesLayer> 返回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;
});

//子域用法
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);

addVectorTilesLayer()

添加矢量瓦片图层服务。 为了保证版本的稳定性,采用该接口创建的MVT图层依然保持原来的使用和实现方式,但不支持VectorTileMap中新增的接口,推荐使用新的实现方式addVectorTilesMap。 支持添加矢量瓦片服务以及存在tileFeature且具有style风格的rest地图服务。

Name Type Default Description
options.url String

适用于通过SuperMap桌面软件生成mvt数据,经iServer发布为rest风格的地图服务,只需提供服务地址。

options.layer String

图层名称,适用于第三方发布的WMTS服务。

options.canvasWidth Number 可选

用来绘制矢量的纹理边长。默认是512,越大越精细,越小性能越高。

options.tileWidth String

瓦片宽度,适用于第三方发布的WMTS服务。

options.tileHeight String

瓦片高度,适用于第三方发布的WMTS服务。

options.format String 'mvt' 可选

适用于第三方发布的WMTS服务。

options.tilematrxset String

瓦片矩阵集名称,适用于第三方发布的WMTS服务。

options.maximumLevel Number 可选

数据的最大级别。适用于第三方发布的WMTS服务,默认根据服务参数计算。

options.minimumLevel Number 可选

数据的最小级别。适用于第三方发布的WMTS服务,默认根据服务参数计算。

options.mapboxStyle Object 可选

使用的mapBox风格。

options.maximumTerrainLevel Number 可选

允许加载MVT图层的最大地形层号(如果未定义则所有层都加载)。

options.minimumTerrainLevel Number 可选

允许加载MVT图层的最小地形层号(如果未定义则所有层都加载)。

options.simplifyTolerance Number 可选

进行几何简化的坐标容限,单位为瓦片坐标系,值域为0-4096。值越大简化得越厉害,默认是0,不简化。

options.viewer Object 可选

设置将要添加到的地球

See:
Example
// 加载矢量瓦片服务
var layer = scene.addVectorTilesLayer({
    url:"http://localhost:8090/iserver/services/map-mvt-test/....../maps/test"//地图服务
});
// 加载存在tileFeature且具有style风格的rest地图服务
var layer = scene.addVectorTilesLayer({
    url:"http://localhost:8090/iserver/services/map-test/rest/maps/test/tileFeature"//地图服务
});

addVectorTilesMap()

新建一个矢量瓦片地图。

Name Type Default Description
options.url String

适用于通过SuperMap桌面软件生成mvt数据,经iServer发布为rest风格的地图服务,只需提供服务地址。

options.layer String

图层名称,适用于第三方发布的WMTS服务。

options.canvasWidth Number 可选

用来绘制矢量的纹理边长。默认是512,越大越精细,越小性能越高。

options.tileWidth String

瓦片宽度,适用于第三方发布的WMTS服务。

options.tileHeight String

瓦片高度,适用于第三方发布的WMTS服务。

options.format String 'mvt' 可选

适用于第三方发布的WMTS服务。

options.tilematrxset String

瓦片矩阵集名称,适用于第三方发布的WMTS服务。

options.maximumLevel Number 可选

数据的最大级别。适用于第三方发布的WMTS服务,默认根据服务参数计算。

options.minimumLevel Number 可选

数据的最小级别。适用于第三方发布的WMTS服务,默认根据服务参数计算。

options.mapboxStyle Object 可选

使用的mapBox风格。

options.maximumTerrainLevel Number 可选

允许加载MVT图层的最大地形层号(如果未定义则所有层都加载)。

options.minimumTerrainLevel Number 可选

允许加载MVT图层的最小地形层号(如果未定义则所有层都加载)。

options.labelScaleByDistance Number 可选

设置文字随距离缩放。

options.customRequestHeaders Object 可选

设置自定义请求头。

options.realtime Boolean 可选

设置是否实时栅格化。

options.swipeEnabled Boolean 可选

设置是否卷帘。

options.swipeRegion Object 可选

设置卷帘区域。

options.billboardMode BillboardMode 可选

设置文字标签样式。

options.labelDepthTestEnabled Boolean 可选

用于控制MVT文字/图标是否做深度检测。默认为true,开启深度检测,反之则关闭深度检测。

options.viewer Object 可选

设置将要添加到的地球

options.localIdeographFontFamily Boolean 可选

用于MVT文字注记设置默认字体。

options.subdomains Array | String

多子域。传入参数为Array时,支持多个子域加载。传入参数为String时仅支持单个子域加载。

options.crs string

目前支持加载第三方坐标系EPSG:4490,EPSG:3857,默认值EPSG:4490。

See:

addVoxelGridLayer(url){Promise}

添加体源栅格图层

Name Type Description
url String

数据url

Returns:
Type Description
Promise 返回场图层VoxelGridLayer3D异步创建对象
Example
var promise =  viewer.scene.addVoxelGridLayer("../data.nc");
 Promise.resolve(promise).then(function(VoxelGridLayer){

	})

cartesianToCanvasCoordinates(position, result){Cartesian2}

转换三维空间坐标到canvas坐标(窗口坐标)。

Name Type Description
position Cartesian3

三维空间坐标。

result Cartesian2 可选

窗口坐标,用于保存结果。

Returns:
Type Description
Cartesian2 窗口坐标。
Example
//随着鼠标移动输出经纬度为(0,0)的窗口坐标。
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}

沿着大地表面法线将给定的Cartesian位置限制到场景几何。返回固定位置,如果没有场景几何来固定,则返回undefined。可用于将对象限制到场景中的球体、三维瓦片或基元。

此函数仅限制当前视图中渲染的球面瓦片和三维瓦片。限制所有其他基元,无论其可见性如何。

Name Type Default Description
cartesian Cartesian3

cartesianCartesian位置。

objectsToExclude Array.<Object> 可选

不限制的基元、实体或三维瓦片特征列表。

width Number 0.1 可选

交叉路口的宽度,以米为单位。

result Cartesian3 可选

用于返回限制位置的可选对象。

See:
Throws:
  • clampToHeight 仅在三维模式下支持。

    Type
    DeveloperError
  • clampToHeight 需要深度纹理支持。检查clampToHeightSupported。

    Type
    DeveloperError
Returns:
Type Description
Cartesian3 如果没有提供新的Cartesian3实例,则使用修改后的结果参数。如果没有场景几何体来限制,这可能是未定义的。
Example
// Clamp an entity to the underlying scene geometry
var position = entity.position.getValue(SuperMap3D.JulianDate.now());
entity.position = viewer.scene.clampToHeight(position);

clampToHeightMostDetailed(cartesians, objectsToExclude, width){Promise.<Array.<Cartesian3>>}

启动异步Scene#clampToHeight查询Cartesian3位置数组,使用场景中三维瓦片集的最大精细级别。 返回查询完成时解析的promise。每个位置都是原地修改的。如果由于无法在该位置采样几何体或发生其他错误而无法限制位置,则数组中的元素将设置为未定义。

Name Type Default Description
cartesians Array.<Cartesian3>

用限制位置更新的cartesians位置。

objectsToExclude Array.<Object> 可选

不限制的基元、实体或三维瓦片特征列表。

width Number 0.1 可选

交叉路口的宽度,以米为单位。

See:
Throws:
  • clampToHeightMostDetailed 仅支持三维模式。

    Type
    DeveloperError
  • clampToHeightMostDetailed 需要深度纹理支持。检查 clampToHeightSupported。

    Type
    DeveloperError
Returns:
Type Description
Promise.<Array.<Cartesian3>> 查询完成后,解析到所提供的位置列表的Promise。
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];
}

destroy()

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 than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.

See:
Throws:

This object was destroyed, i.e., destroy() was called.

Type
DeveloperError
Example
scene = scene && scene.destroy();

getCompressedTextureFormatSupported(format){boolean}

当前场景是否支持纹理压缩格式。

Name Type Description
format String

纹理格式。格式名称或WebGL扩展名。例如:s3tc 或 WEBGL_compressed_texture_s3tc。

Returns:
Type Description
boolean 该格式是否被支持。

getHeight(lon, lat){Number}

根据经纬度坐标获取对应高度。

Name Type Description
lon Number

经度坐标。

lat Number

纬度坐标。

Returns:
Type Description
Number 高度值,单位:米。

getPickRectIDs(){Array}

获取选中ID。返回的是对象数组,每个对象包含图层ID(layerID)和选中对象ID(ids)

Returns:
Type Description
Array id数组

getPickRectIDsAsync(){Array}

异步获取选中ID。返回的是对象数组,每个对象包含图层ID(layerID)和选中对象ID(ids)

Returns:
Type Description
Array id数组

getVectorTilesMap(name){Layer}

根据指定名称获取矢量瓦片地图。

Name Type Description
name String

矢量瓦片地图的名称

Returns:
Type Description
Layer 获取的地图

getViewport(windowPosition){BoundingRectangle}

根据窗口坐标,获取当前场景视口。

Name Type Description
windowPosition Cartesian2

窗口坐标。

Returns:
Type Description
BoundingRectangle 视口。

isDestroyed(){Boolean}

Returns true if this object was destroyed; otherwise, false.

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.

See:
Returns:
Type Description
Boolean true if this object was destroyed; otherwise, false.

open(url, sceneName){Promise}

打开iserver场景服务下所有图层。

Name Type Default Description
url String

服务url。

sceneName String

工作空间中有多个场景,需要指定场景名称;设置为undefined,默认打开第一个。

options.subdomains Array

用于子域,例如:['t1','t2']。

options.autoSetView Boolean true 可选

是否自动定位到场景

Returns:
Type Description
Promise 返回promise异步加载对象
Example
var promise = scene.open('http://localhost:8090/iserver/services/3D-BIM3/rest/realspace');
promise.then(function(layers){});

//子域和不自动定位用法
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){});

outputSceneToFile(){Promise}

将当前场景输出Base64编码

Name Type Description
options.resolutionScale Number 可选

当前画布分辨率宽高的倍数,默认为1,如果大于1,最终出图的分辨率为宽高的resolutionScale * resolutionScale倍,超过当前设备支持的最大分辨率则以设备最大分辨率出图

options.progressCallback function 可选

出图进度的回调函数,参数为出图进度百分比,0到100

Returns:
Type Description
Promise 持有Base64编码的异步对象
Example
var promise =  scene.outputSceneToFile({
      resolutionScale : 4
  });
  Promise.resolve(promise).then(function(base64data){
     $("#ID").css("background","url(" + base64data +")");
   })

parsePBRFromJson()

解析PBR材质参数。

Example
scene.parsePBRFromJson(urls);
var conditions=[
['${id}<=80',0],
['${id}<=90',1],
['${id}<=100',2],
];

pick(windowPosition, width, height){Object}

场景拾取,返回在场景中该窗口位置对应的第一个图元对象,如果该位置没有任何物体则返回undefined。

Name Type Default Description
windowPosition Cartesian2

窗口坐标。

width Number 3 可选

拾取矩形宽度。

height Number 3 可选

拾取矩形高度。

Throws:

windowPosition 未定义。

Type
DeveloperError
Returns:
Type Description
Object 拾取的图元对象。
Example
// On mouse over, color the feature yellow.
handler.setInputAction(function(movement) {
    var feature = scene.pick(movement.endPosition);
    if (feature instanceof SuperMap3D.Cesium3DTileFeature) {
        feature.color = SuperMap3D.Color.YELLOW;
    }
}, SuperMap3D.ScreenSpaceEventType.MOUSE_MOVE);

pickNormal(windowPosition){Cartesian3}

用于拾取法线,传入屏幕坐标,返回法线。结合选中偏移可以实现沿法线方向偏移的效果。

Name Type Description
windowPosition Cartesian2

Window coordinates to perform picking on.拾取的屏幕坐标。

Returns:
Type Description
Cartesian3 Normal.拾取到的法线向量;如果拾取到的不是S3M模型,则返回undefined。

pickNormalAsync(windowPosition){Promise.<Cartesian3>}

用于拾取法线,传入屏幕坐标,返回法线。结合选中偏移可以实现沿法线方向偏移的效果。

Name Type Description
windowPosition Cartesian2

Window coordinates to perform picking on.拾取的屏幕坐标。

Returns:
Type Description
Promise.<Cartesian3> Normal.拾取到的法线向量;如果拾取到的不是S3M模型,则返回undefined。

pickPosition(windowPosition, result){Cartesian3}

位置拾取,根据窗口坐标,从场景的深度缓冲区中拾取相应的位置,返回Cartesian坐标,需要支持深度纹理。

Name Type Description
windowPosition Cartesian2

窗口坐标。

result Cartesian3 可选

Cartesian坐标,保存返回结果。

Throws:

不支持从深度纹理中拾取,请检查 pickPositionSupported。不支持2D。正交投影矩阵不可逆。

Type
DeveloperError
Returns:
Type Description
Cartesian3 返回相应的Cartesian坐标(三维地理坐标)。

pickRect(startPoint, endPoint)

框选

Name Type Description
startPoint Object

框选起始点。

endPoint Object

框选终止点。

removeLightSource(lightSource){Scene}

删除光源。

Name Type Description
lightSource LightSource

光源。

Returns:
Type Description
Scene 添加光源后后的场景。

removeVectorTilesMap(name){Boolean}

按指定名称移除矢量瓦片地图。

Name Type Description
name String

指定拟移除的矢量瓦片地图的名称。

Returns:
Type Description
Boolean 是否移除成功。

sampleHeight(position, objectsToExclude, width){Number}

返回给定投影位置处场景几何体的高度,如果没有场景几何体进行高度采样,则返回未定义值。 输入位置的高度将被忽略。可用于将对象限制到场景中的地球、三维瓦片或基元上。

此函数仅对当前视图中渲染的地球瓦片和三维瓦片的高度进行采样。无论其他基元是否可见,都会对其高度进行采样。

Name Type Default Description
position Cartographic

用于采样高度的地图投影位置。

objectsToExclude Array.<Object> 可选

不进行高度采样的基元、实体或三维瓦片特征的列表。

width Number 0.1 可选

交叉路口的宽度,以米为单位。

See:
Throws:
  • sampleHeight is only supported in 3D mode.

    Type
    DeveloperError
  • sampleHeight requires depth texture support. Check sampleHeightSupported.

    Type
    DeveloperError
Returns:
Type Description
Number 高度。如果没有场景几何体作为高度采样,则可能未定义。
Example
var position = new SuperMap3D.Cartographic(-1.31968, 0.698874);
var height = viewer.scene.sampleHeight(position);
console.log(height);

sampleHeightMostDetailed(positions, objectsToExclude, width){Promise.<Array.<Number>>}

启动异步Scene#sampleHeight查询Cartographic位置数组,使用场景中三维瓦片集的最大精细级别。输入位置的高度被忽略。 返回查询完成时解析的promise。每个点的高度都被就地修改。如果由于无法在该位置采样几何体或发生其他错误而无法确定高度,则将高度设置为未定义。

Name Type Default Description
positions Array.<Cartographic>

需要用采样高度更新的地图投影位置。

objectsToExclude Array.<Object> 可选

不进行高度采样的基元、实体或三维瓦片特征的列表。

width Number 0.1 可选

交叉路口的宽度,以米为单位。

See:
Throws:
  • sampleHeightMostDetailed 仅支持三维模式。

    Type
    DeveloperError
  • sampleHeightMostDetailed 需要深度纹理支持。请检查 sampleHeightSupported。

    Type
    DeveloperError
Returns:
Type Description
Promise.<Array.<Number>> 查询完成后,解析到所提供的位置列表的promise。
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.
}

deprecated setVectorTilesLayersControl(control, level)

Name Type Description
control Boolean

是否对MVT的显示级别进行控制。

level Number

从当前视角由近及远,总共显示的级别数。例如设置为3,则只显示距离相机最近的前三层,第4层及以后的不会显示。