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

+2 -1
View File
@@ -1158,7 +1158,8 @@ test('vessel touch interaction yields to the first nearby flight behind map tile
// The click's shared drill: the 14 px touch window, at least 8 deep.
assert.deepEqual([width, height], [14, 14]);
assert.ok(limit >= 8);
return [tile, { id: 'a1b2c3' }];
// The flight's icon: a draw-set item.
return [tile, { id: { set: 'flights:1', id: 'a1b2c3' } }];
};
try {
harness.handler.click({ position: { x: 10, y: 20 } });
+6 -6
View File
@@ -1078,7 +1078,7 @@ test('CCTV empty-click gate excludes every identified scene object, ADJUST, and
assert.equal(cctvEmptyClickDeselects(null, { activeCameraId: null }), false);
assert.equal(
cctvEmptyClickDeselects(
{ id: 'registered-sibling' },
{ set: 'flights:1', id: 'registered-sibling', surface: false },
{
activeCameraId: 'cam-1',
},
@@ -1087,7 +1087,7 @@ test('CCTV empty-click gate excludes every identified scene object, ADJUST, and
);
assert.equal(
cctvEmptyClickDeselects(
{ id: { id: 'unregistered-local-entity' } },
{ set: '', id: 'unregistered-local-entity', surface: false },
{
activeCameraId: 'cam-1',
},
@@ -1096,7 +1096,7 @@ test('CCTV empty-click gate excludes every identified scene object, ADJUST, and
);
assert.equal(
cctvEmptyClickDeselects(
{ primitive: { id: 'unregistered-primitive' } },
{ set: '', id: 'unregistered-primitive', surface: false },
{
activeCameraId: 'cam-1',
},
@@ -1105,7 +1105,7 @@ test('CCTV empty-click gate excludes every identified scene object, ADJUST, and
);
assert.equal(
cctvEmptyClickDeselects(
{ id: '' },
{ set: '', id: '', surface: false },
{
activeCameraId: 'cam-1',
},
@@ -1115,13 +1115,13 @@ test('CCTV empty-click gate excludes every identified scene object, ADJUST, and
);
assert.equal(
cctvEmptyClickDeselects(
{ primitive: {} },
{ set: '', id: null, surface: false },
{
activeCameraId: 'cam-1',
},
),
true,
'an ID-less surface pick remains true empty space',
'something with no id remains true empty space',
);
const initSource = componentFunctionSource(cctvLayer.init);
+14 -28
View File
@@ -131,21 +131,18 @@ test('two viewers use their supplied contexts and dispose independently', async
);
// A click picks the feature's stem, as the renderer's pick names it.
const viewer = {
scene: {
screenSpaceCameraController: { enableInputs: true },
pick: () => {
const [stem] = fake.set('stems').items.values();
return {
id: {
set: fake.set('stems').spec.id,
id: stem.id,
meta: stem.meta,
},
};
},
},
scene: { screenSpaceCameraController: { enableInputs: true } },
};
const fake = bindFakeGroundRenderer(viewer);
fake.setPick(() => {
const [stem] = fake.set('stems').items.values();
return {
set: fake.set('stems').spec.id,
id: stem.id,
meta: stem.meta,
surface: false,
};
});
const input = fakeInput(viewer);
return { layer, viewer, fake, click: () => input.click({ x: 0, y: 0 }) };
});
@@ -196,44 +193,33 @@ test('consumer build includes only infrastructure code and resolves assets under
const output = result.output;
const entry = output.find((item) => item.type === 'chunk' && item.isEntry);
const sources = Object.keys(entry.modules).filter((id) => id.endsWith('.js'));
// It draws through the renderer's ports: a viewer of the caller's own
// draws once the caller has loaded `./render/cesium/unbound`.
// It draws and takes clicks through the renderer's ports: a viewer of the
// renderer bound draws once the caller has loaded
// `./render/cesium/unbound`.
assert.deepEqual(sources.map((id) => id.split('/').at(-1)).sort(), [
'cameraControls.js',
'cameraInput.js',
'color.js',
'ctrlWheelZoom.js',
'dispatcher.js',
'drawHit.js',
'ellipsoid.js',
'follow.js',
'frames.js',
'geojsonPins.js',
'heights.js',
'infrastructure.js',
'infrastructureData.js',
'infrastructureOverlayEntry.js',
'input.js',
'inputOwnership.js',
'localGeojsonCore.js',
'localGeojsonLod.js',
'pickRegistry.js',
'rendererOf.js',
'rhumb.js',
'router.js',
'scenePick.js',
'sensorPick.js',
'sphere.js',
'stockFollow.js',
'styleStages.js',
'vector.js',
'wheel.js',
]);
assert.deepEqual(
entry.imports,
['cesium'],
'the viewer supplies the same Cesium dependency',
);
assert.deepEqual(entry.imports, [], 'it reaches no Cesium of its own');
for (const name of ['datacenters', 'dams']) {
const asset = output.find(
(item) => item.type === 'asset' && item.fileName.includes(name),
+42 -36
View File
@@ -11,35 +11,34 @@
* that belong to someone else and leave them alone.
*/
import { isSurfacePick } from './scenePick.js';
/**
* A click's hits are the renderer contract's `Hit` (src/render/contract/
* query.d.ts), plus, for something drawn outside the draw port, a `Hit`
* with no set (`set: ''`, `id` null when it has none) named by the renderer
* adapter
* (`nativeClickOf`, src/render/rendererOf.js). The raw forms of these
* rules, for code that still holds a Cesium pick, are the adapter's
* (src/render/cesium/nativeClick.js).
*/
/** Whether a hit is the map itself, or nothing. */
const isSurface = (hit) => !hit || hit.surface === true;
/** @type {Map<string, (pickedId: string) => boolean>} layerId -> ownership predicate */
const _owners = new Map();
/**
* Resolves a scene.pick() result to a String pick id for the ownership scan.
* A hit's canonical pick id, for the ownership scan: its item's id. Layers'
* ids differ (strings, satellites' NORAD catalog numbers as strings), but a
* draw-set item's id is always a string.
*
* Layers use heterogeneous pick ids: flights/military/vessels/bikeshare/CCTV
* use strings, satellites use numeric NORAD catalog ids, and entity picks
* surface the Cesium Entity (identity = its string `id`). Everything is
* coerced to a String so predicates match against one canonical form.
*
* @param {object|null|undefined} picked - Result of `scene.pick()`.
* @returns {string|null} Canonical pick id, or null when the pick carries none.
* @param {import('../render/contract/query').Hit|null|undefined} hit
* @returns {string|null} Its id (an empty one is still an id); null for the
* map, nothing, or something with no id.
*/
export function resolvePickId(picked) {
if (!picked) return null;
const unwrap = (id) => {
if (id === null || id === undefined) return undefined;
if (typeof id === 'object') {
// A Cesium Entity (.id string)
if (typeof id.id === 'string' || typeof id.id === 'number') return id.id;
return undefined;
}
return id;
};
let id = unwrap(picked.id);
if (id === undefined) id = unwrap(picked.primitive?.id);
export function resolvePickId(hit) {
if (isSurface(hit)) return null;
const id = hit.id;
return typeof id === 'string' || typeof id === 'number' ? String(id) : null;
}
@@ -103,25 +102,28 @@ export function isOwnedByOtherLayer(layerId, pickedId) {
/**
* Resolve a moving-contact click without letting map tiles hide a nearby touch
* target. Exact picks always win; only a coarse primary pointer may expand a
* surface miss. Every consumer uses the same ordered, bounded scene hits, so sibling layers
* do not each choose their own contact under one tap.
* Unowned non-surface objects remain barriers, not permission to pick through.
* surface miss. Every consumer uses the same ordered, bounded hits, so sibling
* layers do not each choose their own contact under one tap.
* Unowned items remain barriers, not permission to pick through.
*
* @param {object} scene Cesium scene with pick and optional drillPick.
* @param {import('../render/contract/query').QueryPort} query
* @param {{x: number, y: number}} position Screen position in CSS pixels.
* @param {{picked?: object|null, drill?: (limit: number, width: number, height: number) => object[]}} [options]
* @param {{picked?: import('../render/contract/query').Hit|null, drill?: (limit: number, width: number, height: number) => import('../render/contract/query').Hit[]}} [options]
* The click's own passes when the caller has them, so a click is picked
* once: `picked` is `scene.pick(position)` (a miss is passed as `undefined`
* too, so the key's presence counts), `drill` a shared `scene.drillPick`.
* @returns {object|null|undefined} Original pick or the first registered touch hit.
* once: `picked` is `query.pick(position)` (a miss is passed as `null`
* too, so the key's presence counts), `drill` a shared `query.drillPick`.
* @returns {import('../render/contract/query').Hit|null} The pick, or the
* first registered touch hit.
*/
export function pickContact(scene, position, options = {}) {
const picked = 'picked' in options ? options.picked : scene.pick(position);
export function pickContact(query, position, options = {}) {
const picked =
'picked' in options
? options.picked
: (query.pick(position.x, position.y) ?? null);
if (
!globalThis.matchMedia?.('(pointer: coarse)').matches ||
findPickOwner(resolvePickId(picked)) ||
!isSurfacePick(picked) ||
typeof scene.drillPick !== 'function'
!isSurface(picked)
)
return picked;
let hits;
@@ -129,13 +131,17 @@ export function pickContact(scene, position, options = {}) {
hits =
(options.drill
? options.drill(8, 14, 14)
: scene.drillPick(position, 8, 14, 14)) || [];
: query.drillPick(position.x, position.y, {
width: 14,
height: 14,
limit: 8,
})) || [];
} catch {
return picked;
}
for (const hit of hits.slice(0, 8)) {
if (findPickOwner(resolvePickId(hit))) return hit;
if (!isSurfacePick(hit)) break;
if (!isSurface(hit)) break;
}
return picked;
}
+64 -78
View File
@@ -2,9 +2,9 @@
* Pick-ownership contract tests (pre-ship audit H2).
*
* Locks the cross-layer pick coercion rules:
* - resolvePickId reduces every layer's pick shape (string icao/station ids,
* numeric NORAD ids, AIS vessel record objects, Cesium Entity objects) to
* ONE canonical String id.
* - resolvePickId reads a click's hit (the contract's `Hit`, or one with no
* set for something drawn outside the draw port) as ONE canonical String
* id: its item's id.
* - isOwnedByOtherLayer consults sibling predicates only, never the asker's,
* and never throws on a broken predicate.
*/
@@ -23,27 +23,25 @@ import {
// resolvePickId — canonical String coercion for every layer's pick shape
// ---------------------------------------------------------------------------
test('resolvePickId: string pick id (flights/military/bikeshare/cctv billboards)', () => {
assert.equal(resolvePickId({ id: 'aaa001' }), 'aaa001');
assert.equal(resolvePickId({ id: undefined, primitive: { id: 'station:austin:1' } }), 'station:austin:1');
const item = (set, id) => ({ set, id, surface: false });
const SURFACE = { set: '', id: '', surface: true };
test("resolvePickId: a draw-set item's hit → its item id", () => {
assert.equal(resolvePickId(item('flights:1', 'aaa001')), 'aaa001');
assert.equal(resolvePickId(item('satellites:1:dots', '25544')), '25544');
});
test('resolvePickId: numeric pick id (satellite NORAD numbers) → String', () => {
assert.equal(resolvePickId({ id: 25544 }), '25544');
assert.equal(resolvePickId({ id: undefined, primitive: { id: 43013 } }), '43013');
test('resolvePickId: something drawn outside the draw port → its own id', () => {
assert.equal(resolvePickId(item('', 'transit:bus-1')), 'transit:bus-1');
assert.equal(resolvePickId(item('', null)), null, 'it has none');
assert.equal(resolvePickId(item('', '')), '', 'an empty id is still an id');
});
test('resolvePickId: Cesium-Entity-like object → its string id', () => {
const entity = { id: 'cctv-atx-cam-3-center', properties: {} };
assert.equal(resolvePickId({ id: entity }), 'cctv-atx-cam-3-center');
});
test('resolvePickId: unresolvable picks → null', () => {
test('resolvePickId: the map and nothing → null', () => {
assert.equal(resolvePickId(null), null);
assert.equal(resolvePickId(undefined), null);
assert.equal(resolvePickId({}), null);
assert.equal(resolvePickId({ id: {} }), null); // object with no id
assert.equal(resolvePickId({ primitive: {} }), null);
assert.equal(resolvePickId(SURFACE), null);
assert.equal(resolvePickId({ ...SURFACE, id: 'tile' }), null);
});
// ---------------------------------------------------------------------------
@@ -60,9 +58,9 @@ test('ownership: sibling layers recognize each other via String-coerced ids', ()
registerPickOwner('ais-live-vessels', (pickedId) => vessels.has(pickedId));
try {
// Flights asking about a satellite pick (raw numeric id → String upstream)
assert.equal(isOwnedByOtherLayer('flights', resolvePickId({ id: 25544 })), true);
assert.equal(isOwnedByOtherLayer('flights', resolvePickId(item('sat:1', '25544'))), true);
// Flights asking about a vessel pick (an icon row id: the mmsi)
assert.equal(isOwnedByOtherLayer('flights', resolvePickId({ id: '367123450' })), true);
assert.equal(isOwnedByOtherLayer('flights', resolvePickId(item('ais:1', '367123450'))), true);
// A layer never owns its own pick via the sibling scan
assert.equal(isOwnedByOtherLayer('satellites', '25544'), false);
// Unknown ids belong to nobody
@@ -115,38 +113,48 @@ function contactOwners(t) {
});
}
const mapTile = { primitive: { isCesium3DTileset: true } };
/** A query port double: one pick, and a drill that records its asks. */
function query(picked, drillPick = () => assert.fail('must not drill')) {
return {
pick: () => picked,
drillPick,
};
}
test('touch contact pick expands only a surface miss, bounded to 8 hits in 14 CSS pixels', (t) => {
primaryPointer(t, true);
contactOwners(t);
const position = { x: 30, y: 50 };
const contact = { primitive: { id: 'civil' } };
const contact = item('flights:1', 'civil');
let drills = 0;
const scene = {
pick(point) {
assert.equal(point, position);
return mapTile;
},
drillPick(...args) {
drills++;
assert.deepEqual(args, [position, 8, 14, 14]);
return [mapTile, contact];
},
};
assert.equal(pickContact(scene, position), contact);
const port = query(SURFACE, (...args) => {
drills++;
assert.deepEqual(args, [30, 50, { width: 14, height: 14, limit: 8 }]);
return [contact];
});
assert.equal(pickContact(port, position), contact);
assert.equal(drills, 1);
});
test("touch contact pick uses the click's own pick and drill", (t) => {
primaryPointer(t, true);
contactOwners(t);
const contact = item('flights:1', 'civil');
const asked = [];
const found = pickContact(query(null), { x: 1, y: 1 }, {
picked: null,
drill: (...args) => (asked.push(args), [contact]),
});
assert.equal(found, contact);
assert.deepEqual(asked, [[8, 14, 14]]);
});
test('touch contact pick returns the first registered sibling, never a caller-specific preference', (t) => {
primaryPointer(t, true);
contactOwners(t);
for (const first of [{ id: 'military' }, { id: '123456789' }]) {
const scene = {
pick: () => mapTile,
drillPick: () => [mapTile, first, { id: 'civil' }],
};
assert.equal(pickContact(scene, { x: 1, y: 1 }), first);
for (const first of [item('mil:1', 'military'), item('ais:1', '123456789')]) {
const port = query(SURFACE, () => [first, item('flights:1', 'civil')]);
assert.equal(pickContact(port, { x: 1, y: 1 }), first);
}
});
@@ -154,60 +162,38 @@ test('touch contact pick does not drill through exact registered or unregistered
primaryPointer(t, true);
contactOwners(t);
for (const exact of [
{ id: 'military' },
{ id: 'custom-annotation' },
{ primitive: { id: 'custom-gizmo' } },
{ primitive: { id: 'civil', isCesium3DTileset: true } },
]) {
const scene = {
pick: () => exact,
drillPick: () => assert.fail('must keep exact interactive hit'),
};
assert.equal(pickContact(scene, { x: 1, y: 1 }), exact);
}
item('mil:1', 'military'),
item('notes:1', 'custom-annotation'),
item('', 'custom-gizmo'),
])
assert.equal(pickContact(query(exact), { x: 1, y: 1 }), exact);
});
test('touch expansion stops at a non-surface object and respects the drill bound', (t) => {
test('touch expansion stops at an unowned item and respects the drill bound', (t) => {
primaryPointer(t, true);
contactOwners(t);
for (const hits of [
[mapTile, { id: 'custom-annotation' }, { id: 'civil' }],
[...Array(8).fill(mapTile), { id: 'civil' }],
[mapTile],
]) {
assert.equal(
pickContact(
{ pick: () => mapTile, drillPick: () => hits },
{ x: 1, y: 1 },
),
mapTile,
);
}
[item('notes:1', 'custom-annotation'), item('flights:1', 'civil')],
[...Array(8).fill(item('notes:1', 'x')), item('flights:1', 'civil')],
[],
])
assert.equal(pickContact(query(SURFACE, () => hits), { x: 1, y: 1 }), SURFACE);
});
test('fine primary pointers keep the existing exact mouse pick without a drill', (t) => {
test('fine primary pointers keep the exact mouse pick without a drill', (t) => {
primaryPointer(t, false);
contactOwners(t);
const scene = {
pick: () => mapTile,
drillPick: () => assert.fail('mouse must not expand'),
};
assert.equal(pickContact(scene, { x: 1, y: 1 }), mapTile);
assert.equal(pickContact(query(SURFACE), { x: 1, y: 1 }), SURFACE);
});
test('touch picking tolerates unavailable or failing drill support and preserves empty sky', (t) => {
test('touch picking tolerates a failing drill and preserves empty sky', (t) => {
primaryPointer(t, true);
contactOwners(t);
for (const drillPick of [
undefined,
() => {
throw new Error('context lost');
},
() => [],
]) {
assert.equal(
pickContact({ pick: () => undefined, drillPick }, { x: 1, y: 1 }),
undefined,
);
}
])
assert.equal(pickContact(query(null, drillPick), { x: 1, y: 1 }), null);
});
+16 -33
View File
@@ -3,17 +3,17 @@ import { readEntityRecord } from './entityRecords.js';
import { findPickOwner, resolvePickId } from './pickRegistry.js';
/**
* Resolve a `scene.pick()` result to the identity a person would name: which
* layer, which record, and its display label.
* Resolve a pick (the contract's `Hit`, as `pickAt` in
* src/input/dispatcher.js gives it) to the identity a person would name:
* which layer, which record, and its display label.
*
* Two lanes, in order:
* 1. Context-store carriers. Entity-backed layers (selected vessels, fires,
* installations) write a `contextId` into the picked object's entity
* record, and layers drawing through the draw port (infrastructure
* GeoJSON) into a draw item's `meta`; the store record already carries
* the label and position voice uses everywhere else.
* 2. Pick owners. Primitive-backed layers (aircraft, satellites, vessels)
* register an ownership predicate in `pickRegistry`; the owning layer's
* 1. Context-store carriers. Layers drawing through the draw port
* (infrastructure GeoJSON, ALPR) write a `contextId` into a draw item's
* `meta`; the store record already carries the label and position voice
* uses everywhere else.
* 2. Pick owners. Layers (aircraft, satellites, vessels) register an
* ownership predicate in `pickRegistry`; the owning layer's
* `findByQuery` turns the pick id into a live descriptor.
*
* Trails claim their pick ids only to make clicks inert, so they never
@@ -47,28 +47,11 @@ export function pickedKindForLayer(layerId) {
return KIND_BY_LAYER[layerId] || 'feature';
}
/** A pick of a draw-set item (its id is `{set, id, meta}`): the item's `meta`. */
function drawItemMeta(picked) {
const id = picked?.id;
return id && typeof id.set === 'string' && typeof id.id === 'string'
? id.meta
: undefined;
}
function contextCarrierRecord(picked, dataManager) {
const store = getContextStore();
for (const carrier of [
picked?.id,
picked?.primitive?.id,
picked?.primitive,
drawItemMeta(picked),
]) {
const contextId = readEntityRecord(carrier)?.contextId;
if (!contextId) continue;
const record = store.entities.get(contextId);
if (record && isContextRecordActive(record, dataManager)) return record;
}
return null;
function contextCarrierRecord(hit, dataManager) {
const contextId = readEntityRecord(hit?.meta)?.contextId;
if (!contextId) return null;
const record = getContextStore().entities.get(contextId);
return record && isContextRecordActive(record, dataManager) ? record : null;
}
function fromRecord(record) {
@@ -104,13 +87,13 @@ function descriptorLabel(found, fallback) {
}
/**
* @param {object|null} picked Result of `scene.pick()`.
* @param {import('../render/contract/query').Hit|null} picked
* @param {object} [options]
* @param {object} [options.dataManager] Layer lifecycle (enabled state, modules).
* @returns {{layerId: string, id: string, label: string, kind: string, lat: number|null, lon: number|null, altitudeM?: number|null}|null}
*/
export function resolvePickedContext(picked, { dataManager = null } = {}) {
if (!picked) return null;
if (!picked || picked.surface) return null;
const record = contextCarrierRecord(picked, dataManager);
if (record) return fromRecord(record);
+16 -26
View File
@@ -30,7 +30,7 @@ test('an aircraft billboard resolves through its pick owner to a live label', ()
},
},
});
const picked = { id: 'a1b2c3', primitive: {} };
const picked = { set: 'flights:1', id: 'a1b2c3', surface: false };
assert.equal(findPickOwner('a1b2c3'), 'flights');
assert.deepEqual(resolvePickedContext(picked, { dataManager }), {
layerId: 'flights',
@@ -44,26 +44,6 @@ test('an aircraft billboard resolves through its pick owner to a live label', ()
unregisterPickOwner('flights');
});
test('an entity-backed feature resolves through the context store', () => {
const entity = { show: true };
registerEntityContext(entity, {
id: 'local-datacenters:7',
layerId: 'local-datacenters',
label: 'Data Center 7',
latitude: 30.1,
longitude: -97.6,
});
const out = resolvePickedContext({ id: entity }, { dataManager: manager() });
assert.deepEqual(out, {
layerId: 'local-datacenters',
id: 'local-datacenters:7',
label: 'Data Center 7',
kind: 'feature',
lat: 30.1,
lon: -97.6,
});
});
test('a draw-set item resolves through the context record its meta carries', () => {
const carrier = { show: true };
registerEntityContext(carrier, {
@@ -73,8 +53,8 @@ test('a draw-set item resolves through the context record its meta carries', ()
latitude: 30.3,
longitude: -97.5,
});
// A Cesium pick of a draw-set item: its id is the item's pick id.
const picked = { id: { set: 'local-datacenters#1:fills', id: '8', meta: carrier }, primitive: {} };
// A draw-set item's hit carries the item's meta as it was given.
const picked = { set: 'local-datacenters#1:fills', id: '8', meta: carrier, surface: false };
assert.deepEqual(resolvePickedContext(picked, { dataManager: manager() }), {
layerId: 'local-datacenters',
id: 'local-datacenters:8',
@@ -88,12 +68,22 @@ test('a draw-set item resolves through the context record its meta carries', ()
assert.equal(resolvePickedContext(picked, { dataManager: manager() }), null);
});
test('something drawn outside the draw port resolves through its pick owner', () => {
registerPickOwner('flights', (id) => id === 'z9');
const out = resolvePickedContext({ set: '', id: 'z9', surface: false }, { dataManager: manager() });
assert.equal(out?.layerId, 'flights');
assert.equal(out?.id, 'z9');
unregisterPickOwner('flights');
});
test('disabled layers, trails and empty picks never resolve', () => {
registerPickOwner('military', (id) => id === 'm1');
assert.equal(resolvePickedContext({ id: 'm1' }, { dataManager: manager() }), null, 'military is disabled');
const hit = (id) => ({ set: 'x:1', id, surface: false });
assert.equal(resolvePickedContext(hit('m1'), { dataManager: manager() }), null, 'military is disabled');
unregisterPickOwner('military');
assert.equal(resolvePickedContext({ id: 'gev-trail:1' }, { dataManager: manager() }), null);
assert.equal(resolvePickedContext(hit('gev-trail:1'), { dataManager: manager() }), null);
assert.equal(resolvePickedContext(null), null);
assert.equal(resolvePickedContext({ id: 'unknown' }, { dataManager: manager() }), null);
assert.equal(resolvePickedContext({ set: '', id: '', surface: true }), null);
assert.equal(resolvePickedContext(hit('unknown'), { dataManager: manager() }), null);
assert.equal(pickedKindForLayer('ais-live-vessels'), 'vessel');
});
+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 * as Cesium from 'cesium';
+10 -4
View File
@@ -164,16 +164,22 @@ test('the guard rejects each way Cesium mishandles a degenerate pick', () => {
test('the ground under a click: the rendered surface, else the ellipsoid, never the sky', async () => {
const { pickGroundPosition } = await import('../input/dispatcher.js');
const { bindRenderer } = await import('../render/rendererOf.js');
const ground = { x: 6378137, y: 0, z: 0 };
const sky = { x: 500, y: 0, z: 0 };
const viewer = (picked, ellipsoid) => ({
scene: { pickPositionSupported: true, pickPosition: () => picked },
camera: { pickEllipsoid: () => ellipsoid },
});
// Through the renderer's query port.
const viewer = (picked, ellipsoid) => {
const host = {};
bindRenderer(host, {
query: { pickPosition: () => picked, pickEllipsoid: () => ellipsoid },
});
return host;
};
assert.equal(pickGroundPosition(viewer(ground, null), {}), ground);
assert.equal(pickGroundPosition(viewer(sky, ground), {}), ground);
assert.equal(pickGroundPosition(viewer(undefined, undefined), {}), null);
assert.equal(pickGroundPosition(null, {}), null);
assert.equal(pickGroundPosition({}, {}), null, 'no query port');
});
test('a surface pick is nothing, or Google 3D tile content without an id', async () => {