Take the input dispatcher off Cesium: pointer input from the renderer's input port, picks from the query port

The dispatcher now builds on renderer.input and the query port, with
positions as plain {x, y}. Its viewer access count is zero and it leaves
the Cesium allow-list. Layers that read the raw engine pick read the Hit,
drawHit or event.native instead, and pickRegistry's resolvePickId and
pickContact take a Hit, with the raw versions kept in the Cesium adapter.

rendererOf gains findInput, provideUnboundInput and provideNativeClick.
event.native carries the engine's pick, drill and pickWindow, and picks
through the follow helper happen inside it. An unbound input port
survives the viewer being bound until it is released.

The query port's pick memo is now per task rather than per frame,
because Cesium's own picks advance the frame number. A click on the sky
skips the depth pass when nothing is on the ray. Touch contact search
keeps its eight-deep drill in a 14x14 window.
This commit is contained in:
Sameh Khamis committed 2026-11-09 00:47:30 -08:00
1 parent 6eb9ceef46
commit 8bcaced6ad
52 files changed
+1836 -484

No files matched your search

+1 -1
View File
@@ -395,7 +395,7 @@ export function createLifecycle({
input,
(event) => {
if (!layerState._enabled) return;
const picked = event.pick;
const picked = event.topHit;
const cameraId = parts.selection.extractPickedCameraId(
event.drawHit ?? null,
);
+3 -4
View File
@@ -1,7 +1,6 @@
import { hitTestWorldOverlay } from '../../overlays/worldOverlay.js';
import { VESSEL_OVERLAY_SOURCE_ID } from '../../data/vesselLabels.js';
import { inputFor } from '../../input/dispatcher.js';
import { isSurfacePick } from '../../data/scenePick.js';
import {
registerPickOwner,
unregisterPickOwner,
@@ -167,11 +166,11 @@ export function createCyclonesLayer({
if (id) layer.setParams({ stormId: id });
return;
}
// A storm's own drawing names it; empty map (the globe, or 3D tiles,
// which pick as tileset content without an id) clears the selection.
// A storm's own drawing names it; empty map (the globe, or 3D tiles)
// clears the selection.
const id = rendering?.pickStorm(event.drawHit);
if (id) layer.setParams({ stormId: id });
else if (isSurfacePick(event.pick)) layer.setParams({ clear: true });
else if (!event.topHit) layer.setParams({ clear: true });
});
owner.unsubscribe = unsubscribe;
}
+1 -1
View File
@@ -34,7 +34,7 @@ export function createSelection({
if (layerState._clickSubscription || !layerState._viewer) return;
const input = inputFor(layerState._viewer);
layerState._clickSubscription = input.onClick((event) => {
const picked = event.pick;
const picked = event.topHit;
const fire = pickedFire(event.drawHit);
if (fire) {
selectAndFocusFire(fire);
+7 -8
View File
@@ -46,15 +46,14 @@ import { roundHeadingDegrees } from '../../data/headingDegrees.js';
import { entityRecord } from '../../data/entityRecords.js';
/**
* The icao a pick carries: a draw-set item's id (the icon and model sets'
* rows), a string pick id, or a primitive's id.
* The icao a click's hit carries (`event.hit`, the contract's `Hit`): a
* draw-set item's id (the icon and model sets' rows), or the id of
* something drawn outside the draw port (a hit with no set).
*/
function aircraftPickId(picked) {
const id = picked?.id;
if (typeof id === 'string') return id;
if (id && typeof id.set === 'string' && typeof id.id === 'string')
return isOtherTrackedIconSet(id.set, 'flights') ? undefined : id.id;
return picked?.primitive?.id;
function aircraftPickId(hit) {
if (!hit || hit.surface) return undefined;
if (!hit.set) return hit.id || undefined;
return isOtherTrackedIconSet(hit.set, 'flights') ? undefined : hit.id;
}
export function createTracking({
+1 -1
View File
@@ -615,7 +615,7 @@ export function createGhostMapsLayer({
if (_selectedLink && openExternal) openExternal(_selectedLink);
return;
}
const picked = event.pick;
const picked = event.topHit;
const key = picked ? hitKey(event.drawHit) : null;
if (key) {
_selectedKey = key;
+2
View File
@@ -1,3 +1,5 @@
// The click dispatcher's input port over a viewer double: the Cesium adapter's.
import '../../render/cesium/input.js';
import test from 'node:test';
import assert from 'node:assert/strict';
import http from 'node:http';
+7 -8
View File
@@ -45,15 +45,14 @@ import { roundHeadingDegrees } from '../../data/headingDegrees.js';
import { entityRecord } from '../../data/entityRecords.js';
/**
* The icao a pick carries: a draw-set item's id (the icon and model sets'
* rows), a string pick id, or a primitive's id.
* The icao a click's hit carries (`event.hit`, the contract's `Hit`): a
* draw-set item's id (the icon and model sets' rows), or the id of
* something drawn outside the draw port (a hit with no set).
*/
function aircraftPickId(picked) {
const id = picked?.id;
if (typeof id === 'string') return id;
if (id && typeof id.set === 'string' && typeof id.id === 'string')
return isOtherTrackedIconSet(id.set, 'military') ? undefined : id.id;
return picked?.primitive?.id;
function aircraftPickId(hit) {
if (!hit || hit.surface) return undefined;
if (!hit.set) return hit.id || undefined;
return isOtherTrackedIconSet(hit.set, 'military') ? undefined : hit.id;
}
export function createTracking({
+1 -1
View File
@@ -227,7 +227,7 @@ export function createFirePerimetersLayer({
if (_selectedLink && openExternal) openExternal(_selectedLink);
return;
}
const picked = event.pick;
const picked = event.topHit;
const incidentId = picked ? pickedIncidentId(event.drawHit) : null;
if (incidentId) {
abortLinkVerification();
+1 -1
View File
@@ -36,7 +36,7 @@ export function createInteraction({
? stationId
: null;
};
const primaryPick = event.pick;
const primaryPick = event.topHit;
const primaryStationId = stationFromPick(primaryPick);
if (primaryStationId) return primaryStationId;
const primaryId = resolvePickId(primaryPick);
+8 -5
View File
@@ -21,12 +21,15 @@ function interaction() {
});
}
/** A draw-set item's hit. */
const hit = (id, set = 'radio:1:stations') => ({ set, id, surface: false });
/** A click event whose drill answers only with the window it is asked for. */
function clickEvent({ pick, windowHits = [] }) {
const drills = [];
return {
drills,
pick,
topHit: pick ?? null,
drill(limit, width, height) {
drills.push([limit, width, height]);
return width === RADIO_PICK_WINDOW_PX && height === RADIO_PICK_WINDOW_PX
@@ -40,7 +43,7 @@ test('a near miss finds the station through one windowed drill', () => {
const { pickedRadioStationAt } = interaction();
const event = clickEvent({
pick: undefined,
windowHits: [{ id: 'tile' }, { id: 'radio:kexp' }],
windowHits: [hit('notes:1', 'notes:1'), hit('radio:kexp')],
});
assert.equal(pickedRadioStationAt(event), 'kexp');
assert.deepEqual(event.drills, [
@@ -50,12 +53,12 @@ test('a near miss finds the station through one windowed drill', () => {
test('a direct hit needs no drill, and another layer’s contact keeps its click', () => {
const { pickedRadioStationAt } = interaction();
const direct = clickEvent({ pick: { id: 'radio:kexp' } });
const direct = clickEvent({ pick: hit('radio:kexp') });
assert.equal(pickedRadioStationAt(direct), 'kexp');
assert.deepEqual(direct.drills, []);
const other = clickEvent({
pick: { id: 'flight-1' },
windowHits: [{ id: 'radio:kexp' }],
pick: hit('flight-1', 'flights:1'),
windowHits: [hit('radio:kexp')],
});
assert.equal(pickedRadioStationAt(other), null);
});
+1 -1
View File
@@ -45,7 +45,7 @@ export function createInteraction({
layerState._clickSubscription = inputFor(viewer).onClick((event) => {
if (!layerState._enabled) return;
const picked = event.pick;
const picked = event.topHit;
const hit = event.drawHit;
// Clicking the tracked satellite's own dot — ignore
+2
View File
@@ -1,3 +1,5 @@
// The click dispatcher's input port over a viewer double: the Cesium adapter's.
import '../../render/cesium/input.js';
import assert from 'node:assert/strict';
import http from 'node:http';
import { EventEmitter, once } from 'node:events';