mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Format military-flight and classification components
This commit is contained in:
1 parent
cb790ddea1
commit
1edebcb6f8
17 files changed
+5078
-3959
No files matched your search
+230
-273
@@ -1,443 +1,400 @@
|
||||
import * as Cesium from 'cesium';
|
||||
|
||||
export function createFlightState({ source, services }) {
|
||||
const { createGroundSnap } = services.groundSnap;
|
||||
const flightState = { lifetime: new AbortController() };
|
||||
const { createGroundSnap } = services.groundSnap;
|
||||
const flightState = { lifetime: new AbortController() };
|
||||
|
||||
flightState._source = source;
|
||||
|
||||
/** Per-class model spec for THIS layer (2026-08-16, owner playtest ask:
|
||||
* military contacts should read as their WEIGHT CLASS, always in this layer's
|
||||
* amber). Real Hangar GLBs serve the classes they cover (meters, nose −X →
|
||||
* 180° offset); airliner/quadjet/glider get the shared 747 silhouette
|
||||
* (airplane.glb — C-5M/RC-135-style heavies stop rendering as bizjets);
|
||||
* fastjet and unknown keep jet.glb with the same 180° offset. The MIX tint stays
|
||||
* dominant everywhere — military is amber, tracked is TRACKED_ICON_COLOR,
|
||||
* and the tint must dominate any livery (owner: "stays yellow"). Specs are
|
||||
* static per class — memoized (the fleet pass asks at 12 Hz per model). */
|
||||
|
||||
flightState._source = source;
|
||||
flightState._specCache = new Map();
|
||||
|
||||
/** Per-class model spec for THIS layer (2026-08-16, owner playtest ask:
|
||||
* military contacts should read as their WEIGHT CLASS, always in this layer's
|
||||
* amber). Real Hangar GLBs serve the classes they cover (meters, nose −X →
|
||||
* 180° offset); airliner/quadjet/glider get the shared 747 silhouette
|
||||
* (airplane.glb — C-5M/RC-135-style heavies stop rendering as bizjets);
|
||||
* fastjet and unknown keep jet.glb with the same 180° offset. The MIX tint stays
|
||||
* dominant everywhere — military is amber, tracked is TRACKED_ICON_COLOR,
|
||||
* and the tint must dominate any livery (owner: "stays yellow"). Specs are
|
||||
* static per class — memoized (the fleet pass asks at 12 Hz per model). */
|
||||
/** One-shot cached tile-skin heights for MODELED grounded planes (see groundSnap.js). */
|
||||
|
||||
flightState._specCache = new Map();
|
||||
flightState._groundSnap = createGroundSnap();
|
||||
|
||||
/** One-shot cached tile-skin heights for MODELED grounded planes (see groundSnap.js). */
|
||||
flightState._scratchGroundCarto = new Cesium.Cartographic();
|
||||
|
||||
flightState._groundSnap = createGroundSnap();
|
||||
flightState._scratchGroundPos = new Cesium.Cartesian3();
|
||||
|
||||
/** @type {Cesium.PrimitiveCollection|null} */
|
||||
|
||||
flightState._scratchGroundCarto = new Cesium.Cartographic();
|
||||
flightState._modelCollection = null;
|
||||
|
||||
/** @type {Map<string, Cesium.Model>} icao24 → model */
|
||||
|
||||
flightState._scratchGroundPos = new Cesium.Cartesian3();
|
||||
flightState._models = new Map();
|
||||
|
||||
/** @type {Cesium.PrimitiveCollection|null} */
|
||||
/** @type {Set<string>} icao24 currently loading (async) */
|
||||
|
||||
flightState._modelCollection = null;
|
||||
flightState._modelPending = new Set();
|
||||
|
||||
/** @type {Map<string, Cesium.Model>} icao24 → model */
|
||||
/** @type {Map<string, number>} icao24 → load generation; bumped on release to invalidate
|
||||
* an in-flight load (so a track/untrack/remove during fromGltfAsync can't add a stale model). */
|
||||
|
||||
flightState._models = new Map();
|
||||
flightState._modelGen = new Map();
|
||||
|
||||
/** @type {Set<string>} icao24 currently loading (async) */
|
||||
/** Lifecycle epoch; bumped on destroy so an in-flight load from a PREVIOUS init can't settle
|
||||
* against a new lifecycle's globals (which destroy cleared). Captured by _ensureModel. */
|
||||
|
||||
flightState._modelPending = new Set();
|
||||
flightState._modelEpoch = 0;
|
||||
|
||||
/** @type {Map<string, number>} icao24 → load generation; bumped on release to invalidate
|
||||
* an in-flight load (so a track/untrack/remove during fromGltfAsync can't add a stale model). */
|
||||
/** DEFAULT-ON in PROXIMITY (owner directive 2026-08-22). A fresh boot never runs
|
||||
* layer-state restoration, so this initializer — not the codec — is what the app
|
||||
* actually starts with; it must stay in lockstep with the `models3d` default in
|
||||
* `layerState.js` and `this._models3dEnabled` in ui.js, or the DISPLAY rail would
|
||||
* light a button the layer has not armed. */
|
||||
|
||||
flightState._modelGen = new Map();
|
||||
flightState._models3dEnabled = true;
|
||||
|
||||
/** Lifecycle epoch; bumped on destroy so an in-flight load from a PREVIOUS init can't settle
|
||||
* against a new lifecycle's globals (which destroy cleared). Captured by _ensureModel. */
|
||||
flightState._models3dMode = 'proximity';
|
||||
// 'proximity' = nearest MODEL_MAX in view; 'all' = every in-view plane (≤ MODEL_MAX_ALL)
|
||||
|
||||
flightState._modelEpoch = 0;
|
||||
flightState._lastModelCapWarnMs = 0;
|
||||
// throttle the "more planes in view than the cap" console notice
|
||||
// The tracked entity's billboard goes transparent (rather than hidden) once the model takes
|
||||
// over, so it keeps supplying a bounding sphere for follow-camera framing. We only drop its
|
||||
// alpha after the GLB is preloaded so the model is ready to render the instant the billboard
|
||||
// fades — no gap, no double-image. Preloaded once at init; the instance is retained (not
|
||||
// destroyed) purely to keep Cesium's glTF cache warm for fast tracked-model instantiation.
|
||||
|
||||
/** DEFAULT-ON in PROXIMITY (owner directive 2026-08-22). A fresh boot never runs
|
||||
* layer-state restoration, so this initializer — not the codec — is what the app
|
||||
* actually starts with; it must stay in lockstep with the `models3d` default in
|
||||
* `layerState.js` and `this._models3dEnabled` in ui.js, or the DISPLAY rail would
|
||||
* light a button the layer has not armed. */
|
||||
flightState._planeModelLoaded = false;
|
||||
|
||||
flightState._models3dEnabled = true;
|
||||
/** @type {Cesium.Model|null} retained preload that keeps the glTF cache warm */
|
||||
|
||||
flightState._preloadModel = null;
|
||||
|
||||
flightState._models3dMode = 'proximity';
|
||||
// 'proximity' = nearest MODEL_MAX in view; 'all' = every in-view plane (≤ MODEL_MAX_ALL)
|
||||
flightState._scratchModelHpr = new Cesium.HeadingPitchRoll(0, 0, 0);
|
||||
|
||||
flightState._lastModelCapWarnMs = 0;
|
||||
// throttle the "more planes in view than the cap" console notice
|
||||
// The tracked entity's billboard goes transparent (rather than hidden) once the model takes
|
||||
// over, so it keeps supplying a bounding sphere for follow-camera framing. We only drop its
|
||||
// alpha after the GLB is preloaded so the model is ready to render the instant the billboard
|
||||
// fades — no gap, no double-image. Preloaded once at init; the instance is retained (not
|
||||
// destroyed) purely to keep Cesium's glTF cache warm for fast tracked-model instantiation.
|
||||
flightState._scratchModelMtx = new Cesium.Matrix4();
|
||||
|
||||
flightState._planeModelLoaded = false;
|
||||
flightState._scratchModelBS = new Cesium.BoundingSphere(
|
||||
new Cesium.Cartesian3(),
|
||||
1.0,
|
||||
);
|
||||
// frustum-visibility test
|
||||
/** Last limb taper per billboard, retained across class/ground/cockpit repaints. */
|
||||
|
||||
/** @type {Cesium.Model|null} retained preload that keeps the glTF cache warm */
|
||||
flightState._billboardLimbScale = new WeakMap();
|
||||
|
||||
flightState._preloadModel = null;
|
||||
// ---------------------------------------------------------------------------
|
||||
// Module-level state
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/** @type {Cesium.BillboardCollection|null} Single GPU-batched collection for all aircraft */
|
||||
|
||||
flightState._scratchModelHpr = new Cesium.HeadingPitchRoll(0, 0, 0);
|
||||
flightState._billboardCollection = null;
|
||||
|
||||
/** @type {Map<string, Cesium.Billboard>} ICAO hex -> billboard primitive */
|
||||
|
||||
flightState._scratchModelMtx = new Cesium.Matrix4();
|
||||
flightState._billboards = new Map();
|
||||
|
||||
/** Stable lightweight records reused by the detection overlay between polls. */
|
||||
|
||||
flightState._scratchModelBS = new Cesium.BoundingSphere(new Cesium.Cartesian3(), 1.0);
|
||||
// frustum-visibility test
|
||||
/** Last limb taper per billboard, retained across class/ground/cockpit repaints. */
|
||||
flightState._detectionObjects = new Map();
|
||||
|
||||
flightState._billboardLimbScale = new WeakMap();
|
||||
/** @type {Map<string, Object>} ICAO hex -> flight metadata (callsign, type, registration, operator, altitudeFt, speedMps, track) */
|
||||
|
||||
flightState._flightData = new Map();
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Module-level state
|
||||
// ---------------------------------------------------------------------------
|
||||
/** @type {Map<string, Array<{time: Cesium.JulianDate, position: Cesium.Cartesian3}>>} ICAO hex -> recent position samples for dead reckoning */
|
||||
|
||||
/** @type {Cesium.BillboardCollection|null} Single GPU-batched collection for all aircraft */
|
||||
flightState._positionHistory = new Map();
|
||||
|
||||
flightState._billboardCollection = null;
|
||||
/** @type {number} Current number of visible aircraft */
|
||||
|
||||
/** @type {Map<string, Cesium.Billboard>} ICAO hex -> billboard primitive */
|
||||
flightState._count = 0;
|
||||
|
||||
flightState._billboards = new Map();
|
||||
/** @type {number|null} Epoch ms of last successful API update */
|
||||
|
||||
/** Stable lightweight records reused by the detection overlay between polls. */
|
||||
flightState._lastUpdate = null;
|
||||
|
||||
flightState._detectionObjects = new Map();
|
||||
/** @type {boolean} True when in error-backoff mode */
|
||||
|
||||
/** @type {Map<string, Object>} ICAO hex -> flight metadata (callsign, type, registration, operator, altitudeFt, speedMps, track) */
|
||||
flightState._backoff = false;
|
||||
|
||||
flightState._flightData = new Map();
|
||||
/** @type {number} Epoch ms after which the next retry is allowed */
|
||||
|
||||
/** @type {Map<string, Array<{time: Cesium.JulianDate, position: Cesium.Cartesian3}>>} ICAO hex -> recent position samples for dead reckoning */
|
||||
flightState._retryAt = 0;
|
||||
|
||||
flightState._positionHistory = new Map();
|
||||
/** @type {string|null} Human-readable description of the last error */
|
||||
|
||||
/** @type {number} Current number of visible aircraft */
|
||||
flightState._lastError = null;
|
||||
|
||||
flightState._count = 0;
|
||||
flightState._activeUpdateControllers = new Set();
|
||||
|
||||
/** @type {number|null} Epoch ms of last successful API update */
|
||||
/** @type {number|null} HTTP status code from the last API response */
|
||||
|
||||
flightState._lastUpdate = null;
|
||||
flightState._lastStatus = null;
|
||||
|
||||
/** @type {boolean} True when in error-backoff mode */
|
||||
flightState._lastSource = source?.label || 'Aircraft';
|
||||
|
||||
flightState._backoff = false;
|
||||
/** @type {boolean} True once ensureGeoidReady() has resolved (awaited once at enable()). Mirror of flights.js. */
|
||||
|
||||
/** @type {number} Epoch ms after which the next retry is allowed */
|
||||
flightState._geoidReady = false;
|
||||
|
||||
flightState._retryAt = 0;
|
||||
/** @type {Map<string, number>} icao24 -> geoid undulation N (m), cached (negligible drift per-aircraft). */
|
||||
|
||||
/** @type {string|null} Human-readable description of the last error */
|
||||
flightState._geoidNCache = new Map();
|
||||
|
||||
flightState._lastError = null;
|
||||
// -- Click-to-track state --
|
||||
/** @type {string|null} ICAO hex of the currently tracked aircraft */
|
||||
|
||||
flightState._trackedIcao = null;
|
||||
|
||||
flightState._activeUpdateControllers = new Set();
|
||||
flightState._pendingTrackingRestore = null;
|
||||
|
||||
/** @type {number|null} HTTP status code from the last API response */
|
||||
flightState._trackingIntentGeneration = 0;
|
||||
|
||||
flightState._lastStatus = null;
|
||||
flightState._trackingRefreshEpoch = 0;
|
||||
|
||||
flightState._lastTrackingRefreshOutcome = {
|
||||
epoch: 0,
|
||||
status: 'unavailable',
|
||||
ids: new Set(),
|
||||
source: flightState._lastSource,
|
||||
};
|
||||
|
||||
flightState._lastSource = source?.label || 'Aircraft';
|
||||
/** @type {Cesium.Entity|null} Entity created for the tracked aircraft (camera follows this) */
|
||||
|
||||
/** @type {boolean} True once ensureGeoidReady() has resolved (awaited once at enable()). Mirror of flights.js. */
|
||||
flightState._trackedEntity = null;
|
||||
|
||||
flightState._geoidReady = false;
|
||||
/** Disposes the single active tracked-camera framing owner. */
|
||||
|
||||
/** @type {Map<string, number>} icao24 -> geoid undulation N (m), cached (negligible drift per-aircraft). */
|
||||
flightState._trackedCameraFrameStop = null;
|
||||
|
||||
flightState._geoidNCache = new Map();
|
||||
/** @type {Cesium.Model|null} Standalone 3D model for the tracked aircraft — NOT a graphic on
|
||||
* _trackedEntity, so viewer.trackedEntity's follow-camera always has a ready bounding sphere
|
||||
* (a model graphic reports PENDING until loaded, which freezes the centering on 3D-toggle). */
|
||||
|
||||
flightState._trackedModel = null;
|
||||
|
||||
// -- Click-to-track state --
|
||||
/** @type {string|null} ICAO hex of the currently tracked aircraft */
|
||||
flightState._trackedModelGen = 0;
|
||||
|
||||
flightState._trackedIcao = null;
|
||||
flightState._trackedModelLoading = false;
|
||||
|
||||
/** @type {Cesium.ScreenSpaceEventHandler|null} Click handler for selecting aircraft */
|
||||
|
||||
flightState._pendingTrackingRestore = null;
|
||||
flightState._clickHandler = null;
|
||||
|
||||
/** @type {Cesium.Viewer|null} Cached viewer reference */
|
||||
|
||||
flightState._trackingIntentGeneration = 0;
|
||||
flightState._viewer = null;
|
||||
|
||||
/** Cockpit presentation switches ambient AIR contacts between near aircraft and far dots. */
|
||||
|
||||
flightState._trackingRefreshEpoch = 0;
|
||||
flightState._cockpitContactMode = false;
|
||||
|
||||
/** AIR contacts inside the selected Display range; independent from model admission/load/cap. */
|
||||
|
||||
flightState._lastTrackingRefreshOutcome = {
|
||||
epoch: 0,
|
||||
status: 'unavailable',
|
||||
ids: new Set(),
|
||||
source: flightState._lastSource,
|
||||
};
|
||||
flightState._cockpitNearContacts = new Set();
|
||||
|
||||
/** @type {Cesium.Entity|null} Entity created for the tracked aircraft (camera follows this) */
|
||||
/** Normalized ICAO24 of the active Cockpit subject, omitted from detection candidates. */
|
||||
|
||||
flightState._trackedEntity = null;
|
||||
flightState._cockpitSubjectId = null;
|
||||
|
||||
/** Disposes the single active tracked-camera framing owner. */
|
||||
/** @type {((event: CustomEvent) => void)|null} */
|
||||
|
||||
flightState._trackedCameraFrameStop = null;
|
||||
flightState._cockpitModeListener = null;
|
||||
|
||||
/** @type {Cesium.Model|null} Standalone 3D model for the tracked aircraft — NOT a graphic on
|
||||
* _trackedEntity, so viewer.trackedEntity's follow-camera always has a ready bounding sphere
|
||||
* (a model graphic reports PENDING until loaded, which freezes the centering on 3D-toggle). */
|
||||
/** @type {{setPositions: Function, clear: Function, destroy: Function}|null} Shared fading-trail renderer */
|
||||
|
||||
flightState._trackedModel = null;
|
||||
flightState._trail = null;
|
||||
|
||||
/** @type {Cesium.Entity|null} Per-frame head segment: last body point → live icon */
|
||||
|
||||
flightState._trackedModelGen = 0;
|
||||
flightState._trailHeadEntity = null;
|
||||
|
||||
/** @type {number} Uniquifier for head-segment entity ids (Cesium requires unique ids). */
|
||||
|
||||
flightState._trackedModelLoading = false;
|
||||
flightState._trailHeadSeq = 0;
|
||||
|
||||
/** @type {Cesium.ScreenSpaceEventHandler|null} Click handler for selecting aircraft */
|
||||
/** @type {Cesium.Cartesian3[]} Chronological tracked-aircraft fixes (oldest first) */
|
||||
|
||||
flightState._clickHandler = null;
|
||||
flightState._trailPositions = [];
|
||||
|
||||
/** @type {Cesium.Viewer|null} Cached viewer reference */
|
||||
/** @type {number} Monotonic token — invalidates in-flight backfill responses */
|
||||
|
||||
flightState._viewer = null;
|
||||
flightState._trailBackfillToken = 0;
|
||||
|
||||
/** Cockpit presentation switches ambient AIR contacts between near aircraft and far dots. */
|
||||
/** @type {Map<string, number>} icao24 -> consecutive missed polls */
|
||||
|
||||
flightState._cockpitContactMode = false;
|
||||
flightState._missingPolls = new Map();
|
||||
|
||||
/** AIR contacts inside the selected Display range; independent from model admission/load/cap. */
|
||||
/** @type {number} Epoch ms of the last fleet dead-reckoning pass */
|
||||
|
||||
flightState._cockpitNearContacts = new Set();
|
||||
flightState._lastFleetTickMs = 0;
|
||||
|
||||
/** Normalized ICAO24 of the active Cockpit subject, omitted from detection candidates. */
|
||||
/** @type {string} Camera pose signature at the last rotation pass */
|
||||
|
||||
flightState._cockpitSubjectId = null;
|
||||
flightState._lastCamPoseSig = '';
|
||||
|
||||
/** @type {((event: CustomEvent) => void)|null} */
|
||||
/** @type {number} Epoch ms of the last full rotation pass */
|
||||
|
||||
flightState._cockpitModeListener = null;
|
||||
flightState._lastRotPassMs = 0;
|
||||
|
||||
/** @type {{setPositions: Function, clear: Function, destroy: Function}|null} Shared fading-trail renderer */
|
||||
/** @type {number} Last computed rotation for the tracked entity (radians) */
|
||||
|
||||
flightState._trail = null;
|
||||
flightState._lastTrackedRotation = 0;
|
||||
|
||||
/** @type {Cesium.Entity|null} Per-frame head segment: last body point → live icon */
|
||||
/** @type {Cesium.Event.RemoveCallback|null} preRender listener disposer */
|
||||
|
||||
flightState._trailHeadEntity = null;
|
||||
flightState._preRenderRemove = null;
|
||||
|
||||
/** @type {number} Uniquifier for head-segment entity ids (Cesium requires unique ids). */
|
||||
flightState._trackedModelPreUpdateRemove = null;
|
||||
|
||||
flightState._trailHeadSeq = 0;
|
||||
/** @type {Cesium.Event.RemoveCallback|null} camera.moveEnd listener disposer (arrival rotation pass) */
|
||||
|
||||
/** @type {Cesium.Cartesian3[]} Chronological tracked-aircraft fixes (oldest first) */
|
||||
flightState._moveEndRemove = null;
|
||||
|
||||
flightState._trailPositions = [];
|
||||
/** @type {Cesium.Event.RemoveCallback|null} trackedEntityChanged listener disposer (cross-layer untrack) */
|
||||
|
||||
/** @type {number} Monotonic token — invalidates in-flight backfill responses */
|
||||
flightState._trackedEntityChangedRemove = null;
|
||||
|
||||
flightState._trailBackfillToken = 0;
|
||||
// -- Scratch variables (reused each frame to avoid GC pressure) --
|
||||
|
||||
/** @type {Map<string, number>} icao24 -> consecutive missed polls */
|
||||
flightState._scratchOffset = new Cesium.Cartesian3();
|
||||
|
||||
flightState._missingPolls = new Map();
|
||||
flightState._scratchCarto = new Cesium.Cartographic();
|
||||
|
||||
/** @type {number} Epoch ms of the last fleet dead-reckoning pass */
|
||||
flightState._scratchEnu = new Cesium.Matrix4();
|
||||
|
||||
flightState._lastFleetTickMs = 0;
|
||||
flightState._scratchArc = { east: 0, north: 0, endCourseDeg: 0 };
|
||||
|
||||
/** @type {string} Camera pose signature at the last rotation pass */
|
||||
flightState._scratchRenderTime = new Cesium.JulianDate();
|
||||
|
||||
flightState._lastCamPoseSig = '';
|
||||
flightState._scratchFleetPos = new Cesium.Cartesian3();
|
||||
|
||||
/** @type {number} Epoch ms of the last full rotation pass */
|
||||
flightState._scratchDrRaw = new Cesium.Cartesian3();
|
||||
|
||||
flightState._lastRotPassMs = 0;
|
||||
flightState._scratchWarmupTime = new Cesium.JulianDate();
|
||||
|
||||
/** @type {number} Last computed rotation for the tracked entity (radians) */
|
||||
flightState._trackedPosHolder = new Cesium.Cartesian3();
|
||||
|
||||
flightState._lastTrackedRotation = 0;
|
||||
// -- Per-frame dead-reckoning cache for the tracked entity --
|
||||
/** @type {Cesium.Cartesian3|null} Cached DR position for the current render frame */
|
||||
|
||||
/** @type {Cesium.Event.RemoveCallback|null} preRender listener disposer */
|
||||
flightState._cachedDRPosition = null;
|
||||
|
||||
flightState._preRenderRemove = null;
|
||||
/** @type {number} Frame number the cache was last populated for */
|
||||
|
||||
flightState._cachedDRFrame = -1;
|
||||
|
||||
flightState._trackedModelPreUpdateRemove = null;
|
||||
/** Course (deg) of the position `_deadReckon` most recently returned — set on
|
||||
* every branch of `_deadReckon`, read IMMEDIATELY by the caller (same
|
||||
* synchronous flow; module-scratch idiom, like the Cartesian scratches). */
|
||||
|
||||
/** @type {Cesium.Event.RemoveCallback|null} camera.moveEnd listener disposer (arrival rotation pass) */
|
||||
flightState._drCourseDeg = null;
|
||||
|
||||
flightState._moveEndRemove = null;
|
||||
/** Sibling scratches of _drCourseDeg: the displayed ground speed of the motion
|
||||
* `_deadReckon` just returned, and whether that motion is too slow for ANY
|
||||
* course source to be trusted (hover/GPS drift — consumers HOLD their
|
||||
* previous display course instead of chasing noise). */
|
||||
|
||||
/** @type {Cesium.Event.RemoveCallback|null} trackedEntityChanged listener disposer (cross-layer untrack) */
|
||||
flightState._drSpeedMps = null;
|
||||
|
||||
flightState._trackedEntityChangedRemove = null;
|
||||
flightState._drCourseHold = false;
|
||||
|
||||
/** Frame-cached course for the tracked aircraft (sibling of _cachedDRPosition). */
|
||||
|
||||
// -- Scratch variables (reused each frame to avoid GC pressure) --
|
||||
flightState._cachedDRCourse = null;
|
||||
|
||||
flightState._scratchOffset = new Cesium.Cartesian3();
|
||||
/** Frame-cached siblings of _cachedDRCourse (same discipline). */
|
||||
|
||||
flightState._cachedDRSpeedMps = null;
|
||||
|
||||
flightState._scratchCarto = new Cesium.Cartographic();
|
||||
flightState._cachedDRHold = false;
|
||||
|
||||
/** Wall-clock of the tracked course limiter's last advance (dt source only —
|
||||
* the course VALUE lives in the shared per-icao _displayCourse map below). */
|
||||
|
||||
flightState._scratchEnu = new Cesium.Matrix4();
|
||||
flightState._trackedCourseMs = 0;
|
||||
|
||||
/** Per-aircraft smoothed display course — the SINGLE source of truth for the
|
||||
* nose direction an aircraft displays (mirror of flights.js, 2026-07-03
|
||||
* field fix). The fleet pass reads/writes it at tick cadence for untracked
|
||||
* planes; _trackedDisplayCourse reads/writes the SAME entry per frame for
|
||||
* the tracked plane (the fleet pass skips the tracked icao, so exactly one
|
||||
* writer owns an entry at a time). Sharing the entry — including its slew
|
||||
* state — keeps the tracked↔fleet handoff seamless (separate states froze
|
||||
* the fleet entry while tracked → nose flip on click / click-away). */
|
||||
|
||||
flightState._scratchArc = { east: 0, north: 0, endCourseDeg: 0 };
|
||||
flightState._displayCourse = new Map();
|
||||
|
||||
flightState._drCorrection = new Cesium.Cartesian3(0, 0, 0);
|
||||
|
||||
flightState._scratchRenderTime = new Cesium.JulianDate();
|
||||
flightState._drCorrectionStartMs = 0;
|
||||
|
||||
flightState._drPrevRaw = new Cesium.Cartesian3();
|
||||
|
||||
flightState._scratchFleetPos = new Cesium.Cartesian3();
|
||||
flightState._drPrevDisplay = new Cesium.Cartesian3();
|
||||
|
||||
flightState._drPrevMs = 0;
|
||||
|
||||
flightState._scratchDrRaw = new Cesium.Cartesian3();
|
||||
flightState._drReconcileValid = false;
|
||||
|
||||
/** @type {string|null} icao the reconciliation state currently belongs to */
|
||||
|
||||
flightState._scratchWarmupTime = new Cesium.JulianDate();
|
||||
flightState._drReconcileIcao = null;
|
||||
|
||||
/** @type {Cesium.Cartesian3} Scratch for the tracked model's rendered translation. */
|
||||
|
||||
flightState._trackedPosHolder = new Cesium.Cartesian3();
|
||||
flightState._trackedVisualPos = new Cesium.Cartesian3();
|
||||
|
||||
flightState._trackedTrailPos = new Cesium.Cartesian3();
|
||||
|
||||
// -- Per-frame dead-reckoning cache for the tracked entity --
|
||||
/** @type {Cesium.Cartesian3|null} Cached DR position for the current render frame */
|
||||
/** Scratch for the tracked model's world-space origin (the envelope centre). */
|
||||
|
||||
flightState._cachedDRPosition = null;
|
||||
flightState._scratchTrailClip = new Cesium.Cartesian3();
|
||||
|
||||
/** @type {number} Frame number the cache was last populated for */
|
||||
/** Scratch for the shortened trail-head start. Owned by the head-segment
|
||||
* callback alone, so nothing else can overwrite it mid-frame. */
|
||||
|
||||
flightState._cachedDRFrame = -1;
|
||||
flightState._scratchTrailHead = new Cesium.Cartesian3();
|
||||
|
||||
/** Hysteresis latch for the tracked contact's zoom regime, plus the selection it
|
||||
* belongs to. Scoped per selection so a NEW target re-evaluates against the ENTER
|
||||
* ceiling instead of inheriting the previous target's looser EXIT band. */
|
||||
|
||||
/** Course (deg) of the position `_deadReckon` most recently returned — set on
|
||||
* every branch of `_deadReckon`, read IMMEDIATELY by the caller (same
|
||||
* synchronous flow; module-scratch idiom, like the Cartesian scratches). */
|
||||
flightState._trackedZoomLatched = false;
|
||||
|
||||
flightState._drCourseDeg = null;
|
||||
flightState._trackedZoomLatchIcao = null;
|
||||
|
||||
/** Sibling scratches of _drCourseDeg: the displayed ground speed of the motion
|
||||
* `_deadReckon` just returned, and whether that motion is too slow for ANY
|
||||
* course source to be trusted (hover/GPS drift — consumers HOLD their
|
||||
* previous display course instead of chasing noise). */
|
||||
flightState._trackedModelFailIcao = null;
|
||||
|
||||
flightState._drSpeedMps = null;
|
||||
flightState._trackedModelFailCount = 0;
|
||||
|
||||
flightState._trackedModelRetryAtMs = 0;
|
||||
|
||||
flightState._drCourseHold = false;
|
||||
/** IR hot-target mode — mirror of flights.js: under the luminance-mapped
|
||||
* NVG/FLIR post-styles every model renders flat white (hottest); the dominant
|
||||
* amber/tracked tint restores on style exit. */
|
||||
|
||||
/** Frame-cached course for the tracked aircraft (sibling of _cachedDRPosition). */
|
||||
flightState._irBoost = false;
|
||||
|
||||
flightState._cachedDRCourse = null;
|
||||
/** Boosted models render UNLIT — mirror of flights.js (owner cockpit-FLIR
|
||||
* field rounds): material-stage tint still sun-shades, so side-on planes
|
||||
* read near-black under a high sun; UNLIT emits flat white regardless.
|
||||
* customShader on a READY model is a silent no-op (field-verified), so the
|
||||
* boost flips by release-and-reload — creation-time options carry it. */
|
||||
|
||||
/** Frame-cached siblings of _cachedDRCourse (same discipline). */
|
||||
flightState._IR_UNLIT_SHADER = new Cesium.CustomShader({
|
||||
lightingModel: Cesium.LightingModel.UNLIT,
|
||||
});
|
||||
|
||||
flightState._cachedDRSpeedMps = null;
|
||||
flightState._irReloadQueue = null;
|
||||
|
||||
/** @type {Cesium.Cartographic} Scratch for _trailFloorPosition (per-frame safe). */
|
||||
|
||||
flightState._cachedDRHold = false;
|
||||
|
||||
/** Wall-clock of the tracked course limiter's last advance (dt source only —
|
||||
* the course VALUE lives in the shared per-icao _displayCourse map below). */
|
||||
|
||||
flightState._trackedCourseMs = 0;
|
||||
|
||||
/** Per-aircraft smoothed display course — the SINGLE source of truth for the
|
||||
* nose direction an aircraft displays (mirror of flights.js, 2026-07-03
|
||||
* field fix). The fleet pass reads/writes it at tick cadence for untracked
|
||||
* planes; _trackedDisplayCourse reads/writes the SAME entry per frame for
|
||||
* the tracked plane (the fleet pass skips the tracked icao, so exactly one
|
||||
* writer owns an entry at a time). Sharing the entry — including its slew
|
||||
* state — keeps the tracked↔fleet handoff seamless (separate states froze
|
||||
* the fleet entry while tracked → nose flip on click / click-away). */
|
||||
|
||||
flightState._displayCourse = new Map();
|
||||
|
||||
|
||||
flightState._drCorrection = new Cesium.Cartesian3(0, 0, 0);
|
||||
|
||||
|
||||
flightState._drCorrectionStartMs = 0;
|
||||
|
||||
|
||||
flightState._drPrevRaw = new Cesium.Cartesian3();
|
||||
|
||||
|
||||
flightState._drPrevDisplay = new Cesium.Cartesian3();
|
||||
|
||||
|
||||
flightState._drPrevMs = 0;
|
||||
|
||||
|
||||
flightState._drReconcileValid = false;
|
||||
|
||||
/** @type {string|null} icao the reconciliation state currently belongs to */
|
||||
|
||||
flightState._drReconcileIcao = null;
|
||||
|
||||
|
||||
/** @type {Cesium.Cartesian3} Scratch for the tracked model's rendered translation. */
|
||||
|
||||
flightState._trackedVisualPos = new Cesium.Cartesian3();
|
||||
|
||||
|
||||
flightState._trackedTrailPos = new Cesium.Cartesian3();
|
||||
|
||||
/** Scratch for the tracked model's world-space origin (the envelope centre). */
|
||||
|
||||
flightState._scratchTrailClip = new Cesium.Cartesian3();
|
||||
|
||||
/** Scratch for the shortened trail-head start. Owned by the head-segment
|
||||
* callback alone, so nothing else can overwrite it mid-frame. */
|
||||
|
||||
flightState._scratchTrailHead = new Cesium.Cartesian3();
|
||||
|
||||
|
||||
/** Hysteresis latch for the tracked contact's zoom regime, plus the selection it
|
||||
* belongs to. Scoped per selection so a NEW target re-evaluates against the ENTER
|
||||
* ceiling instead of inheriting the previous target's looser EXIT band. */
|
||||
|
||||
flightState._trackedZoomLatched = false;
|
||||
|
||||
|
||||
flightState._trackedZoomLatchIcao = null;
|
||||
|
||||
|
||||
flightState._trackedModelFailIcao = null;
|
||||
|
||||
|
||||
flightState._trackedModelFailCount = 0;
|
||||
|
||||
|
||||
flightState._trackedModelRetryAtMs = 0;
|
||||
|
||||
|
||||
/** IR hot-target mode — mirror of flights.js: under the luminance-mapped
|
||||
* NVG/FLIR post-styles every model renders flat white (hottest); the dominant
|
||||
* amber/tracked tint restores on style exit. */
|
||||
|
||||
flightState._irBoost = false;
|
||||
|
||||
/** Boosted models render UNLIT — mirror of flights.js (owner cockpit-FLIR
|
||||
* field rounds): material-stage tint still sun-shades, so side-on planes
|
||||
* read near-black under a high sun; UNLIT emits flat white regardless.
|
||||
* customShader on a READY model is a silent no-op (field-verified), so the
|
||||
* boost flips by release-and-reload — creation-time options carry it. */
|
||||
|
||||
flightState._IR_UNLIT_SHADER = new Cesium.CustomShader({ lightingModel: Cesium.LightingModel.UNLIT });
|
||||
|
||||
|
||||
flightState._irReloadQueue = null;
|
||||
|
||||
|
||||
/** @type {Cesium.Cartographic} Scratch for _trailFloorPosition (per-frame safe). */
|
||||
|
||||
flightState._scratchTrailCarto = new Cesium.Cartographic();
|
||||
return flightState;
|
||||
flightState._scratchTrailCarto = new Cesium.Cartographic();
|
||||
return flightState;
|
||||
}
|
||||
Reference in new issue
Block a user