mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42: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
@@ -46,13 +46,16 @@ export function createSelection({
|
||||
const pickedId = resolvePickId(picked);
|
||||
if (pickedId && isOwnedByOtherLayer(id, pickedId)) return;
|
||||
}
|
||||
const cardHit = overlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
{
|
||||
sourceId: FIRMS_OVERLAY_SOURCE_ID,
|
||||
},
|
||||
);
|
||||
// A click a label painted over the cards took is not on a card.
|
||||
const cardHit = event.overlay
|
||||
? null
|
||||
: overlayHost.hitTest?.(
|
||||
event.screenPosition?.x,
|
||||
event.screenPosition?.y,
|
||||
{
|
||||
sourceId: FIRMS_OVERLAY_SOURCE_ID,
|
||||
},
|
||||
);
|
||||
if (cardHit) {
|
||||
const carded = layerState._fireByCardId.get(cardHit.entryId);
|
||||
if (carded) selectAndFocusFire(carded);
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { FIRMS_OVERLAY_SOURCE_ID } from '../../data/firmsLabels.js';
|
||||
import { resolvePickId } from '../../data/pickRegistry.js';
|
||||
import { fakeInputUnderLabel } from '../../input/testDoubles.mjs';
|
||||
import { createSelection } from './selection.js';
|
||||
|
||||
/** The fire selection over a viewer whose clicks a label may take, with a
|
||||
* fire's card under every click. */
|
||||
function selectionHarness(t) {
|
||||
const viewer = { scene: { canvas: {}, pick: () => null } };
|
||||
const fake = fakeInputUnderLabel(viewer);
|
||||
t.after(() => fake.destroy());
|
||||
const fire = { lat: 1, lon: 2, acqMs: 3, frp: 40, satellite: 'N' };
|
||||
const focused = [];
|
||||
const cleared = [];
|
||||
const layerState = {
|
||||
_viewer: viewer,
|
||||
_icons: { id: 'firms:icons' },
|
||||
_pickIndexById: new Map(),
|
||||
_fireByCardId: new Map([['firms-card:1', fire]]),
|
||||
_selectedFire: null,
|
||||
_contextIds: new Set(),
|
||||
};
|
||||
const selection = createSelection({
|
||||
layerState,
|
||||
services: {
|
||||
picking: { resolvePickId, isOwnedByOtherLayer: () => false },
|
||||
focus: { requestWorldFocus: (request) => focused.push(request.kind) },
|
||||
context: {
|
||||
selectEntityContext() {},
|
||||
clearSelectedEntityContextForLayer: (id) => cleared.push(id),
|
||||
getContextStore() {},
|
||||
registerEntityContext() {},
|
||||
},
|
||||
},
|
||||
components: {
|
||||
model: {
|
||||
firePosition: () => ({ x: 0, y: 0, z: 0 }),
|
||||
formatFrp: String,
|
||||
confidenceBucket: String,
|
||||
},
|
||||
cards: { rebuildAmbientLabels() {} },
|
||||
},
|
||||
config: {
|
||||
id: 'firms',
|
||||
name: 'Fires',
|
||||
overlayHost: {
|
||||
hitTest: (_x, _y, { sourceId }) =>
|
||||
sourceId === FIRMS_OVERLAY_SOURCE_ID
|
||||
? { entryId: 'firms-card:1' }
|
||||
: null,
|
||||
},
|
||||
},
|
||||
});
|
||||
selection.installClickHandler();
|
||||
t.after(() => selection.removeClickHandler());
|
||||
return { fake, layerState, fire, focused, cleared };
|
||||
}
|
||||
|
||||
test("a click a label painted over a fire's card takes never selects or focuses the fire", (t) => {
|
||||
const h = selectionHarness(t);
|
||||
h.fake.label.over = true;
|
||||
h.fake.click();
|
||||
assert.equal(h.layerState._selectedFire, null);
|
||||
assert.deepEqual(h.focused, [], 'the camera is not sent to the fire');
|
||||
});
|
||||
|
||||
test('a click a label painted over the map takes lets go of the selected fire', (t) => {
|
||||
const h = selectionHarness(t);
|
||||
// Off the label, a click on the card selects and focuses its fire.
|
||||
h.fake.click();
|
||||
assert.equal(h.layerState._selectedFire, h.fire);
|
||||
assert.deepEqual(h.focused, ['fire']);
|
||||
h.fake.label.over = true;
|
||||
h.fake.click();
|
||||
assert.equal(h.layerState._selectedFire, null);
|
||||
assert.deepEqual(h.cleared, ['firms']);
|
||||
assert.deepEqual(h.focused, ['fire']);
|
||||
});
|
||||
Reference in new issue
Block a user