mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +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
@@ -26,6 +26,7 @@ import * as Cesium from 'cesium';
|
||||
import { createInputRouter } from '../input/router.js';
|
||||
import { acquireCameraInput } from './cameraInput.js';
|
||||
import { installTrackpadPinchZoom } from './ctrlWheelZoom.js';
|
||||
import { wheelLines } from '../input/wheel.js';
|
||||
|
||||
const T = Cesium.ScreenSpaceEventType;
|
||||
const MODIFIERS = [
|
||||
@@ -52,8 +53,6 @@ const DOM_EVENTS = [
|
||||
'touchcancel',
|
||||
'dblclick',
|
||||
];
|
||||
/** A wheel notch scrolls 100 px in Chrome, which it counts as three lines. */
|
||||
const PX_PER_LINE = 100 / 3;
|
||||
/** A drill is run at least this deep and sliced, so asks share one pass. */
|
||||
const DRILL_DEPTH = 16;
|
||||
const NO_MODIFIERS = Object.freeze({
|
||||
@@ -440,16 +439,11 @@ export function createCesiumInput(
|
||||
|
||||
const onWheel = (event) => {
|
||||
const rect = canvas.getBoundingClientRect?.() ?? { left: 0, top: 0 };
|
||||
const lines =
|
||||
event.deltaMode === 1
|
||||
? event.deltaY
|
||||
: event.deltaMode === 2
|
||||
? (event.deltaY * (canvas.clientHeight || 0)) / PX_PER_LINE
|
||||
: event.deltaY / PX_PER_LINE;
|
||||
deliver(
|
||||
'wheel',
|
||||
{ x: event.clientX - rect.left, y: event.clientY - rect.top },
|
||||
{ delta: lines },
|
||||
// Lines as the reference counts them (`../input/wheel.js`).
|
||||
{ delta: wheelLines(event) },
|
||||
event,
|
||||
);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user