diff --git a/CHANGES.md b/CHANGES.md index 31ecf89bea4e..13ffa1d10515 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -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) diff --git a/Source/Core/BoundingSphere.js b/Source/Core/BoundingSphere.js index 0b789cfd2470..2b2862b58e9d 100644 --- a/Source/Core/BoundingSphere.js +++ b/Source/Core/BoundingSphere.js @@ -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);