fix(touch): give each tap to the layer that acts on it

On a coarse pointer the dispatcher can name a contact near the tap instead
of the exact pick. Only flights, military, vessels, radio and Street Level
act on such a contact, so they now register as expanded pick owners, and a
quake card or label yields only to them. A FIRMS fire or CCTV camera reached
only as a nearby contact no longer swallows a quake card, a quake label or
a vessel's own card tap, and FIRMS and CCTV cards yield to a contact whose
layer does act on it.

Radio and Street Level also pick through their own windows. A station or
Street Level item found only there, not as the touch contact, yields to
another layer's card painted over it, and Street Level takes its own touch
contact beyond its narrower window.

Fire, CCTV and vessel cards now act over a passive owner's pick (a flight
trail, the directions route), as the quake card does. The Context panel
leaves a passive route, or a fire or camera reached only as a nearby
contact, to the card painted over it.
This commit is contained in:
manjunath22466 committed 2026-11-17 13:18:32 +05:30
1 parent 4804097ca1
commit 830c980ca6
26 files changed
+1095 -69

No files matched your search

+4 -2
View File
@@ -192,8 +192,10 @@ export function createLifecycle({
});
}
// Pick-ownership (H2): a vessel icon's pick id is its row id, the record's id.
registerPickOwner('ais-live-vessels', (pickedId) =>
state.records.byId.has(pickedId),
registerPickOwner(
'ais-live-vessels',
(pickedId) => state.records.byId.has(pickedId),
{ expanded: true },
);
// Vessels are asked for by view, so ask again when the view moves away.
removeViewListener();
+33 -5
View File
@@ -10,7 +10,8 @@ export function createSelection({
options,
}) {
const { state } = vesselState;
const { isOwnedByOtherLayer } = services.picking;
const { isOwnedByOtherLayer, isActedOnByOtherLayer, resolvePickId } =
services.picking;
const { requestWorldFocus } = services.worldFocus;
const {
selectEntityContext,
@@ -47,19 +48,46 @@ export function createSelection({
// `gev-trail:*` pick is also a no-op. Every other non-vessel pick — sibling
// unowned scene picks dismiss the current vessel inspection.
if (ownRecordPick && (!pickedId || !record)) return;
if (pickedId && !record && String(pickedId).startsWith('gev-trail:'))
return;
/** Whether this layer's own card is painted under the click. */
const ownCardUnder = () =>
vesselState._vesselOverlayHost.hitTest?.(
event.screenPosition?.x,
event.screenPosition?.y,
)?.sourceId === VESSEL_OVERLAY_SOURCE_ID;
// A passive owner's pick (a trail, a directions route) acts for nobody:
// a card of ours painted over it keeps the click; otherwise a no-op.
const passivePick =
Boolean(pickedId) &&
!record &&
(String(pickedId).startsWith('gev-trail:') ||
(Boolean(isActedOnByOtherLayer) &&
isOwnedByOtherLayer('ais-live-vessels', pickedId) &&
!isActedOnByOtherLayer('ais-live-vessels', pickedId)));
if (passivePick && !ownCardUnder()) return;
// A sibling layer already owns this click. Preserve the current vessel
// selection and do not compete with its camera command.
const siblingOwned =
pickedId && isOwnedByOtherLayer('ais-live-vessels', pickedId);
!passivePick &&
pickedId &&
isOwnedByOtherLayer('ais-live-vessels', pickedId);
// Cyclone geometry is ambient context behind painted cards. Its handler
// yields to the same foreground AIS hit. Keep moving-contact precedence
// unchanged: those handlers may issue their own camera command.
const cycloneBackground =
siblingOwned && !isOwnedByOtherLayer('weather-cyclones', pickedId);
if (siblingOwned && !cycloneBackground) return;
if (siblingOwned && !cycloneBackground) {
// A coarse tap's nearby contact (not the exact pick) whose layer acts
// only on exact hits (a fire, a camera) does not take a tap on this
// layer's own card: that card keeps it.
const nearMissOfExactOnly =
isActedOnByOtherLayer &&
resolvePickId?.(event.topHit ?? null) !== pickedId &&
!isActedOnByOtherLayer('ais-live-vessels', pickedId, {
expanded: true,
});
if (!nearMissOfExactOnly || !ownCardUnder()) return;
}
// Cards are painted on a pointer-events:none canvas, so the scene pick is
// usually terrain behind the card. Resolve against the host's current