mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-19 17:52:21 +00:00
Merge origin/main into space-missions-fixes
Main's single click rule (the card or label on top takes the click, read once per click through clickCard and isUnderOtherCard in src/data/pickRegistry.js) covers a click on a Space Missions label: a mission marker label is an interactive world-overlay entry, so the host's hit test names it as the card on top for every other layer. The per-layer label guards in CCTV, Drone Airspace, FIRMS, Ghost Maps, News, Perimeters, Shipwrecks, Vessels, Wildlife Sightings, ALPR, Local ADS-B and the cockpit orbital focus are dropped for main's versions. The mission-label tests are kept on main's API: fakeInputUnderLabel now also names the label as the card on top, and each test shows a click on the label never acts on the card, camera, vessel, fire, reader, aircraft or report under it, and leaves the selection as it is. A launches test checks that a mission label is interactive and is the card on top for every other layer. Docs, changelog and the dispatcher's `overlay` note describe the merged behaviour. Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
commit
0e5c5e624c
146 files changed
+9734
-1157
No files matched your search
@@ -8,7 +8,12 @@ import {
|
||||
} from '../../data/screenRotation.js';
|
||||
import { fromDegreesInto, toLonLatH } from '../../geo/ellipsoid.js';
|
||||
import { hexColor } from '../../render/color.js';
|
||||
import { drawOf, findCamera, findFrame } from '../../render/rendererOf.js';
|
||||
import {
|
||||
drawOf,
|
||||
findCamera,
|
||||
findFrame,
|
||||
findQuery,
|
||||
} from '../../render/rendererOf.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { pickRenderAltitudeM } from '../../data/renderAltitude.js';
|
||||
import { routePlausible } from '../../data/routePlausible.js';
|
||||
@@ -677,8 +682,10 @@ export function createLocalAdsbLayer({
|
||||
if (ownedElsewhere(topId) && !trail) return 'other';
|
||||
let hits = [];
|
||||
try {
|
||||
// The click's own drill: none under a label painted over the map.
|
||||
hits = event.drill(CLICK_DRILL_LIMIT);
|
||||
hits =
|
||||
findQuery(viewer)?.drillPick(event.position.x, event.position.y, {
|
||||
limit: CLICK_DRILL_LIMIT,
|
||||
}) ?? [];
|
||||
} catch {
|
||||
hits = [];
|
||||
}
|
||||
@@ -696,6 +703,9 @@ export function createLocalAdsbLayer({
|
||||
if (clickSubscription || !viewer) return;
|
||||
clickSubscription = inputFor(viewer).onClick((event) => {
|
||||
if (!enabled) return;
|
||||
// Another layer's card or label painted on top takes the click: the item
|
||||
// under it does not act, and the click is not empty space either.
|
||||
if (services.picking.isUnderOtherCard?.(event)) return;
|
||||
const target = clickTarget(event);
|
||||
// Clicking a local aircraft always (re)selects it and republishes its
|
||||
// card, including the one already selected: its card may have been
|
||||
|
||||
@@ -15,10 +15,14 @@ import {
|
||||
} from './index.js';
|
||||
import { createLocalAdsbModels } from './models.js';
|
||||
import { entityRecord, readEntityRecord } from '../../data/entityRecords.js';
|
||||
import { resolvePickId } from '../../data/pickRegistry.js';
|
||||
import {
|
||||
isUnderOtherCard,
|
||||
resolvePickId,
|
||||
setClickCardHitTest,
|
||||
} from '../../data/pickRegistry.js';
|
||||
import { fromDegrees, toLonLatH } from '../../geo/ellipsoid.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import { fakeInput } from '../../input/testDoubles.mjs';
|
||||
import { MISSION_LABEL, fakeInput } from '../../input/testDoubles.mjs';
|
||||
import { hexColor } from '../../render/color.js';
|
||||
import { fakeCameraPort } from '../../testSupport/fakeCameraPort.mjs';
|
||||
import { bindFakeDraw } from '../../testSupport/fakeDrawPort.mjs';
|
||||
@@ -1217,6 +1221,41 @@ test('clicking the selected aircraft keeps it selected and republishes its card'
|
||||
assert.deepEqual(calls.cleared, []);
|
||||
});
|
||||
|
||||
// The card or label painted on top takes the click: a local aircraft under
|
||||
// another layer's card is neither selected nor released.
|
||||
test("another layer's card over a local aircraft keeps the click", async (t) => {
|
||||
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
|
||||
const clock = { now: 100_000 };
|
||||
const harness = clickHarness();
|
||||
let top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
setClickCardHitTest(() => top);
|
||||
t.after(() => setClickCardHitTest(null));
|
||||
const { layer, calls, draw } = await enabledLayer(receiver, clock, null, {
|
||||
viewer: harness.viewer,
|
||||
services: {
|
||||
picking: {
|
||||
registerPickOwner() {},
|
||||
unregisterPickOwner() {},
|
||||
resolvePickId,
|
||||
isUnderOtherCard,
|
||||
},
|
||||
},
|
||||
});
|
||||
t.after(() => layer.destroy());
|
||||
receiver.set({ aircraft: [record()] });
|
||||
await layer.update();
|
||||
harness.scene.pickResult = iconPick(draw, 'local-adsb:abc123');
|
||||
harness.click();
|
||||
assert.deepEqual(calls.selected, [], 'covered: not selected');
|
||||
top = null;
|
||||
harness.click();
|
||||
assert.deepEqual(calls.selected, ['local-adsb:abc123']);
|
||||
top = { sourceId: 'earthquake-card', entryId: 'earthquake-card:ak1' };
|
||||
harness.scene.pickResult = null;
|
||||
harness.click();
|
||||
assert.deepEqual(calls.cleared, [], 'covered: the selection stays');
|
||||
});
|
||||
|
||||
test('a click on a local aircraft under an unowned or trail pick still selects it', async (t) => {
|
||||
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
|
||||
const clock = { now: 100_000 };
|
||||
@@ -1269,17 +1308,29 @@ test('a click on a local aircraft under an unowned or trail pick still selects i
|
||||
assert.equal(calls.selected.length, 2, 'the Flights contact is not taken');
|
||||
});
|
||||
|
||||
test('a click a label painted over a local aircraft takes never selects the aircraft, and lets go of the selection', async (t) => {
|
||||
test('a click on a mission label over a local aircraft never selects the aircraft, and keeps the selection', async (t) => {
|
||||
const receiver = fakeReceiver({ mode: 'adsb', connected: true });
|
||||
const clock = { now: 100_000 };
|
||||
const harness = clickHarness();
|
||||
// A Space Missions label painted over the map: while it is over, it takes
|
||||
// each click and is the card on top.
|
||||
const label = { over: true };
|
||||
setClickCardHitTest(() => (label.over ? MISSION_LABEL : null));
|
||||
t.after(() => setClickCardHitTest(null));
|
||||
const { layer, calls, draw } = await enabledLayer(receiver, clock, null, {
|
||||
viewer: harness.viewer,
|
||||
services: {
|
||||
picking: {
|
||||
registerPickOwner() {},
|
||||
unregisterPickOwner() {},
|
||||
resolvePickId,
|
||||
isUnderOtherCard,
|
||||
},
|
||||
},
|
||||
});
|
||||
t.after(() => layer.destroy());
|
||||
receiver.set({ aircraft: [record()] });
|
||||
await layer.update();
|
||||
const label = { over: true };
|
||||
inputFor(harness.viewer.viewer).onOverlayClick(() => label.over);
|
||||
const model = {
|
||||
set: layerSet(draw, ':models').spec.id,
|
||||
@@ -1292,14 +1343,15 @@ test('a click a label painted over a local aircraft takes never selects the airc
|
||||
harness.click();
|
||||
assert.deepEqual(calls.selected, [], 'the aircraft beneath is not taken');
|
||||
|
||||
// Off the label the same click selects it; on the label it lets go.
|
||||
// Off the label the same click selects it; the label on top is its own
|
||||
// click, so the selection stays.
|
||||
label.over = false;
|
||||
harness.click();
|
||||
assert.deepEqual(calls.selected, ['local-adsb:abc123']);
|
||||
label.over = true;
|
||||
harness.click();
|
||||
assert.deepEqual(calls.selected, ['local-adsb:abc123']);
|
||||
assert.equal(calls.cleared.length, 1, 'the selection is released');
|
||||
assert.equal(calls.cleared.length, 0, 'the selection stays');
|
||||
});
|
||||
|
||||
test('a grounded aircraft changing type keeps its drawn model on its own belly offset until the new one is ready', () => {
|
||||
|
||||
Reference in new issue
Block a user