Skip to content

Commit

Permalink
Fix camera orientation flip after gimbal lock
Browse files Browse the repository at this point in the history
  • Loading branch information
lilleyse committed May 27, 2020
1 parent c123767 commit 43a2d8b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -1843,9 +1843,8 @@ function getStrafeStartPositionUnderground(
// camera's height from the closest surface (closest surface being either
// the globe surface or the underground invisible surface)
distance = getDistanceFromClosestSurface(controller, ray.origin);
Ray.getPoint(ray, distance, result);
}
return result;
return Ray.getPoint(ray, distance, result);
}

var spin3DPick = new Cartesian3();
Expand Down Expand Up @@ -2363,15 +2362,14 @@ function getTiltCenterUnderground(controller, ray, pickedPosition, result) {
distance = Math.min(distance, distanceFromClosestSurface / 5.0);
}

console.log(distance);

return Ray.getPoint(ray, distance, result);
}

function tilt3DOnTerrain(controller, startPosition, movement) {
var ellipsoid = controller._ellipsoid;
var scene = controller._scene;
var camera = scene.camera;
var cameraUnderground = controller._cameraUnderground;

var center;
var ray;
Expand Down Expand Up @@ -2472,7 +2470,11 @@ function tilt3DOnTerrain(controller, startPosition, movement) {
camera._setTransform(verticalTransform);

if (dot < 0.0) {
if (movement.startPosition.y > movement.endPosition.y) {
var movementDelta = movement.startPosition.y - movement.endPosition.y;
if (
(cameraUnderground && movementDelta < 0.0) ||
(!cameraUnderground && movementDelta > 0.0)
) {
constrainedAxis = undefined;
}

Expand Down

0 comments on commit 43a2d8b

Please sign in to comment.