Cesium相機參數 如何獲取相機的高度、經緯度和姿態角


第一視角

Cesium中的相機—四元素:https://blog.csdn.net/u011575168/article/details/83034048

Cesium官方教程6--相機:https://www.cnblogs.com/cesium1/p/10063020.html

相機的高度和飛機的高度不同。。。

利用:

viewer.camera.flyTo({
  destination : Cesium.Cartesian3.fromDegrees(lng, lat,alt),
  orientation : {
      heading : Cesium.Math.toRadians(0.0),
      pitch : Cesium.Math.toRadians(-90.0),
      roll : 0.0
  }
});
得到的相機高度與傳入的alt高度不同。。
獲取相機高度:viewer.camera.positionCartographic.height
獲取相機的位姿:
var handler = new Cesium.ScreenSpaceEventHandler(this.viewer.scene.canvas);
handler.setInputAction(click => {
this.viewer.clock.onTick.removeEventListener(onTickCallback);

//查看當前視角的 x,y,z,heading,pitch,roll值
var e = click;
var position = this.viewer.scene.pickPosition(e.position);
//將笛卡爾坐標轉化為經緯度坐標
var cartographic = Cesium.Cartographic.fromCartesian(position);
var x = Cesium.Math.toDegrees(cartographic.longitude);
var y = Cesium.Math.toDegrees(cartographic.latitude);
var z = cartographic.height;
var h = this.viewer.scene.camera.heading;
var p = this.viewer.scene.camera.pitch;
var r = this.viewer.scene.camera.roll;
handler.removeInputAction(Cesium.ScreenSpaceEventType.LEFT_CLICK)
}, Cesium.ScreenSpaceEventType.LEFT_CLICK);

參考:https://blog.csdn.net/qq_29808089/article/details/108464481

 

 

 

 

>>參考:UAV-simulation: 基於Cesium的無人機飛行模擬 (https://gitee.com/KivenGood/uav-simulation)

//移動模型
        function moveModel() {
            //  tempLng += (step * correction);
            // tempLat -= (step * Math.sin(tempHeading)); //主要用來左右移動

            //tempLat += step

            tempLat = +msg[0].GPS_LAT_CA - 10;
            tempLng = +msg[0].GPS_LONG_CA - 3.5;
            //  tempHeight = +msg[0].ALT_STD+1000;
            tempHeight = 2000;
            //  tempRoll = +msg[0].ROLL_RATE1;
            localStorage.setItem("msg", JSON.stringify(msg[0]));
            console.log("localStorage:" + JSON.stringify(JSON.parse(localStorage.getItem("msg"))));
            console.log("msg.length1:" + msg.length);
            console.log("***tempLng:" + tempLng);
            console.log("***tempLat:" + tempLat);
            console.log("***tempHeight:" + tempHeight);
            console.log("***tempHeading:" + tempHeading);
            console.log("***tempPitch:" + tempPitch);
            console.log("*** tempRoll:" + tempRoll);
            var position = myCesium.Cartesian3.fromDegrees(tempLng, tempLat, tempHeight);
            var hpr = new myCesium.HeadingPitchRoll(tempHeading, tempPitch, tempRoll);
            var orientation = myCesium.Transforms.headingPitchRollQuaternion(position, hpr);
            myEntity.orientation = orientation;
            myEntity.position = position;
            msg.shift();
            console.log("!!!!msg[0].id" + msg[0].id);
            //受異步請求影響,state相當於一個鎖,當數據請求結束才開鎖
            if (msg.length < 100 && state == 0) {
                console.log("!!!!!!");
                state = 1;
                readData();
            }
            document.getElementById('msg').innerHTML = "tempLng:" + tempLng;
            document.getElementById('msg1').innerHTML = "tempLat:" + tempLat;
            document.getElementById('msg2').innerHTML = "tempPitch:" + tempPitch;
            document.getElementById('msg3').innerHTML = "tempHeight:" + parseInt(tempHeight);
            document.getElementById('msg4').innerHTML = "tempHeading:" + tempHeading;
            document.getElementById('msg5').innerHTML = "tempRoll:" + tempRoll;
            //    document.getElementById('msg6').innerHTML = "step:" + step;
            document.getElementById('msg7').innerHTML = "correction:" + correction;
        }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM