Draw contact trails through the draw port

The shared trail renderer draws a trail's history and its live head as
lines in a draw-port set, geodesic for the history and straight for the
head, each dimmed behind the surface in its depth-fail colour, and
leaves the Cesium allow-list. The flights and military trail heads are
drawn through the trail each frame from the frame port instead of
entity callbacks, and the local ADS-B head uses the same head line. A
head given while its trail is hidden waits until the trail shows.

Geodesic lines are cut a step a degree of arc, with at least 64 steps
over the line, so a long trail of short legs costs its positions rather
than 64 vertices a leg.
This commit is contained in:
Sameh Khamis committed 2026-11-07 07:39:58 -08:00
1 parent 6bbe35f232
commit 8cefc8cc4a
12 files changed
+631 -350

No files matched your search

+93
View File
@@ -161,3 +161,96 @@ test('a flight layer without an icon set declines contact refreshes', () => {
assert.equal(layer.refreshTr3b('abc123'), false);
assert.equal(layer.trackById('abc123'), false);
});
test('the tracked trail head is drawn each frame while tracked and stops with the trail', async () => {
const Cesium = await import('cesium');
const { bindFakeDraw } = await import('../../testSupport/fakeDrawPort.mjs');
const trails = await import('../../data/trailRenderer.js');
const listeners = new Set();
const frame = {
on(phase, cb) {
const entry = { phase, cb };
listeners.add(entry);
return () => listeners.delete(entry);
},
};
const tick = () => {
for (const { phase, cb } of [...listeners]) if (phase === 'preRender') cb();
};
const viewer = { isDestroyed: () => false };
const { draw, unbind } = bindFakeDraw(viewer, { frame });
const at = (lon) => Cesium.Cartesian3.fromDegrees(lon, 0, 1000);
const old = Cesium.JulianDate.addSeconds(
Cesium.JulianDate.now(),
-600,
new Cesium.JulianDate(),
);
let headLon = 0.03;
const flightState = {
_viewer: viewer,
_trackedIcao: 'abc123',
_trail: null,
_trailPositions: [],
_trailBackfillToken: 0,
_trailHeadOff: null,
_cockpitContactMode: false,
_positionHistory: new Map([
[
'abc123',
[0, 0.01, 0.02].map((lon) => ({ time: old, position: at(lon) })),
],
]),
_scratchWarmupTime: new Cesium.JulianDate(),
_scratchTrailHead: new Cesium.Cartesian3(),
feed: { _source: {} },
records: { data: new Map() },
lifetime: new AbortController(),
};
const supplied = services();
supplied.trails = trails;
const tracking = createTracking({
flightState,
services: supplied,
parts: {
motion: {
_isTrackWarmingUp: () => false,
_trackedTrailCached: () => at(headLon),
_trackedDisplayPosition: () => null,
_trackedModelCenterWorld: () => null,
_trackedModelEnvelopeM: () => 0,
},
},
layer: {},
});
try {
tracking._startTrail('abc123');
assert.equal(listeners.size, 1, 'one frame listener');
tick();
const set = draw.find('trail:');
const head = () => set.items.get(`${[...set.items.keys()][0]}:head`);
assert.ok(
Cesium.Cartesian3.equals(
new Cesium.Cartesian3(...Object.values(head().positions[1])),
at(0.03),
),
);
headLon = 0.04;
tick();
assert.ok(
Cesium.Cartesian3.equalsEpsilon(
new Cesium.Cartesian3(...Object.values(head().positions[1])),
at(0.04),
1e-6,
),
);
// Tracked again: still one listener.
tracking._clearTrail();
assert.equal(listeners.size, 0, 'cleared with the trail');
tracking._startTrail('abc123');
assert.equal(listeners.size, 1);
tracking._destroyTrail();
assert.equal(listeners.size, 0, 'gone with the trail');
} finally {
unbind();
}
});
+4 -8
View File
@@ -189,15 +189,11 @@ export function createFlightState({ source, services }) {
flightState._trail = null;
/** @type {Cesium.Entity|null} Cheap 2-point head segment bridging the last fix to the LIVE
* dead-reckoned icon, updated per frame via a CallbackProperty — so the trail head stays
* glued to the 12 Hz icon without rebuilding the 400-point trail primitive every frame. */
/** @type {(() => void)|null} Stops the per-frame live head (last body point → live
* icon), drawn as the trail's head line so the head stays glued to the 12 Hz icon
* without rebuilding the 400-point trail body every frame. */
flightState._trailHeadEntity = null;
/** @type {number} Uniquifier for head-segment entity ids (Cesium requires unique ids). */
flightState._trailHeadSeq = 0;
flightState._trailHeadOff = null;
/** @type {Cesium.Cartesian3[]} Chronological tracked-aircraft fixes (oldest first) */
+59 -73
View File
@@ -1,4 +1,5 @@
import { cameraOf } from '../../render/cesium/camera.js';
import { findFrame } from '../../render/rendererOf.js';
import {
entityFollowTarget,
onFollowChanged,
@@ -224,7 +225,6 @@ export function createTracking({
// synchronously blocked Chrome's renderer into Page Unresponsive.
if (flightState._modelCollection) flightState._modelCollection.show = true;
flightState._trail?.setVisible(!next);
if (flightState._trailHeadEntity) flightState._trailHeadEntity.show = !next;
for (const icao24 of flightState._icons?.ids() ?? [])
parts.icons._applyIconPresentation(icao24);
flightState._lastFleetTickMs = 0;
@@ -382,7 +382,7 @@ export function createTracking({
// The trail BODY is the accumulated fixes EXCLUDING the newest raw one — that newest
// fix is at ~now, ~one poll interval AHEAD of the delayed icon (rendered at
// now − RENDER_DELAY_SEC), so drawing it would push the trail in front of the plane.
// The cheap per-frame _trailHeadEntity segment bridges the last body point to the
// The cheap per-frame trail head segment bridges the last body point to the
// delayed dead-reckoned head, so the body primitive only rebuilds on a real fix
// (poll cadence), never at motion cadence.
if (!flightState._trail) return;
@@ -393,6 +393,54 @@ export function createTracking({
);
}
/**
* The live head: the last DISPLAYED body point to the delayed head, or no
* positions while there is none.
* @returns {Cesium.Cartesian3[]}
*/
function _trailHeadPositions() {
// Need ≥2 accumulated points: the body draws all-but-newest, so the head must
// start at the last DISPLAYED body point (index n−2). With a single fix that
// point would be the sole raw fix — which is ~now, AHEAD of the delayed icon —
// so the segment would draw IN FRONT of the plane. Likewise during warm-up the
// icon predates all real history, so there is no valid body point behind it.
if (
!flightState._trackedIcao ||
flightState._trailPositions.length < 2 ||
parts.motion._isTrackWarmingUp()
)
return [];
const head =
parts.motion._trackedTrailCached() ||
parts.motion._trackedDisplayPosition(flightState._trackedIcao);
if (!head) return [];
// body[n−2] (last displayed body point) → delayed head: runs FORWARD, never a
// backward/reversing segment.
const start =
flightState._trailPositions[flightState._trailPositions.length - 2];
// On a contact that has not moved this segment runs from inside the
// model out to its own anchor — a line through the fuselage. The END
// never gives, so a moving trail still terminates on the tail; the
// START is what slides, from nothing on a parked contact out to the
// whole segment once it has cleared its own envelope.
// See trailHeadStart. Read `head` in place and clone only on the draw
// path — a suppressed parked contact runs this every frame.
const from = trailHeadStart(
start,
head,
parts.motion._trackedModelCenterWorld(),
parts.motion._trackedModelEnvelopeM(),
flightState._scratchTrailHead,
);
if (!from) return [];
return [from, Cesium.Cartesian3.clone(head)];
}
/** Each drawn frame, before it draws: the live head where the aircraft is now. */
function _drawTrailHead() {
flightState._trail?.setHead(_trailHeadPositions());
}
/**
* Start the trail for a newly tracked aircraft: seed it with the short
* dead-reckoning history (chronological), render immediately, then
@@ -425,65 +473,13 @@ export function createTracking({
});
}
flightState._trail?.setVisible(!flightState._cockpitContactMode);
// Live head segment: last fix → current dead-reckoned icon, updated every frame via
// a CallbackProperty (Cesium updates entity-polyline positions cheaply, unlike the
// trail primitive which fully rebuilds on setPositions). Keeps the head glued to the
// 12 Hz icon instead of lagging ~1 s behind it.
if (!flightState._trailHeadEntity && flightState._viewer) {
flightState._trailHeadEntity = flightState._viewer.entities.add({
// 'gev-trail' namespace (round 6): claimed by trailRenderer's pick
// owner so a click on the head segment never reads as empty space.
id: `gev-trail:fl-head-${++flightState._trailHeadSeq}`,
show: !flightState._cockpitContactMode,
polyline: {
positions: new Cesium.CallbackProperty(() => {
// Need ≥2 accumulated points: the body draws all-but-newest, so the head must
// start at the last DISPLAYED body point (index n−2). With a single fix that
// point would be the sole raw fix — which is ~now, AHEAD of the delayed icon —
// so the segment would draw IN FRONT of the plane. Likewise during warm-up the
// icon predates all real history, so there is no valid body point behind it.
if (
!flightState._trackedIcao ||
flightState._trailPositions.length < 2 ||
parts.motion._isTrackWarmingUp()
)
return [];
const head =
parts.motion._trackedTrailCached() ||
parts.motion._trackedDisplayPosition(flightState._trackedIcao);
if (!head) return [];
// body[n−2] (last displayed body point) → delayed head: runs FORWARD, never a
// backward/reversing segment.
const start =
flightState._trailPositions[
flightState._trailPositions.length - 2
];
// On a contact that has not moved this segment runs from inside the
// model out to its own anchor — a line through the fuselage. The END
// never gives, so a moving trail still terminates on the tail; the
// START is what slides, from nothing on a parked contact out to the
// whole segment once it has cleared its own envelope.
// See trailHeadStart. Read `head` in place and clone only on the draw
// path — a suppressed parked contact runs this every frame.
const from = trailHeadStart(
start,
head,
parts.motion._trackedModelCenterWorld(),
parts.motion._trackedModelEnvelopeM(),
flightState._scratchTrailHead,
);
if (!from) return [];
return [from, Cesium.Cartesian3.clone(head)];
}, false),
width: 2.5,
material: Cesium.Color.fromCssColorString(TRAIL_COLOR).withAlpha(0.9),
// Round 4: the head must never vanish into the mesh either (dimmed
// when occluded so depth still reads).
depthFailMaterial:
Cesium.Color.fromCssColorString(TRAIL_COLOR).withAlpha(0.45),
arcType: Cesium.ArcType.GEODESIC, // round 8: consistent with the trail body (no chords)
},
});
// Live head segment: last displayed body point → current dead-reckoned icon, drawn
// again each frame before it draws, so it stays glued to the 12 Hz icon instead of
// lagging ~1 s behind it. Only the head line is rebuilt; the body rebuilds on a real
// fix (poll cadence). Dimmed where occluded (round 4), geodesic as the body (round 8).
if (!flightState._trailHeadOff && flightState._viewer) {
flightState._trailHeadOff =
findFrame(flightState._viewer)?.on('preRender', _drawTrailHead) ?? null;
}
_refreshTrailDisplay();
@@ -600,18 +596,8 @@ export function createTracking({
flightState._trailBackfillToken += 1;
flightState._trailPositions = [];
if (flightState._trail) flightState._trail.clear();
if (
flightState._trailHeadEntity &&
flightState._viewer &&
!flightState._viewer.isDestroyed()
) {
try {
flightState._viewer.entities.remove(flightState._trailHeadEntity);
} catch {
/* already gone */
}
}
flightState._trailHeadEntity = null;
flightState._trailHeadOff?.();
flightState._trailHeadOff = null;
}
/**
+12 -27
View File
@@ -138,9 +138,10 @@ export function createLocalAdsbLayer({
let viewer = null;
/**
* The layer's draw sets on its viewer's renderer (`drawOf`), made at
* `init`: the markers, the 978 MHz rings and the selected aircraft's live
* trail head. Shown while the layer is enabled.
* @type {{markers: object, rings: object, head: object}|null}
* `init`: the markers and the 978 MHz rings. Shown while the layer is
* enabled. The selected aircraft's trail and its live head draw through
* the shared trail renderer.
* @type {{markers: object, rings: object}|null}
*/
let sets = null;
let enabled = false;
@@ -153,7 +154,6 @@ export function createLocalAdsbLayer({
let renderHeld = false;
let selectedId = null;
let selectedTrail = null;
let trailHeadSeq = 0;
let models = null;
let geoidReady = false;
let rejectedFixes = 0;
@@ -406,7 +406,6 @@ export function createLocalAdsbLayer({
function releaseTrail() {
if (!selectedTrail) return;
selectedTrail.trail?.destroy();
sets?.head.clear();
selectedTrail = null;
}
@@ -420,35 +419,24 @@ export function createLocalAdsbLayer({
* costs nothing a frame.
*/
function drawTrailHead() {
if (!sets || !selectedTrail?.headId) return;
if (!selectedTrail?.trail?.setHead) return;
const current = markers.get(selectedTrail.id);
const from = selectedTrail.lastFix;
const positions =
current?.position && from ? [from, { ...current.position }] : [];
const key = positions.map(({ x, y, z }) => `${x},${y},${z}`).join(';');
if (key === selectedTrail.drawnKey) return;
const at = now();
if (
positions.length &&
from === selectedTrail.drawnFrom &&
at - selectedTrail.drawnAt < HEAD_REDRAW_MS
)
return;
selectedTrail.drawnKey = key;
selectedTrail.drawnFrom = from;
selectedTrail.drawnAt = at;
sets.head.upsert([
{
// 'gev-trail' namespace: claimed by the trail pick owner so a click
// on the head segment never reads as empty space.
id: selectedTrail.headId,
positions,
widthPx: 2.5,
// Metres to a few km: straight is the ellipsoid's arc to the pixel.
mode: '3d',
style: { kind: 'solid', color: hexColor(LOCAL_ADSB_COLOR, 0.9) },
depthFailColor: hexColor(LOCAL_ADSB_COLOR, 0.45),
},
]);
// The trail's head line: 'gev-trail' ids, claimed by the trail pick
// owner so a click on it never reads as empty space; dimmed where the
// surface hides it. A head that has not moved is not drawn again.
selectedTrail.trail.setHead(positions);
}
function refreshTrail() {
@@ -464,15 +452,13 @@ export function createLocalAdsbLayer({
function startTrail(marker) {
releaseTrail();
const createTrail = services.trails?.createTrail;
if (typeof createTrail !== 'function' || !viewer || !sets) return;
if (typeof createTrail !== 'function' || !viewer) return;
selectedTrail = {
id: marker.id,
trail: createTrail(viewer, { color: LOCAL_ADSB_COLOR, width: 2.5 }),
// Live head: last heard fix → the extrapolated marker, every frame.
headId: `gev-trail:local-adsb-head-${++trailHeadSeq}`,
lastFix: null,
// Where, from which fix and when the head was last drawn.
drawnKey: null,
// From which fix and when the head was last drawn.
drawnFrom: null,
drawnAt: -Infinity,
};
@@ -772,7 +758,6 @@ export function createLocalAdsbLayer({
show: false,
pickable: false,
}),
head: draw.lines({ id: `${prefix}:trail-head`, show: false }),
};
models = createLocalAdsbModels({
viewer,
+16 -10
View File
@@ -445,6 +445,7 @@ test('selecting an aircraft draws a magenta trail of the fixes the receiver hear
});
test('the trail head runs from the last fix to the marker every frame, dimmed behind the surface', async (t) => {
const trails = await import('../../data/trailRenderer.js');
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
const clock = { now: 100_000 };
const listeners = new Map();
@@ -462,19 +463,24 @@ test('the trail head runs from the last fix to the marker every frame, dimmed be
const input = fakeInput(viewer);
const { layer } = await enabledLayer(receiver, clock, null, {
viewer: { draw, viewer, input },
services: {
trails: {
createTrail: () => ({ setPositions() {}, destroy() {} }),
},
},
services: { trails },
});
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()];
// The head is the shared trail's head line.
const trailSet = () => draw.find('trail:');
const heads = () =>
[...(trailSet()?.items.values() ?? [])].filter(
(line) => line.id.endsWith(':head') && line.show !== false,
);
// Selected at its fix, the head has no length yet.
assert.equal(heads().length, 0);
clock.now = 100_500;
listeners.get('preRender')();
const [head] = heads();
assert.match(head.id, /^gev-trail:local-adsb-head-\d+$/);
assert.match(head.id, /^gev-trail:\d+:head$/);
assert.equal(head.mode, '3d');
assert.equal(head.widthPx, 2.5);
assert.deepEqual(head.style, {
@@ -505,9 +511,9 @@ test('the trail head runs from the last fix to the marker every frame, dimmed be
);
// A frame where nothing moved leaves the head alone.
const writes = layerSet(draw, ':trail-head').writes;
const writes = trailSet().writes;
listeners.get('preRender')();
assert.equal(layerSet(draw, ':trail-head').writes, writes);
assert.equal(trailSet().writes, writes);
await layer.disable();
assert.equal(listeners.has('preRender'), false, 'frames stop when off');
@@ -889,7 +895,7 @@ test('the layer draws into sets of its own, shown while it is enabled and let go
.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.equal(mine.length, 2, 'markers and rings');
assert.ok(
ids(other.draw).every((id) => !mine.includes(id)),
'a second layer has ids of its own',
+4 -6
View File
@@ -162,13 +162,11 @@ export function createFlightState({ source, services }) {
flightState._trail = null;
/** @type {Cesium.Entity|null} Per-frame head segment: last body point → live icon */
/** @type {(() => void)|null} Stops the per-frame live head (last body point → live
* icon), drawn as the trail's head line so the head stays glued to the 12 Hz icon
* without rebuilding the 400-point trail body every frame. */
flightState._trailHeadEntity = null;
/** @type {number} Uniquifier for head-segment entity ids (Cesium requires unique ids). */
flightState._trailHeadSeq = 0;
flightState._trailHeadOff = null;
/** @type {Cesium.Cartesian3[]} Chronological tracked-aircraft fixes (oldest first) */
+63 -77
View File
@@ -1,4 +1,5 @@
import { cameraOf } from '../../render/cesium/camera.js';
import { findFrame } from '../../render/rendererOf.js';
import {
entityFollowTarget,
onFollowChanged,
@@ -211,7 +212,6 @@ export function createTracking({
// Never bulk-destroy here: that stalls the renderer exactly as cockpit begins.
if (flightState._modelCollection) flightState._modelCollection.show = true;
flightState._trail?.setVisible(!next);
if (flightState._trailHeadEntity) flightState._trailHeadEntity.show = !next;
const icons = flightState._icons;
for (const icao24 of icons?.ids() ?? [])
parts.icons._applyIconPresentation(icao24);
@@ -497,7 +497,7 @@ export function createTracking({
* Renders the trail BODY — the accumulated fixes EXCLUDING the newest raw one. That
* newest fix is at ~now, ~one poll interval AHEAD of the delayed icon (rendered at
* now − RENDER_DELAY_SEC), so drawing it would push the trail in FRONT of the plane.
* The cheap per-frame _trailHeadEntity segment bridges the last body point to the
* The cheap per-frame trail head segment bridges the last body point to the
* delayed dead-reckoned head, so this primitive only rebuilds on a real fix (poll
* cadence), never at motion cadence.
*/
@@ -511,6 +511,58 @@ export function createTracking({
);
}
/**
* The live head: the last DISPLAYED body point to the delayed head, or no
* positions while there is none.
* @returns {Cesium.Cartesian3[]}
*/
function _trailHeadPositions() {
// Need ≥2 accumulated points: the body draws all-but-newest, so the head must
// start at the last DISPLAYED body point (index n−2). With a single fix that
// point would be the sole raw fix — ~now, AHEAD of the delayed icon — so the
// segment would draw IN FRONT of the plane. Likewise during warm-up the icon
// predates all real history, so there is no valid body point behind it.
if (
!flightState._trackedIcao ||
flightState._trailPositions.length < 2 ||
parts.motion._isTrackWarmingUp()
)
return [];
const head =
parts.motion._trackedTrailCached() ||
parts.motion._trackedDisplayPosition(flightState._trackedIcao);
if (!head) return [];
// body[n−2] (last displayed body point) → delayed head: runs FORWARD, never a
// backward/reversing segment.
const start =
flightState._trailPositions[flightState._trailPositions.length - 2];
// Floor the head too (round 2): a grounded tracked contact's DR
// display height is the pre-datum default — without this the last
// segment dives underground while taxiing.
const end = _trailFloorPosition(Cesium.Cartesian3.clone(head));
// On a contact that has not moved this segment runs from inside the
// model out to its own anchor — a line through the fuselage. The END
// never gives, so a moving trail still terminates on the tail; the
// START is what slides, from nothing on a parked contact out to the
// whole segment once it has cleared its own envelope. Measured against
// the FLOORED endpoint, which is the one actually drawn.
// See trailHeadStart.
const from = trailHeadStart(
start,
end,
parts.motion._trackedModelCenterWorld(),
parts.motion._trackedModelEnvelopeM(),
flightState._scratchTrailHead,
);
if (!from) return [];
return [from, end];
}
/** Each drawn frame, before it draws: the live head where the aircraft is now. */
function _drawTrailHead() {
flightState._trail?.setHead(_trailHeadPositions());
}
/**
* Start the trail for a newly tracked aircraft: seed it with the short
* dead-reckoning history (chronological), render immediately, then
@@ -547,69 +599,13 @@ export function createTracking({
});
}
flightState._trail?.setVisible(!flightState._cockpitContactMode);
// Live head segment: last DISPLAYED body point → current dead-reckoned icon, updated
// every frame via a CallbackProperty (Cesium updates entity-polyline positions cheaply,
// unlike the trail primitive which fully rebuilds on setPositions). Keeps the head glued
// to the 12 Hz icon instead of lagging ~1 s behind it.
if (!flightState._trailHeadEntity && flightState._viewer) {
flightState._trailHeadEntity = flightState._viewer.entities.add({
// 'gev-trail' namespace (round 6): claimed by trailRenderer's pick
// owner so a click on the head segment never reads as empty space.
id: `gev-trail:mil-head-${++flightState._trailHeadSeq}`,
show: !flightState._cockpitContactMode,
polyline: {
positions: new Cesium.CallbackProperty(() => {
// Need ≥2 accumulated points: the body draws all-but-newest, so the head must
// start at the last DISPLAYED body point (index n−2). With a single fix that
// point would be the sole raw fix — ~now, AHEAD of the delayed icon — so the
// segment would draw IN FRONT of the plane. Likewise during warm-up the icon
// predates all real history, so there is no valid body point behind it.
if (
!flightState._trackedIcao ||
flightState._trailPositions.length < 2 ||
parts.motion._isTrackWarmingUp()
)
return [];
const head =
parts.motion._trackedTrailCached() ||
parts.motion._trackedDisplayPosition(flightState._trackedIcao);
if (!head) return [];
// body[n−2] (last displayed body point) → delayed head: runs FORWARD, never a
// backward/reversing segment.
const start =
flightState._trailPositions[
flightState._trailPositions.length - 2
];
// Floor the head too (round 2): a grounded tracked contact's DR
// display height is the pre-datum default — without this the last
// segment dives underground while taxiing.
const end = _trailFloorPosition(Cesium.Cartesian3.clone(head));
// On a contact that has not moved this segment runs from inside the
// model out to its own anchor — a line through the fuselage. The END
// never gives, so a moving trail still terminates on the tail; the
// START is what slides, from nothing on a parked contact out to the
// whole segment once it has cleared its own envelope. Measured against
// the FLOORED endpoint, which is the one actually drawn.
// See trailHeadStart.
const from = trailHeadStart(
start,
end,
parts.motion._trackedModelCenterWorld(),
parts.motion._trackedModelEnvelopeM(),
flightState._scratchTrailHead,
);
if (!from) return [];
return [from, end];
}, false),
width: 2.5,
material: Cesium.Color.fromCssColorString(TRAIL_COLOR).withAlpha(0.9),
// Round 4: the head must never vanish into the mesh either (dimmed
// when occluded so depth still reads).
depthFailMaterial:
Cesium.Color.fromCssColorString(TRAIL_COLOR).withAlpha(0.45),
arcType: Cesium.ArcType.GEODESIC, // round 8: consistent with the trail body (no chords)
},
});
// Live head segment: last displayed body point → current dead-reckoned icon, drawn
// again each frame before it draws, so it stays glued to the 12 Hz icon instead of
// lagging ~1 s behind it. Only the head line is rebuilt; the body rebuilds on a real
// fix (poll cadence). Dimmed where occluded (round 4), geodesic as the body (round 8).
if (!flightState._trailHeadOff && flightState._viewer) {
flightState._trailHeadOff =
findFrame(flightState._viewer)?.on('preRender', _drawTrailHead) ?? null;
}
_refreshTrailDisplay();
@@ -736,18 +732,8 @@ export function createTracking({
flightState._trailBackfillToken += 1;
flightState._trailPositions = [];
if (flightState._trail) flightState._trail.clear();
if (
flightState._trailHeadEntity &&
flightState._viewer &&
!flightState._viewer.isDestroyed()
) {
try {
flightState._viewer.entities.remove(flightState._trailHeadEntity);
} catch {
/* already gone */
}
}
flightState._trailHeadEntity = null;
flightState._trailHeadOff?.();
flightState._trailHeadOff = null;
}
/**