mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
The application shell keeps the page's globe engine and hands it to the navigation controller, location navigation (search, city and POI flights, orbit, globe reset), the tilt and north-up controls, share-link save and restore, share restoration's first-gesture listeners and the HUD. The viewer is passed only where entity tracking still lives on it (phase 1c) and to the HUD's basemap label context (voice); every such use is null-safe. Share links and captured shots write heading and roll as Cesium's camera reports them (src/cameraAngles.js): the contract's [0, 2π) pose maps an exact 0 back to Cesium's 2π, except the roll of a vertical view, so links stay byte-identical (heading=360, roll=360) on every engine. Source-reading tests follow the moved code with the same checks.
34 lines
1.1 KiB
JavaScript
34 lines
1.1 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import * as geo from './geo/index.js';
|
|
import { cesiumHeading, cesiumRoll, poseIsVertical } from './cameraAngles.js';
|
|
import { createFakeEngine } from './globe/testing/fakeEngine.js';
|
|
|
|
const poseAt = (heading, pitch, roll = 0) => {
|
|
const engine = createFakeEngine();
|
|
engine.fake.setPose({
|
|
position: geo.cartesian3.fromDegrees(10, 45, 2000),
|
|
heading,
|
|
pitch,
|
|
roll,
|
|
});
|
|
return engine.camera.pose();
|
|
};
|
|
|
|
test('a level north-facing pose reports Cesium heading and roll 2π', () => {
|
|
const pose = poseAt(0, -0.5);
|
|
assert.equal(pose.heading, 0);
|
|
assert.equal(cesiumHeading(pose), 2 * Math.PI);
|
|
assert.equal(cesiumRoll({ ...pose, roll: 0 }), 2 * Math.PI);
|
|
assert.equal(poseIsVertical(pose), false);
|
|
});
|
|
|
|
test('a straight-down pose keeps roll 0; other angles pass through', () => {
|
|
const down = poseAt(0, -Math.PI / 2);
|
|
assert.equal(poseIsVertical(down), true);
|
|
assert.equal(cesiumRoll(down), 0);
|
|
const oblique = { ...poseAt(1, -0.5), heading: 1.25, roll: 0.5 };
|
|
assert.equal(cesiumHeading(oblique), 1.25);
|
|
assert.equal(cesiumRoll(oblique), 0.5);
|
|
});
|