Browse Source

Merge branch 'dev' of https://github.com/mrdoob/three.js into dev

Mr.doob 9 years ago
parent
commit
0931358b64
1 changed files with 14 additions and 6 deletions
  1. 14 6
      src/math/Box3.js

+ 14 - 6
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 ) {