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

+2 -1
View File
@@ -8,6 +8,7 @@ import { parseSharePath } from '../share/shareLinkPath.js';
import { decodeShareView } from '../share/viewCodec.js';
import { applicationPinia } from './vueRuntime.js';
import { useGlobeActionsStore } from './stores/globeActions.js';
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
/** The decoded view of a `/share/<code>` link. */
const sharedState = (href) =>
@@ -28,7 +29,7 @@ function makeManager(href, { positioned = true } = {}) {
roll: 0,
},
};
return new ShareLinkManager(viewer);
return new ShareLinkManager(bindFakeCesiumCamera(viewer));
}
function installClipboard(writeText) {
+3 -2
View File
@@ -19,6 +19,7 @@ import {
followOffsetToEnu,
} from '../share/viewCodec.js';
import { entityRecord, withEntityRecord } from '../data/entityRecords.js';
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
const NOW_MS = Date.now();
const FIX = { lat: 37.6213, lon: -122.379, alt: 3200 };
@@ -127,7 +128,7 @@ function openPage(t, href, { managerOptions = {}, tracking = null } = {}) {
const clock = installManualTimers(t);
const viewer = fakeViewer();
const restores = [];
const manager = new ShareLinkManager(viewer, {
const manager = new ShareLinkManager(bindFakeCesiumCamera(viewer), {
onRestore: async (state) => restores.push(state),
isNavigationCurrent: () => true,
...managerOptions,
@@ -401,7 +402,7 @@ test('a shared vessel is selected once the vessel feed has it', async (t) => {
test('the share button links to /share/<code>, following the followed entity', (t) => {
installPage(t, 'https://gev.example/?lang=ru#v=2&lat=1&lon=2');
const manager = new ShareLinkManager(fakeViewer());
const manager = new ShareLinkManager(bindFakeCesiumCamera(fakeViewer()));
// A fresh session's look, as the app reports it at start-up.
manager.onToggleChange(false, true, {
hudVisible: true,
+4 -10
View File
@@ -13,6 +13,8 @@ import { registerHooks } from 'node:module';
import { presentSelectedVessel } from '../../hudReadouts.js';
import { useHudStore } from '../stores/hud.js';
import IntelHudView from './IntelHudView.vue';
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
import { toDegrees as deg } from '../../geo/index.js';
const MGRS_STUB_URL = 'gev-test-stub:mgrs';
registerHooks({
@@ -35,7 +37,6 @@ registerHooks({
const { IntelHUD } = await import('../../hud.js');
const listeners = () => ({ addEventListener() {}, removeEventListener() {} });
function mount(t) {
document.body.replaceChildren();
@@ -44,16 +45,9 @@ function mount(t) {
const app = createApp(IntelHudView).use(pinia);
app.mount(document.body.appendChild(document.createElement('div')));
const hud = new IntelHUD(
{},
{
camera: {
pitch: -Math.PI / 2,
positionCartographic: { latitude: 0.7, longitude: -1.2, height: 500 },
computeViewRectangle: () => undefined,
moveStart: listeners(),
moveEnd: listeners(),
},
},
{
camera: fakeCameraPort({ pose: { lat: deg(0.7), lon: deg(-1.2), height: 500 } }).port,
// No AI summary: the readouts are what this test renders.
summaryService: { configured: async () => false },
publish: (view) => store.publish(view),