3d
3d 辅助函数
rotatePoint
旋转平面 x y 轴,xy 坐标 3d 旋转,3d 旋转时使用
ts
const mapRotate = {
rx: 35,
ry: 15,
rz: -15,
};
const mapCenterXY = [103.001033, 30.659462];
const projection = {
project: (point: number[]) =>
rotatePoint(
[
(point[0] / 180) * Math.PI,
-Math.log(Math.tan((Math.PI / 2 + (point[1] / 180) * Math.PI) / 2)),
],
mapCenterXY,
mapRotate.rx,
mapRotate.ry,
mapRotate.rz
),
unproject: (point: number[]) => {
const reversePoint = rotatePoint(
point,
mapCenterXY,
-mapRotate.rx,
-mapRotate.ry,
-mapRotate.rz
);
return [
(reversePoint[0] * 180) / Math.PI,
((2 * 180) / Math.PI) * Math.atan(Math.exp(reversePoint[1])) - 90,
];
},
};