Browse Source

add recastSelf and document that I am unsure of the best way to handle failure cases.

Ben Houston 12 years ago
parent
commit
c8d990f491
1 changed files with 20 additions and 3 deletions
  1. 20 3
      src/core/Ray3.js

+ 20 - 3
src/core/Ray3.js

@@ -47,9 +47,17 @@ THREE.Ray3.prototype = {
 
 	},
 
+	recastSelf: function ( t ) {
+
+		this.origin = this.at( t );
+
+		return this;
+
+	},
+
 	recast: function ( t ) {
 
-		return new THREE.Ray3( this.at( t ), this.direction );
+		return this.clone().recastSelf( t );
 
 	},
 
@@ -90,7 +98,10 @@ THREE.Ray3.prototype = {
 			var absNum = ( ( num >= 0 ) ? num: -num );
 
 			if (absNum >= absDenom * Number.MAX_VALUE ) {
+
+				// Unsure if this is the correct method to handle this case.
 				return this.origin.clone();
+
 		    }
 	    }
 
@@ -105,10 +116,15 @@ THREE.Ray3.prototype = {
 
 		var d = __v1.dot( __v2 );
 		if( d >= 0 ) {
+
 			return d;
-		}
-		return -1;
 
+		} else {
+
+			// Unsure if this is the correct method to handle this case.
+			return -1;
+
+		}
 	},
 
 	isIntersectionPlane: function ( plane ) {
@@ -128,6 +144,7 @@ THREE.Ray3.prototype = {
 		}
 
 		var t = - ( ( this.origin ^ plane.normal ) - plane.constant ) / a;
+
 		return this.at( t );
 
 	},