Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement inertiaZoom in aggregator #11062

Merged
merged 13 commits into from
Feb 21, 2023
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);
jiangheng90 marked this conversation as resolved.
Show resolved Hide resolved
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