From 90748d1e6ed403b550d313ded5b1895be70591a8 Mon Sep 17 00:00:00 2001 From: Stewart Allen Date: Tue, 16 Dec 2025 18:51:42 -0500 Subject: [PATCH] fix ortho zoom behvavior and min zoom distance --- src/moto/orbit.js | 18 ++++++++++++++++-- src/moto/space.js | 7 ++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/moto/orbit.js b/src/moto/orbit.js index 097e7f0b..74dd86b7 100644 --- a/src/moto/orbit.js +++ b/src/moto/orbit.js @@ -315,6 +315,7 @@ class Orbit extends EventDispatcher { scaleSave = newScaleSave; scope.object.zoom = 1 / scaleSave; scope.object.updateProjectionMatrix(); + scale = 1; // Reset scale to prevent accumulation } else { scaleSave *= scale; scale = 1; @@ -468,10 +469,23 @@ class Orbit extends EventDispatcher { delta = -delta; } + // Use delta magnitude as factor for smoother trackpad scrolling + // Scale down large deltas more aggressively for smoother control + let absDelta = Math.abs(delta); + let factor = 1; + + // For typical trackpad deltas (0-20), use linear scaling + if (absDelta <= 20) { + factor = absDelta / 20; + } else { + // For larger deltas (mouse wheel clicks), use smaller steps + factor = 1 + Math.log(absDelta / 20); + } + if (delta > 0) { - scope.dollyOut(); + scope.dollyOut(factor); } else if (delta < 0) { - scope.dollyIn(); + scope.dollyIn(factor); } scope.update(); diff --git a/src/moto/space.js b/src/moto/space.js index da94a180..833b80db 100644 --- a/src/moto/space.js +++ b/src/moto/space.js @@ -337,7 +337,9 @@ function setPlatformSize( } else { platform.scale.set(width, depth, height); } - viewControl.maxDistance = Math.max(width,depth) * 4; + let maxDim = Math.max(width,depth); + viewControl.minDistance = 1; + viewControl.maxDistance = maxDim * 4; updatePlatformPosition(); updateLights(); if (volume) { @@ -1491,6 +1493,7 @@ let Space = { newCamera.lookAt(target); // Store old control properties + const minDistance = viewControl.minDistance; const maxDistance = viewControl.maxDistance; const noKeys = viewControl.noKeys; const enabled = viewControl.enabled; @@ -1535,6 +1538,7 @@ let Space = { if (sliderCallback) sliderCallback(val); }); viewControl.noKeys = noKeys; + viewControl.minDistance = minDistance; viewControl.maxDistance = maxDistance; viewControl.enabled = enabled; viewControl.reverseZoom = reverseZoom; @@ -1620,6 +1624,7 @@ let Space = { }); viewControl.noKeys = true; + viewControl.minDistance = 1; viewControl.maxDistance = 1000; SCENE.add(skyAmbient = new THREE.AmbientLight(0x707070));