界面
相机模块
简介
相机模块提供了相机定位、相机控制和相机漫游等功能。
功能使用
与在Scene中提到的也是区别于其他功能模块最重要的方法
,就是除了Scene类(还有ui),其他的类库在使用时,需要先初始化示例,比如:
js
// 授权码
const kapi = await KAPI.build('Your Auth Token')
// 加载云流场景服务
const scene = new kapi.Scene('kapi-container', { server: 'Your Service URL' })
// 等待场景加载好
const readyState = await scene.ready()
const camera = new kapi.Camera()
console.log(camera)
实例化后的相机模块,就可以执行相机的功能,比如开启漫游
:
js
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)
同样,可以执行关闭漫游
:
js
const camera = new kapi.Camera()
const routeState = await camera.stopRoute()
console.log(routeState)
提示
不同类库的功能在不断丰富完善