mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
The embed views fly through rendererOf's camera port with geo maths, and the panel render loop that keeps an inline panel drawing moves into the Cesium adapter (src/render/cesium/panelRendering.js); the application scene hands it to the embed views as `keepRendering`. The shell reaches the camera, effects and globe through rendererOf and loads no Cesium factories; whether Cockpit's aircraft is an entity of the viewer's own comes from the scene's `viewerDrawsEntity`, wired in through the controls. Callers handing the shell or the application tools a viewer of their own load ./render/cesium/unbound once, as the ports' unbound check now records.
68 lines
2.7 KiB
JavaScript
68 lines
2.7 KiB
JavaScript
import { LayerLifecycle } from '../data/lifecycle.js';
|
|
import { LayerPresentation } from './layerPresentation.js';
|
|
import { createCyberSonarScene } from '../cyberSonarScene.js';
|
|
import { panelAwareVisibility } from './embed.js';
|
|
/** Register the application layer catalog before allowing state restoration. */
|
|
export function createApplicationData({
|
|
scene: { viewer, mapStackController },
|
|
controls: { styleManager },
|
|
catalog,
|
|
allowQaRegistration,
|
|
onData,
|
|
defer,
|
|
}) {
|
|
// Initialize data layer manager
|
|
const dataManager = new LayerLifecycle(viewer, {
|
|
allowQaRegistration,
|
|
// A panel's host may report it hidden while it is on screen; its layers
|
|
// keep polling (see keepPanelRendering in render/cesium/panelRendering.js).
|
|
visibilityTarget: panelAwareVisibility(document),
|
|
getSourceAvailability: catalog?.getSourceAvailability,
|
|
});
|
|
defer(async () => {
|
|
await dataManager.destroyAll();
|
|
if (dataManager.layers.size)
|
|
throw new Error(
|
|
`Data layers could not be destroyed: ${[...dataManager.layers.keys()].join(', ')}`,
|
|
);
|
|
});
|
|
const presentation = new LayerPresentation(dataManager, {
|
|
weatherClock: catalog?.weatherClock,
|
|
});
|
|
defer(() => presentation.destroy());
|
|
onData?.(dataManager);
|
|
if (!catalog?.layers || !catalog?.metadata)
|
|
throw new TypeError('An application layer catalog is required');
|
|
for (const layer of catalog.layers) dataManager.register(layer);
|
|
for (const layer of catalog.layers) layer.attachDataManager?.(dataManager);
|
|
for (const layer of catalog.layers)
|
|
layer.attachMapStackController?.(mapStackController);
|
|
// Restoration starts only after the caller's complete registry is sealed.
|
|
dataManager.finalizeRegistrations(catalog.metadata);
|
|
if (allowQaRegistration) {
|
|
window.__gevQaRegisterLayer = (targetManager, layerModule) => {
|
|
if (targetManager !== dataManager)
|
|
throw new Error('QA layer manager mismatch');
|
|
return dataManager.registerForQa(layerModule);
|
|
};
|
|
window.__gevQaUnregisterLayer = (targetManager, layerId) => {
|
|
if (targetManager !== dataManager)
|
|
throw new Error('QA layer manager mismatch');
|
|
return dataManager.unregisterForQa(layerId);
|
|
};
|
|
const register = window.__gevQaRegisterLayer;
|
|
const unregister = window.__gevQaUnregisterLayer;
|
|
defer(() => {
|
|
if (window.__gevQaRegisterLayer === register)
|
|
delete window.__gevQaRegisterLayer;
|
|
if (window.__gevQaUnregisterLayer === unregister)
|
|
delete window.__gevQaUnregisterLayer;
|
|
});
|
|
}
|
|
presentation.mount(document.getElementById('data-toggles'));
|
|
styleManager.attachDataManager(dataManager);
|
|
defer(createCyberSonarScene(viewer, dataManager));
|
|
|
|
return { dataManager, catalog, presentation };
|
|
}
|