Skip to content

Commit d993f60

Browse files
committed
Avoid allocating local transforms
1 parent 7095292 commit d993f60

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

examples/js/loaders/SVGLoader.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -805,11 +805,11 @@ THREE.SVGLoader.prototype = {
805805
}
806806

807807
// Rotate around center (cx, cy)
808-
var translation = new THREE.Matrix3().translate( -cx, -cy );
809-
var rotation = new THREE.Matrix3().rotate( angle );
810-
var translRot = new THREE.Matrix3().multiplyMatrices( rotation, translation );
811-
translation.identity().translate( cx, cy );
812-
transform.multiplyMatrices( translation, translRot );
808+
tempTransform1.identity().translate( -cx, -cy );
809+
tempTransform2.identity().rotate( angle );
810+
tempTransform3.multiplyMatrices( tempTransform2, tempTransform1 );
811+
tempTransform1.identity().translate( cx, cy );
812+
transform.multiplyMatrices( tempTransform1, tempTransform3 );
813813

814814
}
815815

@@ -979,6 +979,10 @@ THREE.SVGLoader.prototype = {
979979

980980
var transformStack = [];
981981

982+
var tempTransform1 = new THREE.Matrix3();
983+
var tempTransform2 = new THREE.Matrix3();
984+
var tempTransform3 = new THREE.Matrix3();
985+
982986
var currentTransform = new THREE.Matrix3();
983987

984988
console.time( 'THREE.SVGLoader: DOMParser' );

0 commit comments

Comments
 (0)