From a168b17fa0743cf32bd82e3771db8addf84fd3c6 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Thu, 19 Dec 2019 19:20:15 -0500 Subject: [PATCH 1/3] added fallback normal for BoundingSphere.projectTo2D to avoid crash --- Source/Core/BoundingSphere.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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); From b8da286c0df57f03b5c2d2764ec267e94e79eb5c Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Thu, 19 Dec 2019 19:35:41 -0500 Subject: [PATCH 2/3] updated changes.md [skip ci] --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 72c8db6b448e..57cc97ebfa9a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ Change Log * Fixed terrain tile culling problems when under ellipsoid. [#8397](https://github.com/AnalyticalGraphicsInc/cesium/pull/8397) * Fixed primitive culling when below the ellipsoid but above terrain. [#8398](https://github.com/AnalyticalGraphicsInc/cesium/pull/8398) * Improved the translucency calculation for the Water material type. [#8455](https://github.com/AnalyticalGraphicsInc/cesium/pull/8455) +* Fixed `BoundingSphere.projectTo2D` when the bounding sphere’s center is at the origin. [8482](https://github.com/AnalyticalGraphicsInc/cesium/pull/8482) ### 1.64.0 - 2019-12-02 From f3de8094271c24436e40a30f48ecd94d778ba302 Mon Sep 17 00:00:00 2001 From: Ian Lilley Date: Thu, 19 Dec 2019 19:41:40 -0500 Subject: [PATCH 3/3] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 26c740339475..4275b3a8c593 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -9,7 +9,7 @@ Change Log * Fixed primitive culling when below the ellipsoid but above terrain. [#8398](https://github.com/AnalyticalGraphicsInc/cesium/pull/8398) * Improved the translucency calculation for the Water material type. [#8455](https://github.com/AnalyticalGraphicsInc/cesium/pull/8455) * Fixed globe picking so that it returns the closest intersecting triangle instead of the first intersecting triangle. [#8390](https://github.com/AnalyticalGraphicsInc/cesium/pull/8390) -* Fixed `BoundingSphere.projectTo2D` when the bounding sphere’s center is at the origin. [8482](https://github.com/AnalyticalGraphicsInc/cesium/pull/8482) +* Fixed `BoundingSphere.projectTo2D` when the bounding sphere’s center is at the origin. [#8482](https://github.com/AnalyticalGraphicsInc/cesium/pull/8482) ##### Additions :tada: * Added `Globe.backFaceCulling` to support viewing terrain from below the surface. [#8470](https://github.com/AnalyticalGraphicsInc/cesium/pull/8470)