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

fix camera controller issue when tilt on terrain #9562

Merged
merged 10 commits into from
Jun 1, 2021
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
##### Fixes :wrench:

- Fixed `processTerrain` in `decodeGoogleEarthEnterprisePacket` to handle a newer terrain packet format that includes water surface meshes after terrain meshes. [#9519](https://github.com/CesiumGS/cesium/pull/9519)
- Fixed an issue in `ScreenSpaceCameraController.tilt3DOnTerrain` when tilt terrain diagonally along the screen. [#9562](https://github.com/CesiumGS/cesium/pull/9562)
renjianqiang marked this conversation as resolved.
Show resolved Hide resolved

### 1.81 - 2021-05-01

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -291,3 +291,4 @@ See [CONTRIBUTING.md](CONTRIBUTING.md) for details on how to contribute to Cesiu
- [Ben Murphy](https://github.com/littlemurph)
- [Ethan Wong](https://github.com/GetToSet)
- [Calogero Mauceri](https://github.com/kalosma)
- [Ren Jianqiang](https://github.com/renjianqiang)
9 changes: 4 additions & 5 deletions Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2442,7 +2442,7 @@ function tilt3DOnTerrain(controller, startPosition, movement) {
var constrainedAxis = Cartesian3.UNIT_Z;

var oldTransform = Matrix4.clone(camera.transform, tilt3DOldTransform);
camera._setTransform(transform);
camera._setTransform(verticalTransform);

var tangent = Cartesian3.cross(
verticalCenter,
Expand All @@ -2451,10 +2451,6 @@ function tilt3DOnTerrain(controller, startPosition, movement) {
);
var dot = Cartesian3.dot(camera.rightWC, tangent);

rotate3D(controller, startPosition, movement, constrainedAxis, false, true);

camera._setTransform(verticalTransform);

if (dot < 0.0) {
var movementDelta = movement.startPosition.y - movement.endPosition.y;
if (
Expand All @@ -2475,6 +2471,9 @@ function tilt3DOnTerrain(controller, startPosition, movement) {
rotate3D(controller, startPosition, movement, constrainedAxis, true, false);
}

camera._setTransform(transform);
rotate3D(controller, startPosition, movement, constrainedAxis, false, true);

if (defined(camera.constrainedAxis)) {
var right = Cartesian3.cross(
camera.direction,
Expand Down