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

+9 -8
View File
@@ -1,4 +1,5 @@
import * as Cesium from 'cesium';
import * as geo from '../geo/index.js';
/**
* Model-space visual centres measured from the shipped GLBs' scene-space AABBs.
*
@@ -76,13 +77,13 @@ export const MODEL_TRAIL_ANCHOR_NATIVE = Object.freeze({
* renders with `modelMatrix x components.transform x axisCorrection`, and the
* trail anchor has to ride the same chain or it lands on a different axis than
* the aircraft it is supposed to be attached to. */
const AXIS_CORRECTION = Cesium.Matrix4.multiplyTransformation(
const AXIS_CORRECTION = geo.matrix4.multiplyTransformation(
Cesium.Axis.Y_UP_TO_Z_UP,
Cesium.Axis.Z_UP_TO_X_UP,
new Cesium.Matrix4(),
geo.matrix4.create(),
);
const _anchorScratch = new Cesium.Cartesian3();
const _chainScratch = new Cesium.Matrix4();
const _anchorScratch = geo.cartesian3.create();
const _chainScratch = geo.matrix4.create();
/**
* World position of a model-local anchor, through the SAME transform chain
@@ -121,17 +122,17 @@ export function modelAnchorWorld(model, nativeAnchor, result) {
// correction. Read from the instance rather than assumed, so an asset with a
// baked root transform is carried too.
const components = model?.sceneGraph?.components?.transform;
Cesium.Matrix4.multiplyTransformation(
geo.matrix4.multiplyTransformation(
model.modelMatrix,
components || Cesium.Matrix4.IDENTITY,
components || geo.matrix4.IDENTITY,
_chainScratch,
);
Cesium.Matrix4.multiplyTransformation(
geo.matrix4.multiplyTransformation(
_chainScratch,
AXIS_CORRECTION,
_chainScratch,
);
return Cesium.Matrix4.multiplyByPoint(_chainScratch, _anchorScratch, result);
return geo.matrix4.multiplyByPoint(_chainScratch, _anchorScratch, result);
}
/**