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

+15 -2
View File
@@ -135,6 +135,12 @@ const ANCHORS = {
top: Cesium.VerticalOrigin.TOP,
};
/** The longest straight step of a geodesic line, metres: a degree of arc. */
const GEODESIC_STEP_M =
Cesium.Ellipsoid.WGS84.maximumRadius * Cesium.Math.RADIANS_PER_DEGREE;
/** The fewest straight steps a geodesic line is drawn in. */
const GEODESIC_LINE_STEPS = 64;
/** The `flow` line material's type. */
const FLOW_MATERIAL = 'DrawFlowLine';
@@ -1175,8 +1181,15 @@ export function createCesiumDraw({
const a = Cesium.Cartographic.fromCartesian(points[i]);
const b = Cesium.Cartographic.fromCartesian(points[i + 1]);
const geodesic = new Cesium.EllipsoidGeodesic(a, b);
for (let k = 0; k < 64; k++) {
const s = k / 64;
// At least a step a degree of arc, as Cesium's own geodesic
// polylines are cut, and 64 steps over the whole line: a long trail
// of short legs stays as light as its positions.
const steps = Math.max(
Math.ceil((geodesic.surfaceDistance || 0) / GEODESIC_STEP_M),
Math.ceil(GEODESIC_LINE_STEPS / (points.length - 1)),
);
for (let k = 0; k < steps; k++) {
const s = k / steps;
const at = geodesic.interpolateUsingFraction(s);
dense.push(
Cesium.Cartesian3.fromRadians(