mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(globe): engine members and the viewer bridge for the shell
Contract: camera.position(result?) and camera.height() for per-frame readers, render.request(reason?), maps.releasePhotorealTiles, sources with a caller-owned ready provider, isGlobeEngine. engine.maps now hides every tileset it has shown, lets the last imagery/photoreal call win, and setPhotorealTiles(null) restores the last base imagery and its credit instead of leaving the photoreal credit on a bare globe. Cesium engine: reads the Viewer camera/canvas aliases, detaches bridged events through the remover Cesium returns, raises frame timestamps without allocating, re-aims the horizon occluder only when the camera moved, and renders the scene directly when the governor governs another viewer (or none yet). engineFromViewer returns the registered scene engine of a viewer, else builds and caches one. The render governor stays the Cesium render backend under engine.render and gains isRenderGovernorInstalled.
This commit is contained in:
1 parent
a5c98c6b07
commit
58a196374f
26 files changed
+657
-45
No files matched your search
@@ -0,0 +1,40 @@
|
||||
// The bridge for shell callers that still hold only a Cesium viewer (layers
|
||||
// until phase 1c, standalone entries, tests): the engine of that viewer. The
|
||||
// app registers its scene engine (src/app/globeEngine.js); any other viewer
|
||||
// gets one built on first use and cached. Building one changes nothing in
|
||||
// the viewer, and it is never destroyed here: its subscriptions live only as
|
||||
// long as their callers keep them.
|
||||
|
||||
import { isGlobeEngine } from '../contract.js';
|
||||
import { createCesiumEngine } from './createCesiumEngine.js';
|
||||
|
||||
const engines = new WeakMap();
|
||||
|
||||
/**
|
||||
* Make `engine` the one returned for `viewer`.
|
||||
* @returns {() => void} Unregister (only while it is still the registered one).
|
||||
*/
|
||||
export function registerViewerEngine(viewer, engine) {
|
||||
engines.set(viewer, engine);
|
||||
return () => {
|
||||
if (engines.get(viewer) === engine) engines.delete(viewer);
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* @param {object | null | undefined} viewer A Cesium viewer, or an engine
|
||||
* (returned as is).
|
||||
* @param {Parameters<typeof createCesiumEngine>[1]} [options] Used only when
|
||||
* an engine has to be built.
|
||||
* @returns {import('../contract.js').GlobeEngine | null}
|
||||
*/
|
||||
export function engineFromViewer(viewer, options) {
|
||||
if (viewer == null) return null;
|
||||
if (isGlobeEngine(viewer)) return viewer;
|
||||
let engine = engines.get(viewer);
|
||||
if (!engine) {
|
||||
engine = createCesiumEngine(viewer, options);
|
||||
engines.set(viewer, engine);
|
||||
}
|
||||
return engine;
|
||||
}
|
||||
Reference in new issue
Block a user