mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Main's new layers (drone airspace, OSM places, sea marks, ski pistes) are Cesium-only for now: they join the layer directory and the Cesium catalog, are built afresh for each Cesium catalog, and show as unavailable on Navara. The zoom-out guard is a scene part that attaches to Cesium globes only. The awareness range pulses and their echoes draw on Cesium through the awareness display's viewer; Navara keeps the plain range ring. Camera-input wakes go through the display, and the analyst keeps the session-owned memory with main's area presentation. A disposed voice runner aborts work in flight, and an engine switch still keeps the last answer. Modules main added that read Cesium while they load (zoomOutGuard, awarenessEcho, the ground-sampling scratch in localGeojsonCore) now build those values on first use or use src/geo, so a Navara page still starts without the SDK. The OSM view box reads the engine's view rectangle. Main grew its own main chunk by 93,873 bytes gzip-9 since the merge base, so the baseline is raised to the merged size.
102 lines
3.4 KiB
JavaScript
102 lines
3.4 KiB
JavaScript
import test, { after, before } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
import * as Cesium from 'cesium';
|
|
import '../testSupport/stubMgrs.mjs';
|
|
import { installVueDom } from '../testSupport/vueDom.mjs';
|
|
import { MAXIMUM_ZOOM_DISTANCE_M } from './zoomOutGuard.js';
|
|
|
|
const { createApplicationControls } = await import('./controls.js');
|
|
|
|
// controls.js and the shell import browser-only UI modules, so these read the
|
|
// source: the scene engine is threaded to the shell, which hands it (not the
|
|
// viewer) to the world overlay. initWorldOverlay itself is tested on the fake
|
|
// engine without a viewer (src/overlays/worldOverlay.test.mjs).
|
|
const read = (relative) =>
|
|
readFileSync(new URL(relative, import.meta.url), 'utf8');
|
|
|
|
test('the controls pass the scene engine to the shell', () => {
|
|
const controls = read('./controls.js');
|
|
assert.match(
|
|
controls,
|
|
/const \{ viewer, engine, mapStackController, operations \} = scene;/,
|
|
);
|
|
assert.match(controls, /new Controls\(viewer, \{[\s\S]*?\n\s+engine,\n/);
|
|
// A later globe reaches the shell with its own engine.
|
|
assert.match(
|
|
read('./shellPart.js'),
|
|
/styleManager\.attachScene\(\{\s+viewer: next\.viewer,\s+engine: next\.engine,/,
|
|
);
|
|
});
|
|
|
|
test('the shell initializes the world overlay on its engine', () => {
|
|
const shell = read('../ui/applicationShell.js');
|
|
assert.match(
|
|
shell,
|
|
/\{\n\s+engine = engineFromViewer\(viewer\),\n\s+mapStackController = null,/,
|
|
);
|
|
assert.match(shell, /initWorldOverlay\(engine\);/);
|
|
assert.doesNotMatch(shell, /initWorldOverlay\(viewer\)/);
|
|
});
|
|
|
|
let uninstallDom;
|
|
before(() => {
|
|
uninstallDom = installVueDom();
|
|
});
|
|
after(() => uninstallDom());
|
|
|
|
test('application controls install the zoom-out guard and remove it on teardown', async () => {
|
|
const canvas = document.createElement('canvas');
|
|
const controller = { maximumZoomDistance: Infinity };
|
|
const scene = {
|
|
mode: Cesium.SceneMode.SCENE3D,
|
|
screenSpaceCameraController: controller,
|
|
preRender: new Cesium.Event(),
|
|
postUpdate: new Cesium.Event(),
|
|
};
|
|
const camera = {
|
|
position: Cesium.Cartesian3.fromDegrees(0, 0, 1_000_000),
|
|
positionCartographic: { height: 1_000_000 },
|
|
};
|
|
const viewer = { scene, camera, canvas };
|
|
const handoffs = new Set();
|
|
class Controls {
|
|
hasShareState = true;
|
|
orbitController = { stop() {} };
|
|
hud = { destroy() {} };
|
|
dispose() {}
|
|
detachScene() {}
|
|
subscribeCameraHandoff(listener) {
|
|
handoffs.add(listener);
|
|
return () => handoffs.delete(listener);
|
|
}
|
|
}
|
|
const cleanups = [];
|
|
await createApplicationControls({
|
|
scene: {
|
|
viewer,
|
|
mapStackController: {},
|
|
operations: {
|
|
surface: { controlServices: {} },
|
|
searchAndFlyTo() {},
|
|
requests: { regional: {}, weather: {} },
|
|
},
|
|
},
|
|
loaderStatus: {},
|
|
Controls,
|
|
catalog: { get: (id) => ({ id }) },
|
|
defer: (cleanup) => cleanups.push(cleanup),
|
|
});
|
|
|
|
assert.equal(controller.maximumZoomDistance, MAXIMUM_ZOOM_DISTANCE_M);
|
|
assert.equal(scene.preRender.numberOfListeners, 1);
|
|
assert.equal(scene.postUpdate.numberOfListeners, 1);
|
|
assert.equal(handoffs.size, 1);
|
|
|
|
for (const cleanup of cleanups.reverse()) await cleanup();
|
|
assert.equal(controller.maximumZoomDistance, Infinity);
|
|
assert.equal(scene.preRender.numberOfListeners, 0);
|
|
assert.equal(scene.postUpdate.numberOfListeners, 0);
|
|
assert.equal(handoffs.size, 0);
|
|
});
|