Cesium 获取当前摄像机的姿态

2021/5/23 18:55:44

本文主要是介绍Cesium 获取当前摄像机的姿态,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

Cesium 获取当前摄像机的姿态

var arrLoc = \[\];  
var pickPosition = \{ x: null, y: null \}  
var handler = new Cesium.ScreenSpaceEventHandler(viewer.scene.canvas);  //定义事件  
handler.setInputAction(function (movement) \{

  
// screenLocation.x = movement.position.x;  
// screenLocation.y = movement.position.y;

  
var cartesian = viewer.camera.pickEllipsoid(  
movement.position,  
scene.globe.ellipsoid  
);  
if (cartesian) \{  
var cartographic = Cesium.Cartographic.fromCartesian(cartesian);  
var longitudeString = Cesium.Math.toDegrees(  
cartographic.longitude  
).toFixed(2);                               //要更高的精度就修改保留的小数位数  
var latitudeString = Cesium.Math.toDegrees(  
cartographic.latitude  
).toFixed(2);                               //同上

  
pickPosition.x = longitudeString;  
pickPosition.y = latitudeString;  
let cf = \{ x: parseFloat(pickPosition.x), y: parseFloat(pickPosition.y) \}

  
console.log(cf) //鼠标点击位置

  
var a = \{  
position: viewer.camera.position,  
heading: viewer.camera.heading,  
pitch: viewer.camera.pitch  
\}  
console.log(a) //当前视角  
\}  
\}, Cesium.ScreenSpaceEventType.LEFT\_CLICK);


这篇关于Cesium 获取当前摄像机的姿态的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程