mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 09:42:21 +00:00
fix(picking): settle which layers act on a click when it resolves
The flights and military layers treat the aircraft they already track as a passive pick, but they start tracking during the click itself. A card handler running later in the same click then saw the plane as passive and acted too: a quake card opened its source while the plane started tracking, and fire, CCTV and vessel cards could do the same. The pick registry now records the acting owners of a click's exact hit and touch contact when the dispatcher first resolves them, and the quake, FIRMS, CCTV, vessel and Context checks read that record for the rest of the click. Calls without a click keep the live lookup.
This commit is contained in:
1 parent
830c980ca6
commit
54fd3d3bed
13 files changed
+239
-48
No files matched your search
@@ -1012,7 +1012,12 @@ function makeCesiumEvent() {
|
||||
};
|
||||
}
|
||||
|
||||
function installWireHarness(picked, stateOverrides = {}, sceneExtras = {}) {
|
||||
function installWireHarness(
|
||||
picked,
|
||||
stateOverrides = {},
|
||||
sceneExtras = {},
|
||||
firstClick = null,
|
||||
) {
|
||||
const hadWindow = Object.hasOwn(globalThis, 'window');
|
||||
const hadDocument = Object.hasOwn(globalThis, 'document');
|
||||
const priorWindow = globalThis.window;
|
||||
@@ -1041,6 +1046,8 @@ function installWireHarness(picked, stateOverrides = {}, sceneExtras = {}) {
|
||||
scene: { pick: () => picked, ...sceneExtras },
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
// A subscriber that runs before the layer's own (an aircraft layer).
|
||||
if (firstClick) input.input.onClick(firstClick);
|
||||
// The camera port other layers follow through, with no pose to read; its
|
||||
// followChanged event counts who listens.
|
||||
const followChanged = makeCesiumEvent();
|
||||
@@ -1993,6 +2000,42 @@ test('vessel interaction wire: a sibling-owned pick wins without selection mutat
|
||||
}
|
||||
});
|
||||
|
||||
// The aircraft layer runs first and starts tracking the plane under the
|
||||
// vessel's card, making it passive. The card reads the owners that acted
|
||||
// when the click resolved, so it still yields: one action.
|
||||
test('vessel interaction wire: a card yields to an aircraft that starts tracking in the same click', (t) => {
|
||||
let tracked = null;
|
||||
registerPickOwner('test-planes', (pickedId) => pickedId === 'plane:9', {
|
||||
expanded: true,
|
||||
passive: (pickedId) => pickedId === tracked,
|
||||
});
|
||||
t.after(() => unregisterPickOwner('test-planes'));
|
||||
const harness = installWireHarness(
|
||||
{ id: 'plane:9' },
|
||||
{ selectedRecord: null },
|
||||
{},
|
||||
(event) => {
|
||||
if (event.hit?.id === 'plane:9') tracked = 'plane:9';
|
||||
},
|
||||
);
|
||||
const requests = [];
|
||||
harness.windowTarget.addEventListener(WORLD_FOCUS_REQUEST_EVENT, (event) =>
|
||||
requests.push(event.detail),
|
||||
);
|
||||
_setVesselOverlayHostForTest(
|
||||
hostWithCardHit(`vessel:${harness.record.mmsi}`),
|
||||
);
|
||||
try {
|
||||
harness.handler.click({ position: { x: 10, y: 20 } });
|
||||
assert.equal(tracked, 'plane:9', 'the aircraft starts tracking');
|
||||
assert.equal(requests.length, 0, 'the vessel card yields');
|
||||
assert.equal(aisLiveVesselsLayer.getSelectedInfo()?.mmsi ?? null, null);
|
||||
} finally {
|
||||
_setVesselOverlayHostForTest(null);
|
||||
harness.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
// A trail acts for nobody: the vessel's card painted over it still selects,
|
||||
// and a bare trail pick stays a no-op that keeps the selection.
|
||||
test('vessel interaction wire: a card over a trail selects; a bare trail is a no-op', () => {
|
||||
|
||||
Reference in new issue
Block a user