Browse Source

Vector3.projectOn/reflect: normal arg to unitNormal. Removed Vector3.orthoTo

Ben Houston 12 years ago
parent
commit
5c3775465b
2 changed files with 5 additions and 38 deletions
  1. 5 20
      src/math/Vector3.js
  2. 0 18
      test/unit/math/Vector3.js

+ 5 - 20
src/math/Vector3.js

@@ -520,35 +520,20 @@ THREE.extend( THREE.Vector3.prototype, {
 
 
 	},
 	},
 
 
+	projectOn: function( unitNormal ) {
 
 
-	projectOn: function( normal ) {
-
-		var d = this.dot( normal );
-		return this.copy( normal ).multiplyScalar( d );
+		var d = this.dot( unitNormal );
+		return this.copy( unitNormal ).multiplyScalar( d );
 
 
 	},
 	},
-	
-	orthoTo: function () {
-
-		var v1 = new THREE.Vector3();
-
-		return function( normal ) {
-
-			v1.copy( this ).projectOn( normal );
-
-			return this.sub( v1 );
-
-		}
-
-	}(),
 
 
 	reflect: function () {
 	reflect: function () {
 
 
 		var v1 = new THREE.Vector3();
 		var v1 = new THREE.Vector3();
 
 
-		return function ( normal ) {
+		return function ( unitNormal ) {
 
 
-		    v1.copy( this ).projectOn( normal ).multiplyScalar( 2 );
+		    v1.copy( this ).projectOn( unitNormal ).multiplyScalar( 2 );
 
 
 		    return this.subVectors( v1, this );
 		    return this.subVectors( v1, this );
 
 

+ 0 - 18
test/unit/math/Vector3.js

@@ -257,24 +257,6 @@ test( "projectOn", function() {
 
 
 });
 });
 
 
-test( "orthoTo", function() {
-	var a = new THREE.Vector3( 1, 0, 0 );
-	var b = new THREE.Vector3();
-	var normal = new THREE.Vector3( 1, 0, 0 );
-
-	ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
-
-	a.set( 0, 1, 0 );
-	ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 1, 0 ) ), "Passed!" );
-
-	a.set( 0, 0, -1 );
-	ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, -1 ) ), "Passed!" );
-
-	a.set( -1, 0, 0 );
-	ok( b.copy( a ).orthoTo( normal ).equals( new THREE.Vector3( 0, 0, 0 ) ), "Passed!" );
-
-});
-
 test( "reflect", function() {
 test( "reflect", function() {
 	var a = new THREE.Vector3( 1, 0, 0 );
 	var a = new THREE.Vector3( 1, 0, 0 );
 	var normal = new THREE.Vector3( 1, 0, 0 );
 	var normal = new THREE.Vector3( 1, 0, 0 );