Browse Source

improvement to Ray for improved Raycaster integration.

Ben Houston 12 years ago
parent
commit
348a3dd0b4
1 changed files with 9 additions and 3 deletions
  1. 9 3
      src/math/Ray.js

+ 9 - 3
src/math/Ray.js

@@ -32,9 +32,15 @@ THREE.Ray.prototype = {
 
 
 	},
 	},
 
 
-	at: function( t ) {
+	at: function( t, optionalTarget ) {
 
 
-		return this.direction.clone().multiplyScalar( t ).addSelf( this.origin );
+		if( optionalTarget === undefined ) {
+			optionalTarget = this.direction.clone();
+		}
+		else {
+			optionalTarget.copy( this.direction );
+		}
+		return optionalTarget.multiplyScalar( t ).addSelf( this.origin );
 
 
 	},
 	},
 
 
@@ -109,7 +115,7 @@ THREE.Ray.prototype = {
 
 
 		}
 		}
 
 
-		var t = - ( ( this.origin.dot( plane.normal ) ) + plane.constant ) / denominator;
+		var t = - ( this.origin.dot( plane.normal ) + plane.constant ) / denominator;
 
 
 		return this.at( t );
 		return this.at( t );