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 -3
View File
@@ -1,7 +1,6 @@
import { AIRCRAFT_ENVIRONMENT_MAP_OPTIONS } from '../../../data/aircraftModelLighting.js';
// The aircraft renderer on Cesium (contract: ./contract.js): the Cesium
// objects the aircraft layers used to build themselves, moved here one for
// one — the fleet BillboardCollection and its sprite-order slot, the model
// objects the aircraft layers draw with — the fleet BillboardCollection and its sprite-order slot, the model
// PrimitiveCollection and its glTF loads, the tracked Entity (billboard with
// per-frame CallbackProperties, followed through viewer.trackedEntity and
// the one exact tracked frame), the trail entity and its live head
@@ -19,7 +18,7 @@ import { horizonOccluder } from '../../../data/iconOrientation.js';
import { engineFromViewer } from '../../../globe/cesium/engineFromViewer.js';
import { applyTrackedCameraFrame } from '../../../globe/cesium/follow.js';
// The model shader of the IR boost (owner playtest 2026-08-16): boosted
// The model shader of the IR boost: boosted
// models render UNLIT so a side-lit airframe does not go black in FLIR/NVG.
// Assigning a customShader to a ready model is a silent no-op, so the layer
// reloads boosted models and the shader is set at creation. One stateless
+1 -3
View File
@@ -3,7 +3,6 @@ import assert from 'node:assert/strict';
import * as Cesium from 'cesium';
import * as geo from '../../../geo/index.js';
import { createAircraftCesiumRenderer } from './cesium.js';
import { missingAircraftRendererMembers } from './contract.js';
import { CYAN, nearFarScale, rgbaFromCss } from '../../shared/color.js';
/** A viewer with what the renderer touches: primitives, entities, camera. */
@@ -60,9 +59,8 @@ const renderer = (viewer, options = {}) =>
...options,
});
test('the Cesium aircraft renderer has every member of the contract', () => {
test('the Cesium aircraft renderer reports its kind', () => {
const { viewer } = stubViewer();
assert.deepEqual(missingAircraftRendererMembers(renderer(viewer)), []);
assert.equal(renderer(viewer).kind, 'cesium');
});
-70
View File
@@ -88,73 +88,3 @@
* What a vertical surface probe must not hit: the layer's own drawings.
* @property {() => void} destroy
*/
/** The members every aircraft renderer has (shape checks, tests). */
export const AIRCRAFT_RENDERER_SHAPE = Object.freeze({
view: [
'frameNumber',
'viewportHeightPx',
'frustumTester',
'horizon',
'worldToWindow',
'requestRender',
'on',
'holdFrames',
'closeFrameLatch',
'releaseFrames',
],
fleet: [
'attach',
'detach',
'attached',
'visible',
'setVisible',
'add',
'remove',
'restoreOrder',
'restoreOrderOnEnable',
],
models: [
'live',
'setVisible',
'loadFleet',
'loadTracked',
'preload',
'add',
'remove',
'destroy',
'setPose',
],
tracked: [
'create',
'remove',
'isLive',
'setImage',
'setViewFrom',
'billboardSize',
],
follow: [
'start',
'refocus',
'release',
'isFollowing',
'current',
'onChanged',
],
trails: ['create', 'createHead', 'removeHead'],
});
/**
* The members of AIRCRAFT_RENDERER_SHAPE that `renderer` lacks
* (['group.member', …]); empty for a complete renderer.
*/
export function missingAircraftRendererMembers(renderer) {
const missing = [];
for (const key of ['kind', 'view', 'surfaceExclusions', 'destroy'])
if (renderer?.[key] === undefined) missing.push(key);
for (const [group, members] of Object.entries(AIRCRAFT_RENDERER_SHAPE))
for (const member of members)
if (typeof renderer?.[group]?.[member] !== 'function')
missing.push(`${group}.${member}`);
return missing;
}
+30 -132
View File
@@ -23,39 +23,33 @@ import {
drawAircraftIconAtlas,
} from '../../../data/aircraftIcons.js';
import { createEngineLayerView } from '../../shared/render/engineView.js';
import { rgbaFromCss } from '../../shared/color.js';
import { SPRITE_LAYER_ORDER } from '../../../data/spriteOrder.js';
import {
createMoverBank,
StoredColor,
writeFields,
} from '../../shared/render/navaraMoverBank.js';
const BASE_SIZE_PX = 20;
/**
* The model frame → glTF scene axes on Navara: Cesium's own glTF axis
* correction, Y_UP_TO_Z_UP × Z_UP_TO_X_UP (data/modelVisualAnchor.js).
* Navara's glTF loader is three's GLTFLoader, which keeps the scene Y-up.
* (10b used Z_UP_TO_X_UP alone, on the belief that the loader turned the
* scene Z-up: every fleet model drew 90° off its heading — side by side
* with Cesium at the near pose, 10b review item 3.)
* Navara's glTF loader is three's GLTFLoader, which keeps the scene Y-up,
* so Z_UP_TO_X_UP alone would draw every model 90° off its heading.
*/
// Cesium's Axis.Y_UP_TO_Z_UP × Axis.Z_UP_TO_X_UP, column-major.
const NAVARA_GLTF_AXIS = [0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 1];
const FIRST_CAPACITY = 1024;
const ATLAS_PAD = 2;
const TRAIL_ALPHA = 0.85;
const TRAIL_OCCLUDED_ALPHA = 0.4;
const MIN_SEGMENT_DISTANCE_SQ = 0.01;
// ---------------------------------------------------------------------------
// Banks of mover sets
// Sprite fields
// ---------------------------------------------------------------------------
// Reused set() arguments (set() copies them; no object per write).
const fieldsNoPick = {
position: undefined,
orientation: undefined,
color: undefined,
rotation: undefined,
scale: undefined,
cell: undefined,
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.
@@ -64,102 +58,6 @@ 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];
set.set(index, scratch);
for (const key in fields) scratch[key] = undefined;
}
/**
* A growing bank of one kind of mover: handles hold an index; removal moves
* the last handle into the hole. `options(capacity, generation)` gives the
* createSet options; `write(handle, set, index)` writes a handle whole.
*/
export function createMoverBank(engine, { options, write, onCommit }) {
const handles = [];
let set = null;
let generation = 0;
let capacity = 0;
let visible = true;
let dirty = false;
const build = (wanted) => {
const next = engine.movers.createSet(options(wanted, ++generation));
set?.destroy();
set = next;
capacity = wanted;
handles.forEach((handle, index) => write(handle, set, index));
set.setCount(visible ? handles.length : 0);
};
const bank = {
handles,
get set() {
return set;
},
ready: () => Boolean(set?.ready()),
add(handle) {
if (handle.gevBank === bank) return;
handle.gevBank?.remove(handle);
handle.gevBank = bank;
handle.gevIndex = handles.length;
handles.push(handle);
if (!set || handles.length > capacity)
build(Math.max(FIRST_CAPACITY, capacity * 2, handles.length));
else {
write(handle, set, handle.gevIndex);
if (visible) set.setCount(handles.length);
}
bank.touch();
},
remove(handle) {
if (handle.gevBank !== bank) return;
const index = handle.gevIndex;
const last = handles.pop();
if (last !== handle) {
handles[index] = last;
last.gevIndex = index;
write(last, set, index);
}
handle.gevBank = null;
handle.gevIndex = -1;
set?.setCount(visible ? handles.length : 0);
bank.touch();
},
/** Writes `fields` of one handle (when it is in this bank). */
update(handle, fields) {
if (handle.gevBank !== bank || !set) return;
writeFields(set, handle.gevIndex, fields);
bank.touch();
},
setVisible(next) {
visible = next;
set?.setCount(visible ? handles.length : 0);
bank.touch();
},
visible: () => visible,
touch() {
if (!dirty) {
dirty = true;
onCommit(bank);
}
},
commit() {
if (!dirty) return;
dirty = false;
set?.commit();
},
destroy() {
for (const handle of handles) {
handle.gevBank = null;
handle.gevIndex = -1;
}
handles.length = 0;
set?.destroy();
set = null;
},
};
return bank;
}
const rgbaOf = (color, result = scratchColor) => {
result[0] = color?.red ?? 1;
@@ -169,20 +67,6 @@ const rgbaOf = (color, result = scratchColor) => {
return result;
};
/** Plain colour copy (the stored value a handle's colour getter returns). */
class StoredColor {
constructor(color) {
this.red = color?.red ?? 1;
this.green = color?.green ?? 1;
this.blue = color?.blue ?? 1;
this.alpha = color?.alpha ?? 1;
}
withAlpha(alpha) {
return new StoredColor({ ...this, alpha });
}
}
const depthKey = (distance) =>
distance === Number.POSITIVE_INFINITY
? 'always'
@@ -826,13 +710,9 @@ export function createAircraftNavaraRenderer({
// --- trails ----------------------------------------------------------------
let lineSeq = 0;
const rgbaFromCss = (css) => {
const hex = String(css).replace('#', '');
return [0, 2, 4].map((at) => parseInt(hex.slice(at, at + 2), 16) / 255);
};
const trails = {
create({ color, width = 2.5 }) {
const [r, g, b] = rgbaFromCss(color);
const [r, g, b] = rgbaFromCss(color).rgba();
const id = `gev-trail:${layerId}-${++lineSeq}`;
let line = null;
let visible = true;
@@ -880,7 +760,7 @@ export function createAircraftNavaraRenderer({
};
},
createHead({ id, show, positions, color, width = 2.5 }) {
const [r, g, b] = rgbaFromCss(color);
const [r, g, b] = rgbaFromCss(color).rgba();
const line = engine.lines.createLine({
id: `${id}`,
widthPx: width,
@@ -946,5 +826,23 @@ export function createAircraftNavaraRenderer({
};
}
/**
* The Navara registry factory (src/app/layers/renderers.js) of one aircraft
* layer: its sprite slot (data/spriteOrder's order on Cesium) and its
* model's nose offset.
* @param {string} layerId
* @param {number} headingOffsetDeg
*/
export function aircraftLayerNavaraRenderer(layerId, headingOffsetDeg) {
/** @param {import('../../../globe/contract.js').GlobeEngine} engine */
return (engine) =>
createAircraftNavaraRenderer({
engine,
layerId,
order: SPRITE_LAYER_ORDER.indexOf(layerId),
headingOffsetDeg,
});
}
// The glyph atlas helpers, re-exported for tests.
export { aircraftIconAtlasLayout as aircraftAtlasLayout, aircraftIconCells };
+1 -3
View File
@@ -10,7 +10,6 @@ import * as geo from '../../../geo/index.js';
import { createFakeEngine } from '../../../globe/testing/fakeEngine.js';
import { aircraftIcon, TRACKED_ICON_PX } from '../../../data/aircraftIcons.js';
import { CYAN, WHITE, nearFarScale, rgbaFromCss } from '../../shared/color.js';
import { missingAircraftRendererMembers } from './contract.js';
import {
aircraftAtlasLayout,
aircraftIconCells,
@@ -39,9 +38,8 @@ async function setup() {
const setsOf = (engine, prefix) =>
engine.movers.list().filter(({ id }) => id.startsWith(prefix));
test('the Navara aircraft renderer has every member of the contract', async () => {
test('the Navara aircraft renderer reports its kind', async () => {
const { engine, renderer } = await setup();
assert.deepEqual(missingAircraftRendererMembers(renderer), []);
assert.equal(renderer.kind, 'navara');
renderer.destroy();
engine.destroy();