Răsfoiți Sursa

Avoid allocating local transforms

yomboprime 7 ani în urmă
părinte
comite
d993f600a9
1 a modificat fișierele cu 9 adăugiri și 5 ștergeri
  1. 9 5
      examples/js/loaders/SVGLoader.js

+ 9 - 5
examples/js/loaders/SVGLoader.js

@@ -805,11 +805,11 @@ THREE.SVGLoader.prototype = {
 							}
 
 							// Rotate around center (cx, cy)
-							var translation = new THREE.Matrix3().translate( -cx, -cy );
-							var rotation = new THREE.Matrix3().rotate( angle );
-							var translRot = new THREE.Matrix3().multiplyMatrices( rotation, translation );
-							translation.identity().translate( cx, cy );
-							transform.multiplyMatrices( translation, translRot );
+							tempTransform1.identity().translate( -cx, -cy );
+							tempTransform2.identity().rotate( angle );
+							tempTransform3.multiplyMatrices( tempTransform2, tempTransform1 );
+							tempTransform1.identity().translate( cx, cy );
+							transform.multiplyMatrices( tempTransform1, tempTransform3 );
 
 						}
 
@@ -979,6 +979,10 @@ THREE.SVGLoader.prototype = {
 
 		var transformStack = [];
 
+		var tempTransform1 = new THREE.Matrix3();
+		var tempTransform2 = new THREE.Matrix3();
+		var tempTransform3 = new THREE.Matrix3();
+
 		var currentTransform = new THREE.Matrix3();
 
 		console.time( 'THREE.SVGLoader: DOMParser' );