diff --git a/scripts/package-boundaries.json b/scripts/package-boundaries.json
index 95f1b2f6c..6c86f5b60 100644
--- a/scripts/package-boundaries.json
+++ b/scripts/package-boundaries.json
@@ -1493,6 +1493,7 @@
"src/layers/flights/rendering.js",
"src/layers/flights/icons.js",
"src/data/aircraftIconLayer.js",
+ "src/render/motion/iconBook.js",
"src/data/aircraftModelLayer.js",
"src/data/aircraftMotionRegime.js",
"src/data/iconSetPrimitive.js",
@@ -1598,6 +1599,7 @@
"src/layers/military/rendering.js",
"src/layers/military/icons.js",
"src/data/aircraftIconLayer.js",
+ "src/render/motion/iconBook.js",
"src/data/aircraftModelLayer.js",
"src/data/aircraftMotionRegime.js",
"src/data/iconSetPrimitive.js",
diff --git a/src/data/aircraftEmergencyAnalyst.test.mjs b/src/data/aircraftEmergencyAnalyst.test.mjs
index 59516787a..8530fd47b 100644
--- a/src/data/aircraftEmergencyAnalyst.test.mjs
+++ b/src/data/aircraftEmergencyAnalyst.test.mjs
@@ -4,10 +4,12 @@ import { createRendering as civilRendering } from '../layers/flights/rendering.j
import { createRendering as militaryRendering } from '../layers/military/rendering.js';
import { createMilitarySnapshotRenderer } from '../layers/military/snapshotRenderer.js';
import { createIcons as createMilitaryIcons } from '../layers/military/icons.js';
-import { createIconSet } from './iconSet.js';
+import { createContactIcons } from './aircraftIconLayer.js';
import {
aircraftMotionRegime,
createMotionRegime,
+ fixEpochMs,
+ julianAt,
} from './aircraftMotionRegime.js';
import { aircraftEmergency } from './aircraftEmergency.js';
// Source-to-voice provenance, status retention/clearing, contact-time contracts,
@@ -471,7 +473,7 @@ test('tint priorities cover normal, priority, emergency, tracking and Cockpit do
test('GERMAN: an existing untracked military icon repaints each poll without losing its fade', () => {
const { flightState, rendering } = renderHarness(militaryRendering);
Object.assign(flightState, {
- _icons: createIconSet(),
+ _icons: createContactIcons(),
_models: new Map(),
_positionHistory: new Map(),
_displayCourse: new Map(),
@@ -500,6 +502,8 @@ test('GERMAN: an existing untracked military icon repaints each poll without los
{ speed: 'speedMps', track: 'track' },
createMotionRegime(),
),
+ _displayTimeAt: julianAt,
+ _fixEpochMs: fixEpochMs,
},
};
const icons = createMilitaryIcons({
@@ -507,11 +511,13 @@ test('GERMAN: an existing untracked military icon repaints each poll without los
services: { focus: { focusPassIsNeeded: () => false } },
parts,
});
- const row = flightState._icons.add('abc123', {
- layer: 'military',
- id: 'abc123',
+ const row = 'abc123';
+ flightState._icons.put({
+ id: row,
+ pos: { x: 0, y: 0, z: 0 },
+ meta: { layer: 'military', id: row },
});
- // The focus fade the fleet tick composes lives in its own column.
+ // The focus fade the fleet tick composes lives in its own field.
flightState._icons.setFocus(row, 0.65);
const apply = createMilitarySnapshotRenderer({
flightState,
@@ -546,7 +552,7 @@ test('GERMAN: an existing untracked military icon repaints each poll without los
{ observedAtMs: NOW_MS },
);
apply(snapshot, {});
- assert.equal(flightState._icons.color(row).green < 0.5, red);
+ assert.equal(flightState._icons.item(row).color[1] < 0.5, red);
assert.ok(Math.abs(flightState._icons.focus(row) - 0.65) < 1e-6);
}
});
diff --git a/src/data/aircraftIconLayer.js b/src/data/aircraftIconLayer.js
index b098d783f..571b4ff4b 100644
--- a/src/data/aircraftIconLayer.js
+++ b/src/data/aircraftIconLayer.js
@@ -1,60 +1,224 @@
-import * as Cesium from 'cesium';
+import { COURSE_HOLD_SPEED_MPS, courseSlewCapDps } from './motionModel.js';
+import { norm180, distance, clone, copyInto } from '../geo/vector.js';
+import { horizonFrom, liftedForHorizon } from '../geo/horizon.js';
+import { createIconBook } from '../render/motion/iconBook.js';
+import { motionCourse } from '../render/motion/iconMotion.js';
import {
- COURSE_HOLD_SPEED_MPS,
- courseSlewCapDps,
- norm180,
-} from './motionModel.js';
-import {
- createIconSet,
- ICON_CULL_LIFT,
- ICON_CULL_LIFT_BELOW_M,
- ICON_RECEDES,
- ICON_ROTATES,
-} from './iconSet.js';
-import {
- segmentCourse,
- writeArcSegment,
- writeCourseGlide,
- writeHoldSegment,
- writeLerpSegment,
-} from './iconSegment.js';
-import { IconSetPrimitive } from './iconSetPrimitive.js';
-import { iconAtlas } from './iconAtlas.js';
+ drawOf,
+ findCamera,
+ findQuery,
+ rendererOf,
+} from '../render/rendererOf.js';
+import { nearImageSwitchPx } from './iconAtlas.js';
import {
aircraftIcon,
FLEET_ICON_PX,
TRACKED_ICON_PX,
} from './aircraftIcons.js';
import { cockpitContactDotImage } from './cockpitContactDot.js';
-import { horizonOccluder } from './iconOrientation.js';
/** Raster size of the cockpit contact pip (cockpitContactDot.js draws 16 px). */
const COCKPIT_DOT_PX = 16;
/** Fleet glyphs keep the established close-range 3× scale. */
-const NORMAL_SCALE_BY_DISTANCE = new Cesium.NearFarScalar(
- 1000,
- 3.0,
- 8000000,
- 0.5,
-);
-const COCKPIT_SCALE_BY_DISTANCE = new Cesium.NearFarScalar(
- 1000,
- 1.15,
- 8000000,
- 0.65,
-);
+const NORMAL_SCALE_BY_DISTANCE = Object.freeze({
+ near: 1000,
+ nearValue: 3.0,
+ far: 8000000,
+ farValue: 0.5,
+});
+const COCKPIT_SCALE_BY_DISTANCE = Object.freeze({
+ near: 1000,
+ nearValue: 1.15,
+ far: 8000000,
+ farValue: 0.65,
+});
+
+let cockpitDot = null;
+/**
+ * The cockpit pip as an SVG of its own 16 px size around its PNG, so the
+ * draw port rasterises it at 16 px (as the icon set did) rather than at its
+ * few-pixel drawn size.
+ */
+function cockpitDotImage() {
+ if (cockpitDot) return cockpitDot;
+ const png = cockpitContactDotImage();
+ const px = COCKPIT_DOT_PX;
+ cockpitDot = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(
+ ``,
+ )}`;
+ return cockpitDot;
+}
+
+/** A colour as the draw contract's `[r, g, b, a]`, from `{red, green, blue, alpha}`. */
+function rgba(color) {
+ if (!color || typeof color === 'string' || Array.isArray(color)) return color;
+ return [color.red, color.green, color.blue, color.alpha ?? 1];
+}
+
+/** Whether two plain values are the same, nested ones included. */
+function same(a, b) {
+ if (a === b) return true;
+ if (!a || !b || typeof a !== 'object' || typeof b !== 'object') return false;
+ const keys = Object.keys(a);
+ if (keys.length !== Object.keys(b).length) return false;
+ for (const key of keys) if (!same(a[key], b[key])) return false;
+ return true;
+}
/**
- * An aircraft layer's contacts as one icon set: each row's motion segment
- * mirrors the layer's dead reckoning for the delayed display time, so the GPU
- * moves every untracked contact between polls with no per-frame CPU pass.
+ * An aircraft layer's contact icons as it last drew them, over one icon
+ * draw set: each contact's icon item by its id, until when its motion holds
+ * (`render/motion/iconBook`), read back where it is drawn now. Writes go to
+ * the draw set together once the current task ends, so restyling and
+ * replanning a contact in one pass writes its item once.
+ * @param {import('../render/contract/draw').DrawSet