我的github
posts - 3243,  comments - 42,  views - 158万

第一视角

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;
        }
复制代码

 

posted on   XiaoNiuFeiTian  阅读(4292)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
历史上的今天:
2020-10-26 ArcObjects
2020-10-26 Dojo是什么?
2020-10-26 百度地图是什么坐标系?
2020-10-26 高德地图API
2020-10-26 地理POI数据爬取-以百度地图为例
2016-10-26 TurtleBot教程
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示