diff options
| author | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-10-22 13:35:59 +0900 |
|---|---|---|
| committer | Yasutake Yohei <61961825+yasutakeyohei@users.noreply.github.com> | 2026-10-22 13:35:59 +0900 |
| commit | 92b0483c65d2404a096d67a276395e9198499e95 (patch) | |
| tree | b14b7110a8b60b3a8bb9fa20fc4be886b635c32a /public/bluebey-studio/src | |
| parent | 4830503fb3738098ab2395f3475459c5e330cb39 (diff) | |
bluebey-studio: Shift+ドラッグの移動量が加速する不具合を修正
Diffstat (limited to 'public/bluebey-studio/src')
| -rw-r--r-- | public/bluebey-studio/src/main.js | 13 |
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); |
