|
@@ -118,7 +118,7 @@ test( "intersectSphere", function() {
|
|
|
var a1 = new THREE.Ray( one3.clone(), new THREE.Vector3( -1, 0, 0 ) );
|
|
|
|
|
|
// sphere (radius of 2) located behind ray a0, should result in null
|
|
|
- var b = new THREE.Sphere( new THREE.Vector3( 0, 0, 1 ), 2 );
|
|
|
+ var b = new THREE.Sphere( new THREE.Vector3( 0, 0, 3 ), 2 );
|
|
|
ok( a0.intersectSphere( b ) === null, "Passed!" );
|
|
|
|
|
|
// sphere (radius of 2) located in front of, but too far right of ray a0, should result in null
|
|
@@ -145,12 +145,26 @@ test( "intersectSphere", function() {
|
|
|
var b = new THREE.Sphere( new THREE.Vector3( 2.01, 0, -1 ), 2 );
|
|
|
ok( a0.intersectSphere( b ) === null, "Passed!" );
|
|
|
|
|
|
+ // following tests are for situations where the ray origin is inside the sphere
|
|
|
+
|
|
|
// sphere (radius of 1) center located at ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 1,
|
|
|
// is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -1
|
|
|
// thus keeping the intersection point always in front of the ray.
|
|
|
var b = new THREE.Sphere( zero3.clone(), 1 );
|
|
|
ok( a0.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 0, -1 ) ) < TOL, "Passed!" );
|
|
|
|
|
|
+ // sphere (radius of 4) center located behind ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 5,
|
|
|
+ // is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -3
|
|
|
+ // thus keeping the intersection point always in front of the ray.
|
|
|
+ var b = new THREE.Sphere( new THREE.Vector3( 0, 0, 1 ), 4 );
|
|
|
+ ok( a0.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 0, -3 ) ) < TOL, "Passed!" );
|
|
|
+
|
|
|
+ // sphere (radius of 4) center located in front of ray a0 origin / sphere surrounds the ray origin, so the first intersect point 0, 0, 3,
|
|
|
+ // is behind ray a0. Therefore, second exit point on back of sphere will be returned: 0, 0, -5
|
|
|
+ // thus keeping the intersection point always in front of the ray.
|
|
|
+ var b = new THREE.Sphere( new THREE.Vector3( 0, 0, -1 ), 4 );
|
|
|
+ ok( a0.intersectSphere( b ).distanceTo( new THREE.Vector3( 0, 0, -5 ) ) < TOL, "Passed!" );
|
|
|
+
|
|
|
});
|
|
|
|
|
|
test( "isIntersectionPlane", function() {
|