Browse Source

Sphere Fix: Add branch for empty condition in expandByPoint function (#24694)

* Add check for empty in Sphere.expandByPoint

* Update Sphere.js
Garrett Johnson 2 years ago
parent
commit
fcd59f3e36
1 changed files with 8 additions and 0 deletions
  1. 8 0
      src/math/Sphere.js

+ 8 - 0
src/math/Sphere.js

@@ -161,6 +161,14 @@ class Sphere {
 
 	expandByPoint( point ) {
 
+		if ( this.isEmpty() ) {
+
+			this.center.copy( point );
+			this.radius = 0;
+			return;
+
+		}
+
 		// from https://github.com/juj/MathGeoLib/blob/2940b99b99cfe575dd45103ef20f4019dee15b54/src/Geometry/Sphere.cpp#L649-L671
 
 		_toPoint.subVectors( point, this.center );