mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
Give each scene its own render governor, owner holds and recent idle requests. Make the Cesium render backend own its request mode directly, so the governor drives engine.render on both engines without a dependency back from Cesium. Route layer requests through their attached engine and capture the attachment's governor for camera motions, orbit, annotations and shell controls. Release retained-layer holds before clearing the outgoing engine, and destroy the governor after scene consumers have detached. Preserve Cesium's owner-keyed holds, pre-install buffering, last-release settling frame and one-shot requests during continuous rendering. Navara keeps the same render policy. There is no intended visible change on either engine. Simultaneous scenes no longer share holds, and an old captured service cannot release a replacement attachment's hold. Cover both rules on fake and headless Cesium engines, including an old orbit ending after reattachment. Viewer-reference lines fall from 910 to 891, Navara-kind checks from 2 to 1, and engine-name lines from 33 to 32. All other coupling counts stay unchanged. Checked in the browser, keyless: qa-perf passes on both engines with the same idle, active and release counts as before (24 checks on Cesium, 22 on Navara).
37 lines
1.2 KiB
JavaScript
37 lines
1.2 KiB
JavaScript
import { createRenderGovernor } from '../renderGovernor.js';
|
|
import { createPickRegistry } from './pickRegistry.js';
|
|
import { createSelectionDispatcher } from './selectionDispatcher.js';
|
|
|
|
// Portable layers may attach directly to an engine, outside the application.
|
|
// Their lookup reaches the same services the app publishes on its scene.
|
|
const scenes = new WeakMap();
|
|
|
|
/** Create the services for one attachment, including reuse of a parked engine. */
|
|
export function createSceneServices(engine, options = {}) {
|
|
scenes.get(engine)?.destroy();
|
|
const render = createRenderGovernor(engine);
|
|
const picking = createPickRegistry();
|
|
const selection = createSelectionDispatcher(engine, { ...options, picking });
|
|
let destroyed = false;
|
|
const services = {
|
|
picking,
|
|
selection,
|
|
render,
|
|
destroy() {
|
|
if (destroyed) return;
|
|
destroyed = true;
|
|
selection.destroy();
|
|
picking.destroy();
|
|
render.destroy();
|
|
},
|
|
};
|
|
scenes.set(engine, services);
|
|
return services;
|
|
}
|
|
|
|
/** A detached scene stays inert until an explicit new attachment replaces it. */
|
|
export function sceneServicesFor(engine) {
|
|
if (!engine) return null;
|
|
return scenes.get(engine) ?? createSceneServices(engine);
|
|
}
|