mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 17:22:19 +00:00
Merge remote-tracking branch 'origin/main' into selection/no-tint
This commit is contained in:
commit
dc9b1042df
11 files changed
+377
-15
No files matched your search
@@ -349,6 +349,8 @@ export function createMotion({
|
||||
const sameTrack =
|
||||
flightState._drReconcileValid && flightState._drReconcileIcao === icao24;
|
||||
const raw = _deadReckon(icao24, flightState._scratchDrRaw);
|
||||
flightState._cachedDRPlaced =
|
||||
Boolean(raw) && flightState._drSpeedPlaced === true;
|
||||
flightState._cachedDRCourse = flightState._drCourseDeg;
|
||||
flightState._cachedDRSpeedMps = flightState._drSpeedMps;
|
||||
flightState._cachedDRHold = flightState._drCourseHold;
|
||||
@@ -475,6 +477,16 @@ export function createMotion({
|
||||
* later in the frame, so recomputing _trackedDisplayPosition there jitters the label against the
|
||||
* now-stable plane. Null when no valid fix (callers fall back to the icon position). */
|
||||
|
||||
/** Whether a host-supplied placement placed the tracked aircraft where
|
||||
* `_trackedDisplayCached` holds it this frame, rather than this layer's
|
||||
* own motion at its display delay. */
|
||||
|
||||
function _trackedPlaced() {
|
||||
return (
|
||||
_trackedDisplayCached() !== null && flightState._cachedDRPlaced === true
|
||||
);
|
||||
}
|
||||
|
||||
function _trackedDisplayCached() {
|
||||
return flightState._drReconcileValid &&
|
||||
flightState._drReconcileIcao === flightState._trackedIcao
|
||||
@@ -697,6 +709,7 @@ export function createMotion({
|
||||
_trackedFocusSizePx,
|
||||
_trackedDisplayPosition,
|
||||
_trackedDisplayCached,
|
||||
_trackedPlaced,
|
||||
_trackedVisualCached,
|
||||
_trackedModelCenterWorld,
|
||||
_trackedModelEnvelopeM,
|
||||
|
||||
@@ -236,6 +236,12 @@ export function createFlightState({ source, services }) {
|
||||
|
||||
flightState._drSpeedPlaced = false;
|
||||
|
||||
/** Sibling of `_cachedDRPosition`: whether a host-supplied placement placed
|
||||
* it (`_drSpeedPlaced` as the tracked aircraft was drawn), so its trail
|
||||
* ends where it is drawn rather than at the layer's display delay. */
|
||||
|
||||
flightState._cachedDRPlaced = false;
|
||||
|
||||
flightState._drCourseHold = false;
|
||||
|
||||
/** Set by `_deadReckon`: following the clock, the time drawn is well
|
||||
|
||||
@@ -48,6 +48,7 @@ import {
|
||||
trailBodySegments,
|
||||
trailHeadCurvePoints,
|
||||
trailHeadStartFix,
|
||||
trailTimeAt,
|
||||
} from '../../data/trailContinuity.js';
|
||||
import { roundHeadingDegrees } from '../../data/headingDegrees.js';
|
||||
import { entityRecord } from '../../data/entityRecords.js';
|
||||
@@ -612,12 +613,46 @@ export function createTracking({
|
||||
);
|
||||
}
|
||||
|
||||
/** Reports at or before the time the aircraft is drawn (now − the display delay). */
|
||||
/** Reports at or before the time the aircraft is drawn (`_trailDisplayMs`). */
|
||||
|
||||
function _trailBodyCountNow() {
|
||||
return trailBodyCount(
|
||||
return trailBodyCount(flightState._trailFixes, _trailDisplayMs());
|
||||
}
|
||||
|
||||
/**
|
||||
* The time on its trail at which a host-supplied placement draws the
|
||||
* aircraft, read off the trail where it is drawn (`trailTimeAt`): such a
|
||||
* placement draws at a delay of its own, not this layer's. NaN when this
|
||||
* layer's own motion draws it, or the trail has no pair to read.
|
||||
* @returns {number} Epoch ms or NaN.
|
||||
*/
|
||||
function _placedTrailMs() {
|
||||
if (!parts.motion._trackedPlaced?.()) return NaN;
|
||||
return trailTimeAt(
|
||||
flightState._trailFixes,
|
||||
flightState.now() - displayDelayMs(flightState),
|
||||
parts.motion._trackedDisplayCached(),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The time the trail runs up to: the time the aircraft is drawn at, now −
|
||||
* the display delay, or where a placement draws it. Otherwise the trail
|
||||
* ends short of a placed aircraft, or runs on ahead of it.
|
||||
* @returns {number} Epoch ms.
|
||||
*/
|
||||
function _trailDisplayMs() {
|
||||
const placedMs = _placedTrailMs();
|
||||
return Number.isFinite(placedMs)
|
||||
? placedMs
|
||||
: flightState.now() - displayDelayMs(flightState);
|
||||
}
|
||||
|
||||
/** Whether the trail holds no report behind the aircraft yet: this
|
||||
* layer's own motion draws it before its oldest fix. Never for an
|
||||
* aircraft a placement draws: its trail is read where it is drawn. */
|
||||
function _trailWarmingUp() {
|
||||
return (
|
||||
!Number.isFinite(_placedTrailMs()) && parts.motion._isTrackWarmingUp()
|
||||
);
|
||||
}
|
||||
|
||||
@@ -634,7 +669,7 @@ export function createTracking({
|
||||
if (
|
||||
!flightState._trackedIcao ||
|
||||
!flightState._trailFixes.length ||
|
||||
parts.motion._isTrackWarmingUp()
|
||||
_trailWarmingUp()
|
||||
)
|
||||
return [];
|
||||
const head =
|
||||
@@ -662,7 +697,7 @@ export function createTracking({
|
||||
trailHeadCurvePoints(
|
||||
flightState._trailFixes,
|
||||
flightState._trailBodyCount,
|
||||
flightState.now() - displayDelayMs(flightState),
|
||||
_trailDisplayMs(),
|
||||
),
|
||||
end,
|
||||
parts.motion._trackedModelCenterWorld(),
|
||||
|
||||
@@ -65,7 +65,15 @@ function recordingTrail() {
|
||||
};
|
||||
}
|
||||
|
||||
function trackedHarness({ liveFixes = [], trace = null, nowMs, floor, head }) {
|
||||
function trackedHarness({
|
||||
liveFixes = [],
|
||||
trace = null,
|
||||
nowMs,
|
||||
floor,
|
||||
head,
|
||||
placed = false,
|
||||
warmingUp = false,
|
||||
}) {
|
||||
const trail = recordingTrail();
|
||||
const svc = services({ trails: trail, floor });
|
||||
const flightState = createFlightState({
|
||||
@@ -104,7 +112,9 @@ function trackedHarness({ liveFixes = [], trace = null, nowMs, floor, head }) {
|
||||
services: svc,
|
||||
parts: {
|
||||
motion: {
|
||||
_isTrackWarmingUp: () => false,
|
||||
_isTrackWarmingUp: () => warmingUp,
|
||||
_trackedPlaced: () => placed,
|
||||
_trackedDisplayCached: () => head ?? null,
|
||||
_trackedTrailCached: () => head ?? null,
|
||||
_trackedDisplayPosition: () => head ?? null,
|
||||
_trackedModelCenterWorld: () => null,
|
||||
@@ -256,3 +266,36 @@ test('a full 24 h military trace fits within TRAIL_MAX_POINTS without thinning',
|
||||
assert.ok(TRAIL_MAX_POINTS >= day + 500);
|
||||
assert.equal(flightState._trailFixes.length, day + 1);
|
||||
});
|
||||
|
||||
test('a placed military aircraft drawn ahead of the display delay keeps its trail joined to it', () => {
|
||||
const t0 = Date.UTC(2026, 10, 8, 0, 0);
|
||||
const liveFixes = [0, 1, 2, 3].map((i) => ({
|
||||
timeMs: t0 + i * MINUTE,
|
||||
lat: 50,
|
||||
lon: 1 + i * 0.12,
|
||||
}));
|
||||
// Warming up by the layer's own delay; the placement draws it between the
|
||||
// third and fourth reports.
|
||||
const near = Cesium.Cartesian3.fromDegrees(1.3, 50, 9_000);
|
||||
const harness = trackedHarness({
|
||||
liveFixes,
|
||||
nowMs: t0 + 3.5 * MINUTE,
|
||||
head: near,
|
||||
placed: true,
|
||||
warmingUp: true,
|
||||
});
|
||||
harness.flightState._displayDelay = { currentMs: 10 * MINUTE };
|
||||
harness.tracking._startTrail('ae0001');
|
||||
const body = harness.trail.last()[0];
|
||||
assert.equal(harness.trail.last().length, 1);
|
||||
assert.ok(
|
||||
Cesium.Cartesian3.distance(
|
||||
body[body.length - 1],
|
||||
Cesium.Cartesian3.fromDegrees(1.24, 50, 9_000),
|
||||
) < 1,
|
||||
);
|
||||
const drawn = harness.headPositions();
|
||||
assert.ok(drawn.length >= 2);
|
||||
assert.ok(Cesium.Cartesian3.distance(drawn[0], body[body.length - 1]) < 1);
|
||||
assert.ok(Cesium.Cartesian3.distance(drawn[drawn.length - 1], near) < 1);
|
||||
});
|
||||
Reference in new issue
Block a user