Skip to content

Commit

Permalink
Merge pull request #11062 from jiangheng90/smooth-zoom-with-mouse-wheel
Browse files Browse the repository at this point in the history
implement inertiaZoom in aggregator
  • Loading branch information
ggetz authored Feb 21, 2023
2 parents 9295450 + bc1de11 commit ef50203
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions packages/engine/Source/Scene/CameraEventAggregator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 11 additions & 4 deletions packages/engine/Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit ef50203

Please sign in to comment.