mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52: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
@@ -5,6 +5,7 @@ import { viewshedColors, cameraHue } from '../../data/cctvViewshed.js';
|
||||
import { CCTV_OVERLAY_SOURCE_ID } from '../../data/cctvCards.js';
|
||||
import { GIZMO_ID_PREFIX } from '../../data/cctvGizmo.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { isTrackingClickGesture } from '../../data/trackingClickGesture.js';
|
||||
import {
|
||||
GROUND_PRIOR_INIT_WAIT_MS,
|
||||
CALIBRATION_RANGE_FLOOR_M,
|
||||
@@ -509,19 +510,26 @@ export function createLifecycle({
|
||||
layerState._lastUpdate = Date.now();
|
||||
// Pick-ownership (H2): camera icons use the camera id directly;
|
||||
// coverage polyline entities use `cctv-<cameraId>-<role>` entity ids.
|
||||
registerPickOwner('cctv', (pickedId) => {
|
||||
if (layerState._recordById.has(pickedId)) return true;
|
||||
if (
|
||||
typeof pickedId === 'string' &&
|
||||
pickedId.startsWith(GIZMO_ID_PREFIX)
|
||||
)
|
||||
return true;
|
||||
const coverage =
|
||||
/^cctv-(.+)-(?:ray-tl|ray-tr|ray-br|ray-bl|cap|plane|plane-label)$/.exec(
|
||||
pickedId,
|
||||
);
|
||||
return Boolean(coverage && layerState._recordById.has(coverage[1]));
|
||||
});
|
||||
registerPickOwner(
|
||||
'cctv',
|
||||
(pickedId) => {
|
||||
if (layerState._recordById.has(pickedId)) return true;
|
||||
if (
|
||||
typeof pickedId === 'string' &&
|
||||
pickedId.startsWith(GIZMO_ID_PREFIX)
|
||||
)
|
||||
return true;
|
||||
const coverage =
|
||||
/^cctv-(.+)-(?:ray-tl|ray-tr|ray-br|ray-bl|cap|plane|plane-label)$/.exec(
|
||||
pickedId,
|
||||
);
|
||||
return Boolean(coverage && layerState._recordById.has(coverage[1]));
|
||||
},
|
||||
// The world click handler takes only clean clicks (see
|
||||
// `bindCctvWorldClickGesture`), so a card over a camera keeps any
|
||||
// other tap.
|
||||
{ declinesClick: (click) => !isTrackingClickGesture(click?.gesture) },
|
||||
);
|
||||
if (!layerState._activeCameraId && layerState._records.length) {
|
||||
layerState._activeCameraId = parts.navigation.openingCameraId();
|
||||
layerState._autoHopSuspended = false;
|
||||
|
||||
@@ -136,8 +136,8 @@ test('world clicks respect the painted top card and registered card backgrounds'
|
||||
};
|
||||
const services = {
|
||||
sprites: {},
|
||||
focus: {},
|
||||
render: {},
|
||||
focus: { onFocusTargetAppear: () => noop },
|
||||
render: { releaseContinuousRender: noop },
|
||||
picking,
|
||||
activation: { activateCctvCameraFromWorldClick: (id) => actions.push(id) },
|
||||
};
|
||||
@@ -152,6 +152,7 @@ test('world clicks respect the painted top card and registered card backgrounds'
|
||||
picking.unregisterPickOwner('test-trails');
|
||||
picking.unregisterPickOwner('test-planes');
|
||||
picking.unregisterPickOwner('test-tracking');
|
||||
picking.unregisterPickOwner('test-exact');
|
||||
picking.unregisterCardBackground('area-fixture');
|
||||
});
|
||||
await lifecycle.methods.init(viewer);
|
||||
@@ -214,6 +215,13 @@ test('world clicks respect the painted top card and registered card backgrounds'
|
||||
// A coarse tap whose touch contact is an aircraft (a layer that acts on
|
||||
// nearby contacts) is the aircraft's, even under a live CCTV card.
|
||||
const previousMatch = globalThis.matchMedia;
|
||||
const restoreMatch = () => {
|
||||
if (previousMatch) globalThis.matchMedia = previousMatch;
|
||||
else delete globalThis.matchMedia;
|
||||
};
|
||||
// Restored below for the fine-pointer clicks that follow; here too, so a
|
||||
// failing assertion cannot leave the coarse pointer for later tests.
|
||||
t.after(restoreMatch);
|
||||
globalThis.matchMedia = () => ({ matches: true });
|
||||
picking.registerPickOwner('test-planes', (id) => id === 'plane:1', {
|
||||
expanded: true,
|
||||
@@ -230,8 +238,7 @@ test('world clicks respect the painted top card and registered card backgrounds'
|
||||
drilled = [];
|
||||
click(null, [ownCard], ['cam-1']);
|
||||
picking.unregisterPickOwner('test-planes');
|
||||
if (previousMatch) globalThis.matchMedia = previousMatch;
|
||||
else delete globalThis.matchMedia;
|
||||
restoreMatch();
|
||||
// The live card reads the owners that acted when the click resolved, so it
|
||||
// yields to the aircraft even though tracking made it passive meanwhile.
|
||||
picking.registerPickOwner('test-tracking', (id) => id === 'plane:9', {
|
||||
@@ -253,4 +260,28 @@ test('world clicks respect the painted top card and registered card backgrounds'
|
||||
[foreignCard, ownCard],
|
||||
['cam-1'],
|
||||
);
|
||||
// CCTV takes only clean clicks, so for a long press or a drag its cameras
|
||||
// act for nobody: a card painted over one keeps that tap.
|
||||
// Enable's own work is beside the point here: only its registration.
|
||||
Object.assign(parts.cards, {
|
||||
refreshAmbientCards: noop,
|
||||
startCardFrameLoop: noop,
|
||||
});
|
||||
parts.frames = { refreshProjectionImage: noop };
|
||||
Object.assign(parts.geometryQueue, { startGeometryLoadQueue: noop });
|
||||
parts.navigation = { openingCameraId: () => 'cam-1' };
|
||||
Object.assign(parts.projection, {
|
||||
ensureProjectionRuntime: noop,
|
||||
startProjectionLoop: noop,
|
||||
});
|
||||
state._cctvOverlayHost.setVisible ??= noop;
|
||||
lifecycle.methods.enable();
|
||||
t.after(() => picking.unregisterPickOwner('cctv'));
|
||||
const acted = (gesture) =>
|
||||
picking.isActedOnByOtherLayer('earthquakes', 'cam-1', {
|
||||
click: { gesture },
|
||||
});
|
||||
assert.equal(acted({ travelPx: 0, durationMs: 80 }), true, 'a clean click');
|
||||
assert.equal(acted({ travelPx: 0, durationMs: 900 }), false, 'a long press');
|
||||
assert.equal(acted({ travelPx: 20, durationMs: 80 }), false, 'a drag');
|
||||
});
|
||||
Reference in new issue
Block a user