Browse Source

Renamed Sphere.isIntersectionSphere to Sphere.intersectsSphere.
Also, code clean up here and there.

Mr.doob 12 years ago
parent
commit
7d48298acf
3 changed files with 17 additions and 18 deletions
  1. 11 12
      src/math/Frustum.js
  2. 3 3
      src/math/Sphere.js
  3. 3 3
      test/unit/math/Sphere.js

+ 11 - 12
src/math/Frustum.js

@@ -31,22 +31,22 @@ THREE.Frustum.prototype = {
 		planes[3].copy( p3 );
 		planes[3].copy( p3 );
 		planes[4].copy( p4 );
 		planes[4].copy( p4 );
 		planes[5].copy( p5 );
 		planes[5].copy( p5 );
-		
-		return this;	
+
+		return this;
 
 
 	},
 	},
 
 
 	copy: function ( frustum ) {
 	copy: function ( frustum ) {
 
 
 		var planes = this.planes;
 		var planes = this.planes;
-	
+
 		for( var i = 0; i < 6; i ++ ) {
 		for( var i = 0; i < 6; i ++ ) {
 
 
 			planes[i].copy( frustum.planes[i] );
 			planes[i].copy( frustum.planes[i] );
 
 
 		}
 		}
 
 
-		return this;	
+		return this;
 
 
 	},
 	},
 
 
@@ -77,7 +77,7 @@ THREE.Frustum.prototype = {
 		var planes = this.planes;
 		var planes = this.planes;
 		var center = matrix.getPosition();
 		var center = matrix.getPosition();
 		var negRadius = - object.geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
 		var negRadius = - object.geometry.boundingSphere.radius * matrix.getMaxScaleOnAxis();
-		
+
 		for ( var i = 0; i < 6; i ++ ) {
 		for ( var i = 0; i < 6; i ++ ) {
 
 
 			var distance = planes[ i ].distanceToPoint( center );
 			var distance = planes[ i ].distanceToPoint( center );
@@ -95,11 +95,11 @@ THREE.Frustum.prototype = {
 	},
 	},
 
 
 	intersectsSphere: function ( sphere ) {
 	intersectsSphere: function ( sphere ) {
-		
+
 		var planes = this.planes;
 		var planes = this.planes;
 		var center = sphere.center;
 		var center = sphere.center;
 		var negRadius = -sphere.radius;
 		var negRadius = -sphere.radius;
-		
+
 		for ( var i = 0; i < 6; i ++ ) {
 		for ( var i = 0; i < 6; i ++ ) {
 
 
 			var distance = planes[ i ].distanceToPoint( center );
 			var distance = planes[ i ].distanceToPoint( center );
@@ -117,7 +117,7 @@ THREE.Frustum.prototype = {
 	},
 	},
 
 
 	containsPoint: function ( point ) {
 	containsPoint: function ( point ) {
-		
+
 		var planes = this.planes;
 		var planes = this.planes;
 
 
 		for ( var i = 0; i < 6; i ++ ) {
 		for ( var i = 0; i < 6; i ++ ) {
@@ -137,10 +137,9 @@ THREE.Frustum.prototype = {
 	clone: function () {
 	clone: function () {
 
 
 		var planes = this.planes;
 		var planes = this.planes;
-		return new THREE.Frustum(
-			planes[0], planes[1], planes[2], 
-			planes[3], planes[4], planes[5] );
+
+		return new THREE.Frustum( planes[0], planes[1], planes[2], planes[3], planes[4], planes[5] );
 
 
 	}
 	}
 
 
-};
+};

+ 3 - 3
src/math/Sphere.js

@@ -67,12 +67,12 @@ THREE.Sphere.prototype = {
 
 
 	},
 	},
 
 
-	isIntersectionSphere: function( sphere ) {
+	intersectsSphere: function ( sphere ) {
 
 
 		var radiusSum = this.radius + sphere.radius;
 		var radiusSum = this.radius + sphere.radius;
 
 
-		return ( sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum ) );
-		
+		return sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum );
+
 	},
 	},
 
 
 	clampPoint: function ( point, optionalTarget ) {
 	clampPoint: function ( point, optionalTarget ) {

+ 3 - 3
test/unit/math/Sphere.js

@@ -60,13 +60,13 @@ test( "distanceToPoint", function() {
 	ok( a.distanceToPoint( one3 ) === -1, "Passed!" );
 	ok( a.distanceToPoint( one3 ) === -1, "Passed!" );
 });
 });
 
 
-test( "isIntersectionSphere", function() {
+test( "intersectsSphere", function() {
 	var a = new THREE.Sphere( one3, 1 );
 	var a = new THREE.Sphere( one3, 1 );
 	var b = new THREE.Sphere( zero3, 1 );
 	var b = new THREE.Sphere( zero3, 1 );
 	var c = new THREE.Sphere( zero3, 0.25 );
 	var c = new THREE.Sphere( zero3, 0.25 );
 
 
-	ok( a.isIntersectionSphere( b ) , "Passed!" );
-	ok( ! a.isIntersectionSphere( c ) , "Passed!" );
+	ok( a.intersectsSphere( b ) , "Passed!" );
+	ok( ! a.intersectsSphere( c ) , "Passed!" );
 });
 });
 
 
 test( "clampPoint", function() {
 test( "clampPoint", function() {