mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 16:52:20 +00:00
Read the camera through its port when applying flight snapshots
The flights snapshot renderer took the camera's ground point from the Cesium camera, built fix positions and history entries with Cesium types, and handed the scene to the mesh floor sampler itself. It now reads the ground point from the camera port's pose, asks the flights motion part for fix positions, copies and history entries, compares fix times in whole milliseconds as before, and lets the rendering part sample the mesh floor. The file no longer touches Cesium and leaves the allow-list.
This commit is contained in:
1 parent
dbd6363e43
commit
436b110547
5 files changed
+73
-35
No files matched your search
@@ -36,7 +36,6 @@ export function createCivilFlightLayer({
|
|||||||
records: flightState.records,
|
records: flightState.records,
|
||||||
militaryRegistry: services.militaryRegistry,
|
militaryRegistry: services.militaryRegistry,
|
||||||
groundFloor: services.groundFloor,
|
groundFloor: services.groundFloor,
|
||||||
meshFloor: services.meshFloor,
|
|
||||||
rendering: parts.rendering,
|
rendering: parts.rendering,
|
||||||
tracking: parts.tracking,
|
tracking: parts.tracking,
|
||||||
motion: parts.motion,
|
motion: parts.motion,
|
||||||
|
|||||||
@@ -1064,11 +1064,35 @@ export function createMotion({
|
|||||||
/** The display instant `epochMs` as a JulianDate, for `_motionRegime`. */
|
/** The display instant `epochMs` as a JulianDate, for `_motionRegime`. */
|
||||||
const _displayTimeAt = (epochMs, result) => julianAt(epochMs, result);
|
const _displayTimeAt = (epochMs, result) => julianAt(epochMs, result);
|
||||||
|
|
||||||
|
/** A feed fix's ECEF position, from its degrees and render altitude. */
|
||||||
|
const _fixPosition = (lonDeg, latDeg, heightM) =>
|
||||||
|
Cesium.Cartesian3.fromDegrees(lonDeg, latDeg, heightM);
|
||||||
|
|
||||||
|
/** A copy of a fix position, for a trail that keeps it. */
|
||||||
|
const _copyPosition = (position) => Cesium.Cartesian3.clone(position);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A position-history entry for a feed fix at `epochMs`, carrying the fix's
|
||||||
|
* own velocity and track; it keeps a copy of `position`.
|
||||||
|
*/
|
||||||
|
function _historyFix(epochMs, position, velocity, track) {
|
||||||
|
return {
|
||||||
|
time: julianAt(epochMs),
|
||||||
|
epochMs,
|
||||||
|
position: Cesium.Cartesian3.clone(position),
|
||||||
|
velocity,
|
||||||
|
track,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
_refloorStaleGroundedContacts,
|
_refloorStaleGroundedContacts,
|
||||||
_deadReckon,
|
_deadReckon,
|
||||||
_displayTimeAt,
|
_displayTimeAt,
|
||||||
_fixEpochMs: fixEpochMs,
|
_fixEpochMs: fixEpochMs,
|
||||||
|
_fixPosition,
|
||||||
|
_copyPosition,
|
||||||
|
_historyFix,
|
||||||
_motionRegime,
|
_motionRegime,
|
||||||
_extrapolateFix,
|
_extrapolateFix,
|
||||||
_isTrackWarmingUp,
|
_isTrackWarmingUp,
|
||||||
|
|||||||
@@ -98,7 +98,29 @@ export function createRendering({
|
|||||||
parts.icons._floorGroundedIcons(renderTime, t, nowMs, camera.positionWC),
|
parts.icons._floorGroundedIcons(renderTime, t, nowMs, camera.positionWC),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample the rendered mesh under the collected floor cells (see
|
||||||
|
* meshFloorSampler.js), leaving this layer's own icons and models out of
|
||||||
|
* the probe so it cannot land on an aircraft instead of the pavement.
|
||||||
|
*/
|
||||||
|
function _sampleMeshFloor(points, viewerLat, viewerLon) {
|
||||||
|
services.meshFloor.sampleMeshFloorCells(
|
||||||
|
flightState._viewer?.scene,
|
||||||
|
points,
|
||||||
|
{
|
||||||
|
excludeObjects: [
|
||||||
|
...parts.icons._iconIds(),
|
||||||
|
...[...flightState._models.values()].map((record) => record.model),
|
||||||
|
flightState._trackedModel?.model,
|
||||||
|
].filter(Boolean),
|
||||||
|
viewerLat,
|
||||||
|
viewerLon,
|
||||||
|
},
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
_sampleMeshFloor,
|
||||||
_fleetBillboardColor,
|
_fleetBillboardColor,
|
||||||
_fleetBillboardScale,
|
_fleetBillboardScale,
|
||||||
_cockpitContactColor,
|
_cockpitContactColor,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import * as Cesium from 'cesium';
|
import { findCamera } from '../../render/rendererOf.js';
|
||||||
import {
|
import {
|
||||||
turnRateFromFixHistory,
|
turnRateFromFixHistory,
|
||||||
liftRepeatedGroundFix,
|
liftRepeatedGroundFix,
|
||||||
@@ -6,13 +6,12 @@ import {
|
|||||||
} from '../../data/motionModel.js';
|
} from '../../data/motionModel.js';
|
||||||
import { POSITION_HISTORY_LIMIT } from './recordPolicy.js';
|
import { POSITION_HISTORY_LIMIT } from './recordPolicy.js';
|
||||||
|
|
||||||
/** Apply reconciled aircraft records to Cesium resources and follow state. */
|
/** Apply reconciled aircraft records to the layer's drawing and follow state. */
|
||||||
export function createFlightSnapshotRenderer({
|
export function createFlightSnapshotRenderer({
|
||||||
flightState,
|
flightState,
|
||||||
records,
|
records,
|
||||||
militaryRegistry,
|
militaryRegistry,
|
||||||
groundFloor,
|
groundFloor,
|
||||||
meshFloor,
|
|
||||||
rendering,
|
rendering,
|
||||||
tracking,
|
tracking,
|
||||||
motion,
|
motion,
|
||||||
@@ -22,7 +21,6 @@ export function createFlightSnapshotRenderer({
|
|||||||
}) {
|
}) {
|
||||||
const { refreshMilitaryRegistryIfStale, isMilitaryIcao } = militaryRegistry;
|
const { refreshMilitaryRegistryIfStale, isMilitaryIcao } = militaryRegistry;
|
||||||
const { warmGroundFloor } = groundFloor;
|
const { warmGroundFloor } = groundFloor;
|
||||||
const { sampleMeshFloorCells } = meshFloor;
|
|
||||||
return function applySnapshot(snapshot, viewer) {
|
return function applySnapshot(snapshot, viewer) {
|
||||||
// Before init (or after destroy) there is no icon set to draw into.
|
// Before init (or after destroy) there is no icon set to draw into.
|
||||||
if (!flightState._icons) return { count: 0, ids: new Set() };
|
if (!flightState._icons) return { count: 0, ids: new Set() };
|
||||||
@@ -31,14 +29,11 @@ export function createFlightSnapshotRenderer({
|
|||||||
// Field-test round 3 (2026-07-06, Austin fleet-underground): viewer
|
// Field-test round 3 (2026-07-06, Austin fleet-underground): viewer
|
||||||
// subpoint + collected floor cells for the viewer-proximate low-contact
|
// subpoint + collected floor cells for the viewer-proximate low-contact
|
||||||
// clamp below — one carto read per poll, one batch warm after the loop.
|
// clamp below — one carto read per poll, one batch warm after the loop.
|
||||||
const viewerCarto =
|
const pose = findCamera(viewer || flightState._viewer)?.pose() ?? null;
|
||||||
(viewer || flightState._viewer)?.camera?.positionCartographic || null;
|
const hasSubpoint =
|
||||||
const viewerLatDeg = viewerCarto
|
Number.isFinite(pose?.lat) && Number.isFinite(pose?.lon);
|
||||||
? Cesium.Math.toDegrees(viewerCarto.latitude)
|
const viewerLatDeg = hasSubpoint ? pose.lat : null;
|
||||||
: null;
|
const viewerLonDeg = hasSubpoint ? pose.lon : null;
|
||||||
const viewerLonDeg = viewerCarto
|
|
||||||
? Cesium.Math.toDegrees(viewerCarto.longitude)
|
|
||||||
: null;
|
|
||||||
const floorWarmPoints = [];
|
const floorWarmPoints = [];
|
||||||
|
|
||||||
// Classification and display policy consume source-independent observations.
|
// Classification and display policy consume source-independent observations.
|
||||||
@@ -68,7 +63,7 @@ export function createFlightSnapshotRenderer({
|
|||||||
floorWarmPoints,
|
floorWarmPoints,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
const position = Cesium.Cartesian3.fromDegrees(
|
const position = motion._fixPosition(
|
||||||
meta.rawLon,
|
meta.rawLon,
|
||||||
meta.rawLat,
|
meta.rawLat,
|
||||||
meta.renderAltitudeM,
|
meta.renderAltitudeM,
|
||||||
@@ -88,23 +83,27 @@ export function createFlightSnapshotRenderer({
|
|||||||
// 5-15s stale and receipt-time stamping is what caused the
|
// 5-15s stale and receipt-time stamping is what caused the
|
||||||
// back/forward oscillation. Only append when the fix actually
|
// back/forward oscillation. Only append when the fix actually
|
||||||
// advances, so stale repeats don't create zero-dt segments.
|
// advances, so stale repeats don't create zero-dt segments.
|
||||||
const fixTime = Cesium.JulianDate.fromDate(new Date(fixEpochMs));
|
|
||||||
if (!flightState._positionHistory.has(icao24)) {
|
if (!flightState._positionHistory.has(icao24)) {
|
||||||
flightState._positionHistory.set(icao24, []);
|
flightState._positionHistory.set(icao24, []);
|
||||||
}
|
}
|
||||||
const history = flightState._positionHistory.get(icao24);
|
const history = flightState._positionHistory.get(icao24);
|
||||||
const newest = history[history.length - 1];
|
const newest = history[history.length - 1];
|
||||||
if (!newest || Cesium.JulianDate.greaterThan(fixTime, newest.time)) {
|
// Whole milliseconds, as the fix times are kept.
|
||||||
|
if (
|
||||||
|
!newest ||
|
||||||
|
Math.trunc(fixEpochMs) > Math.trunc(motion._fixEpochMs(newest))
|
||||||
|
) {
|
||||||
// Per-fix kinematics: the fix's own velocity/track ride along so the
|
// Per-fix kinematics: the fix's own velocity/track ride along so the
|
||||||
// extrapolation paths use the values that BELONG to the fix they
|
// extrapolation paths use the values that BELONG to the fix they
|
||||||
// extend, not whatever the latest poll reported.
|
// extend, not whatever the latest poll reported.
|
||||||
history.push({
|
history.push(
|
||||||
time: fixTime,
|
motion._historyFix(
|
||||||
epochMs: fixEpochMs,
|
fixEpochMs,
|
||||||
position: position.clone(),
|
position,
|
||||||
velocity: meta.velocity,
|
meta.velocity,
|
||||||
track: meta.true_track,
|
meta.true_track,
|
||||||
});
|
),
|
||||||
|
);
|
||||||
if (history.length > POSITION_HISTORY_LIMIT) {
|
if (history.length > POSITION_HISTORY_LIMIT) {
|
||||||
history.shift();
|
history.shift();
|
||||||
}
|
}
|
||||||
@@ -117,7 +116,7 @@ export function createFlightSnapshotRenderer({
|
|||||||
// Round 2 (owner): ground traffic appends too — taxi history stays
|
// Round 2 (owner): ground traffic appends too — taxi history stays
|
||||||
// live after touchdown (grounded flights positions are already
|
// live after touchdown (grounded flights positions are already
|
||||||
// surface-clamped via the surfaceM chain, so the ground leg drapes).
|
// surface-clamped via the surfaceM chain, so the ground leg drapes).
|
||||||
if (isTracked) tracking._appendTrailFix(position.clone());
|
if (isTracked) tracking._appendTrailFix(motion._copyPosition(position));
|
||||||
} else {
|
} else {
|
||||||
const modelOwnsGroundVisual = rendering._modelOwnsVisual(icao24);
|
const modelOwnsGroundVisual = rendering._modelOwnsVisual(icao24);
|
||||||
if (!modelOwnsGroundVisual) {
|
if (!modelOwnsGroundVisual) {
|
||||||
@@ -139,7 +138,10 @@ export function createFlightSnapshotRenderer({
|
|||||||
history.push(synthetic);
|
history.push(synthetic);
|
||||||
if (history.length > POSITION_HISTORY_LIMIT) history.shift();
|
if (history.length > POSITION_HISTORY_LIMIT) history.shift();
|
||||||
meta.turnRateDps = turnRateFromFixHistory(history);
|
meta.turnRateDps = turnRateFromFixHistory(history);
|
||||||
if (isTracked) tracking._appendTrailFix(synthetic.position.clone());
|
if (isTracked)
|
||||||
|
tracking._appendTrailFix(
|
||||||
|
motion._copyPosition(synthetic.position),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -235,15 +237,7 @@ export function createFlightSnapshotRenderer({
|
|||||||
// cell, budget-capped, viewer-proximate, google-3d regime only). Own
|
// cell, budget-capped, viewer-proximate, google-3d regime only). Own
|
||||||
// billboards/models are excluded so a vertical probe can't land on an
|
// billboards/models are excluded so a vertical probe can't land on an
|
||||||
// aircraft instead of the pavement.
|
// aircraft instead of the pavement.
|
||||||
sampleMeshFloorCells(flightState._viewer?.scene, floorWarmPoints, {
|
rendering._sampleMeshFloor(floorWarmPoints, viewerLatDeg, viewerLonDeg);
|
||||||
excludeObjects: [
|
|
||||||
...icons._iconIds(),
|
|
||||||
...[...flightState._models.values()].map((record) => record.model),
|
|
||||||
flightState._trackedModel?.model,
|
|
||||||
].filter(Boolean),
|
|
||||||
viewerLat: viewerLatDeg,
|
|
||||||
viewerLon: viewerLonDeg,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Round 5: the grounded exact-key warm that used to live here is gone —
|
// Round 5: the grounded exact-key warm that used to live here is gone —
|
||||||
// see the note where _warmGroundedAircraftSurfaceCache was removed. The
|
// see the note where _warmGroundedAircraftSurfaceCache was removed. The
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
"src/layers/flights/policy.js",
|
"src/layers/flights/policy.js",
|
||||||
"src/layers/flights/queries.js",
|
"src/layers/flights/queries.js",
|
||||||
"src/layers/flights/rendering.js",
|
"src/layers/flights/rendering.js",
|
||||||
"src/layers/flights/snapshotRenderer.js",
|
|
||||||
"src/layers/flights/state.js",
|
"src/layers/flights/state.js",
|
||||||
"src/layers/flights/testing.js",
|
"src/layers/flights/testing.js",
|
||||||
"src/layers/flights/tracking.js",
|
"src/layers/flights/tracking.js",
|
||||||
|
|||||||
Reference in new issue
Block a user