diff --git a/src/math/Box3.js b/src/math/Box3.js index ca529eb3a6f94fd9ceb7c35fe96b7aebeaeb9d40..7b98bda47723903abc905d4530170de276d14a10 100644 --- a/src/math/Box3.js +++ b/src/math/Box3.js @@ -247,15 +247,23 @@ THREE.Box3.prototype = { }, - isIntersectionSphere: function ( sphere ) { + isIntersectionSphere: function () { - // Find the point on the AABB closest to the sphere center. - var closestPoint = this.clampPoint( sphere.center ); + var closestPoint; - // If that point is inside the sphere, the AABB and sphere intersect. - return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ) + return function isIntersectionSphere( sphere ) { - }, + if ( closestPoint === undefined ) closestPoint = new THREE.Vector3(); + + // Find the point on the AABB closest to the sphere center. + this.clampPoint( sphere.center, closestPoint ); + + // If that point is inside the sphere, the AABB and sphere intersect. + return closestPoint.distanceToSquared( sphere.center ) <= ( sphere.radius * sphere.radius ); + + }; + + }(), clampPoint: function ( point, optionalTarget ) {