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
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* @module render/cesium/common
|
||||
* @description What the Cesium ports share: the contract's listener rules
|
||||
* and its positions as Cesium's.
|
||||
*/
|
||||
import * as Cesium from 'cesium';
|
||||
|
||||
/**
|
||||
* One subscription list under the contract's listener rules: subscription
|
||||
* order, one removed during delivery does not run, one added during
|
||||
* delivery waits for the next event, and a throw goes to `onThrow` while
|
||||
* the rest still run. Each subscription is its own entry, so a callback
|
||||
* subscribed twice runs twice.
|
||||
* @param {(error: unknown) => void} onThrow
|
||||
*/
|
||||
export function listenerList(onThrow) {
|
||||
const entries = [];
|
||||
return {
|
||||
get size() {
|
||||
return entries.length;
|
||||
},
|
||||
on(cb) {
|
||||
const entry = { cb, live: true };
|
||||
entries.push(entry);
|
||||
return () => {
|
||||
entry.live = false;
|
||||
const i = entries.indexOf(entry);
|
||||
if (i >= 0) entries.splice(i, 1);
|
||||
};
|
||||
},
|
||||
fire(...args) {
|
||||
for (const entry of entries.slice()) {
|
||||
if (!entry.live) continue;
|
||||
try {
|
||||
entry.cb(...args);
|
||||
} catch (error) {
|
||||
onThrow(error);
|
||||
}
|
||||
}
|
||||
},
|
||||
clear() {
|
||||
for (const entry of entries) entry.live = false;
|
||||
entries.length = 0;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
/** A contract position as ECEF. */
|
||||
export function toCartesian(pos) {
|
||||
if ('x' in pos) return new Cesium.Cartesian3(pos.x, pos.y, pos.z);
|
||||
return Cesium.Cartesian3.fromDegrees(pos.lon, pos.lat, pos.height ?? 0);
|
||||
}
|
||||
Reference in new issue
Block a user