@aura3d/math 4.3.7 → 4.6.0

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 (65) hide show
  1. package/dist/SphericalHarmonics3.d.ts +6 -3
  2. package/dist/SphericalHarmonics3.d.ts.map +1 -1
  3. package/dist/SphericalHarmonics3.js +8 -5
  4. package/dist/SphericalHarmonics3.js.map +1 -1
  5. package/dist/three/Box3.d.ts +106 -0
  6. package/dist/three/Box3.d.ts.map +1 -0
  7. package/dist/three/Box3.js +348 -0
  8. package/dist/three/Box3.js.map +1 -0
  9. package/dist/three/Color.d.ts +127 -0
  10. package/dist/three/Color.d.ts.map +1 -0
  11. package/dist/three/Color.js +501 -0
  12. package/dist/three/Color.js.map +1 -0
  13. package/dist/three/Euler.d.ts +50 -0
  14. package/dist/three/Euler.d.ts.map +1 -0
  15. package/dist/three/Euler.js +210 -0
  16. package/dist/three/Euler.js.map +1 -0
  17. package/dist/three/Frustum.d.ts +59 -0
  18. package/dist/three/Frustum.d.ts.map +1 -0
  19. package/dist/three/Frustum.js +135 -0
  20. package/dist/three/Frustum.js.map +1 -0
  21. package/dist/three/Matrix3.d.ts +56 -0
  22. package/dist/three/Matrix3.d.ts.map +1 -0
  23. package/dist/three/Matrix3.js +248 -0
  24. package/dist/three/Matrix3.js.map +1 -0
  25. package/dist/three/Matrix4.d.ts +79 -0
  26. package/dist/three/Matrix4.d.ts.map +1 -0
  27. package/dist/three/Matrix4.js +708 -0
  28. package/dist/three/Matrix4.js.map +1 -0
  29. package/dist/three/Plane.d.ts +65 -0
  30. package/dist/three/Plane.d.ts.map +1 -0
  31. package/dist/three/Plane.js +135 -0
  32. package/dist/three/Plane.js.map +1 -0
  33. package/dist/three/Quaternion.d.ts +91 -0
  34. package/dist/three/Quaternion.d.ts.map +1 -0
  35. package/dist/three/Quaternion.js +444 -0
  36. package/dist/three/Quaternion.js.map +1 -0
  37. package/dist/three/Ray.d.ts +56 -0
  38. package/dist/three/Ray.d.ts.map +1 -0
  39. package/dist/three/Ray.js +340 -0
  40. package/dist/three/Ray.js.map +1 -0
  41. package/dist/three/Sphere.d.ts +58 -0
  42. package/dist/three/Sphere.d.ts.map +1 -0
  43. package/dist/three/Sphere.js +166 -0
  44. package/dist/three/Sphere.js.map +1 -0
  45. package/dist/three/Triangle.d.ts +58 -0
  46. package/dist/three/Triangle.d.ts.map +1 -0
  47. package/dist/three/Triangle.js +229 -0
  48. package/dist/three/Triangle.js.map +1 -0
  49. package/dist/three/Vector2.d.ts +88 -0
  50. package/dist/three/Vector2.d.ts.map +1 -0
  51. package/dist/three/Vector2.js +283 -0
  52. package/dist/three/Vector2.js.map +1 -0
  53. package/dist/three/Vector3.d.ts +137 -0
  54. package/dist/three/Vector3.d.ts.map +1 -0
  55. package/dist/three/Vector3.js +458 -0
  56. package/dist/three/Vector3.js.map +1 -0
  57. package/dist/three/Vector4.d.ts +100 -0
  58. package/dist/three/Vector4.d.ts.map +1 -0
  59. package/dist/three/Vector4.js +443 -0
  60. package/dist/three/Vector4.js.map +1 -0
  61. package/dist/three/index.d.ts +29 -0
  62. package/dist/three/index.d.ts.map +1 -0
  63. package/dist/three/index.js +29 -0
  64. package/dist/three/index.js.map +1 -0
  65. package/package.json +5 -1
@@ -0,0 +1,708 @@
1
+ import { Matrix4 as ImmutableMatrix4 } from "../Matrix4.js";
2
+ import { Vector3 } from "./Vector3.js";
3
+ /** three.js `WebGLCoordinateSystem` constant. */
4
+ export const WebGLCoordinateSystem = 2000;
5
+ /** three.js `WebGPUCoordinateSystem` constant. */
6
+ export const WebGPUCoordinateSystem = 2001;
7
+ /**
8
+ * Mutable three.js-compatible 4x4 matrix, column-major `elements`, with the
9
+ * `set(n11, n12, ...)` row-major argument order three uses. Every modifier
10
+ * mutates `this` and returns `this`, exactly like three r185 `Matrix4`.
11
+ */
12
+ export class Matrix4 {
13
+ elements;
14
+ constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
15
+ this.elements = [
16
+ 1, 0, 0, 0,
17
+ 0, 1, 0, 0,
18
+ 0, 0, 1, 0,
19
+ 0, 0, 0, 1
20
+ ];
21
+ if (n11 !== undefined) {
22
+ this.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44);
23
+ }
24
+ }
25
+ /** Copy the elements of an immutable `@aura3d/math` Matrix4 (or any column-major 16-element source). */
26
+ fromImmutable(m) {
27
+ return this.fromArray(m.elements);
28
+ }
29
+ /** Snapshot as an immutable `@aura3d/math` Matrix4. */
30
+ toImmutable() {
31
+ return new ImmutableMatrix4(this.elements.slice(0, 16));
32
+ }
33
+ set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
34
+ const te = this.elements;
35
+ te[0] = n11;
36
+ te[4] = n12;
37
+ te[8] = n13;
38
+ te[12] = n14;
39
+ te[1] = n21;
40
+ te[5] = n22;
41
+ te[9] = n23;
42
+ te[13] = n24;
43
+ te[2] = n31;
44
+ te[6] = n32;
45
+ te[10] = n33;
46
+ te[14] = n34;
47
+ te[3] = n41;
48
+ te[7] = n42;
49
+ te[11] = n43;
50
+ te[15] = n44;
51
+ return this;
52
+ }
53
+ identity() {
54
+ this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
55
+ return this;
56
+ }
57
+ clone() {
58
+ return new Matrix4().fromArray(this.elements);
59
+ }
60
+ copy(m) {
61
+ const te = this.elements;
62
+ const me = m.elements;
63
+ te[0] = me[0];
64
+ te[1] = me[1];
65
+ te[2] = me[2];
66
+ te[3] = me[3];
67
+ te[4] = me[4];
68
+ te[5] = me[5];
69
+ te[6] = me[6];
70
+ te[7] = me[7];
71
+ te[8] = me[8];
72
+ te[9] = me[9];
73
+ te[10] = me[10];
74
+ te[11] = me[11];
75
+ te[12] = me[12];
76
+ te[13] = me[13];
77
+ te[14] = me[14];
78
+ te[15] = me[15];
79
+ return this;
80
+ }
81
+ copyPosition(m) {
82
+ const te = this.elements;
83
+ const me = m.elements;
84
+ te[12] = me[12];
85
+ te[13] = me[13];
86
+ te[14] = me[14];
87
+ return this;
88
+ }
89
+ setFromMatrix3(m) {
90
+ const me = m.elements;
91
+ this.set(me[0], me[3], me[6], 0, me[1], me[4], me[7], 0, me[2], me[5], me[8], 0, 0, 0, 0, 1);
92
+ return this;
93
+ }
94
+ extractBasis(xAxis, yAxis, zAxis) {
95
+ if (this.determinantAffine() === 0) {
96
+ xAxis.set(1, 0, 0);
97
+ yAxis.set(0, 1, 0);
98
+ zAxis.set(0, 0, 1);
99
+ return this;
100
+ }
101
+ xAxis.setFromMatrixColumn(this, 0);
102
+ yAxis.setFromMatrixColumn(this, 1);
103
+ zAxis.setFromMatrixColumn(this, 2);
104
+ return this;
105
+ }
106
+ makeBasis(xAxis, yAxis, zAxis) {
107
+ this.set(xAxis.x, yAxis.x, zAxis.x, 0, xAxis.y, yAxis.y, zAxis.y, 0, xAxis.z, yAxis.z, zAxis.z, 0, 0, 0, 0, 1);
108
+ return this;
109
+ }
110
+ extractRotation(m) {
111
+ // this method does not support reflection matrices
112
+ if (m.determinantAffine() === 0) {
113
+ return this.identity();
114
+ }
115
+ const te = this.elements;
116
+ const me = m.elements;
117
+ const scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length();
118
+ const scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length();
119
+ const scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length();
120
+ te[0] = me[0] * scaleX;
121
+ te[1] = me[1] * scaleX;
122
+ te[2] = me[2] * scaleX;
123
+ te[3] = 0;
124
+ te[4] = me[4] * scaleY;
125
+ te[5] = me[5] * scaleY;
126
+ te[6] = me[6] * scaleY;
127
+ te[7] = 0;
128
+ te[8] = me[8] * scaleZ;
129
+ te[9] = me[9] * scaleZ;
130
+ te[10] = me[10] * scaleZ;
131
+ te[11] = 0;
132
+ te[12] = 0;
133
+ te[13] = 0;
134
+ te[14] = 0;
135
+ te[15] = 1;
136
+ return this;
137
+ }
138
+ makeRotationFromEuler(euler) {
139
+ const te = this.elements;
140
+ const x = euler.x;
141
+ const y = euler.y;
142
+ const z = euler.z;
143
+ const a = Math.cos(x);
144
+ const b = Math.sin(x);
145
+ const c = Math.cos(y);
146
+ const d = Math.sin(y);
147
+ const e = Math.cos(z);
148
+ const f = Math.sin(z);
149
+ if (euler.order === "XYZ") {
150
+ const ae = a * e;
151
+ const af = a * f;
152
+ const be = b * e;
153
+ const bf = b * f;
154
+ te[0] = c * e;
155
+ te[4] = -c * f;
156
+ te[8] = d;
157
+ te[1] = af + be * d;
158
+ te[5] = ae - bf * d;
159
+ te[9] = -b * c;
160
+ te[2] = bf - ae * d;
161
+ te[6] = be + af * d;
162
+ te[10] = a * c;
163
+ }
164
+ else if (euler.order === "YXZ") {
165
+ const ce = c * e;
166
+ const cf = c * f;
167
+ const de = d * e;
168
+ const df = d * f;
169
+ te[0] = ce + df * b;
170
+ te[4] = de * b - cf;
171
+ te[8] = a * d;
172
+ te[1] = a * f;
173
+ te[5] = a * e;
174
+ te[9] = -b;
175
+ te[2] = cf * b - de;
176
+ te[6] = df + ce * b;
177
+ te[10] = a * c;
178
+ }
179
+ else if (euler.order === "ZXY") {
180
+ const ce = c * e;
181
+ const cf = c * f;
182
+ const de = d * e;
183
+ const df = d * f;
184
+ te[0] = ce - df * b;
185
+ te[4] = -a * f;
186
+ te[8] = de + cf * b;
187
+ te[1] = cf + de * b;
188
+ te[5] = a * e;
189
+ te[9] = df - ce * b;
190
+ te[2] = -a * d;
191
+ te[6] = b;
192
+ te[10] = a * c;
193
+ }
194
+ else if (euler.order === "ZYX") {
195
+ const ae = a * e;
196
+ const af = a * f;
197
+ const be = b * e;
198
+ const bf = b * f;
199
+ te[0] = c * e;
200
+ te[4] = be * d - af;
201
+ te[8] = ae * d + bf;
202
+ te[1] = c * f;
203
+ te[5] = bf * d + ae;
204
+ te[9] = af * d - be;
205
+ te[2] = -d;
206
+ te[6] = b * c;
207
+ te[10] = a * c;
208
+ }
209
+ else if (euler.order === "YZX") {
210
+ const ac = a * c;
211
+ const ad = a * d;
212
+ const bc = b * c;
213
+ const bd = b * d;
214
+ te[0] = c * e;
215
+ te[4] = bd - ac * f;
216
+ te[8] = bc * f + ad;
217
+ te[1] = f;
218
+ te[5] = a * e;
219
+ te[9] = -b * e;
220
+ te[2] = -d * e;
221
+ te[6] = ad * f + bc;
222
+ te[10] = ac - bd * f;
223
+ }
224
+ else if (euler.order === "XZY") {
225
+ const ac = a * c;
226
+ const ad = a * d;
227
+ const bc = b * c;
228
+ const bd = b * d;
229
+ te[0] = c * e;
230
+ te[4] = -f;
231
+ te[8] = d * e;
232
+ te[1] = ac * f + bd;
233
+ te[5] = a * e;
234
+ te[9] = ad * f - bc;
235
+ te[2] = bc * f - ad;
236
+ te[6] = b * e;
237
+ te[10] = bd * f + ac;
238
+ }
239
+ // bottom row
240
+ te[3] = 0;
241
+ te[7] = 0;
242
+ te[11] = 0;
243
+ // last column
244
+ te[12] = 0;
245
+ te[13] = 0;
246
+ te[14] = 0;
247
+ te[15] = 1;
248
+ return this;
249
+ }
250
+ makeRotationFromQuaternion(q) {
251
+ return this.compose(_zero, q, _one);
252
+ }
253
+ lookAt(eye, target, up) {
254
+ const te = this.elements;
255
+ _z.subVectors(eye, target);
256
+ if (_z.lengthSq() === 0) {
257
+ // eye and target are in the same position
258
+ _z.z = 1;
259
+ }
260
+ _z.normalize();
261
+ _x.crossVectors(up, _z);
262
+ if (_x.lengthSq() === 0) {
263
+ // up and z are parallel
264
+ if (Math.abs(up.z) === 1) {
265
+ _z.x += 0.0001;
266
+ }
267
+ else {
268
+ _z.z += 0.0001;
269
+ }
270
+ _z.normalize();
271
+ _x.crossVectors(up, _z);
272
+ }
273
+ _x.normalize();
274
+ _y.crossVectors(_z, _x);
275
+ te[0] = _x.x;
276
+ te[4] = _y.x;
277
+ te[8] = _z.x;
278
+ te[1] = _x.y;
279
+ te[5] = _y.y;
280
+ te[9] = _z.y;
281
+ te[2] = _x.z;
282
+ te[6] = _y.z;
283
+ te[10] = _z.z;
284
+ return this;
285
+ }
286
+ multiply(m) {
287
+ return this.multiplyMatrices(this, m);
288
+ }
289
+ premultiply(m) {
290
+ return this.multiplyMatrices(m, this);
291
+ }
292
+ multiplyMatrices(a, b) {
293
+ const ae = a.elements;
294
+ const be = b.elements;
295
+ const te = this.elements;
296
+ const a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
297
+ const a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
298
+ const a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
299
+ const a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
300
+ const b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
301
+ const b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
302
+ const b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
303
+ const b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
304
+ te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
305
+ te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
306
+ te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
307
+ te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
308
+ te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
309
+ te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
310
+ te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
311
+ te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
312
+ te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
313
+ te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
314
+ te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
315
+ te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
316
+ te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
317
+ te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
318
+ te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
319
+ te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
320
+ return this;
321
+ }
322
+ multiplyScalar(s) {
323
+ const te = this.elements;
324
+ te[0] *= s;
325
+ te[4] *= s;
326
+ te[8] *= s;
327
+ te[12] *= s;
328
+ te[1] *= s;
329
+ te[5] *= s;
330
+ te[9] *= s;
331
+ te[13] *= s;
332
+ te[2] *= s;
333
+ te[6] *= s;
334
+ te[10] *= s;
335
+ te[14] *= s;
336
+ te[3] *= s;
337
+ te[7] *= s;
338
+ te[11] *= s;
339
+ te[15] *= s;
340
+ return this;
341
+ }
342
+ determinant() {
343
+ const te = this.elements;
344
+ const n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
345
+ const n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
346
+ const n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
347
+ const n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
348
+ const t11 = n23 * n34 - n24 * n33;
349
+ const t12 = n22 * n34 - n24 * n32;
350
+ const t13 = n22 * n33 - n23 * n32;
351
+ const t21 = n21 * n34 - n24 * n31;
352
+ const t22 = n21 * n33 - n23 * n31;
353
+ const t23 = n21 * n32 - n22 * n31;
354
+ return (n11 * (n42 * t11 - n43 * t12 + n44 * t13) -
355
+ n12 * (n41 * t11 - n43 * t21 + n44 * t22) +
356
+ n13 * (n41 * t12 - n42 * t21 + n44 * t23) -
357
+ n14 * (n41 * t13 - n42 * t22 + n43 * t23));
358
+ }
359
+ determinantAffine() {
360
+ const te = this.elements;
361
+ const n11 = te[0], n12 = te[4], n13 = te[8];
362
+ const n21 = te[1], n22 = te[5], n23 = te[9];
363
+ const n31 = te[2], n32 = te[6], n33 = te[10];
364
+ return (n11 * (n22 * n33 - n23 * n32) -
365
+ n12 * (n21 * n33 - n23 * n31) +
366
+ n13 * (n21 * n32 - n22 * n31));
367
+ }
368
+ transpose() {
369
+ const te = this.elements;
370
+ let tmp;
371
+ tmp = te[1];
372
+ te[1] = te[4];
373
+ te[4] = tmp;
374
+ tmp = te[2];
375
+ te[2] = te[8];
376
+ te[8] = tmp;
377
+ tmp = te[6];
378
+ te[6] = te[9];
379
+ te[9] = tmp;
380
+ tmp = te[3];
381
+ te[3] = te[12];
382
+ te[12] = tmp;
383
+ tmp = te[7];
384
+ te[7] = te[13];
385
+ te[13] = tmp;
386
+ tmp = te[11];
387
+ te[11] = te[14];
388
+ te[14] = tmp;
389
+ return this;
390
+ }
391
+ setPosition(x, y, z) {
392
+ const te = this.elements;
393
+ if (typeof x === "object") {
394
+ te[12] = x.x;
395
+ te[13] = x.y;
396
+ te[14] = x.z;
397
+ }
398
+ else {
399
+ te[12] = x;
400
+ te[13] = y;
401
+ te[14] = z;
402
+ }
403
+ return this;
404
+ }
405
+ invert() {
406
+ // based on https://github.com/toji/gl-matrix
407
+ const te = this.elements;
408
+ const n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3];
409
+ const n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7];
410
+ const n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11];
411
+ const n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15];
412
+ const t1 = n11 * n22 - n21 * n12;
413
+ const t2 = n11 * n32 - n31 * n12;
414
+ const t3 = n11 * n42 - n41 * n12;
415
+ const t4 = n21 * n32 - n31 * n22;
416
+ const t5 = n21 * n42 - n41 * n22;
417
+ const t6 = n31 * n42 - n41 * n32;
418
+ const t7 = n13 * n24 - n23 * n14;
419
+ const t8 = n13 * n34 - n33 * n14;
420
+ const t9 = n13 * n44 - n43 * n14;
421
+ const t10 = n23 * n34 - n33 * n24;
422
+ const t11 = n23 * n44 - n43 * n24;
423
+ const t12 = n33 * n44 - n43 * n34;
424
+ const det = t1 * t12 - t2 * t11 + t3 * t10 + t4 * t9 - t5 * t8 + t6 * t7;
425
+ if (det === 0)
426
+ return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
427
+ const detInv = 1 / det;
428
+ te[0] = (n22 * t12 - n32 * t11 + n42 * t10) * detInv;
429
+ te[1] = (n31 * t11 - n21 * t12 - n41 * t10) * detInv;
430
+ te[2] = (n24 * t6 - n34 * t5 + n44 * t4) * detInv;
431
+ te[3] = (n33 * t5 - n23 * t6 - n43 * t4) * detInv;
432
+ te[4] = (n32 * t9 - n12 * t12 - n42 * t8) * detInv;
433
+ te[5] = (n11 * t12 - n31 * t9 + n41 * t8) * detInv;
434
+ te[6] = (n34 * t3 - n14 * t6 - n44 * t2) * detInv;
435
+ te[7] = (n13 * t6 - n33 * t3 + n43 * t2) * detInv;
436
+ te[8] = (n12 * t11 - n22 * t9 + n42 * t7) * detInv;
437
+ te[9] = (n21 * t9 - n11 * t11 - n41 * t7) * detInv;
438
+ te[10] = (n14 * t5 - n24 * t3 + n44 * t1) * detInv;
439
+ te[11] = (n23 * t3 - n13 * t5 - n43 * t1) * detInv;
440
+ te[12] = (n22 * t8 - n12 * t10 - n32 * t7) * detInv;
441
+ te[13] = (n11 * t10 - n21 * t8 + n31 * t7) * detInv;
442
+ te[14] = (n24 * t2 - n14 * t4 - n34 * t1) * detInv;
443
+ te[15] = (n13 * t4 - n23 * t2 + n33 * t1) * detInv;
444
+ return this;
445
+ }
446
+ scale(v) {
447
+ const te = this.elements;
448
+ const x = v.x;
449
+ const y = v.y;
450
+ const z = v.z;
451
+ te[0] *= x;
452
+ te[4] *= y;
453
+ te[8] *= z;
454
+ te[1] *= x;
455
+ te[5] *= y;
456
+ te[9] *= z;
457
+ te[2] *= x;
458
+ te[6] *= y;
459
+ te[10] *= z;
460
+ te[3] *= x;
461
+ te[7] *= y;
462
+ te[11] *= z;
463
+ return this;
464
+ }
465
+ getMaxScaleOnAxis() {
466
+ const te = this.elements;
467
+ const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
468
+ const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
469
+ const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
470
+ return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
471
+ }
472
+ makeTranslation(x, y, z) {
473
+ if (typeof x === "object") {
474
+ this.set(1, 0, 0, x.x, 0, 1, 0, x.y, 0, 0, 1, x.z, 0, 0, 0, 1);
475
+ }
476
+ else {
477
+ this.set(1, 0, 0, x, 0, 1, 0, y, 0, 0, 1, z, 0, 0, 0, 1);
478
+ }
479
+ return this;
480
+ }
481
+ makeRotationX(theta) {
482
+ const c = Math.cos(theta);
483
+ const s = Math.sin(theta);
484
+ this.set(1, 0, 0, 0, 0, c, -s, 0, 0, s, c, 0, 0, 0, 0, 1);
485
+ return this;
486
+ }
487
+ makeRotationY(theta) {
488
+ const c = Math.cos(theta);
489
+ const s = Math.sin(theta);
490
+ this.set(c, 0, s, 0, 0, 1, 0, 0, -s, 0, c, 0, 0, 0, 0, 1);
491
+ return this;
492
+ }
493
+ makeRotationZ(theta) {
494
+ const c = Math.cos(theta);
495
+ const s = Math.sin(theta);
496
+ this.set(c, -s, 0, 0, s, c, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1);
497
+ return this;
498
+ }
499
+ makeRotationAxis(axis, angle) {
500
+ // Based on http://www.gamedev.net/reference/articles/article1199.asp
501
+ const c = Math.cos(angle);
502
+ const s = Math.sin(angle);
503
+ const t = 1 - c;
504
+ const x = axis.x;
505
+ const y = axis.y;
506
+ const z = axis.z;
507
+ const tx = t * x;
508
+ const ty = t * y;
509
+ this.set(tx * x + c, tx * y - s * z, tx * z + s * y, 0, tx * y + s * z, ty * y + c, ty * z - s * x, 0, tx * z - s * y, ty * z + s * x, t * z * z + c, 0, 0, 0, 0, 1);
510
+ return this;
511
+ }
512
+ makeScale(x, y, z) {
513
+ this.set(x, 0, 0, 0, 0, y, 0, 0, 0, 0, z, 0, 0, 0, 0, 1);
514
+ return this;
515
+ }
516
+ makeShear(xy, xz, yx, yz, zx, zy) {
517
+ this.set(1, yx, zx, 0, xy, 1, zy, 0, xz, yz, 1, 0, 0, 0, 0, 1);
518
+ return this;
519
+ }
520
+ compose(position, quaternion, scale) {
521
+ const te = this.elements;
522
+ const x = quaternion.x;
523
+ const y = quaternion.y;
524
+ const z = quaternion.z;
525
+ const w = quaternion.w;
526
+ const x2 = x + x;
527
+ const y2 = y + y;
528
+ const z2 = z + z;
529
+ const xx = x * x2;
530
+ const xy = x * y2;
531
+ const xz = x * z2;
532
+ const yy = y * y2;
533
+ const yz = y * z2;
534
+ const zz = z * z2;
535
+ const wx = w * x2;
536
+ const wy = w * y2;
537
+ const wz = w * z2;
538
+ const sx = scale.x;
539
+ const sy = scale.y;
540
+ const sz = scale.z;
541
+ te[0] = (1 - (yy + zz)) * sx;
542
+ te[1] = (xy + wz) * sx;
543
+ te[2] = (xz - wy) * sx;
544
+ te[3] = 0;
545
+ te[4] = (xy - wz) * sy;
546
+ te[5] = (1 - (xx + zz)) * sy;
547
+ te[6] = (yz + wx) * sy;
548
+ te[7] = 0;
549
+ te[8] = (xz + wy) * sz;
550
+ te[9] = (yz - wx) * sz;
551
+ te[10] = (1 - (xx + yy)) * sz;
552
+ te[11] = 0;
553
+ te[12] = position.x;
554
+ te[13] = position.y;
555
+ te[14] = position.z;
556
+ te[15] = 1;
557
+ return this;
558
+ }
559
+ decompose(position, quaternion, scale) {
560
+ const te = this.elements;
561
+ position.x = te[12];
562
+ position.y = te[13];
563
+ position.z = te[14];
564
+ const det = this.determinantAffine();
565
+ if (det === 0) {
566
+ scale.set(1, 1, 1);
567
+ quaternion.identity();
568
+ return this;
569
+ }
570
+ let sx = _v1.set(te[0], te[1], te[2]).length();
571
+ const sy = _v1.set(te[4], te[5], te[6]).length();
572
+ const sz = _v1.set(te[8], te[9], te[10]).length();
573
+ // if determinant is negative, we need to invert one scale
574
+ if (det < 0)
575
+ sx = -sx;
576
+ // scale the rotation part
577
+ _m1.copy(this);
578
+ const invSX = 1 / sx;
579
+ const invSY = 1 / sy;
580
+ const invSZ = 1 / sz;
581
+ _m1.elements[0] *= invSX;
582
+ _m1.elements[1] *= invSX;
583
+ _m1.elements[2] *= invSX;
584
+ _m1.elements[4] *= invSY;
585
+ _m1.elements[5] *= invSY;
586
+ _m1.elements[6] *= invSY;
587
+ _m1.elements[8] *= invSZ;
588
+ _m1.elements[9] *= invSZ;
589
+ _m1.elements[10] *= invSZ;
590
+ quaternion.setFromRotationMatrix(_m1);
591
+ scale.x = sx;
592
+ scale.y = sy;
593
+ scale.z = sz;
594
+ return this;
595
+ }
596
+ makePerspective(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false) {
597
+ const te = this.elements;
598
+ const x = (2 * near) / (right - left);
599
+ const y = (2 * near) / (top - bottom);
600
+ const a = (right + left) / (right - left);
601
+ const b = (top + bottom) / (top - bottom);
602
+ let c;
603
+ let d;
604
+ if (reversedDepth) {
605
+ c = near / (far - near);
606
+ d = (far * near) / (far - near);
607
+ }
608
+ else if (coordinateSystem === WebGLCoordinateSystem) {
609
+ c = -(far + near) / (far - near);
610
+ d = (-2 * far * near) / (far - near);
611
+ }
612
+ else if (coordinateSystem === WebGPUCoordinateSystem) {
613
+ c = -far / (far - near);
614
+ d = (-far * near) / (far - near);
615
+ }
616
+ else {
617
+ throw new Error(`THREE.Matrix4.makePerspective(): Invalid coordinate system: ${coordinateSystem}`);
618
+ }
619
+ te[0] = x;
620
+ te[4] = 0;
621
+ te[8] = a;
622
+ te[12] = 0;
623
+ te[1] = 0;
624
+ te[5] = y;
625
+ te[9] = b;
626
+ te[13] = 0;
627
+ te[2] = 0;
628
+ te[6] = 0;
629
+ te[10] = c;
630
+ te[14] = d;
631
+ te[3] = 0;
632
+ te[7] = 0;
633
+ te[11] = -1;
634
+ te[15] = 0;
635
+ return this;
636
+ }
637
+ makeOrthographic(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem, reversedDepth = false) {
638
+ const te = this.elements;
639
+ const x = 2 / (right - left);
640
+ const y = 2 / (top - bottom);
641
+ const a = -(right + left) / (right - left);
642
+ const b = -(top + bottom) / (top - bottom);
643
+ let c;
644
+ let d;
645
+ if (reversedDepth) {
646
+ c = 1 / (far - near);
647
+ d = far / (far - near);
648
+ }
649
+ else if (coordinateSystem === WebGLCoordinateSystem) {
650
+ c = -2 / (far - near);
651
+ d = -(far + near) / (far - near);
652
+ }
653
+ else if (coordinateSystem === WebGPUCoordinateSystem) {
654
+ c = -1 / (far - near);
655
+ d = -near / (far - near);
656
+ }
657
+ else {
658
+ throw new Error(`THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ${coordinateSystem}`);
659
+ }
660
+ te[0] = x;
661
+ te[4] = 0;
662
+ te[8] = 0;
663
+ te[12] = a;
664
+ te[1] = 0;
665
+ te[5] = y;
666
+ te[9] = 0;
667
+ te[13] = b;
668
+ te[2] = 0;
669
+ te[6] = 0;
670
+ te[10] = c;
671
+ te[14] = d;
672
+ te[3] = 0;
673
+ te[7] = 0;
674
+ te[11] = 0;
675
+ te[15] = 1;
676
+ return this;
677
+ }
678
+ equals(matrix) {
679
+ const te = this.elements;
680
+ const me = matrix.elements;
681
+ for (let i = 0; i < 16; i += 1) {
682
+ if (te[i] !== me[i])
683
+ return false;
684
+ }
685
+ return true;
686
+ }
687
+ fromArray(array, offset = 0) {
688
+ for (let i = 0; i < 16; i += 1) {
689
+ this.elements[i] = array[i + offset];
690
+ }
691
+ return this;
692
+ }
693
+ toArray(array = [], offset = 0) {
694
+ const te = this.elements;
695
+ for (let i = 0; i < 16; i += 1)
696
+ array[offset + i] = te[i];
697
+ return array;
698
+ }
699
+ }
700
+ Matrix4.prototype.isMatrix4 = true;
701
+ const _v1 = new Vector3();
702
+ const _m1 = new Matrix4();
703
+ const _zero = new Vector3(0, 0, 0);
704
+ const _one = new Vector3(1, 1, 1);
705
+ const _x = new Vector3();
706
+ const _y = new Vector3();
707
+ const _z = new Vector3();
708
+ //# sourceMappingURL=Matrix4.js.map