mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
fix(earthquakes): address review follow-ups on click arbitration
A drifting touch tap or a cockpit-mode tap on a fire, quake or vessel card
beside an aircraft did nothing: the cards deferred to the aircraft, whose
click handler ignores such taps. Pick owners can now declare the clicks
they ignore (registerPickOwner(..., { declinesClick })); flights and
military decline a drag or a cockpit tap and CCTV declines any click that
is not clean, so a card over them keeps that tap.
Also from review:
- the selected quake's contour rings sit on the ground the disc is draped
on, re-read through the heights service while they paint;
- a label's fly-to frames the whole disc for large quakes;
- a quake that ages out of the feed clears its selection as evicted;
- id-less quakes are named by their content, not their row;
- the Bhote Koshi trigger-record callout opens its source on a click, as
its keyboard action does, and yields like the other cards;
- the card's place line is cut to 48 characters, its link hint shows only
with an opener, and its accessible name carries depth, place and time; a
link-less card's click and keyboard action fly to the quake;
- camera trace comparison scales its tolerance with the value and wraps
heading and roll.
This commit is contained in:
1 parent
fde5f95b45
commit
7312280817
33 files changed
+702
-76
No files matched your search
@@ -74,6 +74,15 @@ const reducedMotion = () => {
|
||||
}
|
||||
};
|
||||
|
||||
/** How often the rings re-read the ground height under the quake. */
|
||||
const HEIGHT_READ_INTERVAL_MS = 500;
|
||||
/**
|
||||
* A ground height the rings accept, in metres: the Dead Sea shore to above
|
||||
* Everest. Anything else is a bad sample (a hit on something drawn above
|
||||
* the ground, or a broken tile), and the rings stay where they are.
|
||||
*/
|
||||
const groundHeightOk = (h) => Number.isFinite(h) && h >= -500 && h <= 9000;
|
||||
|
||||
/**
|
||||
* The selected earthquake's contour lines, painted on the world overlay:
|
||||
* wavy closed lines, shaped by the quake's id (earthquakeContourShape), run
|
||||
@@ -220,9 +229,32 @@ export function createEarthquakeRipples({
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Re-read the ground height under the quake, at most twice a second while
|
||||
* painting: the ground loads and refines as the camera comes in, and the
|
||||
* rings move onto it once it differs by more than a metre.
|
||||
*/
|
||||
function settleHeight() {
|
||||
if (!target.heightAt) return;
|
||||
const at = now();
|
||||
if (at - target.heightReadAt < HEIGHT_READ_INTERVAL_MS) return;
|
||||
target.heightReadAt = at;
|
||||
let height = null;
|
||||
try {
|
||||
height = target.heightAt();
|
||||
} catch {
|
||||
height = null;
|
||||
}
|
||||
if (!groundHeightOk(height) || Math.abs(height - target.heightM) <= 1)
|
||||
return;
|
||||
target.heightM = height;
|
||||
target.center = fromDegrees(target.lon, target.lat, height);
|
||||
}
|
||||
|
||||
function paint(frame) {
|
||||
if (!target) return;
|
||||
const { ctx } = frame;
|
||||
settleHeight();
|
||||
const center = target.center;
|
||||
onScreen = false;
|
||||
if (frame.occluder?.isPointVisible?.(center) === false) return;
|
||||
@@ -309,7 +341,7 @@ export function createEarthquakeRipples({
|
||||
|
||||
/**
|
||||
* Run the contour lines around one quake, replacing any other.
|
||||
* @param {{id: string, lon: number, lat: number, radiusM: number, color: string}} next
|
||||
* @param {{id: string, lon: number, lat: number, heightM?: number, heightAt?: () => number|null, radiusM: number, color: string}} next
|
||||
* @param {{restart?: boolean}} [options] `restart: false` updates the
|
||||
* same quake in place (a feed refresh) without running it again.
|
||||
*/
|
||||
@@ -336,7 +368,19 @@ export function createEarthquakeRipples({
|
||||
}
|
||||
target = {
|
||||
id: next.id,
|
||||
center: fromDegrees(next.lon, next.lat),
|
||||
// On the ground the disc is draped on: the height known now, then
|
||||
// re-read while painting (see `settleHeight`), since a label's fly-to
|
||||
// starts from far away, before that ground has loaded.
|
||||
lon: next.lon,
|
||||
lat: next.lat,
|
||||
heightM: groundHeightOk(next.heightM) ? next.heightM : 0,
|
||||
heightAt: typeof next.heightAt === 'function' ? next.heightAt : null,
|
||||
heightReadAt: -Infinity,
|
||||
center: fromDegrees(
|
||||
next.lon,
|
||||
next.lat,
|
||||
groundHeightOk(next.heightM) ? next.heightM : 0,
|
||||
),
|
||||
radiusM: next.radiusM,
|
||||
color: next.color || 'rgb(255,165,0)',
|
||||
shape: earthquakeContourShape(next.id),
|
||||
|
||||
@@ -418,3 +418,35 @@ test('a refresh of the same quake does not run a settled selection again', () =>
|
||||
assert.equal(h.frames.size, 1);
|
||||
h.ripples.dispose();
|
||||
});
|
||||
|
||||
// The rings sit on the ground the disc is draped on. A label's fly-to starts
|
||||
// far away, before that ground loads, so the painter reads the height again
|
||||
// while it paints and moves the rings onto it.
|
||||
test('the rings move onto the ground height once it loads', () => {
|
||||
const h = harness();
|
||||
let ground = null;
|
||||
h.ripples.show({ ...target, heightM: 0, heightAt: () => ground });
|
||||
h.advance(600);
|
||||
const [lane] = h.lanes;
|
||||
lane.painter(h.frame());
|
||||
const atSea = h.fills.at(-1).transform;
|
||||
h.fills.length = 0;
|
||||
ground = 4000;
|
||||
h.advance(600);
|
||||
lane.painter(h.frame());
|
||||
const onGround = h.fills.at(-1).transform;
|
||||
assert.notDeepEqual(onGround, atSea, 'the centre moved up onto the ground');
|
||||
// A change of a metre or less, or an impossible height, leaves them put.
|
||||
for (const next of [4000.5, 25000, -2000]) {
|
||||
ground = next;
|
||||
h.advance(600);
|
||||
lane.painter(h.frame());
|
||||
assert.deepEqual(h.fills.at(-1).transform, onGround, String(next));
|
||||
}
|
||||
// Reads are bounded: a second paint within the interval does not ask again.
|
||||
let reads = 0;
|
||||
h.ripples.show({ ...target, id: 'ak2', heightAt: () => (reads++, 4000) });
|
||||
lane.painter(h.frame());
|
||||
lane.painter(h.frame());
|
||||
assert.equal(reads, 1);
|
||||
});
|
||||
@@ -7,6 +7,7 @@ import * as context from '../../data/contextStore.js';
|
||||
import { isPointerFree } from '../../data/inputOwnership.js';
|
||||
import { requestWorldFocus } from '../../worldFocus.js';
|
||||
import { createEarthquakeRipples } from './earthquakeRipples.js';
|
||||
import { heightsOf } from '../../queries/heights.js';
|
||||
import { formatDate, formatNumber, t } from '../../i18n/index.js';
|
||||
|
||||
const EVENT_TIME = Object.freeze({
|
||||
@@ -40,6 +41,9 @@ export function createApplicationEarthquakes(options) {
|
||||
openExternal: (url) => window.open(url, '_blank', 'noopener,noreferrer'),
|
||||
focus: { requestWorldFocus },
|
||||
ripples: createEarthquakeRipples(),
|
||||
// The loaded ground (terrain or tiles) the clamped disc is draped on.
|
||||
groundHeight: (viewer, lon, lat) =>
|
||||
viewer ? heightsOf(viewer).now({ lon, lat }) : null,
|
||||
text: earthquakeCardText,
|
||||
...options,
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user