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

+29 -9
View File
@@ -12,7 +12,9 @@
// wall time (Cesium's cameraEventWaitTime), changed past percentageChanged.
//
// The port is the engine's thin layer over the Navara view (apply, read, fly,
// stop, size, requestFrame); see createNavaraEngine.js.
// stop, size, requestFrame, suspendCameraInputs); see createNavaraEngine.js.
// A flight suspends the camera inputs until it ends, as Cesium's
// CameraFlightPath turns them off: a gesture cannot cut it short.
import * as geo from '../../geo/index.js';
import { createEngineEvent } from '../contract.js';
@@ -81,6 +83,7 @@ function posesNear(a, b, distance, angle) {
* stop: () => void,
* size: () => { width: number, height: number },
* requestFrame: () => void,
* suspendCameraInputs?: () => () => void,
* },
* clock?: { now: () => number, setTimeout: Function, clearTimeout: Function },
* }} options
@@ -124,6 +127,11 @@ export function createCameraModel({
let lastSeen = initial ? copyPose(initial) : null;
let lastFramePose = copyPose(state);
let lastChangedPose = copyPose(state);
let changedAngles = headingPitchRoll(
state.position,
state.direction,
state.up,
);
let moving = false;
let lastMoveAt = 0;
let moveEndTimer = null;
@@ -175,6 +183,7 @@ export function createCameraModel({
function endFlight(current, outcome) {
if (flight !== current) return;
flight = null;
current.resume?.();
if (outcome === 'cancel') current.options.cancel?.();
}
@@ -197,7 +206,7 @@ export function createCameraModel({
options.complete?.();
return;
}
const current = { options };
const current = { options, resume: port.suspendCameraInputs?.() };
flight = current;
// Navara moves the camera from here on; read it back every frame.
pushed = null;
@@ -212,7 +221,7 @@ export function createCameraModel({
(arrived) => {
if (flight !== current || destroyed) return;
if (!arrived) return endFlight(current, 'cancel');
flight = null;
endFlight(current, 'complete');
land(options, target);
options.complete?.();
},
@@ -261,13 +270,28 @@ export function createCameraModel({
}
lastFramePose = pose;
const turn =
angleBetween(pose.direction, lastChangedPose.direction) / Math.PI;
angleBetween(pose.direction, lastChangedPose.direction) /
(view().fovy / 2);
const altitude = Math.max(
1,
cartographic.fromCartesian(pose.position, WGS84).height,
);
const shift =
cartesian3.distance(pose.position, lastChangedPose.position) / altitude;
const angles = headingPitchRoll(pose.position, pose.direction, pose.up);
const delta = (a, b) => {
const angle = Math.abs(a - b) % (2 * Math.PI);
return Math.min(angle, 2 * Math.PI - angle) / Math.PI;
};
// Heading and roll are raised on their own, as Camera._updateCameraChanged
// does: a turn about the line of sight (heading at nadir, roll) moves
// neither the direction nor the position.
for (const angle of ['heading', 'roll']) {
const amount = delta(angles[angle], changedAngles[angle]);
if (amount <= percentageChanged) continue;
changedAngles[angle] = angles[angle];
events.changed.raiseEvent(amount);
}
const amount = Math.max(turn, shift);
if (amount > percentageChanged) {
lastChangedPose = pose;
@@ -311,6 +335,7 @@ export function createCameraModel({
if (!options?.destination)
throw new TypeError('setView needs a destination');
announce();
cancelCurrentFlight();
place(viewFor(options.destination, options.orientation));
},
flyTo(options) {
@@ -395,11 +420,6 @@ export function createCameraModel({
camera,
sync,
afterFrame,
/**
* Ends a running flight (its `cancel` runs) without camera.commanded:
* for the user's own gestures, which are not a new camera owner.
*/
stopFlight: () => cancelCurrentFlight(),
/**
* Whether nothing else drives the camera: no flight and no lookAt target
* (identity transform). The engine's ground floor acts only then.