mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
refactor(ui): navigation, orientation, share links and HUD use the globe engine
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.
This commit is contained in:
1 parent
16e63f4c50
commit
ec38e6ef16
19 files changed
+594
-226
No files matched your search
@@ -10,6 +10,30 @@ import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { ShareLinkManager, decodeShareCreatedAtMs } from './sharelink.js';
|
||||
import { createDefaultLayerState } from './data/layerState.js';
|
||||
import { createFakeEngine } from './globe/testing/fakeEngine.js';
|
||||
/**
|
||||
* A globe engine standing in for the viewer double this test used to build:
|
||||
* the camera pose comes from `camera.positionCartographic`/heading/pitch/roll,
|
||||
* and `camera.flyTo`/`setView` and `scene.requestRender` replace the engine's.
|
||||
*/
|
||||
function engineViewer({ camera = {}, scene = {} } = {}) {
|
||||
const engine = createFakeEngine();
|
||||
const carto = camera.positionCartographic;
|
||||
if (carto)
|
||||
engine.fake.setPose({
|
||||
longitude: carto.longitude,
|
||||
latitude: carto.latitude,
|
||||
height: carto.height,
|
||||
heading: camera.heading ?? 0,
|
||||
pitch: camera.pitch ?? -Math.PI / 2,
|
||||
roll: camera.roll ?? 0,
|
||||
});
|
||||
if (camera.flyTo) engine.camera.flyTo = camera.flyTo;
|
||||
if (camera.setView) engine.camera.setView = camera.setView;
|
||||
if (scene.requestRender) engine.render.request = () => scene.requestRender();
|
||||
return engine;
|
||||
}
|
||||
|
||||
|
||||
const uiSource = readShellSource();
|
||||
|
||||
@@ -47,7 +71,7 @@ function makeManager(hash = '') {
|
||||
roll: 0,
|
||||
},
|
||||
};
|
||||
return new ShareLinkManager(viewer);
|
||||
return new ShareLinkManager(engineViewer(viewer));
|
||||
}
|
||||
|
||||
function installClipboard(writeText) {
|
||||
@@ -424,7 +448,7 @@ test('share-link restore forces a final stationary render for Google 3D Tiles',
|
||||
},
|
||||
scene: { requestRender() { calls.renders += 1; } },
|
||||
};
|
||||
const manager = new ShareLinkManager(viewer);
|
||||
const manager = new ShareLinkManager(engineViewer(viewer));
|
||||
manager.applyState({
|
||||
lat: 40.7669,
|
||||
lon: -73.9909,
|
||||
@@ -453,7 +477,7 @@ test('newer navigation suppresses delayed share camera while non-camera state st
|
||||
flyTo() { flights += 1; },
|
||||
},
|
||||
};
|
||||
const manager = new ShareLinkManager(viewer, {
|
||||
const manager = new ShareLinkManager(engineViewer(viewer), {
|
||||
onRestore: (state) => { restored = state; },
|
||||
isNavigationCurrent: () => false,
|
||||
});
|
||||
@@ -683,7 +707,7 @@ test('share apply completion waits for both callback work and camera settlement'
|
||||
},
|
||||
scene: { requestRender() {} },
|
||||
};
|
||||
const manager = new ShareLinkManager(viewer, { onRestore: () => restoreGate });
|
||||
const manager = new ShareLinkManager(engineViewer(viewer), { onRestore: () => restoreGate });
|
||||
let settled = false;
|
||||
const applying = manager.applyState({
|
||||
lat: 40, lon: -74, alt: 500, heading: 0, pitch: -30, roll: 0,
|
||||
@@ -712,7 +736,7 @@ test('a later navigation prevents share completion from resetting the final pose
|
||||
},
|
||||
scene: { requestRender() {} },
|
||||
};
|
||||
const manager = new ShareLinkManager(viewer, {
|
||||
const manager = new ShareLinkManager(engineViewer(viewer), {
|
||||
isNavigationCurrent: (token) => token === generation,
|
||||
});
|
||||
manager.applyState({
|
||||
@@ -736,7 +760,7 @@ test('destroy cancels only a still-owned share flight and ignores delayed comple
|
||||
},
|
||||
scene: { requestRender() {} },
|
||||
};
|
||||
const manager = new ShareLinkManager(viewer, {
|
||||
const manager = new ShareLinkManager(engineViewer(viewer), {
|
||||
isNavigationCurrent: (token) => token === generation,
|
||||
cancelOwnedNavigation: () => { cancellations += 1; flight?.cancel?.(); },
|
||||
});
|
||||
@@ -748,7 +772,7 @@ test('destroy cancels only a still-owned share flight and ignores delayed comple
|
||||
assert.equal(cancellations, 1);
|
||||
assert.equal(setViews, 0);
|
||||
|
||||
const newerManager = new ShareLinkManager(viewer, {
|
||||
const newerManager = new ShareLinkManager(engineViewer(viewer), {
|
||||
isNavigationCurrent: (token) => token === generation,
|
||||
cancelOwnedNavigation: () => { cancellations += 1; },
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user