Browse Source

remove some GC pressure by copying element by element

foijord 8 years ago
parent
commit
28ca2ce49a
3 changed files with 6 additions and 9 deletions
  1. 2 3
      build/three.js
  2. 2 3
      build/three.module.js
  3. 2 3
      src/math/Matrix4.js

+ 2 - 3
build/three.js

@@ -3402,7 +3402,7 @@
 
 		copy: function ( m ) {
 
-			this.elements = m.elements.slice();
+			for ( var i = 0; i < 16; i ++ ) this.elements[ i ] = m.elements[ i ];
 
 			return this;
 
@@ -4127,8 +4127,7 @@
 				position.z = te[ 14 ];
 
 				// scale the rotation part
-
-				matrix.elements = this.elements.slice(); // at this point matrix is incomplete so we can't use .copy()
+				for ( var i = 0; i < 16; i ++ ) matrix.elements[ i ] = this.elements[ i ]; // at this point matrix is incomplete so we can't use .copy()
 
 				var invSX = 1 / sx;
 				var invSY = 1 / sy;

+ 2 - 3
build/three.module.js

@@ -3396,7 +3396,7 @@ Matrix4.prototype = {
 
 	copy: function ( m ) {
 
-		this.elements = m.elements.slice();
+		for ( var i = 0; i < 16; i ++ ) this.elements[ i ] = m.elements[ i ];
 
 		return this;
 
@@ -4121,8 +4121,7 @@ Matrix4.prototype = {
 			position.z = te[ 14 ];
 
 			// scale the rotation part
-
-			matrix.elements = this.elements.slice(); // at this point matrix is incomplete so we can't use .copy()
+			for ( var i = 0; i < 16; i ++ ) matrix.elements[ i ] = this.elements[ i ]; // at this point matrix is incomplete so we can't use .copy()
 
 			var invSX = 1 / sx;
 			var invSY = 1 / sy;

+ 2 - 3
src/math/Matrix4.js

@@ -75,7 +75,7 @@ Matrix4.prototype = {
 
 	copy: function ( m ) {
 
-		this.elements = m.elements.slice();
+		for ( var i = 0; i < 16; i ++ ) this.elements[ i ] = m.elements[ i ];
 
 		return this;
 
@@ -800,8 +800,7 @@ Matrix4.prototype = {
 			position.z = te[ 14 ];
 
 			// scale the rotation part
-
-			matrix.elements = this.elements.slice(); // at this point matrix is incomplete so we can't use .copy()
+			for ( var i = 0; i < 16; i ++ ) matrix.elements[ i ] = this.elements[ i ]; // at this point matrix is incomplete so we can't use .copy()
 
 			var invSX = 1 / sx;
 			var invSY = 1 / sy;