mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Fly the camera through the renderer's camera port
The Cesium camera port moves into render/cesium/camera.js, with the listener list and position conversion shared from common.js. It now covers flights (flyTo, flyToBounds, cancelFlight, flying), lookAt and release, command hooks, and a flightEnd event for the flights it starts. A flight's end that Cesium raises inside one of the port's own calls is delivered once Cesium's call returns, so its callback sees the flight let go of. A flight Cesium declines to start, mid scene-mode morph, ends as cancelled instead of never settling. Flight traces run in Node on the recorder's headless camera with a virtual clock; the browser harness keeps the instant traces. The startup fly-in, landmark and viewport flights, share-link restore and the shell's camera state now go through the port. camera.js and sharelink.js leave the Cesium allow-list.
This commit is contained in:
1 parent
b5900b4178
commit
46a53bb49c
20 files changed
+846
-305
No files matched your search
@@ -1,25 +1,68 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { flyToAustin } from '../camera.js';
|
||||
import { bindFakeCesiumCamera } from '../testSupport/fakeCameraPort.mjs';
|
||||
|
||||
test('teardown before the initial camera delay prevents a late flight', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
let flights = 0;
|
||||
let cancelled = 0;
|
||||
const stop = flyToAustin({
|
||||
isDestroyed: () => false,
|
||||
camera: {
|
||||
setView() {},
|
||||
flyTo() {
|
||||
flights++;
|
||||
const stop = flyToAustin(
|
||||
bindFakeCesiumCamera({
|
||||
isDestroyed: () => false,
|
||||
camera: {
|
||||
setView() {},
|
||||
flyTo() {
|
||||
flights++;
|
||||
},
|
||||
cancelFlight() {
|
||||
cancelled++;
|
||||
},
|
||||
},
|
||||
cancelFlight() {
|
||||
cancelled++;
|
||||
},
|
||||
},
|
||||
});
|
||||
}),
|
||||
);
|
||||
stop();
|
||||
t.mock.timers.tick(1000);
|
||||
assert.equal(flights, 0);
|
||||
assert.equal(cancelled, 1);
|
||||
assert.equal(cancelled, 0, 'no fly-in started, so none to cancel');
|
||||
});
|
||||
|
||||
test('teardown cancels the fly-in, not a flight the user started since', (t) => {
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
const cancelled = [];
|
||||
let current = null;
|
||||
const viewer = bindFakeCesiumCamera({
|
||||
isDestroyed: () => false,
|
||||
camera: {
|
||||
get _currentFlight() {
|
||||
return current;
|
||||
},
|
||||
setView() {},
|
||||
flyTo(options) {
|
||||
current?.cancel();
|
||||
current = {
|
||||
name: options.duration === 4 ? 'fly-in' : 'user',
|
||||
...options,
|
||||
};
|
||||
},
|
||||
cancelFlight() {
|
||||
cancelled.push(current?.name);
|
||||
const flight = current;
|
||||
current = null;
|
||||
flight?.cancel();
|
||||
},
|
||||
},
|
||||
});
|
||||
const stop = flyToAustin(viewer);
|
||||
t.mock.timers.tick(500);
|
||||
stop();
|
||||
assert.deepEqual(cancelled, ['fly-in']);
|
||||
|
||||
// A user flight replaces the fly-in; teardown leaves it alone.
|
||||
const second = flyToAustin(viewer);
|
||||
t.mock.timers.tick(500);
|
||||
viewer.camera.flyTo({ duration: 2 });
|
||||
second();
|
||||
assert.deepEqual(cancelled, ['fly-in']);
|
||||
assert.equal(current.name, 'user');
|
||||
});
|
||||
Reference in new issue
Block a user