Skip to content

Commit

Permalink
Merge pull request CesiumGS#2875 from AnalyticalGraphicsInc/height-2D
Browse files Browse the repository at this point in the history
Update Camera.positionCartographic when the height changes in 2D.
  • Loading branch information
mramato committed Jul 8, 2015
2 parents 89bd293 + fc4afb2 commit 15ea3fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Change Log
*
* Fixes Cesium.js failing to parse in IE 8 and 9. While Cesium doesn't work in IE versions less than 11, but this allows for more graceful error handling.
* Fix calling `Scene.pickPosition` after calling `Scene.drillPick`. [#2813](https://github.com/AnalyticalGraphicsInc/cesium/issues/2813)
* Fixed a bug that caused `Camera.positionCartographic` to be incorrect. [#2838](https://github.com/AnalyticalGraphicsInc/cesium/issues/2838)
* Make `ArcGisMapServerImageryprovider` issue `pickFeatures` requests via a proxy if one is specified.

### 1.11 - 2015-07-01
Expand Down
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 15ea3fc

Please sign in to comment.