Draw Local ADS-B aircraft models through the draw port

Local ADS-B's 3D aircraft are now one models set of the renderer's draw
port, re-posed in place each frame, instead of Cesium models of their own.
Ground placement samples heights through the query port and sees through
the layer's sets by id; clicks read the dispatcher's draw-set hit and the
query port's drill. A class change keeps the drawn model, at its own belly
offset, until the new asset is ready; a scale-only change applies at once.
The models file leaves the Cesium allow-list.

Cesium model sets retry a failed load when its item is next updated after
a short wait, and parse an item's tint only when it changes.
This commit is contained in:
Sameh Khamis committed 2026-11-07 15:43:33 -08:00
1 parent 20155ff3fa
commit 20fdfd492e
10 files changed
+502 -375

No files matched your search

+16 -7
View File
@@ -48,6 +48,7 @@
import * as Cesium from 'cesium';
import { heightsFor } from '../render/cesium/heights.js';
import { heightsOf } from '../queries/heights.js';
// The application operations entry reaches the annotation resolver and
// locations.js, whose flights and heights go through the camera and query
// ports and which cannot load the Cesium adapter themselves; this listed
@@ -169,7 +170,8 @@ function _tilesReady(viewer) {
* Create a per-layer ground-snap cache.
* @returns {{
* heightFor: (viewer: Cesium.Viewer, icao: string, pos: Cesium.Cartesian3,
* getExclusions?: () => Array<unknown>) => number|null,
* getExclusions?: (() => Array<unknown>)|{sets: string[]})
* => number|null,
* forget: (icao: string) => void,
* clear: () => void,
* }}
@@ -287,7 +289,10 @@ export function createGroundSnap({ groundFloor }) {
* @param {(() => Array<unknown>)|undefined} getExclusions - Lazily builds the
* scene.sampleHeight objectsToExclude list (own billboards/models/entities —
* the vertical pick ray at a plane's OWN lat/lon lands on its icon/model
* otherwise). Only invoked when a sample actually fires.
* otherwise). Only invoked when a sample actually fires. `{sets}` (draw
* set ids) instead samples through the renderer's query port
* (`heightsOf`), which sees through every draw set not drawn as ground
* and these: for a caller whose markers and models are on the draw port.
* @returns {number|null}
*/
function heightFor(viewer, icao, pos, getExclusions) {
@@ -359,11 +364,15 @@ export function createGroundSnap({ groundFloor }) {
Cesium.Ellipsoid.WGS84,
scratchCarto,
);
const sampled = carto
? heightsFor(viewer.scene).now(carto, {
exclude: getExclusions ? getExclusions() : undefined,
})
: null;
// Draw-set exclusions ask the renderer's query port, which sees through
// every draw set not drawn as ground (the caller's markers and models).
const sampled = !carto
? null
: Array.isArray(getExclusions?.sets)
? heightsOf(viewer).now(carto, { exclude: getExclusions.sets })
: heightsFor(viewer.scene).now(carto, {
exclude: getExclusions ? getExclusions() : undefined,
});
// Same sanity floor as cctv.js's sampleGroundHeight: a hit far below the
// ellipsoid is pick garbage, not ground.
if (!Number.isFinite(sampled) || sampled < -150) return miss();
+24
View File
@@ -2,6 +2,7 @@ import assert from 'node:assert/strict';
import test from 'node:test';
import * as Cesium from 'cesium';
import { createGroundSnap } from './groundSnap.js';
import { bindRenderer } from '../render/rendererOf.js';
const groundFloor = {
cachedMeshFloor: () => null,
@@ -60,3 +61,26 @@ test('a retry backoff stamped before the clock stepped back does not wait for it
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), 1650);
assert.equal(viewer.calls.samples, 1);
});
test('draw-set exclusions sample through the renderer’s query port', () => {
const viewer = makeViewer();
const asked = [];
bindRenderer(viewer, {
query: {
sampleHeightNow(point, options) {
asked.push({ point, options });
return 1655;
},
},
});
const snap = createGroundSnap({ groundFloor });
assert.equal(
snap.heightFor(viewer, 'a00001', atDenverAirport, {
sets: ['mine:models'],
}),
1655,
);
assert.equal(viewer.calls.samples, 0, 'not the scene’s own sample');
assert.deepEqual(asked[0].options, { exclude: ['mine:models'] });
assert.ok(Math.abs(asked[0].point.lon + 104.6737) < 1e-6);
});