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:
German Khokhlov committed 2026-10-15 00:15:59 +04:00
1 parent 4a92ed8377
commit d886be68a8
17 files changed
+481 -285

No files matched your search

+10 -16
View File
@@ -1,4 +1,5 @@
import * as Cesium from 'cesium';
import * as geo from './geo/index.js';
import { BLOOM_INTENSITY_DEFAULT, BLOOM_SCALE_VERSION } from './bloom.js';
import {
migrateDetectionState,
@@ -263,15 +264,11 @@ export class ShareLinkManager {
if (this._destroyed || !state)
return { succeeded: false, reason: 'unavailable' };
const view = {
destination: Cesium.Cartesian3.fromDegrees(
state.lon,
state.lat,
state.alt,
),
destination: geo.cartesian3.fromDegrees(state.lon, state.lat, state.alt),
orientation: {
heading: Cesium.Math.toRadians(state.heading),
pitch: Cesium.Math.toRadians(state.pitch),
roll: Cesium.Math.toRadians(state.roll),
heading: geo.math.toRadians(state.heading),
pitch: geo.math.toRadians(state.pitch),
roll: geo.math.toRadians(state.roll),
},
};
let cameraPromise = Promise.resolve({
@@ -548,21 +545,18 @@ export class ShareLinkManager {
const params = new URLSearchParams();
params.set('v', '2');
params.set('lat', Cesium.Math.toDegrees(carto.latitude).toFixed(4));
params.set('lon', Cesium.Math.toDegrees(carto.longitude).toFixed(4));
params.set('lat', geo.math.toDegrees(carto.latitude).toFixed(4));
params.set('lon', geo.math.toDegrees(carto.longitude).toFixed(4));
params.set('alt', Math.round(carto.height).toString());
params.set(
'heading',
Math.round(Cesium.Math.toDegrees(camera.heading)).toString(),
Math.round(geo.math.toDegrees(camera.heading)).toString(),
);
params.set(
'pitch',
Math.round(Cesium.Math.toDegrees(camera.pitch)).toString(),
);
params.set(
'roll',
Math.round(Cesium.Math.toDegrees(camera.roll)).toString(),
Math.round(geo.math.toDegrees(camera.pitch)).toString(),
);
params.set('roll', Math.round(geo.math.toDegrees(camera.roll)).toString());
params.set('style', STYLE_TO_URL[this._currentStyle] || 'normal');
params.set('bloom', this._bloomEnabled ? '1' : '0');
params.set('sharpen', this._sharpenEnabled ? '1' : '0');