mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Take pointer input through one dispatcher per scene
Every layer and tool bound its own ScreenSpaceEventHandler and picked the same click again: with the usual layers on, one click ran about 26 scene.pick and 2 drillPick passes (120-215 ms in NYC with 18 layers). Pointer input now comes in through src/input/dispatcher.js, one handler per scene. A click is picked lazily and at most once per kind of query, and every subscriber reads the same ClickEvent (pick, hit, id, ownerId, gesture, drill, ground). The same click now costs 3 picks and 2 drills, 17-70 ms. - Ambient onClick subscribers run only while no tool holds the pointer, checked once per event; tools subscribe with their lease. Moves and releases always reach ambient subscribers, so hover and drags end cleanly. - Camera input and the viewer's stock select/track clicks are ref-counted holds (suspendCamera, suppressStockClicks). The dispatcher owns the controller's enableInputs, so a Cesium flight that ends no longer turns input back on under a drag or the cockpit. - The draw tool, imagery box, CCTV gizmo, cockpit, directions and every selecting layer use it; bindTrackingClickGesture is gone (the gesture is on the event). A source scan forbids new handlers, enableInputs writes and stock-click removal outside the dispatcher. - The sensor-style pick correction transit had now applies to every layer. - Radio's 8-pick near-miss ring is one 17x17 windowed drill. - A missed pick passed to pickContact is no longer picked again, and a touch tap's contact search shares the click's drill. - A gizmo drag whose release Cesium never reported ends on the next press instead of leaving the camera held. The dispatcher is exported as ./input with the pointer-lease functions, and documented in docs/APPLICATION.md.
This commit is contained in:
1 parent
83ec9473b6
commit
02d492a079
97 files changed
+2506
-1307
No files matched your search
@@ -2,6 +2,7 @@ import * as Cesium from 'cesium';
|
||||
import { viewshedColors, cameraHue } from '../../data/cctvViewshed.js';
|
||||
import { CCTV_OVERLAY_SOURCE_ID } from '../../data/cctvCards.js';
|
||||
import { GIZMO_ID_PREFIX } from '../../data/cctvGizmo.js';
|
||||
import { inputFor } from '../../input/dispatcher.js';
|
||||
import {
|
||||
GROUND_PRIOR_INIT_WAIT_MS,
|
||||
CALIBRATION_RANGE_FLOOR_M,
|
||||
@@ -382,14 +383,12 @@ export function createLifecycle({
|
||||
}
|
||||
parts.rendering.refreshHorizonCulling();
|
||||
|
||||
layerState._clickHandler = new Cesium.ScreenSpaceEventHandler(
|
||||
layerState._viewer.scene.canvas,
|
||||
);
|
||||
parts.selection.bindCctvWorldClickGesture(
|
||||
layerState._clickHandler,
|
||||
(click) => {
|
||||
const input = inputFor(layerState._viewer);
|
||||
const unsubscribeClick = parts.selection.bindCctvWorldClickGesture(
|
||||
input,
|
||||
(event) => {
|
||||
if (!layerState._enabled) return;
|
||||
const picked = layerState._viewer.scene.pick(click.position);
|
||||
const picked = event.pick;
|
||||
const cameraId = parts.selection.extractPickedCameraId(picked);
|
||||
if (cameraId) {
|
||||
activateCctvCameraFromWorldClick(
|
||||
@@ -410,8 +409,8 @@ export function createLifecycle({
|
||||
// its camera exactly like a click on the icon. Cesium click positions
|
||||
// and the recorded rects are both CSS px — direct comparison.
|
||||
const cardId = layerState._cctvOverlayHost.hitTest(
|
||||
click.position.x,
|
||||
click.position.y,
|
||||
event.screenPosition.x,
|
||||
event.screenPosition.y,
|
||||
{ sourceId: CCTV_OVERLAY_SOURCE_ID },
|
||||
)?.entryId;
|
||||
if (cardId && layerState._recordById.has(cardId)) {
|
||||
@@ -430,14 +429,15 @@ export function createLifecycle({
|
||||
parts.selection.deactivateActiveCamera();
|
||||
}
|
||||
},
|
||||
{
|
||||
// Item B: hover summons a card on a cardless camera icon. The gesture
|
||||
// classifier owns MOUSE_MOVE too, so chain hover work through its seam
|
||||
// instead of replacing the travel accumulator's handler.
|
||||
onMouseMove: (movement) =>
|
||||
parts.hover.handleHoverMove(movement?.endPosition),
|
||||
},
|
||||
);
|
||||
// Item B: hover summons a card on a cardless camera icon.
|
||||
const unsubscribeHover = input.onPointer('move', (movement) =>
|
||||
parts.hover.handleHoverMove(movement?.endPosition),
|
||||
);
|
||||
layerState._clickSubscription = () => {
|
||||
unsubscribeClick();
|
||||
unsubscribeHover();
|
||||
};
|
||||
|
||||
await parts.health.syncHealthState(true);
|
||||
// Health ranks crowded cells: thin again now that it has arrived (a
|
||||
@@ -584,13 +584,8 @@ export function createLifecycle({
|
||||
}
|
||||
layerState._calibrationMode = false;
|
||||
releaseContinuousRender('cctv-adjust');
|
||||
if (layerState._clickHandler) {
|
||||
layerState._clickHandler.destroy();
|
||||
layerState._clickHandler = null;
|
||||
}
|
||||
if (teardownViewer?.scene?.screenSpaceCameraController) {
|
||||
teardownViewer.scene.screenSpaceCameraController.enableInputs = true;
|
||||
}
|
||||
layerState._clickSubscription?.();
|
||||
layerState._clickSubscription = null;
|
||||
parts.projection.stopProjectionLoop();
|
||||
parts.geometryQueue.stopGeometryLoadQueue();
|
||||
parts.cards.teardownAmbientCards();
|
||||
|
||||
@@ -1,7 +1,4 @@
|
||||
import {
|
||||
bindTrackingClickGesture,
|
||||
isTrackingClickGesture,
|
||||
} from '../../data/trackingClickGesture.js';
|
||||
import { isTrackingClickGesture } from '../../data/trackingClickGesture.js';
|
||||
import * as Cesium from 'cesium';
|
||||
import { cctvPicks } from './pickState.js';
|
||||
|
||||
@@ -35,24 +32,19 @@ export function createSelection({
|
||||
}
|
||||
|
||||
/**
|
||||
* Bind CCTV activation to clean taps while preserving the layer's hover-move
|
||||
* callback on the shared Cesium handler. Drag-like and long-press gestures do
|
||||
* Bind CCTV activation to clean taps. Drag-like and long-press gestures do
|
||||
* not reach camera activation or focus dispatch.
|
||||
* @param {Cesium.ScreenSpaceEventHandler|Object} handler - Input handler.
|
||||
* @param {(click: Object) => void} onClick - Accepted CCTV click callback.
|
||||
* @param {Object} [options] - Gesture test seams and optional onMouseMove hook.
|
||||
* @returns {void}
|
||||
* @param {import('../../input/dispatcher.js').InputDispatcher} input
|
||||
* @param {(event: import('../../input/dispatcher.js').ClickEvent) => void} onClick
|
||||
* Accepted CCTV click callback.
|
||||
* @returns {() => void} Unsubscribe.
|
||||
*/
|
||||
|
||||
function bindCctvWorldClickGesture(handler, onClick, options = {}) {
|
||||
bindTrackingClickGesture(
|
||||
handler,
|
||||
(click, gesture) => {
|
||||
if (!isTrackingClickGesture(gesture)) return;
|
||||
onClick(click);
|
||||
},
|
||||
options,
|
||||
);
|
||||
function bindCctvWorldClickGesture(input, onClick) {
|
||||
return input.onClick((event) => {
|
||||
if (!isTrackingClickGesture(event.gesture)) return;
|
||||
onClick(event);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,7 +50,7 @@ export function createState({ services }) {
|
||||
|
||||
layerState._lastViewContext = '';
|
||||
|
||||
layerState._clickHandler = null;
|
||||
layerState._clickSubscription = null;
|
||||
|
||||
layerState._count = 0;
|
||||
|
||||
|
||||
Reference in new issue
Block a user