Skip to content

Commit

Permalink
Merge pull request #4967 from AnalyticalGraphicsInc/stop-that-camera
Browse files Browse the repository at this point in the history
Halt camera zoom
  • Loading branch information
bagnell authored Feb 9, 2017
2 parents b23f758 + 52ce5ca commit 901a9f6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Source/Scene/ScreenSpaceCameraController.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,14 +568,17 @@ define([
Cartesian3.clone(camera.direction, forward);
Cartesian3.add(cameraPosition, Cartesian3.multiplyByScalar(forward, 1000, scratchCartesian), center);


var positionToTarget = scratchPositionToTarget;
var positionToTargetNormal = scratchPositionToTargetNormal;
Cartesian3.subtract(target, cameraPosition, positionToTarget);

Cartesian3.normalize(positionToTarget, positionToTargetNormal);

var alpha = Math.acos( -Cartesian3.dot( cameraPositionNormal, positionToTargetNormal ) );
var alphaDot = Cartesian3.dot(cameraPositionNormal, positionToTargetNormal);
if (alphaDot >= 0.0) {
return;
}
var alpha = Math.acos(-alphaDot);
var cameraDistance = Cartesian3.magnitude( cameraPosition );
var targetDistance = Cartesian3.magnitude( target );
var remainingDistance = cameraDistance - distance;
Expand Down Expand Up @@ -632,7 +635,9 @@ define([
Cartesian3.cross(camera.right, camera.direction, camera.up);

return;
} else if (defined(centerPosition)) {
}

if (defined(centerPosition)) {
var positionNormal = Cartesian3.normalize(centerPosition, scratchPositionNormal);
var pickedNormal = Cartesian3.normalize(object._zoomWorldPosition, scratchPickNormal);
var dotProduct = Cartesian3.dot(pickedNormal, positionNormal);
Expand Down

0 comments on commit 901a9f6

Please sign in to comment.