cesium获取当前视角参数
获取当前屏幕中心的经纬度坐标、笛卡尔坐标、heading、pitch、roll参数。
function getCamera() {
const camera = viewer.scene.camera
const cartographic = Cesium.Cartographic.fromCartesian(camera.position)
const x = Cesium.Math.toDegrees(cartographic.longitude)
const y = Cesium.Math.toDegrees(cartographic.latitude)
const z = cartographic.height
let pt = Cesium.Cartographic.fromDegrees(x, y, z);
let ellipsoid = viewer.scene.globe.ellipsoid;
let cartesian3 = ellipsoid.cartographicToCartesian(pt);
let objinfo = {
"经度": x,
"维度": y,
"高度": z,
"x": cartesian3.x,
"y": cartesian3.y,
"z": cartesian3.z,
"heading": camera.heading,
"pitch": camera.pitch,
"roll": camera.roll
}
console.log(objinfo)
}