123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- /**
- * @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!" );
- 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!" );
- });
|