mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +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
@@ -64,6 +64,7 @@ function harness({
|
||||
withGlobe = false,
|
||||
feed = null,
|
||||
drilled = null,
|
||||
firstClick = null,
|
||||
} = {}) {
|
||||
const hadWindow = Object.hasOwn(globalThis, 'window');
|
||||
const priorWindow = globalThis.window;
|
||||
@@ -137,6 +138,8 @@ function harness({
|
||||
if (!withGlobe)
|
||||
layer.attachShellServices({ imageryHost: () => ({ kind: 'none' }) });
|
||||
const input = fakeInput(viewer);
|
||||
// A subscriber that runs before the layer's own (an aircraft layer).
|
||||
if (firstClick) input.input.onClick(firstClick);
|
||||
// The LOD rebuild (and with it the context-registration sweep) is inert
|
||||
// without a data source, so tests that drive a real refresh need one.
|
||||
if (withDataSource) layer.init(viewer);
|
||||
@@ -576,6 +579,35 @@ test('a fire card keeps a tap whose contact does not act; bare taps still clear'
|
||||
}
|
||||
});
|
||||
|
||||
// The aircraft layer runs first and starts tracking the plane it was clicked
|
||||
// on, which makes that plane passive. The fire card painted over it reads
|
||||
// the owners that acted when the click resolved, so it still yields.
|
||||
test('a fire card yields to an aircraft that starts tracking in the same click', (t) => {
|
||||
const fire = makeFire();
|
||||
let tracked = null;
|
||||
registerPickOwner('test-planes', (pickedId) => pickedId === 'plane:9', {
|
||||
expanded: true,
|
||||
passive: (pickedId) => pickedId === tracked,
|
||||
});
|
||||
t.after(() => unregisterPickOwner('test-planes'));
|
||||
const h = harness({
|
||||
fires: [fire],
|
||||
picked: { id: 'plane:9' },
|
||||
cardHit: `fire:${fireDetectionKey(fire)}`,
|
||||
firstClick: (event) => {
|
||||
if (event.hit?.id === 'plane:9') tracked = 'plane:9';
|
||||
},
|
||||
});
|
||||
try {
|
||||
h.click();
|
||||
assert.equal(tracked, 'plane:9', 'the aircraft starts tracking');
|
||||
assert.equal(h.requests.length, 0, 'the fire card yields');
|
||||
assert.equal(h.layer.getSelectedInfo(), null);
|
||||
} finally {
|
||||
h.cleanup();
|
||||
}
|
||||
});
|
||||
|
||||
test('a stale card id resolves to nothing instead of an arbitrary fire', () => {
|
||||
const h = harness({
|
||||
picked: { primitive: {}, content: {}, featureId: 0 },
|
||||
|
||||
Reference in new issue
Block a user