Skip to content

Commit

Permalink
Fix zooming out speed after reaching minimum zoom distance.
Browse files Browse the repository at this point in the history
  • Loading branch information
puckey committed Jan 25, 2022
1 parent 10112c8 commit 8e313d9
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -532,9 +532,12 @@ function handleZoom(
);
}

var diff = movement.endPosition.y - movement.startPosition.y;

// distanceMeasure should be the height above the ellipsoid.
// The zoomRate slows as it approaches the surface and stops minimumZoomDistance above it.
var minHeight = object.minimumZoomDistance * percentage;
// When approaching the surface, the zoomRate slows and stops minimumZoomDistance above it.
var approachingSurface = diff > 0;
var minHeight = approachingSurface ? object.minimumZoomDistance * percentage : 0;
var maxHeight = object.maximumZoomDistance;

var minDistance = distanceMeasure - minHeight;
Expand All @@ -545,7 +548,6 @@ function handleZoom(
object._maximumZoomRate
);

var diff = movement.endPosition.y - movement.startPosition.y;
var rangeWindowRatio = diff / object._scene.canvas.clientHeight;
rangeWindowRatio = Math.min(rangeWindowRatio, object.maximumMovementRatio);
var distance = zoomRate * rangeWindowRatio;
Expand Down

0 comments on commit 8e313d9

Please sign in to comment.