Draw local ADS-B through the draw port

The local receiver layer draws its aircraft, the 978 MHz rings and the
selected aircraft's trail head through draw-port sets, updates them on
the frame port each frame, rotates icons from the camera port's screen
axes, and leaves the Cesium allow-list. The trail head now dims behind
terrain instead of vanishing, as the rest of the trail does.
This commit is contained in:
Sameh Khamis committed 2026-11-07 06:04:12 -08:00
1 parent 84e6f13725
commit be5a6f0fe5
5 files changed
+614 -292

No files matched your search

+266 -147
View File
@@ -13,7 +13,31 @@ import {
localAdsbStatus,
} from './index.js';
import { entityRecord, readEntityRecord } from '../../data/entityRecords.js';
import { resolvePickId } from '../../data/pickRegistry.js';
import { toLonLatH } from '../../geo/ellipsoid.js';
import { fakeInput } from '../../input/testDoubles.mjs';
import { hexColor } from '../../render/color.js';
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
const MAGENTA = hexColor('#ff4fd8');
/** The layer's live draw set whose id ends with `suffix`. */
function layerSet(draw, suffix) {
return [...draw.sets.values()].find(
(record) =>
!record.disposed &&
record.spec.id.startsWith('local-adsb:') &&
record.spec.id.endsWith(suffix),
);
}
/** The icon drawn for an aircraft, or undefined. */
const iconOf = (draw, id) => layerSet(draw, ':markers')?.items.get(id);
/** The 978 MHz ring drawn for an aircraft, or undefined. */
const ringOf = (draw, id) => layerSet(draw, ':rings')?.items.get(id);
/** Degrees of latitude where an aircraft's icon now is. */
const latitudeOf = (draw, id) => toLonLatH(iconOf(draw, id).pos).lat;
function fakeReceiver(initial = {}) {
const state = {
@@ -49,7 +73,13 @@ function fakeReceiver(initial = {}) {
}
function fakeServices() {
const calls = { registered: [], selected: [], cleared: [], removed: [] };
const calls = {
registered: [],
selected: [],
cleared: [],
removed: [],
carriers: new Map(),
};
let selected = null;
return {
calls,
@@ -59,6 +89,7 @@ function fakeServices() {
registerEntityContext(entity, metadata) {
entityRecord(entity).contextId = metadata.id;
calls.registered.push(metadata);
calls.carriers.set(metadata.id, entity);
},
selectEntityContext(entity) {
selected = { id: readEntityRecord(entity)?.contextId, entity };
@@ -74,36 +105,29 @@ function fakeServices() {
calls.removed.push({ layerId, retainIds: options?.retainIds });
},
},
picking: { registerPickOwner() {}, unregisterPickOwner() {} },
picking: {
registerPickOwner() {},
unregisterPickOwner() {},
resolvePickId,
},
detection: { markSourcesChanged() {} },
overlays: { refreshReadout() {} },
},
};
}
function fakeViewer() {
const sources = [];
const camera = {
rightWC: new Cesium.Cartesian3(0, 1, 0),
upWC: new Cesium.Cartesian3(0, 0, 1),
};
return {
sources,
viewer: {
camera,
scene: { camera },
entities: {
add: (entity) => entity,
remove() {},
},
dataSources: {
add(source) {
sources.push(source);
},
remove() {},
},
},
};
/**
* A viewer with a fake draw port and a camera port whose screen axes are
* east and north at (0°, 0°); `viewer` adds the Cesium-shaped members the
* 3D models read.
*/
function fakeViewer(viewer = { scene: {} }) {
const camera = fakeCameraPort({
pose: { right: { x: 0, y: 1, z: 0 }, up: { x: 0, y: 0, z: 1 } },
});
const { draw } = bindFakeDraw(viewer, { camera: camera.port });
const input = fakeInput(viewer);
return { draw, viewer, input };
}
function record(overrides = {}) {
@@ -160,9 +184,7 @@ function fakeFeeds(initial = {}) {
/** A viewer whose camera looks down on (0°, 0°) from 50 km, with primitives. */
function modelViewer(primitives) {
const base = fakeViewer();
const camera = {
...base.viewer.camera,
positionWC: new Cesium.Cartesian3(6_378_137 + 50_000, 0, 0),
positionCartographic: new Cesium.Cartographic(0, 0, 50_000),
directionWC: new Cesium.Cartesian3(-1, 0, 0),
@@ -172,28 +194,24 @@ function modelViewer(primitives) {
}),
},
};
return {
...base,
viewer: {
...base.viewer,
return fakeViewer({
camera,
scene: {
camera,
scene: {
camera,
primitives: {
add(collection) {
primitives.push(collection);
return collection;
},
remove() {},
primitives: {
add(collection) {
primitives.push(collection);
return collection;
},
remove() {},
},
},
};
});
}
async function enabledLayer(receiver, clock, feeds = null, options = {}) {
const { services, calls } = fakeServices();
const { sources, viewer } = options.viewer || fakeViewer();
const { draw, viewer } = options.viewer || fakeViewer();
const layer = createLocalAdsbLayer({
receiver,
feeds,
@@ -203,7 +221,7 @@ async function enabledLayer(receiver, clock, feeds = null, options = {}) {
});
layer.init(viewer);
await layer.enable();
return { layer, calls, sources };
return { layer, calls, draw };
}
test('enabling Local ADS-B asks the shared tuner for 1090 MHz; disabling leaves it alone', async (t) => {
@@ -225,47 +243,39 @@ test('enabling Local ADS-B asks the shared tuner for 1090 MHz; disabling leaves
test('local aircraft use their class silhouette and scale in magenta', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const { layer, sources } = await enabledLayer(receiver, clock);
const { layer, draw, calls } = await enabledLayer(receiver, clock);
t.after(() => layer.destroy());
receiver.set({
aircraft: [record(), record({ icao: 'a0b702', category: 'A7' })],
});
await layer.update();
const entity = sources[0].entities.getById('local-adsb:abc123');
assert.ok(entity);
assert.equal(entity.point, undefined);
assert.equal(entity.label, undefined);
assert.equal(entity.billboard.image.getValue(), aircraftIcon('airliner'));
assert.equal(entity.billboard.width.getValue(), 20);
assert.ok(
Cesium.Color.equals(
entity.billboard.color.getValue(),
Cesium.Color.fromCssColorString('#ff4fd8'),
),
);
assert.ok(
Cesium.Cartesian3.equals(
entity.billboard.alignedAxis.getValue(),
Cesium.Cartesian3.ZERO,
),
);
assert.equal(entity.billboard.rotation.getValue(), 0);
assert.equal(readEntityRecord(entity)?.labelModel.title, 'LOCAL1');
assert.equal(typeof readEntityRecord(entity)?.displayPosition, 'function');
const icon = iconOf(draw, 'local-adsb:abc123');
assert.ok(icon);
assert.equal(ringOf(draw, 'local-adsb:abc123'), undefined);
assert.equal(icon.image, aircraftIcon('airliner'));
assert.deepEqual(icon.size, [20, 20]);
assert.deepEqual(icon.color, MAGENTA);
assert.equal(icon.rotationMode, 'screen', 'upright on screen, turned');
assert.equal(icon.rotation, 0);
assert.deepEqual(icon.displayRange, [0, 2_000_000]);
assert.equal(icon.disableDepthTest, Number.POSITIVE_INFINITY);
assert.equal(layerSet(draw, ':markers').spec.horizonCull, true);
const carrier = calls.carriers.get('local-adsb:abc123');
assert.equal(readEntityRecord(carrier)?.labelModel.title, 'LOCAL1');
assert.equal(typeof readEntityRecord(carrier)?.displayPosition, 'function');
const heli = sources[0].entities.getById('local-adsb:a0b702');
assert.equal(heli.billboard.image.getValue(), aircraftIcon('helicopter'));
assert.equal(heli.billboard.scale.getValue(), CLASS_SCALE_2D.helicopter);
assert.ok(
Cesium.Color.equals(
heli.billboard.color.getValue(),
Cesium.Color.fromCssColorString('#ff4fd8'),
),
const heli = () => iconOf(draw, 'local-adsb:a0b702');
assert.equal(heli().image, aircraftIcon('helicopter'));
assert.equal(heli().scale, CLASS_SCALE_2D.helicopter);
assert.deepEqual(
heli().color,
MAGENTA,
'the helicopter keeps the local magenta',
);
assert.equal(
readEntityRecord(heli)?.labelModel.details[1],
readEntityRecord(calls.carriers.get('local-adsb:a0b702'))?.labelModel
.details[1],
'Helicopter · A7',
);
@@ -281,10 +291,7 @@ test('local aircraft use their class silhouette and scale in magenta', async (t)
],
});
await layer.update();
assert.equal(
heli.billboard.scale.getValue(),
CLASS_SCALE_2D.helicopter * 0.8,
);
assert.equal(heli().scale, CLASS_SCALE_2D.helicopter * 0.8);
const [detectable] = layer.getDetectableObjects();
assert.equal(detectable.sourceId, 'a0b702');
@@ -294,12 +301,12 @@ test('local aircraft use their class silhouette and scale in magenta', async (t)
test('the heading slews toward a new track instead of snapping', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const { layer, sources } = await enabledLayer(receiver, clock);
const { layer, draw } = await enabledLayer(receiver, clock);
t.after(() => layer.destroy());
receiver.set({ aircraft: [record()] });
await layer.update();
const entity = sources[0].entities.getById('local-adsb:abc123');
assert.equal(entity.billboard.rotation.getValue(), 0);
const rotation = () => iconOf(draw, 'local-adsb:abc123').rotation;
assert.equal(rotation(), 0);
clock.now = 101_000;
receiver.set({
@@ -313,7 +320,7 @@ test('the heading slews toward a new track instead of snapping', async (t) => {
],
});
await layer.update();
const first = entity.billboard.rotation.getValue();
const first = rotation();
assert.ok(
first > -Cesium.Math.PI_OVER_TWO && first <= 0,
'one frame does not swing the nose 90°',
@@ -323,8 +330,7 @@ test('the heading slews toward a new track instead of snapping', async (t) => {
await layer.update();
}
assert.ok(
Math.abs(entity.billboard.rotation.getValue() + Cesium.Math.PI_OVER_TWO) <
1e-6,
Math.abs(rotation() + Cesium.Math.PI_OVER_TWO) < 1e-6,
'the nose settles on the new track',
);
});
@@ -332,14 +338,9 @@ test('the heading slews toward a new track instead of snapping', async (t) => {
test('markers move in real time between fixes and never jump on a new fix', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const { layer, sources } = await enabledLayer(receiver, clock);
const { layer, draw } = await enabledLayer(receiver, clock);
t.after(() => layer.destroy());
const latitude = () =>
Cesium.Math.toDegrees(
Cesium.Cartographic.fromCartesian(
sources[0].entities.getById('local-adsb:abc123').position.getValue(),
).latitude,
);
const latitude = () => latitudeOf(draw, 'local-adsb:abc123');
// 180 kt due north: 1 s covers 92.6 m, 0.000833° of latitude.
const degPerSecond = (180 * 1852) / 3600 / 111_195;
receiver.set({ aircraft: [record({ lastPositionAt: 99_000 })] });
@@ -376,7 +377,7 @@ test('markers move in real time between fixes and never jump on a new fix', asyn
test('an implausible jump in a feed record is ignored by the display', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const { layer, sources } = await enabledLayer(receiver, clock);
const { layer, draw } = await enabledLayer(receiver, clock);
t.after(() => layer.destroy());
receiver.set({ aircraft: [record({ groundSpeedKt: 120, trackDeg: 0 })] });
await layer.update();
@@ -392,11 +393,7 @@ test('an implausible jump in a feed record is ignored by the display', async (t)
],
});
await layer.update();
const lat = Cesium.Math.toDegrees(
Cesium.Cartographic.fromCartesian(
sources[0].entities.getById('local-adsb:abc123').position.getValue(),
).latitude,
);
const lat = latitudeOf(draw, 'local-adsb:abc123');
assert.ok(lat < 0.001, `stayed on its track (${lat})`);
assert.equal(layer.getStats().rejectedPositions, 1);
});
@@ -447,11 +444,81 @@ test('selecting an aircraft draws a magenta trail of the fixes the receiver hear
assert.equal(trails[0].destroyed, true, 'the trail leaves with the aircraft');
});
test('the trail head runs from the last fix to the marker every frame, dimmed behind the surface', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const listeners = new Map();
const frame = {
on(event, callback) {
listeners.set(event, callback);
return () => listeners.delete(event);
},
};
const viewer = { scene: {} };
const camera = fakeCameraPort({
pose: { right: { x: 0, y: 1, z: 0 }, up: { x: 0, y: 0, z: 1 } },
});
const { draw } = bindFakeDraw(viewer, { camera: camera.port, frame });
const input = fakeInput(viewer);
const { layer } = await enabledLayer(receiver, clock, null, {
viewer: { draw, viewer, input },
services: {
trails: {
createTrail: () => ({ setPositions() {}, destroy() {} }),
},
},
});
t.after(() => layer.destroy());
receiver.set({ aircraft: [record()] });
await layer.update();
assert.equal(layer.selectAircraft('abc123'), true);
const heads = () => [...layerSet(draw, ':trail-head').items.values()];
const [head] = heads();
assert.match(head.id, /^gev-trail:local-adsb-head-\d+$/);
assert.equal(head.mode, '3d');
assert.equal(head.widthPx, 2.5);
assert.deepEqual(head.style, {
kind: 'solid',
color: hexColor('#ff4fd8', 0.9),
});
assert.deepEqual(
head.depthFailColor,
hexColor('#ff4fd8', 0.45),
'dimmed, not hidden, behind the surface',
);
assert.equal(head.positions.length, 2);
assert.deepEqual(
head.positions[1],
iconOf(draw, 'local-adsb:abc123').pos,
'it ends at the marker',
);
// A frame alone moves the marker, its icon and the head's end.
const before = latitudeOf(draw, 'local-adsb:abc123');
clock.now = 101_000;
listeners.get('preRender')();
const after = latitudeOf(draw, 'local-adsb:abc123');
assert.ok(after > before, `the marker flew north (${before} → ${after})`);
assert.ok(
Math.abs(toLonLatH(heads()[0].positions[1]).lat - after) < 1e-9,
'the head follows the marker',
);
// A frame where nothing moved leaves the head alone.
const writes = layerSet(draw, ':trail-head').writes;
listeners.get('preRender')();
assert.equal(layerSet(draw, ':trail-head').writes, writes);
await layer.disable();
assert.equal(listeners.has('preRender'), false, 'frames stop when off');
assert.equal(heads().length, 0, 'the head leaves with the selection');
});
test('adsbdb type, operator and route reach the card for the selected aircraft only', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const queries = [];
const { layer, sources } = await enabledLayer(receiver, clock, null, {
const { layer, calls } = await enabledLayer(receiver, clock, null, {
services: {
enrichment: {
async getEnrichment(query) {
@@ -480,7 +547,7 @@ test('adsbdb type, operator and route reach the card for the selected aircraft o
assert.equal(layer.selectAircraft('a0b702'), true);
await new Promise((resolve) => setTimeout(resolve, 400));
assert.deepEqual([...queries].sort(), ['route:EVC145', 'type:a0b702']);
const entity = sources[0].entities.getById('local-adsb:a0b702');
const entity = calls.carriers.get('local-adsb:a0b702');
assert.deepEqual(readEntityRecord(entity)?.labelModel.details.slice(0, 4), [
'ICAO A0B702 · EVC145',
'Helicopter · A7',
@@ -502,7 +569,7 @@ test('the DISPLAY 3D toggle gives local aircraft magenta class models', async (t
const loads = [];
const display = { models3d: true, models3dMode: 'proximity' };
const primitives = [];
const { layer, sources } = await enabledLayer(receiver, clock, null, {
const { layer, draw } = await enabledLayer(receiver, clock, null, {
services: { display: { getParams: () => display } },
viewer: modelViewer(primitives),
loadModel: async (options) => {
@@ -547,28 +614,24 @@ test('the DISPLAY 3D toggle gives local aircraft magenta class models', async (t
assert.equal(model.colorBlendMode, Cesium.ColorBlendMode.MIX);
assert.equal(model.colorBlendAmount, 0.94);
assert.equal(model.show, true);
const heli = sources[0].entities.getById('local-adsb:a0b702');
assert.equal(
heli.billboard.show.getValue(),
false,
'the model is the visual',
);
const heli = () => iconOf(draw, 'local-adsb:a0b702');
assert.equal(heli().show, false, 'the model is the visual');
const origin = Cesium.Matrix4.getTranslation(
model.modelMatrix,
new Cesium.Cartesian3(),
);
assert.ok(Cesium.Cartesian3.distance(origin, heli.position.getValue()) < 1);
assert.ok(Cesium.Cartesian3.distance(origin, heli().pos) < 1);
display.models3d = false;
await layer.update();
assert.equal(model.destroyed || !primitives[0].contains(model), true);
assert.equal(heli.billboard.show.getValue(), true, 'the billboard is back');
assert.equal(heli().show, true, 'the icon is back');
});
test('markers drop when the position is 60 s old and records when silent 60 s', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const { layer, sources } = await enabledLayer(receiver, clock);
const { layer, draw } = await enabledLayer(receiver, clock);
t.after(() => layer.destroy());
receiver.set({
aircraft: [
@@ -583,7 +646,7 @@ test('markers drop when the position is 60 s old and records when silent 60 s',
],
});
await layer.update();
const entities = () => sources[0].entities.values.map((entity) => entity.id);
const entities = () => [...layerSet(draw, ':markers').items.keys()];
assert.deepEqual(
entities(),
['local-adsb:abc123'],
@@ -731,7 +794,7 @@ test('feed records merge with browser SDR records by ICAO and UAT-only aircraft
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const feeds = fakeFeeds();
const clock = { now: 100_000 };
const { layer, sources } = await enabledLayer(receiver, clock, feeds);
const { layer, draw, calls } = await enabledLayer(receiver, clock, feeds);
t.after(() => layer.destroy());
assert.deepEqual(feeds.calls, ['start'], 'the feeds poll while enabled');
@@ -750,31 +813,37 @@ test('feed records merge with browser SDR records by ICAO and UAT-only aircraft
],
});
await layer.update();
const shared = sources[0].entities.getById('local-adsb:abc123');
const uat = sources[0].entities.getById('local-adsb:a1b2c3');
assert.equal(sources[0].entities.values.length, 2);
assert.equal(
Cesium.Cartographic.fromCartesian(
shared.position.getValue(),
).latitude.toFixed(4),
Cesium.Math.toRadians(1).toFixed(4),
const shared = calls.carriers.get('local-adsb:abc123');
const uat = calls.carriers.get('local-adsb:a1b2c3');
assert.equal(layerSet(draw, ':markers').items.size, 2);
assert.ok(
Math.abs(latitudeOf(draw, 'local-adsb:abc123') - 1) < 0.002,
'the newer feed position wins',
);
assert.equal(shared.point, undefined, 'heard on 1090 too: no UAT ring');
assert.equal(
ringOf(draw, 'local-adsb:abc123'),
undefined,
'heard on 1090 too: no UAT ring',
);
assert.equal(
readEntityRecord(shared)?.labelModel.details.at(-1),
'Heard by your receiver · 1090 MHz + 978 MHz UAT · browser SDR + decoder feed',
);
assert.ok(uat.point, 'a UAT-only aircraft carries the ring');
assert.equal(uat.point.outlineWidth.getValue(), 1.5);
assert.ok(
Cesium.Color.equals(uat.point.color.getValue(), Cesium.Color.TRANSPARENT),
const ring = ringOf(draw, 'local-adsb:a1b2c3');
assert.ok(ring, 'a UAT-only aircraft carries the ring');
assert.equal(ring.outlineWidth, 1.5);
assert.deepEqual(ring.color, [0, 0, 0, 0]);
assert.deepEqual(ring.outlineColor, hexColor('#ffb3ef'));
assert.deepEqual(
ring.displayRange,
[0, 2_000_000],
'shown within 2,000 km, as its aircraft is',
);
assert.ok(
Cesium.Color.equals(
uat.billboard.color.getValue(),
Cesium.Color.fromCssColorString('#ff4fd8'),
),
assert.deepEqual(ring.pos, iconOf(draw, 'local-adsb:a1b2c3').pos);
assert.equal(layerSet(draw, ':rings').spec.horizonCull, true);
assert.deepEqual(
iconOf(draw, 'local-adsb:a1b2c3').color,
MAGENTA,
'same magenta marker family',
);
assert.equal(
@@ -786,8 +855,65 @@ test('feed records merge with browser SDR records by ICAO and UAT-only aircraft
assert.equal(stats.loadingLabel, '1 feed live · 2 heard');
assert.equal(stats.count, 2);
// Heard on 1090 as well later: the ring goes.
feeds.set({
records: [
record({
icao: 'a1b2c3',
callsign: 'N978UA',
band: '1090',
source: 'feed',
}),
],
});
await layer.update();
assert.equal(ringOf(draw, 'local-adsb:a1b2c3'), undefined);
await layer.disable();
assert.deepEqual(feeds.calls, ['start', 'stop']);
assert.equal(layerSet(draw, ':markers').show, false, 'hidden with the layer');
});
test('the layer draws into sets of its own, shown while it is enabled and let go when destroyed', async (t) => {
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const feeds = fakeFeeds();
const clock = { now: 100_000 };
const first = fakeViewer();
const { layer, draw } = await enabledLayer(receiver, clock, feeds, {
viewer: first,
});
const other = await enabledLayer(fakeReceiver(), clock);
t.after(() => other.layer.destroy());
const ids = (port) =>
[...port.sets.values()]
.filter((record) => !record.disposed)
.map((record) => record.spec.id);
const mine = ids(draw);
assert.equal(mine.length, 3, 'markers, rings and the trail head');
assert.ok(
ids(other.draw).every((id) => !mine.includes(id)),
'a second layer has ids of its own',
);
for (const id of mine) assert.equal(draw.set(id).show, true, id);
feeds.set({
configured: true,
records: [record({ icao: 'a1b2c3', band: '978', source: 'feed' })],
});
await layer.update();
assert.ok(ringOf(draw, 'local-adsb:a1b2c3'));
// Silent long enough to expire: its ring goes with it.
clock.now = 200_000;
await layer.update();
assert.equal(iconOf(draw, 'local-adsb:a1b2c3'), undefined);
assert.equal(ringOf(draw, 'local-adsb:a1b2c3'), undefined);
await layer.disable();
for (const id of mine) assert.equal(draw.set(id).show, false, id);
await layer.enable();
for (const id of mine) assert.equal(draw.set(id).show, true, id);
layer.destroy();
assert.deepEqual(ids(draw), [], 'every set disposed');
});
test('row status reflects decoder feeds and the browser SDR together', () => {
@@ -1053,11 +1179,14 @@ test('the last aircraft expiring removes its 3D model and cancels a pending load
assert.equal(late.destroyed, true);
});
/** A pick on a draw-port icon of the layer's, as the renderer reports it. */
function iconPick(id) {
return { primitive: {}, id: { set: 'local-adsb:1:markers', id } };
}
/** A viewer with a canvas and scripted picks, plus the layer's click action. */
function clickHarness() {
const base = fakeViewer();
const scene = {
...base.viewer.scene,
canvas: {},
pickResult: null,
drillResult: [],
@@ -1068,13 +1197,12 @@ function clickHarness() {
return scene.drillResult;
},
};
const viewer = { ...base.viewer, scene };
const input = fakeInput(viewer);
const base = fakeViewer({ scene });
return {
scene,
viewer: { ...base, viewer },
viewer: base,
click() {
input.click(new Cesium.Cartesian2(10, 10));
base.input.click(new Cesium.Cartesian2(10, 10));
},
};
}
@@ -1089,9 +1217,7 @@ test('clicking the selected aircraft keeps it selected and republishes its card'
t.after(() => layer.destroy());
receiver.set({ aircraft: [record()] });
await layer.update();
const entity =
harness.viewer.sources[0].entities.getById('local-adsb:abc123');
harness.scene.pickResult = { id: entity, primitive: {} };
harness.scene.pickResult = iconPick('local-adsb:abc123');
harness.click();
assert.deepEqual(calls.selected, ['local-adsb:abc123']);
// Its card may have been displaced (another readout, a camera move): a
@@ -1106,7 +1232,6 @@ test('a click on a local aircraft under an unowned or trail pick still selects i
const clock = { now: 100_000 };
const harness = clickHarness();
const owners = new Map();
const { resolvePickId } = await import('../../data/pickRegistry.js');
const { layer, calls } = await enabledLayer(receiver, clock, null, {
viewer: harness.viewer,
services: {
@@ -1129,7 +1254,7 @@ test('a click on a local aircraft under an unowned or trail pick still selects i
});
await layer.update();
const [first, second] = ['abc123', 'def456'].map((icao) =>
harness.viewer.sources[0].entities.getById(`local-adsb:${icao}`),
iconPick(`local-adsb:${icao}`),
);
// A photoreal tile (no pick id) drawn over the 3D model at this pixel.
harness.scene.pickResult = { primitive: { tileset: true } };
@@ -1142,19 +1267,13 @@ test('a click on a local aircraft under an unowned or trail pick still selects i
// The selected aircraft's trail crosses another local aircraft's marker.
harness.scene.pickResult = { id: { id: 'gev-trail:local-adsb-head-1' } };
harness.scene.drillResult = [
harness.scene.pickResult,
{ id: second, primitive: {} },
];
harness.scene.drillResult = [harness.scene.pickResult, second];
harness.click();
assert.deepEqual(calls.selected, ['local-adsb:abc123', 'local-adsb:def456']);
// Another layer's own contact on top is that layer's click.
harness.scene.pickResult = { id: 'abc123', primitive: {} };
harness.scene.drillResult = [
harness.scene.pickResult,
{ id: first, primitive: {} },
];
harness.scene.drillResult = [harness.scene.pickResult, first];
harness.click();
assert.equal(calls.selected.length, 2, 'the Flights contact is not taken');
});