diff --git a/CHANGES.md b/CHANGES.md index a2f3f687680b..5d69123edb90 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,10 @@ #### Major Announcements :loudspeaker: +##### Additions :tada: + +- Added smooth zoom with mouse wheel. [#11062](https://github.com/CesiumGS/cesium/pull/11062) + ##### Fixes :wrench: - Fixed Primitive.getGeometryInstanceAttributes cache acquisition speed. [#11066](https://github.com/CesiumGS/cesium/issues/11066) diff --git a/packages/engine/Source/Scene/CameraEventAggregator.js b/packages/engine/Source/Scene/CameraEventAggregator.js index 79be40dff2bb..10929311dd8e 100644 --- a/packages/engine/Source/Scene/CameraEventAggregator.js +++ b/packages/engine/Source/Scene/CameraEventAggregator.js @@ -159,8 +159,7 @@ function listenToWheel(aggregator, modifier) { aggregator._eventHandler.setInputAction( function (delta) { - // TODO: magic numbers - const arcLength = 15.0 * CesiumMath.toRadians(delta); + const arcLength = 7.5 * CesiumMath.toRadians(delta); pressTime[key] = releaseTime[key] = new Date(); movement.endPosition.x = 0.0; movement.endPosition.y = arcLength; diff --git a/packages/engine/Source/Scene/ScreenSpaceCameraController.js b/packages/engine/Source/Scene/ScreenSpaceCameraController.js index c52a36eeadef..38e767dd16d6 100644 --- a/packages/engine/Source/Scene/ScreenSpaceCameraController.js +++ b/packages/engine/Source/Scene/ScreenSpaceCameraController.js @@ -591,9 +591,9 @@ function handleZoom( return; } - const sameStartPosition = Cartesian2.equals( - startPosition, - object._zoomMouseStart + const sameStartPosition = defaultValue( + movement.inertiaEnabled, + Cartesian2.equals(startPosition, object._zoomMouseStart) ); let zoomingOnVector = object._zoomingOnVector; let rotatingZoom = object._rotatingZoom; @@ -2162,6 +2162,7 @@ function zoom3D(controller, startPosition, movement) { if (defined(movement.distance)) { movement = movement.distance; } + const inertiaMovement = movement.inertiaEnabled; const ellipsoid = controller._ellipsoid; const scene = controller._scene; @@ -2187,7 +2188,13 @@ function zoom3D(controller, startPosition, movement) { camera.position, zoom3DCartographic ).height; - if (height < controller._minimumPickingTerrainHeight) { + + const inertiaMovementApproachingGround = Math.abs(height) < 50; + + const needPickGlobe = inertiaMovement + ? inertiaMovementApproachingGround + : height < controller._minimumPickingTerrainHeight; + if (needPickGlobe) { intersection = pickGlobe(controller, windowPosition, zoomCVIntersection); }