@@ -682,76 +682,17 @@ class Matrix4 {
682
682
} else if (x is Vector4 ) {
683
683
translateByVector4 (x);
684
684
} else if (x is double ) {
685
- translateByDouble (x, y, z);
685
+ translateByDouble (x, y, z, 1.0 );
686
686
} else {
687
687
throw UnimplementedError ();
688
688
}
689
689
}
690
690
691
691
/// Translate this matrix by x, y, z.
692
- void translateByDouble (double tx, double ty, double tz) {
693
- final t1 = _m4storage[0 ] * tx +
694
- _m4storage[4 ] * ty +
695
- _m4storage[8 ] * tz +
696
- _m4storage[12 ];
697
- _m4storage[12 ] = t1;
698
-
699
- final t2 = _m4storage[1 ] * tx +
700
- _m4storage[5 ] * ty +
701
- _m4storage[9 ] * tz +
702
- _m4storage[13 ];
703
- _m4storage[13 ] = t2;
704
-
705
- final t3 = _m4storage[2 ] * tx +
706
- _m4storage[6 ] * ty +
707
- _m4storage[10 ] * tz +
708
- _m4storage[14 ];
709
- _m4storage[14 ] = t3;
710
-
711
- final t4 = _m4storage[3 ] * tx +
712
- _m4storage[7 ] * ty +
713
- _m4storage[11 ] * tz +
714
- _m4storage[15 ];
715
- _m4storage[15 ] = t4;
716
- }
717
-
718
- /// Translate this matrix by a [Vector3] .
719
- void translateByVector3 (Vector3 v3) {
720
- final tx = v3.x;
721
- final ty = v3.y;
722
- final tz = v3.z;
723
- final t1 = _m4storage[0 ] * tx +
724
- _m4storage[4 ] * ty +
725
- _m4storage[8 ] * tz +
726
- _m4storage[12 ];
727
- _m4storage[12 ] = t1;
728
-
729
- final t2 = _m4storage[1 ] * tx +
730
- _m4storage[5 ] * ty +
731
- _m4storage[9 ] * tz +
732
- _m4storage[13 ];
733
- _m4storage[13 ] = t2;
734
-
735
- final t3 = _m4storage[2 ] * tx +
736
- _m4storage[6 ] * ty +
737
- _m4storage[10 ] * tz +
738
- _m4storage[14 ];
739
- _m4storage[14 ] = t3;
740
-
741
- final t4 = _m4storage[3 ] * tx +
742
- _m4storage[7 ] * ty +
743
- _m4storage[11 ] * tz +
744
- _m4storage[15 ];
745
- _m4storage[15 ] = t4;
746
- }
747
-
748
- /// Translate this matrix by a [Vector4] .
749
- void translateByVector4 (Vector4 v4) {
750
- final tx = v4.x;
751
- final ty = v4.y;
752
- final tz = v4.z;
753
- final tw = v4.w;
754
-
692
+ @pragma ('wasm:prefer-inline' )
693
+ @pragma ('vm:prefer-inline' )
694
+ @pragma ('dart2js:prefer-inline' )
695
+ void translateByDouble (double tx, double ty, double tz, double tw) {
755
696
final t1 = _m4storage[0 ] * tx +
756
697
_m4storage[4 ] * ty +
757
698
_m4storage[8 ] * tz +
@@ -777,6 +718,20 @@ class Matrix4 {
777
718
_m4storage[15 ] = t4;
778
719
}
779
720
721
+ /// Translate this matrix by a [Vector3] .
722
+ @pragma ('wasm:prefer-inline' )
723
+ @pragma ('vm:prefer-inline' )
724
+ @pragma ('dart2js:prefer-inline' )
725
+ void translateByVector3 (Vector3 v3) =>
726
+ translateByDouble (v3.x, v3.y, v3.z, 1.0 );
727
+
728
+ /// Translate this matrix by a [Vector4] .
729
+ @pragma ('wasm:prefer-inline' )
730
+ @pragma ('vm:prefer-inline' )
731
+ @pragma ('dart2js:prefer-inline' )
732
+ void translateByVector4 (Vector4 v4) =>
733
+ translateByDouble (v4.x, v4.y, v4.z, v4.w);
734
+
780
735
/// Multiply this by a translation from the left.
781
736
///
782
737
/// The translation can be specified with a [Vector3] , [Vector4] , or x, y, z
@@ -794,77 +749,17 @@ class Matrix4 {
794
749
} else if (x is Vector4 ) {
795
750
leftTranslateByVector4 (x);
796
751
} else if (x is double ) {
797
- leftTranslateByDouble (x, y, z);
752
+ leftTranslateByDouble (x, y, z, 1.0 );
798
753
} else {
799
754
throw UnimplementedError ();
800
755
}
801
756
}
802
757
803
758
/// Multiply this by a translation from the left.
804
- void leftTranslateByDouble (double tx, double ty, double tz) {
805
- // Column 1
806
- final r1 = _m4storage[3 ];
807
- _m4storage[0 ] += tx * r1;
808
- _m4storage[1 ] += ty * r1;
809
- _m4storage[2 ] += tz * r1;
810
-
811
- // Column 2
812
- final r2 = _m4storage[7 ];
813
- _m4storage[4 ] += tx * r2;
814
- _m4storage[5 ] += ty * r2;
815
- _m4storage[6 ] += tz * r2;
816
-
817
- // Column 3
818
- final r3 = _m4storage[11 ];
819
- _m4storage[8 ] += tx * r3;
820
- _m4storage[9 ] += ty * r3;
821
- _m4storage[10 ] += tz * r3;
822
-
823
- // Column 4
824
- final r4 = _m4storage[15 ];
825
- _m4storage[12 ] += tx * r4;
826
- _m4storage[13 ] += ty * r4;
827
- _m4storage[14 ] += tz * r4;
828
- }
829
-
830
- /// Multiply this by a translation from the left.
831
- void leftTranslateByVector3 (Vector3 v3) {
832
- final tx = v3.x;
833
- final ty = v3.y;
834
- final tz = v3.z;
835
-
836
- // Column 1
837
- final r1 = _m4storage[3 ];
838
- _m4storage[0 ] += tx * r1;
839
- _m4storage[1 ] += ty * r1;
840
- _m4storage[2 ] += tz * r1;
841
-
842
- // Column 2
843
- final r2 = _m4storage[7 ];
844
- _m4storage[4 ] += tx * r2;
845
- _m4storage[5 ] += ty * r2;
846
- _m4storage[6 ] += tz * r2;
847
-
848
- // Column 3
849
- final r3 = _m4storage[11 ];
850
- _m4storage[8 ] += tx * r3;
851
- _m4storage[9 ] += ty * r3;
852
- _m4storage[10 ] += tz * r3;
853
-
854
- // Column 4
855
- final r4 = _m4storage[15 ];
856
- _m4storage[12 ] += tx * r4;
857
- _m4storage[13 ] += ty * r4;
858
- _m4storage[14 ] += tz * r4;
859
- }
860
-
861
- /// Multiply this by a translation from the left.
862
- void leftTranslateByVector4 (Vector4 v4) {
863
- final tx = v4.x;
864
- final ty = v4.y;
865
- final tz = v4.z;
866
- final tw = v4.w;
867
-
759
+ @pragma ('wasm:prefer-inline' )
760
+ @pragma ('vm:prefer-inline' )
761
+ @pragma ('dart2js:prefer-inline' )
762
+ void leftTranslateByDouble (double tx, double ty, double tz, double tw) {
868
763
// Column 1
869
764
final r1 = _m4storage[3 ];
870
765
_m4storage[0 ] += tx * r1;
@@ -894,6 +789,20 @@ class Matrix4 {
894
789
_m4storage[15 ] = tw * r4;
895
790
}
896
791
792
+ /// Multiply this by a translation from the left.
793
+ @pragma ('wasm:prefer-inline' )
794
+ @pragma ('vm:prefer-inline' )
795
+ @pragma ('dart2js:prefer-inline' )
796
+ void leftTranslateByVector3 (Vector3 v3) =>
797
+ leftTranslateByDouble (v3.x, v3.y, v3.z, 1.0 );
798
+
799
+ /// Multiply this by a translation from the left.
800
+ @pragma ('wasm:prefer-inline' )
801
+ @pragma ('vm:prefer-inline' )
802
+ @pragma ('dart2js:prefer-inline' )
803
+ void leftTranslateByVector4 (Vector4 v4) =>
804
+ leftTranslateByDouble (v4.x, v4.y, v4.z, v4.w);
805
+
897
806
/// Rotate this [angle] radians around [axis]
898
807
void rotate (Vector3 axis, double angle) {
899
808
final len = axis.length;
0 commit comments