Drive the camera verbs through the camera and frame ports and take them off the Cesium list

The verbs' motions run on the frame port's preUpdate, which Cesium raises
right after the clock tick they used to run on; a renderer bound after the
verbs started is picked up when the next motion starts. They read the camera
from its port's pose, wait for a flight through its `flying`, and frame an
orbit from the pose with the geo maths.

Globe rotation tests the keyhole fit from the pose and the port's projection
matrix (a centred perspective one) instead of Cesium's frustum, and checks
the Globe View preset by computing its pose rather than cloning a Cesium
camera. The contract's renderer is a 3D WGS84 globe, so the scene-mode and
non-WGS84 refusals go with their tests. At the start the captured pose is
written back through setView only when the camera handoff changed it (a
route's bank levelled), instead of copying the basis into Cesium's camera.

The verbs still read the viewer's canvas for its size and listen on it for
the user's input.
This commit is contained in:
Sameh Khamis committed 2026-11-07 14:37:58 -08:00
1 parent 2c7f882bd2
commit 491c58cdc6
6 files changed
+227 -264

No files matched your search

+30 -2
View File
@@ -103,10 +103,8 @@ function createTickableViewer({ heightM = 700 } = {}) {
};
const viewer = bindFakeCesiumCamera({
trackedEntity: undefined,
clock: { onTick: { addEventListener: (fn) => { listeners.push(fn); return () => {}; } } },
scene: {
canvas: { addEventListener() {}, removeEventListener() {} },
tweens: [],
requestRender() {},
},
camera,
@@ -114,6 +112,12 @@ function createTickableViewer({ heightM = 700 } = {}) {
// A live app has a rendered surface under the route; the mesh probe reads
// it, so these flights start immediately rather than arming.
query: { sampleHeightNow: () => 0 },
frame: {
on: (phase, fn) => {
if (phase === 'preUpdate') listeners.push(fn);
return () => {};
},
},
});
return {
viewer,
@@ -1103,3 +1107,27 @@ test('a route hidden from Draw is not flown; the newest visible one is', () => {
assert.match(JSON.stringify(started), /shown walk/, 'the visible route is flown');
interruptCameraMotion?.('test');
});
test('a frame port bound after the verbs started runs the next motion', () => {
// A viewer with no renderer yet, so no frame port to listen to.
const viewer = {
scene: { canvas: { addEventListener() {}, removeEventListener() {} } },
};
try {
initCameraVerbs(viewer);
const listeners = [];
bindRenderer(viewer, {
frame: {
on: (phase, fn) => {
if (phase === 'preUpdate') listeners.push(fn);
return () => listeners.splice(listeners.indexOf(fn), 1);
},
},
});
assert.equal(listeners.length, 0, 'nothing listens before a motion');
assert.equal(moveCamera({ motion: 'rotate', direction: 'left' }).ok, true);
assert.equal(listeners.length, 1, 'the motion runs on the bound port');
} finally {
interruptCameraMotion('test-cleanup');
}
});