Skip to content

Commit

Permalink
Merge pull request #8482 from AnalyticalGraphicsInc/boundingSpherePro…
Browse files Browse the repository at this point in the history
…jectTo2DZeroFix

Fixed crash when BoundingSphere.projectTo2D is called on a BoundingSphere centered at the origin
  • Loading branch information
lilleyse authored Jan 6, 2020
2 parents 215a588 + 07874ac commit b5943bc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Change Log
##### Additions :tada:

* Added `Globe.showSkirts` to support the ability to hide terrain skirts when viewing terrain from below the surface. [#8489](https://github.com/AnalyticalGraphicsInc/cesium/pull/8489)
* Fixed `BoundingSphere.projectTo2D` when the bounding sphere’s center is at the origin. [#8482](https://github.com/AnalyticalGraphicsInc/cesium/pull/8482)

##### Fixes :wrench:
* Fixed a bug where the camera could go underground during mouse navigation. [#8504](https://github.com/AnalyticalGraphicsInc/cesium/pull/8504)
Expand Down
9 changes: 8 additions & 1 deletion Source/Core/BoundingSphere.js
Original file line number Diff line number Diff line change
Expand Up @@ -1101,7 +1101,14 @@ import Rectangle from './Rectangle.js';
var center = sphere.center;
var radius = sphere.radius;

var normal = ellipsoid.geodeticSurfaceNormal(center, projectTo2DNormalScratch);
var normal;
if (Cartesian3.equals(center, Cartesian3.ZERO)) {
// Bounding sphere is at the center. The geodetic surface normal is not
// defined here so pick the x-axis as a fallback.
normal = Cartesian3.clone(Cartesian3.UNIT_X, projectTo2DNormalScratch);
} else {
normal = ellipsoid.geodeticSurfaceNormal(center, projectTo2DNormalScratch);
}
var east = Cartesian3.cross(Cartesian3.UNIT_Z, normal, projectTo2DEastScratch);
Cartesian3.normalize(east, east);
var north = Cartesian3.cross(normal, east, projectTo2DNorthScratch);
Expand Down

0 comments on commit b5943bc

Please sign in to comment.