refactor(vessels,satellites,awareness): take vector maths from src/geo

Moves the Cartesian3/Cartographic/Matrix3/Matrix4/Math calls of the vessel, satellite and Contacts (awareness) layers, plus flights controller/enrichment, to src/geo. The satellites-layer package boundary now owns the src/geo modules. Awareness keeps Cesium.Cartesian3.clone for the resolved subject position, which reaches the installations anchor (anchor.test pins a Cesium instance).
This commit is contained in:
German Khokhlov committed 2026-10-15 00:17:17 +04:00
1 parent 1a69368ae6
commit 2b83606765
15 files changed
+97 -86

No files matched your search

+14 -14
View File
@@ -1,4 +1,4 @@
import * as Cesium from 'cesium';
import * as geo from '../../geo/index.js';
import {
gstime,
propagate,
@@ -24,16 +24,16 @@ export function createOrbits({ state: layerState, services, parts, source }) {
function orbitFrameModelMatrix(
gmstAtBake,
nowDate,
result = new Cesium.Matrix4(),
result = geo.matrix4.create(),
) {
const deltaGmst = gstime(nowDate) - gmstAtBake;
const rotation = Cesium.Matrix3.fromRotationZ(
const rotation = geo.matrix3.fromRotationZ(
-deltaGmst,
layerState._scratchRingRotation,
);
return Cesium.Matrix4.fromRotationTranslation(
return geo.matrix4.fromRotationTranslation(
rotation,
Cesium.Cartesian3.ZERO,
geo.cartesian3.ZERO,
result,
);
}
@@ -55,7 +55,7 @@ export function createOrbits({ state: layerState, services, parts, source }) {
if (!posVel.position || typeof posVel.position === 'boolean') return null;
const gmst = gstime(date);
const geo = eciToGeodetic(posVel.position, gmst);
const geodetic = eciToGeodetic(posVel.position, gmst);
const velocity =
posVel.velocity && typeof posVel.velocity !== 'boolean'
? posVel.velocity
@@ -65,9 +65,9 @@ export function createOrbits({ state: layerState, services, parts, source }) {
: null;
return {
longitude: degreesLong(geo.longitude),
latitude: degreesLat(geo.latitude),
altitude: geo.height * 1000, // km → meters
longitude: degreesLong(geodetic.longitude),
latitude: degreesLat(geodetic.latitude),
altitude: geodetic.height * 1000, // km → meters
speedMps: Number.isFinite(speedMps) ? speedMps : null,
};
} catch {
@@ -101,12 +101,12 @@ export function createOrbits({ state: layerState, services, parts, source }) {
try {
const posVel = propagate(satrec, t);
if (!posVel.position || typeof posVel.position === 'boolean') continue;
const geo = eciToGeodetic(posVel.position, fixedGmst);
const geodetic = eciToGeodetic(posVel.position, fixedGmst);
positions.push(
Cesium.Cartesian3.fromDegrees(
degreesLong(geo.longitude),
degreesLat(geo.latitude),
geo.height * 1000,
geo.cartesian3.fromDegrees(
degreesLong(geodetic.longitude),
degreesLat(geodetic.latitude),
geodetic.height * 1000,
),
);
} catch {