Step the range ring's fronts and band on the Cyber sonar interval while the camera moves

The fronts and band are fixed in the world, so a camera move needs nothing
of them: they now step 80 ms apart however many frames are drawn, as a
parked view's do, and look the same moving or parked. Each frame checks
only whether the camera crossed the rim height, which shows or hides them
at once.
This commit is contained in:
Sameh Khamis committed 2026-11-10 08:07:22 -08:00
1 parent e4af6c8ed7
commit 3bca55831f
4 files changed
+36 -40

No files matched your search

+1 -1
View File
@@ -5798,7 +5798,7 @@ silently demoting every later lookup for the session.
- On activation it focuses the nearest currently observed aircraft across the civilian and military feeds, with military winning an exact distance tie; if none are available, it focuses an observed AIS vessel. The aircraft search is deliberately uncapped and one refresh-tick retry handles initially empty feeds. This is an attention-priority navigation shortcut, not a high-risk, affiliation, or threat classification.
- A selected aircraft, AIS vessel, or mapped installation gets a 250 km **context window** with nearby cohort counts, nearest examples, source labels, and stale/unavailable reasons. It emits `NEARBY` or `UNKNOWN`; no detection, engagement, affiliation, or sensor-activity conclusion is calculated.
- Contacts rows and the Cockpit Contact counts name each cohort's provider: the source of the last snapshot, marked `FALLBACK` or `STALE` as its layer row would be. A poll in flight keeps the mark, where the layer row shows `LOADING`. A flight snapshot from the adsb.lol regional fallback reads `adsb.lol · FALLBACK`, not `OpenSky`.
- The window's edge is drawn on the globe as a 250 km range ring: a 4 px polyline with a 2 px Context-blue core inside a 1 px dark halo on each side, 2.5 km above the ellipsoid (`AWARENESS_RANGE_RING_STYLE` in `src/layers/awareness/policy.js`). The halo keeps it legible over bright desert and snow, dark ocean and forest, and under the FLIR, NVG and CRT styles, where the earlier 1 px ellipse outline disappeared. It is one outlined line in an unpickable draw-port line set (`src/layers/awareness/rangeRing.js`), so a click or tap on its edge reaches the contact underneath; the halo is the line's own outline, so the translucent core and halo never darken where they meet; it moves when the subject moves. Three dim sonar pulses (3 px with a dark edge half a pixel wide on each side, same colours, at most 60% opacity), each an outlined line in the same set, grow slowly from the subject at constant speed, one every 3 s and each taking 9 s, and arrive at the ring at about a third of that. Behind each pulse a radial gradient in the same blue fades inward over 35% of the radius: one unpickable flat ellipse 2.5 km up with 270 km semi-axes, filled with a 256-pixel canvas painted with the band (two canvases in turn, each under a new key). The ellipse stands until the subject has moved 20 km from where it was built, the canvas keeping the band concentric with the subject meanwhile, and not at all while the pulses rest. The fronts move on every frame the camera moves in (and every frame while something holds continuous rendering); the soft band is repainted at most every 80 ms. While the camera is below the band's 2.5 km height, where it would sweep across the sky, the pulses rest: the band and fronts are hidden and there is no ring flash, no echo and no frame request. Terrain or 3D tiles higher than 2.5 km (the Alps, Andes, Rockies) still cut through the band and the ring when seen from above, as the ring alone already did; the height check uses the camera's height above the ellipsoid, not above the ground. While pulses run, the ring dims to 40% and flashes to full strength as each pulse reaches it, fading over 1.8 s. As a pulse front crosses a flight, military aircraft or AIS vessel, the detection overlay draws a second bracket around that contact's own bracket, in the pulse blue on the default detection style and in the style's own line colour under NVG, FLIR and CRT, which spreads outward as it fades over 1.4 s (`AWARENESS_RANGE_ECHO`, read through `src/awarenessEcho.js`; no layer's icon is restyled, and mapped installations have no detection bracket). Pulses are born 5 km out, so the subject itself and anything nearer never echo. Pulses run for 9 s (three ring flashes) after a selection or a camera move, fading in and out over 1.2 s, then rest: the ring stays on screen at full strength, the pulses, gradient and echoes are hidden, and nothing asks for frames, so a parked Contacts view is quiet again. Only a camera move within 1.5 s of the user handling the map (pointer, wheel or touch on the Cesium canvas, which covers a drag's inertia, and a drag or touch begun there keeps counting until its last finger or button lifts, even outside the canvas, unless the window loses focus or the page is hidden first; keys typed elsewhere do not count, nor does input while Cesium's camera controls are off, as in the cockpit view, and a gesture still pending when the cockpit or another owner takes the camera is dropped) wakes them; a moving subject and the app's own camera moves (a tracked aircraft, the cockpit view, an orbit, a fly-to) do not, since they move on every refresh. While they run they never hold continuous rendering: each drawn frame arms one step 80 ms later (the Cyber sonar cadence, `CYBER_SONAR_RENDER_INTERVAL_MS`) whose changes ask for the frame that draws them, so a parked view repaints at about 12.5 fps, one frame a step, and never beats the detection lane's 80 ms gate. Under `prefers-reduced-motion`, or on a renderer without frame hooks, there are no pulses or echoes and the ring stays on screen; changing the preference mid-session rebuilds the ring. The ring follows a moving subject once it has moved 250 m.
- The window's edge is drawn on the globe as a 250 km range ring: a 4 px polyline with a 2 px Context-blue core inside a 1 px dark halo on each side, 2.5 km above the ellipsoid (`AWARENESS_RANGE_RING_STYLE` in `src/layers/awareness/policy.js`). The halo keeps it legible over bright desert and snow, dark ocean and forest, and under the FLIR, NVG and CRT styles, where the earlier 1 px ellipse outline disappeared. It is one outlined line in an unpickable draw-port line set (`src/layers/awareness/rangeRing.js`), so a click or tap on its edge reaches the contact underneath; the halo is the line's own outline, so the translucent core and halo never darken where they meet; it moves when the subject moves. Three dim sonar pulses (3 px with a dark edge half a pixel wide on each side, same colours, at most 60% opacity), each an outlined line in the same set, grow slowly from the subject at constant speed, one every 3 s and each taking 9 s, and arrive at the ring at about a third of that. Behind each pulse a radial gradient in the same blue fades inward over 35% of the radius: one unpickable flat ellipse 2.5 km up with 270 km semi-axes, filled with a 256-pixel canvas painted with the band (two canvases in turn, each under a new key). The ellipse stands until the subject has moved 20 km from where it was built, the canvas keeping the band concentric with the subject meanwhile, and not at all while the pulses rest. Fronts and band are fixed in the world, so they step every 80 ms however many frames are drawn and look the same whether the camera moves or not; crossing the 2.5 km rim height shows or hides them at once. While the camera is below the band's 2.5 km height, where it would sweep across the sky, the pulses rest: the band and fronts are hidden and there is no ring flash, no echo and no frame request. Terrain or 3D tiles higher than 2.5 km (the Alps, Andes, Rockies) still cut through the band and the ring when seen from above, as the ring alone already did; the height check uses the camera's height above the ellipsoid, not above the ground. While pulses run, the ring dims to 40% and flashes to full strength as each pulse reaches it, fading over 1.8 s. As a pulse front crosses a flight, military aircraft or AIS vessel, the detection overlay draws a second bracket around that contact's own bracket, in the pulse blue on the default detection style and in the style's own line colour under NVG, FLIR and CRT, which spreads outward as it fades over 1.4 s (`AWARENESS_RANGE_ECHO`, read through `src/awarenessEcho.js`; no layer's icon is restyled, and mapped installations have no detection bracket). Pulses are born 5 km out, so the subject itself and anything nearer never echo. Pulses run for 9 s (three ring flashes) after a selection or a camera move, fading in and out over 1.2 s, then rest: the ring stays on screen at full strength, the pulses, gradient and echoes are hidden, and nothing asks for frames, so a parked Contacts view is quiet again. Only a camera move within 1.5 s of the user handling the map (pointer, wheel or touch on the Cesium canvas, which covers a drag's inertia, and a drag or touch begun there keeps counting until its last finger or button lifts, even outside the canvas, unless the window loses focus or the page is hidden first; keys typed elsewhere do not count, nor does input while Cesium's camera controls are off, as in the cockpit view, and a gesture still pending when the cockpit or another owner takes the camera is dropped) wakes them; a moving subject and the app's own camera moves (a tracked aircraft, the cockpit view, an orbit, a fly-to) do not, since they move on every refresh. While they run they never hold continuous rendering: each drawn frame arms one step 80 ms later (the Cyber sonar cadence, `CYBER_SONAR_RENDER_INTERVAL_MS`) whose changes ask for the frame that draws them, so a parked view repaints at about 12.5 fps, one frame a step, and never beats the detection lane's 80 ms gate. Under `prefers-reduced-motion`, or on a renderer without frame hooks, there are no pulses or echoes and the ring stays on screen; changing the preference mid-session rebuilds the ring. The ring follows a moving subject once it has moved 250 m.
- For a selected live aircraft or vessel, the context window refreshes from the existing tracker/feed position every 750 ms, so nearest distances and cohort counts follow the subject without introducing a duplicate poll loop.
- Aircraft cohort membership uses every locally loaded, selectable contact inside the 250 km window, including a plane hidden only by horizon culling or because its 3D model owns the visual. Counts and navigation therefore do not change with the current camera angle or billboard/model handoff.
- Nearby examples in the context panel are focus controls: they use their owning layer's existing selection/tracking path, then frame that contact. Static-installation distances use ellipsoidal surface distance so the count matches the ground-projected context disk.
+4 -3
View File
@@ -95,9 +95,10 @@ export const AWARENESS_RANGE_RING_STYLE = Object.freeze({
* (tracking, cockpit, orbit, a fly-to) do not. Below the band's height they
* rest too. While they run they never hold
* continuous rendering; each drawn frame arms one more step after the
* Cyber sonar's 80 ms cadence, so the two never beat. The fronts move on
* every frame the camera moves in, or while something else holds
* continuous rendering; the band is repainted at most every 80 ms.
* Cyber sonar's 80 ms cadence, so the two never beat. Fronts and band,
* fixed in the world, step at that cadence however many frames are
* drawn, so they look the same whether the camera moves or not; crossing
* the rim height shows or hides them at once.
* Skipped under prefers-reduced-motion. */
export const AWARENESS_RANGE_PULSE = Object.freeze({
count: 3,
+21 -27
View File
@@ -3,11 +3,10 @@
* @description The Global Context range ring and its sonar pulses, drawn
* through the renderer's draw port. The ring is a haloed line (a solid line
* with an outline) 2.5 km above the ellipsoid. While pulses run, each pulse
* front is a haloed line whose positions move each step: every
* `CYBER_SONAR_RENDER_INTERVAL_MS` on a parked view, every frame the camera
* moves in. The band behind the fronts is one flat ellipse at the same
* height filled with a canvas painted anew at most every interval (a new
* key for new content). Nothing here is
* front is a haloed line whose positions move each step, every
* `CYBER_SONAR_RENDER_INTERVAL_MS` whether the camera moves or not. The
* band behind the fronts is one flat ellipse at the same height filled
* with a canvas painted anew each step (a new key for new content). Nothing here is
* pickable, so a click or tap near the ring reaches the contact underneath.
* Under reduced motion, or where the renderer has no frame hooks, the ring
* alone is drawn and stays.
@@ -619,35 +618,30 @@ export function createRangeRing({
next.step(nowMs);
}
};
// The eye as the pulses were last drawn under it, to tell frames the
// camera moved in from frames the pulses themselves asked for.
const camera = findCamera(viewer);
let lastEye = '';
const eyeMoved = () => {
const pose = camera?.pose();
if (!pose) return false;
const { position: p, direction: d } = pose;
const eye = `${p.x},${p.y},${p.z},${d.x},${d.y},${d.z}`;
if (eye === lastEye) return false;
lastEye = eye;
return true;
};
next.lastStepMs = performance.now();
next.step(next.lastStepMs);
// Each frame drawn while the camera moves, or held drawing, or at
// least a Cyber sonar interval after the last step, steps them. A
// step asks for the frame that draws it, which is no reason to step
// again: a parked view, held by nothing, draws one frame each
// interval, as the timer below asks.
// Whether the camera was below the rim at the last step.
let wasBelow = belowRim();
// The fronts and band are fixed in the world: a camera move needs
// nothing of them, so they step a Cyber sonar interval apart however
// many frames are drawn, and look the same parked or moving. Each
// frame checks only whether the camera crossed the rim height, which
// shows or hides them at once. A step asks for the frame that draws
// it, which is no reason to step again: a parked view draws one
// frame each interval, as the timer below asks.
const offPreRender = frame.on('preRender', () => {
const nowMs = performance.now();
const moved = eyeMoved();
const below = belowRim();
if (
moved ||
frame.diagnostics?.()?.holds?.length > 0 ||
below !== wasBelow ||
nowMs - next.lastStepMs >= CYBER_SONAR_RENDER_INTERVAL_MS
)
) {
// A crossing at the instant of the last step must not reuse
// that step's level.
if (below !== wasBelow) levelMemo.nowMs = Number.NaN;
wasBelow = below;
stepRunning(nowMs);
}
});
// Each drawn frame, whoever asked for it, arms one step a Cyber
// sonar interval later, as the Cyber sonar scene does, whose changes
+10 -9
View File
@@ -502,7 +502,7 @@ test('pulses ask for a frame 80 ms after each drawn frame instead of holding con
assert.equal(pulseFrames(), frames, 'no frames once the ring is gone');
});
test('a pulse frame draws the step made before it was asked for; only a moving camera steps every frame', (t) => {
test('a pulse frame draws the step made before it was asked for; a moving camera steps nothing sooner', (t) => {
const ring = ringRendering(t);
const { rendering, state } = ring;
const loop = frameLoop(t, ring);
@@ -527,8 +527,8 @@ test('a pulse frame draws the step made before it was asked for; only a moving c
assert.ok(pulses.length >= 9, `${pulses.length} pulse frames`);
for (const [, stepMs, nowMs] of pulses) assert.equal(stepMs, nowMs);
assert.equal(steps, pulses.length, 'one step a pulse frame');
// Frames the camera moves in step each one: the fronts move, and the
// soft band is painted again only a Cyber sonar interval on.
// The fronts and band are fixed in the world: frames the camera moves
// in within the interval step nothing, as a parked view's would not.
steps = 0;
const bandKey = drawn(ring).band.fill.image.key;
for (let i = 0; i < 5; i++) {
@@ -539,13 +539,14 @@ test('a pulse frame draws the step made before it was asked for; only a moving c
);
loop.draw();
}
assert.equal(steps, 5);
assert.equal(drawn(ring).band.fill.image.key, bandKey);
// A frame asked for by something else within the interval, the camera
// parked, steps nothing.
steps = 0;
loop.draw();
assert.equal(steps, 0);
assert.equal(drawn(ring).band.fill.image.key, bandKey);
// Crossing below the rim height hides them at once, interval or not.
state.viewer.camera.positionCartographic = { height: 1_000 };
loop.draw();
assert.equal(steps, 1);
assert.equal(drawn(ring).pulse(0).show, false);
assert.equal(drawn(ring).band.show, false);
});
test('a parked view stops asking for frames once the pulses rest', (t) => {