Fix the review findings across the engines, layers, data and QA

Navara now matches Cesium where the review found it diverging: a flight
holds the camera inputs, camera.changed counts turns as Cesium does,
render requests made during a frame survive it, follow pinches zoom,
ground widths follow the pixel ratio and Cyber sonar reaches glyph caches
and models. On Cesium, a staged imagery swap keeps loading tiles, setView
replaces a running flight, and a cleared weather detail goes away.

The contract gains MoverSet.failed, maps.terrainRevision,
render.maxTextureSize and surface.sampleTerrainMostDetailed on every
engine, so layers retry failed models, key road heights by terrain,
size weather textures to the GPU and place Bhote Koshi cards on detailed
terrain.

Engine switches keep the live view, follows, focus, layer options and
cards: a pick hands over the exact pose, applies no address options and
pans no carried-over card; a history visit still applies its entry.

Layers put GhostMaps pins, cable landings, OSM Places and directions on
the measured surface without per-frame sampling, draw the Cockpit contact
dot, hide disabled CCTV on attach, and keep ALPR running outside secure
contexts. KML imports draw raised polygon fills, rotated and coloured
ground overlays and north-referenced icon headings, and report files
with nothing to draw.

QA scripts read the contract instead of Cesium internals (test:track is
109/109 again), wait for the camera to rest before clicking, and give
cold switches and parked engines realistic time. Docs follow the code.
This commit is contained in:
German Khokhlov committed 2026-11-09 21:34:42 +04:00
1 parent 69fbf5b38d
commit 0ef29781e5
276 files changed
+7217 -1517

No files matched your search

+64
View File
@@ -0,0 +1,64 @@
// A CCTV layer that was initialized and then switched off must stay hidden
// across an engine switch: detachRenderer() + attachRenderer() on the new
// engine while _enabled is false must not draw the camera markers. The active
// camera is left for an obstruction probe on the new engine's surface.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import * as geo from '../../geo/index.js';
import { createFakeEngine } from '../../globe/testing/fakeEngine.js';
import { loadLayerRenderers } from '../../app/layers/renderers.js';
import cctvLayer, { _setCctvCoverageStateForTest } from '../../data/cctv.js';
await loadLayerRenderers('cesium');
test('disabled CCTV markers stay hidden after an engine switch', () => {
const first = createFakeEngine({
width: 1280,
height: 800,
altitude: 50_000,
});
const second = createFakeEngine({
width: 1280,
height: 800,
altitude: 50_000,
});
const position = geo.cartesian3.fromDegrees(0, 0, 10);
const record = {
camera: { id: 'cam-1', lat: 0, lon: 0, feedType: 'image' },
position,
coverageEntities: [],
activationDone: true,
};
_setCctvCoverageStateForTest({
engine: first,
records: [record],
activeCameraId: 'cam-1',
enabled: false,
});
try {
cctvLayer.detachRenderer();
cctvLayer.attachRenderer(null, { engine: second });
second.fake.frames(2);
const set = second.fake.moverSet('cctv');
assert.ok(set, 'marker set exists');
assert.equal(
record.activationDone,
false,
'the new surface needs an activation probe',
);
assert.equal(record.surfaceProbePending, true);
assert.equal(set.store.count ?? set.count ?? 1, 1);
assert.equal(
set.store.shows[0],
0,
'marker of the disabled layer is hidden',
);
} finally {
try {
cctvLayer.detachRenderer();
} catch {}
_setCctvCoverageStateForTest({ enabled: false });
first.destroy();
second.destroy();
}
});
+11
View File
@@ -29,6 +29,17 @@ export function createIngestion({
parts.model.projectionTilesReady()
) {
layerState._tilesReadyReenqueued = true;
const active = parts.selection.getActiveRecord();
if (active?.surfaceProbePending) {
active.surfaceProbePending = false;
parts.geometry.runActivationObstructionProbe(active);
parts.geometry.applyFrustumGeometry(
active,
parts.ground.groundAltFor(active),
);
active.activationDone = true;
changed = true;
}
// Per-regime resolution (Task 5): only records unresolved for the
// CURRENT surface regime need the completion pass. On globe stacks
// projectionTilesReady() is false while a (hidden) Google tileset
+23
View File
@@ -26,6 +26,7 @@ function setup() {
},
},
navigation: { maybeAutoHop() {} },
selection: { getActiveRecord: () => record },
presentation: {
notifyListeners() {
calls.notify++;
@@ -100,3 +101,25 @@ test('a tick resuming after an engine switch released the renderer does no scene
assert.equal(sceneWork, 0);
assert.equal(h.calls.notify, 1);
});
test('an engine switch probes the active camera once the new surface is ready', async () => {
const h = setup();
const probes = [];
h.parts.geometry = {
runActivationObstructionProbe: (record) => probes.push(['probe', record]),
applyFrustumGeometry: (record, ground) =>
probes.push(['geometry', record, ground]),
};
h.parts.ground.groundAltFor = () => 12;
h.record.surfaceProbePending = true;
h.state._tilesReadyReenqueued = false;
assert.equal((await h.layer.update()).changed, true);
assert.deepEqual(probes, [
['probe', h.record],
['geometry', h.record, 12],
]);
assert.equal(h.record.activationDone, true, 're-selecting it is a no-op');
h.state._tilesReadyReenqueued = false;
await h.layer.update();
assert.equal(probes.length, 2, 'one probe per engine switch');
});
+17 -12
View File
@@ -45,11 +45,11 @@ export function createLifecycle({
/** Records the camera pose the last view pass ran at. */
function noteViewPose() {
const camera = layerState._viewer?.camera;
if (!camera?.positionWC) return;
const camera = parts.renderer?.cameraPose();
if (!camera?.position) return;
layerState._viewPose = {
position: geo.cartesian3.clone(camera.positionWC),
direction: camera.directionWC && geo.cartesian3.clone(camera.directionWC),
position: geo.cartesian3.clone(camera.position),
direction: camera.direction && geo.cartesian3.clone(camera.direction),
};
}
@@ -59,16 +59,14 @@ export function createLifecycle({
* would otherwise rerun the full pass on every tick.
*/
function viewPoseChanged() {
const camera = layerState._viewer?.camera;
const camera = parts.renderer?.cameraPose();
const pose = layerState._viewPose;
if (!pose || !camera?.positionWC) return true;
const height = Math.max(1, camera.positionCartographic?.height ?? 0);
const moved = geo.cartesian3.distance(camera.positionWC, pose.position);
if (!pose || !camera?.position) return true;
const height = Math.max(1, camera.cartographic?.height ?? 0);
const moved = geo.cartesian3.distance(camera.position, pose.position);
if (moved > height * VIEW_MOTION_MIN_MOVE_FRACTION) return true;
if (!pose.direction || !camera.directionWC) return false;
return (
geo.cartesian3.dot(camera.directionWC, pose.direction) < MIN_TURN_COS
);
if (!pose.direction || !camera.direction) return false;
return geo.cartesian3.dot(camera.direction, pose.direction) < MIN_TURN_COS;
}
function viewMotionTick() {
@@ -428,6 +426,7 @@ export function createLifecycle({
const renderer = createRenderer(viewer, options);
layerState._restoringViewport = Boolean(options.waitForCameraRestore);
renderer.createMarkers();
const active = parts.selection.getActiveRecord();
for (const record of layerState._records) {
record.billboard = renderer.createMarker(
record.camera,
@@ -436,7 +435,13 @@ export function createLifecycle({
record.groundResolved = {};
record.groundSamples = {};
record.probeClampRangeM = null;
// The new surface is unprobed: update() probes the active camera
// once its tiles are in.
record.surfaceProbePending =
record === active && record.activationDone === true;
record.activationDone = false;
}
renderer.setMarkersVisible(layerState._enabled);
bindScene(viewer, options);
if (!layerState._restoringViewport && layerState._enabled)
this.resumeDisplay();
+1
View File
@@ -569,6 +569,7 @@ export function createCctvDisplay(engine, { state, services = {} } = {}) {
get ready() {
return initialized && !destroyed && !engine.isDestroyed();
},
cameraPose: () => engine.camera.pose(),
cameraCartographic: () => engine.camera.pose().cartographic,
following: () => Boolean(engine.camera.following()),
globeVisible: () => !engine.maps.photorealActive(),
+1 -1
View File
@@ -177,7 +177,7 @@ export function createRendering({
const minY = -height * VIEW_ICON_MARGIN;
const maxY = height * (1 + VIEW_ICON_MARGIN);
// Ground metres one pixel covers per metre of distance from the viewer.
const fovy = layerState._viewer?.camera?.frustum?.fovy || Math.PI / 3;
const fovy = parts.renderer.cameraPose()?.fovy || Math.PI / 3;
const metresPerPixelPerMetre =
(2 * Math.tan(fovy / 2)) / Math.max(1, height);
const activeId = layerState._activeCameraId;
+57
View File
@@ -0,0 +1,57 @@
// CCTV icon thinning must use the camera's real vertical FOV. In a 16:9
// window with Cesium's default fov 60deg the vertical FOV is about 36deg;
// main read it from viewer.camera.frustum.fovy. Two cameras 17 m apart seen
// from 2 km: with fovy 36deg the cell is ~48 m (< VIEW_MIN_CELL_M, both shown),
// with the hard-coded pi/3 fallback it is ~86 m and one camera is hidden.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { createRendering } from './rendering.js';
import { isVideoFeedType } from '../../sources/cctvTypes.js';
const FOVY_16_9 = 2 * Math.atan(Math.tan(Math.PI / 6) / (16 / 9));
test('icon thinning uses the camera vertical FOV, not a pi/3 fallback', () => {
const record = (id, lat, x) => ({
camera: { id, lat, lon: 0, feedType: 'image' },
billboard: { show: true, position: { x, y: 0, z: 0 } },
});
const a = record('cam-a', 10.0005, 0);
const b = record('cam-b', 10.00065, 17);
const pose = { fovy: FOVY_16_9 };
const state = {
_enabled: true,
_records: [a, b],
_viewRecords: [],
_healthById: new Map(),
_activeCameraId: null,
};
const renderer = {
ready: true,
viewport: () => ({ width: 1920, height: 1080 }),
horizonTest: () => () => true,
project: () => ({ x: 960, y: 540 }),
distance: () => 2000,
// Accessor the fix is expected to add (any name works if the stub follows).
cameraPose: () => pose,
fovy: () => pose.fovy,
engine: { camera: { pose: () => pose } },
};
const { refreshHorizonCulling } = createRendering({
state,
services: {
focus: {
focusNowMs: (n) => n,
getFocusTarget: () => null,
focusPassIsNeeded: () => false,
advanceSpriteFocus: () => ({ factor: 1 }),
focusAlphaNeedsWrite: () => false,
},
},
parts: { renderer, model: { isVideoFeedType } },
source: {},
});
refreshHorizonCulling();
assert.equal(a.billboard.show, true, 'cam-a shown');
assert.equal(b.billboard.show, true, 'cam-b shown');
assert.equal(state._viewRecords.length, 2);
});