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);
上一篇:iOS开发UI篇—核心动画(关键帧动画)


下一篇:地图可视化开发技术选型