Import
-is an addon, and must be imported explicitly, see Installation#Addons.
+is an addon, and must be imported explicitly, see Installation#Addons.
diff --git a/manual/pages/installation.html b/manual/pages/installation.html index 558bb8b9466959..af6fc7a59e47f2 100644 --- a/manual/pages/installation.html +++ b/manual/pages/installation.html @@ -253,7 +253,7 @@
Out of the box, three.js includes the fundamentals of a 3D engine. Other three.js components — such as controls, loaders, and post-processing effects — are part of the [link:https://github.com/mrdoob/three.js/tree/dev/examples/jsm addons/] directory. Addons do not need to be installed separately, but do need to be imported separately.
diff --git a/src/math/Ray.js b/src/math/Ray.js
index 8edd1a7497e6fd..94391ddd4482aa 100644
--- a/src/math/Ray.js
+++ b/src/math/Ray.js
@@ -306,6 +306,8 @@ class Ray {
*/
intersectSphere( sphere, target ) {
+ if ( sphere.radius < 0 ) return null; // handle empty spheres, see #31187
+
_vector.subVectors( sphere.center, this.origin );
const tca = _vector.dot( this.direction );
const d2 = _vector.dot( _vector ) - tca * tca;
diff --git a/test/unit/src/math/Ray.tests.js b/test/unit/src/math/Ray.tests.js
index 0a956ef71c56be..0dad45816f774a 100644
--- a/test/unit/src/math/Ray.tests.js
+++ b/test/unit/src/math/Ray.tests.js
@@ -260,6 +260,13 @@ export default QUnit.module( 'Maths', () => {
a0.intersectSphere( b, point );
assert.ok( point.distanceTo( new Vector3( 0, 0, - 5 ) ) < TOL, 'Passed!' );
+ // empty sphere ( negative radius ) can never be intersected, so the
+ // target must be left untouched and the return value must be null,
+ // consistent with intersectsSphere()
+ b = new Sphere( new Vector3( 0, 0, - 1 ), - 1 );
+ assert.strictEqual( a0.intersectSphere( b, point.copy( posInf3 ) ), null, 'Passed!' );
+ assert.ok( point.equals( posInf3 ), 'Passed!' );
+
} );
QUnit.test( 'intersectsSphere', ( assert ) => {
diff --git a/utils/docs/template/tmpl/container.tmpl b/utils/docs/template/tmpl/container.tmpl
index ba51458c7e1e60..c95d2c87559b49 100644
--- a/utils/docs/template/tmpl/container.tmpl
+++ b/utils/docs/template/tmpl/container.tmpl
@@ -42,7 +42,7 @@
is an addon, and must be imported explicitly, see Installation#Addons. is an addon, and must be imported explicitly, see Installation#Addons.Import
-