原始坐标数据来源于threejs 在cesium 需要做如下转换
const position = {
x:1,
y:1,
z:1
}
const newPos: TunnelTypes = {
x: position.x,
y: position.z * -1,
z: position.y
};
转化后使用 geodesy 库实现求具体的偏移量
import LatLonSpherical from 'geodesy/latlon-spherical.js';
const startPoint = new LatLonSpherical(0, 0);
const newX = x;
const newY = y;
const newZ = z;
startPoint.lat = lat;
startPoint.lon = long;
const destinationPoint = startPoint.destinationPoint(newY, 0);
const destinationPoint2 = destinationPoint.destinationPoint(newX, 90);
const result = wgs84ToCartesian3({
long: destinationPoint2.lon,
lat: destinationPoint2.lat,
height: new Big(height).plus(newZ).toNumber()
});
const hpr = new HeadingPitchRoll(0, 0, 0);
const modelMatrix = Transforms.headingPitchRollToFixedFrame(result, hpr);
计算需要旋转后对应的坐标方法
const heading = CesiumMath.toRadians(orientationAngle);
const hpr = new HeadingPitchRoll(heading, 0, 0);
const destinationPoint = startPoint.destinationPoint(newY, orientationAngle);
const destinationPoint2 = destinationPoint.destinationPoint(newX, 90 + orientationAngle);