Compute launch paths, cameras and colours without Cesium

The launches layer's path building, replay camera maths, policy constants,
state, marker colours and mission panel no longer import Cesium. Paths and
camera poses are plain ECEF points computed by the geo helpers with the
default renderer's own formulas in the same order, so trajectories, orbits
and camera framing land where they did. Geodesic interpolation moves from
the stub renderer into geo/geodesic (geodesicLine, solved once per
geodesic), and geo/sphere gains the renderer's sphere union.

Marker colours are renderer colours, with the panel's CSS from the same
palette. The rendering part, still Cesium for its entities, converts the
plain points where the entities take them, culls with the shared horizon
test, loads the unbound camera factory, and hands the panel the live
payload position directly instead of through the entity.

Camera, model, panel, paths, policy, policyHelpers and state leave the
allow-list.
This commit is contained in:
Sameh Khamis committed 2026-11-06 22:57:55 -08:00
1 parent 0782b073e2
commit a2503476de
19 files changed
+561 -548

No files matched your search

+93
View File
@@ -148,3 +148,96 @@ export function geodesicInverse(lon1, lat1, lon2, lat2) {
export function surfaceDistance(start, end) {
return geodesicInverse(start.lon, start.lat, end.lon, end.lat).distance;
}
/**
* The WGS84 geodesic from (lon1, lat1) to (lon2, lat2), radians, solved once
* as the default renderer's `EllipsoidGeodesic` solves it: its length in
* metres, its start heading, and `at(fraction)`, the longitude and latitude
* (radians) that fraction of the way along it, by the series the renderer
* interpolates with, term for term. The longitude is not wrapped, as the
* renderer's is not.
*/
export function geodesicLine(lon1, lat1, lon2, lat2) {
const { distance, startHeading, uSquared } = geodesicInverse(
lon1,
lat1,
lon2,
lat2,
);
const cosH = Math.cos(startHeading);
const sinH = Math.sin(startHeading);
const tanU = (1 - FLATTENING) * Math.tan(lat1);
const cosU = 1 / Math.sqrt(1 + tanU * tanU);
const sinU = cosU * tanU;
const sigma1 = Math.atan2(tanU, cosH);
const sineAlpha = cosU * sinH;
const cos2Alpha = 1 - sineAlpha * sineAlpha;
const cosAlpha = Math.sqrt(cos2Alpha);
const u2 = uSquared / 4;
const u4 = u2 * u2;
const u6 = u4 * u2;
const u8 = u4 * u4;
const a0 = 1 + u2 - (3 * u4) / 4 + (5 * u6) / 4 - (175 * u8) / 64;
const a1 = 1 - u2 + (15 * u4) / 8 - (35 * u6) / 8;
const a2 = 1 - 3 * u2 + (35 * u4) / 4;
const a3 = 1 - 5 * u2;
const distanceRatio =
a0 * sigma1 -
(a1 * Math.sin(2 * sigma1) * u2) / 2 -
(a2 * Math.sin(4 * sigma1) * u4) / 16 -
(a3 * Math.sin(6 * sigma1) * u6) / 48 -
(Math.sin(8 * sigma1) * 5 * u8) / 512;
return {
distance,
startHeading,
at(fraction) {
const s = distanceRatio + (distance * fraction) / MINOR;
const cos2S = Math.cos(2 * s);
const cos4S = Math.cos(4 * s);
const cos6S = Math.cos(6 * s);
const sin2S = Math.sin(2 * s);
const sin4S = Math.sin(4 * s);
const sin6S = Math.sin(6 * s);
const sin8S = Math.sin(8 * s);
const s2 = s * s;
const s3 = s * s2;
let sigma =
(2 * s3 * u8 * cos2S) / 3 +
s *
(1 -
u2 +
(7 * u4) / 4 -
(15 * u6) / 4 +
(579 * u8) / 64 -
(u4 - (15 * u6) / 4 + (187 * u8) / 16) * cos2S -
((5 * u6) / 4 - (115 * u8) / 16) * cos4S -
(29 * u8 * cos6S) / 16) +
(u2 / 2 - u4 + (71 * u6) / 32 - (85 * u8) / 16) * sin2S +
((5 * u4) / 16 - (5 * u6) / 4 + (383 * u8) / 96) * sin4S -
s2 * ((u6 - (11 * u8) / 2) * sin2S + (5 * u8 * sin4S) / 2) +
((29 * u6) / 96 - (29 * u8) / 16) * sin6S +
(539 * u8 * sin8S) / 1536;
const theta = Math.asin(Math.sin(sigma) * cosAlpha);
const lat = Math.atan((MAJOR / MINOR) * Math.tan(theta));
sigma -= sigma1;
const cos2Sm = Math.cos(2 * sigma1 + sigma);
const sinSigma = Math.sin(sigma);
const cosSigma = Math.cos(sigma);
const lambda = Math.atan2(
sinSigma * sinH,
cosU * cosSigma - sinU * sinSigma * cosH,
);
const l =
lambda -
deltaLambda(sineAlpha, cos2Alpha, sigma, sinSigma, cosSigma, cos2Sm);
return { lon: lon1 + l, lat };
},
};
}
/** `geodesicLine(lon1, lat1, lon2, lat2).at(fraction)`. */
export function geodesicAt(lon1, lat1, lon2, lat2, fraction) {
return geodesicLine(lon1, lat1, lon2, lat2).at(fraction);
}