mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 18:52:18 +00:00
refactor(camera): use the globe engine
The startup fly-in, orbit, world-target focus, the arrival ground guard, arrival ownership, camera sensitivity claims, landmark/viewport/globe flights and place search (with its view bias and near-view recovery) take the globe engine. Callers that still hold a viewer (voice, layers until phase 1c) reach the same engine through engineFromViewer, and arrival ownership is keyed by the engine whichever one a caller names. The ground guard yields on camera.commanded instead of patching the viewer camera itself; on Cesium that event hooks the same command methods and tracking changes, so direct Cesium callers still end it. Landmark framing reads the frustum fov from the pose's fovy and aspectRatio. Tests that built viewer doubles now run on the fake engine (or on the Cesium engine over the same double), with the same expectations.
This commit is contained in:
1 parent
a3e929870d
commit
16e63f4c50
19 files changed
+601
-215
No files matched your search
@@ -1,16 +1,26 @@
|
||||
/** Arrival corrections belong to one viewer and yield to its next camera owner. */
|
||||
import { engineFromViewer } from '../globe/cesium/engineFromViewer.js';
|
||||
|
||||
/**
|
||||
* Arrival corrections belong to one globe engine and yield to its next camera
|
||||
* owner. Callers may name the engine or (layers until phase 1c) the viewer it
|
||||
* is registered for; both reach the same correction.
|
||||
*/
|
||||
const arrivals = new WeakMap();
|
||||
|
||||
const ownerOf = (engineOrViewer) =>
|
||||
engineFromViewer(engineOrViewer) ?? engineOrViewer;
|
||||
|
||||
/** Cancel an outstanding arrival correction before navigation or teardown. */
|
||||
export function cancelCameraArrival(viewer) {
|
||||
if (viewer) arrivals.get(viewer)?.();
|
||||
export function cancelCameraArrival(engineOrViewer) {
|
||||
if (engineOrViewer) arrivals.get(ownerOf(engineOrViewer))?.();
|
||||
}
|
||||
|
||||
/** Register a correction and return an idempotent ownership release. */
|
||||
export function ownCameraArrival(viewer, cancel) {
|
||||
cancelCameraArrival(viewer);
|
||||
arrivals.set(viewer, cancel);
|
||||
export function ownCameraArrival(engineOrViewer, cancel) {
|
||||
const owner = ownerOf(engineOrViewer);
|
||||
cancelCameraArrival(owner);
|
||||
arrivals.set(owner, cancel);
|
||||
return () => {
|
||||
if (arrivals.get(viewer) === cancel) arrivals.delete(viewer);
|
||||
if (arrivals.get(owner) === cancel) arrivals.delete(owner);
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user