فهرست منبع

Support Matrix4.setPosition( x, y, z )

WestLangley 6 سال پیش
والد
کامیت
a4fe6f8700
3فایلهای تغییر یافته به همراه16 افزوده شده و 5 حذف شده
  1. 1 0
      docs/api/en/math/Matrix4.html
  2. 1 1
      src/math/Matrix4.d.ts
  3. 14 4
      src/math/Matrix4.js

+ 1 - 0
docs/api/en/math/Matrix4.html

@@ -375,6 +375,7 @@ x, y, 1, 0,
 		</p>
 
 		<h3>[method:this setPosition]( [param:Vector3 v] )</h3>
+		<h3>[method:this setPosition]( [param:Float x], [param:Float y], [param:Float z] ) // optional API</h3>
 		<p>
 			Sets the position component for this matrix from vector [page:Vector3 v], without affecting the
 			rest of the matrix - i.e. if the matrix is currently:

+ 1 - 1
src/math/Matrix4.d.ts

@@ -122,7 +122,7 @@ export class Matrix4 implements Matrix {
   /**
    * Sets the position component for this matrix from vector v.
    */
-  setPosition(v: Vector3): Matrix4;
+  setPosition(v: Vector3 | number, y?: number, z?: number): Matrix4;
 
   /**
    * Sets this matrix to the inverse of matrix m.

+ 14 - 4
src/math/Matrix4.js

@@ -519,13 +519,23 @@ Object.assign( Matrix4.prototype, {
 
 	},
 
-	setPosition: function ( v ) {
+	setPosition: function ( x, y, z ) {
 
 		var te = this.elements;
 
-		te[ 12 ] = v.x;
-		te[ 13 ] = v.y;
-		te[ 14 ] = v.z;
+		if ( x.isVector3 ) {
+
+			te[ 12 ] = x.x;
+			te[ 13 ] = x.y;
+			te[ 14 ] = x.z;
+
+		} else {
+
+			te[ 12 ] = x;
+			te[ 13 ] = y;
+			te[ 14 ] = z;
+
+		}
 
 		return this;