mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 16:22:20 +00:00
Add pointer-driven camera scripts with Cesium goldens, and count wheel lines as Cesium does
Five new camera conformance scripts move the camera by user input: a left drag that coasts, thirty pixel-mode and thirty line-mode wheel notches from 5 km, a middle-drag tilt, and Shift and Ctrl drags held too long to coast. The runner turns input steps into pointer events for a driver: a move starts where the pointer last pressed or moved and carries the held button. The golden recorder now drives Cesium's own screen-space camera controller on a stand-in canvas, with Date on the virtual clock so inertia is deterministic. The existing goldens are unchanged. A harness that answers pointer input sets cameraInput and a pointer hook. Harnesses without it, such as the stub, skip the input scripts. The input port reported a line-mode wheel at 33 1/3 pixels a line. It now counts lines as the reference does, 40 pixels a line and 3 lines a page, so a pixel or line wheel converts back to the same pixels.
This commit is contained in:
1 parent
ef616b7905
commit
90499762f5
16 files changed
+1055
-38
No files matched your search
@@ -0,0 +1,50 @@
|
||||
import assert from 'node:assert/strict';
|
||||
import test from 'node:test';
|
||||
|
||||
import { runCameraScript } from './cameraRunner.js';
|
||||
|
||||
/** A driver that only keeps the pointer events the runner sends. */
|
||||
const pointerDriver = () => {
|
||||
const events = [];
|
||||
return {
|
||||
events,
|
||||
driver: {
|
||||
pointer: async (ev) => {
|
||||
events.push(ev);
|
||||
},
|
||||
frame: async () => {},
|
||||
},
|
||||
};
|
||||
};
|
||||
|
||||
test('a move starts where the pointer last pressed or moved, not at a wheel or release', async () => {
|
||||
const { events, driver } = pointerDriver();
|
||||
await runCameraScript(driver, {
|
||||
name: 'origins',
|
||||
steps: [
|
||||
{ input: 'down', x: 10, y: 10, button: 1 },
|
||||
{ input: 'wheel', x: 20, y: 20, deltaY: -100 },
|
||||
{ input: 'move', x: 30, y: 30 },
|
||||
{ input: 'up', x: 40, y: 40 },
|
||||
{ input: 'move', x: 50, y: 50 },
|
||||
],
|
||||
});
|
||||
const [, wheel, held, up, free] = events;
|
||||
assert.deepEqual(wheel.wheel, { deltaY: -100, deltaMode: 0 });
|
||||
assert.deepEqual(held.position, { x: 10, y: 10 });
|
||||
assert.deepEqual(held.endPosition, { x: 30, y: 30 });
|
||||
assert.equal(held.button, 1, 'a move carries the held button');
|
||||
assert.equal(up.button, 0);
|
||||
assert.deepEqual(free.position, { x: 30, y: 30 });
|
||||
assert.equal(free.button, 0, 'nothing is held after the release');
|
||||
});
|
||||
|
||||
test('a first move with no earlier pointer starts where it ends', async () => {
|
||||
const { events, driver } = pointerDriver();
|
||||
await runCameraScript(driver, {
|
||||
name: 'first',
|
||||
steps: [{ input: 'move', x: 5, y: 6 }],
|
||||
});
|
||||
assert.deepEqual(events[0].position, { x: 5, y: 6 });
|
||||
assert.deepEqual(events[0].endPosition, { x: 5, y: 6 });
|
||||
});
|
||||
Reference in new issue
Block a user