mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Give the Cesium renderer the contract's input port
src/render/cesium/input.js feeds the shared router from one ScreenSpaceEventHandler: every button's press, release and click, double clicks, moves and pinches, under any one modifier. The DOM event being dispatched gives the full modifiers and pointer type; an action Cesium raises on a timer takes its own modifier. Wheel comes from the canvas in lines and is never cancelled. Clicks are picked once, lazily, through the query port. Cesium ends every held button on any release; those presses end there, but only the button released clicks. The viewer's stock select and follow move off its handler and run first, as they did, but only for a press no lease took and while not suppressed. Camera holds go through the scene's shared holds, ctrlWheelZoom through ctrlWheelZoom.js. The router gains a before-hook and dispose, which stops delivery mid-event. The conformance renderer exposes the port and the harness feeds it; input.lease, input.lease.grab, input.lease.press, input.clickPick and input.behaviours join the Cesium checks.
This commit is contained in:
1 parent
6921e075d0
commit
1c29a54dc9
8 files changed
+870
-12
No files matched your search
@@ -214,12 +214,20 @@ export function createInputRouter({
|
||||
/**
|
||||
* Delivers one event to the listeners it belongs to.
|
||||
* @param {import('../contract/input').PointerEv} ev
|
||||
* @returns {{lease: object|null, ambient: boolean}} Who it went to, so a
|
||||
* renderer can leave a grabbed press out of its stock behaviours. A
|
||||
* @param {(to: {lease: object|null, ambient: boolean}) => void} [before]
|
||||
* Runs first with who the event goes to: a renderer's stock behaviours,
|
||||
* which run ahead of the subscribers. Its error is reported.
|
||||
* @returns {{lease: object|null, ambient: boolean}} Who it went to. A
|
||||
* `move` or `up` always reads as going to both, grabbed press or not.
|
||||
*/
|
||||
function dispatch(ev) {
|
||||
function dispatch(ev, before) {
|
||||
const to = recipients(ev);
|
||||
if (before)
|
||||
try {
|
||||
before(to);
|
||||
} catch (error) {
|
||||
report(error);
|
||||
}
|
||||
for (const entry of listeners.slice()) {
|
||||
if (!entry.live || entry.type !== ev.type) continue;
|
||||
if (entry.lease) {
|
||||
@@ -240,5 +248,14 @@ export function createInputRouter({
|
||||
dispatch,
|
||||
/** Live listeners, for leak checks. */
|
||||
listenerCount: () => listeners.length,
|
||||
/**
|
||||
* Ends delivery: no listener runs again, even for the event under way
|
||||
* (a listener that destroys the renderer stops the rest).
|
||||
*/
|
||||
dispose() {
|
||||
for (const entry of listeners) entry.live = false;
|
||||
listeners.length = 0;
|
||||
currentLease?.release();
|
||||
},
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user