mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
A renderer plugin may supply applicationHooks(renderer) for what only its renderer has (map engine, own credits, stale commands, QA handles). What every renderer should do moves onto the contract: controls.keepEarthFramed (behind the keepEarthFramed capability), query.occlusionTest (behind occlusionTest), and panel drawing, which keepPanelRendering now does through resize and frame.renderNow through the contract. renderNow throws when the frame fails to draw. The Cesium port installs its zoom-out guard through keepEarthFramed (a setView no longer cancels its turn) and answers occlusionTest with the scene's probe; the stub answers it with a horizon test.
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 app/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 };
|
|
}
|