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:
Sameh Khamis committed 2026-11-05 19:48:58 -08:00
1 parent 910185bfe0
commit b5900b4178
28 files changed
+688 -243

No files matched your search

+8 -7
View File
@@ -10,6 +10,7 @@ import { ShareLinkManager, decodeShareCreatedAtMs } from './sharelink.js';
import { createDefaultLayerState } from './data/layerState.js';
import { parseSharePath } from './share/shareLinkPath.js';
import { decodeShareView } from './share/viewCodec.js';
import { bindFakeCesiumCamera } from './testSupport/fakeCameraPort.mjs';
/** The decoded view of a copied `/share/<code>` link. */
const sharedState = (href) =>
@@ -51,7 +52,7 @@ function makeManager(hash = '') {
roll: 0,
},
};
return new ShareLinkManager(viewer);
return new ShareLinkManager(bindFakeCesiumCamera(viewer));
}
function installClipboard(writeText) {
@@ -443,7 +444,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(bindFakeCesiumCamera(viewer));
manager.applyState({
lat: 40.7669,
lon: -73.9909,
@@ -472,7 +473,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(bindFakeCesiumCamera(viewer), {
onRestore: (state) => { restored = state; },
isNavigationCurrent: () => false,
});
@@ -702,7 +703,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(bindFakeCesiumCamera(viewer), { onRestore: () => restoreGate });
let settled = false;
const applying = manager.applyState({
lat: 40, lon: -74, alt: 500, heading: 0, pitch: -30, roll: 0,
@@ -731,7 +732,7 @@ test('a later navigation prevents share completion from resetting the final pose
},
scene: { requestRender() {} },
};
const manager = new ShareLinkManager(viewer, {
const manager = new ShareLinkManager(bindFakeCesiumCamera(viewer), {
isNavigationCurrent: (token) => token === generation,
});
manager.applyState({
@@ -755,7 +756,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(bindFakeCesiumCamera(viewer), {
isNavigationCurrent: (token) => token === generation,
cancelOwnedNavigation: () => { cancellations += 1; flight?.cancel?.(); },
});
@@ -767,7 +768,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(bindFakeCesiumCamera(viewer), {
isNavigationCurrent: (token) => token === generation,
cancelOwnedNavigation: () => { cancellations += 1; },
});