mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
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.
60 lines
2.2 KiB
JavaScript
60 lines
2.2 KiB
JavaScript
import assert from 'node:assert/strict';
|
||
import * as Cesium from 'cesium';
|
||
import test from 'node:test';
|
||
import { fromDegrees } from './ellipsoid.js';
|
||
import { sphereFromPoints, sphereUnion } from './sphere.js';
|
||
|
||
test('a sphere from points is the default renderer’s, to the bit', () => {
|
||
let seed = 7;
|
||
const random = () => (seed = (seed * 16807) % 2147483647) / 2147483647;
|
||
const cases = [
|
||
[],
|
||
[fromDegrees(10, 20)],
|
||
[fromDegrees(-125.8, 15.5), fromDegrees(-130, 18), fromDegrees(-135, 21)],
|
||
// Across the antimeridian, and a long track.
|
||
Array.from({ length: 40 }, (_, i) => fromDegrees(170 + i, -10 + i / 2)),
|
||
Array.from({ length: 200 }, () =>
|
||
fromDegrees(random() * 360 - 180, random() * 180 - 90, random() * 1e5),
|
||
),
|
||
];
|
||
for (const points of cases) {
|
||
const ours = sphereFromPoints(points);
|
||
const theirs = Cesium.BoundingSphere.fromPoints(
|
||
points.map((p) => new Cesium.Cartesian3(p.x, p.y, p.z)),
|
||
);
|
||
assert.deepEqual(
|
||
[ours.center.x, ours.center.y, ours.center.z, ours.radius],
|
||
[theirs.center.x, theirs.center.y, theirs.center.z, theirs.radius],
|
||
);
|
||
}
|
||
});
|
||
|
||
test('the union of two spheres is the default renderer’s, to the bit', () => {
|
||
const sphere = (x, y, z, radius) => ({ center: { x, y, z }, radius });
|
||
const cases = [
|
||
// Apart, overlapping, one inside the other either way, concentric.
|
||
[sphere(0, 0, 0, 6378137), sphere(4.2e7, 1e6, -3e5, 2.1e7)],
|
||
[sphere(1, 2, 3, 10), sphere(5, -4, 2, 8)],
|
||
[sphere(0, 0, 0, 6378137), sphere(1e5, 0, 0, 7000)],
|
||
[sphere(1e5, 0, 0, 7000), sphere(0, 0, 0, 6378137)],
|
||
[sphere(3, 3, 3, 5), sphere(3, 3, 3, 5)],
|
||
];
|
||
for (const [left, right] of cases) {
|
||
const ours = sphereUnion(left, right);
|
||
const theirs = Cesium.BoundingSphere.union(
|
||
new Cesium.BoundingSphere(
|
||
new Cesium.Cartesian3(left.center.x, left.center.y, left.center.z),
|
||
left.radius,
|
||
),
|
||
new Cesium.BoundingSphere(
|
||
new Cesium.Cartesian3(right.center.x, right.center.y, right.center.z),
|
||
right.radius,
|
||
),
|
||
);
|
||
assert.deepEqual(
|
||
[ours.center.x, ours.center.y, ours.center.z, ours.radius],
|
||
[theirs.center.x, theirs.center.y, theirs.center.z, theirs.radius],
|
||
);
|
||
}
|
||
});
|