fix ortho zoom behvavior and min zoom distance

This commit is contained in:
Stewart Allen 2025-12-16 18:51:42 -05:00
commit 90748d1e6e
2 changed files with 22 additions and 3 deletions

View file

@ -315,6 +315,7 @@ class Orbit extends EventDispatcher {
scaleSave = newScaleSave; scaleSave = newScaleSave;
scope.object.zoom = 1 / scaleSave; scope.object.zoom = 1 / scaleSave;
scope.object.updateProjectionMatrix(); scope.object.updateProjectionMatrix();
scale = 1; // Reset scale to prevent accumulation
} else { } else {
scaleSave *= scale; scaleSave *= scale;
scale = 1; scale = 1;
@ -468,10 +469,23 @@ class Orbit extends EventDispatcher {
delta = -delta; 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) { if (delta > 0) {
scope.dollyOut(); scope.dollyOut(factor);
} else if (delta < 0) { } else if (delta < 0) {
scope.dollyIn(); scope.dollyIn(factor);
} }
scope.update(); scope.update();

View file

@ -337,7 +337,9 @@ function setPlatformSize(
} else { } else {
platform.scale.set(width, depth, height); 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(); updatePlatformPosition();
updateLights(); updateLights();
if (volume) { if (volume) {
@ -1491,6 +1493,7 @@ let Space = {
newCamera.lookAt(target); newCamera.lookAt(target);
// Store old control properties // Store old control properties
const minDistance = viewControl.minDistance;
const maxDistance = viewControl.maxDistance; const maxDistance = viewControl.maxDistance;
const noKeys = viewControl.noKeys; const noKeys = viewControl.noKeys;
const enabled = viewControl.enabled; const enabled = viewControl.enabled;
@ -1535,6 +1538,7 @@ let Space = {
if (sliderCallback) sliderCallback(val); if (sliderCallback) sliderCallback(val);
}); });
viewControl.noKeys = noKeys; viewControl.noKeys = noKeys;
viewControl.minDistance = minDistance;
viewControl.maxDistance = maxDistance; viewControl.maxDistance = maxDistance;
viewControl.enabled = enabled; viewControl.enabled = enabled;
viewControl.reverseZoom = reverseZoom; viewControl.reverseZoom = reverseZoom;
@ -1620,6 +1624,7 @@ let Space = {
}); });
viewControl.noKeys = true; viewControl.noKeys = true;
viewControl.minDistance = 1;
viewControl.maxDistance = 1000; viewControl.maxDistance = 1000;
SCENE.add(skyAmbient = new THREE.AmbientLight(0x707070)); SCENE.add(skyAmbient = new THREE.AmbientLight(0x707070));