poly-extrude 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,914 @@
1
+ // code copy from https://github.com/mrdoob/three.js/blob/dev/src/math/Matrix4.js
2
+ // import { WebGLCoordinateSystem, WebGPUCoordinateSystem } from '../constants.js';
3
+ // import { Vector3 } from './Vector3.js';
4
+
5
+ class Matrix4 {
6
+
7
+ constructor(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
8
+
9
+ this.elements = [
10
+
11
+ 1, 0, 0, 0,
12
+ 0, 1, 0, 0,
13
+ 0, 0, 1, 0,
14
+ 0, 0, 0, 1
15
+
16
+ ];
17
+
18
+ if (n11 !== undefined) {
19
+
20
+ this.set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44);
21
+
22
+ }
23
+
24
+ }
25
+
26
+ set(n11, n12, n13, n14, n21, n22, n23, n24, n31, n32, n33, n34, n41, n42, n43, n44) {
27
+
28
+ const te = this.elements;
29
+
30
+ te[0] = n11; te[4] = n12; te[8] = n13; te[12] = n14;
31
+ te[1] = n21; te[5] = n22; te[9] = n23; te[13] = n24;
32
+ te[2] = n31; te[6] = n32; te[10] = n33; te[14] = n34;
33
+ te[3] = n41; te[7] = n42; te[11] = n43; te[15] = n44;
34
+
35
+ return this;
36
+
37
+ }
38
+
39
+ // identity() {
40
+
41
+ // this.set(
42
+
43
+ // 1, 0, 0, 0,
44
+ // 0, 1, 0, 0,
45
+ // 0, 0, 1, 0,
46
+ // 0, 0, 0, 1
47
+
48
+ // );
49
+
50
+ // return this;
51
+
52
+ // }
53
+
54
+ // clone() {
55
+
56
+ // return new Matrix4().fromArray(this.elements);
57
+
58
+ // }
59
+
60
+ // copy(m) {
61
+
62
+ // const te = this.elements;
63
+ // const me = m.elements;
64
+
65
+ // te[0] = me[0]; te[1] = me[1]; te[2] = me[2]; te[3] = me[3];
66
+ // te[4] = me[4]; te[5] = me[5]; te[6] = me[6]; te[7] = me[7];
67
+ // te[8] = me[8]; te[9] = me[9]; te[10] = me[10]; te[11] = me[11];
68
+ // te[12] = me[12]; te[13] = me[13]; te[14] = me[14]; te[15] = me[15];
69
+
70
+ // return this;
71
+
72
+ // }
73
+
74
+ // copyPosition(m) {
75
+
76
+ // const te = this.elements, me = m.elements;
77
+
78
+ // te[12] = me[12];
79
+ // te[13] = me[13];
80
+ // te[14] = me[14];
81
+
82
+ // return this;
83
+
84
+ // }
85
+
86
+ // setFromMatrix3(m) {
87
+
88
+ // const me = m.elements;
89
+
90
+ // this.set(
91
+
92
+ // me[0], me[3], me[6], 0,
93
+ // me[1], me[4], me[7], 0,
94
+ // me[2], me[5], me[8], 0,
95
+ // 0, 0, 0, 1
96
+
97
+ // );
98
+
99
+ // return this;
100
+
101
+ // }
102
+
103
+ // extractBasis(xAxis, yAxis, zAxis) {
104
+
105
+ // xAxis.setFromMatrixColumn(this, 0);
106
+ // yAxis.setFromMatrixColumn(this, 1);
107
+ // zAxis.setFromMatrixColumn(this, 2);
108
+
109
+ // return this;
110
+
111
+ // }
112
+
113
+ // makeBasis(xAxis, yAxis, zAxis) {
114
+
115
+ // this.set(
116
+ // xAxis.x, yAxis.x, zAxis.x, 0,
117
+ // xAxis.y, yAxis.y, zAxis.y, 0,
118
+ // xAxis.z, yAxis.z, zAxis.z, 0,
119
+ // 0, 0, 0, 1
120
+ // );
121
+
122
+ // return this;
123
+
124
+ // }
125
+
126
+ // extractRotation(m) {
127
+
128
+ // // this method does not support reflection matrices
129
+
130
+ // const te = this.elements;
131
+ // const me = m.elements;
132
+
133
+ // const scaleX = 1 / _v1.setFromMatrixColumn(m, 0).length();
134
+ // const scaleY = 1 / _v1.setFromMatrixColumn(m, 1).length();
135
+ // const scaleZ = 1 / _v1.setFromMatrixColumn(m, 2).length();
136
+
137
+ // te[0] = me[0] * scaleX;
138
+ // te[1] = me[1] * scaleX;
139
+ // te[2] = me[2] * scaleX;
140
+ // te[3] = 0;
141
+
142
+ // te[4] = me[4] * scaleY;
143
+ // te[5] = me[5] * scaleY;
144
+ // te[6] = me[6] * scaleY;
145
+ // te[7] = 0;
146
+
147
+ // te[8] = me[8] * scaleZ;
148
+ // te[9] = me[9] * scaleZ;
149
+ // te[10] = me[10] * scaleZ;
150
+ // te[11] = 0;
151
+
152
+ // te[12] = 0;
153
+ // te[13] = 0;
154
+ // te[14] = 0;
155
+ // te[15] = 1;
156
+
157
+ // return this;
158
+
159
+ // }
160
+
161
+ // makeRotationFromEuler(euler) {
162
+
163
+ // const te = this.elements;
164
+
165
+ // const x = euler.x, y = euler.y, z = euler.z;
166
+ // const a = Math.cos(x), b = Math.sin(x);
167
+ // const c = Math.cos(y), d = Math.sin(y);
168
+ // const e = Math.cos(z), f = Math.sin(z);
169
+
170
+ // if (euler.order === 'XYZ') {
171
+
172
+ // const ae = a * e, af = a * f, be = b * e, bf = b * f;
173
+
174
+ // te[0] = c * e;
175
+ // te[4] = -c * f;
176
+ // te[8] = d;
177
+
178
+ // te[1] = af + be * d;
179
+ // te[5] = ae - bf * d;
180
+ // te[9] = -b * c;
181
+
182
+ // te[2] = bf - ae * d;
183
+ // te[6] = be + af * d;
184
+ // te[10] = a * c;
185
+
186
+ // } else if (euler.order === 'YXZ') {
187
+
188
+ // const ce = c * e, cf = c * f, de = d * e, df = d * f;
189
+
190
+ // te[0] = ce + df * b;
191
+ // te[4] = de * b - cf;
192
+ // te[8] = a * d;
193
+
194
+ // te[1] = a * f;
195
+ // te[5] = a * e;
196
+ // te[9] = -b;
197
+
198
+ // te[2] = cf * b - de;
199
+ // te[6] = df + ce * b;
200
+ // te[10] = a * c;
201
+
202
+ // } else if (euler.order === 'ZXY') {
203
+
204
+ // const ce = c * e, cf = c * f, de = d * e, df = d * f;
205
+
206
+ // te[0] = ce - df * b;
207
+ // te[4] = -a * f;
208
+ // te[8] = de + cf * b;
209
+
210
+ // te[1] = cf + de * b;
211
+ // te[5] = a * e;
212
+ // te[9] = df - ce * b;
213
+
214
+ // te[2] = -a * d;
215
+ // te[6] = b;
216
+ // te[10] = a * c;
217
+
218
+ // } else if (euler.order === 'ZYX') {
219
+
220
+ // const ae = a * e, af = a * f, be = b * e, bf = b * f;
221
+
222
+ // te[0] = c * e;
223
+ // te[4] = be * d - af;
224
+ // te[8] = ae * d + bf;
225
+
226
+ // te[1] = c * f;
227
+ // te[5] = bf * d + ae;
228
+ // te[9] = af * d - be;
229
+
230
+ // te[2] = -d;
231
+ // te[6] = b * c;
232
+ // te[10] = a * c;
233
+
234
+ // } else if (euler.order === 'YZX') {
235
+
236
+ // const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
237
+
238
+ // te[0] = c * e;
239
+ // te[4] = bd - ac * f;
240
+ // te[8] = bc * f + ad;
241
+
242
+ // te[1] = f;
243
+ // te[5] = a * e;
244
+ // te[9] = -b * e;
245
+
246
+ // te[2] = -d * e;
247
+ // te[6] = ad * f + bc;
248
+ // te[10] = ac - bd * f;
249
+
250
+ // } else if (euler.order === 'XZY') {
251
+
252
+ // const ac = a * c, ad = a * d, bc = b * c, bd = b * d;
253
+
254
+ // te[0] = c * e;
255
+ // te[4] = -f;
256
+ // te[8] = d * e;
257
+
258
+ // te[1] = ac * f + bd;
259
+ // te[5] = a * e;
260
+ // te[9] = ad * f - bc;
261
+
262
+ // te[2] = bc * f - ad;
263
+ // te[6] = b * e;
264
+ // te[10] = bd * f + ac;
265
+
266
+ // }
267
+
268
+ // // bottom row
269
+ // te[3] = 0;
270
+ // te[7] = 0;
271
+ // te[11] = 0;
272
+
273
+ // // last column
274
+ // te[12] = 0;
275
+ // te[13] = 0;
276
+ // te[14] = 0;
277
+ // te[15] = 1;
278
+
279
+ // return this;
280
+
281
+ // }
282
+
283
+ // makeRotationFromQuaternion(q) {
284
+
285
+ // return this.compose(_zero, q, _one);
286
+
287
+ // }
288
+
289
+ // lookAt(eye, target, up) {
290
+
291
+ // const te = this.elements;
292
+
293
+ // _z.subVectors(eye, target);
294
+
295
+ // if (_z.lengthSq() === 0) {
296
+
297
+ // // eye and target are in the same position
298
+
299
+ // _z.z = 1;
300
+
301
+ // }
302
+
303
+ // _z.normalize();
304
+ // _x.crossVectors(up, _z);
305
+
306
+ // if (_x.lengthSq() === 0) {
307
+
308
+ // // up and z are parallel
309
+
310
+ // if (Math.abs(up.z) === 1) {
311
+
312
+ // _z.x += 0.0001;
313
+
314
+ // } else {
315
+
316
+ // _z.z += 0.0001;
317
+
318
+ // }
319
+
320
+ // _z.normalize();
321
+ // _x.crossVectors(up, _z);
322
+
323
+ // }
324
+
325
+ // _x.normalize();
326
+ // _y.crossVectors(_z, _x);
327
+
328
+ // te[0] = _x.x; te[4] = _y.x; te[8] = _z.x;
329
+ // te[1] = _x.y; te[5] = _y.y; te[9] = _z.y;
330
+ // te[2] = _x.z; te[6] = _y.z; te[10] = _z.z;
331
+
332
+ // return this;
333
+
334
+ // }
335
+
336
+ multiply(m) {
337
+
338
+ return this.multiplyMatrices(this, m);
339
+
340
+ }
341
+
342
+ // premultiply(m) {
343
+
344
+ // return this.multiplyMatrices(m, this);
345
+
346
+ // }
347
+
348
+ // multiplyMatrices(a, b) {
349
+
350
+ // const ae = a.elements;
351
+ // const be = b.elements;
352
+ // const te = this.elements;
353
+
354
+ // const a11 = ae[0], a12 = ae[4], a13 = ae[8], a14 = ae[12];
355
+ // const a21 = ae[1], a22 = ae[5], a23 = ae[9], a24 = ae[13];
356
+ // const a31 = ae[2], a32 = ae[6], a33 = ae[10], a34 = ae[14];
357
+ // const a41 = ae[3], a42 = ae[7], a43 = ae[11], a44 = ae[15];
358
+
359
+ // const b11 = be[0], b12 = be[4], b13 = be[8], b14 = be[12];
360
+ // const b21 = be[1], b22 = be[5], b23 = be[9], b24 = be[13];
361
+ // const b31 = be[2], b32 = be[6], b33 = be[10], b34 = be[14];
362
+ // const b41 = be[3], b42 = be[7], b43 = be[11], b44 = be[15];
363
+
364
+ // te[0] = a11 * b11 + a12 * b21 + a13 * b31 + a14 * b41;
365
+ // te[4] = a11 * b12 + a12 * b22 + a13 * b32 + a14 * b42;
366
+ // te[8] = a11 * b13 + a12 * b23 + a13 * b33 + a14 * b43;
367
+ // te[12] = a11 * b14 + a12 * b24 + a13 * b34 + a14 * b44;
368
+
369
+ // te[1] = a21 * b11 + a22 * b21 + a23 * b31 + a24 * b41;
370
+ // te[5] = a21 * b12 + a22 * b22 + a23 * b32 + a24 * b42;
371
+ // te[9] = a21 * b13 + a22 * b23 + a23 * b33 + a24 * b43;
372
+ // te[13] = a21 * b14 + a22 * b24 + a23 * b34 + a24 * b44;
373
+
374
+ // te[2] = a31 * b11 + a32 * b21 + a33 * b31 + a34 * b41;
375
+ // te[6] = a31 * b12 + a32 * b22 + a33 * b32 + a34 * b42;
376
+ // te[10] = a31 * b13 + a32 * b23 + a33 * b33 + a34 * b43;
377
+ // te[14] = a31 * b14 + a32 * b24 + a33 * b34 + a34 * b44;
378
+
379
+ // te[3] = a41 * b11 + a42 * b21 + a43 * b31 + a44 * b41;
380
+ // te[7] = a41 * b12 + a42 * b22 + a43 * b32 + a44 * b42;
381
+ // te[11] = a41 * b13 + a42 * b23 + a43 * b33 + a44 * b43;
382
+ // te[15] = a41 * b14 + a42 * b24 + a43 * b34 + a44 * b44;
383
+
384
+ // return this;
385
+
386
+ // }
387
+
388
+ // multiplyScalar(s) {
389
+
390
+ // const te = this.elements;
391
+
392
+ // te[0] *= s; te[4] *= s; te[8] *= s; te[12] *= s;
393
+ // te[1] *= s; te[5] *= s; te[9] *= s; te[13] *= s;
394
+ // te[2] *= s; te[6] *= s; te[10] *= s; te[14] *= s;
395
+ // te[3] *= s; te[7] *= s; te[11] *= s; te[15] *= s;
396
+
397
+ // return this;
398
+
399
+ // }
400
+
401
+ // determinant() {
402
+
403
+ // const te = this.elements;
404
+
405
+ // const n11 = te[0], n12 = te[4], n13 = te[8], n14 = te[12];
406
+ // const n21 = te[1], n22 = te[5], n23 = te[9], n24 = te[13];
407
+ // const n31 = te[2], n32 = te[6], n33 = te[10], n34 = te[14];
408
+ // const n41 = te[3], n42 = te[7], n43 = te[11], n44 = te[15];
409
+
410
+ // //TODO: make this more efficient
411
+ // //( based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm )
412
+
413
+ // return (
414
+ // n41 * (
415
+ // + n14 * n23 * n32
416
+ // - n13 * n24 * n32
417
+ // - n14 * n22 * n33
418
+ // + n12 * n24 * n33
419
+ // + n13 * n22 * n34
420
+ // - n12 * n23 * n34
421
+ // ) +
422
+ // n42 * (
423
+ // + n11 * n23 * n34
424
+ // - n11 * n24 * n33
425
+ // + n14 * n21 * n33
426
+ // - n13 * n21 * n34
427
+ // + n13 * n24 * n31
428
+ // - n14 * n23 * n31
429
+ // ) +
430
+ // n43 * (
431
+ // + n11 * n24 * n32
432
+ // - n11 * n22 * n34
433
+ // - n14 * n21 * n32
434
+ // + n12 * n21 * n34
435
+ // + n14 * n22 * n31
436
+ // - n12 * n24 * n31
437
+ // ) +
438
+ // n44 * (
439
+ // - n13 * n22 * n31
440
+ // - n11 * n23 * n32
441
+ // + n11 * n22 * n33
442
+ // + n13 * n21 * n32
443
+ // - n12 * n21 * n33
444
+ // + n12 * n23 * n31
445
+ // )
446
+
447
+ // );
448
+
449
+ // }
450
+
451
+ // transpose() {
452
+
453
+ // const te = this.elements;
454
+ // let tmp;
455
+
456
+ // tmp = te[1]; te[1] = te[4]; te[4] = tmp;
457
+ // tmp = te[2]; te[2] = te[8]; te[8] = tmp;
458
+ // tmp = te[6]; te[6] = te[9]; te[9] = tmp;
459
+
460
+ // tmp = te[3]; te[3] = te[12]; te[12] = tmp;
461
+ // tmp = te[7]; te[7] = te[13]; te[13] = tmp;
462
+ // tmp = te[11]; te[11] = te[14]; te[14] = tmp;
463
+
464
+ // return this;
465
+
466
+ // }
467
+
468
+ // setPosition(x, y, z) {
469
+
470
+ // const te = this.elements;
471
+
472
+ // if (x.isVector3) {
473
+
474
+ // te[12] = x.x;
475
+ // te[13] = x.y;
476
+ // te[14] = x.z;
477
+
478
+ // } else {
479
+
480
+ // te[12] = x;
481
+ // te[13] = y;
482
+ // te[14] = z;
483
+
484
+ // }
485
+
486
+ // return this;
487
+
488
+ // }
489
+
490
+ // invert() {
491
+
492
+ // // based on http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm
493
+ // const te = this.elements,
494
+
495
+ // n11 = te[0], n21 = te[1], n31 = te[2], n41 = te[3],
496
+ // n12 = te[4], n22 = te[5], n32 = te[6], n42 = te[7],
497
+ // n13 = te[8], n23 = te[9], n33 = te[10], n43 = te[11],
498
+ // n14 = te[12], n24 = te[13], n34 = te[14], n44 = te[15],
499
+
500
+ // t11 = n23 * n34 * n42 - n24 * n33 * n42 + n24 * n32 * n43 - n22 * n34 * n43 - n23 * n32 * n44 + n22 * n33 * n44,
501
+ // t12 = n14 * n33 * n42 - n13 * n34 * n42 - n14 * n32 * n43 + n12 * n34 * n43 + n13 * n32 * n44 - n12 * n33 * n44,
502
+ // t13 = n13 * n24 * n42 - n14 * n23 * n42 + n14 * n22 * n43 - n12 * n24 * n43 - n13 * n22 * n44 + n12 * n23 * n44,
503
+ // t14 = n14 * n23 * n32 - n13 * n24 * n32 - n14 * n22 * n33 + n12 * n24 * n33 + n13 * n22 * n34 - n12 * n23 * n34;
504
+
505
+ // const det = n11 * t11 + n21 * t12 + n31 * t13 + n41 * t14;
506
+
507
+ // if (det === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
508
+
509
+ // const detInv = 1 / det;
510
+
511
+ // te[0] = t11 * detInv;
512
+ // te[1] = (n24 * n33 * n41 - n23 * n34 * n41 - n24 * n31 * n43 + n21 * n34 * n43 + n23 * n31 * n44 - n21 * n33 * n44) * detInv;
513
+ // te[2] = (n22 * n34 * n41 - n24 * n32 * n41 + n24 * n31 * n42 - n21 * n34 * n42 - n22 * n31 * n44 + n21 * n32 * n44) * detInv;
514
+ // te[3] = (n23 * n32 * n41 - n22 * n33 * n41 - n23 * n31 * n42 + n21 * n33 * n42 + n22 * n31 * n43 - n21 * n32 * n43) * detInv;
515
+
516
+ // te[4] = t12 * detInv;
517
+ // te[5] = (n13 * n34 * n41 - n14 * n33 * n41 + n14 * n31 * n43 - n11 * n34 * n43 - n13 * n31 * n44 + n11 * n33 * n44) * detInv;
518
+ // te[6] = (n14 * n32 * n41 - n12 * n34 * n41 - n14 * n31 * n42 + n11 * n34 * n42 + n12 * n31 * n44 - n11 * n32 * n44) * detInv;
519
+ // te[7] = (n12 * n33 * n41 - n13 * n32 * n41 + n13 * n31 * n42 - n11 * n33 * n42 - n12 * n31 * n43 + n11 * n32 * n43) * detInv;
520
+
521
+ // te[8] = t13 * detInv;
522
+ // te[9] = (n14 * n23 * n41 - n13 * n24 * n41 - n14 * n21 * n43 + n11 * n24 * n43 + n13 * n21 * n44 - n11 * n23 * n44) * detInv;
523
+ // te[10] = (n12 * n24 * n41 - n14 * n22 * n41 + n14 * n21 * n42 - n11 * n24 * n42 - n12 * n21 * n44 + n11 * n22 * n44) * detInv;
524
+ // te[11] = (n13 * n22 * n41 - n12 * n23 * n41 - n13 * n21 * n42 + n11 * n23 * n42 + n12 * n21 * n43 - n11 * n22 * n43) * detInv;
525
+
526
+ // te[12] = t14 * detInv;
527
+ // te[13] = (n13 * n24 * n31 - n14 * n23 * n31 + n14 * n21 * n33 - n11 * n24 * n33 - n13 * n21 * n34 + n11 * n23 * n34) * detInv;
528
+ // te[14] = (n14 * n22 * n31 - n12 * n24 * n31 - n14 * n21 * n32 + n11 * n24 * n32 + n12 * n21 * n34 - n11 * n22 * n34) * detInv;
529
+ // te[15] = (n12 * n23 * n31 - n13 * n22 * n31 + n13 * n21 * n32 - n11 * n23 * n32 - n12 * n21 * n33 + n11 * n22 * n33) * detInv;
530
+
531
+ // return this;
532
+
533
+ // }
534
+
535
+ // scale(v) {
536
+
537
+ // const te = this.elements;
538
+ // const x = v.x, y = v.y, z = v.z;
539
+
540
+ // te[0] *= x; te[4] *= y; te[8] *= z;
541
+ // te[1] *= x; te[5] *= y; te[9] *= z;
542
+ // te[2] *= x; te[6] *= y; te[10] *= z;
543
+ // te[3] *= x; te[7] *= y; te[11] *= z;
544
+
545
+ // return this;
546
+
547
+ // }
548
+
549
+ // getMaxScaleOnAxis() {
550
+
551
+ // const te = this.elements;
552
+
553
+ // const scaleXSq = te[0] * te[0] + te[1] * te[1] + te[2] * te[2];
554
+ // const scaleYSq = te[4] * te[4] + te[5] * te[5] + te[6] * te[6];
555
+ // const scaleZSq = te[8] * te[8] + te[9] * te[9] + te[10] * te[10];
556
+
557
+ // return Math.sqrt(Math.max(scaleXSq, scaleYSq, scaleZSq));
558
+
559
+ // }
560
+
561
+ // makeTranslation(x, y, z) {
562
+
563
+ // if (x.isVector3) {
564
+
565
+ // this.set(
566
+
567
+ // 1, 0, 0, x.x,
568
+ // 0, 1, 0, x.y,
569
+ // 0, 0, 1, x.z,
570
+ // 0, 0, 0, 1
571
+
572
+ // );
573
+
574
+ // } else {
575
+
576
+ // this.set(
577
+
578
+ // 1, 0, 0, x,
579
+ // 0, 1, 0, y,
580
+ // 0, 0, 1, z,
581
+ // 0, 0, 0, 1
582
+
583
+ // );
584
+
585
+ // }
586
+
587
+ // return this;
588
+
589
+ // }
590
+
591
+ // makeRotationX(theta) {
592
+
593
+ // const c = Math.cos(theta), s = Math.sin(theta);
594
+
595
+ // this.set(
596
+
597
+ // 1, 0, 0, 0,
598
+ // 0, c, -s, 0,
599
+ // 0, s, c, 0,
600
+ // 0, 0, 0, 1
601
+
602
+ // );
603
+
604
+ // return this;
605
+
606
+ // }
607
+
608
+ // makeRotationY(theta) {
609
+
610
+ // const c = Math.cos(theta), s = Math.sin(theta);
611
+
612
+ // this.set(
613
+
614
+ // c, 0, s, 0,
615
+ // 0, 1, 0, 0,
616
+ // -s, 0, c, 0,
617
+ // 0, 0, 0, 1
618
+
619
+ // );
620
+
621
+ // return this;
622
+
623
+ // }
624
+
625
+ // makeRotationZ(theta) {
626
+
627
+ // const c = Math.cos(theta), s = Math.sin(theta);
628
+
629
+ // this.set(
630
+
631
+ // c, -s, 0, 0,
632
+ // s, c, 0, 0,
633
+ // 0, 0, 1, 0,
634
+ // 0, 0, 0, 1
635
+
636
+ // );
637
+
638
+ // return this;
639
+
640
+ // }
641
+
642
+ makeRotationAxis(axis, angle) {
643
+
644
+ // Based on http://www.gamedev.net/reference/articles/article1199.asp
645
+
646
+ const c = Math.cos(angle);
647
+ const s = Math.sin(angle);
648
+ const t = 1 - c;
649
+ const x = axis.x, y = axis.y, z = axis.z;
650
+ const tx = t * x, ty = t * y;
651
+
652
+ this.set(
653
+
654
+ tx * x + c, tx * y - s * z, tx * z + s * y, 0,
655
+ tx * y + s * z, ty * y + c, ty * z - s * x, 0,
656
+ tx * z - s * y, ty * z + s * x, t * z * z + c, 0,
657
+ 0, 0, 0, 1
658
+
659
+ );
660
+
661
+ return this;
662
+
663
+ }
664
+
665
+ // makeScale(x, y, z) {
666
+
667
+ // this.set(
668
+
669
+ // x, 0, 0, 0,
670
+ // 0, y, 0, 0,
671
+ // 0, 0, z, 0,
672
+ // 0, 0, 0, 1
673
+
674
+ // );
675
+
676
+ // return this;
677
+
678
+ // }
679
+
680
+ // makeShear(xy, xz, yx, yz, zx, zy) {
681
+
682
+ // this.set(
683
+
684
+ // 1, yx, zx, 0,
685
+ // xy, 1, zy, 0,
686
+ // xz, yz, 1, 0,
687
+ // 0, 0, 0, 1
688
+
689
+ // );
690
+
691
+ // return this;
692
+
693
+ // }
694
+
695
+ // compose(position, quaternion, scale) {
696
+
697
+ // const te = this.elements;
698
+
699
+ // const x = quaternion._x, y = quaternion._y, z = quaternion._z, w = quaternion._w;
700
+ // const x2 = x + x, y2 = y + y, z2 = z + z;
701
+ // const xx = x * x2, xy = x * y2, xz = x * z2;
702
+ // const yy = y * y2, yz = y * z2, zz = z * z2;
703
+ // const wx = w * x2, wy = w * y2, wz = w * z2;
704
+
705
+ // const sx = scale.x, sy = scale.y, sz = scale.z;
706
+
707
+ // te[0] = (1 - (yy + zz)) * sx;
708
+ // te[1] = (xy + wz) * sx;
709
+ // te[2] = (xz - wy) * sx;
710
+ // te[3] = 0;
711
+
712
+ // te[4] = (xy - wz) * sy;
713
+ // te[5] = (1 - (xx + zz)) * sy;
714
+ // te[6] = (yz + wx) * sy;
715
+ // te[7] = 0;
716
+
717
+ // te[8] = (xz + wy) * sz;
718
+ // te[9] = (yz - wx) * sz;
719
+ // te[10] = (1 - (xx + yy)) * sz;
720
+ // te[11] = 0;
721
+
722
+ // te[12] = position.x;
723
+ // te[13] = position.y;
724
+ // te[14] = position.z;
725
+ // te[15] = 1;
726
+
727
+ // return this;
728
+
729
+ // }
730
+
731
+ // decompose(position, quaternion, scale) {
732
+
733
+ // const te = this.elements;
734
+
735
+ // let sx = _v1.set(te[0], te[1], te[2]).length();
736
+ // const sy = _v1.set(te[4], te[5], te[6]).length();
737
+ // const sz = _v1.set(te[8], te[9], te[10]).length();
738
+
739
+ // // if determine is negative, we need to invert one scale
740
+ // const det = this.determinant();
741
+ // if (det < 0) sx = -sx;
742
+
743
+ // position.x = te[12];
744
+ // position.y = te[13];
745
+ // position.z = te[14];
746
+
747
+ // // scale the rotation part
748
+ // _m1.copy(this);
749
+
750
+ // const invSX = 1 / sx;
751
+ // const invSY = 1 / sy;
752
+ // const invSZ = 1 / sz;
753
+
754
+ // _m1.elements[0] *= invSX;
755
+ // _m1.elements[1] *= invSX;
756
+ // _m1.elements[2] *= invSX;
757
+
758
+ // _m1.elements[4] *= invSY;
759
+ // _m1.elements[5] *= invSY;
760
+ // _m1.elements[6] *= invSY;
761
+
762
+ // _m1.elements[8] *= invSZ;
763
+ // _m1.elements[9] *= invSZ;
764
+ // _m1.elements[10] *= invSZ;
765
+
766
+ // quaternion.setFromRotationMatrix(_m1);
767
+
768
+ // scale.x = sx;
769
+ // scale.y = sy;
770
+ // scale.z = sz;
771
+
772
+ // return this;
773
+
774
+ // }
775
+
776
+ // makePerspective(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem) {
777
+
778
+ // const te = this.elements;
779
+ // const x = 2 * near / (right - left);
780
+ // const y = 2 * near / (top - bottom);
781
+
782
+ // const a = (right + left) / (right - left);
783
+ // const b = (top + bottom) / (top - bottom);
784
+
785
+ // let c, d;
786
+
787
+ // if (coordinateSystem === WebGLCoordinateSystem) {
788
+
789
+ // c = - (far + near) / (far - near);
790
+ // d = (- 2 * far * near) / (far - near);
791
+
792
+ // } else if (coordinateSystem === WebGPUCoordinateSystem) {
793
+
794
+ // c = - far / (far - near);
795
+ // d = (- far * near) / (far - near);
796
+
797
+ // } else {
798
+
799
+ // throw new Error('THREE.Matrix4.makePerspective(): Invalid coordinate system: ' + coordinateSystem);
800
+
801
+ // }
802
+
803
+ // te[0] = x; te[4] = 0; te[8] = a; te[12] = 0;
804
+ // te[1] = 0; te[5] = y; te[9] = b; te[13] = 0;
805
+ // te[2] = 0; te[6] = 0; te[10] = c; te[14] = d;
806
+ // te[3] = 0; te[7] = 0; te[11] = - 1; te[15] = 0;
807
+
808
+ // return this;
809
+
810
+ // }
811
+
812
+ // makeOrthographic(left, right, top, bottom, near, far, coordinateSystem = WebGLCoordinateSystem) {
813
+
814
+ // const te = this.elements;
815
+ // const w = 1.0 / (right - left);
816
+ // const h = 1.0 / (top - bottom);
817
+ // const p = 1.0 / (far - near);
818
+
819
+ // const x = (right + left) * w;
820
+ // const y = (top + bottom) * h;
821
+
822
+ // let z, zInv;
823
+
824
+ // if (coordinateSystem === WebGLCoordinateSystem) {
825
+
826
+ // z = (far + near) * p;
827
+ // zInv = - 2 * p;
828
+
829
+ // } else if (coordinateSystem === WebGPUCoordinateSystem) {
830
+
831
+ // z = near * p;
832
+ // zInv = - 1 * p;
833
+
834
+ // } else {
835
+
836
+ // throw new Error('THREE.Matrix4.makeOrthographic(): Invalid coordinate system: ' + coordinateSystem);
837
+
838
+ // }
839
+
840
+ // te[0] = 2 * w; te[4] = 0; te[8] = 0; te[12] = - x;
841
+ // te[1] = 0; te[5] = 2 * h; te[9] = 0; te[13] = - y;
842
+ // te[2] = 0; te[6] = 0; te[10] = zInv; te[14] = - z;
843
+ // te[3] = 0; te[7] = 0; te[11] = 0; te[15] = 1;
844
+
845
+ // return this;
846
+
847
+ // }
848
+
849
+ equals(matrix) {
850
+
851
+ const te = this.elements;
852
+ const me = matrix.elements;
853
+
854
+ for (let i = 0; i < 16; i++) {
855
+
856
+ if (te[i] !== me[i]) return false;
857
+
858
+ }
859
+
860
+ return true;
861
+
862
+ }
863
+
864
+ // fromArray(array, offset = 0) {
865
+
866
+ // for (let i = 0; i < 16; i++) {
867
+
868
+ // this.elements[i] = array[i + offset];
869
+
870
+ // }
871
+
872
+ // return this;
873
+
874
+ // }
875
+
876
+ // toArray(array = [], offset = 0) {
877
+
878
+ // const te = this.elements;
879
+
880
+ // array[offset] = te[0];
881
+ // array[offset + 1] = te[1];
882
+ // array[offset + 2] = te[2];
883
+ // array[offset + 3] = te[3];
884
+
885
+ // array[offset + 4] = te[4];
886
+ // array[offset + 5] = te[5];
887
+ // array[offset + 6] = te[6];
888
+ // array[offset + 7] = te[7];
889
+
890
+ // array[offset + 8] = te[8];
891
+ // array[offset + 9] = te[9];
892
+ // array[offset + 10] = te[10];
893
+ // array[offset + 11] = te[11];
894
+
895
+ // array[offset + 12] = te[12];
896
+ // array[offset + 13] = te[13];
897
+ // array[offset + 14] = te[14];
898
+ // array[offset + 15] = te[15];
899
+
900
+ // return array;
901
+
902
+ // }
903
+
904
+ }
905
+
906
+ // const _v1 = new Vector3();
907
+ // const _m1 = new Matrix4();
908
+ // const _zero = new Vector3(0, 0, 0);
909
+ // const _one = new Vector3(1, 1, 1);
910
+ // const _x = new Vector3();
911
+ // const _y = new Vector3();
912
+ // const _z = new Vector3();
913
+
914
+ export { Matrix4 };