fix: refine 'Go To' camera alignment using flyToBoundingSphere

This commit is contained in:
silvertakana committed 2026-03-05 18:18:38 +13:00
1 parent 90d6985599
commit dadbeea612
1 file changed
+12 -8
+12 -8
View File
@@ -2,6 +2,8 @@ import {
Cartesian3,
Math as CesiumMath,
Matrix4,
BoundingSphere,
HeadingPitchRange,
} from "cesium";
import type { Viewer as CesiumViewer } from "cesium";
import { dataBus } from "@/core/data/DataBus";
@@ -108,14 +110,16 @@ export function goToEntity(
lon: number,
alt = 0
): void {
const viewDistance = Math.max(50000, alt * 3 + 30000);
viewer.camera.flyTo({
destination: Cartesian3.fromDegrees(lon, lat, alt + viewDistance),
orientation: {
heading: CesiumMath.toRadians(0),
pitch: CesiumMath.toRadians(-45),
roll: 0,
},
const target = Cartesian3.fromDegrees(lon, lat, alt);
const bs = new BoundingSphere(target, 0);
const hpr = new HeadingPitchRange(
CesiumMath.toRadians(0),
CesiumMath.toRadians(-45),
Math.max(50000, alt * 3 + 30000)
);
viewer.camera.flyToBoundingSphere(bs, {
offset: hpr,
duration: 1.5,
});
}