fix(cctv): a count click yields to what is on top and keeps its group in frame

- A count click stands aside when an overlay label or another layer's card
  already took the click, and CCTV now claims a count click in the shared
  pick registry, so the flights layer no longer reads it as an empty-map
  click and keeps tracking its aircraft.
- The flight to a group halves the distance only while the group stays in
  frame; otherwise it flies to the nearest ground cell of the group, so a
  tilted click no longer ends with no camera on screen.
- Counts hidden under the HUD no longer push the active icon aside, and a
  lone camera that would move a merged count under the HUD leaves the
  original count and its icon as they were.
- Cameras on one mount are spread before counts merge, so a spread icon no
  longer slides under a neighbouring count.
- The ground module comment says how a camera without a batch height takes
  the drawn terrain.
This commit is contained in:
German Khokhlov committed 2026-11-19 17:52:50 +04:00
1 parent 2b7a6b0c63
commit f6982dc934
16 files changed
+452 -70

No files matched your search

+40 -15
View File
@@ -1,4 +1,7 @@
import { CCTV_OVERLAY_SOURCE_ID } from '../../data/cctvCards.js';
import {
CCTV_COUNT_CARD_SOURCE_ID,
CCTV_OVERLAY_SOURCE_ID,
} from '../../data/cctvCards.js';
import { isTrackingClickGesture } from '../../data/trackingClickGesture.js';
export function createSelection({
@@ -8,7 +11,8 @@ export function createSelection({
source,
}) {
const { CCTV_ACTIVATION_RESULT } = services.activation;
const { resolvePickId, findPickOwner } = services.picking;
const { resolvePickId, findPickOwner, isUnderOtherCard } = services.picking;
const OWN_CARD_SOURCES = [CCTV_OVERLAY_SOURCE_ID, CCTV_COUNT_CARD_SOURCE_ID];
/**
* Returns the camera record for the currently active camera. A stale ID falls
@@ -30,15 +34,8 @@ export function createSelection({
return fallback;
}
/** A card painted above the count, or another layer's object, owns the click. */
function countYields(event) {
const { x, y } = event.screenPosition;
if (
layerState._cctvOverlayHost?.hitTest(x, y, {
sourceId: CCTV_OVERLAY_SOURCE_ID,
})?.entryId
)
return true;
/** Whether another layer's scene object owns the click at this count. */
function sceneTakesCountClick(event) {
const top = event.topHit;
if (!top) return false;
const drawHit = event.drawHit;
@@ -47,6 +44,34 @@ export function createSelection({
return id !== null && findPickOwner?.(id) !== 'cctv';
}
/** Leave other layers' cards to the caller since clickCard also calls this. */
function clickedCount(event) {
if (
!isTrackingClickGesture(event.gesture) ||
!layerState._enabled ||
event.overlay
)
return null;
const cell = layerState._counts?.pickedCell(event.screenPosition);
if (!cell) return null;
const { x, y } = event.screenPosition;
if (
layerState._cctvOverlayHost?.hitTest(x, y, {
sourceId: CCTV_OVERLAY_SOURCE_ID,
})?.entryId
)
return null;
return sceneTakesCountClick(event) ? null : cell;
}
/** The count marker as the card on top of a click it takes, for every layer's clickCard. */
function countClickCard(event) {
const cell = clickedCount(event);
return cell
? { sourceId: CCTV_COUNT_CARD_SOURCE_ID, entryId: String(cell.key ?? '') }
: null;
}
/**
* Bind CCTV activation to clean taps. Drag-like and long-press gestures do
* not reach camera activation or focus dispatch.
@@ -59,10 +84,9 @@ export function createSelection({
function bindCctvWorldClickGesture(input, onClick) {
return input.onClick((event) => {
if (!isTrackingClickGesture(event.gesture)) return;
const cell =
layerState._enabled &&
layerState._counts?.pickedCell(event.screenPosition);
if (cell && !countYields(event)) {
const cell = clickedCount(event);
// Another layer's card or label painted above the count takes the click.
if (cell && !isUnderOtherCard?.(event, OWN_CARD_SOURCES)) {
parts.navigation.zoomToCell(cell);
return;
}
@@ -243,6 +267,7 @@ export function createSelection({
return {
getActiveRecord,
bindCctvWorldClickGesture,
countClickCard,
setActiveCamera,
deactivateActiveCamera,
cctvEmptyClickDeselects,