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
+26
-24
@@ -21,10 +21,11 @@ import {
|
||||
GLOBE_VIEW,
|
||||
searchAndFlyTo,
|
||||
} from './locations.js';
|
||||
import { bindFakeCesiumCamera } from './testSupport/fakeCameraPort.mjs';
|
||||
|
||||
function stubViewer() {
|
||||
const flights = [];
|
||||
return {
|
||||
return bindFakeCesiumCamera({
|
||||
flights,
|
||||
scene: { globe: null, canvas: { clientWidth: 0, clientHeight: 0 } },
|
||||
camera: {
|
||||
@@ -39,7 +40,7 @@ function stubViewer() {
|
||||
lookAt() {},
|
||||
lookAtTransform() {},
|
||||
},
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
const AUSTIN_RESULT = {
|
||||
@@ -604,29 +605,22 @@ test('GLOBE_VIEW preset height sits in the global view band', () => {
|
||||
assert.equal(GLOBE_VIEW.pitchDeg, -90);
|
||||
});
|
||||
|
||||
// The globe flight's callbacks are what resolves Reset Globe / zoom_to_globe.
|
||||
// They were published under this module's OWN option names (`onComplete` /
|
||||
// `onCancel`), which Cesium's Camera.flyTo ignores — so neither ever fired and
|
||||
// every caller resolved off its ~4.2 s watchdog timeout instead of the flight.
|
||||
test('the globe flight publishes its callbacks under Cesium\'s own option names', () => {
|
||||
// The globe flight's callbacks are what resolves Reset Globe / zoom_to_globe:
|
||||
// each must reach the caller when the flight ends that way.
|
||||
test('the globe flight ends through its own callbacks', () => {
|
||||
const viewer = stubViewer();
|
||||
const fired = [];
|
||||
flyToGlobeView(viewer, {
|
||||
const hooks = {
|
||||
onComplete: () => fired.push('complete'),
|
||||
onCancel: () => fired.push('cancel'),
|
||||
});
|
||||
|
||||
const flight = viewer.flights[0];
|
||||
assert.equal(typeof flight.complete, 'function', 'Cesium resolves arrival through `complete`');
|
||||
assert.equal(typeof flight.cancel, 'function', 'Cesium reports supersession through `cancel`');
|
||||
// Not merely present under both spellings: the ignored names must be gone,
|
||||
// or a later reader can "fix" the wrong one back.
|
||||
assert.equal('onComplete' in flight, false, 'Cesium ignores onComplete — do not publish it');
|
||||
assert.equal('onCancel' in flight, false, 'Cesium ignores onCancel — do not publish it');
|
||||
|
||||
flight.complete();
|
||||
flight.cancel();
|
||||
};
|
||||
flyToGlobeView(viewer, hooks);
|
||||
flyToGlobeView(viewer, hooks);
|
||||
viewer.flights[0].complete();
|
||||
viewer.flights[1].cancel();
|
||||
assert.deepEqual(fired, ['complete', 'cancel'], 'each hook reaches the caller it belongs to');
|
||||
viewer.flights[0].cancel();
|
||||
assert.deepEqual(fired, ['complete', 'cancel'], 'a flight ends once');
|
||||
});
|
||||
|
||||
test('a globe flight without callbacks still flies (both hooks are optional)', () => {
|
||||
@@ -634,8 +628,7 @@ test('a globe flight without callbacks still flies (both hooks are optional)', (
|
||||
const target = flyToGlobeView(viewer);
|
||||
assert.equal(viewer.flights.length, 1);
|
||||
assert.equal(target.heightM, GLOBE_VIEW.heightM);
|
||||
assert.equal(viewer.flights[0].complete, undefined);
|
||||
assert.equal(viewer.flights[0].cancel, undefined);
|
||||
viewer.flights[0].complete();
|
||||
});
|
||||
|
||||
test('geocoded Location branches forward the resolved-navigation ownership hook', () => {
|
||||
@@ -674,8 +667,13 @@ test('city and landmark flights expose completion and cancellation hooks', () =>
|
||||
onComplete: () => overviewEvents.push('complete'),
|
||||
onCancel: () => overviewEvents.push('cancel'),
|
||||
});
|
||||
flyToPresetLocation(overviewViewer, 'austin', {
|
||||
viewMode: 'overview',
|
||||
onComplete: () => overviewEvents.push('complete'),
|
||||
onCancel: () => overviewEvents.push('cancel'),
|
||||
});
|
||||
overviewViewer.flights[0].complete();
|
||||
overviewViewer.flights[0].cancel();
|
||||
overviewViewer.flights[1].cancel();
|
||||
assert.deepEqual(overviewEvents, ['complete', 'cancel']);
|
||||
|
||||
const landmarkViewer = stubViewer();
|
||||
@@ -684,8 +682,12 @@ test('city and landmark flights expose completion and cancellation hooks', () =>
|
||||
onComplete: () => landmarkEvents.push('complete'),
|
||||
onCancel: () => landmarkEvents.push('cancel'),
|
||||
});
|
||||
flyToPresetLocation(landmarkViewer, 'austin', {
|
||||
onComplete: () => landmarkEvents.push('complete'),
|
||||
onCancel: () => landmarkEvents.push('cancel'),
|
||||
});
|
||||
landmarkViewer.flights[0].complete();
|
||||
landmarkViewer.flights[0].cancel();
|
||||
landmarkViewer.flights[1].cancel();
|
||||
assert.deepEqual(landmarkEvents, ['complete', 'cancel']);
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user