Sandbox(divname, sandboxOptions)

显示,操作,与多个altizure项目交互, 和多个导入的gl元素。

new Sandbox(divname, sandboxOptions)

创建沙箱实例。

Parameters:
Name Type Description
divname string

包含画布的div元素的名称

sandboxOptions object

初始化选项

Properties
Name Type Attributes Description
altizureApi object

api设置

Properties
Name Type Attributes Description
key string

应用程序密钥,由Altizure颁发

apiUrl string <optional>

API网址,默认https://api.altizure.com/graphql

altitoken string <optional>

用户令牌,由Altizure官方发布

region string <optional>

'CN'或'Inter'。默认'CN'

api object <optional>

引擎API配置(加密)

camera object <optional>

打开动画设置

Properties
Name Type Attributes Description
poseTo pose <optional>

动画开始相机姿势(lat,lng,alt,north,tilt)

flyTo pose <optional>

动画结束相机姿势

renderItems object <optional>

渲染什么

Properties
Name Type Attributes Default Description
earth bool <optional>
true

渲染地球

earthUseTexture bool <optional>
true

呈现卫星图像

featureInView bool <optional>
true

提供altizure特色项目

orbitRing bool <optional>
false

渲染地球轨道环

background.transparent bool <optional>
false

gl背景透明

background.opacity bool <optional>

gl背景不透明度

background.color bool <optional>

gl背景颜色

background.image bool <optional>

gl背景图像

quality number <optional>
60

渲染AltizureProjectMarker(森林大小)的质量,范围[1,100]

Extends

Members

static, readonly mat

获取当前姿势下矩阵的元素

static pose

设置相机的姿势

static range

设置倾斜和alt的范围

readonly camera

Camera interface.

camera.pose (setter and getter) set or get the pose. pose: {lng, lat, alt, north, tilt}

camera.range (setter) set the range for tilt and alt. camera.range = {tilt: {max: ..., min: ...}, alt: {max: ..., min: ...}}

camera.flyTo(p, duration = 2500), p is the pose, duration is fly time in ms. returns a promise which resolves when fly ends.

camera.stop(), stop flying

camera.lookAt(marker, north, tilt, alt, duration = 3000), marker is arbitrary marker, north is the pose north, tile is the pose tilt, alt is the alt over marker, duration is the fly time duration.

or

camera.lookAt(marker, pose, duration = 3000), pose is an object with three keys, north, tilt and alt. example of pose: {north: 40, tilt, 30, alt: undefined} the method will fly to the pose and returns a promise resolve when fly ends.

camera.matToPose(mat), mat is the matrix element. returns the corresonding pose: {lng, lat, alt, north, tilt}

camera.mat (getter) get the matrix element in current pose: number[]

camera.flyToMat(mat, duration = 3000), mat is the matrix element, duration is fly time in ms. returns a promise which resolves when fly ends.

camera.flyToCamToEarth(mat, duration = 2500), mat is the matrix element, duration is fly time in ms. returns a promise which resolves when fly ends.

readonly control

控制。

readonly domElement

渲染器的dom元素

Inherited From:

enableDolly

启用地球小车。

Inherited From:

readonly height

帆布的高度。

readonly interaction

鼠标交互。

readonly JSON

一个json对象描述当前场景

readonly renderer

Threejs WebGLRenderer。

Inherited From:

readonly scene

threejs现场

Inherited From:

readonly sceneRoot

地球的现场根(地球空间)

Inherited From:

readonly viewerCamera

Threejs相机。

Inherited From:

visibilityCamera

将相机设置为可见性渲染。

Example

bind a spot light to a CameraMarker

 sandbox.visibilityCamera = cameraMarker

readonly width

画布的宽度。

readonly window

屏幕空间操作。

window.toLngLatAlt({x,y})返回LngLatAlt

window.fromLngLatAlt({lng,lat,alt})返回{x,y}

window.screenshot()返回{width:number,height:number,data:number [],值是从0到255的整数}

Methods

static flyTo(p, duration) → {Promise}

从当前姿势飞行到输入姿势。该过程会花费持续时间(毫秒)

Parameters:
Name Type Description
p object

{lng,lat,all,north,tilt}

duration number

飞行时间以毫秒为单位

Returns:
Promise

static flyToCamToEarth(mat, ms) → {promise}

飞行到由矩阵元素表示的姿势

Parameters:
Name Type Description
mat Array.<number>

矩阵元素

ms number

飞行时间以毫秒为单位

Returns:
promise -
  • 在航班结束时解决

static flyToMat(mat, ms) → {promise}

飞行到由矩阵元素表示的姿势

Parameters:
Name Type Description
mat Array.<number>

矩阵元素

ms number

飞行时间以毫秒为单位

Returns:
promise -
  • 在航班结束时解决

static fromLngLatAlt() → {object}

从LngLatAlt点获取屏幕空间x,y

Parameters:
Type Description
LngLatAlt
Returns:
object -
  • {x,y}

static lookAt(marker, north, tile, alt, pose, duration) → {Promise}

look at the marker. the camera will fly to appropriate position to look at it with specified north and tilt.

Parameters:
Name Type Description
marker Marker

arbitrary marker

the pose can be input by each attributes

north number

姿势的北部

tile number

姿势的倾斜

alt number

the alt over the marker the pose may also be input as object

pose object

{north, tilt, alt}

duration number

fly time duration

Returns:
Promise

static matToPose(camToEarth) → {object}

将矩阵元素转换为相机姿态

Parameters:
Name Type Description
camToEarth Matrix4

相机对地球空间

Returns:
object -
  • {lng,lat,alt,up,north,tilt}

static screenshot() → {object}

得到一个截图

Parameters:
Type Description
object

{width: required width, height: required height}

Returns:
object -
  • {width:number,height:number,data:number [],值是从0到255的整数}

static stop() → {Promise}

停止飞行过程

Returns:
Promise

static toLngLatAlt() → {LngLatAlt}

通过屏幕空间点(x,y)获得LngLatAlt

Parameters:
Type Description
object

{x,y}

Returns:
LngLatAlt

add(type, data, options) → {promsie}

添加一个GL元素到场景中

Parameters:
Name Type Description
type string

元素类型:'AltizureProjectMarker','OBJMarker'

data object

内容

options object

选项来创建标记

Returns:
promsie

calculateDistanceBetweenTwoPoints(first, second) → {number}

计算两个LngLatAlt点之间的距离(以米为单位)

Parameters:
Name Type Description
first LngLatAlt

第一点

second LngLatAlt

第二点

Returns:
number -
  • 以米为单位的两点之间的距离
Inherited From:

destruct()

析构函数

Overrides:

earthToScene() → {Matrix4}

从(抽象)地球空间到场景根。

Returns:
Matrix4
Inherited From:

freeze() → {bool}

冻结地球轨道控制。 (轨道,漩涡,小车)

Returns:
bool
Inherited From:

generateMask(boundaryPtns, altRange, markerArray, bufferMaxSizeopt) → {Object}

使用给定的标记生成快照,并将该颜色用作其快照中的ID

Parameters:
Name Type Attributes Default Description
boundaryPtns Array

数组lngLatAlt形式点

altRange Object

高度范围以米为单位。例如{min:0,max:40}

markerArray Array

标记阵列

bufferMaxSize Number <optional>
512

返回缓冲区的较大边的长度

Returns:
Object -
  • { 掩码:{ 缓冲区:UintArray8, 分辨率:数字, 分辨率宽度:分辨率区域的宽度, resolutionheight:分辨率区域的高度, 尺寸:缓冲区尺寸{宽度,高度}, bbox:边界框lngLatAlt形式 }, 映射:{  一些颜色标识:一些标记 } }
Inherited From:

lngLatAlt2XYZ(LngLatAlt) → {THREE.Vector3}

将地球坐标空间中的LngLatAlt转换为THREE.Vector3

Parameters:
Name Type Description
LngLatAlt altizure.LngLatAlt
Returns:
THREE.Vector3
Inherited From:
Example

convert LngLatAlt to THREE.Vector3

 let lngLatAlt = {lng: 113.93977612840078, lat: 22.5364271949327, alt: 12.3}
 let vector3 = sandbox.lngLatAlt2XYZ(lngLatAlt)
 // vector3 is in THREE.Vector3 form

login()

为登录用户设置用户信息

markerSnapshot(boundaryPtns, altRange, renderObjects, returnDepthopt, bufferMaxSizeopt) → {Object}

拍摄指定对象进行渲染的有界区域的快照

Parameters:
Name Type Attributes Default Description
boundaryPtns Array

数组lngLatAlt形式点

altRange Object

高度范围以米为单位。例如{min:0,max:40}

renderObjects Array

要呈现的对象数组

returnDepth Bool <optional>
false

其结果是深度缓冲或不

bufferMaxSize Number <optional>
512

返回缓冲区的较大边的长度

Returns:
Object -
  • { 缓冲区:UintArray8, 分辨率:数字, 分辨率宽度:分辨率区域的宽度, resolutionheight:分辨率区域的高度, 尺寸:缓冲区尺寸{宽度,高度}, bbox:边界框lngLatAlt形式 }
Inherited From:
Examples

Take a colorful snapshot

 let boundaryPtns = [
   {lng: 113.939, lat: 22.536},
   {lng: 113.9391, lat: 22.5361},
   // more points to specify the boundary
   ...
 ]
 // take a colorful (RGB snapshot)
 let RGBSnapshot = sandbox.markerSnapshot(
   boundaryPtns, // boundary
   {min: 0, max: 40}, // altitude range
   [polygonMarker.contentHolder, altizureProjectMarker.contentHolder]
   // here a polygonMarker and an altizureProjectMarker are rendered
 )
 // RGBSnapshot.dimension: {width: width of the snapshot, height: height of the snapshot}
 // RGBSnapshot.buffer: UintArray8 with size 4 * dimension.width * dimension.height
 // RGBSnapshot.bbox: the bounding box of the snapshoted area
 // RGBSnapshot.resolution: area that each pixel represents
 // RGBSnapshot.resolutionwidth: width of area that each pixel represents
 // RGBSnapshot.resolutionheight: height of area that each pixel represents

Take a depth snapshot

 let boundaryPtns = [
   {lng: 113.939, lat: 22.536},
   {lng: 113.9391, lat: 22.5361},
   // more points to specify the boundary
   ...
 ]
 // take a depth snapshot
 let depthSnapshot = sandbox.markerSnapshot(
   boundaryPtns, //boundary
   {min: 0, max 40}, // altitude range
   [altizureProjectMarker.contentHolder],
   // here an altizureProjectMarker is rendered
   true // so that this will returns a depth snapshot
 )
 // depthSnapshot.dimension: {width: width of the snapshot, height: height of the snapshot}
 // depthSnapshot.buffer: UintArray8 with size dimension.width * dimension.height. Higher place should be darker (smaller values)
 // depthSnapshot.bbox: the bounding box of the snapshoted area
 // depthSnapshot.resolution: area that each pixel represents
 // RGBSnapshot.resolutionwidth: width of area that each pixel represents
 // RGBSnapshot.resolutionheight: height of area that each pixel represents

off(eventType, handler)

取消注册事件。

Parameters:
Name Type Description
eventType string

'cameraChange'

handler function

on(eventType, handler)

活动注册。

Parameters:
Name Type Description
eventType string

'cameraChange'

handler function

事件处理函数

pick(event) → {LngLatAlt}

在指定的鼠标事件位置选取地球上的点。

Parameters:
Name Type Description
event MouseEvent

鼠标/触摸事件

Returns:
LngLatAlt -
  • 与地球的接触点
Inherited From:
Example

pick earth point by mouse

let earth = new altizure.Earth('page-content', options)
let domElement = earth.domElement
domElement.addEventListener('mousedown', function (event) {
  if (event.button === 0) { // left button
    let pt = earth.pick(event)
    console.log('earth.pick', pt)
  }
}, false)

pickOnProjects(event) → {LngLatAlt}

选择altizure模型上的点。

Parameters:
Name Type Description
event MouseEvent

鼠标/触摸事件

Returns:
LngLatAlt -
  • 与任何AltizureProjectMarker的联络点,未定义 如果不与项目联系
Inherited From:

polygonsFromGeoJson(geojson, polygonOptions) → {Array.<PolygonMarker>}

使用GeoJson构建一个PolygonMarker列表

Parameters:
Name Type Description
geojson object
polygonOptions object

默认{top:4,bottom:0.1,color:0x0000ff,opacity:0.3}

Returns:
Array.<PolygonMarker>

positionsAltitude(positions, projMarkerList) → {array}

计算职位列表的高度。

Parameters:
Name Type Description
positions array

以{lng,lat}形式表示的LngLatAlt位置或位置阵列。

projMarkerList array

一系列altizure项目标记。用于减少此功能的负载。

Returns:
array -
  • 每个职位的高度

queryGeoJsonForAltizureProjectMarker(altizureProjectMarker) → {Promise}

查询GeoJson(构建)AltizureProjectMarker

Parameters:
Name Type Description
altizureProjectMarker AltizureProjectMarker
Returns:
Promise

render(marker, mode)

更改(altizureProject)标记的渲染模式。

Parameters:
Name Type Description
marker AltizureProjectMarker
mode string

'texture'= 0,'flat','wireframe','select','crop','visibility','transparent','phong'

unfreeze() → {bool}

解冻地球轨道控制。

Returns:
bool
Inherited From:

updateVisibility()

更新屏幕可见性。通常在相机更换后调用。