mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
feat(data): the selection dispatcher treats an unowned pick as empty space
Task 10a moves flights onto the dispatcher; its old handler deselected on a pick nobody owns (an unclaimed entity), and only another layer's pick was not empty space. The dispatcher now does the same (after drill-through owners had their chance), and selectionDispatcherFor(engine) gives the application one dispatcher per engine. Tests for both.
This commit is contained in:
1 parent
9f1a0611fa
commit
8e702f0c3b
2 files changed
+56
-3
No files matched your search
@@ -9,8 +9,8 @@
|
||||
// onEmptyClick(ctx) a clean click (short, no drag) on the map or nothing;
|
||||
// onEscape() Escape.
|
||||
// The rules are the old handlers': a pick another layer owns is not empty
|
||||
// space; `passThrough` picks (trails) never take the click, the next pick
|
||||
// does; a `drillThrough` owner (local ADS-B) takes its object from under
|
||||
// space (a pick nobody owns is); `passThrough` picks (trails) never take the
|
||||
// click, the next pick does; a `drillThrough` owner (local ADS-B) takes its object from under
|
||||
// another layer's; a drag selects nothing; a pointer owned by a tool
|
||||
// (inputOwnership) selects nothing. Layers not moved yet keep their own
|
||||
// handlers: the dispatcher never acts on an id it does not own.
|
||||
@@ -125,6 +125,10 @@ export function createSelectionDispatcher(
|
||||
return;
|
||||
}
|
||||
}
|
||||
// A pick no layer owns (an unclaimed entity) is empty space, as it was
|
||||
// for the old handlers: only another layer's object is not.
|
||||
if (first.owner === null && isTrackingClickGesture(gesture))
|
||||
for (const owner of [...owners.values()]) owner.onEmptyClick?.(ctx);
|
||||
};
|
||||
|
||||
const onKey = (event) => {
|
||||
@@ -186,6 +190,23 @@ export function createSelectionDispatcher(
|
||||
};
|
||||
}
|
||||
|
||||
const dispatchers = new WeakMap();
|
||||
|
||||
/**
|
||||
* The application's one dispatcher for `engine`, created on first use (the
|
||||
* layers that moved onto the engine share it).
|
||||
* @param {import('../globe/contract.js').GlobeEngine} engine
|
||||
*/
|
||||
export function selectionDispatcherFor(engine) {
|
||||
if (!engine) return null;
|
||||
let dispatcher = dispatchers.get(engine);
|
||||
if (!dispatcher) {
|
||||
dispatcher = createSelectionDispatcher(engine);
|
||||
dispatchers.set(engine, dispatcher);
|
||||
}
|
||||
return dispatcher;
|
||||
}
|
||||
|
||||
function safely(run) {
|
||||
try {
|
||||
return run();
|
||||
|
||||
Reference in new issue
Block a user