提交 1269d968 编写于 作者: O Oliver Sand

Add unit test, fix is isIntersectionSphere

Add missing space
Fix isIntersectionSphere
Addunit test for isIntersectionSphere
上级 dcd25863
...@@ -67,9 +67,11 @@ THREE.Sphere.prototype = { ...@@ -67,9 +67,11 @@ THREE.Sphere.prototype = {
}, },
isIntersectionSphere: function(sphere) { isIntersectionSphere: function( sphere ) {
return ( sphere.center.distanceToSquared( this.center ) <= ( this.radius * this.radius + sphere.radius * sphere.radius) ); var radiusSum = this.radius + sphere.radius;
return ( sphere.center.distanceToSquared( this.center ) <= ( radiusSum * radiusSum ) );
}, },
......
...@@ -60,6 +60,15 @@ test( "distanceToPoint", function() { ...@@ -60,6 +60,15 @@ test( "distanceToPoint", function() {
ok( a.distanceToPoint( one3 ) === -1, "Passed!" ); ok( a.distanceToPoint( one3 ) === -1, "Passed!" );
}); });
test( "isIntersectionSphere", function() {
var a = new THREE.Sphere( one3, 1 );
var b = new THREE.Sphere( zero3, 1 );
var c = new THREE.Sphere( zero3, 0.25 );
ok( a.isIntersectionSphere( b ) , "Passed!" );
ok( ! a.isIntersectionSphere( c ) , "Passed!" );
});
test( "clampPoint", function() { test( "clampPoint", function() {
var a = new THREE.Sphere( one3, 1 ); var a = new THREE.Sphere( one3, 1 );
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册