mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-17 00:32:21 +00:00
Grounded aircraft turn 3D on the first settled frame: streaming tiles are not a miss. groundSnap's tests keep main's cases against the branch's query port; trackedModelForm.test.mjs (the branch's form of trackedModelRegime.test.mjs) takes main's edits.
This commit is contained in:
commit
4b0958b9e8
5 files changed
+111
-56
No files matched your search
@@ -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
|
||||
@@ -124,7 +129,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;
|
||||
@@ -327,7 +332,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;
|
||||
const at = toLonLatH(pos);
|
||||
const exclude = Array.isArray(exclusions?.sets)
|
||||
|
||||
@@ -18,7 +18,8 @@ function makeViewer() {
|
||||
const calls = { samples: 0 };
|
||||
const tileset = { show: true, tilesLoaded: true };
|
||||
const asked = [];
|
||||
const viewer = { calls, tileset, asked, surfaceLoaded: true };
|
||||
const ground = { heightM: 1650 };
|
||||
const viewer = { calls, tileset, asked, ground, surfaceLoaded: true };
|
||||
bindRenderer(viewer, {
|
||||
globe: {
|
||||
isSettled: (kind) =>
|
||||
@@ -30,7 +31,7 @@ function makeViewer() {
|
||||
sampleHeightNow(point, options) {
|
||||
calls.samples += 1;
|
||||
asked.push({ point, options });
|
||||
return 1650;
|
||||
return ground.heightM;
|
||||
},
|
||||
},
|
||||
});
|
||||
@@ -60,15 +61,35 @@ test('a retry backoff stamped before the clock stepped back does not wait for it
|
||||
const viewer = makeViewer();
|
||||
const { tileset } = viewer;
|
||||
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;
|
||||
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);
|
||||
});
|
||||
|
||||
@@ -160,3 +181,58 @@ test('through the Cesium globe port, a streaming tileset the port did not load h
|
||||
assert.equal(later.heightFor(viewer, 'a00001', atDenverAirport), 1650);
|
||||
assert.equal(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;
|
||||
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 = 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;
|
||||
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