界面
相机
new Camera()
实例化
返回:
- 实例化Camera对象
详情:
实例化
Camera
对象,可以调用相机模块中的方法示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
console.log(camera)
getCameraInfo()
获取相机信息
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 获取相机信息的返回信息
详情:
返回相机的信息,可以获得相机的位置、姿态、高度信息
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const camearInfo = await camera.getCameraInfo()
console.log(camearInfo)
flyTo()
飞行到某个位置
参数:
{Object} position 根渲染节点
{Object} duration 动画持续时间,单位秒,默认1.5秒
{Boolean} sync 是否要与其他客户端同步状态
postion参数如下表
参数 | 类型 | 描述 |
---|---|---|
x | number | x坐标/经度 |
y | number | y坐标/维度 |
z | number | z坐标/高度 |
rotation | object | 姿态 |
roll | number | roll |
pitch | number | pitch |
yaw | number | yaw |
返回:
- 执行飞行到某个位置后的返回信息
详情:
以动画的形式,从当前位置飞行到目标位置处。
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const postion = {
x: 108020.0,
y: -129000.0,
z: -8240.0,
rotation: {
roll: 0,
pitch: 0,
yaw: -120.000153
}
}
const camearInfo = await camera.flyTo(postion, 1.5)
console.log(camearInfo)
addBookmark()
获取相机信息(TODO)
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 获取相机信息的返回信息
详情:
返回相机的信息,可以获得相机的位置、姿态、高度信息
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const camearInfo = await camera.getCameraInfo()
console.log(camearInfo)
setRotationStatus()
设置场景绕物旋转
参数:
{Boolean} status 开启状态
{Number} speed 旋转速度
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 设置场景绕物旋转后的返回信息
详情:
设置场景围绕某个中心点旋转,中心点是在场景中定制的。
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const rotetionState = await camera.setRotationStatus(true, 0.5)
console.log(rotetionState)
playRoute()
开始漫游
参数:
{Boolean} route 路线数组,投影坐标和地理坐标都是x,y,z
{Object} option 飞行参数
{Boolean} sync 是否要与其他客户端同步状态
option参数如下表
变量 | 类型 | 说明 |
---|---|---|
speed | number | 飞行速度,默认10m/s,单位(米/每秒,m/s) |
time | number | 两点飞行间隔时间 |
isGraphic | string | 是否是地理坐标(经纬度),默认true |
返回:
- 开始漫游后的返回信息
详情:
开始漫游。
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const route = [{x: 117.0951698, y: 36.6568560, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.0989151, y: 36.6579687, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.101380, y: 36.658651, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.104513, y: 36.658556, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.110243, y: 36.658797, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.113300, y: 36.659102, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.117694, y: 36.659221, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.121247, y: 36.659218, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.122851, y: 36.658847, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.126288, y: 36.658258, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.128160, y: 36.658287, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.128318, y: 36.661273, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.1294164, y: 36.6614676, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.1302911, y: 36.6619168, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}},
{x: 117.1306743, y: 36.6626012, z: 100, rotation: {yaw: 1, roll: 0, pitch: 1}}
]
const option = {
speed: 10,
time: 3,
isGraphic: true
}
const routeState = await camera.playRoute(route, option)
console.log(routeState)
stopRoute()
停止漫游
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 停止漫游后的返回信息
详情:
停止漫游。
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const routeState = await camera.stopRoute()
console.log(routeState)
playRouteFree()
开始自由漫游
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 开始自由漫游后的返回信息
详情:
开始自由漫游
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const routeState = await camera.playRouteFree()
console.log(routeState)
stopRouteFree()
停止自由漫游
参数:
{Boolean} sync 是否要与其他客户端同步状态
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 停止自由漫游后的返回信息
详情:
停止自由漫游。
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const routeState = await camera.stopRouteFree()
console.log(routeState)
startPatrol()
开始巡检
参数:
{Number} type 巡检类型,0人员车辆巡检,1其他巡检
{Number} speed 移动速度,单位(米/秒),默认10米/秒
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 开始巡检后的返回信息
详情:
开始巡检
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const patrolState = await camera.startPatrol()
console.log(patrolState)
stopPatrol()
停止巡检
参数:
{Boolean} sync 是否要与其他客户端同步状态
参数:
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 停止巡检后的返回信息
详情:
停止巡检。
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const patrolState = await camera.stopPatrol()
console.log(patrolState)
setCameraHeight()
抬升相机高度
参数:
{Number} height 需要抬升的高度
{Boolean} sync 是否要与其他客户端同步状态
返回:
- 抬升高度后的返回信息
详情:
提高场景的视角高度。
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const heightState = await camera.setCameraHeight(100)
console.log(heightState)
setCameraSpeed()
设置相机移动速度
参数:
{Object} option 移动速度参数
{Boolean} sync 是否要与其他客户端同步状态
option参数如下表
变量 | 类型 | 说明 |
---|---|---|
speed | number | 移动速度 |
speedUp | number | 按开键盘后到speed时的加速度 |
speedDown | number | 松开键盘后速度停止到0减速度 |
返回:
- 设置相机移动速度后的返回信息
详情:
提高场景的视角高度。
示例:
js
import KAPI from '@ibrucekong/kapi'
const kapi = await KAPI.build('Your Auth Token')
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' } )
const camera = new kapi.Camera()
const option = {
speed: 10,
speedUp: 20,
speedDown: 30,
}
const speedState = await camera.setCameraSpeed(option)
console.log(speedState)