Skip to content

Commit

Permalink
Update Camera.positionCartographic when the height changes in 2D.
Browse files Browse the repository at this point in the history
  • Loading branch information
bagnell committed Jul 7, 2015
1 parent 168dd31 commit d14a6fc
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions Source/Scene/Camera.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,8 +398,17 @@ define([
var scratchCartesian = new Cartesian3();

function updateMembers(camera) {
var mode = camera._mode;

var heightChanged = false;
var height = 0.0;
if (mode === SceneMode.SCENE2D) {
height = (camera.frustum.right - camera.frustum.left) * 0.5;
heightChanged = height !== camera._positionCartographic.height;
}

var position = camera._position;
var positionChanged = !Cartesian3.equals(position, camera.position);
var positionChanged = !Cartesian3.equals(position, camera.position) || heightChanged;
if (positionChanged) {
position = Cartesian3.clone(camera.position, camera._position);
}
Expand Down Expand Up @@ -451,7 +460,6 @@ define([
camera._positionWC = Matrix4.multiplyByPoint(transform, position, camera._positionWC);

// Compute the Cartographic position of the camera.
var mode = camera._mode;
if (mode === SceneMode.SCENE3D || mode === SceneMode.MORPHING) {
camera._positionCartographic = camera._projection.ellipsoid.cartesianToCartographic(camera._positionWC, camera._positionCartographic);
} else {
Expand All @@ -466,7 +474,7 @@ define([
// In 2D, the camera height is always 12.7 million meters.
// The apparent height is equal to half the frustum width.
if (mode === SceneMode.SCENE2D) {
positionENU.z = (camera.frustum.right - camera.frustum.left) * 0.5;
positionENU.z = height;
}

camera._projection.unproject(positionENU, camera._positionCartographic);
Expand Down

0 comments on commit d14a6fc

Please sign in to comment.