mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Merge pull request #1758 from bilawalsidhu/flights/ground-models-at-once
Grounded aircraft turn 3D as soon as the tiles settle
This commit is contained in:
5 files changed
+111
-33
No files matched your search
@@ -0,0 +1,3 @@
|
||||
### Fixed
|
||||
|
||||
- A grounded aircraft turns from its icon into its 3D model as soon as the 3D tiles under it have loaded. Tiles still streaming no longer count as a failed ground sample, so after a pan the models no longer appear late and in batches, up to half a minute after the view settled.
|
||||
@@ -7661,7 +7661,7 @@ pins and share links already supply complete boxes.
|
||||
### 3D Aircraft + Tracking (June 2026)
|
||||
|
||||
- **The TRACKED contact's 2D↔3D handoff is DEFAULT behaviour (2026-08-19), driven by camera distance alone.** It does NOT consult the DISPLAY-rail `3D` toggle, which continues to own the FLEET (the un-instanced draw-call budget stays the operator's decision). Policy lives in `src/data/trackedModelRegime.js` and is shared by both layers: enter below `TRACKED_MODEL_ENTER_ALT_M` = 150,000 m and hand back to the billboard only above `TRACKED_MODEL_EXIT_ALT_M` = 172,500 m. **The swap distance was set by playtesting on 2026-08-20:** a first pass at 1,000,000 m switched too early; 2D reads correctly at ~600 km and the handoff belongs at ~150 km. **Consequence, recorded on purpose:** the tracked contact now enters 3D NEARER than the FLEET does (`MODEL_ALT_CEIL_M` = 800,000 m, unchanged), so with the DISPLAY-rail `3D` toggle on, 150–800 km draws surrounding contacts as models while the selected one is still a glyph. Nothing double-draws (the fleet pass skips the tracked icao) and aligning the two is a fleet-side decision, deliberately out of scope. **The two thresholds are asymmetric on purpose:** a single threshold makes a tracked orbit sitting ON the boundary strobe billboard↔model as the camera's altitude wobbles across it. Do not collapse them. The latch is scoped per selection, so a new target re-evaluates against the ENTER ceiling rather than inheriting the previous target's exit band. Exactly ONE model is involved; it loads on demand when the regime opens, is HIDDEN (not released) on regime exit so re-entry has no load gap, and is released by the existing teardown on deselect/re-track/destroy. Cockpit and TR-3B suppression are unchanged. **Two invariants around it:** (a) the hysteresis latch AND the load-failure latch are per-selection state cleared by `_resetTrackedSelectionState()` in the tracking lifecycle (deselect / re-track / cross-layer / init / destroy) — the predicate's icao-change guard is defence only, since it needs a drawn frame while nothing is selected and the render governor's idle mode does not promise one; (b) on-demand loading is bounded at 3 attempts per selection with a 1.5 s backoff and one console warning naming the asset — the driver runs every `scene.preUpdate`, so an unbounded catch means a missing GLB spins load→reject at frame rate. The billboard stays the visual throughout a failed load.
|
||||
- **Grounded 3D handoff is terrain-validity gated (2026-08-23).** A ready civilian or military glTF does not own the visual until `groundSnap` (`src/data/groundSnap.js`) can answer with a MEASURED photoreal-surface height. On success the layer writes `height + the model's measured belly offset` before revealing the model. Cache movement is measured on the WGS84 surface, not across altitude, so a stationary contact keeps its snap through poll-time vertical-datum changes. Model existence or GPU readiness alone never suppresses the billboard floor, and ordinary zoom/style/deselect transitions preserve a valid snap cache. **Two states, and the difference is the whole design.** COLD — nothing has ever resolved for this icao (tiles still streaming on first sight, sample failure, backoff after a first miss): there is no evidence of where the ground is, `heightFor` returns null, the model stays hidden and the depth-test-free 2D billboard remains opaque and floored. WARM — a snap resolved and then a >`MOVE_INVALIDATE_M` (50 m) taxi move stopped it answering directly: the measurement is DEMOTED to a bounded last-known rather than deleted, and it keeps answering while the resample is outstanding, so a taxiing aircraft does not pop 3D→2D→3D across a 2–30 s retry backoff. The bound is `HELD_SNAP_MAX_DRIFT_M` = 250 m from the spot the value was measured at, past which the hold is dropped rather than stretched and the contact is COLD again. It is spatial with no timer beside it (ground under a contact that has not moved does not change; what invalidates the value is the contact MOVING) and deliberately a quarter of the billboard chain's `HELD_FLOOR_MAX_DRIFT_KM` — that hold only ever RAISES a sprite, while a held snap IS the model's placement, so its error shows in both directions. A fresh sample releases the hold, and so does a ground flip (which already calls `forget`). **A loading model is HIDDEN, never zero-scaled:** admission sets `show = false` (Cesium's default is `true`, and an unplaced primitive would claim the visual at the identity matrix), and ownership is `ready && show` — Cesium 1.138's `Model.update` has no `show` guard, so hiding a primitive costs its load nothing.
|
||||
- **Grounded 3D handoff is terrain-validity gated (2026-08-23).** A ready civilian or military glTF does not own the visual until `groundSnap` (`src/data/groundSnap.js`) can answer with a MEASURED photoreal-surface height. On success the layer writes `height + the model's measured belly offset` before revealing the model. Cache movement is measured on the WGS84 surface, not across altitude, so a stationary contact keeps its snap through poll-time vertical-datum changes. Model existence or GPU readiness alone never suppresses the billboard floor, and ordinary zoom/style/deselect transitions preserve a valid snap cache. **Two states, and the difference is the whole design.** COLD — nothing has ever resolved for this icao (tiles still streaming on first sight, sample failure, backoff after a first miss): there is no evidence of where the ground is, `heightFor` returns null, the model stays hidden and the depth-test-free 2D billboard remains opaque and floored. Tiles still streaming is not a miss: no sample is taken, so it earns no retry backoff, and the first fleet tick after the tiles settle samples (2026-11-15); only a sample that finds no ground backs off (2 s, doubling to 30 s). WARM — a snap resolved and then a >`MOVE_INVALIDATE_M` (50 m) taxi move stopped it answering directly: the measurement is DEMOTED to a bounded last-known rather than deleted, and it keeps answering while the resample is outstanding, so a taxiing aircraft does not pop 3D→2D→3D across a 2–30 s retry backoff. The bound is `HELD_SNAP_MAX_DRIFT_M` = 250 m from the spot the value was measured at, past which the hold is dropped rather than stretched and the contact is COLD again. It is spatial with no timer beside it (ground under a contact that has not moved does not change; what invalidates the value is the contact MOVING) and deliberately a quarter of the billboard chain's `HELD_FLOOR_MAX_DRIFT_KM` — that hold only ever RAISES a sprite, while a held snap IS the model's placement, so its error shows in both directions. A fresh sample releases the hold, and so does a ground flip (which already calls `forget`). **A loading model is HIDDEN, never zero-scaled:** admission sets `show = false` (Cesium's default is `true`, and an unplaced primitive would claim the visual at the identity matrix), and ownership is `ready && show` — Cesium 1.138's `Model.update` has no `show` guard, so hiding a primitive costs its load nothing.
|
||||
- **Ground-snap clock rollback recovery.** If the wall clock moves before the
|
||||
sampling-window start, ground snap opens a new window while retaining the
|
||||
normal four-samples-per-250-ms budget. Retry timestamps more than the maximum
|
||||
|
||||
@@ -373,16 +373,12 @@ for (const fixture of LAYERS) {
|
||||
assert.ok(model.show || billboard.show, 'the contact never has both visuals hidden');
|
||||
assert.equal(sampleCalls, 0, 'cold tiles do not force sampleHeight');
|
||||
|
||||
now += 1000;
|
||||
// Streaming tiles are not a miss, so they earn no retry backoff: the
|
||||
// first frame after the tiles settle samples and hands over.
|
||||
now += 100;
|
||||
viewer.tileset.tilesLoaded = true;
|
||||
ownsVisual = fixture.driveFleetModel({ icao24, position, course: 92 });
|
||||
assert.equal(ownsVisual, false, 'the miss backoff remains in force before two seconds');
|
||||
assert.equal(sampleCalls, 0, 'backoff prevents an early synchronous sample');
|
||||
assert.ok(model.show || billboard.show, 'backoff still leaves a visible owner');
|
||||
|
||||
now += 1500;
|
||||
ownsVisual = fixture.driveFleetModel({ icao24, position, course: 92 });
|
||||
assert.equal(ownsVisual, true, 'the model takes over after a valid terrain sample');
|
||||
assert.equal(ownsVisual, true, 'the model takes over on the first settled frame');
|
||||
assert.equal(sampleCalls, 1, 'the settled terrain is sampled exactly once');
|
||||
assert.equal(model.show, true);
|
||||
assert.equal(billboard.show, false);
|
||||
@@ -403,13 +399,13 @@ for (const fixture of LAYERS) {
|
||||
// Taxi past the 50 m resample threshold while the tiles are gone. The old
|
||||
// snap stops being the direct answer, but it is still a MEASUREMENT of
|
||||
// ground this contact was standing on ~96 m ago, so it is held: hiding the
|
||||
// model here would pop a taxiing aircraft from 3D to 2D for a whole retry
|
||||
// backoff (2–30 s), which is the one thing the gate must not introduce.
|
||||
// model here would pop a taxiing aircraft from 3D to 2D until the tiles
|
||||
// return, which is the one thing the gate must not introduce.
|
||||
const taxied = Cesium.Cartesian3.fromDegrees(-97.709, 30.21, -500);
|
||||
ownsVisual = fixture.driveFleetModel({ icao24, position: taxied, course: 92 });
|
||||
assert.equal(ownsVisual, true,
|
||||
'a taxi-invalidated snap is HELD through the resample outage, not dropped');
|
||||
assert.equal(model.show, true, 'no 3D→2D pop while the resample is backing off');
|
||||
assert.equal(model.show, true, 'no 3D→2D pop while the resample waits for tiles');
|
||||
assert.equal(billboard.show, false);
|
||||
assert.equal(sampleCalls, 1, 'and the hold costs no extra synchronous sample');
|
||||
const held = Cesium.Matrix4.getTranslation(model.modelMatrix, new Cesium.Cartesian3());
|
||||
@@ -646,17 +642,11 @@ for (const fixture of LAYERS) {
|
||||
1e-6,
|
||||
), 'a hidden tracked model cannot steal the proximity position');
|
||||
|
||||
now += 1000;
|
||||
// Streaming tiles earned no backoff, so the first settled turn samples.
|
||||
now += 100;
|
||||
viewer.tileset.tilesLoaded = true;
|
||||
sampledHeight = 187.5;
|
||||
fixture.driveTrackedModel();
|
||||
assert.equal(sampleCalls, 0, 'the tracked path honors the same retry backoff before sampling');
|
||||
assert.equal(model.show, false, 'retry backoff keeps the unplaced primitive hidden');
|
||||
assert.equal(fixture.trackedBillboardColor().alpha, 1,
|
||||
'retry backoff leaves the tracked billboard opaque');
|
||||
|
||||
now += 1500;
|
||||
fixture.driveTrackedModel();
|
||||
assert.equal(sampleCalls, 1, 'the first settled turn samples once');
|
||||
assert.equal(model.show, false, 'terrain alone does not reveal an unready model');
|
||||
assert.equal(fixture.trackedBillboardColor().alpha, 1,
|
||||
@@ -683,7 +673,7 @@ for (const fixture of LAYERS) {
|
||||
|
||||
// Taxi past the resample threshold with the tiles gone: the tracked model
|
||||
// holds its last measured floor rather than handing the operator's own
|
||||
// selection back to a 2D glyph for a retry backoff.
|
||||
// selection back to a 2D glyph until the tiles return.
|
||||
billboard.position = Cesium.Cartesian3.fromDegrees(-97.709, 30.21, -500);
|
||||
fixture.driveTrackedModel();
|
||||
assert.equal(model.show, true,
|
||||
|
||||
@@ -11,11 +11,16 @@
|
||||
* Discipline (CCTV-B9b style): scene.sampleHeight forces a synchronous offscreen
|
||||
* pick render, so it is NEVER called per frame. Each grounded modeled plane gets
|
||||
* ONE successful sample, cached per icao; the cache stops answering directly when
|
||||
* the plane moves >MOVE_INVALIDATE_M from the sampled spot (taxiing). Misses (tiles
|
||||
* still streaming, OSM fallback with no tileset skin, sample outside loaded
|
||||
* geometry) are a retry-later signal with per-icao exponential backoff. A
|
||||
* per-window budget stops a freshly modeled airport cluster from firing dozens of
|
||||
* pick renders in one fleet tick.
|
||||
* the plane moves >MOVE_INVALIDATE_M from the sampled spot (taxiing). A sample
|
||||
* that misses (OSM fallback with no tileset skin, sample outside loaded
|
||||
* geometry) is a retry-later signal with per-icao exponential backoff. Tiles
|
||||
* still streaming is not a miss: no sample was taken, so it earns no backoff
|
||||
* and the plane asks again on the next tick, sampling as soon as the tiles
|
||||
* settle. Counting it as a miss had every grounded plane in view back off to
|
||||
* RETRY_MAX_MS while the camera moved, then wait out that backoff after the
|
||||
* tiles had loaded, so models replaced icons late and in batches. A per-window
|
||||
* budget stops a freshly modeled airport cluster from firing dozens of pick
|
||||
* renders in one fleet tick.
|
||||
*
|
||||
* What a caller gets while a sample is outstanding depends on whether this
|
||||
* contact has ever HAD one, and the difference is the difference between two
|
||||
@@ -121,7 +126,7 @@ const HELD_SNAP_MAX_DRIFT_M = 250;
|
||||
* alternative because it errs UPWARD and stays visible, where a buried model
|
||||
* errs into the terrain and cannot be seen at all. */
|
||||
const HELD_SNAP_CONTRADICTION_M = 5;
|
||||
/** First retry delay after a miss / tiles-not-ready (ms); doubles per consecutive miss. */
|
||||
/** First retry delay after a sample finds no ground (ms); doubles per consecutive miss. */
|
||||
const RETRY_BASE_MS = 2000;
|
||||
/** Backoff cap (ms) — on the OSM fallback (no tile skin) sampleHeight misses forever. */
|
||||
const RETRY_MAX_MS = 30000;
|
||||
@@ -345,7 +350,10 @@ export function createGroundSnap({ groundFloor }) {
|
||||
entries.set(icao, next);
|
||||
return heldSnapM(next, surfacePos);
|
||||
};
|
||||
if (!_tilesReady(viewer)) return miss();
|
||||
// Tiles still streaming: no sample is taken, so no backoff is earned (as
|
||||
// with the budget above). The next tick asks again, and the first one after
|
||||
// the tiles settle samples.
|
||||
if (!_tilesReady(viewer)) return heldSnapM(entry, surfacePos);
|
||||
windowCount += 1;
|
||||
let sampled;
|
||||
try {
|
||||
|
||||
@@ -13,13 +13,15 @@ const groundFloor = {
|
||||
function makeViewer() {
|
||||
const calls = { samples: 0 };
|
||||
const tileset = { show: true, tilesLoaded: true };
|
||||
const ground = { heightM: 1650 };
|
||||
return {
|
||||
calls,
|
||||
ground,
|
||||
scene: {
|
||||
primitives: { length: 1, get: () => tileset },
|
||||
sampleHeight() {
|
||||
calls.samples += 1;
|
||||
return 1650;
|
||||
return ground.heightM;
|
||||
},
|
||||
globe: { getHeight: () => 1600 },
|
||||
},
|
||||
@@ -49,14 +51,89 @@ test('a retry backoff stamped before the clock stepped back does not wait for it
|
||||
const viewer = makeViewer();
|
||||
const tileset = viewer.scene.primitives.get(0);
|
||||
const snap = createGroundSnap({ groundFloor });
|
||||
// Tiles still streaming: a miss, backed off for 2 s.
|
||||
tileset.tilesLoaded = false;
|
||||
// A sample that finds no ground: a miss, backed off for 2 s.
|
||||
viewer.ground.heightM = undefined;
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), null);
|
||||
tileset.tilesLoaded = true;
|
||||
viewer.ground.heightM = 1650;
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), null);
|
||||
assert.equal(viewer.calls.samples, 0, 'the backoff holds');
|
||||
assert.equal(viewer.calls.samples, 1, 'the backoff holds');
|
||||
// The clock steps back an hour: the stamp is an hour off, past any backoff.
|
||||
t.mock.timers.setTime(10_000_000 - 3_600_000);
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), 1650);
|
||||
assert.equal(viewer.calls.samples, 2);
|
||||
});
|
||||
|
||||
test('tiles still streaming earn no backoff: the first tick after they settle samples', (t) => {
|
||||
t.mock.timers.enable({ apis: ['Date'], now: 20_000_000 });
|
||||
const viewer = makeViewer();
|
||||
const tileset = viewer.scene.primitives.get(0);
|
||||
const snap = createGroundSnap({ groundFloor });
|
||||
// The camera moves for 40 s: tiles stream the whole time, and the aircraft
|
||||
// asks on every tick.
|
||||
tileset.tilesLoaded = false;
|
||||
for (let ms = 0; ms <= 40_000; ms += 100) {
|
||||
t.mock.timers.setTime(20_000_000 + ms);
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), null);
|
||||
}
|
||||
assert.equal(viewer.calls.samples, 0, 'nothing samples while tiles stream');
|
||||
// The tiles settle: the very next tick samples, with no backoff to wait out.
|
||||
tileset.tilesLoaded = true;
|
||||
t.mock.timers.setTime(20_000_000 + 40_100);
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), 1650);
|
||||
assert.equal(viewer.calls.samples, 1);
|
||||
});
|
||||
|
||||
test('a held measurement still answers while tiles stream', (t) => {
|
||||
t.mock.timers.enable({ apis: ['Date'], now: 30_000_000 });
|
||||
const viewer = makeViewer();
|
||||
const tileset = viewer.scene.primitives.get(0);
|
||||
const snap = createGroundSnap({ groundFloor });
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), 1650);
|
||||
// Taxi 100 m: the snap is demoted to a held value and a resample is due,
|
||||
// but the tiles are streaming. The held value answers.
|
||||
tileset.tilesLoaded = false;
|
||||
const taxied = Cesium.Cartesian3.fromDegrees(-104.6737, 39.857, 0);
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', taxied), 1650);
|
||||
assert.equal(viewer.calls.samples, 1);
|
||||
// Tiles settle: the resample runs at once and answers fresh.
|
||||
viewer.ground.heightM = 1652;
|
||||
tileset.tilesLoaded = true;
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', taxied), 1652);
|
||||
assert.equal(viewer.calls.samples, 2);
|
||||
});
|
||||
|
||||
test('a sample that finds no ground still backs off', (t) => {
|
||||
t.mock.timers.enable({ apis: ['Date'], now: 40_000_000 });
|
||||
const viewer = makeViewer();
|
||||
const snap = createGroundSnap({ groundFloor });
|
||||
viewer.ground.heightM = undefined;
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), null);
|
||||
t.mock.timers.setTime(40_000_000 + 1_000);
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), null);
|
||||
assert.equal(viewer.calls.samples, 1, 'inside the 2 s backoff');
|
||||
t.mock.timers.setTime(40_000_000 + 2_001);
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), null);
|
||||
assert.equal(viewer.calls.samples, 2, 'retried once the backoff ended');
|
||||
});
|
||||
|
||||
test('streaming tiles after a real miss leave its backoff as it was', (t) => {
|
||||
t.mock.timers.enable({ apis: ['Date'], now: 50_000_000 });
|
||||
const viewer = makeViewer();
|
||||
const tileset = viewer.scene.primitives.get(0);
|
||||
const snap = createGroundSnap({ groundFloor });
|
||||
// One real miss: backed off for 2 s.
|
||||
viewer.ground.heightM = undefined;
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), null);
|
||||
// Tiles stream on every tick of that backoff and past it.
|
||||
tileset.tilesLoaded = false;
|
||||
for (let ms = 100; ms <= 3_000; ms += 100) {
|
||||
t.mock.timers.setTime(50_000_000 + ms);
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), null);
|
||||
}
|
||||
// They settle 3 s in: still the first 2 s backoff, not a doubled 4 s one.
|
||||
viewer.ground.heightM = 1650;
|
||||
tileset.tilesLoaded = true;
|
||||
t.mock.timers.setTime(50_000_000 + 3_100);
|
||||
assert.equal(snap.heightFor(viewer, 'a00001', atDenverAirport), 1650);
|
||||
assert.equal(viewer.calls.samples, 2);
|
||||
});
|
||||
Reference in new issue
Block a user