Explorar o código

Make applyMatrix4 branchless, clean up docs

Franklin Ta %!s(int64=8) %!d(string=hai) anos
pai
achega
9d6f2d4ad2
Modificáronse 2 ficheiros con 6 adicións e 12 borrados
  1. 1 3
      docs/api/math/Vector3.html
  2. 5 9
      src/math/Vector3.js

+ 1 - 3
docs/api/math/Vector3.html

@@ -108,9 +108,7 @@ var d = a.distanceTo( b );
 
 		<h3>[method:Vector3 applyMatrix4]( [page:Matrix4 m] )</h3>
 		<div>
-		[page:Matrix4 m] - [page:Matrix4] projection matrix.<br /><br />
-
-		Multiplies this vector and m, and divides by perspective.
+		Multiplies this vector (with an implicit 1 in the 4th dimension) and m, and divides by perspective.
 		</div>
 
 		<h3>[method:Vector3 applyQuaternion]( [page:Quaternion quaternion] )</h3>

+ 5 - 9
src/math/Vector3.js

@@ -299,16 +299,12 @@ Vector3.prototype = {
 		this.x = e[ 0 ] * x + e[ 4 ] * y + e[ 8 ]  * z + e[ 12 ];
 		this.y = e[ 1 ] * x + e[ 5 ] * y + e[ 9 ]  * z + e[ 13 ];
 		this.z = e[ 2 ] * x + e[ 6 ] * y + e[ 10 ] * z + e[ 14 ];
-		var w =  e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ];
+		var w = e[ 3 ] * x + e[ 7 ] * y + e[ 11 ] * z + e[ 15 ];
 
-		if ( w !== 1 ) {
-
-			var d = 1 / w; // perspective divide
-			this.x *= d;
-			this.y *= d;
-			this.z *= d;
-
-		}
+		var d = 1 / w; // perspective divide
+		this.x *= d;
+		this.y *= d;
+		this.z *= d;
 
 		return this;