fix(input): no double-click follow or zoom on the map

The globe viewer's own double-click tracked a picked entity with a
position or zoomed to one without. Layers moving onto the draw port had it
re-created one by one (data/stockFollow.js); following is a click in GEV,
so the viewer's handler is removed where the viewer is made and every
re-creation goes: earthquakes, cyclones, air quality, news, perimeters,
drone airspace, ghost maps, places, radio, cables, CCTV, ALPR, launches,
bikeshare, Local ADS-B, installations, directions, trails, data packs,
annotations, the library's view and local GeoJSON. The Cockpit's own
double-click and the draw tool's finishing double-click stay.
This commit is contained in:
Sameh Khamis committed 2026-11-14 09:10:14 -08:00
1 parent bb2d22dbce
commit b86014244d
69 files changed
+94 -2797

No files matched your search

+10 -71
View File
@@ -27,9 +27,8 @@
* changing settle into static geometry.
*/
import { cssColor } from '../render/color.js';
import { findDraw, findInput } from '../render/rendererOf.js';
import { findDraw } from '../render/rendererOf.js';
import { registerPickOwner } from './pickRegistry.js';
import { drawnItemTarget, followOnDoubleClick } from './stockFollow.js';
// Trail lines are pickable (a click on one must not fall through to the
// ground under it). A trail hugs its aircraft, so an unclaimed pick would
@@ -44,54 +43,6 @@ registerPickOwner('trails', (pickedId) =>
/** @type {number} Uniquifier for trail set and line ids. */
let _trailSeq = 0;
/**
* Per viewer, its trails' drawn lines by set id and the one double-click
* handler they share: a double-click on a trail line zooms to it, as the
* default renderer zoomed to the polyline entity a trail was drawn as.
* @type {WeakMap<object, {lines: Map<string, (id: string) => object|null>,
* follow: object|null}>}
*/
const doubleClicks = new WeakMap();
/**
* Take part in `viewer`'s trail double-click with the set `setId`, whose
* line by id `lineFor` gives. Returns how to leave it.
*/
function joinDoubleClick(viewer, setId, lineFor) {
let shared = doubleClicks.get(viewer);
if (!shared) {
const lines = new Map();
// A scene that takes no input (or a headless one, with no page to take
// it from) has no double-click.
let input = null;
try {
input = findInput(viewer);
} catch {
input = null;
}
shared = {
lines,
follow: input
? followOnDoubleClick({
viewer,
inputFor: () => input,
name: 'trails',
enabled: () => true,
targetFor: (hit) =>
drawnItemTarget(hit.set, lines.get(hit.set)?.(hit.id)),
})
: null,
};
doubleClicks.set(viewer, shared);
}
shared.lines.set(setId, lineFor);
return () => {
if (!shared.lines.delete(setId) || shared.lines.size) return;
shared.follow?.destroy();
if (doubleClicks.get(viewer) === shared) doubleClicks.delete(viewer);
};
}
/** @constant {number} Alpha where the trail passes the depth test. */
const TRAIL_ALPHA = 0.85;
/** @constant {number} Alpha where the trail is behind/below scene geometry —
@@ -182,21 +133,11 @@ export function createTrail(viewer, { color, width = 2.5 }) {
* the position objects it was drawn from, which never change. */
let chunks = [];
let chunkSeq = 0;
/** Leaves the viewer's trail double-click, once the set is drawn. */
let leaveDoubleClick = null;
/** The line drawn under `id`, for a double-click to zoom to. */
function lineFor(id) {
const shown = drawn.get(id)?.item;
if (shown) return shown.show === false ? null : shown;
return chunks.find((chunk) => chunk.id === id)?.item ?? null;
}
function ensureSet() {
if (set || destroyed || !viewer || viewer.isDestroyed?.()) return set;
set =
findDraw(viewer)?.lines({ id: `trail:${seq}`, show: visible }) ?? null;
if (set) leaveDoubleClick = joinDoubleClick(viewer, set.id, lineFor);
return set;
}
@@ -282,16 +223,16 @@ export function createTrail(viewer, { color, width = 2.5 }) {
}
}
const positions = seg.slice(i, end + 1);
const id = `${bodyId}:${++chunkSeq}`;
const item = lineItem(
id,
positions.map(plain),
TRAIL_ALPHA,
TRAIL_OCCLUDED_ALPHA,
);
const chunk = { id, positions, item };
const chunk = { id: `${bodyId}:${++chunkSeq}`, positions };
next.push(chunk);
added.push(item);
added.push(
lineItem(
chunk.id,
positions.map(plain),
TRAIL_ALPHA,
TRAIL_OCCLUDED_ALPHA,
),
);
i = end;
}
});
@@ -377,8 +318,6 @@ export function createTrail(viewer, { color, width = 2.5 }) {
/** Remove the trail permanently (layer disable/teardown). */
destroy() {
destroyed = true;
leaveDoubleClick?.();
leaveDoubleClick = null;
try {
set?.dispose();
} catch {