mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Never act on what lies under a mission label when it is clicked
A click on a Space Missions label reaches every click subscriber so they can let go of their selection, but the layers that test their own painted cards or pick the scene themselves still found what lay under the label: CCTV turned that camera on, FIRMS and Vessels selected and flew to theirs, News and Wildlife Sightings opened their item, Perimeters, Ghost Maps and Shipwrecks opened the card's link, ALPR selected its reader, and Local ADS-B drilled the scene itself and selected the aircraft. Each now skips its own test on such a click, and Local ADS-B drills through the click, so the click only releases selections, as a click on empty map or another layer's contact does. Ordinary clicks behave as before. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
1 parent
8675ead171
commit
5feac417d6
22 files changed
+453
-72
No files matched your search
@@ -411,12 +411,15 @@ export function createLifecycle({
|
||||
// painted ambient cards. The cards canvas is pointer-events:none (this
|
||||
// handler owns the events), so a click landing on a card's rect selects
|
||||
// its camera exactly like a click on the icon. Click positions
|
||||
// and the recorded rects are both CSS px — direct comparison.
|
||||
const cardId = layerState._cctvOverlayHost.hitTest(
|
||||
event.screenPosition.x,
|
||||
event.screenPosition.y,
|
||||
{ sourceId: CCTV_OVERLAY_SOURCE_ID },
|
||||
)?.entryId;
|
||||
// and the recorded rects are both CSS px — direct comparison. A
|
||||
// click a label painted over the cards took is not on a card.
|
||||
const cardId = event.overlay
|
||||
? null
|
||||
: layerState._cctvOverlayHost.hitTest(
|
||||
event.screenPosition.x,
|
||||
event.screenPosition.y,
|
||||
{ sourceId: CCTV_OVERLAY_SOURCE_ID },
|
||||
)?.entryId;
|
||||
if (cardId && layerState._recordById.has(cardId)) {
|
||||
activateCctvCameraFromWorldClick(
|
||||
cardId,
|
||||
|
||||
@@ -3,6 +3,9 @@ import assert from 'node:assert/strict';
|
||||
import { createLifecycle } from './lifecycle.js';
|
||||
import { bindRenderer } from '../../render/rendererOf.js';
|
||||
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
|
||||
import { CCTV_OVERLAY_SOURCE_ID } from '../../data/cctvCards.js';
|
||||
import { resolvePickId } from '../../data/pickRegistry.js';
|
||||
import { fakeInputUnderLabel } from '../../input/testDoubles.mjs';
|
||||
|
||||
function viewerWithCamera() {
|
||||
const camera = fakeCameraPort();
|
||||
@@ -72,3 +75,81 @@ test('the view listeners follow the camera port and let go on teardown', () => {
|
||||
assert.deepEqual(counts(second.camera), [0, 0]);
|
||||
assert.equal(state._viewListenerCamera, null);
|
||||
});
|
||||
|
||||
/** A part whose members are `own`'s, and any other a function that does
|
||||
* nothing. */
|
||||
const inert = (own = {}) =>
|
||||
new Proxy(own, {
|
||||
get: (target, name) => (name in target ? target[name] : () => {}),
|
||||
});
|
||||
|
||||
test("a click a label painted over a camera's card takes never turns that camera on, and lets go of the active one", async (t) => {
|
||||
const { viewer } = viewerWithCamera();
|
||||
viewer.scene = { canvas: {}, pick: () => null };
|
||||
const fake = fakeInputUnderLabel(viewer);
|
||||
t.after(() => fake.destroy());
|
||||
const activated = [];
|
||||
const deactivated = [];
|
||||
const state = {};
|
||||
const lifecycle = createLifecycle({
|
||||
state,
|
||||
services: {
|
||||
activation: {
|
||||
activateCctvCameraFromWorldClick: (id) => activated.push(id),
|
||||
},
|
||||
picking: { resolvePickId },
|
||||
focus: {},
|
||||
render: {},
|
||||
},
|
||||
parts: {
|
||||
calibration: { loadCalibrationStore: () => new Map() },
|
||||
catalog: {
|
||||
loadCameraSources: async () => [],
|
||||
buildCatalogFromSources: () => [],
|
||||
seedCatalog: () => [],
|
||||
},
|
||||
ground: {
|
||||
resolveGroundPriors: async () => [],
|
||||
currentSurfaceRegime: () => null,
|
||||
},
|
||||
rendering: inert({ refreshHorizonCulling: () => false }),
|
||||
health: { syncHealthState: async () => {} },
|
||||
geometryQueue: inert(),
|
||||
cards: inert(),
|
||||
projection: inert(),
|
||||
presentation: inert(),
|
||||
navigation: inert(),
|
||||
hover: inert(),
|
||||
selection: {
|
||||
// The camera's own gate takes only clean clicks; these are.
|
||||
bindCctvWorldClickGesture: (input, onClick) => input.onClick(onClick),
|
||||
extractPickedCameraId: () => null,
|
||||
cctvEmptyClickDeselects: (picked, { activeCameraId }) =>
|
||||
Boolean(activeCameraId) && resolvePickId(picked) === null,
|
||||
deactivateActiveCamera: () => deactivated.push(state._activeCameraId),
|
||||
},
|
||||
},
|
||||
});
|
||||
// Init's bounded wait for ground heights never runs out here: they are in.
|
||||
t.mock.timers.enable({ apis: ['setTimeout'] });
|
||||
await lifecycle.methods.init(viewer);
|
||||
t.after(() => state._clickSubscription?.());
|
||||
state._enabled = true;
|
||||
state._activeCameraId = 'cam-0';
|
||||
state._recordById.set('cam-1', {});
|
||||
// The card of camera `cam-1` lies under every click.
|
||||
state._cctvOverlayHost = {
|
||||
hitTest: (_x, _y, { sourceId }) =>
|
||||
sourceId === CCTV_OVERLAY_SOURCE_ID ? { entryId: 'cam-1' } : null,
|
||||
};
|
||||
|
||||
fake.label.over = true;
|
||||
fake.click();
|
||||
assert.deepEqual(activated, [], 'the camera under the label stays off');
|
||||
assert.deepEqual(deactivated, ['cam-0'], 'the active camera is let go');
|
||||
|
||||
// Off the label, a click on the card turns its camera on.
|
||||
fake.label.over = false;
|
||||
fake.click();
|
||||
assert.deepEqual(activated, ['cam-1']);
|
||||
});
|
||||
Reference in new issue
Block a user