视角飞行功能相关

1.用于项目初始化视角及点击某一按钮飞行到指定的位置

// 获取destination 和 orientation

viewer.screenSpaceEventHandler.setInputAction(function onLeftClick(movement) {

let worldPosition = viewer.scene.pickPosition(movement.position);

let cartographic = NF.Cartographic.fromCartesian(worldPosition);

let 相机视角信息 = {

destination: {

x: viewer.camera.position.x,

y: viewer.camera.position.y,

z: viewer.camera.position.z

},

orientation: {

heading: viewer.camera.heading,

pitch: viewer.camera.pitch,

roll: viewer.camera.roll

}

}

console.log('相机视角信息', 相机视角信息);

}, NF.ScreenSpaceEventType.LEFT_CLICK);

// 项目初始视角

ZhiYunGisProperty.ZhiYunViewer.camera.flyTo({

destination : {x: -2575531.245434923, y: 4501622.944444179, z: 3700509.0237947735},

orientation : {

heading : 0.010234152586337864,

pitch : -0.31173143691065497,

roll : 6.283185307179586

}

});

2.保存当前视角,当需要时返回保存的视角

// 保存场景信息

let position, up ,direction;

position = viewer.camera.positionWC.clone();

up = viewer.camera.up.clone();

direction = viewer.camera.direction.clone();

// 返回不存的场景信息

viewer.camera.setView({

destination: position,

orientation: {

direction: direction,

up: up }

});

 

你可能感兴趣的:(Cesiumjs)