Jelajahi Sumber

add offset to Matrix4.fromArray for consistency with all other fromArray functions (#9611)

* add offset to fromArray for consistency with all other fromArray functions in the ThreeJS math library.

* Added matrix3/fixed whitespace
Josiah Konrad 9 tahun lalu
induk
melakukan
f5830756ed
2 mengubah file dengan 15 tambahan dan 3 penghapusan
  1. 7 1
      src/math/Matrix3.js
  2. 8 2
      src/math/Matrix4.js

+ 7 - 1
src/math/Matrix3.js

@@ -274,7 +274,13 @@ Matrix3.prototype = {
 
 	fromArray: function ( array ) {
 
-		this.elements.set( array );
+		if ( offset === undefined ) offset = 0;
+
+		for( var i = 0; i < 9; i ++ ) {
+
+			this.elements[ i ] = array[ i + offset ];
+
+		}
 
 		return this;
 

+ 8 - 2
src/math/Matrix4.js

@@ -934,9 +934,15 @@ Matrix4.prototype = {
 
 	},
 
-	fromArray: function ( array ) {
+	fromArray: function ( array, offset ) {
 
-		this.elements.set( array );
+		if ( offset === undefined ) offset = 0;
+
+		for( var i = 0; i < 16; i ++ ) {
+
+			this.elements[ i ] = array[ i + offset ];
+
+		}
 
 		return this;