| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- /**
- * @author bhouston / http://exocortex.com
- */
- module( "Plane" );
- test( "constructor", function() {
- var a = new THREE.Plane();
- ok( a.normal.x == 0, "Passed!" );
- ok( a.normal.y == 0, "Passed!" );
- ok( a.normal.z == 0, "Passed!" );
- ok( a.constant == 0, "Passed!" );
- console.log( one );
- a = new THREE.Plane( one, 0 );
- ok( a.normal.x == 1, "Passed!" );
- ok( a.normal.y == 1, "Passed!" );
- ok( a.normal.z == 1, "Passed!" );
- ok( a.constant == 0, "Passed!" );
- a = new THREE.Plane( one, 1 );
- ok( a.normal.x == 1, "Passed!" );
- ok( a.normal.y == 1, "Passed!" );
- ok( a.normal.z == 1, "Passed!" );
- ok( a.constant == 1, "Passed!" );
- });
- test( "copy", function() {
- var a = new THREE.Plane( new THREE.Vector3( x, y, z ), w );
- var b = new THREE.Plane().copy( a );
- ok( b.normal.x == x, "Passed!" );
- ok( b.normal.y == y, "Passed!" );
- ok( b.normal.z == z, "Passed!" );
- ok( b.constant == w, "Passed!" );
- // ensure that it is a true copy
- a.normal.x = 0;
- a.normal.y = -1;
- a.normal.z = -2;
- a.constant = -3;
- ok( b.normal.x == x, "Passed!" );
- ok( b.normal.y == y, "Passed!" );
- ok( b.normal.z == z, "Passed!" );
- ok( b.constant == w, "Passed!" );
- });
- test( "set", function() {
- var a = new THREE.Plane();
- ok( a.normal.x == 0, "Passed!" );
- ok( a.normal.y == 0, "Passed!" );
- ok( a.normal.z == 0, "Passed!" );
- ok( a.constant == 0, "Passed!" );
- var b = a.clone().set( new THREE.Vector3( x, y, z ), w );
- ok( b.normal.x == x, "Passed!" );
- ok( b.normal.y == y, "Passed!" );
- ok( b.normal.z == z, "Passed!" );
- ok( b.constant == w, "Passed!" );
- });
- test( "setComponents", function() {
- var a = new THREE.Plane();
- ok( a.normal.x == 0, "Passed!" );
- ok( a.normal.y == 0, "Passed!" );
- ok( a.normal.z == 0, "Passed!" );
- ok( a.constant == 0, "Passed!" );
- var b = a.clone().setComponents( x, y, z , w );
- ok( b.normal.x == x, "Passed!" );
- ok( b.normal.y == y, "Passed!" );
- ok( b.normal.z == z, "Passed!" );
- ok( b.constant == w, "Passed!" );
- });
- test( "setFromNormalAndCoplanarPoint", function() {
- var a = new THREE.Plane().setFromNormalAndCoplanarPoint( one, zero );
-
- ok( a.normal.equals( one ), "Passed!" );
- ok( a.constant == 0, "Passed!" );
- });
- test( "flip", function() {
- var a = new THREE.Plane( one, 0 );
-
- ok( a.normal.equals( one ), "Passed!" );
- a.flip();
- ok( a.normal.negate().equals( one ), "Passed!" );
- });
- test( "normalize", function() {
- var a = new THREE.Plane( two, 2 );
-
- a.normalize();
- ok( a.normal.length() == 1, "Passed!" );
- ok( a.normal.equals( one ), "Passed!" );
- ok( a.constant == 1, "Passed!" );
- });
|