Complete phase 3 W1 acceptance and close T16 findings

Fix Navara model display tint, overlay ordering, follow gestures and resource cleanup.
Reduce repeated aircraft work and correct fixture enrichment responses.
Strengthen dev/preview QA, preserve failure history and document verified W1 results.

Validation: 7171 ordinary tests pass, one Windows-only skip; 15 allocation probes;
37 W1 acceptance steps; contracts, shell, four performance gates; 18 identical
Cesium baseline PNGs. Known pre-existing CCTV and live-source limits are recorded.
This commit is contained in:
German Khokhlov committed 2026-10-26 23:23:25 +04:00
1 parent 766c786093
commit 0600964249
59 files changed
+2334 -701

No files matched your search

+8
View File
@@ -26,6 +26,12 @@ export function aircraftQaDrawn(state) {
width: sprite.width,
show: sprite.show,
rotation: sprite.rotation,
trackedRotation:
id === state._trackedIcao
? (state._trackedEntity?.rotation ??
state._lastTrackedRotation ??
null)
: null,
alpha: sprite.color?.alpha ?? null,
position: sprite.position
? {
@@ -43,6 +49,7 @@ export function aircraftQaDrawn(state) {
ready: model.ready,
// Where it is drawn: its transform's translation.
position: translationOf(model.modelMatrix),
matrix: model.modelMatrix ? Array.from(model.modelMatrix) : null,
}
: null,
});
@@ -56,6 +63,7 @@ export function aircraftQaDrawn(state) {
scale: tracked.scale,
show: tracked.show,
ready: tracked.ready,
matrix: tracked.modelMatrix ? Array.from(tracked.modelMatrix) : null,
},
});
return out;
+43
View File
@@ -0,0 +1,43 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { aircraftQaDrawn } from './qaDrawn.js';
for (const native of [false, true]) {
test(`heading probe copies model transforms and reads tracked glyph (${native ? 'native' : 'engine'})`, () => {
const matrix = Float64Array.from({ length: 16 }, (_, i) => i);
const sprite = {
position: { x: 1, y: 2, z: 3 },
rotation: 0.4,
show: false,
};
const model = { modelMatrix: matrix, show: true, ready: true };
const state = {
_billboards: new Map([['a', sprite]]),
_models: new Map([['a', model]]),
_trackedIcao: 'a',
_lastTrackedRotation: 0.7,
_trackedModel: model,
_trackedEntity: native
? {
billboard: {
rotation: {
getValue: () => {
throw new Error(
'Probe must not evaluate a reactive property',
);
},
},
},
}
: { rotation: 0.7 },
};
const [fleet, tracked] = aircraftQaDrawn(state);
assert.equal(fleet.trackedRotation, 0.7);
assert.equal(fleet.rotation, 0.4);
assert.equal(tracked.model.matrix[12], 12);
fleet.model.matrix[12] = -1;
tracked.model.matrix[12] = -2;
assert.equal(matrix[12], 12);
assert.equal(aircraftQaDrawn(state)[1].model.matrix[12], 12);
});
}
+33 -7
View File
@@ -57,6 +57,13 @@ const fieldsNoPick = {
show: undefined,
};
const scratchColor = new Float64Array(4);
// Sprite setters write synchronously into the mover store; reuse their
// field records rather than allocating one per contact and assignment.
const spritePositionField = { position: null };
const spriteShowField = { show: true };
const spriteRotationField = { rotation: 0 };
const spriteScaleField = { scale: 1 };
const spriteColorField = { color: scratchColor };
function writeFields(set, index, fields) {
const scratch = fieldsNoPick;
for (const key in fields) scratch[key] = fields[key];
@@ -371,7 +378,8 @@ export function createAircraftNavaraRenderer({
set position(value) {
geo.cartesian3.clone(value, this._position);
this.write({ position: this._position });
spritePositionField.position = this._position;
this.write(spritePositionField);
}
get show() {
@@ -379,8 +387,11 @@ export function createAircraftNavaraRenderer({
}
set show(value) {
this._show = value !== false;
this.write({ show: this._show });
const next = value !== false;
if (next === this._show) return;
this._show = next;
spriteShowField.show = next;
this.write(spriteShowField);
}
get rotation() {
@@ -388,8 +399,10 @@ export function createAircraftNavaraRenderer({
}
set rotation(value) {
if (value === this._rotation) return;
this._rotation = value;
this.write({ rotation: value });
spriteRotationField.rotation = value;
this.write(spriteRotationField);
}
get scale() {
@@ -397,8 +410,10 @@ export function createAircraftNavaraRenderer({
}
set scale(value) {
if (value === this._scale) return;
this._scale = value;
this.write({ scale: this.drawnScale() });
spriteScaleField.scale = this.drawnScale();
this.write(spriteScaleField);
}
get width() {
@@ -406,8 +421,10 @@ export function createAircraftNavaraRenderer({
}
set width(value) {
if (value === this._width) return;
this._width = value;
this.write({ scale: this.drawnScale() });
spriteScaleField.scale = this.drawnScale();
this.write(spriteScaleField);
}
get height() {
@@ -423,8 +440,17 @@ export function createAircraftNavaraRenderer({
}
set color(value) {
if (
value !== this._color &&
(value?.red ?? 1) === this._color.red &&
(value?.green ?? 1) === this._color.green &&
(value?.blue ?? 1) === this._color.blue &&
(value?.alpha ?? 1) === this._color.alpha
)
return;
this._color = new StoredColor(value);
this.write({ color: rgbaOf(this._color) });
rgbaOf(this._color);
this.write(spriteColorField);
}
get image() {
@@ -293,3 +293,59 @@ test('trails are engine lines in the trail pick namespace; the head follows each
renderer.destroy();
engine.destroy();
});
test('unchanged sprite style does not upload or request another frame', async () => {
const { engine, renderer } = await setup();
const sprite = renderer.fleet.add({
id: 'same',
position: geo.cartesian3.fromDegrees(0, 0, 1000),
image: aircraftIcon('light'),
});
await Promise.resolve();
const [listed] = setsOf(engine, 'flights-sprites');
const part = engine.fake.moverSet(listed.id);
const before = part.commits;
const color = sprite.color;
for (let n = 0; n < 1000; n++) {
sprite.show = true;
sprite.rotation = 0;
sprite.scale = 1;
sprite.width = 20;
sprite.color = WHITE;
}
await Promise.resolve();
assert.equal(part.commits, before);
assert.equal(sprite.color, color);
renderer.destroy();
engine.destroy();
});
test('reused sprite field records are copied, including a mutated color getter', async () => {
const { engine, renderer } = await setup();
const a = renderer.fleet.add({
id: 'a',
position: geo.cartesian3.fromDegrees(0, 0, 1000),
image: aircraftIcon('light'),
});
const b = renderer.fleet.add({
id: 'b',
position: a.position,
image: aircraftIcon('light'),
});
await Promise.resolve();
const [listed] = setsOf(engine, 'flights-sprites');
const { store } = engine.fake.moverSet(listed.id);
const position = geo.cartesian3.create(7, 8, 9);
a.position = position;
position.x = 20;
b.position = position;
a.color.alpha = 0.25;
a.color = a.color;
b.color = WHITE.withAlpha(0.75);
await Promise.resolve();
assert.deepEqual([...store.positions.subarray(0, 6)], [7, 8, 9, 20, 8, 9]);
assert.equal(store.colors[3], 0.25);
assert.equal(store.colors[7], 0.75);
renderer.destroy();
engine.destroy();
});
+5 -1
View File
@@ -1048,7 +1048,11 @@ export function createTracking({
} else if (flightState._renderer.fleet.visible()) {
// Fire-and-forget refresh; only while the layer is actually enabled.
// The query reads the renderer's camera (no viewer argument needed).
void flightsLayer.update(null);
void flightsLayer.update(null).catch((error) => {
// This refresh has no lifecycle-manager caller. Disabling flights
// cancels it locally; retain visibility of unexpected failures.
if (error?.name !== 'AbortError') console.error(error);
});
}
}
@@ -0,0 +1,54 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import { createTracking } from './tracking.js';
function handoff(update) {
return createTracking({
flightState: {
_renderer: { fleet: { attached: () => true, visible: () => true } },
},
services: Object.fromEntries(
[
'context',
'aircraftPresentation',
'geoid',
'groundFloor',
'focus',
'militaryRegistry',
'readout',
'selection',
].map((name) => [name, {}]),
),
parts: {},
layer: { update },
});
}
test('a military-off refresh owns cancellation when flights are disabled before it settles', async (t) => {
const errors = [];
t.mock.method(console, 'error', (error) => errors.push(error));
let reject,
calls = 0;
const tracking = handoff(() => {
calls++;
return new Promise((_resolve, fail) => {
reject = fail;
});
});
tracking._onMilitaryActiveChange(false);
assert.equal(calls, 1);
reject(new DOMException('Flights update aborted', 'AbortError'));
await new Promise((resolve) => setImmediate(resolve));
assert.deepEqual(errors, []);
});
test('unexpected military-off refresh failures remain visible instead of being swallowed', async (t) => {
const error = new Error('fixture update failure');
const errors = [];
t.mock.method(console, 'error', (value) => errors.push(value));
handoff(async () => {
throw error;
})._onMilitaryActiveChange(false);
await new Promise((resolve) => setImmediate(resolve));
assert.deepEqual(errors, [error]);
});
+13
View File
@@ -22,6 +22,7 @@ import {
} from './card.js';
import { createLocalAdsbEnrichment, localAdsbClass } from './enrichment.js';
import { createLocalAdsbModels } from './models.js';
import { localAdsbQaDrawn } from './qaDrawn.js';
import { LocalAdsbMotion } from './motion.js';
import {
ENTITY_PREFIX,
@@ -714,6 +715,18 @@ export function createLocalAdsbLayer({
void receiver.destroy?.();
},
...(import.meta.env?.DEV
? {
qaDrawn() {
return localAdsbQaDrawn(markers, models?.qaModels?.(), {
enabled,
cameraPosition: renderer?.view.camera?.positionWC,
isVisible: markerVisible,
});
},
}
: {}),
getStats() {
const current = receiver.getState();
const at = now();
+1
View File
@@ -178,6 +178,7 @@ export function createLocalAdsbModels({
}
return {
...(import.meta.env?.DEV ? { qaModels: () => models } : {}),
/** Ids whose model admission is current; the layer enriches these. */
get eligible() {
return eligible;
+49
View File
@@ -0,0 +1,49 @@
// On-demand QA snapshots of the cached local renderer state. Never read
// an entity CallbackProperty: that would evaluate rendering during a probe.
export function localAdsbQaDrawn(
markers,
models,
{ enabled, cameraPosition, isVisible },
) {
const rows = [];
for (const marker of markers.values()) {
const position = marker.position;
const distance =
position && cameraPosition
? Math.hypot(
position.x - cameraPosition.x,
position.y - cameraPosition.y,
position.z - cameraPosition.z,
)
: Infinity;
const show = Boolean(
enabled &&
!marker.modelOwnsVisual &&
isVisible(marker) &&
distance <= 2_000_000,
);
const model = models?.get(marker.id);
const matrix = model?.modelMatrix;
rows.push({
id: marker.record.icao,
show,
rotation: marker.lastRotation,
alpha: show ? 1 : 0,
position: position
? { x: position.x, y: position.y, z: position.z }
: null,
model: model
? {
show: model.show,
ready: model.ready,
computedScale: model.computedScale,
position: matrix
? { x: matrix[12], y: matrix[13], z: matrix[14] }
: null,
matrix: matrix ? Array.from(matrix) : null,
}
: null,
});
}
return rows;
}
+72
View File
@@ -0,0 +1,72 @@
import assert from 'node:assert/strict';
import test from 'node:test';
import { localAdsbQaDrawn } from './qaDrawn.js';
function setup() {
const marker = {
id: 'local-adsb:abc123',
record: { icao: 'abc123' },
position: { x: 6378137, y: 2, z: 3 },
lastRotation: 0.7,
modelOwnsVisual: false,
};
Object.defineProperty(marker, 'entity', {
get() {
throw new Error('A snapshot must not evaluate native callbacks');
},
});
const matrix = new Float64Array(16);
matrix[12] = 6378138;
matrix[13] = 4;
matrix[14] = 5;
const model = {
ready: true,
show: true,
computedScale: 12,
modelMatrix: matrix,
};
const markers = new Map([[marker.id, marker]]),
models = new Map([[marker.id, model]]);
const options = {
enabled: true,
cameraPosition: { x: 6379137, y: 2, z: 3 },
isVisible: () => true,
};
return { marker, matrix, markers, models, options };
}
test('local QA copies the drawn model and reads cached glyph rotation without callbacks', () => {
const f = setup();
const [row] = localAdsbQaDrawn(f.markers, f.models, f.options);
assert.equal(row.id, 'abc123');
assert.equal(row.rotation, 0.7);
assert.equal(row.alpha, 1);
assert.equal(row.model.computedScale, 12);
assert.equal(row.model.ready, true);
row.position.x = 0;
row.model.matrix[12] = 0;
row.model.position.x = 0;
assert.equal(f.marker.position.x, 6378137);
assert.equal(f.matrix[12], 6378138);
});
test('local QA respects disabled, horizon, model handoff and the two-million-metre glyph limit', () => {
for (const change of [
(f) => {
f.options.enabled = false;
},
(f) => {
f.options.isVisible = () => false;
},
(f) => {
f.marker.modelOwnsVisual = true;
},
(f) => {
f.options.cameraPosition.x += 2_000_000;
},
]) {
const f = setup();
change(f);
const [row] = localAdsbQaDrawn(f.markers, f.models, f.options);
assert.equal(row.show, false);
assert.equal(row.alpha, 0);
assert.equal(row.model.ready, true);
}
});