Build the selected vessel's trail without Cesium

Trail vertices are geo/ellipsoid positions and the minimum move is measured
with geo/vector, both giving what the Cesium calls gave. Re-anchoring rows
when the geoid loads asks the rendering part for the anchor, now one
function prepareRecordVisual shares, so icon positions stay Cesium values.
The shared trail renderer takes plain ECEF positions as well, turning them
into Cartesian3s for its polyline; the Cartesian3s other layers hand it
pass through untouched. tracking leaves the Cesium allow-list.
This commit is contained in:
Sameh Khamis committed 2026-11-06 23:02:09 -08:00
1 parent 1c840cb66f
commit e327760074
6 files changed
+224 -26

No files matched your search

+7 -16
View File
@@ -1,7 +1,7 @@
import * as Cesium from 'cesium';
import { fromDegrees } from '../../geo/ellipsoid.js';
import { distance } from '../../geo/vector.js';
import {
TRAIL_HEIGHT_M,
VESSEL_LIFT_M,
TRAIL_COLOR,
TRAIL_MAX_POINTS,
TRAIL_MIN_MOVE_M,
@@ -35,7 +35,7 @@ export function createTracking({
* TRAIL_HEIGHT_M above the sea surface (geoid, same datum as the anchor)
* to avoid z-fighting.
* @param {Object} record - Vessel record with lat/lon.
* @returns {Cesium.Cartesian3|null} Lifted position, or null without a fix.
* @returns {{x: number, y: number, z: number}|null} Lifted ECEF position, or null without a fix.
*/
function vesselTrailPosition(record) {
@@ -45,7 +45,7 @@ export function createTracking({
currentGeoidN(record.lat, record.lon),
TRAIL_HEIGHT_M,
);
return Cesium.Cartesian3.fromDegrees(record.lon, record.lat, heightM);
return fromDegrees(record.lon, record.lat, heightM);
}
/**
@@ -63,15 +63,7 @@ export function createTracking({
const visual = components.rendering.getVisual(record);
if (!Number.isFinite(record.lat) || !Number.isFinite(record.lon))
continue;
const heightM = components.queries.vesselDatumHeightM(
currentGeoidN(record.lat, record.lon),
VESSEL_LIFT_M,
);
visual.position = Cesium.Cartesian3.fromDegrees(
record.lon,
record.lat,
heightM,
);
visual.position = components.rendering.anchorPosition(record);
components.rendering.syncRecordIcon(record);
}
// The rows moved with no poll behind them: draw the frame that shows it.
@@ -149,7 +141,7 @@ export function createTracking({
currentGeoidN(lat, lon),
TRAIL_HEIGHT_M,
);
older.push(Cesium.Cartesian3.fromDegrees(lon, lat, heightM));
older.push(fromDegrees(lon, lat, heightM));
}
if (!older.length) return;
@@ -173,8 +165,7 @@ export function createTracking({
const next = vesselTrailPosition(record);
if (!next) return;
const last = state.trailPositions[state.trailPositions.length - 1];
if (last && Cesium.Cartesian3.distance(last, next) <= TRAIL_MIN_MOVE_M)
return;
if (last && distance(last, next) <= TRAIL_MIN_MOVE_M) return;
state.trailPositions.push(next);
if (state.trailPositions.length > TRAIL_MAX_POINTS)
state.trailPositions.shift();