mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
Deliver the application's pointer input through the renderer's input port
The Cesium renderer now creates the input port and exposes it as renderer.input. The input dispatcher becomes an adapter over the port: one port listener per event type, fanned out to its subscribers with the ownership check read once per event, keeping the legacy event shapes. - Ctrl+wheel zoom is switched on through renderer.input.ctrlWheelZoom. - A dispatcher made for a viewer with no port creates its own port with takeStock: false, which borrows the stock select and double-click follow only while they are suppressed. - The stock actions see the press as it began: a click whose press started while select or follow was held off never runs them. - A scene accepts one input port; cesiumInputOf(scene) returns it. - Releasing one mouse button while another is held no longer gives the held button a click. Cesium still ends that press.
This commit is contained in:
1 parent
1c29a54dc9
commit
910185bfe0
16 files changed
+427
-275
No files matched your search
@@ -509,21 +509,10 @@ export function initDrawTool({
|
||||
previewDataSources: countPreviewDataSources(viewer),
|
||||
previewEntities: destroyed ? 0 : dataSource.entities.values.length,
|
||||
pointerOwner: pointerOwner(),
|
||||
// The viewer's OWN click actions. While a session is open both are
|
||||
// borrowed (absent here); after it closes both are back. A harness can
|
||||
// compare the restored functions by identity with what it captured
|
||||
// before, which is the only way to prove they were given back rather
|
||||
// than replaced.
|
||||
stockSingleClick: Boolean(
|
||||
viewer.screenSpaceEventHandler?.getInputAction?.(
|
||||
Cesium.ScreenSpaceEventType.LEFT_CLICK,
|
||||
),
|
||||
),
|
||||
stockDoubleClick: Boolean(
|
||||
viewer.screenSpaceEventHandler?.getInputAction?.(
|
||||
Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK,
|
||||
),
|
||||
),
|
||||
// The viewer's own select and follow, which the input port runs: off
|
||||
// while a session is open, back on after it closes.
|
||||
stockSingleClick: inputFor(viewer).stockEnabled('select'),
|
||||
stockDoubleClick: inputFor(viewer).stockEnabled('dblclickFollow'),
|
||||
};
|
||||
},
|
||||
/** Resolves once every deferred teardown step has run. */
|
||||
|
||||
@@ -224,11 +224,13 @@ function fakeAnnotations() {
|
||||
}
|
||||
|
||||
/** Stand up a tool against fresh doubles, with globals restored afterwards. */
|
||||
function harness({ navigation = null } = {}) {
|
||||
function harness({ navigation = null, beforeInput = () => {} } = {}) {
|
||||
resetPointerOwnership();
|
||||
const { byId, documentDouble } = fakeDom();
|
||||
const viewer = fakeViewer();
|
||||
const input = fakeInput(viewer, { eventTypes: Cesium.ScreenSpaceEventType });
|
||||
// The viewer's own actions are bound before its input port takes them.
|
||||
beforeInput(viewer);
|
||||
const input = fakeInput(viewer);
|
||||
const annotations = fakeAnnotations();
|
||||
const previousDocument = globalThis.document;
|
||||
const previousWindow = globalThis.window;
|
||||
@@ -339,30 +341,33 @@ test('a destroyed instance cannot free the pointer its replacement holds', async
|
||||
}
|
||||
});
|
||||
|
||||
test('both stock viewer click actions are borrowed for the session and given back', async () => {
|
||||
const h = harness();
|
||||
test('both stock viewer click actions are held off for the session and given back', async () => {
|
||||
const stockClick = () => 'viewer picks and selects';
|
||||
const stockDouble = () => 'viewer tracks';
|
||||
const h = harness({
|
||||
beforeInput(viewer) {
|
||||
viewer.screenSpaceEventHandler.setInputAction(stockClick, LEFT_CLICK);
|
||||
viewer.screenSpaceEventHandler.setInputAction(stockDouble, LEFT_DOUBLE_CLICK);
|
||||
},
|
||||
});
|
||||
try {
|
||||
const stockClick = () => 'viewer picks and selects';
|
||||
const stockDouble = () => 'viewer tracks';
|
||||
h.viewer.screenSpaceEventHandler.setInputAction(stockClick, LEFT_CLICK);
|
||||
h.viewer.screenSpaceEventHandler.setInputAction(stockDouble, LEFT_DOUBLE_CLICK);
|
||||
|
||||
assert.equal(h.input.stockEnabled('select'), true);
|
||||
h.act('toggleDraw');
|
||||
assert.equal(
|
||||
h.viewer.screenSpaceEventHandler.getInputAction(LEFT_CLICK),
|
||||
undefined,
|
||||
h.input.stockEnabled('select'),
|
||||
false,
|
||||
"the viewer's own selecting click must not run while drawing",
|
||||
);
|
||||
assert.equal(
|
||||
h.viewer.screenSpaceEventHandler.getInputAction(LEFT_DOUBLE_CLICK),
|
||||
undefined,
|
||||
);
|
||||
assert.equal(h.input.stockEnabled('dblclickFollow'), false);
|
||||
|
||||
h.act('toggleDraw');
|
||||
assert.equal(h.input.stockEnabled('select'), true);
|
||||
assert.equal(h.input.stockEnabled('dblclickFollow'), true);
|
||||
h.input.destroy();
|
||||
assert.equal(
|
||||
h.viewer.screenSpaceEventHandler.getInputAction(LEFT_CLICK),
|
||||
stockClick,
|
||||
'the exact function is restored, not a replacement',
|
||||
'the exact function goes back to the viewer, not a replacement',
|
||||
);
|
||||
assert.equal(
|
||||
h.viewer.screenSpaceEventHandler.getInputAction(LEFT_DOUBLE_CLICK),
|
||||
|
||||
Reference in new issue
Block a user