mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-16 08:12:24 +00:00
fix(camera): let a two-finger tilt win over finger-spacing drift
Above 300 km the guard treated any shrinking pinch distance as an outward zoom, so a two-finger tilt whose fingers drifted slightly closer had its pitch overwritten. A two-finger gesture now counts as a zoom only when the spacing changes more than the fingers' midpoint moves.
This commit is contained in:
1 parent
e4b3933166
commit
b817d5802b
3 files changed
+44
-5
No files matched your search
+13
-3
@@ -47,10 +47,20 @@ function readInput(aggregator, bindings) {
|
||||
for (const { type, modifier } of INPUT_BINDINGS) {
|
||||
if (!aggregator.isMoving(type, modifier)) continue;
|
||||
const movement = aggregator.getMovement(type, modifier);
|
||||
const distance =
|
||||
type === Cesium.CameraEventType.PINCH ? movement.distance : movement;
|
||||
const pinch = type === Cesium.CameraEventType.PINCH;
|
||||
const distance = pinch ? movement.distance : movement;
|
||||
const delta = distance.endPosition.y - distance.startPosition.y;
|
||||
if (matchesZoomBinding(bindings, type, modifier) && delta !== 0) {
|
||||
// Cesium tilts by the fingers' midpoint while zooming by their spacing,
|
||||
// both in the same quarter-pixel units. Fingers rarely keep a perfectly
|
||||
// even spacing, so the larger of the two movements decides the gesture.
|
||||
const tilt = pinch
|
||||
? movement.angleAndHeight.endPosition.y -
|
||||
movement.angleAndHeight.startPosition.y
|
||||
: 0;
|
||||
if (
|
||||
matchesZoomBinding(bindings, type, modifier) &&
|
||||
Math.abs(delta) > Math.abs(tilt)
|
||||
) {
|
||||
outward ||= delta < 0;
|
||||
cancel ||= delta > 0;
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user