Keep tracked-entity state in app records instead of on Cesium entities

Flights, military, satellites, installations, local ADS-B and ALPR hung
gevTrackedId, gevDisplayPosition, gevVisualPosition, gevSelectionOrigin and
gevLabelModel on the Cesium entities they draw, and the tracked readout,
follow camera, cockpit, share links and awareness read them back. They now
live in src/data/entityRecords.js, an app-owned record per entity: layers
write entityRecord(entity), readers use readEntityRecord(entity). Nothing
changes on screen. This is the first slice of the renderer plan's state
mirror (P1).

The module is exported as ./data/entity-records so callers can read the
same records, and window.__godsEyeView.entityRecords gives the QA scripts
the same access from the page.
This commit is contained in:
Sameh Khamis committed 2026-11-03 08:09:00 -08:00
1 parent ea69bb4ce2
commit 65587f6c08
53 files changed
+408 -291

No files matched your search

+14 -10
View File
@@ -4,6 +4,7 @@ import {
setOverlaySourceVisible,
} from '../overlays/worldOverlay.js';
import { WORLD_OVERLAY_STYLE } from '../overlays/worldOverlayTokens.js';
import { readEntityRecord } from './entityRecords.js';
/**
* @module trackedReadout
@@ -79,9 +80,10 @@ export function trackedLabelModelFromText(
* @returns {Object|null}
*/
export function cachedTrackedDisplayPosition(entity) {
if (!entity || typeof entity.gevDisplayPosition !== 'function') return null;
const displayPosition = readEntityRecord(entity)?.displayPosition;
if (typeof displayPosition !== 'function') return null;
try {
return entity.gevDisplayPosition() || null;
return displayPosition() || null;
} catch {
return null;
}
@@ -91,22 +93,23 @@ export function cachedTrackedDisplayPosition(entity) {
* Anchor for the tracked CARD: the position the target is visually at.
*
* A layer that renders its tracked contact as a 3D model publishes
* `gevVisualPosition`, which returns the translation that model is actually rendering
* the entity record's `visualPosition`, which returns the translation that model is actually rendering
* with. For a grounded aircraft that differs from the display position by the full
* ground-snap offset (~100 m at an inland airport), so a card anchored to the display
* position sits below the aircraft and climbs slowly as the coarse floor cell warms.
*
* Falls back to the display position, so layers without a 3D visual (and any layer
* before its model is ready) are unchanged. This deliberately does NOT repurpose
* `gevDisplayPosition`: that accessor carries the follow-camera anti-jitter contract
* the entity record's `displayPosition`: that accessor carries the follow-camera anti-jitter contract
* and must keep returning the value the camera settled on.
* @param {Object|null} entity Tracked or selected presentation entity.
* @returns {Object|null}
*/
export function cachedTrackedVisualPosition(entity) {
if (entity && typeof entity.gevVisualPosition === 'function') {
const visualPosition = readEntityRecord(entity)?.visualPosition;
if (typeof visualPosition === 'function') {
try {
const visual = entity.gevVisualPosition();
const visual = visualPosition();
if (visual) return visual;
} catch {
/* fall through to the display position */
@@ -116,7 +119,7 @@ export function cachedTrackedVisualPosition(entity) {
}
function entryIdFor(entity) {
const explicit = String(entity?.gevTrackedId || '').trim();
const explicit = String(readEntityRecord(entity)?.trackedId || '').trim();
if (explicit) return explicit;
const fallback = String(entity?.id || '').trim();
return fallback ? `entity:${fallback}` : null;
@@ -132,9 +135,10 @@ function activeEntity() {
* @returns {Object|null}
*/
export function createTrackedOverlayEntry(entity) {
const model = entity?.gevLabelModel;
const record = readEntityRecord(entity);
const model = record?.labelModel;
const id = entryIdFor(entity);
if (!id || !model || typeof entity.gevDisplayPosition !== 'function') {
if (!id || !model || typeof record.displayPosition !== 'function') {
return null;
}
const title = String(model.title || '').trim();
@@ -204,7 +208,7 @@ function syncActiveEntity() {
}
/**
* Republish a layer's newly assigned `gevLabelModel` when that entity owns the
* Republish an entity record's newly assigned `labelModel` when that entity owns the
* active tracked readout. Layers call this only when presentation text changes;
* position remains the live frame-cache getter already registered with host.
* @param {Object} entity Entity whose model changed.