Browse Source

add some unit tests for Ray-Sphere intersection testing.

Ben Houston 12 years ago
parent
commit
b9a98dd689
1 changed files with 15 additions and 0 deletions
  1. 15 0
      test/core/Ray.js

+ 15 - 0
test/core/Ray.js

@@ -136,6 +136,21 @@ test( "closestPointToRay", function() {
 });
 */
 
+test( "isIntersectionSphere", function() {
+	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
+	var b = new THREE.Sphere( zero3, 0.5 );
+	var c = new THREE.Sphere( zero3, 1.5 );
+	var d = new THREE.Sphere( one3, 0.1 );
+	var e = new THREE.Sphere( two3, 0.1 );
+	var f = new THREE.Sphere( two3, 1 );
+
+	ok( ! a.isIntersectionSphere( b ), "Passed!" );
+	ok( a.isIntersectionSphere( c ), "Passed!" );
+	ok( a.isIntersectionSphere( d ), "Passed!" );
+	ok( ! a.isIntersectionSphere( e ), "Passed!" );
+	ok( ! a.isIntersectionSphere( f ), "Passed!" );
+});
+
 test( "isIntersectionBox", function() {
 	var a = new THREE.Ray( one3, new THREE.Vector3( 0, 0, 1 ) );
 	var b = new THREE.Box3( zero3, one3 );