mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-18 01:02:23 +00:00
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:
1 parent
6eb9ceef46
commit
8bcaced6ad
52 files changed
+1836
-484
No files matched your search
+16
-33
@@ -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);
|
||||
|
||||
|
||||
Reference in new issue
Block a user