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
@@ -48,7 +48,7 @@ function fakeDocument() {
|
||||
};
|
||||
}
|
||||
|
||||
function setup({ stock = true, document = null } = {}) {
|
||||
function setup({ stock = true, document = null, takeStock = true } = {}) {
|
||||
const stockHandler = fakeHandler();
|
||||
const selected = [];
|
||||
const followed = [];
|
||||
@@ -86,6 +86,7 @@ function setup({ stock = true, document = null } = {}) {
|
||||
createHandler: () => handler,
|
||||
now: () => clock,
|
||||
document,
|
||||
takeStock,
|
||||
ctrlWheelZoom: () => {
|
||||
wheelZoom.push('on');
|
||||
return () => wheelZoom.push('off');
|
||||
@@ -374,3 +375,53 @@ test('a double-tap is a touch; a click on Cesium’s timer ends no press', () =>
|
||||
s.handler.fire(T.RIGHT_CLICK, { position: s.at(5, 6) });
|
||||
assert.deepEqual(heard, ['touch', { travelPx: 0, durationMs: 0 }]);
|
||||
});
|
||||
|
||||
test('a press that began suppressed never selects, even if its tool lets go on the up', () => {
|
||||
const s = setup();
|
||||
let release = s.port.behaviours.select.suppress();
|
||||
s.port.on('up', () => {
|
||||
release?.();
|
||||
release = null;
|
||||
});
|
||||
s.press(5, 6);
|
||||
assert.equal(s.selected.length, 0, 'the click of the suppressed press');
|
||||
s.press(5, 6);
|
||||
assert.equal(s.selected.length, 1, 'the next press selects');
|
||||
});
|
||||
|
||||
test('a hold a down subscriber takes keeps its press from selecting', () => {
|
||||
const s = setup();
|
||||
let release = null;
|
||||
s.port.on('down', () => {
|
||||
release = s.port.behaviours.select.suppress();
|
||||
});
|
||||
s.port.on('up', () => release?.());
|
||||
s.press(5, 6);
|
||||
assert.equal(s.selected.length, 0);
|
||||
});
|
||||
|
||||
test('not taking the stock, they stay on the viewer’s handler but while held', () => {
|
||||
const s = setup({ takeStock: false });
|
||||
const original = s.stockHandler.getInputAction(T.LEFT_CLICK);
|
||||
assert.equal(typeof original, 'function', 'left where the viewer put them');
|
||||
s.press(5, 6);
|
||||
assert.equal(s.selected.length, 0, 'the port never runs them itself');
|
||||
const release = s.port.behaviours.select.suppress();
|
||||
assert.equal(s.stockHandler.getInputAction(T.LEFT_CLICK), undefined);
|
||||
assert.equal(
|
||||
typeof s.stockHandler.getInputAction(T.LEFT_DOUBLE_CLICK),
|
||||
'function',
|
||||
'follow is its own',
|
||||
);
|
||||
release();
|
||||
assert.equal(s.stockHandler.getInputAction(T.LEFT_CLICK), original);
|
||||
s.port.behaviours.dblclickFollow.suppress();
|
||||
const follow = s.stockHandler.getInputAction(T.LEFT_DOUBLE_CLICK);
|
||||
assert.equal(follow, undefined);
|
||||
s.input.dispose();
|
||||
assert.equal(
|
||||
typeof s.stockHandler.getInputAction(T.LEFT_DOUBLE_CLICK),
|
||||
'function',
|
||||
'dispose gives a held one back',
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user