如图,我想改变圆锥和卫星的朝向,改变的值是heading和pitch,但是改变之后圆锥和卫星发生了偏离,请问有没有什么好的解决办法?
大概解决了,就是先旋转再移动,移动的距离大概如下,l是圆锥的长度:
let offset = new Cesium.Cartesian3(
l/2 * Math.sin(pitch) * Math.cos(heading),
-l/2 * Math.sin(heading) * Math.sin(pitch),
0,
);
let enuTransform = Cesium.Transforms.eastNorthUpToFixedFrame(yz_position);
Cesium.Matrix4.multiplyByPointAsVector(enuTransform, offset, offset);
entity_yz.position = new Cesium.CallbackProperty(function () {
return Cesium.Cartesian3.add(yz_position, offset, new Cesium.Cartesian3())
}, false);
entity_yz.orientation = new Cesium.CallbackProperty(function () {
return Cesium.Transforms.headingPitchRollQuaternion(yz_position, hpr_yz)
}, false);