Draw military flights from the shared GPU icon set

The flights icon planning and presentation move into
`createAircraftIcons` (src/data/aircraftIconLayer.js), and the motion
regime both layers dead-reckon from into src/data/aircraftMotionRegime.js.
Flights keeps only its grounded-floor pass on top.

Military now draws every contact as a row of that icon set, like
flights: the billboards, the cull positions and the rotation-pass
signature go. Tracking hides the row and untracking re-plans it from
the tracked course. Queries read the drawn row position and judge the
horizon as the shader does. Snapshots that arrive before init or after
destroy are ignored, and per-contact lookups find no contact then
instead of throwing.

With about 120 live military contacts, preRender p95 drops from
0.7-0.8 ms to 0.2 ms on the same views. Render time and frame gaps are
unchanged or slightly lower.
This commit is contained in:
Sameh Khamis committed 2026-11-03 20:30:43 -08:00
1 parent fa3a3a3bca
commit b027bde6ad
33 files changed
+1256 -1376

No files matched your search

+20 -15
View File
@@ -87,7 +87,7 @@ test('military state owns separate contact maps, motion scratch and ground sampl
for (const key of [
'records',
'feed',
'_billboards',
'_displayCourse',
'_positionHistory',
'_groundSnap',
'_scratchCarto',
@@ -141,7 +141,7 @@ test('a normalized source can retain its stale reason without changing standalon
test('a newly seen military contact appears at its delayed position, not ahead of it', async () => {
// The military fleet renders RENDER_DELAY_SEC behind real time, so a fresh
// contact's first displayed position is its fix projected back to that
// delayed time. Creating the billboard at the raw fix drew it ahead until
// delayed time. Creating the icon at the raw fix drew it ahead until
// the next fleet tick jumped it back.
const Cesium = await import('cesium');
const { RENDER_DELAY_SEC } = await import('./policy.js');
@@ -177,7 +177,6 @@ test('a newly seen military contact appears at its delayed position, not ahead o
},
},
});
const added = [];
layer.testing._setTrackedMilitaryRefreshStateForTest({
icao24: 'seed00',
entity: null,
@@ -186,22 +185,14 @@ test('a newly seen military contact appears at its delayed position, not ahead o
show: false,
position: Cesium.Cartesian3.fromDegrees(0, 0, 0),
},
billboardCollection: {
show: false,
add(options) {
const billboard = { ...options };
added.push(billboard);
return billboard;
},
remove() {},
},
billboardCollection: { show: false },
viewer: { camera: { positionCartographic: null }, scene: {} },
tracked: false,
});
await layer.update({ camera: { positionCartographic: null }, scene: {} });
const billboard = added.find((entry) => entry.id === 'ae0001');
assert.ok(billboard, 'the new contact gets a billboard');
const shown = Cesium.Cartographic.fromCartesian(billboard.position);
const icon = layer.testing._iconForTest('ae0001');
assert.ok(icon, 'the new contact gets an icon');
const shown = Cesium.Cartographic.fromCartesian(icon.position);
const behindM = Cesium.Cartesian3.distance(
Cesium.Cartesian3.fromRadians(shown.longitude, shown.latitude, 0),
Cesium.Cartesian3.fromDegrees(fixLon, fixLat, 0),
@@ -289,3 +280,17 @@ test('voice context reads a track that rounds to north as 0°, not 360°', () =>
'0°',
);
});
test('a military layer without an icon set declines contact refreshes', () => {
// Before init and after destroy there are no icon rows: a TR-3B refresh
// reports that the layer owns no such contact instead of throwing.
const layer = createMilitaryFlightLayer({
source: { label: 'Fixture aircraft', getSnapshot() {} },
services: {
...services(),
aircraftPresentation: { isTr3b: () => true, tr3bConvertedIds: () => [] },
},
});
assert.equal(layer.refreshTr3b('abc123'), false);
assert.equal(layer.trackById('abc123'), false);
});