Cut duplicated and dead code across the engines, the layers and the QA scripts

- src/geo drops the ported debug argument checks and the tests that
  bitExact already covers; package boundaries accept a directory entry,
  so src/geo/ is listed once per group.
- Cesium no longer carries movers and lines nobody draws with: they are
  optional engine capabilities. The fake engine and the Cesium camera use
  the shared cameraMath; unused contract tables, clock.ticked, the
  'finest' surface detail and Navara click statistics are gone.
- ALPR keeps one overlay core and one presentation model for both
  engines, bikeshare one station bookkeeping, the Navara ground effects
  one definition helper; image atlases, view centres, mover banks and
  colours are shared.
- The legacy switch route, the clock offset and rate controls and other
  unused exports are removed.
- The acceptance runs the Navara draw, geo import and scope checks;
  scenarios use the harness switch and page helpers; the main chunk
  check keeps the size budget only and runs once in CI.
This commit is contained in:
German Khokhlov committed 2026-11-05 13:32:39 +04:00
1 parent c502404e1d
commit 7abf74518f
272 files changed
+4828 -10213

No files matched your search

+2
View File
@@ -78,6 +78,8 @@ function fixture({ holdFirst = false } = {}) {
},
},
};
// A Viewer's canvas is its scene's.
viewer.canvas = viewer.scene.canvas;
const runner = createGevActionRunner({
engine: createCesiumEngine(viewer),
viewer,
+1 -1
View File
@@ -258,7 +258,7 @@ export const UNAVAILABLE_FEATURES = Object.freeze({
});
/** The engine to switch to for a refused feature. */
export const SWITCH_ENGINE_HINT = '?engine=cesium';
const SWITCH_ENGINE_HINT = '?engine=cesium';
const engineName = (engine) =>
engine?.kind === 'navara' ? 'the Navara engine' : 'this engine';
+4
View File
@@ -184,6 +184,8 @@ function createVoiceNavigationHarness({ cockpitActive = false } = {}) {
lookAtTransform() {},
},
};
// A Viewer's canvas is its scene's.
viewer.canvas = viewer.scene.canvas;
// Location flights run on the globe engine registered for the viewer, as
// the app's scene engine is (src/app/globeEngine.js).
registerViewerEngine(viewer, createCesiumEngine(viewer));
@@ -3577,6 +3579,8 @@ function createPrewarmHarness({ pickPosition, positionCartographic } = {}) {
},
},
};
// A Viewer's canvas is its scene's.
viewer.canvas = viewer.scene.canvas;
return {
viewer,
calls,
+15 -13
View File
@@ -1,4 +1,4 @@
// The W1 voice actions on the globe engine (phase 3, Task 9): the same
// The W1 voice actions on the globe engine: the same
// results as on the Cesium viewer, through engine.camera / picker /
// projector only, and a structured refusal when a required capability
// is missing from the attached scene.
@@ -395,19 +395,21 @@ test('select_nearest_aircraft runs on the engine end to end', async () => {
assert.equal(tracked, 'n1');
});
test('the camera pose key reads the engine as it reads the viewer', () => {
test('the camera pose key reads the engine pose', () => {
const engine = engineOverAustin({ kind: 'navara' });
const pose = engine.camera.pose();
const viewer = {
camera: {
positionWC: pose.position,
heading: pose.heading,
pitch: pose.pitch,
roll: pose.roll,
},
};
assert.equal(typeof cameraPoseKey(engine), 'string');
assert.equal(cameraPoseKey(engine), cameraPoseKey(viewer));
const { position, heading, pitch, roll } = engine.camera.pose();
const angle = (value) => Math.round(value * 1000);
assert.equal(
cameraPoseKey(engine),
[
Math.round(position.x),
Math.round(position.y),
Math.round(position.z),
angle(heading),
angle(pitch),
angle(roll),
].join(','),
);
});
test('the pointer picker picks through the engine', () => {
+1 -12
View File
@@ -38,7 +38,7 @@ export function withToolCatalog(runner, loadCatalog) {
* session; the action runner, the pointer's canvas and picker and the
* annotation events belong to one engine attachment (`attachScene`), and a
* switch only replaces those. Returns `{ commands, runner, attachScene,
* detachScene }`; `commands` is what initGevVoiceCommands returns.
* detachScene }`; `commands` is the voice controls' command handle.
*
* `isSwitching()` tells the runner that the page has started a switch, so a
* call made before the outgoing scene detaches waits for the next one too.
@@ -166,14 +166,3 @@ export function createSceneVoice(options) {
detachScene,
};
}
/**
* Compose the standalone action runner with the voice controls, on the globe
* `engine` (by default the one registered for `options.viewer`). The runner
* checks each action against the capabilities of the attached scene.
*/
export function initGevVoiceCommands(options) {
const voice = createSceneVoice(options);
voice.attachScene(options);
return voice.commands;
}
+12 -12
View File
@@ -2859,13 +2859,13 @@ test('isBenignViewportDeleteError is false for non-error payloads and junk', ()
test('hidden document yields no fresh frame — capture must not label a stale canvas Current', async () => {
const originalDocument = globalThis.document;
let requested = 0;
const scene = {
postRender: { addEventListener() { return () => {}; } },
requestRender() { requested += 1; },
const engine = {
frames: { postRender: { addEventListener() { return () => {}; } } },
render: { request() { requested += 1; } },
};
try {
globalThis.document = { hidden: true };
const fresh = await renderFreshCesiumFrame({ scene });
const fresh = await renderFreshCesiumFrame(engine);
assert.equal(fresh, false, 'hidden capture reports non-fresh');
assert.equal(requested, 0, 'no secret render restart while hidden');
} finally {
@@ -2878,11 +2878,11 @@ test('visible document with a rendering scene reports a fresh frame', async () =
try {
globalThis.document = { hidden: false };
let fire = null;
const scene = {
postRender: { addEventListener(listener) { fire = listener; return () => { fire = null; }; } },
requestRender() { queueMicrotask(() => fire?.()); },
const engine = {
frames: { postRender: { addEventListener(listener) { fire = listener; return () => { fire = null; }; } } },
render: { request() { queueMicrotask(() => fire?.()); } },
};
const fresh = await renderFreshCesiumFrame({ scene });
const fresh = await renderFreshCesiumFrame(engine);
assert.equal(fresh, true);
} finally {
globalThis.document = originalDocument;
@@ -2895,11 +2895,11 @@ test('a tab switch during the bounded render wait invalidates freshness', async
const doc = { hidden: false };
globalThis.document = doc;
let fire = null;
const scene = {
postRender: { addEventListener(listener) { fire = listener; return () => { fire = null; }; } },
requestRender() { doc.hidden = true; queueMicrotask(() => fire?.()); },
const engine = {
frames: { postRender: { addEventListener(listener) { fire = listener; return () => { fire = null; }; } } },
render: { request() { doc.hidden = true; queueMicrotask(() => fire?.()); } },
};
const fresh = await renderFreshCesiumFrame({ scene });
const fresh = await renderFreshCesiumFrame(engine);
assert.equal(fresh, false, 'freshness rechecked after the await');
} finally {
globalThis.document = originalDocument;
+1 -1
View File
@@ -66,7 +66,7 @@ function createViewer({ latitude, longitude, heightM, groundM = 0 }) {
),
};
return {
viewer: createCesiumEngine({ camera, scene }),
viewer: createCesiumEngine({ camera, canvas, scene }),
state,
degreesPerPixel,
};
+4 -11
View File
@@ -19,8 +19,6 @@
* Provider-neutral and Cesium-free: the pick is injected.
*/
import { isGlobeEngine } from '../globe/contract.js';
/** Movement below this many CSS pixels is still the same dwell. */
const POINTER_DWELL_PX = 12;
/** Stillness that makes a dwell point. */
@@ -59,17 +57,12 @@ const finite = finiteOrNull;
* Camera pose identity: position to 1 m, orientation to about 0.06 degrees.
* A pixel read under one key names nothing under another. Reads plain
* numbers only, so it needs no Cesium import.
* @param {object} globe The globe engine (its camera pose), or a Cesium
* viewer.
* @param {object} engine The globe engine (its camera pose).
* @returns {string|null}
*/
export function cameraPoseKey(globe) {
let camera = globe?.camera;
if (isGlobeEngine(globe)) {
const pose = camera.pose();
camera = { ...pose, positionWC: pose.position };
}
const p = camera?.positionWC;
export function cameraPoseKey(engine) {
const camera = engine?.camera?.pose?.();
const p = camera?.position;
if (!p || !Number.isFinite(p.x)) return null;
const angle = (value) => Math.round((Number(value) || 0) * 1000);
return [
+22 -16
View File
@@ -96,21 +96,25 @@ test('crop: a slow render gets one bounded fresh-frame recovery request', async
let listener = null;
try {
globalThis.document = { hidden: false };
const scene = {
postRender: {
addEventListener(next) {
listener = next;
return () => {
if (listener === next) listener = null;
};
const engine = {
frames: {
postRender: {
addEventListener(next) {
listener = next;
return () => {
if (listener === next) listener = null;
};
},
},
},
requestRender() {
requests += 1;
if (requests === 2) queueMicrotask(() => listener?.());
render: {
request() {
requests += 1;
if (requests === 2) queueMicrotask(() => listener?.());
},
},
};
assert.equal(await renderFreshPointerFrame({ scene }), true);
assert.equal(await renderFreshPointerFrame(engine), true);
assert.equal(requests, 2, 'only the pointer path retries once');
assert.equal(listener, null, 'the successful listener is removed');
} finally {
@@ -123,13 +127,15 @@ test('crop: a hidden document never starts the recovery request', async () => {
let requests = 0;
try {
globalThis.document = { hidden: true };
const scene = {
postRender: { addEventListener: () => () => {} },
requestRender() {
requests += 1;
const engine = {
frames: { postRender: { addEventListener: () => () => {} } },
render: {
request() {
requests += 1;
},
},
};
assert.equal(await renderFreshPointerFrame({ scene }), false);
assert.equal(await renderFreshPointerFrame(engine), false);
assert.equal(requests, 0);
} finally {
globalThis.document = originalDocument;
+1
View File
@@ -179,6 +179,7 @@ function compositionFixture(
const position = { x: 6379137, y: 0, z: 0 };
const viewer = {
clock: { onTick: { addEventListener: () => () => {} } },
canvas,
camera: {
positionWC: position,
positionCartographic: { height: state.height },
+13 -17
View File
@@ -3,21 +3,19 @@ import {
hasStructuredViewIdentity,
} from './realtimeProtocol.js';
import { cameraPoseKey } from './pointerContext.js';
import { isGlobeEngine } from '../globe/contract.js';
/** The page's globe engine (both engines), else its Cesium viewer. */
/** The page's globe engine (both engines). */
function pageGlobe() {
const debug = globalThis.window?.__godsEyeView;
return debug?.engine ?? debug?.viewer ?? null;
return globalThis.window?.__godsEyeView?.engine ?? null;
}
/** The map canvas: the engine's host canvas, else the viewer's. */
/** The map canvas: the engine's host canvas. */
function pageCanvas(globe) {
return isGlobeEngine(globe) ? globe.host.canvas : globe?.scene?.canvas;
return globe?.host?.canvas;
}
/** The live camera pose identity (Cesium-free read). */
export function readViewerCameraKey() {
function readViewerCameraKey() {
return cameraPoseKey(pageGlobe());
}
// Viewport-screenshot size guards (M13). The old code clamped WIDTH only, so a
@@ -142,7 +140,7 @@ export function pointerCropRect({
* @returns {Promise<{dataUrl: string, rect: object}|null>} JPEG data URL and
* the crop's normalized bounds in the full canvas, or null.
*/
export async function capturePointerCrop(screenPx) {
async function capturePointerCrop(screenPx) {
const globe = pageGlobe();
const source = pageCanvas(globe);
if (!source?.width || !source?.height || !screenPx) return null;
@@ -243,14 +241,12 @@ export function estimateDataUrlBytes(dataUrl) {
* canvas as current. (perf wave 2)
*/
export async function renderFreshFrame(globe) {
// The engine's frame events and render request, else the viewer's scene.
const scene = isGlobeEngine(globe)
? {
postRender: globe.frames.postRender,
requestRender: () => globe.render.request('voice-capture'),
}
: globe?.scene;
if (!scene) return false;
if (!globe) return false;
// The engine's frame events and render request.
const scene = {
postRender: globe.frames.postRender,
requestRender: () => globe.render.request('voice-capture'),
};
// While the document is hidden the render loop is suspended — don't
// secretly restart rendering for an optional screenshot, and don't pass
// the stale preserved frame off as current.
@@ -509,5 +505,5 @@ export class RealtimeViewport {
}
}
/** renderFreshFrame for callers that hold a Cesium viewer. */
/** renderFreshFrame under its earlier name (realtimeController re-exports it). */
export const renderFreshCesiumFrame = renderFreshFrame;