mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-15 15:52:21 +00:00
refactor(camera,data): take vector maths from src/geo
Move the Cartesian3/Cartographic/Matrix/Quaternion/Transforms/Math calls of the first batch (src/data motion, anchor, tracked-camera and icon helpers; the root camera, locations, HUD, share-link, world-focus, ground-guard, orbit and cloud modules; services/groundSnap) to src/geo. Behaviour is unchanged: same argument order, same `result` semantics. Kept on Cesium: out-of-scope classes (JulianDate, Axis, HeadingPitchRange, BoundingSphere, Rectangle, EasingFunction, EllipsoidalOccluder with its WGS84 and seed vector, SceneTransforms) and Matrix4.IDENTITY wherever it is handed straight to a Cesium camera call (locations.test pins its identity). synthesizeForwardKinematicsFix now returns a plain position, so the two snapshot renderers clone it with the static Cesium.Cartesian3.clone instead of the instance method. The package-boundary groups that reach these modules now own the src/geo files.
This commit is contained in:
1 parent
4a92ed8377
commit
d886be68a8
17 files changed
+481
-285
No files matched your search
@@ -15,6 +15,7 @@
|
||||
* held, so the correction reads as the shot settling.
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
import * as geo from './geo/index.js';
|
||||
import { ownCameraArrival } from './data/cameraArrival.js';
|
||||
|
||||
/** Minimum eye height above the rendered surface for a usable view. */
|
||||
@@ -25,7 +26,7 @@ export const GUARD_INTERVAL_MS = 600;
|
||||
/** Ignore sub-metre noise rather than nudging the camera forever. */
|
||||
const GUARD_EPSILON_M = 2;
|
||||
|
||||
const probeScratch = new Cesium.Cartographic();
|
||||
const probeScratch = geo.cartographic.create();
|
||||
|
||||
/**
|
||||
* Highest rendered surface across a few cells, with how many cells answered.
|
||||
@@ -41,7 +42,7 @@ function sampleSurfaceM(scene, cells) {
|
||||
for (const cell of cells) {
|
||||
try {
|
||||
const height = scene.sampleHeight(
|
||||
Cesium.Cartographic.fromDegrees(cell.lon, cell.lat, 0, probeScratch),
|
||||
geo.cartographic.fromDegrees(cell.lon, cell.lat, 0, probeScratch),
|
||||
);
|
||||
if (!Number.isFinite(height)) continue;
|
||||
sampled += 1;
|
||||
@@ -152,8 +153,8 @@ export function guardCameraAboveGround(viewer, at, options = {}) {
|
||||
const carto = camera.positionCartographic;
|
||||
// The eye must clear both the framed target and the ground beneath it.
|
||||
const below = {
|
||||
lat: Cesium.Math.toDegrees(carto.latitude),
|
||||
lon: Cesium.Math.toDegrees(carto.longitude),
|
||||
lat: geo.math.toDegrees(carto.latitude),
|
||||
lon: geo.math.toDegrees(carto.longitude),
|
||||
};
|
||||
const { heightM, sampled } = sampleSurfaceM(viewer.scene, [
|
||||
{ lat: at.lat, lon: at.lon },
|
||||
@@ -168,7 +169,7 @@ export function guardCameraAboveGround(viewer, at, options = {}) {
|
||||
if (deficit > 0) {
|
||||
stop();
|
||||
camera.flyTo({
|
||||
destination: Cesium.Cartesian3.fromRadians(
|
||||
destination: geo.cartesian3.fromRadians(
|
||||
carto.longitude,
|
||||
carto.latitude,
|
||||
carto.height + deficit,
|
||||
|
||||
Reference in new issue
Block a user