feat(geo): add src/geo, Cesium's vector maths without Cesium

An engine-neutral port of the CesiumJS 1.138 core maths gev uses: angle
maths, the WGS84 ellipsoid and geodetic coordinates, 2D/3D vectors, 3x3/4x4
matrices, quaternions and local east-north-up / heading-pitch-roll frames.
Formulas and operation order match Cesium, so outputs are bit-identical
(golden tests pin the centre, pole, -0 and quaternion branches).

- Values are plain-data instances of module-private constructors (own
  enumerable fields only), so geo's hot functions keep their own V8 hidden
  classes; matrices are plain column-major arrays Cesium accepts.
- Cesium's debug argument checks are ported with the same conditions, order
  and DeveloperError messages, gated on DEBUG (src/geo/debug.js): on in Node
  and the dev server, folded away by vite build, as Cesium's Build strips
  them. A release-parity test compares DEBUG=false geo with Build/Cesium.
- The import-direction check forbids cesium and @cesium/* in src/geo;
  CODE-BOUNDARIES.md and THIRD_PARTY_NOTICES.md document the port.
This commit is contained in:
German Khokhlov committed 2026-10-15 00:15:20 +04:00
1 parent 132b9e96dc
commit 4a92ed8377
29 files changed
+4470 -6

No files matched your search

+26
View File
@@ -82,6 +82,24 @@ for (const [name, files, pattern] of [
},
/reaches browser globals/,
],
[
'geo module imports cesium',
{ 'src/geo/demo.js': "import 'cesium';" },
/src\/geo\/demo\.js: geo reaches platform\/rendering dependency: cesium/,
],
[
'geo module imports a Cesium workspace package',
{ 'src/geo/demo.js': "import { Cartesian3 } from '@cesium/engine';" },
/src\/geo\/demo\.js: geo reaches platform\/rendering dependency: @cesium\/engine/,
],
[
'geo module reaches cesium through a helper',
{
'src/geo/demo.js': "import '../data/helper.js';",
'src/data/helper.js': "export * from 'cesium';",
},
/src\/data\/helper\.js: geo reaches platform\/rendering dependency: cesium/,
],
[
'browser imports Node without prefix',
{ 'src/unused.mjs': "import 'fs/promises';" },
@@ -149,6 +167,14 @@ for (const [name, files, pattern] of [
});
}
test('geo modules may import each other, and its tests may import cesium', (t) => {
const { root, write } = fixture(t);
write('src/geo/math.js', 'export const half = (value) => value / 2;');
write('src/geo/demo.js', "export { half } from './math.js';");
write('src/geo/demo.test.mjs', "import 'cesium'; import './demo.js';");
assert.doesNotThrow(() => checkImportDirections(root));
});
test('self package imports cannot evade portable ownership', (t) => {
const { root, write } = fixture(t, { './view': './src/ui/view.js' });
write('src/sources/demo.js', "import '@gods-eye-view/core/view';");