aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--public/bluebey-studio/src/main.js13
1 files changed, 11 insertions, 2 deletions
diff --git a/public/bluebey-studio/src/main.js b/public/bluebey-studio/src/main.js
index ac8c04b..063a6fc 100644
--- a/public/bluebey-studio/src/main.js
+++ b/public/bluebey-studio/src/main.js
@@ -2361,6 +2361,8 @@ async function init() {
pan: event.shiftKey,
x: event.clientX,
y: event.clientY,
+ lastX: event.clientX,
+ lastY: event.clientY,
root: [...root],
};
view.controls.enabled = false;
@@ -2376,11 +2378,18 @@ async function init() {
if (modelDrag.pan) {
// Shift+drag: move the camera's reference point (the same effect as the
// two-finger drag on a phone). The character stays where it is.
+ // Use the step since the previous event, not the total from the press:
+ // pointermove fires many times per drag, so adding the total every time
+ // would make the pan accelerate.
+ const stepX = event.clientX - modelDrag.lastX;
+ const stepY = event.clientY - modelDrag.lastY;
+ modelDrag.lastX = event.clientX;
+ modelDrag.lastY = event.clientY;
const right = new THREE.Vector3(1, 0, 0).applyQuaternion(view.camera.quaternion);
const up = new THREE.Vector3(0, 1, 0).applyQuaternion(view.camera.quaternion);
const move = new THREE.Vector3()
- .addScaledVector(right, -dx * k)
- .addScaledVector(up, dy * k);
+ .addScaledVector(right, -stepX * k)
+ .addScaledVector(up, stepY * k);
view.target.add(move);
for (const controls of Object.values(view.controlsMap ?? {})) controls.target.add(move);
for (const cam of Object.values(view.cameras ?? {})) cam.position.add(move);