Skip to content

Commit

Permalink
Merge pull request mrdoob#1 from agargaro/trackballcontrolszoom
Browse files Browse the repository at this point in the history
Trackball zoom limit
  • Loading branch information
agargaro authored Mar 2, 2023
2 parents 5fcbe5a + 85bedf7 commit bd5d9e5
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions examples/jsm/controls/TrackballControls.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
EventDispatcher,
MathUtils,
MOUSE,
Quaternion,
Vector2,
Expand Down Expand Up @@ -205,8 +206,13 @@ class TrackballControls extends EventDispatcher {

} else if ( scope.object.isOrthographicCamera ) {

scope.object.zoom /= factor;
scope.object.updateProjectionMatrix();
scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minDistance, scope.maxDistance);

if (lastZoom != scope.object.zoom) {

scope.object.updateProjectionMatrix();

}

} else {

Expand All @@ -226,8 +232,13 @@ class TrackballControls extends EventDispatcher {

} else if ( scope.object.isOrthographicCamera ) {

scope.object.zoom /= factor;
scope.object.updateProjectionMatrix();
scope.object.zoom = MathUtils.clamp(scope.object.zoom / factor, scope.minDistance, scope.maxDistance);

if (lastZoom != scope.object.zoom) {

scope.object.updateProjectionMatrix();

}

} else {

Expand Down

0 comments on commit bd5d9e5

Please sign in to comment.