高度计算其实方法很多,关键在交互体验上的易用性和直观性。
首先,获取鼠标交互坐标:
其次,存入鼠标点击的xyz,然后画出entity单元:
positon:
label:
polyline:
然后,鼠标事件进入mouse.move中,添加move的xyz到entity位置的
Cesium.CallbackProperty中。
对水平位移赋值到高度位移变化中(因为三维场景交互高度移动体验不好,不容易移动),关键代码:
let lonOri = Cesium.Math.toRadians(tempHeightOriLonLat[0]) let latOri = Cesium.Math.toRadians(tempHeightOriLonLat[1]) let heightOri = tempHeightOriLonLat[2] let lastLon = Cesium.Math.toRadians(tempHeightArr[2]) let lastLat = Cesium.Math.toRadians(tempHeightArr[3]) let distancetoHeight = Math.abs(Math.sqrt(Math.pow((lastLon-lonOri),2)+Math.pow((lastLat-latOri),2)))*6378137 console.log("原始高",heightOri,"高度变化",distancetoHeight)