mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Read the HUD and share-link camera through the renderer's camera port
The first camera-family slice. The camera port's events move into a shared module (render/camera/events.js) that the stub and the Cesium port both use: listener lists, delivery with errors reported, and the contract's per-listener `changed` measure. The Cesium port gains: - camera.on: `changed` measured per listener on every tick, where Cesium measures its single threshold (the counts match Cesium's own at each threshold); moveStart and moveEnd relayed from Cesium's camera; - camera.viewRectangle, in degrees (now in CESIUM_CHECKS); - lon and lat in pose, and NaN where Cesium has no cartographic position. Code that still holds the viewer reaches the renderer through rendererOf(viewer); the application renderer binds it on create and unbinds on destroy. The HUD reads its telemetry from the camera port and no longer imports Cesium (off the allow-list). The share link writes the hash from the pose. Its restore path stays on the viewer's camera for a later slice. Behaviour changes: - The share link listens to `changed` at its own 0.5 threshold, not at whatever global threshold layers had set, and also to moveEnd, so the hash always catches up with where the camera comes to rest. - The HUD's and share link's camera callbacks run from the port's single relay, ahead of other moveStart/moveEnd listeners, and a throw in one is reported to the renderer's error listeners instead of escaping from Cesium's render.
This commit is contained in:
1 parent
910185bfe0
commit
b5900b4178
28 files changed
+688
-243
No files matched your search
@@ -10,6 +10,7 @@ import {
|
||||
decodeLayerStateParams,
|
||||
} from './data/layerState.js';
|
||||
import { LayerStateCoordinator } from './data/layerStateCoordinator.js';
|
||||
import { bindFakeCesiumCamera } from './testSupport/fakeCameraPort.mjs';
|
||||
|
||||
const SHARE_A = 'v=2&lat=10.0000&lon=20.0000&alt=800&style=nvg&l=e';
|
||||
const SHARE_B = 'v=2&lat=48.8584&lon=2.2945&alt=500&style=normal&l=f';
|
||||
@@ -102,7 +103,7 @@ function fakeViewer() {
|
||||
|
||||
test('a hash navigation to a different share restores it and holds URL writes', (t) => {
|
||||
const tab = installTab(t, SHARE_A);
|
||||
const manager = new ShareLinkManager(fakeViewer());
|
||||
const manager = new ShareLinkManager(bindFakeCesiumCamera(fakeViewer()));
|
||||
const initial = manager.parseInitialHash();
|
||||
manager.completeInitialRestore(initial.restoreToken);
|
||||
const navigated = [];
|
||||
@@ -124,7 +125,7 @@ test('a hash navigation to a different share restores it and holds URL writes',
|
||||
|
||||
test("the app's own hash writes never trigger a restore", (t) => {
|
||||
installTab(t, SHARE_A);
|
||||
const manager = new ShareLinkManager(fakeViewer());
|
||||
const manager = new ShareLinkManager(bindFakeCesiumCamera(fakeViewer()));
|
||||
manager.completeInitialRestore(manager.parseInitialHash().restoreToken);
|
||||
let restores = 0;
|
||||
manager.watchNavigation(() => {
|
||||
@@ -142,7 +143,7 @@ test("the app's own hash writes never trigger a restore", (t) => {
|
||||
|
||||
test('a non-share hash is ignored and Back/Forward restores each entry once', (t) => {
|
||||
const tab = installTab(t, SHARE_A);
|
||||
const manager = new ShareLinkManager(fakeViewer());
|
||||
const manager = new ShareLinkManager(bindFakeCesiumCamera(fakeViewer()));
|
||||
manager.completeInitialRestore(manager.parseInitialHash().restoreToken);
|
||||
// The app rewrites entry 0 with its own state; Back must return to that.
|
||||
manager._updateHash();
|
||||
@@ -176,7 +177,7 @@ test('a newer navigation supersedes an older restore and its pending write', (t)
|
||||
const tab = installTab(t, SHARE_A);
|
||||
const timers = installManualTimers(t);
|
||||
|
||||
const manager = new ShareLinkManager(fakeViewer());
|
||||
const manager = new ShareLinkManager(bindFakeCesiumCamera(fakeViewer()));
|
||||
manager.completeInitialRestore(manager.parseInitialHash().restoreToken);
|
||||
assert.equal(timers.size, 1, 'releasing suppression schedules a write');
|
||||
const navigated = [];
|
||||
@@ -204,7 +205,7 @@ test('a newer navigation supersedes an older restore and its pending write', (t)
|
||||
|
||||
test('destroy removes the navigation listeners', (t) => {
|
||||
const tab = installTab(t, SHARE_A);
|
||||
const manager = new ShareLinkManager(fakeViewer());
|
||||
const manager = new ShareLinkManager(bindFakeCesiumCamera(fakeViewer()));
|
||||
manager.parseInitialHash();
|
||||
let restores = 0;
|
||||
manager.watchNavigation(() => {
|
||||
@@ -240,7 +241,7 @@ function restorationHarness(t, initialHash, navigationOverrides = {}) {
|
||||
|
||||
const restores = [];
|
||||
let navigationGeneration = 0;
|
||||
const manager = new ShareLinkManager(fakeViewer(), {
|
||||
const manager = new ShareLinkManager(bindFakeCesiumCamera(fakeViewer()), {
|
||||
onRestore: (state) => {
|
||||
const gate = deferred();
|
||||
restores.push({ state, gate });
|
||||
|
||||
Reference in new issue
Block a user