@math.gl/core 4.0.0 → 4.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/dist/classes/base/math-array.d.ts +1 -2
  2. package/dist/classes/base/math-array.js +220 -266
  3. package/dist/classes/base/matrix.d.ts +1 -2
  4. package/dist/classes/base/matrix.js +52 -53
  5. package/dist/classes/base/vector.d.ts +1 -2
  6. package/dist/classes/base/vector.js +121 -135
  7. package/dist/classes/euler.d.ts +2 -3
  8. package/dist/classes/euler.js +462 -533
  9. package/dist/classes/matrix3.d.ts +2 -3
  10. package/dist/classes/matrix3.js +185 -190
  11. package/dist/classes/matrix4.d.ts +1 -2
  12. package/dist/classes/matrix4.js +516 -452
  13. package/dist/classes/pose.d.ts +4 -5
  14. package/dist/classes/pose.js +104 -119
  15. package/dist/classes/quaternion.d.ts +1 -2
  16. package/dist/classes/quaternion.js +257 -233
  17. package/dist/classes/spherical-coordinates.d.ts +3 -4
  18. package/dist/classes/spherical-coordinates.js +138 -147
  19. package/dist/classes/vector2.d.ts +1 -2
  20. package/dist/classes/vector2.js +101 -85
  21. package/dist/classes/vector3.d.ts +1 -2
  22. package/dist/classes/vector3.js +125 -136
  23. package/dist/classes/vector4.d.ts +2 -3
  24. package/dist/classes/vector4.js +106 -114
  25. package/dist/gl-matrix/common.d.ts +0 -1
  26. package/dist/gl-matrix/common.js +38 -6
  27. package/dist/gl-matrix/mat3.d.ts +0 -1
  28. package/dist/gl-matrix/mat3.js +699 -425
  29. package/dist/gl-matrix/mat4.d.ts +0 -1
  30. package/dist/gl-matrix/mat4.js +1879 -1339
  31. package/dist/gl-matrix/quat.d.ts +0 -1
  32. package/dist/gl-matrix/quat.js +655 -257
  33. package/dist/gl-matrix/vec2.d.ts +0 -1
  34. package/dist/gl-matrix/vec2.js +529 -212
  35. package/dist/gl-matrix/vec3.d.ts +0 -1
  36. package/dist/gl-matrix/vec3.js +703 -335
  37. package/dist/gl-matrix/vec4.d.ts +0 -1
  38. package/dist/gl-matrix/vec4.js +579 -293
  39. package/dist/gl-matrix/wip/index.d.ts +3 -4
  40. package/dist/gl-matrix/wip/index.js +2 -1
  41. package/dist/gl-matrix/wip/mat2.d.ts +0 -1
  42. package/dist/gl-matrix/wip/mat2.js +333 -157
  43. package/dist/gl-matrix/wip/mat2d.d.ts +0 -1
  44. package/dist/gl-matrix/wip/mat2d.js +377 -202
  45. package/dist/gl-matrix/wip/quat2.d.ts +0 -1
  46. package/dist/gl-matrix/wip/quat2.js +647 -409
  47. package/dist/index.cjs +60 -100
  48. package/dist/index.cjs.map +7 -0
  49. package/dist/index.d.ts +21 -22
  50. package/dist/index.js +23 -16
  51. package/dist/lib/assert.d.ts +0 -1
  52. package/dist/lib/assert.js +3 -4
  53. package/dist/lib/common.d.ts +2 -3
  54. package/dist/lib/common.js +163 -134
  55. package/dist/lib/gl-matrix-extras.d.ts +0 -1
  56. package/dist/lib/gl-matrix-extras.js +39 -36
  57. package/dist/lib/math-utils.d.ts +0 -1
  58. package/dist/lib/math-utils.js +2 -1
  59. package/dist/lib/validators.d.ts +0 -1
  60. package/dist/lib/validators.js +22 -25
  61. package/package.json +5 -6
  62. package/src/classes/matrix3.ts +1 -1
  63. package/dist/classes/base/math-array.d.ts.map +0 -1
  64. package/dist/classes/base/math-array.js.map +0 -1
  65. package/dist/classes/base/matrix.d.ts.map +0 -1
  66. package/dist/classes/base/matrix.js.map +0 -1
  67. package/dist/classes/base/vector.d.ts.map +0 -1
  68. package/dist/classes/base/vector.js.map +0 -1
  69. package/dist/classes/euler.d.ts.map +0 -1
  70. package/dist/classes/euler.js.map +0 -1
  71. package/dist/classes/matrix3.d.ts.map +0 -1
  72. package/dist/classes/matrix3.js.map +0 -1
  73. package/dist/classes/matrix4.d.ts.map +0 -1
  74. package/dist/classes/matrix4.js.map +0 -1
  75. package/dist/classes/pose.d.ts.map +0 -1
  76. package/dist/classes/pose.js.map +0 -1
  77. package/dist/classes/quaternion.d.ts.map +0 -1
  78. package/dist/classes/quaternion.js.map +0 -1
  79. package/dist/classes/spherical-coordinates.d.ts.map +0 -1
  80. package/dist/classes/spherical-coordinates.js.map +0 -1
  81. package/dist/classes/vector2.d.ts.map +0 -1
  82. package/dist/classes/vector2.js.map +0 -1
  83. package/dist/classes/vector3.d.ts.map +0 -1
  84. package/dist/classes/vector3.js.map +0 -1
  85. package/dist/classes/vector4.d.ts.map +0 -1
  86. package/dist/classes/vector4.js.map +0 -1
  87. package/dist/gl-matrix/common.d.ts.map +0 -1
  88. package/dist/gl-matrix/common.js.map +0 -1
  89. package/dist/gl-matrix/mat3.d.ts.map +0 -1
  90. package/dist/gl-matrix/mat3.js.map +0 -1
  91. package/dist/gl-matrix/mat4.d.ts.map +0 -1
  92. package/dist/gl-matrix/mat4.js.map +0 -1
  93. package/dist/gl-matrix/quat.d.ts.map +0 -1
  94. package/dist/gl-matrix/quat.js.map +0 -1
  95. package/dist/gl-matrix/vec2.d.ts.map +0 -1
  96. package/dist/gl-matrix/vec2.js.map +0 -1
  97. package/dist/gl-matrix/vec3.d.ts.map +0 -1
  98. package/dist/gl-matrix/vec3.js.map +0 -1
  99. package/dist/gl-matrix/vec4.d.ts.map +0 -1
  100. package/dist/gl-matrix/vec4.js.map +0 -1
  101. package/dist/gl-matrix/wip/index.d.ts.map +0 -1
  102. package/dist/gl-matrix/wip/index.js.map +0 -1
  103. package/dist/gl-matrix/wip/mat2.d.ts.map +0 -1
  104. package/dist/gl-matrix/wip/mat2.js.map +0 -1
  105. package/dist/gl-matrix/wip/mat2d.d.ts.map +0 -1
  106. package/dist/gl-matrix/wip/mat2d.js.map +0 -1
  107. package/dist/gl-matrix/wip/quat2.d.ts.map +0 -1
  108. package/dist/gl-matrix/wip/quat2.js.map +0 -1
  109. package/dist/gl-matrix/wip/types.d.js +0 -2
  110. package/dist/gl-matrix/wip/types.d.js.map +0 -1
  111. package/dist/index.d.ts.map +0 -1
  112. package/dist/index.js.map +0 -1
  113. package/dist/lib/assert.d.ts.map +0 -1
  114. package/dist/lib/assert.js.map +0 -1
  115. package/dist/lib/common.d.ts.map +0 -1
  116. package/dist/lib/common.js.map +0 -1
  117. package/dist/lib/gl-matrix-extras.d.ts.map +0 -1
  118. package/dist/lib/gl-matrix-extras.js.map +0 -1
  119. package/dist/lib/gl-matrix.d.js +0 -2
  120. package/dist/lib/gl-matrix.d.js.map +0 -1
  121. package/dist/lib/math-utils.d.ts.map +0 -1
  122. package/dist/lib/math-utils.js.map +0 -1
  123. package/dist/lib/validators.d.ts.map +0 -1
  124. package/dist/lib/validators.js.map +0 -1
@@ -1,489 +1,763 @@
1
1
  import * as glMatrix from './common.js';
2
+ /**
3
+ * 3x3 Matrix
4
+ * @module mat3
5
+ */
6
+ /**
7
+ * Creates a new identity mat3
8
+ *
9
+ * @returns {mat3} a new 3x3 matrix
10
+ */
2
11
  export function create() {
3
- const out = new glMatrix.ARRAY_TYPE(9);
4
-
5
- if (glMatrix.ARRAY_TYPE != Float32Array) {
6
- out[1] = 0;
7
- out[2] = 0;
8
- out[3] = 0;
9
- out[5] = 0;
10
- out[6] = 0;
11
- out[7] = 0;
12
- }
13
-
14
- out[0] = 1;
15
- out[4] = 1;
16
- out[8] = 1;
17
- return out;
12
+ const out = new glMatrix.ARRAY_TYPE(9);
13
+ if (glMatrix.ARRAY_TYPE != Float32Array) {
14
+ out[1] = 0;
15
+ out[2] = 0;
16
+ out[3] = 0;
17
+ out[5] = 0;
18
+ out[6] = 0;
19
+ out[7] = 0;
20
+ }
21
+ out[0] = 1;
22
+ out[4] = 1;
23
+ out[8] = 1;
24
+ return out;
18
25
  }
26
+ /**
27
+ * Copies the upper-left 3x3 values into the given mat3.
28
+ *
29
+ * @param {mat3} out the receiving 3x3 matrix
30
+ * @param {ReadonlyMat4} a the source 4x4 matrix
31
+ * @returns {mat3} out
32
+ */
19
33
  export function fromMat4(out, a) {
20
- out[0] = a[0];
21
- out[1] = a[1];
22
- out[2] = a[2];
23
- out[3] = a[4];
24
- out[4] = a[5];
25
- out[5] = a[6];
26
- out[6] = a[8];
27
- out[7] = a[9];
28
- out[8] = a[10];
29
- return out;
34
+ out[0] = a[0];
35
+ out[1] = a[1];
36
+ out[2] = a[2];
37
+ out[3] = a[4];
38
+ out[4] = a[5];
39
+ out[5] = a[6];
40
+ out[6] = a[8];
41
+ out[7] = a[9];
42
+ out[8] = a[10];
43
+ return out;
30
44
  }
45
+ /**
46
+ * Creates a new mat3 initialized with values from an existing matrix
47
+ *
48
+ * @param {ReadonlyMat3} a matrix to clone
49
+ * @returns {mat3} a new 3x3 matrix
50
+ */
31
51
  export function clone(a) {
32
- const out = new glMatrix.ARRAY_TYPE(9);
33
- out[0] = a[0];
34
- out[1] = a[1];
35
- out[2] = a[2];
36
- out[3] = a[3];
37
- out[4] = a[4];
38
- out[5] = a[5];
39
- out[6] = a[6];
40
- out[7] = a[7];
41
- out[8] = a[8];
42
- return out;
52
+ const out = new glMatrix.ARRAY_TYPE(9);
53
+ out[0] = a[0];
54
+ out[1] = a[1];
55
+ out[2] = a[2];
56
+ out[3] = a[3];
57
+ out[4] = a[4];
58
+ out[5] = a[5];
59
+ out[6] = a[6];
60
+ out[7] = a[7];
61
+ out[8] = a[8];
62
+ return out;
43
63
  }
64
+ /**
65
+ * Copy the values from one mat3 to another
66
+ *
67
+ * @param {mat3} out the receiving matrix
68
+ * @param {ReadonlyMat3} a the source matrix
69
+ * @returns {mat3} out
70
+ */
44
71
  export function copy(out, a) {
45
- out[0] = a[0];
46
- out[1] = a[1];
47
- out[2] = a[2];
48
- out[3] = a[3];
49
- out[4] = a[4];
50
- out[5] = a[5];
51
- out[6] = a[6];
52
- out[7] = a[7];
53
- out[8] = a[8];
54
- return out;
72
+ out[0] = a[0];
73
+ out[1] = a[1];
74
+ out[2] = a[2];
75
+ out[3] = a[3];
76
+ out[4] = a[4];
77
+ out[5] = a[5];
78
+ out[6] = a[6];
79
+ out[7] = a[7];
80
+ out[8] = a[8];
81
+ return out;
55
82
  }
83
+ /**
84
+ * Create a new mat3 with the given values
85
+ *
86
+ * @param {Number} m00 Component in column 0, row 0 position (index 0)
87
+ * @param {Number} m01 Component in column 0, row 1 position (index 1)
88
+ * @param {Number} m02 Component in column 0, row 2 position (index 2)
89
+ * @param {Number} m10 Component in column 1, row 0 position (index 3)
90
+ * @param {Number} m11 Component in column 1, row 1 position (index 4)
91
+ * @param {Number} m12 Component in column 1, row 2 position (index 5)
92
+ * @param {Number} m20 Component in column 2, row 0 position (index 6)
93
+ * @param {Number} m21 Component in column 2, row 1 position (index 7)
94
+ * @param {Number} m22 Component in column 2, row 2 position (index 8)
95
+ * @returns {mat3} A new mat3
96
+ */
56
97
  export function fromValues(m00, m01, m02, m10, m11, m12, m20, m21, m22) {
57
- const out = new glMatrix.ARRAY_TYPE(9);
58
- out[0] = m00;
59
- out[1] = m01;
60
- out[2] = m02;
61
- out[3] = m10;
62
- out[4] = m11;
63
- out[5] = m12;
64
- out[6] = m20;
65
- out[7] = m21;
66
- out[8] = m22;
67
- return out;
98
+ const out = new glMatrix.ARRAY_TYPE(9);
99
+ out[0] = m00;
100
+ out[1] = m01;
101
+ out[2] = m02;
102
+ out[3] = m10;
103
+ out[4] = m11;
104
+ out[5] = m12;
105
+ out[6] = m20;
106
+ out[7] = m21;
107
+ out[8] = m22;
108
+ return out;
68
109
  }
110
+ /**
111
+ * Set the components of a mat3 to the given values
112
+ *
113
+ * @param {mat3} out the receiving matrix
114
+ * @param {Number} m00 Component in column 0, row 0 position (index 0)
115
+ * @param {Number} m01 Component in column 0, row 1 position (index 1)
116
+ * @param {Number} m02 Component in column 0, row 2 position (index 2)
117
+ * @param {Number} m10 Component in column 1, row 0 position (index 3)
118
+ * @param {Number} m11 Component in column 1, row 1 position (index 4)
119
+ * @param {Number} m12 Component in column 1, row 2 position (index 5)
120
+ * @param {Number} m20 Component in column 2, row 0 position (index 6)
121
+ * @param {Number} m21 Component in column 2, row 1 position (index 7)
122
+ * @param {Number} m22 Component in column 2, row 2 position (index 8)
123
+ * @returns {mat3} out
124
+ */
69
125
  export function set(out, m00, m01, m02, m10, m11, m12, m20, m21, m22) {
70
- out[0] = m00;
71
- out[1] = m01;
72
- out[2] = m02;
73
- out[3] = m10;
74
- out[4] = m11;
75
- out[5] = m12;
76
- out[6] = m20;
77
- out[7] = m21;
78
- out[8] = m22;
79
- return out;
126
+ out[0] = m00;
127
+ out[1] = m01;
128
+ out[2] = m02;
129
+ out[3] = m10;
130
+ out[4] = m11;
131
+ out[5] = m12;
132
+ out[6] = m20;
133
+ out[7] = m21;
134
+ out[8] = m22;
135
+ return out;
80
136
  }
137
+ /**
138
+ * Set a mat3 to the identity matrix
139
+ *
140
+ * @param {mat3} out the receiving matrix
141
+ * @returns {mat3} out
142
+ */
81
143
  export function identity(out) {
82
- out[0] = 1;
83
- out[1] = 0;
84
- out[2] = 0;
85
- out[3] = 0;
86
- out[4] = 1;
87
- out[5] = 0;
88
- out[6] = 0;
89
- out[7] = 0;
90
- out[8] = 1;
91
- return out;
144
+ out[0] = 1;
145
+ out[1] = 0;
146
+ out[2] = 0;
147
+ out[3] = 0;
148
+ out[4] = 1;
149
+ out[5] = 0;
150
+ out[6] = 0;
151
+ out[7] = 0;
152
+ out[8] = 1;
153
+ return out;
92
154
  }
155
+ /**
156
+ * Transpose the values of a mat3
157
+ *
158
+ * @param {mat3} out the receiving matrix
159
+ * @param {ReadonlyMat3} a the source matrix
160
+ * @returns {mat3} out
161
+ */
93
162
  export function transpose(out, a) {
94
- if (out === a) {
163
+ // If we are transposing ourselves we can skip a few steps but have to cache some values
164
+ if (out === a) {
165
+ const a01 = a[1];
166
+ const a02 = a[2];
167
+ const a12 = a[5];
168
+ out[1] = a[3];
169
+ out[2] = a[6];
170
+ out[3] = a01;
171
+ out[5] = a[7];
172
+ out[6] = a02;
173
+ out[7] = a12;
174
+ }
175
+ else {
176
+ out[0] = a[0];
177
+ out[1] = a[3];
178
+ out[2] = a[6];
179
+ out[3] = a[1];
180
+ out[4] = a[4];
181
+ out[5] = a[7];
182
+ out[6] = a[2];
183
+ out[7] = a[5];
184
+ out[8] = a[8];
185
+ }
186
+ return out;
187
+ }
188
+ /**
189
+ * Inverts a mat3
190
+ *
191
+ * @param {mat3} out the receiving matrix
192
+ * @param {ReadonlyMat3} a the source matrix
193
+ * @returns {mat3} out
194
+ */
195
+ export function invert(out, a) {
196
+ const a00 = a[0];
95
197
  const a01 = a[1];
96
198
  const a02 = a[2];
199
+ const a10 = a[3];
200
+ const a11 = a[4];
97
201
  const a12 = a[5];
98
- out[1] = a[3];
99
- out[2] = a[6];
100
- out[3] = a01;
101
- out[5] = a[7];
102
- out[6] = a02;
103
- out[7] = a12;
104
- } else {
105
- out[0] = a[0];
106
- out[1] = a[3];
107
- out[2] = a[6];
108
- out[3] = a[1];
109
- out[4] = a[4];
110
- out[5] = a[7];
111
- out[6] = a[2];
112
- out[7] = a[5];
113
- out[8] = a[8];
114
- }
115
-
116
- return out;
117
- }
118
- export function invert(out, a) {
119
- const a00 = a[0];
120
- const a01 = a[1];
121
- const a02 = a[2];
122
- const a10 = a[3];
123
- const a11 = a[4];
124
- const a12 = a[5];
125
- const a20 = a[6];
126
- const a21 = a[7];
127
- const a22 = a[8];
128
- const b01 = a22 * a11 - a12 * a21;
129
- const b11 = -a22 * a10 + a12 * a20;
130
- const b21 = a21 * a10 - a11 * a20;
131
- let det = a00 * b01 + a01 * b11 + a02 * b21;
132
-
133
- if (!det) {
134
- return null;
135
- }
136
-
137
- det = 1.0 / det;
138
- out[0] = b01 * det;
139
- out[1] = (-a22 * a01 + a02 * a21) * det;
140
- out[2] = (a12 * a01 - a02 * a11) * det;
141
- out[3] = b11 * det;
142
- out[4] = (a22 * a00 - a02 * a20) * det;
143
- out[5] = (-a12 * a00 + a02 * a10) * det;
144
- out[6] = b21 * det;
145
- out[7] = (-a21 * a00 + a01 * a20) * det;
146
- out[8] = (a11 * a00 - a01 * a10) * det;
147
- return out;
202
+ const a20 = a[6];
203
+ const a21 = a[7];
204
+ const a22 = a[8];
205
+ const b01 = a22 * a11 - a12 * a21;
206
+ const b11 = -a22 * a10 + a12 * a20;
207
+ const b21 = a21 * a10 - a11 * a20;
208
+ // Calculate the determinant
209
+ let det = a00 * b01 + a01 * b11 + a02 * b21;
210
+ if (!det) {
211
+ return null;
212
+ }
213
+ det = 1.0 / det;
214
+ out[0] = b01 * det;
215
+ out[1] = (-a22 * a01 + a02 * a21) * det;
216
+ out[2] = (a12 * a01 - a02 * a11) * det;
217
+ out[3] = b11 * det;
218
+ out[4] = (a22 * a00 - a02 * a20) * det;
219
+ out[5] = (-a12 * a00 + a02 * a10) * det;
220
+ out[6] = b21 * det;
221
+ out[7] = (-a21 * a00 + a01 * a20) * det;
222
+ out[8] = (a11 * a00 - a01 * a10) * det;
223
+ return out;
148
224
  }
225
+ /**
226
+ * Calculates the adjugate of a mat3
227
+ *
228
+ * @param {mat3} out the receiving matrix
229
+ * @param {ReadonlyMat3} a the source matrix
230
+ * @returns {mat3} out
231
+ */
149
232
  export function adjoint(out, a) {
150
- const a00 = a[0];
151
- const a01 = a[1];
152
- const a02 = a[2];
153
- const a10 = a[3];
154
- const a11 = a[4];
155
- const a12 = a[5];
156
- const a20 = a[6];
157
- const a21 = a[7];
158
- const a22 = a[8];
159
- out[0] = a11 * a22 - a12 * a21;
160
- out[1] = a02 * a21 - a01 * a22;
161
- out[2] = a01 * a12 - a02 * a11;
162
- out[3] = a12 * a20 - a10 * a22;
163
- out[4] = a00 * a22 - a02 * a20;
164
- out[5] = a02 * a10 - a00 * a12;
165
- out[6] = a10 * a21 - a11 * a20;
166
- out[7] = a01 * a20 - a00 * a21;
167
- out[8] = a00 * a11 - a01 * a10;
168
- return out;
233
+ const a00 = a[0];
234
+ const a01 = a[1];
235
+ const a02 = a[2];
236
+ const a10 = a[3];
237
+ const a11 = a[4];
238
+ const a12 = a[5];
239
+ const a20 = a[6];
240
+ const a21 = a[7];
241
+ const a22 = a[8];
242
+ out[0] = a11 * a22 - a12 * a21;
243
+ out[1] = a02 * a21 - a01 * a22;
244
+ out[2] = a01 * a12 - a02 * a11;
245
+ out[3] = a12 * a20 - a10 * a22;
246
+ out[4] = a00 * a22 - a02 * a20;
247
+ out[5] = a02 * a10 - a00 * a12;
248
+ out[6] = a10 * a21 - a11 * a20;
249
+ out[7] = a01 * a20 - a00 * a21;
250
+ out[8] = a00 * a11 - a01 * a10;
251
+ return out;
169
252
  }
253
+ /**
254
+ * Calculates the determinant of a mat3
255
+ *
256
+ * @param {ReadonlyMat3} a the source matrix
257
+ * @returns {Number} determinant of a
258
+ */
170
259
  export function determinant(a) {
171
- const a00 = a[0];
172
- const a01 = a[1];
173
- const a02 = a[2];
174
- const a10 = a[3];
175
- const a11 = a[4];
176
- const a12 = a[5];
177
- const a20 = a[6];
178
- const a21 = a[7];
179
- const a22 = a[8];
180
- return a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20);
260
+ const a00 = a[0];
261
+ const a01 = a[1];
262
+ const a02 = a[2];
263
+ const a10 = a[3];
264
+ const a11 = a[4];
265
+ const a12 = a[5];
266
+ const a20 = a[6];
267
+ const a21 = a[7];
268
+ const a22 = a[8];
269
+ return (a00 * (a22 * a11 - a12 * a21) + a01 * (-a22 * a10 + a12 * a20) + a02 * (a21 * a10 - a11 * a20));
181
270
  }
271
+ /**
272
+ * Multiplies two mat3's
273
+ *
274
+ * @param {mat3} out the receiving matrix
275
+ * @param {ReadonlyMat3} a the first operand
276
+ * @param {ReadonlyMat3} b the second operand
277
+ * @returns {mat3} out
278
+ */
182
279
  export function multiply(out, a, b) {
183
- const a00 = a[0];
184
- const a01 = a[1];
185
- const a02 = a[2];
186
- const a10 = a[3];
187
- const a11 = a[4];
188
- const a12 = a[5];
189
- const a20 = a[6];
190
- const a21 = a[7];
191
- const a22 = a[8];
192
- const b00 = b[0];
193
- const b01 = b[1];
194
- const b02 = b[2];
195
- const b10 = b[3];
196
- const b11 = b[4];
197
- const b12 = b[5];
198
- const b20 = b[6];
199
- const b21 = b[7];
200
- const b22 = b[8];
201
- out[0] = b00 * a00 + b01 * a10 + b02 * a20;
202
- out[1] = b00 * a01 + b01 * a11 + b02 * a21;
203
- out[2] = b00 * a02 + b01 * a12 + b02 * a22;
204
- out[3] = b10 * a00 + b11 * a10 + b12 * a20;
205
- out[4] = b10 * a01 + b11 * a11 + b12 * a21;
206
- out[5] = b10 * a02 + b11 * a12 + b12 * a22;
207
- out[6] = b20 * a00 + b21 * a10 + b22 * a20;
208
- out[7] = b20 * a01 + b21 * a11 + b22 * a21;
209
- out[8] = b20 * a02 + b21 * a12 + b22 * a22;
210
- return out;
280
+ const a00 = a[0];
281
+ const a01 = a[1];
282
+ const a02 = a[2];
283
+ const a10 = a[3];
284
+ const a11 = a[4];
285
+ const a12 = a[5];
286
+ const a20 = a[6];
287
+ const a21 = a[7];
288
+ const a22 = a[8];
289
+ const b00 = b[0];
290
+ const b01 = b[1];
291
+ const b02 = b[2];
292
+ const b10 = b[3];
293
+ const b11 = b[4];
294
+ const b12 = b[5];
295
+ const b20 = b[6];
296
+ const b21 = b[7];
297
+ const b22 = b[8];
298
+ out[0] = b00 * a00 + b01 * a10 + b02 * a20;
299
+ out[1] = b00 * a01 + b01 * a11 + b02 * a21;
300
+ out[2] = b00 * a02 + b01 * a12 + b02 * a22;
301
+ out[3] = b10 * a00 + b11 * a10 + b12 * a20;
302
+ out[4] = b10 * a01 + b11 * a11 + b12 * a21;
303
+ out[5] = b10 * a02 + b11 * a12 + b12 * a22;
304
+ out[6] = b20 * a00 + b21 * a10 + b22 * a20;
305
+ out[7] = b20 * a01 + b21 * a11 + b22 * a21;
306
+ out[8] = b20 * a02 + b21 * a12 + b22 * a22;
307
+ return out;
211
308
  }
309
+ /**
310
+ * Translate a mat3 by the given vector
311
+ *
312
+ * @param {mat3} out the receiving matrix
313
+ * @param {ReadonlyMat3} a the matrix to translate
314
+ * @param {ReadonlyVec2} v vector to translate by
315
+ * @returns {mat3} out
316
+ */
212
317
  export function translate(out, a, v) {
213
- const a00 = a[0];
214
- const a01 = a[1];
215
- const a02 = a[2];
216
- const a10 = a[3];
217
- const a11 = a[4];
218
- const a12 = a[5];
219
- const a20 = a[6];
220
- const a21 = a[7];
221
- const a22 = a[8];
222
- const x = v[0];
223
- const y = v[1];
224
- out[0] = a00;
225
- out[1] = a01;
226
- out[2] = a02;
227
- out[3] = a10;
228
- out[4] = a11;
229
- out[5] = a12;
230
- out[6] = x * a00 + y * a10 + a20;
231
- out[7] = x * a01 + y * a11 + a21;
232
- out[8] = x * a02 + y * a12 + a22;
233
- return out;
318
+ const a00 = a[0];
319
+ const a01 = a[1];
320
+ const a02 = a[2];
321
+ const a10 = a[3];
322
+ const a11 = a[4];
323
+ const a12 = a[5];
324
+ const a20 = a[6];
325
+ const a21 = a[7];
326
+ const a22 = a[8];
327
+ const x = v[0];
328
+ const y = v[1];
329
+ out[0] = a00;
330
+ out[1] = a01;
331
+ out[2] = a02;
332
+ out[3] = a10;
333
+ out[4] = a11;
334
+ out[5] = a12;
335
+ out[6] = x * a00 + y * a10 + a20;
336
+ out[7] = x * a01 + y * a11 + a21;
337
+ out[8] = x * a02 + y * a12 + a22;
338
+ return out;
234
339
  }
340
+ /**
341
+ * Rotates a mat3 by the given angle
342
+ *
343
+ * @param {mat3} out the receiving matrix
344
+ * @param {ReadonlyMat3} a the matrix to rotate
345
+ * @param {Number} rad the angle to rotate the matrix by
346
+ * @returns {mat3} out
347
+ */
235
348
  export function rotate(out, a, rad) {
236
- const a00 = a[0];
237
- const a01 = a[1];
238
- const a02 = a[2];
239
- const a10 = a[3];
240
- const a11 = a[4];
241
- const a12 = a[5];
242
- const a20 = a[6];
243
- const a21 = a[7];
244
- const a22 = a[8];
245
- const s = Math.sin(rad);
246
- const c = Math.cos(rad);
247
- out[0] = c * a00 + s * a10;
248
- out[1] = c * a01 + s * a11;
249
- out[2] = c * a02 + s * a12;
250
- out[3] = c * a10 - s * a00;
251
- out[4] = c * a11 - s * a01;
252
- out[5] = c * a12 - s * a02;
253
- out[6] = a20;
254
- out[7] = a21;
255
- out[8] = a22;
256
- return out;
349
+ const a00 = a[0];
350
+ const a01 = a[1];
351
+ const a02 = a[2];
352
+ const a10 = a[3];
353
+ const a11 = a[4];
354
+ const a12 = a[5];
355
+ const a20 = a[6];
356
+ const a21 = a[7];
357
+ const a22 = a[8];
358
+ const s = Math.sin(rad);
359
+ const c = Math.cos(rad);
360
+ out[0] = c * a00 + s * a10;
361
+ out[1] = c * a01 + s * a11;
362
+ out[2] = c * a02 + s * a12;
363
+ out[3] = c * a10 - s * a00;
364
+ out[4] = c * a11 - s * a01;
365
+ out[5] = c * a12 - s * a02;
366
+ out[6] = a20;
367
+ out[7] = a21;
368
+ out[8] = a22;
369
+ return out;
257
370
  }
371
+ /**
372
+ * Scales the mat3 by the dimensions in the given vec2
373
+ *
374
+ * @param {mat3} out the receiving matrix
375
+ * @param {ReadonlyMat3} a the matrix to scale
376
+ * @param {ReadonlyVec2} v the vec2 to scale the matrix by
377
+ * @returns {mat3} out
378
+ **/
258
379
  export function scale(out, a, v) {
259
- const x = v[0];
260
- const y = v[1];
261
- out[0] = x * a[0];
262
- out[1] = x * a[1];
263
- out[2] = x * a[2];
264
- out[3] = y * a[3];
265
- out[4] = y * a[4];
266
- out[5] = y * a[5];
267
- out[6] = a[6];
268
- out[7] = a[7];
269
- out[8] = a[8];
270
- return out;
380
+ const x = v[0];
381
+ const y = v[1];
382
+ out[0] = x * a[0];
383
+ out[1] = x * a[1];
384
+ out[2] = x * a[2];
385
+ out[3] = y * a[3];
386
+ out[4] = y * a[4];
387
+ out[5] = y * a[5];
388
+ out[6] = a[6];
389
+ out[7] = a[7];
390
+ out[8] = a[8];
391
+ return out;
271
392
  }
393
+ /**
394
+ * Creates a matrix from a vector translation
395
+ * This is equivalent to (but much faster than):
396
+ *
397
+ * mat3.identity(dest);
398
+ * mat3.translate(dest, dest, vec);
399
+ *
400
+ * @param {mat3} out mat3 receiving operation result
401
+ * @param {ReadonlyVec2} v Translation vector
402
+ * @returns {mat3} out
403
+ */
272
404
  export function fromTranslation(out, v) {
273
- out[0] = 1;
274
- out[1] = 0;
275
- out[2] = 0;
276
- out[3] = 0;
277
- out[4] = 1;
278
- out[5] = 0;
279
- out[6] = v[0];
280
- out[7] = v[1];
281
- out[8] = 1;
282
- return out;
405
+ out[0] = 1;
406
+ out[1] = 0;
407
+ out[2] = 0;
408
+ out[3] = 0;
409
+ out[4] = 1;
410
+ out[5] = 0;
411
+ out[6] = v[0];
412
+ out[7] = v[1];
413
+ out[8] = 1;
414
+ return out;
283
415
  }
416
+ /**
417
+ * Creates a matrix from a given angle
418
+ * This is equivalent to (but much faster than):
419
+ *
420
+ * mat3.identity(dest);
421
+ * mat3.rotate(dest, dest, rad);
422
+ *
423
+ * @param {mat3} out mat3 receiving operation result
424
+ * @param {Number} rad the angle to rotate the matrix by
425
+ * @returns {mat3} out
426
+ */
284
427
  export function fromRotation(out, rad) {
285
- const s = Math.sin(rad);
286
- const c = Math.cos(rad);
287
- out[0] = c;
288
- out[1] = s;
289
- out[2] = 0;
290
- out[3] = -s;
291
- out[4] = c;
292
- out[5] = 0;
293
- out[6] = 0;
294
- out[7] = 0;
295
- out[8] = 1;
296
- return out;
428
+ const s = Math.sin(rad);
429
+ const c = Math.cos(rad);
430
+ out[0] = c;
431
+ out[1] = s;
432
+ out[2] = 0;
433
+ out[3] = -s;
434
+ out[4] = c;
435
+ out[5] = 0;
436
+ out[6] = 0;
437
+ out[7] = 0;
438
+ out[8] = 1;
439
+ return out;
297
440
  }
441
+ /**
442
+ * Creates a matrix from a vector scaling
443
+ * This is equivalent to (but much faster than):
444
+ *
445
+ * mat3.identity(dest);
446
+ * mat3.scale(dest, dest, vec);
447
+ *
448
+ * @param {mat3} out mat3 receiving operation result
449
+ * @param {ReadonlyVec2} v Scaling vector
450
+ * @returns {mat3} out
451
+ */
298
452
  export function fromScaling(out, v) {
299
- out[0] = v[0];
300
- out[1] = 0;
301
- out[2] = 0;
302
- out[3] = 0;
303
- out[4] = v[1];
304
- out[5] = 0;
305
- out[6] = 0;
306
- out[7] = 0;
307
- out[8] = 1;
308
- return out;
453
+ out[0] = v[0];
454
+ out[1] = 0;
455
+ out[2] = 0;
456
+ out[3] = 0;
457
+ out[4] = v[1];
458
+ out[5] = 0;
459
+ out[6] = 0;
460
+ out[7] = 0;
461
+ out[8] = 1;
462
+ return out;
309
463
  }
464
+ /**
465
+ * Copies the values from a mat2d into a mat3
466
+ *
467
+ * @param {mat3} out the receiving matrix
468
+ * @param {ReadonlyMat2d} a the matrix to copy
469
+ * @returns {mat3} out
470
+ **/
310
471
  export function fromMat2d(out, a) {
311
- out[0] = a[0];
312
- out[1] = a[1];
313
- out[2] = 0;
314
- out[3] = a[2];
315
- out[4] = a[3];
316
- out[5] = 0;
317
- out[6] = a[4];
318
- out[7] = a[5];
319
- out[8] = 1;
320
- return out;
472
+ out[0] = a[0];
473
+ out[1] = a[1];
474
+ out[2] = 0;
475
+ out[3] = a[2];
476
+ out[4] = a[3];
477
+ out[5] = 0;
478
+ out[6] = a[4];
479
+ out[7] = a[5];
480
+ out[8] = 1;
481
+ return out;
321
482
  }
483
+ /**
484
+ * Calculates a 3x3 matrix from the given quaternion
485
+ *
486
+ * @param {mat3} out mat3 receiving operation result
487
+ * @param {ReadonlyQuat} q Quaternion to create matrix from
488
+ *
489
+ * @returns {mat3} out
490
+ */
322
491
  export function fromQuat(out, q) {
323
- const x = q[0];
324
- const y = q[1];
325
- const z = q[2];
326
- const w = q[3];
327
- const x2 = x + x;
328
- const y2 = y + y;
329
- const z2 = z + z;
330
- const xx = x * x2;
331
- const yx = y * x2;
332
- const yy = y * y2;
333
- const zx = z * x2;
334
- const zy = z * y2;
335
- const zz = z * z2;
336
- const wx = w * x2;
337
- const wy = w * y2;
338
- const wz = w * z2;
339
- out[0] = 1 - yy - zz;
340
- out[3] = yx - wz;
341
- out[6] = zx + wy;
342
- out[1] = yx + wz;
343
- out[4] = 1 - xx - zz;
344
- out[7] = zy - wx;
345
- out[2] = zx - wy;
346
- out[5] = zy + wx;
347
- out[8] = 1 - xx - yy;
348
- return out;
492
+ const x = q[0];
493
+ const y = q[1];
494
+ const z = q[2];
495
+ const w = q[3];
496
+ const x2 = x + x;
497
+ const y2 = y + y;
498
+ const z2 = z + z;
499
+ const xx = x * x2;
500
+ const yx = y * x2;
501
+ const yy = y * y2;
502
+ const zx = z * x2;
503
+ const zy = z * y2;
504
+ const zz = z * z2;
505
+ const wx = w * x2;
506
+ const wy = w * y2;
507
+ const wz = w * z2;
508
+ out[0] = 1 - yy - zz;
509
+ out[3] = yx - wz;
510
+ out[6] = zx + wy;
511
+ out[1] = yx + wz;
512
+ out[4] = 1 - xx - zz;
513
+ out[7] = zy - wx;
514
+ out[2] = zx - wy;
515
+ out[5] = zy + wx;
516
+ out[8] = 1 - xx - yy;
517
+ return out;
349
518
  }
519
+ /**
520
+ * Calculates a 3x3 normal matrix (transpose inverse) from the 4x4 matrix
521
+ *
522
+ * @param {mat3} out mat3 receiving operation result
523
+ * @param {ReadonlyMat4} a Mat4 to derive the normal matrix from
524
+ *
525
+ * @returns {mat3} out
526
+ */
350
527
  export function normalFromMat4(out, a) {
351
- const a00 = a[0];
352
- const a01 = a[1];
353
- const a02 = a[2];
354
- const a03 = a[3];
355
- const a10 = a[4];
356
- const a11 = a[5];
357
- const a12 = a[6];
358
- const a13 = a[7];
359
- const a20 = a[8];
360
- const a21 = a[9];
361
- const a22 = a[10];
362
- const a23 = a[11];
363
- const a30 = a[12];
364
- const a31 = a[13];
365
- const a32 = a[14];
366
- const a33 = a[15];
367
- const b00 = a00 * a11 - a01 * a10;
368
- const b01 = a00 * a12 - a02 * a10;
369
- const b02 = a00 * a13 - a03 * a10;
370
- const b03 = a01 * a12 - a02 * a11;
371
- const b04 = a01 * a13 - a03 * a11;
372
- const b05 = a02 * a13 - a03 * a12;
373
- const b06 = a20 * a31 - a21 * a30;
374
- const b07 = a20 * a32 - a22 * a30;
375
- const b08 = a20 * a33 - a23 * a30;
376
- const b09 = a21 * a32 - a22 * a31;
377
- const b10 = a21 * a33 - a23 * a31;
378
- const b11 = a22 * a33 - a23 * a32;
379
- let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
380
-
381
- if (!det) {
382
- return null;
383
- }
384
-
385
- det = 1.0 / det;
386
- out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
387
- out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
388
- out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
389
- out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
390
- out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
391
- out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
392
- out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
393
- out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
394
- out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
395
- return out;
528
+ const a00 = a[0];
529
+ const a01 = a[1];
530
+ const a02 = a[2];
531
+ const a03 = a[3];
532
+ const a10 = a[4];
533
+ const a11 = a[5];
534
+ const a12 = a[6];
535
+ const a13 = a[7];
536
+ const a20 = a[8];
537
+ const a21 = a[9];
538
+ const a22 = a[10];
539
+ const a23 = a[11];
540
+ const a30 = a[12];
541
+ const a31 = a[13];
542
+ const a32 = a[14];
543
+ const a33 = a[15];
544
+ const b00 = a00 * a11 - a01 * a10;
545
+ const b01 = a00 * a12 - a02 * a10;
546
+ const b02 = a00 * a13 - a03 * a10;
547
+ const b03 = a01 * a12 - a02 * a11;
548
+ const b04 = a01 * a13 - a03 * a11;
549
+ const b05 = a02 * a13 - a03 * a12;
550
+ const b06 = a20 * a31 - a21 * a30;
551
+ const b07 = a20 * a32 - a22 * a30;
552
+ const b08 = a20 * a33 - a23 * a30;
553
+ const b09 = a21 * a32 - a22 * a31;
554
+ const b10 = a21 * a33 - a23 * a31;
555
+ const b11 = a22 * a33 - a23 * a32;
556
+ // Calculate the determinant
557
+ let det = b00 * b11 - b01 * b10 + b02 * b09 + b03 * b08 - b04 * b07 + b05 * b06;
558
+ if (!det) {
559
+ return null;
560
+ }
561
+ det = 1.0 / det;
562
+ out[0] = (a11 * b11 - a12 * b10 + a13 * b09) * det;
563
+ out[1] = (a12 * b08 - a10 * b11 - a13 * b07) * det;
564
+ out[2] = (a10 * b10 - a11 * b08 + a13 * b06) * det;
565
+ out[3] = (a02 * b10 - a01 * b11 - a03 * b09) * det;
566
+ out[4] = (a00 * b11 - a02 * b08 + a03 * b07) * det;
567
+ out[5] = (a01 * b08 - a00 * b10 - a03 * b06) * det;
568
+ out[6] = (a31 * b05 - a32 * b04 + a33 * b03) * det;
569
+ out[7] = (a32 * b02 - a30 * b05 - a33 * b01) * det;
570
+ out[8] = (a30 * b04 - a31 * b02 + a33 * b00) * det;
571
+ return out;
396
572
  }
573
+ /**
574
+ * Generates a 2D projection matrix with the given bounds
575
+ *
576
+ * @param {mat3} out mat3 frustum matrix will be written into
577
+ * @param {number} width Width of your gl context
578
+ * @param {number} height Height of gl context
579
+ * @returns {mat3} out
580
+ */
397
581
  export function projection(out, width, height) {
398
- out[0] = 2 / width;
399
- out[1] = 0;
400
- out[2] = 0;
401
- out[3] = 0;
402
- out[4] = -2 / height;
403
- out[5] = 0;
404
- out[6] = -1;
405
- out[7] = 1;
406
- out[8] = 1;
407
- return out;
582
+ out[0] = 2 / width;
583
+ out[1] = 0;
584
+ out[2] = 0;
585
+ out[3] = 0;
586
+ out[4] = -2 / height;
587
+ out[5] = 0;
588
+ out[6] = -1;
589
+ out[7] = 1;
590
+ out[8] = 1;
591
+ return out;
408
592
  }
593
+ /**
594
+ * Returns a string representation of a mat3
595
+ *
596
+ * @param {ReadonlyMat3} a matrix to represent as a string
597
+ * @returns {String} string representation of the matrix
598
+ */
409
599
  export function str(a) {
410
- return "mat3(".concat(a[0], ", ").concat(a[1], ", ").concat(a[2], ", ").concat(a[3], ", ").concat(a[4], ", ").concat(a[5], ", ").concat(a[6], ", ").concat(a[7], ", ").concat(a[8], ")");
600
+ return `mat3(${a[0]}, ${a[1]}, ${a[2]}, ${a[3]}, ${a[4]}, ${a[5]}, ${a[6]}, ${a[7]}, ${a[8]})`;
411
601
  }
602
+ /**
603
+ * Returns Frobenius norm of a mat3
604
+ *
605
+ * @param {ReadonlyMat3} a the matrix to calculate Frobenius norm of
606
+ * @returns {Number} Frobenius norm
607
+ */
412
608
  export function frob(a) {
413
- return Math.sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2] + a[3] * a[3] + a[4] * a[4] + a[5] * a[5] + a[6] * a[6] + a[7] * a[7] + a[8] * a[8]);
609
+ return Math.sqrt(a[0] * a[0] +
610
+ a[1] * a[1] +
611
+ a[2] * a[2] +
612
+ a[3] * a[3] +
613
+ a[4] * a[4] +
614
+ a[5] * a[5] +
615
+ a[6] * a[6] +
616
+ a[7] * a[7] +
617
+ a[8] * a[8]);
414
618
  }
619
+ /**
620
+ * Adds two mat3's
621
+ *
622
+ * @param {mat3} out the receiving matrix
623
+ * @param {ReadonlyMat3} a the first operand
624
+ * @param {ReadonlyMat3} b the second operand
625
+ * @returns {mat3} out
626
+ */
415
627
  export function add(out, a, b) {
416
- out[0] = a[0] + b[0];
417
- out[1] = a[1] + b[1];
418
- out[2] = a[2] + b[2];
419
- out[3] = a[3] + b[3];
420
- out[4] = a[4] + b[4];
421
- out[5] = a[5] + b[5];
422
- out[6] = a[6] + b[6];
423
- out[7] = a[7] + b[7];
424
- out[8] = a[8] + b[8];
425
- return out;
628
+ out[0] = a[0] + b[0];
629
+ out[1] = a[1] + b[1];
630
+ out[2] = a[2] + b[2];
631
+ out[3] = a[3] + b[3];
632
+ out[4] = a[4] + b[4];
633
+ out[5] = a[5] + b[5];
634
+ out[6] = a[6] + b[6];
635
+ out[7] = a[7] + b[7];
636
+ out[8] = a[8] + b[8];
637
+ return out;
426
638
  }
639
+ /**
640
+ * Subtracts matrix b from matrix a
641
+ *
642
+ * @param {mat3} out the receiving matrix
643
+ * @param {ReadonlyMat3} a the first operand
644
+ * @param {ReadonlyMat3} b the second operand
645
+ * @returns {mat3} out
646
+ */
427
647
  export function subtract(out, a, b) {
428
- out[0] = a[0] - b[0];
429
- out[1] = a[1] - b[1];
430
- out[2] = a[2] - b[2];
431
- out[3] = a[3] - b[3];
432
- out[4] = a[4] - b[4];
433
- out[5] = a[5] - b[5];
434
- out[6] = a[6] - b[6];
435
- out[7] = a[7] - b[7];
436
- out[8] = a[8] - b[8];
437
- return out;
648
+ out[0] = a[0] - b[0];
649
+ out[1] = a[1] - b[1];
650
+ out[2] = a[2] - b[2];
651
+ out[3] = a[3] - b[3];
652
+ out[4] = a[4] - b[4];
653
+ out[5] = a[5] - b[5];
654
+ out[6] = a[6] - b[6];
655
+ out[7] = a[7] - b[7];
656
+ out[8] = a[8] - b[8];
657
+ return out;
438
658
  }
659
+ /**
660
+ * Multiply each element of the matrix by a scalar.
661
+ *
662
+ * @param {mat3} out the receiving matrix
663
+ * @param {ReadonlyMat3} a the matrix to scale
664
+ * @param {Number} b amount to scale the matrix's elements by
665
+ * @returns {mat3} out
666
+ */
439
667
  export function multiplyScalar(out, a, b) {
440
- out[0] = a[0] * b;
441
- out[1] = a[1] * b;
442
- out[2] = a[2] * b;
443
- out[3] = a[3] * b;
444
- out[4] = a[4] * b;
445
- out[5] = a[5] * b;
446
- out[6] = a[6] * b;
447
- out[7] = a[7] * b;
448
- out[8] = a[8] * b;
449
- return out;
668
+ out[0] = a[0] * b;
669
+ out[1] = a[1] * b;
670
+ out[2] = a[2] * b;
671
+ out[3] = a[3] * b;
672
+ out[4] = a[4] * b;
673
+ out[5] = a[5] * b;
674
+ out[6] = a[6] * b;
675
+ out[7] = a[7] * b;
676
+ out[8] = a[8] * b;
677
+ return out;
450
678
  }
679
+ /**
680
+ * Adds two mat3's after multiplying each element of the second operand by a scalar value.
681
+ *
682
+ * @param {mat3} out the receiving vector
683
+ * @param {ReadonlyMat3} a the first operand
684
+ * @param {ReadonlyMat3} b the second operand
685
+ * @param {Number} scale the amount to scale b's elements by before adding
686
+ * @returns {mat3} out
687
+ */
451
688
  export function multiplyScalarAndAdd(out, a, b, scale) {
452
- out[0] = a[0] + b[0] * scale;
453
- out[1] = a[1] + b[1] * scale;
454
- out[2] = a[2] + b[2] * scale;
455
- out[3] = a[3] + b[3] * scale;
456
- out[4] = a[4] + b[4] * scale;
457
- out[5] = a[5] + b[5] * scale;
458
- out[6] = a[6] + b[6] * scale;
459
- out[7] = a[7] + b[7] * scale;
460
- out[8] = a[8] + b[8] * scale;
461
- return out;
689
+ out[0] = a[0] + b[0] * scale;
690
+ out[1] = a[1] + b[1] * scale;
691
+ out[2] = a[2] + b[2] * scale;
692
+ out[3] = a[3] + b[3] * scale;
693
+ out[4] = a[4] + b[4] * scale;
694
+ out[5] = a[5] + b[5] * scale;
695
+ out[6] = a[6] + b[6] * scale;
696
+ out[7] = a[7] + b[7] * scale;
697
+ out[8] = a[8] + b[8] * scale;
698
+ return out;
462
699
  }
700
+ /**
701
+ * Returns whether or not the matrices have exactly the same elements in the same position (when compared with ===)
702
+ *
703
+ * @param {ReadonlyMat3} a The first matrix.
704
+ * @param {ReadonlyMat3} b The second matrix.
705
+ * @returns {Boolean} True if the matrices are equal, false otherwise.
706
+ */
463
707
  export function exactEquals(a, b) {
464
- return a[0] === b[0] && a[1] === b[1] && a[2] === b[2] && a[3] === b[3] && a[4] === b[4] && a[5] === b[5] && a[6] === b[6] && a[7] === b[7] && a[8] === b[8];
708
+ return (a[0] === b[0] &&
709
+ a[1] === b[1] &&
710
+ a[2] === b[2] &&
711
+ a[3] === b[3] &&
712
+ a[4] === b[4] &&
713
+ a[5] === b[5] &&
714
+ a[6] === b[6] &&
715
+ a[7] === b[7] &&
716
+ a[8] === b[8]);
465
717
  }
718
+ /**
719
+ * Returns whether or not the matrices have approximately the same elements in the same position.
720
+ *
721
+ * @param {ReadonlyMat3} a The first matrix.
722
+ * @param {ReadonlyMat3} b The second matrix.
723
+ * @returns {Boolean} True if the matrices are equal, false otherwise.
724
+ */
466
725
  export function equals(a, b) {
467
- const a0 = a[0];
468
- const a1 = a[1];
469
- const a2 = a[2];
470
- const a3 = a[3];
471
- const a4 = a[4];
472
- const a5 = a[5];
473
- const a6 = a[6];
474
- const a7 = a[7];
475
- const a8 = a[8];
476
- const b0 = b[0];
477
- const b1 = b[1];
478
- const b2 = b[2];
479
- const b3 = b[3];
480
- const b4 = b[4];
481
- const b5 = b[5];
482
- const b6 = b[6];
483
- const b7 = b[7];
484
- const b8 = b[8];
485
- return Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) && Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) && Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) && Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) && Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) && Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) && Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) && Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) && Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8));
726
+ const a0 = a[0];
727
+ const a1 = a[1];
728
+ const a2 = a[2];
729
+ const a3 = a[3];
730
+ const a4 = a[4];
731
+ const a5 = a[5];
732
+ const a6 = a[6];
733
+ const a7 = a[7];
734
+ const a8 = a[8];
735
+ const b0 = b[0];
736
+ const b1 = b[1];
737
+ const b2 = b[2];
738
+ const b3 = b[3];
739
+ const b4 = b[4];
740
+ const b5 = b[5];
741
+ const b6 = b[6];
742
+ const b7 = b[7];
743
+ const b8 = b[8];
744
+ return (Math.abs(a0 - b0) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a0), Math.abs(b0)) &&
745
+ Math.abs(a1 - b1) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a1), Math.abs(b1)) &&
746
+ Math.abs(a2 - b2) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a2), Math.abs(b2)) &&
747
+ Math.abs(a3 - b3) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a3), Math.abs(b3)) &&
748
+ Math.abs(a4 - b4) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a4), Math.abs(b4)) &&
749
+ Math.abs(a5 - b5) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a5), Math.abs(b5)) &&
750
+ Math.abs(a6 - b6) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a6), Math.abs(b6)) &&
751
+ Math.abs(a7 - b7) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a7), Math.abs(b7)) &&
752
+ Math.abs(a8 - b8) <= glMatrix.EPSILON * Math.max(1.0, Math.abs(a8), Math.abs(b8)));
486
753
  }
754
+ /**
755
+ * Alias for {@link mat3.multiply}
756
+ * @function
757
+ */
487
758
  export const mul = multiply;
759
+ /**
760
+ * Alias for {@link mat3.subtract}
761
+ * @function
762
+ */
488
763
  export const sub = subtract;
489
- //# sourceMappingURL=mat3.js.map