Keep the range ring's 80 ms step while a drag wakes its pulses

A user's drag woke the pulses on every frame it drew, and each wake
stepped the fronts at once without noting the step, so a drag stepped
every frame and some frames twice. A wake now starts resting pulses at
once and leaves running ones to their Cyber sonar interval; a subject
move that steps notes it too.
This commit is contained in:
Sameh Khamis committed 2026-11-10 09:45:49 -08:00
1 parent 3f194d0eec
commit ac0496a785
2 files changed
+16 -4

No files matched your search

+10 -4
View File
@@ -338,13 +338,18 @@ export function createRangeRing({
/**
* Run the range pulses again for `activeMs`, after a camera move. Call it
* during a frame (lifecycle's preRender): that frame's postRender arms the
* next request, so waking asks for no extra frame of its own.
* next request, so waking asks for no extra frame of its own. Pulses at
* rest start in this frame; running ones keep their Cyber sonar interval,
* however many frames a drag draws.
*/
function wakePulses() {
const visual = layerState.visual;
if (!visual?.wake) return;
wakeAwarenessPulses(visual.wake, performance.now());
visual.step(performance.now());
const nowMs = performance.now();
wakeAwarenessPulses(visual.wake, nowMs);
if (nowMs - visual.lastStepMs < CYBER_SONAR_RENDER_INTERVAL_MS) return;
visual.lastStepMs = nowMs;
visual.step(nowMs);
}
function clearVisual() {
@@ -399,7 +404,8 @@ export function createRangeRing({
AWARENESS_RADIUS_M,
CONTEXT_RIM_HEIGHT_M,
);
visual.step(performance.now());
visual.lastStepMs = performance.now();
visual.step(visual.lastStepMs);
// Content actually changed — buy exactly one frame instead of holding.
governorRequestRender('awareness-visual');
}
+6
View File
@@ -541,6 +541,12 @@ test('a pulse frame draws the step made before it was asked for; a moving camera
}
assert.equal(steps, 0);
assert.equal(drawn(ring).band.fill.image.key, bandKey);
// Nor do frames a user's drag draws, each waking the running pulses.
for (let i = 0; i < 3; i++) {
rendering.wakePulses();
loop.draw();
}
assert.equal(steps, 0, 'a drag keeps the interval');
// Crossing below the rim height hides them at once, interval or not.
state.viewer.camera.positionCartographic = { height: 1_000 };
loop.draw();