Skip to content

Commit ad83fa4

Browse files
committed
Avoid using THREE.Matrix3 elements
1 parent d993f60 commit ad83fa4

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

examples/js/loaders/SVGLoader.js

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -769,15 +769,16 @@ THREE.SVGLoader.prototype = {
769769

770770
transform = new THREE.Matrix3();
771771

772-
// Translation X
773-
transform.elements[ 6 ] = array[ 0 ];
772+
var tx = array[ 0 ];
773+
var ty = tx;
774774

775-
}
775+
if ( array.length >= 2 ) {
776+
777+
ty = array[ 1 ];
776778

777-
if ( array.length >= 2 ) {
779+
}
778780

779-
// Translation Y
780-
transform.elements[ 7 ] = array[ 1 ];
781+
transform.translate( tx, ty );
781782

782783
}
783784

@@ -828,8 +829,7 @@ THREE.SVGLoader.prototype = {
828829
scaleY = array[ 1 ];
829830
}
830831

831-
transform.elements[ 0 ] = scaleX;
832-
transform.elements[ 4 ] = scaleY;
832+
transform.scale( scaleX, scaleY );
833833

834834
}
835835

@@ -841,7 +841,11 @@ THREE.SVGLoader.prototype = {
841841

842842
transform = new THREE.Matrix3();
843843

844-
transform.elements[ 3 ] = Math.tan( array[ 0 ] * Math.PI / 180 );
844+
transform.set(
845+
1, Math.tan( array[ 0 ] * Math.PI / 180 ), 0,
846+
0, 1, 0,
847+
0, 0, 1
848+
);
845849

846850
}
847851

@@ -853,7 +857,11 @@ THREE.SVGLoader.prototype = {
853857

854858
transform = new THREE.Matrix3();
855859

856-
transform.elements[ 1 ] = Math.tan( array[ 0 ] * Math.PI / 180 );
860+
transform.set(
861+
1, 0, 0,
862+
Math.tan( array[ 0 ] * Math.PI / 180 ), 1, 0,
863+
0, 0, 1
864+
);
857865

858866
}
859867

@@ -865,17 +873,11 @@ THREE.SVGLoader.prototype = {
865873

866874
transform = new THREE.Matrix3();
867875

868-
var e = transform.elements;
869-
870-
e[ 0 ] = array[ 0 ];
871-
e[ 1 ] = array[ 1 ];
872-
e[ 2 ] = 0;
873-
e[ 3 ] = array[ 2 ];
874-
e[ 4 ] = array[ 3 ];
875-
e[ 5 ] = 0;
876-
e[ 6 ] = array[ 4 ];
877-
e[ 7 ] = array[ 5 ];
878-
e[ 8 ] = 1;
876+
transform.set(
877+
array[ 0 ], array[ 2 ], array[ 4 ],
878+
array[ 1 ], array[ 3 ], array[ 5 ],
879+
0, 0, 1
880+
);
879881

880882
}
881883

0 commit comments

Comments
 (0)