|
@@ -106,65 +106,30 @@ test( "setFromMatrix/makeFrustum/containsPoint", function() {
|
|
|
ok( ! a.containsPoint( new THREE.Vector3( 0, 0, -101 ) ), "Passed!" );
|
|
|
});
|
|
|
|
|
|
-test( "setFromMatrix/makeFrustum/containsSphere", function() {
|
|
|
+test( "setFromMatrix/makeFrustum/intersectsSphere", function() {
|
|
|
var m = new THREE.Matrix4().makeFrustum( -1, 1, -1, 1, 1, 100 )
|
|
|
var a = new THREE.Frustum().setFromMatrix( m );
|
|
|
|
|
|
- ok( ! a.containsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, 0 ), 0 ) ), "Passed!" );
|
|
|
- ok( ! a.containsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, 0 ), 0.9 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, 0 ), 1.1 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -50 ), 0 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -1.001 ), 0 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( -1, -1, -1.001 ), 0 ) ), "Passed!" );
|
|
|
- ok( ! a.containsSphere( new THREE.Sphere( new THREE.Vector3( -1.1, -1.1, -1.001 ), 0 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( -1.1, -1.1, -1.001 ), 0.5 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 1, 1, -1.001 ), 0 ) ), "Passed!" );
|
|
|
- ok( ! a.containsSphere( new THREE.Sphere( new THREE.Vector3( 1.1, 1.1, -1.001 ), 0 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 1.1, 1.1, -1.001 ), 0.5 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -99.999 ), 0 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( -99.999, -99.999, -99.999 ), 0 ) ), "Passed!" );
|
|
|
- ok( ! a.containsSphere( new THREE.Sphere( new THREE.Vector3( -100.1, -100.1, -100.1 ), 0 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( -100.1, -100.1, -100.1 ), 0.5 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 99.999, 99.999, -99.999 ), 0 ) ), "Passed!" );
|
|
|
- ok( ! a.containsSphere( new THREE.Sphere( new THREE.Vector3( 100.1, 100.1, -100.1 ), 0 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 100.1, 100.1, -100.1 ), 0.2 ) ), "Passed!" );
|
|
|
- ok( ! a.containsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -101 ), 0 ) ), "Passed!" );
|
|
|
- ok( a.containsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -101 ), 1.1 ) ), "Passed!" );
|
|
|
-});
|
|
|
-
|
|
|
-test( "transform", function() {
|
|
|
-
|
|
|
- var p0 = new THREE.Plane( unit3, -1 );
|
|
|
- var p1 = new THREE.Plane( unit3, 1 );
|
|
|
- var p2 = new THREE.Plane( unit3, 2 );
|
|
|
- var p3 = new THREE.Plane( unit3, 3 );
|
|
|
- var p4 = new THREE.Plane( unit3, 4 );
|
|
|
- var p5 = new THREE.Plane( unit3, 5 );
|
|
|
-
|
|
|
- var b = new THREE.Frustum( p0, p1, p2, p3, p4, p5 );
|
|
|
- var a = new THREE.Frustum().copy( b ).transform( new THREE.Matrix4() );
|
|
|
- ok( a.planes[0].equals( p0 ), "Passed!" );
|
|
|
- ok( a.planes[1].equals( p1 ), "Passed!" );
|
|
|
- ok( a.planes[2].equals( p2 ), "Passed!" );
|
|
|
- ok( a.planes[3].equals( p3 ), "Passed!" );
|
|
|
- ok( a.planes[4].equals( p4 ), "Passed!" );
|
|
|
- ok( a.planes[5].equals( p5 ), "Passed!" );
|
|
|
-
|
|
|
- a = new THREE.Frustum().copy( b ).transform( new THREE.Matrix4().makeRotationZ( Math.PI ) );
|
|
|
- ok( ! planeEquals( a.planes[0], p0 ), "Passed!" );
|
|
|
- ok( ! planeEquals( a.planes[1], p1 ), "Passed!" );
|
|
|
- ok( ! planeEquals( a.planes[2], p2 ), "Passed!" );
|
|
|
- ok( ! planeEquals( a.planes[3], p3 ), "Passed!" );
|
|
|
- ok( ! planeEquals( a.planes[4], p4 ), "Passed!" );
|
|
|
- ok( ! planeEquals( a.planes[5], p5 ), "Passed!" );
|
|
|
-
|
|
|
- a = a.transform( new THREE.Matrix4().makeRotationZ( Math.PI ) );
|
|
|
- ok( planeEquals( a.planes[0], p0 ), "Passed!" );
|
|
|
- ok( planeEquals( a.planes[1], p1 ), "Passed!" );
|
|
|
- ok( planeEquals( a.planes[2], p2 ), "Passed!" );
|
|
|
- ok( planeEquals( a.planes[3], p3 ), "Passed!" );
|
|
|
- ok( planeEquals( a.planes[4], p4 ), "Passed!" );
|
|
|
- ok( planeEquals( a.planes[5], p5 ), "Passed!" );
|
|
|
+ ok( ! a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, 0 ), 0 ) ), "Passed!" );
|
|
|
+ ok( ! a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, 0 ), 0.9 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, 0 ), 1.1 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -50 ), 0 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -1.001 ), 0 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( -1, -1, -1.001 ), 0 ) ), "Passed!" );
|
|
|
+ ok( ! a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( -1.1, -1.1, -1.001 ), 0 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( -1.1, -1.1, -1.001 ), 0.5 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 1, 1, -1.001 ), 0 ) ), "Passed!" );
|
|
|
+ ok( ! a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 1.1, 1.1, -1.001 ), 0 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 1.1, 1.1, -1.001 ), 0.5 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -99.999 ), 0 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( -99.999, -99.999, -99.999 ), 0 ) ), "Passed!" );
|
|
|
+ ok( ! a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( -100.1, -100.1, -100.1 ), 0 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( -100.1, -100.1, -100.1 ), 0.5 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 99.999, 99.999, -99.999 ), 0 ) ), "Passed!" );
|
|
|
+ ok( ! a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 100.1, 100.1, -100.1 ), 0 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 100.1, 100.1, -100.1 ), 0.2 ) ), "Passed!" );
|
|
|
+ ok( ! a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -101 ), 0 ) ), "Passed!" );
|
|
|
+ ok( a.intersectsSphere( new THREE.Sphere( new THREE.Vector3( 0, 0, -101 ), 1.1 ) ), "Passed!" );
|
|
|
});
|
|
|
|
|
|
test( "clone", function() {
|