mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-21 02:32:18 +00:00
fix(picking): arbitrate card clicks over passive and background shapes
Flight trails register their ids so every layer reads a trail click as a
no-op, and the directions route claims its line and markers though it acts
only on its maneuver steps. The quake card and magnitude labels yielded to
any registered owner, so over a trail or a route they did nothing. Pick
owners can now name the picks they never act on (registerPickOwner(...,
{ passive })); isActedOnByOtherLayer leaves those out while
isOwnedByOtherLayer is unchanged, so they are still not empty space.
Submarine cables and rocket launches acted on any scene pick, so a card or
label over a cable or a launch marker made both layers act. Both now stand
aside when a world-overlay entry is under the click, as drone airspace and
fire perimeters do through the top-entry check. Each of these layers, and
the quake discs, registers its shapes with registerCardBackground. CCTV
asks isCardBackground instead of matching other layers' set and id formats,
so a live top CCTV card acts once over any of them, while unknown
identified objects and registered owners still block it.
This commit is contained in:
1 parent
836daf82b3
commit
133d022b29
23 files changed
+825
-78
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
import { createLifecycle } from './lifecycle.js';
|
||||
import { fakeInput } from '../../input/testDoubles.mjs';
|
||||
import * as picking from '../../data/pickRegistry.js';
|
||||
|
||||
/** Any part method is a no-op unless the test supplies it. */
|
||||
const stubs = (given = {}) =>
|
||||
new Proxy(given, {
|
||||
get: (target, key) => (key in target ? target[key] : () => undefined),
|
||||
});
|
||||
|
||||
// Mission overlays are not interactive: an overlay entry under the pointer is
|
||||
// another layer's card or label painted over the mission (a quake label), and
|
||||
// that layer takes the click, so the mission is not also selected.
|
||||
test('a card painted over a launch marker keeps its click; with none the mission selects', () => {
|
||||
const viewer = {
|
||||
scene: {
|
||||
pick: () => null,
|
||||
canvas: { clientWidth: 100, clientHeight: 100 },
|
||||
},
|
||||
};
|
||||
const input = fakeInput(viewer);
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
const selected = [];
|
||||
const state = { _launches: [{ id: 'L1' }], _enabled: false };
|
||||
const { methods: lifecycle } = createLifecycle({
|
||||
state,
|
||||
services: {
|
||||
render: { holdContinuousRender() {}, releaseContinuousRender() {} },
|
||||
overlays: { hitTestWorldOverlay: () => top },
|
||||
picking,
|
||||
},
|
||||
parts: {
|
||||
panel: stubs(),
|
||||
overlays: stubs(),
|
||||
launchPad: stubs(),
|
||||
orbitRendering: stubs(),
|
||||
replay: stubs(),
|
||||
ingestion: stubs(),
|
||||
rendering: stubs({
|
||||
missionsShown: () => true,
|
||||
missionHitsAt: () => [{ id: 'mission:L1' }],
|
||||
launchIdFromPicks: (hits) =>
|
||||
hits.some((hit) => hit?.id === 'mission:L1') ? 'L1' : null,
|
||||
}),
|
||||
selection: stubs({ setSelectedMission: (id) => selected.push(id) }),
|
||||
},
|
||||
source: {},
|
||||
});
|
||||
try {
|
||||
// init installs the click handler; enable would start a feed load.
|
||||
lifecycle.init(viewer);
|
||||
state._enabled = true;
|
||||
input.click();
|
||||
assert.deepEqual(selected, [], 'the mission stands aside');
|
||||
top = null;
|
||||
input.click();
|
||||
assert.deepEqual(
|
||||
selected,
|
||||
['L1'],
|
||||
'with no card on top, the mission selects',
|
||||
);
|
||||
// So a card on top (a live CCTV card) may act over the mission instead.
|
||||
const mission = { set: 'launches:1:markers', id: 'mission:L1' };
|
||||
assert.equal(picking.isCardBackground(mission), true);
|
||||
assert.equal(picking.isCardBackground({ ...mission, id: 'x' }), false);
|
||||
state._enabled = false;
|
||||
assert.equal(picking.isCardBackground(mission), false);
|
||||
state._inputSubscription();
|
||||
state._enabled = true;
|
||||
assert.equal(picking.isCardBackground(mission), false);
|
||||
} finally {
|
||||
state._inputSubscription?.();
|
||||
input.destroy();
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user