@mlightcad/geometry-engine 3.2.36 → 3.2.37

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.
@@ -1,3909 +0,0 @@
1
- import { AcCmErrors as U } from "@mlightcad/common";
2
- const N = [
3
- "00",
4
- "01",
5
- "02",
6
- "03",
7
- "04",
8
- "05",
9
- "06",
10
- "07",
11
- "08",
12
- "09",
13
- "0a",
14
- "0b",
15
- "0c",
16
- "0d",
17
- "0e",
18
- "0f",
19
- "10",
20
- "11",
21
- "12",
22
- "13",
23
- "14",
24
- "15",
25
- "16",
26
- "17",
27
- "18",
28
- "19",
29
- "1a",
30
- "1b",
31
- "1c",
32
- "1d",
33
- "1e",
34
- "1f",
35
- "20",
36
- "21",
37
- "22",
38
- "23",
39
- "24",
40
- "25",
41
- "26",
42
- "27",
43
- "28",
44
- "29",
45
- "2a",
46
- "2b",
47
- "2c",
48
- "2d",
49
- "2e",
50
- "2f",
51
- "30",
52
- "31",
53
- "32",
54
- "33",
55
- "34",
56
- "35",
57
- "36",
58
- "37",
59
- "38",
60
- "39",
61
- "3a",
62
- "3b",
63
- "3c",
64
- "3d",
65
- "3e",
66
- "3f",
67
- "40",
68
- "41",
69
- "42",
70
- "43",
71
- "44",
72
- "45",
73
- "46",
74
- "47",
75
- "48",
76
- "49",
77
- "4a",
78
- "4b",
79
- "4c",
80
- "4d",
81
- "4e",
82
- "4f",
83
- "50",
84
- "51",
85
- "52",
86
- "53",
87
- "54",
88
- "55",
89
- "56",
90
- "57",
91
- "58",
92
- "59",
93
- "5a",
94
- "5b",
95
- "5c",
96
- "5d",
97
- "5e",
98
- "5f",
99
- "60",
100
- "61",
101
- "62",
102
- "63",
103
- "64",
104
- "65",
105
- "66",
106
- "67",
107
- "68",
108
- "69",
109
- "6a",
110
- "6b",
111
- "6c",
112
- "6d",
113
- "6e",
114
- "6f",
115
- "70",
116
- "71",
117
- "72",
118
- "73",
119
- "74",
120
- "75",
121
- "76",
122
- "77",
123
- "78",
124
- "79",
125
- "7a",
126
- "7b",
127
- "7c",
128
- "7d",
129
- "7e",
130
- "7f",
131
- "80",
132
- "81",
133
- "82",
134
- "83",
135
- "84",
136
- "85",
137
- "86",
138
- "87",
139
- "88",
140
- "89",
141
- "8a",
142
- "8b",
143
- "8c",
144
- "8d",
145
- "8e",
146
- "8f",
147
- "90",
148
- "91",
149
- "92",
150
- "93",
151
- "94",
152
- "95",
153
- "96",
154
- "97",
155
- "98",
156
- "99",
157
- "9a",
158
- "9b",
159
- "9c",
160
- "9d",
161
- "9e",
162
- "9f",
163
- "a0",
164
- "a1",
165
- "a2",
166
- "a3",
167
- "a4",
168
- "a5",
169
- "a6",
170
- "a7",
171
- "a8",
172
- "a9",
173
- "aa",
174
- "ab",
175
- "ac",
176
- "ad",
177
- "ae",
178
- "af",
179
- "b0",
180
- "b1",
181
- "b2",
182
- "b3",
183
- "b4",
184
- "b5",
185
- "b6",
186
- "b7",
187
- "b8",
188
- "b9",
189
- "ba",
190
- "bb",
191
- "bc",
192
- "bd",
193
- "be",
194
- "bf",
195
- "c0",
196
- "c1",
197
- "c2",
198
- "c3",
199
- "c4",
200
- "c5",
201
- "c6",
202
- "c7",
203
- "c8",
204
- "c9",
205
- "ca",
206
- "cb",
207
- "cc",
208
- "cd",
209
- "ce",
210
- "cf",
211
- "d0",
212
- "d1",
213
- "d2",
214
- "d3",
215
- "d4",
216
- "d5",
217
- "d6",
218
- "d7",
219
- "d8",
220
- "d9",
221
- "da",
222
- "db",
223
- "dc",
224
- "dd",
225
- "de",
226
- "df",
227
- "e0",
228
- "e1",
229
- "e2",
230
- "e3",
231
- "e4",
232
- "e5",
233
- "e6",
234
- "e7",
235
- "e8",
236
- "e9",
237
- "ea",
238
- "eb",
239
- "ec",
240
- "ed",
241
- "ee",
242
- "ef",
243
- "f0",
244
- "f1",
245
- "f2",
246
- "f3",
247
- "f4",
248
- "f5",
249
- "f6",
250
- "f7",
251
- "f8",
252
- "f9",
253
- "fa",
254
- "fb",
255
- "fc",
256
- "fd",
257
- "fe",
258
- "ff"
259
- ];
260
- let jt = 1234567;
261
- const Qt = Math.PI / 180, Kt = 180 / Math.PI;
262
- function hs() {
263
- const u = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, s = Math.random() * 4294967295 | 0, e = Math.random() * 4294967295 | 0;
264
- return (N[u & 255] + N[u >> 8 & 255] + N[u >> 16 & 255] + N[u >> 24 & 255] + "-" + N[t & 255] + N[t >> 8 & 255] + "-" + N[t >> 16 & 15 | 64] + N[t >> 24 & 255] + "-" + N[s & 63 | 128] + N[s >> 8 & 255] + "-" + N[s >> 16 & 255] + N[s >> 24 & 255] + N[e & 255] + N[e >> 8 & 255] + N[e >> 16 & 255] + N[e >> 24 & 255]).toLowerCase();
265
- }
266
- function Z(u, t, s) {
267
- return Math.max(t, Math.min(s, u));
268
- }
269
- function $t(u, t) {
270
- return (u % t + t) % t;
271
- }
272
- function as(u, t, s, e, n) {
273
- return e + (u - t) * (n - e) / (s - t);
274
- }
275
- function cs(u, t, s) {
276
- return u !== t ? (s - u) / (t - u) : 0;
277
- }
278
- function Wt(u, t, s) {
279
- return (1 - s) * u + s * t;
280
- }
281
- function ls(u, t, s, e) {
282
- return Wt(u, t, 1 - Math.exp(-s * e));
283
- }
284
- function us(u, t = 1) {
285
- return t - Math.abs($t(u, t * 2) - t);
286
- }
287
- function ds(u, t, s) {
288
- return u <= t ? 0 : u >= s ? 1 : (u = (u - t) / (s - t), u * u * (3 - 2 * u));
289
- }
290
- function ms(u, t, s) {
291
- return u <= t ? 0 : u >= s ? 1 : (u = (u - t) / (s - t), u * u * u * (u * (u * 6 - 15) + 10));
292
- }
293
- function xs(u, t) {
294
- return u + Math.floor(Math.random() * (t - u + 1));
295
- }
296
- function gs(u, t) {
297
- return u + Math.random() * (t - u);
298
- }
299
- function ys(u) {
300
- return u * (0.5 - Math.random());
301
- }
302
- function _s(u) {
303
- u !== void 0 && (jt = u);
304
- let t = jt += 1831565813;
305
- return t = Math.imul(t ^ t >>> 15, t | 1), t ^= t + Math.imul(t ^ t >>> 7, t | 61), ((t ^ t >>> 14) >>> 0) / 4294967296;
306
- }
307
- function ps(u) {
308
- return u * Qt;
309
- }
310
- function fs(u) {
311
- return u * Kt;
312
- }
313
- function As(u) {
314
- return (u & u - 1) === 0 && u !== 0;
315
- }
316
- function ws(u) {
317
- return Math.pow(2, Math.ceil(Math.log(u) / Math.LN2));
318
- }
319
- function zs(u) {
320
- return Math.pow(2, Math.floor(Math.log(u) / Math.LN2));
321
- }
322
- function pt(u) {
323
- const t = Math.PI * 2;
324
- return (u % t + t) % t;
325
- }
326
- function Ms(u, t, s) {
327
- return u > t && u < s || u > s && u < t;
328
- }
329
- function Ps(u, t, s, e = !1) {
330
- return u = pt(u), t = pt(t), s = pt(s), e ? t > s ? u <= t && u >= s : u <= t || u >= s : t < s ? u >= t && u <= s : u >= t || u <= s;
331
- }
332
- function Ht(u) {
333
- return u = Math.abs(u), u < 1 ? 0 : Math.ceil(Math.log10(Math.abs(u) + 1));
334
- }
335
- function bs(u, t = 1e-7) {
336
- const s = Ht(u);
337
- return Math.max(Math.pow(10, s) * t, t);
338
- }
339
- const M = {
340
- DEG2RAD: Qt,
341
- RAD2DEG: Kt,
342
- generateUUID: hs,
343
- clamp: Z,
344
- euclideanModulo: $t,
345
- mapLinear: as,
346
- inverseLerp: cs,
347
- lerp: Wt,
348
- damp: ls,
349
- pingpong: us,
350
- smoothstep: ds,
351
- smootherstep: ms,
352
- randInt: xs,
353
- randFloat: gs,
354
- randFloatSpread: ys,
355
- seededRandom: _s,
356
- degToRad: ps,
357
- radToDeg: fs,
358
- isPowerOfTwo: As,
359
- ceilPowerOfTwo: ws,
360
- floorPowerOfTwo: zs,
361
- normalizeAngle: pt,
362
- isBetween: Ms,
363
- isBetweenAngle: Ps,
364
- intPartLength: Ht,
365
- relativeEps: bs
366
- }, tt = class tt {
367
- constructor(t, s) {
368
- this.x = 0, this.y = 0;
369
- const e = +(t !== void 0) + +(s !== void 0);
370
- if (e !== 0) {
371
- if (e === 1 && t instanceof Array) {
372
- this.x = t[0], this.y = t[1];
373
- return;
374
- }
375
- if (e === 1) {
376
- const { x: n, y: i } = t;
377
- this.x = n, this.y = i;
378
- return;
379
- }
380
- if (e === 2) {
381
- this.x = t, this.y = s;
382
- return;
383
- }
384
- throw U.ILLEGAL_PARAMETERS;
385
- }
386
- }
387
- get width() {
388
- return this.x;
389
- }
390
- set width(t) {
391
- this.x = t;
392
- }
393
- get height() {
394
- return this.y;
395
- }
396
- set height(t) {
397
- this.y = t;
398
- }
399
- set(t, s) {
400
- return this.x = t, this.y = s, this;
401
- }
402
- setScalar(t) {
403
- return this.x = t, this.y = t, this;
404
- }
405
- setX(t) {
406
- return this.x = t, this;
407
- }
408
- setY(t) {
409
- return this.y = t, this;
410
- }
411
- setComponent(t, s) {
412
- switch (t) {
413
- case 0:
414
- this.x = s;
415
- break;
416
- case 1:
417
- this.y = s;
418
- break;
419
- default:
420
- throw new Error("index is out of range: " + t);
421
- }
422
- return this;
423
- }
424
- getComponent(t) {
425
- switch (t) {
426
- case 0:
427
- return this.x;
428
- case 1:
429
- return this.y;
430
- default:
431
- throw new Error("index is out of range: " + t);
432
- }
433
- }
434
- clone() {
435
- return new tt(this.x, this.y);
436
- }
437
- copy(t) {
438
- return this.x = t.x, this.y = t.y, this;
439
- }
440
- add(t) {
441
- return this.x += t.x, this.y += t.y, this;
442
- }
443
- addScalar(t) {
444
- return this.x += t, this.y += t, this;
445
- }
446
- addVectors(t, s) {
447
- return this.x = t.x + s.x, this.y = t.y + s.y, this;
448
- }
449
- addScaledVector(t, s) {
450
- return this.x += t.x * s, this.y += t.y * s, this;
451
- }
452
- sub(t) {
453
- return this.x -= t.x, this.y -= t.y, this;
454
- }
455
- subScalar(t) {
456
- return this.x -= t, this.y -= t, this;
457
- }
458
- subVectors(t, s) {
459
- return this.x = t.x - s.x, this.y = t.y - s.y, this;
460
- }
461
- multiply(t) {
462
- return this.x *= t.x, this.y *= t.y, this;
463
- }
464
- multiplyScalar(t) {
465
- return this.x *= t, this.y *= t, this;
466
- }
467
- divide(t) {
468
- return this.x /= t.x, this.y /= t.y, this;
469
- }
470
- divideScalar(t) {
471
- return this.multiplyScalar(1 / t);
472
- }
473
- applyMatrix2d(t) {
474
- const s = this.x, e = this.y, n = t.elements;
475
- return this.x = n[0] * s + n[3] * e + n[6], this.y = n[1] * s + n[4] * e + n[7], this;
476
- }
477
- min(t) {
478
- return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this;
479
- }
480
- max(t) {
481
- return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this;
482
- }
483
- clamp(t, s) {
484
- return this.x = Math.max(t.x, Math.min(s.x, this.x)), this.y = Math.max(t.y, Math.min(s.y, this.y)), this;
485
- }
486
- clampScalar(t, s) {
487
- return this.x = Math.max(t, Math.min(s, this.x)), this.y = Math.max(t, Math.min(s, this.y)), this;
488
- }
489
- clampLength(t, s) {
490
- const e = this.length();
491
- return this.divideScalar(e || 1).multiplyScalar(
492
- Math.max(t, Math.min(s, e))
493
- );
494
- }
495
- floor() {
496
- return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this;
497
- }
498
- ceil() {
499
- return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this;
500
- }
501
- round() {
502
- return this.x = Math.round(this.x), this.y = Math.round(this.y), this;
503
- }
504
- roundToZero() {
505
- return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this;
506
- }
507
- negate() {
508
- return this.x = -this.x, this.y = -this.y, this;
509
- }
510
- dot(t) {
511
- return this.x * t.x + this.y * t.y;
512
- }
513
- cross(t) {
514
- return this.x * t.y - this.y * t.x;
515
- }
516
- lengthSq() {
517
- return this.x * this.x + this.y * this.y;
518
- }
519
- length() {
520
- return Math.sqrt(this.x * this.x + this.y * this.y);
521
- }
522
- manhattanLength() {
523
- return Math.abs(this.x) + Math.abs(this.y);
524
- }
525
- normalize() {
526
- return this.divideScalar(this.length() || 1);
527
- }
528
- angle() {
529
- return Math.atan2(-this.y, -this.x) + Math.PI;
530
- }
531
- angleTo(t) {
532
- const s = Math.sqrt(this.lengthSq() * t.lengthSq());
533
- if (s === 0) return Math.PI / 2;
534
- const e = this.dot(t) / s;
535
- return Math.acos(Math.max(-1, Math.min(1, e)));
536
- }
537
- distanceTo(t) {
538
- return Math.sqrt(this.distanceToSquared(t));
539
- }
540
- distanceToSquared(t) {
541
- const s = this.x - t.x, e = this.y - t.y;
542
- return s * s + e * e;
543
- }
544
- manhattanDistanceTo(t) {
545
- return Math.abs(this.x - t.x) + Math.abs(this.y - t.y);
546
- }
547
- setLength(t) {
548
- return this.normalize().multiplyScalar(t);
549
- }
550
- lerp(t, s) {
551
- return this.x += (t.x - this.x) * s, this.y += (t.y - this.y) * s, this;
552
- }
553
- lerpVectors(t, s, e) {
554
- return this.x = t.x + (s.x - t.x) * e, this.y = t.y + (s.y - t.y) * e, this;
555
- }
556
- equals(t) {
557
- return t.x === this.x && t.y === this.y;
558
- }
559
- fromArray(t, s = 0) {
560
- return this.x = t[s], this.y = t[s + 1], this;
561
- }
562
- toArray(t = [], s = 0) {
563
- return t[s] = this.x, t[s + 1] = this.y, t;
564
- }
565
- rotateAround(t, s) {
566
- const e = Math.cos(s), n = Math.sin(s), i = this.x - t.x, r = this.y - t.y;
567
- return this.x = i * e - r * n + t.x, this.y = i * n + r * e + t.y, this;
568
- }
569
- random() {
570
- return this.x = Math.random(), this.y = Math.random(), this;
571
- }
572
- relativeEps(t = 1e-7) {
573
- return Math.min(
574
- M.relativeEps(this.x, t),
575
- M.relativeEps(this.y, t)
576
- );
577
- }
578
- *[Symbol.iterator]() {
579
- yield this.x, yield this.y;
580
- }
581
- };
582
- tt.EMPTY = Object.freeze(new tt(0, 0));
583
- let B = tt;
584
- const st = class st {
585
- constructor(t, s, e, n, i, r, o, a, h) {
586
- this.elements = [1, 0, 0, 0, 1, 0, 0, 0, 1], t != null && s != null && e != null && n != null && i != null && r != null && o != null && a != null && h != null && this.set(t, s, e, n, i, r, o, a, h);
587
- }
588
- set(t, s, e, n, i, r, o, a, h) {
589
- const c = this.elements;
590
- return c[0] = t, c[1] = n, c[2] = o, c[3] = s, c[4] = i, c[5] = a, c[6] = e, c[7] = r, c[8] = h, this;
591
- }
592
- identity() {
593
- return this.set(1, 0, 0, 0, 1, 0, 0, 0, 1), this;
594
- }
595
- copy(t) {
596
- const s = this.elements, e = t.elements;
597
- return s[0] = e[0], s[1] = e[1], s[2] = e[2], s[3] = e[3], s[4] = e[4], s[5] = e[5], s[6] = e[6], s[7] = e[7], s[8] = e[8], this;
598
- }
599
- extractBasis(t, s, e) {
600
- return t.setFromMatrix3Column(this, 0), s.setFromMatrix3Column(this, 1), e.setFromMatrix3Column(this, 2), this;
601
- }
602
- setFromMatrix4(t) {
603
- const s = t.elements;
604
- return this.set(s[0], s[4], s[8], s[1], s[5], s[9], s[2], s[6], s[10]), this;
605
- }
606
- multiply(t) {
607
- return this.multiplyMatrices(this, t);
608
- }
609
- premultiply(t) {
610
- return this.multiplyMatrices(t, this);
611
- }
612
- multiplyMatrices(t, s) {
613
- const e = t.elements, n = s.elements, i = this.elements, r = e[0], o = e[3], a = e[6], h = e[1], c = e[4], l = e[7], m = e[2], d = e[5], x = e[8], g = n[0], y = n[3], p = n[6], z = n[1], f = n[4], b = n[7], P = n[2], I = n[5], A = n[8];
614
- return i[0] = r * g + o * z + a * P, i[3] = r * y + o * f + a * I, i[6] = r * p + o * b + a * A, i[1] = h * g + c * z + l * P, i[4] = h * y + c * f + l * I, i[7] = h * p + c * b + l * A, i[2] = m * g + d * z + x * P, i[5] = m * y + d * f + x * I, i[8] = m * p + d * b + x * A, this;
615
- }
616
- multiplyScalar(t) {
617
- const s = this.elements;
618
- return s[0] *= t, s[3] *= t, s[6] *= t, s[1] *= t, s[4] *= t, s[7] *= t, s[2] *= t, s[5] *= t, s[8] *= t, this;
619
- }
620
- determinant() {
621
- const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], r = t[4], o = t[5], a = t[6], h = t[7], c = t[8];
622
- return s * r * c - s * o * h - e * i * c + e * o * a + n * i * h - n * r * a;
623
- }
624
- invert() {
625
- const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], r = t[4], o = t[5], a = t[6], h = t[7], c = t[8], l = c * r - o * h, m = o * a - c * i, d = h * i - r * a, x = s * l + e * m + n * d;
626
- if (x === 0) return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0);
627
- const g = 1 / x;
628
- return t[0] = l * g, t[1] = (n * h - c * e) * g, t[2] = (o * e - n * r) * g, t[3] = m * g, t[4] = (c * s - n * a) * g, t[5] = (n * i - o * s) * g, t[6] = d * g, t[7] = (e * a - h * s) * g, t[8] = (r * s - e * i) * g, this;
629
- }
630
- transpose() {
631
- let t;
632
- const s = this.elements;
633
- return t = s[1], s[1] = s[3], s[3] = t, t = s[2], s[2] = s[6], s[6] = t, t = s[5], s[5] = s[7], s[7] = t, this;
634
- }
635
- getNormalMatrix(t) {
636
- return this.setFromMatrix4(t).invert().transpose();
637
- }
638
- transposeIntoArray(t) {
639
- const s = this.elements;
640
- return t.elements[0] = s[0], t.elements[1] = s[3], t.elements[2] = s[6], t.elements[3] = s[1], t.elements[4] = s[4], t.elements[5] = s[7], t.elements[6] = s[2], t.elements[7] = s[5], t.elements[8] = s[8], this;
641
- }
642
- setUvTransform(t, s, e, n, i, r, o) {
643
- const a = Math.cos(i), h = Math.sin(i);
644
- return this.set(
645
- e * a,
646
- e * h,
647
- -e * (a * r + h * o) + r + t,
648
- -n * h,
649
- n * a,
650
- -n * (-h * r + a * o) + o + s,
651
- 0,
652
- 0,
653
- 1
654
- ), this;
655
- }
656
- scale(t, s) {
657
- return this.premultiply(Et.makeScale(t, s)), this;
658
- }
659
- rotate(t) {
660
- return this.premultiply(Et.makeRotation(-t)), this;
661
- }
662
- translate(t, s) {
663
- return this.premultiply(Et.makeTranslation(t, s)), this;
664
- }
665
- makeTranslation(t, s) {
666
- return t instanceof B ? this.set(1, 0, t.x, 0, 1, t.y, 0, 0, 1) : this.set(1, 0, t, 0, 1, s, 0, 0, 1), this;
667
- }
668
- makeRotation(t) {
669
- const s = Math.cos(t), e = Math.sin(t);
670
- return this.set(s, -e, 0, e, s, 0, 0, 0, 1), this;
671
- }
672
- makeScale(t, s) {
673
- return this.set(t, 0, 0, 0, s, 0, 0, 0, 1), this;
674
- }
675
- equals(t) {
676
- const s = this.elements, e = t.elements;
677
- for (let n = 0; n < 9; n++)
678
- if (s[n] !== e[n]) return !1;
679
- return !0;
680
- }
681
- fromArray(t, s = 0) {
682
- for (let e = 0; e < 9; e++)
683
- this.elements[e] = t[e + s];
684
- return this;
685
- }
686
- toArray(t = [], s = 0) {
687
- const e = this.elements;
688
- return t[s] = e[0], t[s + 1] = e[1], t[s + 2] = e[2], t[s + 3] = e[3], t[s + 4] = e[4], t[s + 5] = e[5], t[s + 6] = e[6], t[s + 7] = e[7], t[s + 8] = e[8], t;
689
- }
690
- clone() {
691
- return new st().fromArray(this.elements);
692
- }
693
- };
694
- st.IDENTITY = Object.freeze(new st());
695
- let it = st;
696
- const Et = new it(), H = 1e-6, E = 2 * Math.PI, Ls = {
697
- x: 0,
698
- y: 0
699
- }, Jt = {
700
- x: 0,
701
- y: 0,
702
- z: 0
703
- };
704
- class bt {
705
- constructor() {
706
- this.equalPointTol = H, this.equalVectorTol = H;
707
- }
708
- clone() {
709
- const t = new bt();
710
- return t.equalPointTol = this.equalPointTol, t.equalVectorTol = this.equalVectorTol, t;
711
- }
712
- equalPoint2d(t, s) {
713
- return new B(t).sub(s).length() < this.equalPointTol;
714
- }
715
- equalPoint3d(t, s) {
716
- return new _(t).sub(s).length() < this.equalPointTol;
717
- }
718
- static equalToZero(t, s = H) {
719
- return t < s && t > -s;
720
- }
721
- static equal(t, s, e = H) {
722
- return Math.abs(t - s) < e;
723
- }
724
- static great(t, s, e = H) {
725
- return t - s > e;
726
- }
727
- static less(t, s, e = H) {
728
- return t - s < e;
729
- }
730
- }
731
- const Gt = new bt();
732
- class St {
733
- constructor(t = 0, s = 0, e = 0, n = 1) {
734
- this._x = t, this._y = s, this._z = e, this._w = n;
735
- }
736
- static slerpFlat(t, s, e, n, i, r, o) {
737
- let a = e[n + 0], h = e[n + 1], c = e[n + 2], l = e[n + 3];
738
- const m = i[r + 0], d = i[r + 1], x = i[r + 2], g = i[r + 3];
739
- if (o === 0) {
740
- t[s + 0] = a, t[s + 1] = h, t[s + 2] = c, t[s + 3] = l;
741
- return;
742
- }
743
- if (o === 1) {
744
- t[s + 0] = m, t[s + 1] = d, t[s + 2] = x, t[s + 3] = g;
745
- return;
746
- }
747
- if (l !== g || a !== m || h !== d || c !== x) {
748
- let y = 1 - o;
749
- const p = a * m + h * d + c * x + l * g, z = p >= 0 ? 1 : -1, f = 1 - p * p;
750
- if (f > Number.EPSILON) {
751
- const P = Math.sqrt(f), I = Math.atan2(P, p * z);
752
- y = Math.sin(y * I) / P, o = Math.sin(o * I) / P;
753
- }
754
- const b = o * z;
755
- if (a = a * y + m * b, h = h * y + d * b, c = c * y + x * b, l = l * y + g * b, y === 1 - o) {
756
- const P = 1 / Math.sqrt(a * a + h * h + c * c + l * l);
757
- a *= P, h *= P, c *= P, l *= P;
758
- }
759
- }
760
- t[s] = a, t[s + 1] = h, t[s + 2] = c, t[s + 3] = l;
761
- }
762
- static multiplyQuaternionsFlat(t, s, e, n, i, r) {
763
- const o = e[n], a = e[n + 1], h = e[n + 2], c = e[n + 3], l = i[r], m = i[r + 1], d = i[r + 2], x = i[r + 3];
764
- return t[s] = o * x + c * l + a * d - h * m, t[s + 1] = a * x + c * m + h * l - o * d, t[s + 2] = h * x + c * d + o * m - a * l, t[s + 3] = c * x - o * l - a * m - h * d, t;
765
- }
766
- get x() {
767
- return this._x;
768
- }
769
- set x(t) {
770
- this._x = t, this._onChangeCallback();
771
- }
772
- get y() {
773
- return this._y;
774
- }
775
- set y(t) {
776
- this._y = t, this._onChangeCallback();
777
- }
778
- get z() {
779
- return this._z;
780
- }
781
- set z(t) {
782
- this._z = t, this._onChangeCallback();
783
- }
784
- get w() {
785
- return this._w;
786
- }
787
- set w(t) {
788
- this._w = t, this._onChangeCallback();
789
- }
790
- set(t, s, e, n) {
791
- return this._x = t, this._y = s, this._z = e, this._w = n, this._onChangeCallback(), this;
792
- }
793
- clone() {
794
- return new St(this._x, this._y, this._z, this._w);
795
- }
796
- copy(t) {
797
- return this._x = t.x, this._y = t.y, this._z = t.z, this._w = t.w, this._onChangeCallback(), this;
798
- }
799
- setFromEuler(t, s = !0) {
800
- const e = t.x, n = t.y, i = t.z, r = t.order, o = Math.cos, a = Math.sin, h = o(e / 2), c = o(n / 2), l = o(i / 2), m = a(e / 2), d = a(n / 2), x = a(i / 2);
801
- switch (r) {
802
- case "XYZ":
803
- this._x = m * c * l + h * d * x, this._y = h * d * l - m * c * x, this._z = h * c * x + m * d * l, this._w = h * c * l - m * d * x;
804
- break;
805
- case "YXZ":
806
- this._x = m * c * l + h * d * x, this._y = h * d * l - m * c * x, this._z = h * c * x - m * d * l, this._w = h * c * l + m * d * x;
807
- break;
808
- case "ZXY":
809
- this._x = m * c * l - h * d * x, this._y = h * d * l + m * c * x, this._z = h * c * x + m * d * l, this._w = h * c * l - m * d * x;
810
- break;
811
- case "ZYX":
812
- this._x = m * c * l - h * d * x, this._y = h * d * l + m * c * x, this._z = h * c * x - m * d * l, this._w = h * c * l + m * d * x;
813
- break;
814
- case "YZX":
815
- this._x = m * c * l + h * d * x, this._y = h * d * l + m * c * x, this._z = h * c * x - m * d * l, this._w = h * c * l - m * d * x;
816
- break;
817
- case "XZY":
818
- this._x = m * c * l - h * d * x, this._y = h * d * l - m * c * x, this._z = h * c * x + m * d * l, this._w = h * c * l + m * d * x;
819
- break;
820
- }
821
- return s === !0 && this._onChangeCallback(), this;
822
- }
823
- setFromAxisAngle(t, s) {
824
- const e = s / 2, n = Math.sin(e);
825
- return this._x = t.x * n, this._y = t.y * n, this._z = t.z * n, this._w = Math.cos(e), this._onChangeCallback(), this;
826
- }
827
- setFromRotationMatrix(t) {
828
- const s = t.elements, e = s[0], n = s[4], i = s[8], r = s[1], o = s[5], a = s[9], h = s[2], c = s[6], l = s[10], m = e + o + l;
829
- if (m > 0) {
830
- const d = 0.5 / Math.sqrt(m + 1);
831
- this._w = 0.25 / d, this._x = (c - a) * d, this._y = (i - h) * d, this._z = (r - n) * d;
832
- } else if (e > o && e > l) {
833
- const d = 2 * Math.sqrt(1 + e - o - l);
834
- this._w = (c - a) / d, this._x = 0.25 * d, this._y = (n + r) / d, this._z = (i + h) / d;
835
- } else if (o > l) {
836
- const d = 2 * Math.sqrt(1 + o - e - l);
837
- this._w = (i - h) / d, this._x = (n + r) / d, this._y = 0.25 * d, this._z = (a + c) / d;
838
- } else {
839
- const d = 2 * Math.sqrt(1 + l - e - o);
840
- this._w = (r - n) / d, this._x = (i + h) / d, this._y = (a + c) / d, this._z = 0.25 * d;
841
- }
842
- return this._onChangeCallback(), this;
843
- }
844
- setFromUnitVectors(t, s) {
845
- let e = t.dot(s) + 1;
846
- return e < Number.EPSILON ? (e = 0, Math.abs(t.x) > Math.abs(t.z) ? (this._x = -t.y, this._y = t.x, this._z = 0, this._w = e) : (this._x = 0, this._y = -t.z, this._z = t.y, this._w = e)) : (this._x = t.y * s.z - t.z * s.y, this._y = t.z * s.x - t.x * s.z, this._z = t.x * s.y - t.y * s.x, this._w = e), this.normalize();
847
- }
848
- angleTo(t) {
849
- return 2 * Math.acos(Math.abs(Z(this.dot(t), -1, 1)));
850
- }
851
- rotateTowards(t, s) {
852
- const e = this.angleTo(t);
853
- if (e === 0) return this;
854
- const n = Math.min(1, s / e);
855
- return this.slerp(t, n), this;
856
- }
857
- identity() {
858
- return this.set(0, 0, 0, 1);
859
- }
860
- invert() {
861
- return this.conjugate();
862
- }
863
- conjugate() {
864
- return this._x *= -1, this._y *= -1, this._z *= -1, this._onChangeCallback(), this;
865
- }
866
- dot(t) {
867
- return this._x * t._x + this._y * t._y + this._z * t._z + this._w * t._w;
868
- }
869
- lengthSq() {
870
- return this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w;
871
- }
872
- length() {
873
- return Math.sqrt(
874
- this._x * this._x + this._y * this._y + this._z * this._z + this._w * this._w
875
- );
876
- }
877
- normalize() {
878
- let t = this.length();
879
- return t === 0 ? (this._x = 0, this._y = 0, this._z = 0, this._w = 1) : (t = 1 / t, this._x = this._x * t, this._y = this._y * t, this._z = this._z * t, this._w = this._w * t), this._onChangeCallback(), this;
880
- }
881
- multiply(t) {
882
- return this.multiplyQuaternions(this, t);
883
- }
884
- premultiply(t) {
885
- return this.multiplyQuaternions(t, this);
886
- }
887
- multiplyQuaternions(t, s) {
888
- const e = t._x, n = t._y, i = t._z, r = t._w, o = s._x, a = s._y, h = s._z, c = s._w;
889
- return this._x = e * c + r * o + n * h - i * a, this._y = n * c + r * a + i * o - e * h, this._z = i * c + r * h + e * a - n * o, this._w = r * c - e * o - n * a - i * h, this._onChangeCallback(), this;
890
- }
891
- slerp(t, s) {
892
- if (s === 0) return this;
893
- if (s === 1) return this.copy(t);
894
- const e = this._x, n = this._y, i = this._z, r = this._w;
895
- let o = r * t._w + e * t._x + n * t._y + i * t._z;
896
- if (o < 0 ? (this._w = -t._w, this._x = -t._x, this._y = -t._y, this._z = -t._z, o = -o) : this.copy(t), o >= 1)
897
- return this._w = r, this._x = e, this._y = n, this._z = i, this;
898
- const a = 1 - o * o;
899
- if (a <= Number.EPSILON) {
900
- const d = 1 - s;
901
- return this._w = d * r + s * this._w, this._x = d * e + s * this._x, this._y = d * n + s * this._y, this._z = d * i + s * this._z, this.normalize(), this;
902
- }
903
- const h = Math.sqrt(a), c = Math.atan2(h, o), l = Math.sin((1 - s) * c) / h, m = Math.sin(s * c) / h;
904
- return this._w = r * l + this._w * m, this._x = e * l + this._x * m, this._y = n * l + this._y * m, this._z = i * l + this._z * m, this._onChangeCallback(), this;
905
- }
906
- slerpQuaternions(t, s, e) {
907
- return this.copy(t).slerp(s, e);
908
- }
909
- random() {
910
- const t = 2 * Math.PI * Math.random(), s = 2 * Math.PI * Math.random(), e = Math.random(), n = Math.sqrt(1 - e), i = Math.sqrt(e);
911
- return this.set(
912
- n * Math.sin(t),
913
- n * Math.cos(t),
914
- i * Math.sin(s),
915
- i * Math.cos(s)
916
- );
917
- }
918
- equals(t) {
919
- return t._x === this._x && t._y === this._y && t._z === this._z && t._w === this._w;
920
- }
921
- fromArray(t, s = 0) {
922
- return this._x = t[s], this._y = t[s + 1], this._z = t[s + 2], this._w = t[s + 3], this._onChangeCallback(), this;
923
- }
924
- toArray(t = [], s = 0) {
925
- return t[s] = this._x, t[s + 1] = this._y, t[s + 2] = this._z, t[s + 3] = this._w, t;
926
- }
927
- toJSON() {
928
- return this.toArray();
929
- }
930
- _onChange(t) {
931
- return this._onChangeCallback = t, this;
932
- }
933
- _onChangeCallback() {
934
- }
935
- *[Symbol.iterator]() {
936
- yield this._x, yield this._y, yield this._z, yield this._w;
937
- }
938
- }
939
- const R = class R {
940
- constructor(t, s, e) {
941
- this.x = 0, this.y = 0, this.z = 0;
942
- const n = +(t !== void 0) + +(s !== void 0) + +(e !== void 0);
943
- if (n !== 0) {
944
- if (n === 1 && t instanceof Array) {
945
- this.x = t[0], this.y = t[1], this.z = t[2];
946
- return;
947
- }
948
- if (n === 1) {
949
- const { x: i, y: r, z: o } = t;
950
- this.x = i, this.y = r, this.z = o || 0;
951
- return;
952
- }
953
- if (n === 3) {
954
- this.x = t, this.y = s, this.z = e;
955
- return;
956
- }
957
- throw U.ILLEGAL_PARAMETERS;
958
- }
959
- }
960
- set(t, s, e) {
961
- return e === void 0 && (e = this.z), this.x = t, this.y = s, this.z = e, this;
962
- }
963
- setScalar(t) {
964
- return this.x = t, this.y = t, this.z = t, this;
965
- }
966
- setX(t) {
967
- return this.x = t, this;
968
- }
969
- setY(t) {
970
- return this.y = t, this;
971
- }
972
- setZ(t) {
973
- return this.z = t, this;
974
- }
975
- setComponent(t, s) {
976
- switch (t) {
977
- case 0:
978
- this.x = s;
979
- break;
980
- case 1:
981
- this.y = s;
982
- break;
983
- case 2:
984
- this.z = s;
985
- break;
986
- default:
987
- throw new Error("index is out of range: " + t);
988
- }
989
- return this;
990
- }
991
- getComponent(t) {
992
- switch (t) {
993
- case 0:
994
- return this.x;
995
- case 1:
996
- return this.y;
997
- case 2:
998
- return this.z;
999
- default:
1000
- throw new Error("index is out of range: " + t);
1001
- }
1002
- }
1003
- clone() {
1004
- return new R(this.x, this.y, this.z);
1005
- }
1006
- copy(t) {
1007
- return this.x = t.x, this.y = t.y, this.z = t.z || 0, this;
1008
- }
1009
- add(t) {
1010
- return this.x += t.x, this.y += t.y, this.z += t.z || 0, this;
1011
- }
1012
- addScalar(t) {
1013
- return this.x += t, this.y += t, this.z += t, this;
1014
- }
1015
- addVectors(t, s) {
1016
- return this.x = t.x + s.x, this.y = t.y + s.y, this.z = t.z + s.z, this;
1017
- }
1018
- addScaledVector(t, s) {
1019
- return this.x += t.x * s, this.y += t.y * s, this.z += t.z * s, this;
1020
- }
1021
- sub(t) {
1022
- return this.x -= t.x, this.y -= t.y, this.z -= t.z, this;
1023
- }
1024
- subScalar(t) {
1025
- return this.x -= t, this.y -= t, this.z -= t, this;
1026
- }
1027
- subVectors(t, s) {
1028
- return this.x = t.x - s.x, this.y = t.y - s.y, this.z = t.z - s.z, this;
1029
- }
1030
- multiply(t) {
1031
- return this.x *= t.x, this.y *= t.y, this.z *= t.z, this;
1032
- }
1033
- multiplyScalar(t) {
1034
- return this.x *= t, this.y *= t, this.z *= t, this;
1035
- }
1036
- multiplyVectors(t, s) {
1037
- return this.x = t.x * s.x, this.y = t.y * s.y, this.z = t.z * s.z, this;
1038
- }
1039
- applyEuler(t) {
1040
- return this.applyQuaternion(Vt.setFromEuler(t));
1041
- }
1042
- applyAxisAngle(t, s) {
1043
- return this.applyQuaternion(Vt.setFromAxisAngle(t, s));
1044
- }
1045
- applyMatrix3(t) {
1046
- const s = this.x, e = this.y, n = this.z, i = t.elements;
1047
- return this.x = i[0] * s + i[3] * e + i[6] * n, this.y = i[1] * s + i[4] * e + i[7] * n, this.z = i[2] * s + i[5] * e + i[8] * n, this;
1048
- }
1049
- applyNormalMatrix(t) {
1050
- return this.applyMatrix3(t).normalize();
1051
- }
1052
- applyMatrix4(t) {
1053
- const s = this.x, e = this.y, n = this.z, i = t.elements, r = 1 / (i[3] * s + i[7] * e + i[11] * n + i[15]);
1054
- return this.x = (i[0] * s + i[4] * e + i[8] * n + i[12]) * r, this.y = (i[1] * s + i[5] * e + i[9] * n + i[13]) * r, this.z = (i[2] * s + i[6] * e + i[10] * n + i[14]) * r, this;
1055
- }
1056
- applyQuaternion(t) {
1057
- const s = this.x, e = this.y, n = this.z, i = t.x, r = t.y, o = t.z, a = t.w, h = 2 * (r * n - o * e), c = 2 * (o * s - i * n), l = 2 * (i * e - r * s);
1058
- return this.x = s + a * h + r * l - o * c, this.y = e + a * c + o * h - i * l, this.z = n + a * l + i * c - r * h, this;
1059
- }
1060
- transformDirection(t) {
1061
- const s = this.x, e = this.y, n = this.z, i = t.elements;
1062
- return this.x = i[0] * s + i[4] * e + i[8] * n, this.y = i[1] * s + i[5] * e + i[9] * n, this.z = i[2] * s + i[6] * e + i[10] * n, this.normalize();
1063
- }
1064
- divide(t) {
1065
- return this.x /= t.x, this.y /= t.y, this.z /= t.z, this;
1066
- }
1067
- divideScalar(t) {
1068
- return this.multiplyScalar(1 / t);
1069
- }
1070
- min(t) {
1071
- return this.x = Math.min(this.x, t.x), this.y = Math.min(this.y, t.y), this.z = Math.min(this.z, t.z), this;
1072
- }
1073
- max(t) {
1074
- return this.x = Math.max(this.x, t.x), this.y = Math.max(this.y, t.y), this.z = Math.max(this.z, t.z), this;
1075
- }
1076
- clamp(t, s) {
1077
- return this.x = Math.max(t.x, Math.min(s.x, this.x)), this.y = Math.max(t.y, Math.min(s.y, this.y)), this.z = Math.max(t.z, Math.min(s.z, this.z)), this;
1078
- }
1079
- clampScalar(t, s) {
1080
- return this.x = Math.max(t, Math.min(s, this.x)), this.y = Math.max(t, Math.min(s, this.y)), this.z = Math.max(t, Math.min(s, this.z)), this;
1081
- }
1082
- clampLength(t, s) {
1083
- const e = this.length();
1084
- return this.divideScalar(e || 1).multiplyScalar(
1085
- Math.max(t, Math.min(s, e))
1086
- );
1087
- }
1088
- floor() {
1089
- return this.x = Math.floor(this.x), this.y = Math.floor(this.y), this.z = Math.floor(this.z), this;
1090
- }
1091
- ceil() {
1092
- return this.x = Math.ceil(this.x), this.y = Math.ceil(this.y), this.z = Math.ceil(this.z), this;
1093
- }
1094
- round() {
1095
- return this.x = Math.round(this.x), this.y = Math.round(this.y), this.z = Math.round(this.z), this;
1096
- }
1097
- roundToZero() {
1098
- return this.x = Math.trunc(this.x), this.y = Math.trunc(this.y), this.z = Math.trunc(this.z), this;
1099
- }
1100
- negate() {
1101
- return this.x = -this.x, this.y = -this.y, this.z = -this.z, this;
1102
- }
1103
- dot(t) {
1104
- return this.x * t.x + this.y * t.y + this.z * t.z;
1105
- }
1106
- isParallelTo(t) {
1107
- const s = this.dot(t), e = this.length(), n = t.length();
1108
- return Math.abs(s) === e * n;
1109
- }
1110
- lengthSq() {
1111
- return this.x * this.x + this.y * this.y + this.z * this.z;
1112
- }
1113
- length() {
1114
- return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
1115
- }
1116
- manhattanLength() {
1117
- return Math.abs(this.x) + Math.abs(this.y) + Math.abs(this.z);
1118
- }
1119
- normalize() {
1120
- return this.divideScalar(this.length() || 1);
1121
- }
1122
- setLength(t) {
1123
- return this.normalize().multiplyScalar(t);
1124
- }
1125
- lerp(t, s) {
1126
- return this.x += (t.x - this.x) * s, this.y += (t.y - this.y) * s, this.z += (t.z - this.z) * s, this;
1127
- }
1128
- lerpVectors(t, s, e) {
1129
- return this.x = t.x + (s.x - t.x) * e, this.y = t.y + (s.y - t.y) * e, this.z = t.z + (s.z - t.z) * e, this;
1130
- }
1131
- cross(t) {
1132
- return this.crossVectors(this, t);
1133
- }
1134
- crossVectors(t, s) {
1135
- const e = t.x, n = t.y, i = t.z, r = s.x, o = s.y, a = s.z;
1136
- return this.x = n * a - i * o, this.y = i * r - e * a, this.z = e * o - n * r, this;
1137
- }
1138
- projectOnVector(t) {
1139
- const s = t.lengthSq();
1140
- if (s === 0) return this.set(0, 0, 0);
1141
- const e = t.dot(this) / s;
1142
- return this.copy(t).multiplyScalar(e);
1143
- }
1144
- projectOnPlane(t) {
1145
- return It.copy(this).projectOnVector(t), this.sub(It);
1146
- }
1147
- reflect(t) {
1148
- return this.sub(It.copy(t).multiplyScalar(2 * this.dot(t)));
1149
- }
1150
- angleTo(t) {
1151
- const s = Math.sqrt(this.lengthSq() * t.lengthSq());
1152
- if (s === 0) return Math.PI / 2;
1153
- const e = this.dot(t) / s;
1154
- return Math.acos(Math.max(-1, Math.min(1, e)));
1155
- }
1156
- distanceTo(t) {
1157
- return Math.sqrt(this.distanceToSquared(t));
1158
- }
1159
- distanceToSquared(t) {
1160
- const s = this.x - t.x, e = this.y - t.y, n = this.z - t.z;
1161
- return s * s + e * e + n * n;
1162
- }
1163
- manhattanDistanceTo(t) {
1164
- return Math.abs(this.x - t.x) + Math.abs(this.y - t.y) + Math.abs(this.z - t.z);
1165
- }
1166
- setFromMatrixPosition(t) {
1167
- const s = t.elements;
1168
- return this.x = s[12], this.y = s[13], this.z = s[14], this;
1169
- }
1170
- setFromMatrixScale(t) {
1171
- const s = this.setFromMatrixColumn(t, 0).length(), e = this.setFromMatrixColumn(t, 1).length(), n = this.setFromMatrixColumn(t, 2).length();
1172
- return this.x = s, this.y = e, this.z = n, this;
1173
- }
1174
- setFromMatrixColumn(t, s) {
1175
- return this.fromArray(t.elements, s * 4);
1176
- }
1177
- setFromMatrix3Column(t, s) {
1178
- return this.fromArray(t.elements, s * 3);
1179
- }
1180
- equals(t) {
1181
- return t.x === this.x && t.y === this.y && t.z === this.z;
1182
- }
1183
- fromArray(t, s = 0) {
1184
- return this.x = t[s], this.y = t[s + 1], this.z = t[s + 2], this;
1185
- }
1186
- toArray(t = [], s = 0) {
1187
- return t[s] = this.x, t[s + 1] = this.y, t[s + 2] = this.z, t;
1188
- }
1189
- random() {
1190
- return this.x = Math.random(), this.y = Math.random(), this.z = Math.random(), this;
1191
- }
1192
- randomDirection() {
1193
- const t = Math.random() * Math.PI * 2, s = Math.random() * 2 - 1, e = Math.sqrt(1 - s * s);
1194
- return this.x = e * Math.cos(t), this.y = s, this.z = e * Math.sin(t), this;
1195
- }
1196
- *[Symbol.iterator]() {
1197
- yield this.x, yield this.y, yield this.z;
1198
- }
1199
- };
1200
- R.ORIGIN = Object.freeze(new R(0, 0, 0)), R.X_AXIS = Object.freeze(new R(1, 0, 0)), R.NEGATIVE_X_AXIS = Object.freeze(new R(-1, 0, 0)), R.Y_AXIS = Object.freeze(new R(0, 1, 0)), R.NEGATIVE_Y_AXIS = Object.freeze(new R(0, -1, 0)), R.Z_AXIS = Object.freeze(new R(0, 0, 1)), R.NEGATIVE_Z_AXIS = Object.freeze(new R(0, 0, -1));
1201
- let _ = R;
1202
- const It = new _(), Vt = new St(), et = class et {
1203
- constructor(t, s, e, n, i, r, o, a, h, c, l, m, d, x, g, y) {
1204
- this.elements = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1], t != null && s != null && e != null && n != null && i != null && r != null && o != null && a != null && h != null && c != null && l != null && m != null && d != null && x != null && g != null && y != null && this.set(
1205
- t,
1206
- s,
1207
- e,
1208
- n,
1209
- i,
1210
- r,
1211
- o,
1212
- a,
1213
- h,
1214
- c,
1215
- l,
1216
- m,
1217
- d,
1218
- x,
1219
- g,
1220
- y
1221
- );
1222
- }
1223
- set(t, s, e, n, i, r, o, a, h, c, l, m, d, x, g, y) {
1224
- const p = this.elements;
1225
- return p[0] = t, p[4] = s, p[8] = e, p[12] = n, p[1] = i, p[5] = r, p[9] = o, p[13] = a, p[2] = h, p[6] = c, p[10] = l, p[14] = m, p[3] = d, p[7] = x, p[11] = g, p[15] = y, this;
1226
- }
1227
- identity() {
1228
- return this.set(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this;
1229
- }
1230
- clone() {
1231
- return new et().fromArray(this.elements);
1232
- }
1233
- copy(t) {
1234
- const s = this.elements, e = t.elements;
1235
- return s[0] = e[0], s[1] = e[1], s[2] = e[2], s[3] = e[3], s[4] = e[4], s[5] = e[5], s[6] = e[6], s[7] = e[7], s[8] = e[8], s[9] = e[9], s[10] = e[10], s[11] = e[11], s[12] = e[12], s[13] = e[13], s[14] = e[14], s[15] = e[15], this;
1236
- }
1237
- copyPosition(t) {
1238
- const s = this.elements, e = t.elements;
1239
- return s[12] = e[12], s[13] = e[13], s[14] = e[14], this;
1240
- }
1241
- setFromMatrix3(t) {
1242
- const s = t.elements;
1243
- return this.set(
1244
- s[0],
1245
- s[3],
1246
- s[6],
1247
- 0,
1248
- s[1],
1249
- s[4],
1250
- s[7],
1251
- 0,
1252
- s[2],
1253
- s[5],
1254
- s[8],
1255
- 0,
1256
- 0,
1257
- 0,
1258
- 0,
1259
- 1
1260
- ), this;
1261
- }
1262
- setFromExtrusionDirection(t) {
1263
- if (Gt.equalPoint3d(t, _.Z_AXIS))
1264
- this.identity();
1265
- else {
1266
- const s = new _(1, 0, 0);
1267
- Math.abs(t.x) < 1 / 64 && Math.abs(t.y) < 1 / 64 ? s.crossVectors(_.Y_AXIS, t).normalize() : s.crossVectors(_.Z_AXIS, t).normalize();
1268
- const e = t.clone().cross(s).normalize();
1269
- this.set(
1270
- s.x,
1271
- s.y,
1272
- s.z,
1273
- 0,
1274
- e.x,
1275
- e.y,
1276
- e.z,
1277
- 0,
1278
- t.x,
1279
- t.y,
1280
- t.z,
1281
- 0,
1282
- 0,
1283
- 0,
1284
- 0,
1285
- 1
1286
- );
1287
- }
1288
- return this;
1289
- }
1290
- extractBasis(t, s, e) {
1291
- return t.setFromMatrixColumn(this, 0), s.setFromMatrixColumn(this, 1), e.setFromMatrixColumn(this, 2), this;
1292
- }
1293
- makeBasis(t, s, e) {
1294
- return this.set(
1295
- t.x,
1296
- s.x,
1297
- e.x,
1298
- 0,
1299
- t.y,
1300
- s.y,
1301
- e.y,
1302
- 0,
1303
- t.z,
1304
- s.z,
1305
- e.z,
1306
- 0,
1307
- 0,
1308
- 0,
1309
- 0,
1310
- 1
1311
- ), this;
1312
- }
1313
- extractRotation(t) {
1314
- const s = this.elements, e = t.elements, n = 1 / J.setFromMatrixColumn(t, 0).length(), i = 1 / J.setFromMatrixColumn(t, 1).length(), r = 1 / J.setFromMatrixColumn(t, 2).length();
1315
- return s[0] = e[0] * n, s[1] = e[1] * n, s[2] = e[2] * n, s[3] = 0, s[4] = e[4] * i, s[5] = e[5] * i, s[6] = e[6] * i, s[7] = 0, s[8] = e[8] * r, s[9] = e[9] * r, s[10] = e[10] * r, s[11] = 0, s[12] = 0, s[13] = 0, s[14] = 0, s[15] = 1, this;
1316
- }
1317
- makeRotationFromQuaternion(t) {
1318
- return this.compose(Ss, t, Cs);
1319
- }
1320
- lookAt(t, s, e) {
1321
- const n = this.elements;
1322
- return V.subVectors(t, s), V.lengthSq() === 0 && (V.z = 1), V.normalize(), Y.crossVectors(e, V), Y.lengthSq() === 0 && (Math.abs(e.z) === 1 ? V.x += 1e-4 : V.z += 1e-4, V.normalize(), Y.crossVectors(e, V)), Y.normalize(), yt.crossVectors(V, Y), n[0] = Y.x, n[4] = yt.x, n[8] = V.x, n[1] = Y.y, n[5] = yt.y, n[9] = V.y, n[2] = Y.z, n[6] = yt.z, n[10] = V.z, this;
1323
- }
1324
- multiply(t) {
1325
- return this.multiplyMatrices(this, t);
1326
- }
1327
- premultiply(t) {
1328
- return this.multiplyMatrices(t, this);
1329
- }
1330
- multiplyMatrices(t, s) {
1331
- const e = t.elements, n = s.elements, i = this.elements, r = e[0], o = e[4], a = e[8], h = e[12], c = e[1], l = e[5], m = e[9], d = e[13], x = e[2], g = e[6], y = e[10], p = e[14], z = e[3], f = e[7], b = e[11], P = e[15], I = n[0], A = n[4], k = n[8], C = n[12], j = n[1], q = n[5], W = n[9], ht = n[13], at = n[2], ct = n[6], lt = n[10], ut = n[14], dt = n[3], mt = n[7], xt = n[11], gt = n[15];
1332
- return i[0] = r * I + o * j + a * at + h * dt, i[4] = r * A + o * q + a * ct + h * mt, i[8] = r * k + o * W + a * lt + h * xt, i[12] = r * C + o * ht + a * ut + h * gt, i[1] = c * I + l * j + m * at + d * dt, i[5] = c * A + l * q + m * ct + d * mt, i[9] = c * k + l * W + m * lt + d * xt, i[13] = c * C + l * ht + m * ut + d * gt, i[2] = x * I + g * j + y * at + p * dt, i[6] = x * A + g * q + y * ct + p * mt, i[10] = x * k + g * W + y * lt + p * xt, i[14] = x * C + g * ht + y * ut + p * gt, i[3] = z * I + f * j + b * at + P * dt, i[7] = z * A + f * q + b * ct + P * mt, i[11] = z * k + f * W + b * lt + P * xt, i[15] = z * C + f * ht + b * ut + P * gt, this;
1333
- }
1334
- multiplyScalar(t) {
1335
- const s = this.elements;
1336
- return s[0] *= t, s[4] *= t, s[8] *= t, s[12] *= t, s[1] *= t, s[5] *= t, s[9] *= t, s[13] *= t, s[2] *= t, s[6] *= t, s[10] *= t, s[14] *= t, s[3] *= t, s[7] *= t, s[11] *= t, s[15] *= t, this;
1337
- }
1338
- determinant() {
1339
- const t = this.elements, s = t[0], e = t[4], n = t[8], i = t[12], r = t[1], o = t[5], a = t[9], h = t[13], c = t[2], l = t[6], m = t[10], d = t[14], x = t[3], g = t[7], y = t[11], p = t[15];
1340
- return x * (+i * a * l - n * h * l - i * o * m + e * h * m + n * o * d - e * a * d) + g * (+s * a * d - s * h * m + i * r * m - n * r * d + n * h * c - i * a * c) + y * (+s * h * l - s * o * d - i * r * l + e * r * d + i * o * c - e * h * c) + p * (-n * o * c - s * a * l + s * o * m + n * r * l - e * r * m + e * a * c);
1341
- }
1342
- transpose() {
1343
- const t = this.elements;
1344
- let s;
1345
- return s = t[1], t[1] = t[4], t[4] = s, s = t[2], t[2] = t[8], t[8] = s, s = t[6], t[6] = t[9], t[9] = s, s = t[3], t[3] = t[12], t[12] = s, s = t[7], t[7] = t[13], t[13] = s, s = t[11], t[11] = t[14], t[14] = s, this;
1346
- }
1347
- setPosition(t, s, e) {
1348
- const n = this.elements;
1349
- return t instanceof _ ? (n[12] = t.x, n[13] = t.y, n[14] = t.z) : (n[12] = t, n[13] = s, n[14] = e), this;
1350
- }
1351
- invert() {
1352
- const t = this.elements, s = t[0], e = t[1], n = t[2], i = t[3], r = t[4], o = t[5], a = t[6], h = t[7], c = t[8], l = t[9], m = t[10], d = t[11], x = t[12], g = t[13], y = t[14], p = t[15], z = l * y * h - g * m * h + g * a * d - o * y * d - l * a * p + o * m * p, f = x * m * h - c * y * h - x * a * d + r * y * d + c * a * p - r * m * p, b = c * g * h - x * l * h + x * o * d - r * g * d - c * o * p + r * l * p, P = x * l * a - c * g * a - x * o * m + r * g * m + c * o * y - r * l * y, I = s * z + e * f + n * b + i * P;
1353
- if (I === 0)
1354
- return this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1355
- const A = 1 / I;
1356
- return t[0] = z * A, t[1] = (g * m * i - l * y * i - g * n * d + e * y * d + l * n * p - e * m * p) * A, t[2] = (o * y * i - g * a * i + g * n * h - e * y * h - o * n * p + e * a * p) * A, t[3] = (l * a * i - o * m * i - l * n * h + e * m * h + o * n * d - e * a * d) * A, t[4] = f * A, t[5] = (c * y * i - x * m * i + x * n * d - s * y * d - c * n * p + s * m * p) * A, t[6] = (x * a * i - r * y * i - x * n * h + s * y * h + r * n * p - s * a * p) * A, t[7] = (r * m * i - c * a * i + c * n * h - s * m * h - r * n * d + s * a * d) * A, t[8] = b * A, t[9] = (x * l * i - c * g * i - x * e * d + s * g * d + c * e * p - s * l * p) * A, t[10] = (r * g * i - x * o * i + x * e * h - s * g * h - r * e * p + s * o * p) * A, t[11] = (c * o * i - r * l * i - c * e * h + s * l * h + r * e * d - s * o * d) * A, t[12] = P * A, t[13] = (c * g * n - x * l * n + x * e * m - s * g * m - c * e * y + s * l * y) * A, t[14] = (x * o * n - r * g * n - x * e * a + s * g * a + r * e * y - s * o * y) * A, t[15] = (r * l * n - c * o * n + c * e * a - s * l * a - r * e * m + s * o * m) * A, this;
1357
- }
1358
- scale(t) {
1359
- const s = this.elements, e = t.x, n = t.y, i = t.z;
1360
- return s[0] *= e, s[4] *= n, s[8] *= i, s[1] *= e, s[5] *= n, s[9] *= i, s[2] *= e, s[6] *= n, s[10] *= i, s[3] *= e, s[7] *= n, s[11] *= i, this;
1361
- }
1362
- getMaxScaleOnAxis() {
1363
- const t = this.elements, s = t[0] * t[0] + t[1] * t[1] + t[2] * t[2], e = t[4] * t[4] + t[5] * t[5] + t[6] * t[6], n = t[8] * t[8] + t[9] * t[9] + t[10] * t[10];
1364
- return Math.sqrt(Math.max(s, e, n));
1365
- }
1366
- makeTranslation(t, s, e) {
1367
- return t instanceof _ ? this.set(1, 0, 0, t.x, 0, 1, 0, t.y, 0, 0, 1, t.z, 0, 0, 0, 1) : this.set(1, 0, 0, t, 0, 1, 0, s, 0, 0, 1, e, 0, 0, 0, 1), this;
1368
- }
1369
- makeRotationX(t) {
1370
- const s = Math.cos(t), e = Math.sin(t);
1371
- return this.set(1, 0, 0, 0, 0, s, -e, 0, 0, e, s, 0, 0, 0, 0, 1), this;
1372
- }
1373
- makeRotationY(t) {
1374
- const s = Math.cos(t), e = Math.sin(t);
1375
- return this.set(s, 0, e, 0, 0, 1, 0, 0, -e, 0, s, 0, 0, 0, 0, 1), this;
1376
- }
1377
- makeRotationZ(t) {
1378
- const s = Math.cos(t), e = Math.sin(t);
1379
- return this.set(s, -e, 0, 0, e, s, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1), this;
1380
- }
1381
- makeRotationAxis(t, s) {
1382
- const e = Math.cos(s), n = Math.sin(s), i = 1 - e, r = t.x, o = t.y, a = t.z, h = i * r, c = i * o;
1383
- return this.set(
1384
- h * r + e,
1385
- h * o - n * a,
1386
- h * a + n * o,
1387
- 0,
1388
- h * o + n * a,
1389
- c * o + e,
1390
- c * a - n * r,
1391
- 0,
1392
- h * a - n * o,
1393
- c * a + n * r,
1394
- i * a * a + e,
1395
- 0,
1396
- 0,
1397
- 0,
1398
- 0,
1399
- 1
1400
- ), this;
1401
- }
1402
- makeScale(t, s, e) {
1403
- return this.set(t, 0, 0, 0, 0, s, 0, 0, 0, 0, e, 0, 0, 0, 0, 1), this;
1404
- }
1405
- makeShear(t, s, e, n, i, r) {
1406
- return this.set(1, e, i, 0, t, 1, r, 0, s, n, 1, 0, 0, 0, 0, 1), this;
1407
- }
1408
- compose(t, s, e) {
1409
- const n = this.elements, i = s.x, r = s.y, o = s.z, a = s.w, h = i + i, c = r + r, l = o + o, m = i * h, d = i * c, x = i * l, g = r * c, y = r * l, p = o * l, z = a * h, f = a * c, b = a * l, P = e.x, I = e.y, A = e.z;
1410
- return n[0] = (1 - (g + p)) * P, n[1] = (d + b) * P, n[2] = (x - f) * P, n[3] = 0, n[4] = (d - b) * I, n[5] = (1 - (m + p)) * I, n[6] = (y + z) * I, n[7] = 0, n[8] = (x + f) * A, n[9] = (y - z) * A, n[10] = (1 - (m + g)) * A, n[11] = 0, n[12] = t.x, n[13] = t.y, n[14] = t.z, n[15] = 1, this;
1411
- }
1412
- decompose(t, s, e) {
1413
- const n = this.elements;
1414
- let i = J.set(n[0], n[1], n[2]).length();
1415
- const r = J.set(n[4], n[5], n[6]).length(), o = J.set(n[8], n[9], n[10]).length();
1416
- this.determinant() < 0 && (i = -i), t.x = n[12], t.y = n[13], t.z = n[14], L.copy(this);
1417
- const h = 1 / i, c = 1 / r, l = 1 / o;
1418
- return L.elements[0] *= h, L.elements[1] *= h, L.elements[2] *= h, L.elements[4] *= c, L.elements[5] *= c, L.elements[6] *= c, L.elements[8] *= l, L.elements[9] *= l, L.elements[10] *= l, s.setFromRotationMatrix(L), e.x = i, e.y = r, e.z = o, this;
1419
- }
1420
- equals(t) {
1421
- const s = this.elements, e = t.elements;
1422
- for (let n = 0; n < 16; n++)
1423
- if (s[n] !== e[n]) return !1;
1424
- return !0;
1425
- }
1426
- fromArray(t, s = 0) {
1427
- for (let e = 0; e < 16; e++)
1428
- this.elements[e] = t[e + s];
1429
- return this;
1430
- }
1431
- toArray(t = [], s = 0) {
1432
- const e = this.elements;
1433
- return t[s] = e[0], t[s + 1] = e[1], t[s + 2] = e[2], t[s + 3] = e[3], t[s + 4] = e[4], t[s + 5] = e[5], t[s + 6] = e[6], t[s + 7] = e[7], t[s + 8] = e[8], t[s + 9] = e[9], t[s + 10] = e[10], t[s + 11] = e[11], t[s + 12] = e[12], t[s + 13] = e[13], t[s + 14] = e[14], t[s + 15] = e[15], t;
1434
- }
1435
- };
1436
- et.IDENTITY = Object.freeze(new et());
1437
- let O = et;
1438
- const J = new _(), L = new O(), Ss = new _(0, 0, 0), Cs = new _(1, 1, 1), Y = new _(), yt = new _(), V = new _();
1439
- class v {
1440
- constructor(t = void 0, s = void 0) {
1441
- this.min = t == null ? new _(1 / 0, 1 / 0, 1 / 0) : new _(t.x, t.y, t.z), this.max = s == null ? new _(-1 / 0, -1 / 0, -1 / 0) : new _(s.x, s.y, s.z);
1442
- }
1443
- set(t, s) {
1444
- return this.min.copy(t), this.max.copy(s), this;
1445
- }
1446
- setFromArray(t) {
1447
- this.makeEmpty();
1448
- for (let s = 0, e = t.length; s < e; s += 3)
1449
- this.expandByPoint(Bt.fromArray(t, s));
1450
- return this;
1451
- }
1452
- setFromPoints(t) {
1453
- this.makeEmpty();
1454
- for (let s = 0, e = t.length; s < e; s++)
1455
- this.expandByPoint(t[s]);
1456
- return this;
1457
- }
1458
- setFromCenterAndSize(t, s) {
1459
- const e = Bt.copy(s).multiplyScalar(0.5);
1460
- return this.min.copy(t).sub(e), this.max.copy(t).add(e), this;
1461
- }
1462
- clone() {
1463
- return new v().copy(this);
1464
- }
1465
- copy(t) {
1466
- return this.min.copy(t.min), this.max.copy(t.max), this;
1467
- }
1468
- makeEmpty() {
1469
- return this.min.x = this.min.y = this.min.z = 1 / 0, this.max.x = this.max.y = this.max.z = -1 / 0, this;
1470
- }
1471
- isEmpty() {
1472
- return this.max.x < this.min.x || this.max.y < this.min.y || this.max.z < this.min.z;
1473
- }
1474
- getCenter(t) {
1475
- return this.isEmpty() ? t.set(0, 0, 0) : t.addVectors(this.min, this.max).multiplyScalar(0.5);
1476
- }
1477
- getSize(t) {
1478
- return this.isEmpty() ? t.set(0, 0, 0) : t.subVectors(this.max, this.min);
1479
- }
1480
- get center() {
1481
- return this.isEmpty() ? new _(0, 0, 0) : new _(0, 0, 0).addVectors(this.min, this.max).multiplyScalar(0.5);
1482
- }
1483
- get size() {
1484
- return this.isEmpty() ? new _(0, 0, 0) : new _(0, 0, 0).subVectors(this.max, this.min);
1485
- }
1486
- expandByPoint(t) {
1487
- return this.min.min(t), this.max.max(t), this;
1488
- }
1489
- expandByVector(t) {
1490
- return this.min.sub(t), this.max.add(t), this;
1491
- }
1492
- expandByScalar(t) {
1493
- return this.min.addScalar(-t), this.max.addScalar(t), this;
1494
- }
1495
- containsPoint(t) {
1496
- return !(t.x < this.min.x || t.x > this.max.x || t.y < this.min.y || t.y > this.max.y || t.z < this.min.z || t.z > this.max.z);
1497
- }
1498
- containsBox(t) {
1499
- return this.min.x <= t.min.x && t.max.x <= this.max.x && this.min.y <= t.min.y && t.max.y <= this.max.y && this.min.z <= t.min.z && t.max.z <= this.max.z;
1500
- }
1501
- getParameter(t, s) {
1502
- return s.set(
1503
- (t.x - this.min.x) / (this.max.x - this.min.x),
1504
- (t.y - this.min.y) / (this.max.y - this.min.y),
1505
- (t.z - this.min.z) / (this.max.z - this.min.z)
1506
- );
1507
- }
1508
- intersectsBox(t) {
1509
- return !(t.max.x < this.min.x || t.min.x > this.max.x || t.max.y < this.min.y || t.min.y > this.max.y || t.max.z < this.min.z || t.min.z > this.max.z);
1510
- }
1511
- intersectsPlane(t) {
1512
- let s, e;
1513
- return t.normal.x > 0 ? (s = t.normal.x * this.min.x, e = t.normal.x * this.max.x) : (s = t.normal.x * this.max.x, e = t.normal.x * this.min.x), t.normal.y > 0 ? (s += t.normal.y * this.min.y, e += t.normal.y * this.max.y) : (s += t.normal.y * this.max.y, e += t.normal.y * this.min.y), t.normal.z > 0 ? (s += t.normal.z * this.min.z, e += t.normal.z * this.max.z) : (s += t.normal.z * this.max.z, e += t.normal.z * this.min.z), s <= -t.constant && e >= -t.constant;
1514
- }
1515
- clampPoint(t, s) {
1516
- return s.copy(t).clamp(this.min, this.max);
1517
- }
1518
- distanceToPoint(t) {
1519
- return this.clampPoint(t, Bt).distanceTo(t);
1520
- }
1521
- intersect(t) {
1522
- return this.min.max(t.min), this.max.min(t.max), this.isEmpty() && this.makeEmpty(), this;
1523
- }
1524
- union(t) {
1525
- return this.min.min(t.min), this.max.max(t.max), this;
1526
- }
1527
- applyMatrix4(t) {
1528
- return this.isEmpty() ? this : (D[0].set(this.min.x, this.min.y, this.min.z).applyMatrix4(t), D[1].set(this.min.x, this.min.y, this.max.z).applyMatrix4(t), D[2].set(this.min.x, this.max.y, this.min.z).applyMatrix4(t), D[3].set(this.min.x, this.max.y, this.max.z).applyMatrix4(t), D[4].set(this.max.x, this.min.y, this.min.z).applyMatrix4(t), D[5].set(this.max.x, this.min.y, this.max.z).applyMatrix4(t), D[6].set(this.max.x, this.max.y, this.min.z).applyMatrix4(t), D[7].set(this.max.x, this.max.y, this.max.z).applyMatrix4(t), this.setFromPoints(D), this);
1529
- }
1530
- translate(t) {
1531
- return this.min.add(t), this.max.add(t), this;
1532
- }
1533
- equals(t) {
1534
- return t.min.equals(this.min) && t.max.equals(this.max);
1535
- }
1536
- }
1537
- const D = [
1538
- new _(),
1539
- new _(),
1540
- new _(),
1541
- new _(),
1542
- new _(),
1543
- new _(),
1544
- new _(),
1545
- new _()
1546
- ], Bt = new _(), qt = new B();
1547
- class X {
1548
- constructor(t = void 0, s = void 0) {
1549
- this.min = t == null ? new B(1 / 0, 1 / 0) : new B(t.x, t.y), this.max = s == null ? new B(-1 / 0, -1 / 0) : new B(s.x, s.y);
1550
- }
1551
- set(t, s) {
1552
- return this.min.copy(t), this.max.copy(s), this;
1553
- }
1554
- setFromPoints(t) {
1555
- this.makeEmpty();
1556
- for (let s = 0, e = t.length; s < e; s++)
1557
- this.expandByPoint(t[s]);
1558
- return this;
1559
- }
1560
- setFromCenterAndSize(t, s) {
1561
- const e = qt.copy(s).multiplyScalar(0.5);
1562
- return this.min.copy(t).sub(e), this.max.copy(t).add(e), this;
1563
- }
1564
- clone() {
1565
- return new X().copy(this);
1566
- }
1567
- copy(t) {
1568
- return this.min.copy(t.min), this.max.copy(t.max), this;
1569
- }
1570
- makeEmpty() {
1571
- return this.min.x = this.min.y = 1 / 0, this.max.x = this.max.y = -1 / 0, this;
1572
- }
1573
- isEmpty() {
1574
- return this.max.x < this.min.x || this.max.y < this.min.y;
1575
- }
1576
- getCenter(t) {
1577
- return this.isEmpty() ? t.set(0, 0) : t.addVectors(this.min, this.max).multiplyScalar(0.5);
1578
- }
1579
- getSize(t) {
1580
- return this.isEmpty() ? t.set(0, 0) : t.subVectors(this.max, this.min);
1581
- }
1582
- get center() {
1583
- return this.isEmpty() ? new B(0, 0) : new B(0, 0).addVectors(this.min, this.max).multiplyScalar(0.5);
1584
- }
1585
- get size() {
1586
- return this.isEmpty() ? new B(0, 0) : new B(0, 0).subVectors(this.max, this.min);
1587
- }
1588
- expandByPoint(t) {
1589
- return this.min.min(t), this.max.max(t), this;
1590
- }
1591
- expandByVector(t) {
1592
- return this.min.sub(t), this.max.add(t), this;
1593
- }
1594
- expandByScalar(t) {
1595
- return this.min.addScalar(-t), this.max.addScalar(t), this;
1596
- }
1597
- containsPoint(t) {
1598
- return !(t.x < this.min.x || t.x > this.max.x || t.y < this.min.y || t.y > this.max.y);
1599
- }
1600
- containsBox(t) {
1601
- return this.min.x <= t.min.x && t.max.x <= this.max.x && this.min.y <= t.min.y && t.max.y <= this.max.y;
1602
- }
1603
- getParameter(t, s) {
1604
- return s.set(
1605
- (t.x - this.min.x) / (this.max.x - this.min.x),
1606
- (t.y - this.min.y) / (this.max.y - this.min.y)
1607
- );
1608
- }
1609
- intersectsBox(t) {
1610
- return !(t.max.x < this.min.x || t.min.x > this.max.x || t.max.y < this.min.y || t.min.y > this.max.y);
1611
- }
1612
- clampPoint(t, s) {
1613
- return s.copy(t).clamp(this.min, this.max);
1614
- }
1615
- distanceToPoint(t) {
1616
- return this.clampPoint(t, qt).distanceTo(t);
1617
- }
1618
- intersect(t) {
1619
- return this.min.max(t.min), this.max.min(t.max), this.isEmpty() && this.makeEmpty(), this;
1620
- }
1621
- union(t) {
1622
- return this.min.min(t.min), this.max.max(t.max), this;
1623
- }
1624
- translate(t) {
1625
- return this.min.add(t), this.max.add(t), this;
1626
- }
1627
- equals(t) {
1628
- return t.min.equals(this.min) && t.max.equals(this.max);
1629
- }
1630
- }
1631
- const Ut = new _(), Es = new _(), Is = new it();
1632
- class Ct {
1633
- constructor(t = new _(1, 0, 0), s = 0) {
1634
- this.normal = t, this.constant = s;
1635
- }
1636
- set(t, s) {
1637
- return this.normal.copy(t), this.constant = s, this;
1638
- }
1639
- setComponents(t, s, e, n) {
1640
- return this.normal.set(t, s, e), this.constant = n, this;
1641
- }
1642
- setFromNormalAndCoplanarPoint(t, s) {
1643
- return this.normal.copy(t), this.constant = -s.dot(this.normal), this;
1644
- }
1645
- setFromCoplanarPoints(t, s, e) {
1646
- const n = Ut.subVectors(e, s).cross(Es.subVectors(t, s)).normalize();
1647
- return this.setFromNormalAndCoplanarPoint(n, t), this;
1648
- }
1649
- copy(t) {
1650
- return this.normal.copy(t.normal), this.constant = t.constant, this;
1651
- }
1652
- normalize() {
1653
- const t = 1 / this.normal.length();
1654
- return this.normal.multiplyScalar(t), this.constant *= t, this;
1655
- }
1656
- negate() {
1657
- return this.constant *= -1, this.normal.negate(), this;
1658
- }
1659
- distanceToPoint(t) {
1660
- return this.normal.dot(t) + this.constant;
1661
- }
1662
- projectPoint(t, s) {
1663
- return s.copy(t).addScaledVector(this.normal, -this.distanceToPoint(t));
1664
- }
1665
- intersectsBox(t) {
1666
- return t.intersectsPlane(this);
1667
- }
1668
- coplanarPoint(t) {
1669
- return t.copy(this.normal).multiplyScalar(-this.constant);
1670
- }
1671
- applyMatrix4(t, s) {
1672
- const e = s || Is.getNormalMatrix(t), n = this.coplanarPoint(Ut).applyMatrix4(t), i = this.normal.applyMatrix3(e).normalize();
1673
- return this.constant = -n.dot(i), this;
1674
- }
1675
- translate(t) {
1676
- return this.constant -= t.dot(this.normal), this;
1677
- }
1678
- equals(t) {
1679
- return t.normal.equals(this.normal) && t.constant === this.constant;
1680
- }
1681
- clone() {
1682
- return new Ct().copy(this);
1683
- }
1684
- }
1685
- class S extends B {
1686
- clone() {
1687
- return new S(this.x, this.y);
1688
- }
1689
- static pointArrayToNumberArray(t) {
1690
- const s = new Array(t.length * 2);
1691
- return t.forEach((e, n) => {
1692
- e.toArray(s, n * 2);
1693
- }), s;
1694
- }
1695
- }
1696
- class w extends _ {
1697
- clone() {
1698
- return new w(this.x, this.y, this.z);
1699
- }
1700
- static pointArrayToNumberArray(t, s = !0) {
1701
- const e = s ? 3 : 2, n = new Array(t.length * e);
1702
- return t.forEach((i, r) => {
1703
- i.toArray(n, r * e);
1704
- }), n;
1705
- }
1706
- }
1707
- const Lt = new O(), Ft = new St(), nt = class nt {
1708
- constructor(t = 0, s = 0, e = 0, n = nt.DEFAULT_ORDER) {
1709
- this._x = t, this._y = s, this._z = e, this._order = n;
1710
- }
1711
- get x() {
1712
- return this._x;
1713
- }
1714
- set x(t) {
1715
- this._x = t, this._onChangeCallback();
1716
- }
1717
- get y() {
1718
- return this._y;
1719
- }
1720
- set y(t) {
1721
- this._y = t, this._onChangeCallback();
1722
- }
1723
- get z() {
1724
- return this._z;
1725
- }
1726
- set z(t) {
1727
- this._z = t, this._onChangeCallback();
1728
- }
1729
- get order() {
1730
- return this._order;
1731
- }
1732
- set order(t) {
1733
- this._order = t, this._onChangeCallback();
1734
- }
1735
- set(t, s, e, n = this._order) {
1736
- return this._x = t, this._y = s, this._z = e, this._order = n, this._onChangeCallback(), this;
1737
- }
1738
- clone() {
1739
- return new nt(this._x, this._y, this._z, this._order);
1740
- }
1741
- copy(t) {
1742
- return this._x = t._x, this._y = t._y, this._z = t._z, this._order = t._order, this._onChangeCallback(), this;
1743
- }
1744
- setFromRotationMatrix(t, s = this._order, e = !0) {
1745
- const n = t.elements, i = n[0], r = n[4], o = n[8], a = n[1], h = n[5], c = n[9], l = n[2], m = n[6], d = n[10];
1746
- switch (s) {
1747
- case "XYZ":
1748
- this._y = Math.asin(Z(o, -1, 1)), Math.abs(o) < 0.9999999 ? (this._x = Math.atan2(-c, d), this._z = Math.atan2(-r, i)) : (this._x = Math.atan2(m, h), this._z = 0);
1749
- break;
1750
- case "YXZ":
1751
- this._x = Math.asin(-Z(c, -1, 1)), Math.abs(c) < 0.9999999 ? (this._y = Math.atan2(o, d), this._z = Math.atan2(a, h)) : (this._y = Math.atan2(-l, i), this._z = 0);
1752
- break;
1753
- case "ZXY":
1754
- this._x = Math.asin(Z(m, -1, 1)), Math.abs(m) < 0.9999999 ? (this._y = Math.atan2(-l, d), this._z = Math.atan2(-r, h)) : (this._y = 0, this._z = Math.atan2(a, i));
1755
- break;
1756
- case "ZYX":
1757
- this._y = Math.asin(-Z(l, -1, 1)), Math.abs(l) < 0.9999999 ? (this._x = Math.atan2(m, d), this._z = Math.atan2(a, i)) : (this._x = 0, this._z = Math.atan2(-r, h));
1758
- break;
1759
- case "YZX":
1760
- this._z = Math.asin(Z(a, -1, 1)), Math.abs(a) < 0.9999999 ? (this._x = Math.atan2(-c, h), this._y = Math.atan2(-l, i)) : (this._x = 0, this._y = Math.atan2(o, d));
1761
- break;
1762
- case "XZY":
1763
- this._z = Math.asin(-Z(r, -1, 1)), Math.abs(r) < 0.9999999 ? (this._x = Math.atan2(m, h), this._y = Math.atan2(o, i)) : (this._x = Math.atan2(-c, d), this._y = 0);
1764
- break;
1765
- }
1766
- return this._order = s, e === !0 && this._onChangeCallback(), this;
1767
- }
1768
- setFromQuaternion(t, s, e = !0) {
1769
- return Lt.makeRotationFromQuaternion(t), this.setFromRotationMatrix(Lt, s, e);
1770
- }
1771
- setFromVector3(t, s = this._order) {
1772
- return this.set(t.x, t.y, t.z, s);
1773
- }
1774
- reorder(t) {
1775
- return Ft.setFromEuler(this), this.setFromQuaternion(Ft, t);
1776
- }
1777
- equals(t) {
1778
- return t._x === this._x && t._y === this._y && t._z === this._z && t._order === this._order;
1779
- }
1780
- fromArray(t) {
1781
- return this._x = t[0], this._y = t[1], this._z = t[2], t[3] !== void 0 && (this._order = t[3]), this._onChangeCallback(), this;
1782
- }
1783
- toArray(t = [], s = 0) {
1784
- return t[s] = this._x, t[s + 1] = this._y, t[s + 2] = this._z, t[s + 3] = this._order, t;
1785
- }
1786
- _onChange(t) {
1787
- return this._onChangeCallback = t, this;
1788
- }
1789
- _onChangeCallback() {
1790
- }
1791
- *[Symbol.iterator]() {
1792
- yield this._x, yield this._y, yield this._z, yield this._order;
1793
- }
1794
- };
1795
- nt.DEFAULT_ORDER = "XYZ";
1796
- let Xt = nt;
1797
- function ts(u, t, s = !1) {
1798
- const e = u.x, n = u.y;
1799
- let i = !1;
1800
- const r = t.length;
1801
- for (let o = 0, a = r - 1; o < r; a = o++) {
1802
- const h = t[o].x, c = t[o].y, l = t[a].x, m = t[a].y;
1803
- let d = c > n != m > n;
1804
- s && (d = c >= n != m >= n), d && e < (l - h) * (n - c) / (m - c) + h && (i = !i);
1805
- }
1806
- return i;
1807
- }
1808
- function Bs(u, t) {
1809
- if (u.length === 0 || t.length === 0)
1810
- return !1;
1811
- const s = new X().setFromPoints(u), e = new X().setFromPoints(t);
1812
- if (!s.intersectsBox(e))
1813
- return !1;
1814
- for (let n = 0; n < u.length; ) {
1815
- if (ts(u[n], t, !0))
1816
- return !0;
1817
- n < u.length - 1 && Gt.equalPoint2d(u[n + 1], u[n]) && ++n, ++n;
1818
- }
1819
- return !1;
1820
- }
1821
- const ks = {
1822
- isPointInPolygon: ts,
1823
- isPolygonIntersect: Bs
1824
- };
1825
- function Fs(u, t) {
1826
- const s = [], e = t - 1, n = u;
1827
- for (let i = 0; i <= n; i++)
1828
- s.push(0);
1829
- for (let i = 1; i <= e - n; i++)
1830
- s.push(i);
1831
- for (let i = 0; i <= n; i++)
1832
- s.push(e - n + 1);
1833
- return s;
1834
- }
1835
- function Xs(u, t) {
1836
- const s = t.length - 1, e = u, n = [0];
1837
- let i = 0;
1838
- for (let o = 1; o <= s; o++) {
1839
- const a = t[o][0] - t[o - 1][0], h = t[o][1] - t[o - 1][1], c = t[o][2] - t[o - 1][2], l = Math.sqrt(a * a + h * h + c * c);
1840
- i += l, n.push(i);
1841
- }
1842
- const r = [];
1843
- for (let o = 0; o <= e; o++)
1844
- r.push(0);
1845
- for (let o = 1; o <= s - e; o++) {
1846
- const a = n[o] / i;
1847
- r.push(a * (s - e + 1));
1848
- }
1849
- for (let o = 0; o <= e; o++)
1850
- r.push(s - e + 1);
1851
- return r;
1852
- }
1853
- function Rs(u, t = "Uniform") {
1854
- const s = u.length;
1855
- if (s === 0)
1856
- return [];
1857
- if (s === 1)
1858
- return [0];
1859
- const e = s - 1;
1860
- if (t === "Uniform")
1861
- return new Array(s).fill(0).map((r, o) => o / e);
1862
- const n = [0];
1863
- let i = 0;
1864
- for (let r = 1; r <= e; r++) {
1865
- const o = u[r][0] - u[r - 1][0], a = u[r][1] - u[r - 1][1], h = u[r][2] - u[r - 1][2], c = Math.sqrt(o * o + a * a + h * h), l = t === "SqrtChord" ? Math.sqrt(c) : c;
1866
- i += l, n.push(i);
1867
- }
1868
- return i < 1e-12 ? new Array(s).fill(0).map((r, o) => o / e) : n.map((r) => r / i);
1869
- }
1870
- function Ns(u, t) {
1871
- const s = t.length - 1, e = u, n = s + e + 1, i = new Array(n + 1).fill(0), r = t[t.length - 1];
1872
- for (let o = n - e; o <= n; o++)
1873
- i[o] = r;
1874
- for (let o = 1; o <= s - e; o++) {
1875
- let a = 0;
1876
- for (let h = o; h < o + e; h++)
1877
- a += t[h];
1878
- i[o + e] = a / e;
1879
- }
1880
- return i;
1881
- }
1882
- function Ds(u, t) {
1883
- const s = t.length - 1, e = u, n = [0];
1884
- let i = 0;
1885
- for (let o = 1; o <= s; o++) {
1886
- const a = t[o][0] - t[o - 1][0], h = t[o][1] - t[o - 1][1], c = t[o][2] - t[o - 1][2], l = Math.sqrt(a * a + h * h + c * c), m = Math.sqrt(l);
1887
- i += m, n.push(i);
1888
- }
1889
- const r = [];
1890
- for (let o = 0; o <= e; o++)
1891
- r.push(0);
1892
- for (let o = 1; o <= s - e; o++) {
1893
- const a = n[o] / i;
1894
- r.push(a * (s - e + 1));
1895
- }
1896
- for (let o = 0; o <= e; o++)
1897
- r.push(s - e + 1);
1898
- return r;
1899
- }
1900
- function kt(u, t) {
1901
- const s = u.length, e = u.map((r) => r.slice()), n = t.slice();
1902
- for (let r = 0; r < s; r++) {
1903
- let o = r, a = Math.abs(e[r][r]);
1904
- for (let h = r + 1; h < s; h++) {
1905
- const c = Math.abs(e[h][r]);
1906
- c > a && (a = c, o = h);
1907
- }
1908
- if (a < 1e-12)
1909
- throw new Error("Interpolation matrix is singular.");
1910
- if (o !== r) {
1911
- const h = e[r];
1912
- e[r] = e[o], e[o] = h;
1913
- const c = n[r];
1914
- n[r] = n[o], n[o] = c;
1915
- }
1916
- for (let h = r + 1; h < s; h++) {
1917
- const c = e[h][r] / e[r][r];
1918
- if (!(Math.abs(c) < 1e-14)) {
1919
- for (let l = r; l < s; l++)
1920
- e[h][l] -= c * e[r][l];
1921
- n[h] -= c * n[r];
1922
- }
1923
- }
1924
- }
1925
- const i = new Array(s).fill(0);
1926
- for (let r = s - 1; r >= 0; r--) {
1927
- let o = n[r];
1928
- for (let a = r + 1; a < s; a++)
1929
- o -= e[r][a] * i[a];
1930
- i[r] = o / e[r][r];
1931
- }
1932
- return i;
1933
- }
1934
- function ss(u, t, s = "Uniform", e, n) {
1935
- if (u.length === 0)
1936
- return { controlPoints: [], knots: [], weights: [] };
1937
- const i = u.map((C) => [C[0], C[1], C[2] ?? 0]), r = !!e, o = !!n, a = (r ? 1 : 0) + (o ? 1 : 0), h = i.length - 1, c = h + a;
1938
- if (c < t)
1939
- throw new Error("Not enough points to interpolate a curve of this degree.");
1940
- const l = Rs(i, s), m = l.slice();
1941
- r && m.unshift(l[0]), o && m.push(l[l.length - 1]);
1942
- const d = Ns(t, m), x = c + 1, g = new Array(x), y = new Array(x), p = new Array(x), z = new Array(x);
1943
- let f = 0;
1944
- g[f] = new Array(x).fill(0), g[f][0] = 1, y[f] = i[0][0], p[f] = i[0][1], z[f] = i[0][2], f++;
1945
- for (let C = 1; C <= h - 1; C++) {
1946
- const j = l[C];
1947
- g[f] = new Array(x).fill(0);
1948
- for (let q = 0; q <= c; q++)
1949
- g[f][q] = zt(q, t, j, d);
1950
- y[f] = i[C][0], p[f] = i[C][1], z[f] = i[C][2], f++;
1951
- }
1952
- if (g[f] = new Array(x).fill(0), g[f][c] = 1, y[f] = i[h][0], p[f] = i[h][1], z[f] = i[h][2], f++, r) {
1953
- const C = d[t + 1] - d[0], j = C !== 0 ? t / C : 0;
1954
- g[f] = new Array(x).fill(0), g[f][0] = -j, g[f][1] = j, y[f] = (e == null ? void 0 : e[0]) ?? 0, p[f] = (e == null ? void 0 : e[1]) ?? 0, z[f] = (e == null ? void 0 : e[2]) ?? 0, f++;
1955
- }
1956
- if (o) {
1957
- const C = d[c + t + 1] - d[c], j = C !== 0 ? t / C : 0;
1958
- g[f] = new Array(x).fill(0), g[f][c - 1] = -j, g[f][c] = j, y[f] = (n == null ? void 0 : n[0]) ?? 0, p[f] = (n == null ? void 0 : n[1]) ?? 0, z[f] = (n == null ? void 0 : n[2]) ?? 0, f++;
1959
- }
1960
- const b = kt(g, y), P = kt(g, p), I = kt(g, z), A = new Array(x);
1961
- for (let C = 0; C < x; C++)
1962
- A[C] = [b[C], P[C], I[C]];
1963
- const k = new Array(x).fill(1);
1964
- return { controlPoints: A, knots: d, weights: k };
1965
- }
1966
- function zt(u, t, s, e) {
1967
- if (t === 0)
1968
- return s >= e[u] && s < e[u + 1] ? 1 : 0;
1969
- const n = e[u + t] - e[u], i = e[u + t + 1] - e[u + 1], r = n > 1e-10 ? (s - e[u]) / n : 0, o = i > 1e-10 ? (e[u + t + 1] - s) / i : 0;
1970
- return r * zt(u, t - 1, s, e) + o * zt(u + 1, t - 1, s, e);
1971
- }
1972
- function ft(u, t, s, e, n) {
1973
- const i = e.length - 1, r = t;
1974
- if (u = Math.max(s[r], Math.min(s[i + 1], u)), Math.abs(u - s[i + 1]) < 1e-8)
1975
- return [...e[i]];
1976
- if (Math.abs(u - s[r]) < 1e-8)
1977
- return [...e[0]];
1978
- const o = [0, 0, 0];
1979
- let a = 0;
1980
- for (let h = 0; h <= i; h++) {
1981
- const c = zt(h, r, u, s), l = n[h] * c;
1982
- o[0] += e[h][0] * l, o[1] += e[h][1] * l, o[2] += e[h][2] * l, a += l;
1983
- }
1984
- if (Math.abs(a) < 1e-10) {
1985
- const h = s[s.length - r - 1];
1986
- if (Math.abs(u - h) < 1e-8)
1987
- return [...e[i]];
1988
- if (Math.abs(u - s[r]) < 1e-8)
1989
- return [...e[0]];
1990
- }
1991
- return Math.abs(a) >= 1e-10 && (o[0] /= a, o[1] /= a, o[2] /= a), o;
1992
- }
1993
- function Ts(u, t, s, e) {
1994
- const n = u, i = t[n], r = t[t.length - n - 1];
1995
- let o = 0;
1996
- const a = 1e3, h = (r - i) / a;
1997
- let c = ft(
1998
- i,
1999
- u,
2000
- t,
2001
- s,
2002
- e
2003
- );
2004
- for (let g = 1; g <= a; g++) {
2005
- const y = i + g * h, p = ft(y, u, t, s, e), z = p[0] - c[0], f = p[1] - c[1], b = p[2] - c[2];
2006
- o += Math.sqrt(z * z + f * f + b * b), c = p;
2007
- }
2008
- const l = ft(
2009
- r,
2010
- u,
2011
- t,
2012
- s,
2013
- e
2014
- ), m = l[0] - c[0], d = l[1] - c[1], x = l[2] - c[2];
2015
- return o += Math.sqrt(m * m + d * d + x * x), o;
2016
- }
2017
- function vs(u, t = 3, s = "Uniform", e, n) {
2018
- return u.length === 0 ? [] : ss(
2019
- u,
2020
- t,
2021
- s,
2022
- e,
2023
- n
2024
- ).controlPoints;
2025
- }
2026
- const Dt = new O(), vt = new _(), js = new _(), Vs = new _(), Rt = new w();
2027
- function es(u) {
2028
- return new O().setFromExtrusionDirection(
2029
- new _(u.x, u.y, u.z)
2030
- );
2031
- }
2032
- function Ys(u) {
2033
- return Dt.setFromExtrusionDirection(
2034
- new _(u.x, u.y, u.z)
2035
- ), Dt.extractBasis(vt, js, Vs), vt.clone();
2036
- }
2037
- function Zs(u, t) {
2038
- return new w(u.x, u.y, u.z ?? 0).applyMatrix4(
2039
- es(t)
2040
- );
2041
- }
2042
- function Yt(u, t) {
2043
- return new w(u.x, u.y, u.z ?? 0).applyMatrix4(
2044
- es(t).invert()
2045
- );
2046
- }
2047
- function Os(u, t, s) {
2048
- const e = Yt(u, s), n = Yt(t, s);
2049
- return Rt.set(
2050
- n.x - e.x,
2051
- n.y - e.y,
2052
- (n.z ?? 0) - (e.z ?? 0)
2053
- ), M.normalizeAngle(Math.atan2(Rt.y, Rt.x));
2054
- }
2055
- class ns {
2056
- constructor() {
2057
- this._boundingBoxNeedsUpdate = !1;
2058
- }
2059
- get boundingBoxNeedUpdate() {
2060
- return this._boundingBoxNeedsUpdate;
2061
- }
2062
- }
2063
- class is extends ns {
2064
- translate(t) {
2065
- return this.transform(new it().makeTranslation(t.x, t.y));
2066
- }
2067
- get box() {
2068
- return (this._box == null || this._boundingBoxNeedsUpdate) && (this._box = this.calculateBoundingBox(), this._boundingBoxNeedsUpdate = !1), this._box;
2069
- }
2070
- }
2071
- class rs extends is {
2072
- constructor() {
2073
- super(), this._loops = [];
2074
- }
2075
- add(t) {
2076
- this._loops.push(t), this._boundingBoxNeedsUpdate = !0;
2077
- }
2078
- get loops() {
2079
- return this._loops;
2080
- }
2081
- get outter() {
2082
- if (this._loops.length > 0)
2083
- return this._loops[0];
2084
- }
2085
- calculateBoundingBox() {
2086
- const t = this.outter;
2087
- return t ? t.box : new X();
2088
- }
2089
- transform(t) {
2090
- return this._loops.forEach((s) => {
2091
- s.transform(t);
2092
- }), this._boundingBoxNeedsUpdate = !0, this;
2093
- }
2094
- clone() {
2095
- const t = new rs();
2096
- return this._loops.forEach((s) => {
2097
- t.add(s.clone());
2098
- }), t;
2099
- }
2100
- getPoints(t) {
2101
- const s = [];
2102
- for (let e = 0; e < this.loops.length; ++e) {
2103
- const i = this.loops[e].getPoints(t);
2104
- s.push(i);
2105
- }
2106
- return s;
2107
- }
2108
- buildHierarchy() {
2109
- var o;
2110
- const t = this.getPoints(100), s = this.calculateBoundaryBoxes(t), e = this.sortBoundaryBoxesByAreas(s), n = /* @__PURE__ */ new Map(), i = e.length;
2111
- for (let a = 0; a < i; a++)
2112
- n.set(e[a], {
2113
- index: e[a],
2114
- children: []
2115
- });
2116
- const r = { index: -1, children: [] };
2117
- for (let a = 0; a < i; a++) {
2118
- const h = e[a], c = t[h], l = s[h];
2119
- let m = a + 1;
2120
- for (; m < i; m++) {
2121
- const d = e[m], x = t[d];
2122
- if (s[d].containsBox(l) && ks.isPointInPolygon(
2123
- c[M.randInt(0, c.length - 1)],
2124
- x
2125
- )) {
2126
- (o = n.get(d)) == null || o.children.push(n.get(h));
2127
- break;
2128
- }
2129
- }
2130
- m === i && r.children.push(n.get(h));
2131
- }
2132
- return r;
2133
- }
2134
- get area() {
2135
- if (this._loops.length === 0) return 0;
2136
- let t = 0;
2137
- for (let s = 0; s < this._loops.length; s++) {
2138
- const n = this._loops[s].getPoints(128), i = this.polygonArea(n);
2139
- s === 0 ? t += Math.abs(i) : t -= Math.abs(i);
2140
- }
2141
- return t;
2142
- }
2143
- polygonArea(t) {
2144
- const s = t.length;
2145
- if (s < 3) return 0;
2146
- let e = 0;
2147
- for (let n = 0, i = s - 1; n < s; i = n++) {
2148
- const r = t[i], o = t[n];
2149
- e += r.x * o.y - o.x * r.y;
2150
- }
2151
- return e * 0.5;
2152
- }
2153
- calculateBoundaryBoxes(t) {
2154
- const s = [];
2155
- return t.forEach((e) => {
2156
- s.push(new X().setFromPoints(e));
2157
- }), s;
2158
- }
2159
- sortBoundaryBoxesByAreas(t) {
2160
- const s = [];
2161
- t.forEach((n, i) => {
2162
- const r = n.size, o = r.width * r.height;
2163
- s.push({
2164
- area: o,
2165
- index: i
2166
- });
2167
- }), s.sort((n, i) => n.area - i.area);
2168
- const e = [];
2169
- return s.forEach((n) => {
2170
- e.push(n.index);
2171
- }), e;
2172
- }
2173
- }
2174
- class rt extends is {
2175
- constructor() {
2176
- super(), this.arcLengthDivisions = 100;
2177
- }
2178
- get startPoint() {
2179
- return this.getPoint(0);
2180
- }
2181
- get endPoint() {
2182
- return this.getPoint(1);
2183
- }
2184
- get length() {
2185
- return this.getLength();
2186
- }
2187
- getPoint(t) {
2188
- throw new Error("AcGeCurve2d: .getPoint() not implemented.");
2189
- }
2190
- getPointAt(t) {
2191
- const s = this.getUtoTmapping(t);
2192
- return this.getPoint(s);
2193
- }
2194
- getPoints(t = 5) {
2195
- const s = [];
2196
- for (let e = 0; e <= t; e++)
2197
- s.push(this.getPoint(e / t));
2198
- return s;
2199
- }
2200
- getSpacedPoints(t = 5) {
2201
- const s = [];
2202
- for (let e = 0; e <= t; e++)
2203
- s.push(this.getPointAt(e / t));
2204
- return s;
2205
- }
2206
- getLength() {
2207
- const t = this.getLengths();
2208
- return t[t.length - 1];
2209
- }
2210
- getLengths(t = this.arcLengthDivisions) {
2211
- const s = [];
2212
- let e, n = this.getPoint(0), i = 0;
2213
- s.push(0);
2214
- for (let r = 1; r <= t; r++)
2215
- e = this.getPoint(r / t), i += e.distanceTo(n), s.push(i), n = e;
2216
- return s;
2217
- }
2218
- getUtoTmapping(t, s) {
2219
- const e = this.getLengths();
2220
- let n = 0;
2221
- const i = e.length;
2222
- let r;
2223
- s ? r = s : r = t * e[i - 1];
2224
- let o = 0, a = i - 1, h;
2225
- for (; o <= a; )
2226
- if (n = Math.floor(o + (a - o) / 2), h = e[n] - r, h < 0)
2227
- o = n + 1;
2228
- else if (h > 0)
2229
- a = n - 1;
2230
- else {
2231
- a = n;
2232
- break;
2233
- }
2234
- if (n = a, e[n] === r)
2235
- return n / (i - 1);
2236
- const c = e[n], m = e[n + 1] - c, d = (r - c) / m;
2237
- return (n + d) / (i - 1);
2238
- }
2239
- getTangent(t) {
2240
- let e = t - 1e-4, n = t + 1e-4;
2241
- e < 0 && (e = 0), n > 1 && (n = 1);
2242
- const i = this.getPoint(e), r = this.getPoint(n), o = new S();
2243
- return o.copy(r).sub(i).normalize(), o;
2244
- }
2245
- getTangentAt(t) {
2246
- const s = this.getUtoTmapping(t);
2247
- return this.getTangent(s);
2248
- }
2249
- }
2250
- class $ extends rt {
2251
- constructor(t, s, e, n, i) {
2252
- super();
2253
- const r = +(t !== void 0) + +(s !== void 0) + +(e !== void 0) + +(n !== void 0) + +(i !== void 0);
2254
- if (r == 3)
2255
- typeof t == "object" && typeof s == "object" && typeof e == "object" ? this.createByThreePoints(
2256
- t,
2257
- s,
2258
- e
2259
- ) : this.createByStartEndPointsAndBulge(
2260
- t,
2261
- s,
2262
- e
2263
- );
2264
- else if (r == 5) {
2265
- const o = t;
2266
- this.center = new S(o.x, o.y), this.radius = s, this._clockwise = i, this._startAngle = this._clockwise ? this._mirrorAngle(M.normalizeAngle(e)) : M.normalizeAngle(e), this._endAngle = this._clockwise ? this._mirrorAngle(M.normalizeAngle(n)) : M.normalizeAngle(n);
2267
- } else
2268
- throw U.ILLEGAL_PARAMETERS;
2269
- }
2270
- createByThreePoints(t, s, e) {
2271
- const n = (A, k) => ({
2272
- x: (A.x + k.x) / 2,
2273
- y: (A.y + k.y) / 2
2274
- }), i = (A, k) => (k.y - A.y) / (k.x - A.x), r = (A) => -1 / A, o = n(t, s), a = n(s, e), h = i(t, s), c = i(s, e), l = r(h), m = r(c), d = (A, k, C, j) => {
2275
- const q = (j - k) / (A - C), W = A * q + k;
2276
- return { x: q, y: W };
2277
- }, x = o.y - l * o.x, g = a.y - m * a.x, y = d(l, x, m, g), p = Math.sqrt(
2278
- Math.pow(t.x - y.x, 2) + Math.pow(t.y - y.y, 2)
2279
- ), z = (A, k) => Math.atan2(A.y - k.y, A.x - k.x), f = z(t, y), b = z(s, y), P = z(e, y), I = P > f && P < b || f > P && f < b || b > P && b < f;
2280
- this.center = y, this.radius = p, this._clockwise = !I, this._startAngle = f, this._endAngle = P;
2281
- }
2282
- createByStartEndPointsAndBulge(t, s, e) {
2283
- let n, i, r;
2284
- e < 0 ? (n = Math.atan(-e) * 4, i = new B(t), r = new B(s)) : (n = Math.atan(e) * 4, i = new B(s), r = new B(t));
2285
- const o = new B().subVectors(r, i), a = o.length(), h = new B().addVectors(i, o.multiplyScalar(0.5)), c = Math.abs(a / 2 / Math.tan(n / 2)), l = o.normalize(), m = e < 0 ? -Math.PI / 2 : Math.PI / 2, d = new B(
2286
- l.x * Math.cos(m) - l.y * Math.sin(m),
2287
- l.y * Math.cos(m) + l.x * Math.sin(m)
2288
- );
2289
- let x;
2290
- n < Math.PI ? e < 0 ? x = h.add(d.multiplyScalar(c)) : x = h.add(d.multiplyScalar(-c)) : e < 0 ? x = h.add(d.multiplyScalar(-c)) : x = h.add(d.multiplyScalar(c)), e < 0 ? (this._startAngle = Math.atan2(i.y - x.y, i.x - x.x), this._endAngle = Math.atan2(r.y - x.y, r.x - x.x)) : (this._startAngle = Math.atan2(r.y - x.y, r.x - x.x), this._endAngle = Math.atan2(i.y - x.y, i.x - x.x)), this._clockwise = e < 0, this.center = x, this.radius = r.sub(x).length();
2291
- }
2292
- get center() {
2293
- return this._center;
2294
- }
2295
- set center(t) {
2296
- this._center = new S(t.x, t.y), this._boundingBoxNeedsUpdate = !0;
2297
- }
2298
- get radius() {
2299
- return this._radius;
2300
- }
2301
- set radius(t) {
2302
- this._radius = t, this._boundingBoxNeedsUpdate = !0;
2303
- }
2304
- get startAngle() {
2305
- return this._clockwise ? this._mirrorAngle(this._startAngle) : this._startAngle;
2306
- }
2307
- set startAngle(t) {
2308
- this._startAngle = this._clockwise ? this._mirrorAngle(M.normalizeAngle(t)) : M.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
2309
- }
2310
- get endAngle() {
2311
- return this._clockwise ? this._mirrorAngle(this._endAngle) : this._endAngle;
2312
- }
2313
- set endAngle(t) {
2314
- const s = this.startAngle == 0 && t == E ? t : M.normalizeAngle(t);
2315
- this._endAngle = this._clockwise ? this._mirrorAngle(s) : s, this._boundingBoxNeedsUpdate = !0;
2316
- }
2317
- _mirrorAngle(t) {
2318
- return (360 - t * 180 / Math.PI) % 360 * Math.PI / 180;
2319
- }
2320
- _getInternalAngle(t) {
2321
- return this._clockwise ? this._mirrorAngle(t) : t;
2322
- }
2323
- get deltaAngle() {
2324
- const t = this._getInternalAngle(this.startAngle), s = this._getInternalAngle(this.endAngle);
2325
- return this.clockwise ? M.normalizeAngle(t - s) : M.normalizeAngle(s - t);
2326
- }
2327
- get clockwise() {
2328
- return this._clockwise;
2329
- }
2330
- set clockwise(t) {
2331
- this._clockwise = t, this._boundingBoxNeedsUpdate = !0;
2332
- }
2333
- get startPoint() {
2334
- return this.getPointAtAngle(this.startAngle);
2335
- }
2336
- get endPoint() {
2337
- return this.getPointAtAngle(this.endAngle);
2338
- }
2339
- get midPoint() {
2340
- const t = this._getInternalAngle(this.startAngle), s = this._clockwise ? M.normalizeAngle(t - this.deltaAngle / 2) : M.normalizeAngle(t + this.deltaAngle / 2), e = this._clockwise ? this._mirrorAngle(s) : s;
2341
- return this.getPointAtAngle(e);
2342
- }
2343
- get closed() {
2344
- const t = this._getInternalAngle(this.startAngle), s = this._getInternalAngle(this.endAngle);
2345
- return Math.abs(s - t) / Math.PI % 2 == 0;
2346
- }
2347
- calculateBoundingBox() {
2348
- const t = [this.startPoint, this.endPoint], s = [0, Math.PI / 2, Math.PI, 3 * Math.PI / 2];
2349
- for (const i of s) {
2350
- const r = this._getInternalAngle(i);
2351
- M.isBetweenAngle(
2352
- r,
2353
- this._getInternalAngle(this.startAngle),
2354
- this._getInternalAngle(this.endAngle),
2355
- this.clockwise
2356
- ) && t.push(this.getPointAtAngle(i));
2357
- }
2358
- const e = t.map((i) => i.x), n = t.map((i) => i.y);
2359
- return new X(
2360
- new S(Math.min(...e), Math.min(...n)),
2361
- new S(Math.max(...e), Math.max(...n))
2362
- );
2363
- }
2364
- get length() {
2365
- return Math.abs(this.deltaAngle * this.radius);
2366
- }
2367
- transform(t) {
2368
- const s = t, e = this.center.clone().applyMatrix2d(s), n = this.startPoint.clone().applyMatrix2d(s);
2369
- if (this.closed)
2370
- return this.center = e, this.radius = e.distanceTo(n), this._startAngle = Math.atan2(
2371
- n.y - e.y,
2372
- n.x - e.x
2373
- ), this._endAngle = this._startAngle, this._clockwise = s.determinant() < 0 ? !this._clockwise : this._clockwise, this._boundingBoxNeedsUpdate = !0, this;
2374
- const i = this.midPoint.clone().applyMatrix2d(s), r = this.endPoint.clone().applyMatrix2d(s), o = new $(
2375
- n,
2376
- i,
2377
- r
2378
- ), a = s.determinant() < 0 ? !this.clockwise : this.clockwise, h = (c) => {
2379
- const l = M.normalizeAngle(c);
2380
- return a ? this._mirrorAngle(l) : l;
2381
- };
2382
- return this.center = o.center, this.radius = o.radius, this.clockwise = a, this.startAngle = h(
2383
- Math.atan2(
2384
- n.y - o.center.y,
2385
- n.x - o.center.x
2386
- )
2387
- ), this.endAngle = h(
2388
- Math.atan2(
2389
- r.y - o.center.y,
2390
- r.x - o.center.x
2391
- )
2392
- ), this._boundingBoxNeedsUpdate = !0, this;
2393
- }
2394
- clone() {
2395
- return new $(
2396
- this.center.clone(),
2397
- this.radius,
2398
- this._startAngle,
2399
- this._endAngle,
2400
- this.clockwise
2401
- );
2402
- }
2403
- getPointAtAngle(t) {
2404
- const s = this._getInternalAngle(t), e = this.center.x + this.radius * Math.cos(s), n = this.center.y + this.radius * Math.sin(s);
2405
- return new S(e, n);
2406
- }
2407
- getPoints(t = 100) {
2408
- const s = [];
2409
- let e = this.deltaAngle, n = this._getInternalAngle(this.startAngle);
2410
- if (this.closed && (e = E, n = 0), this.clockwise)
2411
- for (let i = 0; i <= t; i++) {
2412
- const r = n - e * (i / t), o = this._clockwise ? this._mirrorAngle(r) : r, a = this.getPointAtAngle(o);
2413
- s.push(new S(a.x, a.y));
2414
- }
2415
- else
2416
- for (let i = 0; i <= t; i++) {
2417
- const r = n + e * (i / t), o = this._clockwise ? this._mirrorAngle(r) : r, a = this.getPointAtAngle(o);
2418
- s.push(new S(a.x, a.y));
2419
- }
2420
- return s;
2421
- }
2422
- }
2423
- class qs extends ns {
2424
- translate(t) {
2425
- return this.transform(new O().makeTranslation(t.x, t.y, t.z));
2426
- }
2427
- get box() {
2428
- return (this._box == null || this._boundingBoxNeedsUpdate) && (this._box = this.calculateBoundingBox(), this._boundingBoxNeedsUpdate = !1), this._box;
2429
- }
2430
- }
2431
- class ot extends qs {
2432
- }
2433
- class Mt extends ot {
2434
- constructor(t, s) {
2435
- super(), this._start = new w(t), this._end = new w(s);
2436
- }
2437
- get startPoint() {
2438
- return this._start;
2439
- }
2440
- set startPoint(t) {
2441
- this._start.copy(t), this._boundingBoxNeedsUpdate = !0;
2442
- }
2443
- get endPoint() {
2444
- return this._end;
2445
- }
2446
- set endPoint(t) {
2447
- this._end.copy(t), this._boundingBoxNeedsUpdate = !0;
2448
- }
2449
- get direction() {
2450
- return new _().subVectors(this.endPoint, this.startPoint).normalize();
2451
- }
2452
- get midPoint() {
2453
- return new w(
2454
- (this._start.x + this._end.x) / 2,
2455
- (this._start.y + this._end.y) / 2,
2456
- (this._start.z + this._end.z) / 2
2457
- );
2458
- }
2459
- nearestPoint(t) {
2460
- return this.project(t);
2461
- }
2462
- get length() {
2463
- return this.startPoint.distanceTo(this.endPoint);
2464
- }
2465
- isPointOnLine(t) {
2466
- return this.project(t).distanceTo(t) < 1e-6;
2467
- }
2468
- at(t, s) {
2469
- return this.delta(s).multiplyScalar(t).add(this._start);
2470
- }
2471
- atLength(t, s = !1) {
2472
- if (s) {
2473
- const e = this.delta(Q).normalize();
2474
- return new w(this._start).addScaledVector(e, t);
2475
- } else {
2476
- const e = this.delta(Q).normalize();
2477
- return new w(this._end).addScaledVector(e, t);
2478
- }
2479
- }
2480
- extend(t, s = !1) {
2481
- if (s) {
2482
- const e = Q.subVectors(this._start, this._end).normalize();
2483
- this._start = new w(this._start).addScaledVector(
2484
- e,
2485
- t
2486
- );
2487
- } else {
2488
- const e = this.delta(Q).normalize();
2489
- this._end = new w(this._end).addScaledVector(e, t);
2490
- }
2491
- return this._boundingBoxNeedsUpdate = !0, this;
2492
- }
2493
- closestPointToPointParameter(t, s) {
2494
- Zt.subVectors(t, this._start), _t.subVectors(this.endPoint, this.startPoint);
2495
- const e = _t.dot(_t);
2496
- let i = _t.dot(Zt) / e;
2497
- return s && (i = M.clamp(i, 0, 1)), i;
2498
- }
2499
- closestPointToPoint(t, s, e) {
2500
- const n = this.closestPointToPointParameter(t, s);
2501
- return this.delta(e).multiplyScalar(n).add(this._start);
2502
- }
2503
- delta(t) {
2504
- return t.subVectors(this._end, this._start);
2505
- }
2506
- distanceSq() {
2507
- return this._start.distanceToSquared(this._end);
2508
- }
2509
- distance() {
2510
- return this._start.distanceTo(this._end);
2511
- }
2512
- project(t) {
2513
- const s = this.direction, n = Q.subVectors(t, this.startPoint).dot(s);
2514
- return new w().copy(s).multiplyScalar(n).add(this.startPoint);
2515
- }
2516
- perpPoint(t) {
2517
- const s = this.direction, e = this.startPoint, i = Q.subVectors(t, e).dot(s), r = Q.copy(s).multiplyScalar(i);
2518
- return new w().addVectors(e, r);
2519
- }
2520
- calculateBoundingBox() {
2521
- const t = new w(
2522
- Math.min(this._start.x, this._end.x),
2523
- Math.min(this._start.y, this._end.y),
2524
- Math.min(this._start.z, this._end.z)
2525
- ), s = new w(
2526
- Math.max(this._start.x, this._end.x),
2527
- Math.max(this._start.y, this._end.y),
2528
- Math.max(this._start.z, this._end.z)
2529
- );
2530
- return new v(t, s);
2531
- }
2532
- transform(t) {
2533
- return this._start.applyMatrix4(t), this._end.applyMatrix4(t), this._boundingBoxNeedsUpdate = !0, this;
2534
- }
2535
- get closed() {
2536
- return !1;
2537
- }
2538
- copy(t) {
2539
- return this.startPoint = t.startPoint, this.endPoint = t.endPoint, this._boundingBoxNeedsUpdate = !0, this;
2540
- }
2541
- clone() {
2542
- return new Mt(this._start.clone(), this._end.clone());
2543
- }
2544
- }
2545
- const Q = new _(), Zt = new _(), _t = new _();
2546
- class At extends ot {
2547
- static computeCenterPoint(t, s, e) {
2548
- const n = new _().addVectors(t, s).multiplyScalar(0.5), i = new _().addVectors(t, e).multiplyScalar(0.5), r = new _().subVectors(s, t), o = new _().subVectors(e, t), a = new _().crossVectors(r, o).normalize();
2549
- if (a.lengthSq() === 0)
2550
- return null;
2551
- const h = new _().crossVectors(r, a).normalize(), c = new _().crossVectors(o, a).normalize(), l = h.clone().multiplyScalar(Number.MAX_SAFE_INTEGER), m = c.clone().multiplyScalar(Number.MAX_SAFE_INTEGER), d = new Mt(n, n.clone().add(l)), x = new Mt(i, i.clone().add(m)), g = new _();
2552
- return d.closestPointToPoint(x.startPoint, !0, g) ? g : null;
2553
- }
2554
- static createByThreePoints(t, s, e) {
2555
- const n = At.computeCenterPoint(
2556
- t,
2557
- s,
2558
- e
2559
- );
2560
- if (n) {
2561
- const i = n.distanceTo(t), r = new _().subVectors(t, n), o = new _().subVectors(s, n), a = Math.atan2(r.y, r.x), h = Math.atan2(o.y, o.x);
2562
- return new At(
2563
- n,
2564
- i,
2565
- a,
2566
- h,
2567
- _.Z_AXIS
2568
- );
2569
- }
2570
- }
2571
- constructor(t, s, e, n, i, r = _.X_AXIS) {
2572
- super(), this.center = t, this.radius = s, this.startAngle = e, this.endAngle = n, this.normal = i, this.refVec = r, (n - e) % E == 0 ? (this.startAngle = 0, this.endAngle = E) : (this.startAngle = e, this.endAngle = n);
2573
- }
2574
- get center() {
2575
- return this._center;
2576
- }
2577
- set center(t) {
2578
- this._center = new w(t.x, t.y, t.z || 0), this._boundingBoxNeedsUpdate = !0;
2579
- }
2580
- get radius() {
2581
- return this._radius;
2582
- }
2583
- set radius(t) {
2584
- if (t < 0) throw U.ILLEGAL_PARAMETERS;
2585
- this._radius = t, this._boundingBoxNeedsUpdate = !0;
2586
- }
2587
- get startAngle() {
2588
- return this._startAngle;
2589
- }
2590
- set startAngle(t) {
2591
- this._startAngle = M.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
2592
- }
2593
- get endAngle() {
2594
- return this._endAngle;
2595
- }
2596
- set endAngle(t) {
2597
- this._endAngle = this.startAngle == 0 && t == E ? t : M.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
2598
- }
2599
- get deltaAngle() {
2600
- return M.normalizeAngle(this.endAngle - this.startAngle);
2601
- }
2602
- get isLargeArc() {
2603
- return Math.abs(this.deltaAngle) > Math.PI ? 1 : 0;
2604
- }
2605
- get clockwise() {
2606
- return this.deltaAngle <= 0;
2607
- }
2608
- get normal() {
2609
- return this._normal;
2610
- }
2611
- set normal(t) {
2612
- this._normal = new _(t.x, t.y, t.z), this._normal.normalize(), this._boundingBoxNeedsUpdate = !0;
2613
- }
2614
- get refVec() {
2615
- return this._refVec;
2616
- }
2617
- set refVec(t) {
2618
- this._refVec = new _(t.x, t.y, t.z), this._refVec.normalize(), this._boundingBoxNeedsUpdate = !0;
2619
- }
2620
- get startPoint() {
2621
- return this.getPointAtAngle(this._startAngle);
2622
- }
2623
- get endPoint() {
2624
- return this.getPointAtAngle(this._endAngle);
2625
- }
2626
- get midPoint() {
2627
- let t = this.startAngle, s = this.deltaAngle;
2628
- this.closed && (t = 0, s = E);
2629
- const e = t + s * 0.5;
2630
- return this.getPointAtAngle(e);
2631
- }
2632
- get length() {
2633
- return this.closed ? 2 * Math.PI * this.radius : Math.abs(this.deltaAngle * this.radius);
2634
- }
2635
- get area() {
2636
- return this.closed ? Math.PI * this.radius * this.radius : Math.abs(this.deltaAngle * this.radius * this.radius);
2637
- }
2638
- nearestPoint(t) {
2639
- const s = new _(t.x, t.y, t.z || 0), e = this.center, n = this.normal, r = s.clone().sub(e).dot(n), a = s.clone().sub(n.clone().multiplyScalar(r)).clone().sub(e);
2640
- if (a.lengthSq() === 0)
2641
- return this.startPoint.clone();
2642
- a.normalize().multiplyScalar(this.radius);
2643
- const h = e.clone().add(a), c = this.getAngle(h.clone()), l = this.startAngle, m = this.deltaAngle;
2644
- let d = M.normalizeAngle(c - l);
2645
- d < 0 && (d = 0), d > m && (d = m);
2646
- const x = this.getPointAtAngle(l + d), g = x.distanceTo(s), y = this.startPoint.distanceTo(s), p = this.endPoint.distanceTo(s);
2647
- return y < g && y <= p ? this.startPoint.clone() : p < g && p < y ? this.endPoint.clone() : x;
2648
- }
2649
- tangentPoints(t) {
2650
- const s = [], e = new _(t.x, t.y, t.z || 0), n = this.center, i = this.normal, r = this.radius, a = e.clone().sub(n).dot(i), h = e.clone().sub(i.clone().multiplyScalar(a)), c = n.clone(), m = h.clone().sub(c).length();
2651
- if (m < r) return s;
2652
- const d = Math.acos(r / m), x = this.getAngle(h.clone()), g = [x + d, x - d];
2653
- for (const y of g) {
2654
- const p = M.normalizeAngle(y - this.startAngle);
2655
- p >= 0 && p <= this.deltaAngle && s.push(this.getPointAtAngle(this.startAngle + p));
2656
- }
2657
- return s;
2658
- }
2659
- nearestTangentPoint(t) {
2660
- const s = this.tangentPoints(t);
2661
- if (s.length === 0) return null;
2662
- const e = new w(t.x, t.y, t.z || 0);
2663
- return s.length === 1 || s[0].distanceTo(e) < s[1].distanceTo(e) ? s[0] : s[1];
2664
- }
2665
- calculateBoundingBox() {
2666
- const t = [this.startAngle, this.endAngle];
2667
- for (let a = 0; a < 2 * Math.PI; a += Math.PI / 2)
2668
- M.isBetweenAngle(a, this.startAngle, this.endAngle) && t.push(a);
2669
- let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, o = -1 / 0;
2670
- for (const a of t) {
2671
- const h = this.getPointAtAngle(a);
2672
- h.x < s && (s = h.x), h.y < e && (e = h.y), h.z < n && (n = h.z), h.x > i && (i = h.x), h.y > r && (r = h.y), h.z > o && (o = h.z);
2673
- }
2674
- return new v(
2675
- { x: s, y: e, z: n },
2676
- { x: i, y: r, z: o }
2677
- );
2678
- }
2679
- get closed() {
2680
- return Math.abs(this.endAngle - this.startAngle) / Math.PI % 2 == 0;
2681
- }
2682
- getPoints(t) {
2683
- const s = [];
2684
- let e = this.deltaAngle, n = this.startAngle;
2685
- this.closed && (e = E, n = 0);
2686
- for (let i = 0; i <= t; i++) {
2687
- const r = n + e * (i / t), o = this.getPointAtAngle(r);
2688
- s.push(o);
2689
- }
2690
- return s;
2691
- }
2692
- transform(t) {
2693
- const s = this.center.clone().applyMatrix4(t), e = this.startPoint.clone().applyMatrix4(t), n = this.endPoint.clone().applyMatrix4(t), i = this.getPointAtAngle(
2694
- this.closed ? Math.PI / 2 : this.startAngle + this.deltaAngle / 2
2695
- ).clone().applyMatrix4(t), r = new _(e).sub(s).normalize(), o = s.distanceTo(e);
2696
- let a = new _().crossVectors(
2697
- new _(e).sub(s),
2698
- new _(i).sub(s)
2699
- ).normalize();
2700
- a.lengthSq() === 0 && (a = this.normal.clone().transformDirection(t));
2701
- const h = (c) => {
2702
- const l = new _(c).sub(s);
2703
- return Math.atan2(
2704
- l.dot(Ot.crossVectors(a, r)),
2705
- l.dot(r)
2706
- );
2707
- };
2708
- return this.center = s, this.radius = o, this.normal = a, this.refVec = r, this.startAngle = 0, this.endAngle = this.closed ? E : h(n), this._boundingBoxNeedsUpdate = !0, this;
2709
- }
2710
- copy(t) {
2711
- return this.center = t.center, this.radius = t.radius, this.startAngle = t.startAngle, this.endAngle = t.endAngle, this.normal = t.normal, this.refVec = t.refVec, this._boundingBoxNeedsUpdate = !0, this;
2712
- }
2713
- clone() {
2714
- return new At(
2715
- this.center.clone(),
2716
- this.radius,
2717
- this.startAngle,
2718
- this.endAngle,
2719
- this.normal,
2720
- this.refVec
2721
- );
2722
- }
2723
- getAngle(t) {
2724
- return t.sub(this.center), Math.atan2(
2725
- t.dot(Ot.crossVectors(this.refVec, this.normal)),
2726
- t.dot(this.refVec)
2727
- );
2728
- }
2729
- getPointAtAngle(t) {
2730
- const s = this.normal, e = this.refVec, n = {
2731
- x: s.y * e.z - s.z * e.y,
2732
- y: s.z * e.x - s.x * e.z,
2733
- z: s.x * e.y - s.y * e.x
2734
- }, i = this.center, r = this.radius;
2735
- return new w(
2736
- i.x + r * (e.x * Math.cos(t) + n.x * Math.sin(t)),
2737
- i.y + r * (e.y * Math.cos(t) + n.y * Math.sin(t)),
2738
- i.z + r * (e.z * Math.cos(t) + n.z * Math.sin(t))
2739
- );
2740
- }
2741
- get plane() {
2742
- const t = new _(this.center).distanceTo(Jt);
2743
- return new Ct(this.normal, t);
2744
- }
2745
- }
2746
- const Ot = new _();
2747
- class G extends rt {
2748
- constructor(t, s, e, n = 0, i = E, r = !1, o = 0) {
2749
- super(), this.center = t, this.majorAxisRadius = s, this.minorAxisRadius = e, (i - n) % E == 0 ? (this.startAngle = 0, this.endAngle = E) : (this.startAngle = n, this.endAngle = i), this.clockwise = r, this.rotation = o;
2750
- }
2751
- get center() {
2752
- return this._center;
2753
- }
2754
- set center(t) {
2755
- this._center = new w(t.x, t.y, t.z || 0), this._boundingBoxNeedsUpdate = !0;
2756
- }
2757
- get majorAxisRadius() {
2758
- return this._majorAxisRadius;
2759
- }
2760
- set majorAxisRadius(t) {
2761
- if (t < 0) throw U.ILLEGAL_PARAMETERS;
2762
- this._majorAxisRadius = t, this._boundingBoxNeedsUpdate = !0;
2763
- }
2764
- get minorAxisRadius() {
2765
- return this._minorAxisRadius;
2766
- }
2767
- set minorAxisRadius(t) {
2768
- if (t < 0) throw U.ILLEGAL_PARAMETERS;
2769
- this._minorAxisRadius = t, this._boundingBoxNeedsUpdate = !0;
2770
- }
2771
- get startAngle() {
2772
- return this._startAngle;
2773
- }
2774
- set startAngle(t) {
2775
- this._startAngle = M.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
2776
- }
2777
- get endAngle() {
2778
- return this._endAngle;
2779
- }
2780
- set endAngle(t) {
2781
- this._endAngle = this.startAngle == 0 && t == E ? t : M.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
2782
- }
2783
- get clockwise() {
2784
- return this._clockwise;
2785
- }
2786
- set clockwise(t) {
2787
- this._clockwise = t, this._boundingBoxNeedsUpdate = !0;
2788
- }
2789
- get rotation() {
2790
- return this._rotation;
2791
- }
2792
- set rotation(t) {
2793
- this._rotation = t, this._boundingBoxNeedsUpdate = !0;
2794
- }
2795
- get deltaAngle() {
2796
- return M.normalizeAngle(this.endAngle - this.startAngle);
2797
- }
2798
- get isLargeArc() {
2799
- return Math.abs(this.deltaAngle) > Math.PI ? 1 : 0;
2800
- }
2801
- calculateBoundingBox() {
2802
- let s = 1 / 0, e = 1 / 0, n = -1 / 0, i = -1 / 0;
2803
- for (let r = 0; r <= 100; r++) {
2804
- const o = this.getPoint(r / 100);
2805
- s = Math.min(s, o.x), e = Math.min(e, o.y), n = Math.max(n, o.x), i = Math.max(i, o.y);
2806
- }
2807
- return new X({ x: s, y: e }, { x: n, y: i });
2808
- }
2809
- get closed() {
2810
- return this.deltaAngle == 0;
2811
- }
2812
- getPoint(t) {
2813
- const s = Math.PI * 2;
2814
- let e = this.endAngle - this.startAngle;
2815
- const n = Math.abs(e) < Number.EPSILON;
2816
- for (; e < 0; ) e += s;
2817
- for (; e > s; ) e -= s;
2818
- e < Number.EPSILON && (n ? e = 0 : e = s), this.clockwise === !0 && !n && (e === s ? e = -s : e = e - s);
2819
- const i = this.startAngle + t * e;
2820
- let r = this.center.x + this.majorAxisRadius * Math.cos(i), o = this.center.y + this.minorAxisRadius * Math.sin(i);
2821
- if (this.rotation !== 0) {
2822
- const a = Math.cos(this.rotation), h = Math.sin(this.rotation), c = r - this.center.x, l = o - this.center.y;
2823
- r = c * a - l * h + this.center.x, o = c * h + l * a + this.center.y;
2824
- }
2825
- return new S(r, o);
2826
- }
2827
- transform(t) {
2828
- const s = t, e = new S(this.center).applyMatrix2d(
2829
- s
2830
- ), n = new w(
2831
- e.x,
2832
- e.y,
2833
- this.center.z
2834
- ), i = this.getPointAtAngle(0).clone().applyMatrix2d(s), r = this.getPointAtAngle(Math.PI / 2).clone().applyMatrix2d(s), o = new S(i).sub(
2835
- e
2836
- ), a = new S(r).sub(
2837
- e
2838
- ), h = o.length(), c = a.length(), l = Math.atan2(o.y, o.x), m = o.clone().normalize(), d = a.clone().normalize(), x = (p) => {
2839
- const z = new S(p).sub(e), f = z.dot(m), b = z.dot(d);
2840
- return M.normalizeAngle(
2841
- Math.atan2(b / c, f / h)
2842
- );
2843
- }, g = s.determinant() < 0 ? !this.clockwise : this.clockwise, y = this.closed ? new G(
2844
- n,
2845
- h,
2846
- c,
2847
- 0,
2848
- E,
2849
- g,
2850
- l
2851
- ) : new G(
2852
- n,
2853
- h,
2854
- c,
2855
- x(this.startPoint.clone().applyMatrix2d(s)),
2856
- x(this.endPoint.clone().applyMatrix2d(s)),
2857
- g,
2858
- l
2859
- );
2860
- return this.center = y.center, this.majorAxisRadius = y.majorAxisRadius, this.minorAxisRadius = y.minorAxisRadius, this._startAngle = y._startAngle, this._endAngle = y._endAngle, this._clockwise = y._clockwise, this.rotation = y.rotation, this._boundingBoxNeedsUpdate = !0, this;
2861
- }
2862
- getPointAtAngle(t) {
2863
- return this.getPoint(
2864
- this.closed ? t / E : M.normalizeAngle(t - this.startAngle) / this.deltaAngle
2865
- );
2866
- }
2867
- copy(t) {
2868
- return this.center = t.center, this.majorAxisRadius = t.majorAxisRadius, this.minorAxisRadius = t.minorAxisRadius, this.startAngle = t.startAngle, this.endAngle = t.endAngle, this.clockwise = t.clockwise, this.rotation = t.rotation, this;
2869
- }
2870
- clone() {
2871
- return new G(
2872
- this.center,
2873
- this.majorAxisRadius,
2874
- this.minorAxisRadius,
2875
- this.startAngle,
2876
- this.endAngle,
2877
- this.clockwise,
2878
- this.rotation
2879
- );
2880
- }
2881
- }
2882
- class wt extends ot {
2883
- constructor(t, s, e, n, i, r = 0, o = E) {
2884
- super(), this.center = t, this.normal = s, this.majorAxis = e, this.majorAxisRadius = n, this.minorAxisRadius = i;
2885
- const a = Math.abs(o - r);
2886
- Math.abs(a - E) < 1e-10 || Math.abs(a - 2 * E) < 1e-10 ? (this.startAngle = 0, this.endAngle = E) : (this.startAngle = r, this.endAngle = o);
2887
- }
2888
- get center() {
2889
- return this._center;
2890
- }
2891
- set center(t) {
2892
- this._center = new w(t.x, t.y, t.z || 0), this._boundingBoxNeedsUpdate = !0;
2893
- }
2894
- get majorAxisRadius() {
2895
- return this._majorAxisRadius;
2896
- }
2897
- set majorAxisRadius(t) {
2898
- if (t < 0) throw U.ILLEGAL_PARAMETERS;
2899
- this._majorAxisRadius = t, this._boundingBoxNeedsUpdate = !0;
2900
- }
2901
- get minorAxisRadius() {
2902
- return this._minorAxisRadius;
2903
- }
2904
- set minorAxisRadius(t) {
2905
- if (t < 0) throw U.ILLEGAL_PARAMETERS;
2906
- this._minorAxisRadius = t, this._boundingBoxNeedsUpdate = !0;
2907
- }
2908
- get startAngle() {
2909
- return this._startAngle;
2910
- }
2911
- set startAngle(t) {
2912
- this._startAngle = M.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
2913
- }
2914
- get endAngle() {
2915
- return this._endAngle;
2916
- }
2917
- set endAngle(t) {
2918
- this._endAngle = this.startAngle == 0 && t == E ? t : M.normalizeAngle(t), this._boundingBoxNeedsUpdate = !0;
2919
- }
2920
- get deltaAngle() {
2921
- const t = this.endAngle - this.startAngle;
2922
- return Math.abs(t - E) < 1e-10 ? E : M.normalizeAngle(t);
2923
- }
2924
- get isLargeArc() {
2925
- return Math.abs(this.deltaAngle) > Math.PI ? 1 : 0;
2926
- }
2927
- get clockwise() {
2928
- return this.deltaAngle <= 0;
2929
- }
2930
- get normal() {
2931
- return this._normal;
2932
- }
2933
- set normal(t) {
2934
- this._normal = new _(t.x, t.y, t.z), this._normal.normalize(), this._boundingBoxNeedsUpdate = !0;
2935
- }
2936
- get majorAxis() {
2937
- return this._majorAxis;
2938
- }
2939
- set majorAxis(t) {
2940
- this._majorAxis = new _(t.x, t.y, t.z), this._majorAxis.normalize(), this._boundingBoxNeedsUpdate = !0;
2941
- }
2942
- get minorAxis() {
2943
- return new _().crossVectors(this.normal, this.majorAxis).normalize();
2944
- }
2945
- get startPoint() {
2946
- return this.getPointAtAngle(this._startAngle);
2947
- }
2948
- get endPoint() {
2949
- return this.getPointAtAngle(this._endAngle);
2950
- }
2951
- get midPoint() {
2952
- let t = this.startAngle, s = this.deltaAngle;
2953
- (this.closed || Math.abs(s - E) < 1e-10) && (t = 0, s = E);
2954
- const e = t + s / 2;
2955
- return this.getPointAtAngle(e);
2956
- }
2957
- get isCircular() {
2958
- return bt.equal(this.majorAxisRadius, this.minorAxisRadius);
2959
- }
2960
- get length() {
2961
- if (this.isCircular)
2962
- return this.majorAxisRadius * Math.abs(this.deltaAngle);
2963
- const t = 1e3, s = this.deltaAngle / t;
2964
- let e = 0, n = this.getPointAtAngle(this.startAngle);
2965
- for (let i = 1; i <= t; i++) {
2966
- const r = this.startAngle + i * s, o = this.getPointAtAngle(r), a = o.x - n.x, h = o.y - n.y, c = o.z - n.z;
2967
- e += Math.sqrt(a * a + h * h + c * c), n = o;
2968
- }
2969
- return e;
2970
- }
2971
- get area() {
2972
- const t = this.majorAxisRadius, s = this.minorAxisRadius, e = this.startAngle, n = e + this.deltaAngle;
2973
- if (Math.abs(this.deltaAngle - E) < 1e-10)
2974
- return Math.PI * t * s;
2975
- const i = t * s / 2 * (n - e - (Math.sin(n) * Math.cos(n) - Math.sin(e) * Math.cos(e)));
2976
- return Math.abs(i);
2977
- }
2978
- calculateBoundingBox() {
2979
- if (this.majorAxis.equals(_.X_AXIS) || this.majorAxis.equals(_.Y_AXIS) || this.majorAxis.isParallelTo(_.X_AXIS) || this.majorAxis.isParallelTo(_.Y_AXIS)) {
2980
- const t = [this.startAngle, this.endAngle];
2981
- for (let a = 0; a < 2 * Math.PI; a += Math.PI / 2)
2982
- M.isBetweenAngle(a, this.startAngle, this.endAngle) && t.push(a);
2983
- let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, o = -1 / 0;
2984
- for (const a of t) {
2985
- const h = this.getPointAtAngle(a);
2986
- h.x < s && (s = h.x), h.y < e && (e = h.y), h.z < n && (n = h.z), h.x > i && (i = h.x), h.y > r && (r = h.y), h.z > o && (o = h.z);
2987
- }
2988
- return new v(
2989
- { x: s, y: e, z: n },
2990
- { x: i, y: r, z: o }
2991
- );
2992
- } else {
2993
- let s = 1 / 0, e = 1 / 0, n = 1 / 0, i = -1 / 0, r = -1 / 0, o = -1 / 0;
2994
- for (let a = 0; a <= 100; a++) {
2995
- const h = this.startAngle + this.deltaAngle * (a / 100), c = this.getPointAtAngle(h);
2996
- s = Math.min(s, c.x), e = Math.min(e, c.y), n = Math.min(n, c.z), i = Math.max(i, c.x), r = Math.max(r, c.y), o = Math.max(o, c.z);
2997
- }
2998
- return new v(
2999
- { x: s, y: e, z: n },
3000
- { x: i, y: r, z: o }
3001
- );
3002
- }
3003
- }
3004
- get closed() {
3005
- return this.deltaAngle == 0;
3006
- }
3007
- getPoints(t = 100) {
3008
- const s = [];
3009
- let e = this.deltaAngle, n = this.startAngle;
3010
- this.closed && (e = E, n = 0);
3011
- for (let i = 0; i <= t; i++) {
3012
- const r = n + e * (i / t), o = this.getPointAtAngle(r);
3013
- s.push(o);
3014
- }
3015
- return s;
3016
- }
3017
- getPointAtAngle(t) {
3018
- const s = Math.cos(t), e = Math.sin(t), n = this.minorAxis.clone().multiplyScalar(this.minorAxisRadius).multiplyScalar(e), i = this.majorAxis.clone().multiplyScalar(s * this.majorAxisRadius).add(n);
3019
- return new w(
3020
- this.center.x + i.x,
3021
- this.center.y + i.y,
3022
- this.center.z + i.z
3023
- );
3024
- }
3025
- contains(t) {
3026
- const s = new _(t).sub(this.center), e = s.dot(this.majorAxis), n = s.dot(this.minorAxis), i = e / this.majorAxisRadius, r = n / this.minorAxisRadius;
3027
- return i * i + r * r <= 1;
3028
- }
3029
- transform(t) {
3030
- const s = t, e = this.center.clone().applyMatrix4(s), n = this.getPointAtAngle(0).clone().applyMatrix4(s), i = this.getPointAtAngle(Math.PI / 2).clone().applyMatrix4(s), r = new _(n).sub(
3031
- e
3032
- ), o = new _(i).sub(
3033
- e
3034
- ), a = r.length(), h = o.length(), c = r.clone().normalize(), l = new _().crossVectors(r, o).normalize();
3035
- let m = new _().crossVectors(l, c).normalize();
3036
- m.dot(o) < 0 && (l.negate(), m = new _().crossVectors(l, c).normalize());
3037
- const d = (g) => {
3038
- const y = new _(g).sub(e), p = y.dot(c), z = y.dot(m);
3039
- return M.normalizeAngle(
3040
- Math.atan2(z / h, p / a)
3041
- );
3042
- }, x = this.closed ? new wt(
3043
- e,
3044
- l,
3045
- c,
3046
- a,
3047
- h,
3048
- 0,
3049
- E
3050
- ) : new wt(
3051
- e,
3052
- l,
3053
- c,
3054
- a,
3055
- h,
3056
- d(this.startPoint.clone().applyMatrix4(s)),
3057
- d(this.endPoint.clone().applyMatrix4(s))
3058
- );
3059
- return this.center = x.center, this.normal = x.normal, this.majorAxis = x.majorAxis, this.majorAxisRadius = x.majorAxisRadius, this.minorAxisRadius = x.minorAxisRadius, this._startAngle = x._startAngle, this._endAngle = x._endAngle, this._boundingBoxNeedsUpdate = !0, this;
3060
- }
3061
- copy(t) {
3062
- return this.center = t.center, this.normal = t.normal, this.majorAxis = t.majorAxis, this.majorAxisRadius = t.majorAxisRadius, this.minorAxisRadius = t.minorAxisRadius, this.startAngle = t.startAngle, this.endAngle = t.endAngle, this._boundingBoxNeedsUpdate = !0, this;
3063
- }
3064
- clone() {
3065
- return new wt(
3066
- this.center,
3067
- this.normal,
3068
- this.majorAxis,
3069
- this.majorAxisRadius,
3070
- this.minorAxisRadius,
3071
- this.startAngle,
3072
- this.endAngle
3073
- );
3074
- }
3075
- get plane() {
3076
- const t = new _(this.center).distanceTo(Jt);
3077
- return new Ct(this.normal, t);
3078
- }
3079
- }
3080
- class os extends rt {
3081
- constructor(t = null, s = !1) {
3082
- super(), this._vertices = t || new Array(), this._closed = s;
3083
- }
3084
- get vertices() {
3085
- return this._vertices;
3086
- }
3087
- get numberOfVertices() {
3088
- return this._vertices.length;
3089
- }
3090
- get closed() {
3091
- return this._closed;
3092
- }
3093
- get startPoint() {
3094
- if (this.numberOfVertices > 0) {
3095
- const t = this._vertices[0];
3096
- return new S(t.x, t.y);
3097
- }
3098
- throw new Error("Start point does not exist in an empty polyline.");
3099
- }
3100
- get endPoint() {
3101
- const t = this.numberOfVertices;
3102
- if (t > 0)
3103
- if (this.closed) {
3104
- const s = this._vertices[0];
3105
- return new S(s.x, s.y);
3106
- } else {
3107
- const s = this._vertices[t - 1];
3108
- return new S(s.x, s.y);
3109
- }
3110
- throw new Error("End point does not exist in an empty polyline.");
3111
- }
3112
- get length() {
3113
- let t = 0;
3114
- const s = this._vertices.length;
3115
- for (let e = 0; e < s; ++e) {
3116
- const n = this._vertices[e];
3117
- let i = null;
3118
- if (e < s - 1 ? i = this._vertices[e + 1] : e == s - 1 && this.closed && (i = this._vertices[0]), i)
3119
- if (n.bulge) {
3120
- const r = new $(n, i, n.bulge);
3121
- t += r.length;
3122
- } else
3123
- t += new S(n.x, n.y).distanceTo(i);
3124
- }
3125
- return t;
3126
- }
3127
- set closed(t) {
3128
- this._closed = t, this._boundingBoxNeedsUpdate = !0;
3129
- }
3130
- addVertexAt(t, s) {
3131
- t <= 0 ? this._vertices.unshift(s) : this._vertices.splice(t, 0, s), this._boundingBoxNeedsUpdate = !0;
3132
- }
3133
- removeVertexAt(t) {
3134
- if (t < 0 || t >= this._vertices.length)
3135
- throw new Error(
3136
- `Index ${t} is out of bounds. Valid range is 0 to ${this._vertices.length - 1}.`
3137
- );
3138
- this._vertices.splice(t, 1), this._boundingBoxNeedsUpdate = !0;
3139
- }
3140
- reset(t, s) {
3141
- t ? s !== void 0 && s >= 0 && s < this._vertices.length && (this._vertices = this._vertices.slice(0, s), this._boundingBoxNeedsUpdate = !0) : (this._vertices = new Array(), this._boundingBoxNeedsUpdate = !0);
3142
- }
3143
- getPointAt(t) {
3144
- const s = this._vertices[t];
3145
- return new S(s.x, s.y);
3146
- }
3147
- calculateBoundingBox() {
3148
- const t = this.getPoints(100);
3149
- return new X().setFromPoints(t);
3150
- }
3151
- transform(t) {
3152
- const s = t.determinant() < 0;
3153
- return this._vertices.forEach((e) => {
3154
- const n = new S(e).applyMatrix2d(t);
3155
- e.x = n.x, e.y = n.y, s && e.bulge != null && (e.bulge = -e.bulge);
3156
- }), this._boundingBoxNeedsUpdate = !0, this;
3157
- }
3158
- clone() {
3159
- return new os(
3160
- this._vertices.map((t) => ({ ...t })),
3161
- this._closed
3162
- );
3163
- }
3164
- getPoints3d(t, s) {
3165
- const e = [];
3166
- return this.getPoints(t).forEach(
3167
- (i) => e.push(new w().set(i.x, i.y, s))
3168
- ), e;
3169
- }
3170
- getPoints(t) {
3171
- const s = [], e = this._vertices.length;
3172
- for (let n = 0; n < e; ++n) {
3173
- const i = this._vertices[n];
3174
- if (i.bulge) {
3175
- let r = null;
3176
- if (n < e - 1 ? r = this._vertices[n + 1] : n == e - 1 && this.closed && (r = this._vertices[0]), r) {
3177
- const a = new $(i, r, i.bulge).getPoints(t), h = a.length;
3178
- for (let c = 0; c < h; ++c) {
3179
- const l = a[c];
3180
- s.push(new S(l.x, l.y));
3181
- }
3182
- }
3183
- } else
3184
- s.push(new S(i.x, i.y)), n == e - 1 && this.closed && s.push(s[0]);
3185
- }
3186
- return s;
3187
- }
3188
- }
3189
- class Pt extends rt {
3190
- constructor(t, s) {
3191
- super(), this._start = new S(t), this._end = new S(s);
3192
- }
3193
- get startPoint() {
3194
- return this._start;
3195
- }
3196
- set startPoint(t) {
3197
- this._start.copy(t), this._boundingBoxNeedsUpdate = !0;
3198
- }
3199
- get endPoint() {
3200
- return this._end;
3201
- }
3202
- set endPoint(t) {
3203
- this._end.copy(t), this._boundingBoxNeedsUpdate = !0;
3204
- }
3205
- getPoints() {
3206
- return [this.startPoint, this.endPoint];
3207
- }
3208
- get length() {
3209
- return this.startPoint.distanceTo(this.endPoint);
3210
- }
3211
- calculateBoundingBox() {
3212
- const t = new S(
3213
- Math.min(this._start.x, this._end.x),
3214
- Math.min(this._start.y, this._end.y)
3215
- ), s = new S(
3216
- Math.max(this._start.x, this._end.x),
3217
- Math.max(this._start.y, this._end.y)
3218
- );
3219
- return new X(t, s);
3220
- }
3221
- transform(t) {
3222
- return this._start.applyMatrix2d(t), this._end.applyMatrix2d(t), this._boundingBoxNeedsUpdate = !0, this;
3223
- }
3224
- get closed() {
3225
- return !1;
3226
- }
3227
- copy(t) {
3228
- return this.startPoint = t.startPoint, this.endPoint = t.endPoint, this._boundingBoxNeedsUpdate = !0, this;
3229
- }
3230
- clone() {
3231
- return new Pt(this._start.clone(), this._end.clone());
3232
- }
3233
- }
3234
- class F extends rt {
3235
- constructor(t = []) {
3236
- super(), this._curves = t;
3237
- }
3238
- get curves() {
3239
- return this._curves;
3240
- }
3241
- static buildFromEdges(t, s = 1e-3) {
3242
- if (t.length === 0) return [];
3243
- const e = [...t], n = [], i = s * s, r = (o, a) => {
3244
- const h = o.x - a.x, c = o.y - a.y;
3245
- return h * h + c * c <= i;
3246
- };
3247
- for (; e.length > 0; ) {
3248
- const o = [], a = e.shift();
3249
- o.push(a);
3250
- const h = F.getEdgeStartPoint(a);
3251
- let c = F.getEdgeEndPoint(a);
3252
- if (!r(h, c))
3253
- for (; e.length > 0; ) {
3254
- const l = F.findConnectingEdge(
3255
- e,
3256
- c,
3257
- i
3258
- );
3259
- if (l.index < 0) break;
3260
- let m = e.splice(l.index, 1)[0];
3261
- if (l.reverse && (m = F.reverseEdge(m)), o.push(m), c = F.getEdgeEndPoint(m), r(c, h)) break;
3262
- }
3263
- n.push(new F(o));
3264
- }
3265
- return n;
3266
- }
3267
- add(t) {
3268
- this._curves.push(t), this._boundingBoxNeedsUpdate = !0;
3269
- }
3270
- get numberOfEdges() {
3271
- return this._curves.length;
3272
- }
3273
- get startPoint() {
3274
- if (this._curves.length > 0) {
3275
- const t = this._curves[0].startPoint;
3276
- return new S(t.x, t.y);
3277
- }
3278
- throw new Error("Start point does not exist in an empty loop.");
3279
- }
3280
- get endPoint() {
3281
- return this.startPoint;
3282
- }
3283
- get length() {
3284
- let t = 0;
3285
- return this._curves.forEach((s) => {
3286
- t += s.length;
3287
- }), t;
3288
- }
3289
- calculateBoundingBox() {
3290
- const t = this.getPoints(100), s = new X();
3291
- return s.setFromPoints(t), s;
3292
- }
3293
- transform(t) {
3294
- const s = new O().set(
3295
- t.elements[0],
3296
- t.elements[3],
3297
- 0,
3298
- t.elements[6],
3299
- t.elements[1],
3300
- t.elements[4],
3301
- 0,
3302
- t.elements[7],
3303
- 0,
3304
- 0,
3305
- 1,
3306
- 0,
3307
- 0,
3308
- 0,
3309
- 0,
3310
- 1
3311
- );
3312
- return this._curves.forEach((e) => {
3313
- e instanceof K ? e.transform(s) : e.transform(t);
3314
- }), this._boundingBoxNeedsUpdate = !0, this;
3315
- }
3316
- clone() {
3317
- return new F(this._curves.map((t) => t.clone()));
3318
- }
3319
- get closed() {
3320
- return !0;
3321
- }
3322
- getPoints(t) {
3323
- const s = [];
3324
- return this.curves.forEach((e) => {
3325
- e.getPoints(t).forEach((n) => {
3326
- s.push(new S(n.x, n.y));
3327
- });
3328
- }), s;
3329
- }
3330
- static findConnectingEdge(t, s, e) {
3331
- let n = -1, i = !1, r = Number.POSITIVE_INFINITY;
3332
- for (let o = 0; o < t.length; o++) {
3333
- const a = t[o], h = F.getEdgeStartPoint(a), c = F.getEdgeEndPoint(a), l = s.x - h.x, m = s.y - h.y, d = l * l + m * m;
3334
- d < r && (r = d, n = o, i = !1);
3335
- const x = s.x - c.x, g = s.y - c.y, y = x * x + g * g;
3336
- y < r && (r = y, n = o, i = !0);
3337
- }
3338
- return r > e ? { index: -1, reverse: !1 } : { index: n, reverse: i };
3339
- }
3340
- static getEdgeStartPoint(t) {
3341
- const s = t.startPoint;
3342
- return new S(s.x, s.y);
3343
- }
3344
- static getEdgeEndPoint(t) {
3345
- const s = t.endPoint;
3346
- return new S(s.x, s.y);
3347
- }
3348
- static reverseEdge(t) {
3349
- return t instanceof Pt ? new Pt(t.endPoint, t.startPoint) : t instanceof $ ? new $(
3350
- t.center,
3351
- t.radius,
3352
- t.endAngle,
3353
- t.startAngle,
3354
- !t.clockwise
3355
- ) : t instanceof G ? new G(
3356
- t.center,
3357
- t.majorAxisRadius,
3358
- t.minorAxisRadius,
3359
- t.endAngle,
3360
- t.startAngle,
3361
- !t.clockwise,
3362
- t.rotation
3363
- ) : t instanceof K ? F.reverseSplineEdge(t) : t;
3364
- }
3365
- static reverseSplineEdge(t) {
3366
- const s = [...t.controlPoints].reverse(), e = t.knots, n = e[0], i = e[e.length - 1], r = e.map((h) => n + i - h).reverse(), o = t.weights, a = o.length > 0 ? [...o].reverse() : void 0;
3367
- return new K(
3368
- s,
3369
- r,
3370
- a,
3371
- t.degree,
3372
- t.closed
3373
- );
3374
- }
3375
- }
3376
- class Nt {
3377
- constructor() {
3378
- this.c0 = 0, this.c1 = 0, this.c2 = 0, this.c3 = 0;
3379
- }
3380
- init(t, s, e, n) {
3381
- this.c0 = t, this.c1 = e, this.c2 = -3 * t + 3 * s - 2 * e - n, this.c3 = 2 * t - 2 * s + e + n;
3382
- }
3383
- initCatmullRom(t, s, e, n, i) {
3384
- this.init(s, e, i * (e - t), i * (n - s));
3385
- }
3386
- initNonuniformCatmullRom(t, s, e, n, i, r, o) {
3387
- let a = (s - t) / i - (e - t) / (i + r) + (e - s) / r, h = (e - s) / r - (n - s) / (r + o) + (n - e) / o;
3388
- a *= r, h *= r, this.init(s, e, a, h);
3389
- }
3390
- calc(t) {
3391
- const s = t * t, e = s * t;
3392
- return this.c0 + this.c1 * t + this.c2 * s + this.c3 * e;
3393
- }
3394
- }
3395
- class Tt extends ot {
3396
- constructor(t = [], s = !1, e = "centripetal", n = 0.5) {
3397
- super(), this.isCatmullRomCurve3d = !0, this.type = "CatmullRomCurve3d", this._tmp = new _(), this._px = new Nt(), this._py = new Nt(), this._pz = new Nt(), this._points = t.map((i) => new w(i)), this._closed = s, this._curveType = e, this._tension = n;
3398
- }
3399
- get points() {
3400
- return this._points;
3401
- }
3402
- get closed() {
3403
- return this._closed;
3404
- }
3405
- get curveType() {
3406
- return this._curveType;
3407
- }
3408
- get tension() {
3409
- return this._tension;
3410
- }
3411
- get startPoint() {
3412
- return this._points.length > 0 ? this._points[0] : new w();
3413
- }
3414
- get endPoint() {
3415
- return this._points.length > 0 ? this._points[this._points.length - 1] : new w();
3416
- }
3417
- get length() {
3418
- if (this._points.length < 2) return 0;
3419
- let t = 0;
3420
- for (let s = 1; s < this._points.length; s++)
3421
- t += this._points[s - 1].distanceTo(this._points[s]);
3422
- return this._closed && this._points.length > 2 && (t += this._points[this._points.length - 1].distanceTo(
3423
- this._points[0]
3424
- )), t;
3425
- }
3426
- getPoint(t, s = new w()) {
3427
- const e = s, n = this._points, i = n.length;
3428
- if (i === 0)
3429
- return e.set(0, 0, 0);
3430
- if (i === 1)
3431
- return e.copy(n[0]);
3432
- const r = (i - (this._closed ? 0 : 1)) * t;
3433
- let o = Math.floor(r), a = r - o;
3434
- this._closed ? o += o > 0 ? 0 : (Math.floor(Math.abs(o) / i) + 1) * i : a === 0 && o === i - 1 && (o = i - 2, a = 1);
3435
- let h, c;
3436
- this._closed || o > 0 ? h = n[(o - 1) % i] : (this._tmp.subVectors(n[0], n[1]).add(n[0]), h = new w(this._tmp.x, this._tmp.y, this._tmp.z));
3437
- const l = n[o % i], m = n[(o + 1) % i];
3438
- if (this._closed || o + 2 < i ? c = n[(o + 2) % i] : (this._tmp.subVectors(n[i - 1], n[i - 2]).add(n[i - 1]), c = new w(this._tmp.x, this._tmp.y, this._tmp.z)), this._curveType === "centripetal" || this._curveType === "chordal") {
3439
- const d = this._curveType === "chordal" ? 0.5 : 0.25;
3440
- let x = Math.pow(h.distanceToSquared(l), d), g = Math.pow(l.distanceToSquared(m), d), y = Math.pow(m.distanceToSquared(c), d);
3441
- g < 1e-4 && (g = 1), x < 1e-4 && (x = g), y < 1e-4 && (y = g), this._px.initNonuniformCatmullRom(h.x, l.x, m.x, c.x, x, g, y), this._py.initNonuniformCatmullRom(h.y, l.y, m.y, c.y, x, g, y), this._pz.initNonuniformCatmullRom(h.z, l.z, m.z, c.z, x, g, y);
3442
- } else this._curveType === "catmullrom" && (this._px.initCatmullRom(h.x, l.x, m.x, c.x, this._tension), this._py.initCatmullRom(h.y, l.y, m.y, c.y, this._tension), this._pz.initCatmullRom(h.z, l.z, m.z, c.z, this._tension));
3443
- return e.set(
3444
- this._px.calc(a),
3445
- this._py.calc(a),
3446
- this._pz.calc(a)
3447
- ), e;
3448
- }
3449
- getPoints(t) {
3450
- const s = [];
3451
- for (let e = 0; e <= t; e++)
3452
- s.push(this.getPoint(e / t));
3453
- return s;
3454
- }
3455
- setPoints(t) {
3456
- this._points = t.map((s) => new w(s)), this._boundingBoxNeedsUpdate = !0;
3457
- }
3458
- setClosed(t) {
3459
- this._closed !== t && (this._closed = t, this._boundingBoxNeedsUpdate = !0);
3460
- }
3461
- setCurveType(t) {
3462
- this._curveType = t;
3463
- }
3464
- setTension(t) {
3465
- this._tension = t;
3466
- }
3467
- clone() {
3468
- return new Tt(
3469
- this._points.map((t) => t.clone()),
3470
- this._closed,
3471
- this._curveType,
3472
- this._tension
3473
- );
3474
- }
3475
- transform(t) {
3476
- return this._points = this._points.map((s) => {
3477
- const e = new w();
3478
- return e.copy(s), e.applyMatrix4(t), e;
3479
- }), this._boundingBoxNeedsUpdate = !0, this;
3480
- }
3481
- calculateBoundingBox() {
3482
- if (this._points.length === 0)
3483
- return new v();
3484
- const t = new v();
3485
- return this._points.forEach((s) => {
3486
- t.expandByPoint(s);
3487
- }), t;
3488
- }
3489
- }
3490
- class T {
3491
- constructor(t, s, e, n) {
3492
- this._degree = t, this._knots = [...s], this._controlPoints = e.map((i) => ({ x: i.x, y: i.y, z: i.z })), this._weights = n ? [...n] : new Array(e.length).fill(1);
3493
- }
3494
- degree() {
3495
- return this._degree;
3496
- }
3497
- knots() {
3498
- return [...this._knots];
3499
- }
3500
- controlPoints() {
3501
- return this._controlPoints.map((t) => ({ x: t.x, y: t.y, z: t.z }));
3502
- }
3503
- weights() {
3504
- return [...this._weights];
3505
- }
3506
- clone() {
3507
- return new T(
3508
- this._degree,
3509
- this._knots,
3510
- this._controlPoints,
3511
- this._weights
3512
- );
3513
- }
3514
- point(t) {
3515
- const s = this._controlPoints.map((e) => [e.x, e.y, e.z]);
3516
- return ft(
3517
- t,
3518
- this._degree,
3519
- this._knots,
3520
- s,
3521
- this._weights
3522
- );
3523
- }
3524
- length() {
3525
- const t = this._controlPoints.map((s) => [s.x, s.y, s.z]);
3526
- return Ts(
3527
- this._degree,
3528
- this._knots,
3529
- t,
3530
- this._weights
3531
- );
3532
- }
3533
- static byKnotsControlPointsWeights(t, s, e, n) {
3534
- return new T(t, s, e, n);
3535
- }
3536
- static byPoints(t, s, e = "Uniform", n, i) {
3537
- const r = ss(
3538
- t,
3539
- s,
3540
- e,
3541
- n,
3542
- i
3543
- ), o = r.controlPoints.map((a) => ({
3544
- x: a[0],
3545
- y: a[1],
3546
- z: a[2]
3547
- }));
3548
- return new T(
3549
- s,
3550
- r.knots,
3551
- o,
3552
- r.weights
3553
- );
3554
- }
3555
- getParameterRange() {
3556
- const t = this._knots[this._degree], s = this._knots[this._knots.length - this._degree - 1];
3557
- return { start: t, end: s };
3558
- }
3559
- getPoints(t) {
3560
- const s = [], { start: e, end: n } = this.getParameterRange();
3561
- for (let i = 0; i <= t; i++) {
3562
- const r = e + (n - e) * (i / t);
3563
- s.push(this.point(r));
3564
- }
3565
- return s;
3566
- }
3567
- isClosed(t = 1e-6) {
3568
- const { start: s, end: e } = this.getParameterRange(), n = this.point(s), i = this.point(e), r = n[0] - i[0], o = n[1] - i[1], a = n[2] - i[2];
3569
- return Math.sqrt(r * r + o * o + a * a) < t;
3570
- }
3571
- static createFitPointsForClosedCurve(t) {
3572
- if (t.length < 4)
3573
- throw new Error("At least 4 points are required for a closed NURBS curve");
3574
- const s = new Tt(
3575
- t,
3576
- !0,
3577
- "centripetal"
3578
- ), e = Math.max(50, t.length * 2);
3579
- return s.getPoints(e);
3580
- }
3581
- static createClosedCurve(t, s, e = "Chord") {
3582
- const i = this.createFitPointsForClosedCurve(t).map((r) => [r.x, r.y, r.z]);
3583
- return T.byPoints(i, s, e);
3584
- }
3585
- }
3586
- class K extends ot {
3587
- constructor(t, s, e, n, i, r) {
3588
- super();
3589
- const o = arguments.length;
3590
- if (this._degree = 3, this._closed = !1, Array.isArray(s)) {
3591
- if (o < 2 || o > 5)
3592
- throw U.ILLEGAL_PARAMETERS;
3593
- this._controlPoints = t;
3594
- let a, h = 3, c = !1;
3595
- if (o >= 3 && (Array.isArray(e) ? (a = e, o >= 4 && (h = n || 3), o >= 5 && (c = i)) : e !== void 0 && (h = e || 3, o >= 4 && (c = n))), e === void 0 && o >= 4 && (h = n || 3, o >= 5 && (c = i)), this._degree = h, this._closed = c, this._controlPoints.length < this._degree + 1)
3596
- throw U.ILLEGAL_PARAMETERS;
3597
- this._nurbsCurve = T.byKnotsControlPointsWeights(
3598
- this._degree,
3599
- s,
3600
- this._controlPoints,
3601
- a
3602
- );
3603
- } else {
3604
- if (o < 2 || o > 6)
3605
- throw U.ILLEGAL_PARAMETERS;
3606
- this._fitPoints = t, this._knotParameterization = s, o >= 3 && (this._degree = e || 3);
3607
- const a = typeof n == "boolean";
3608
- o >= 4 && a && (this._closed = n), a ? (o >= 5 && (this._startTangent = i), o >= 6 && (this._endTangent = r)) : (o >= 4 && (this._startTangent = n), o >= 5 && (this._endTangent = i)), this._closed && (this._startTangent = void 0, this._endTangent = void 0);
3609
- const h = (this._startTangent ? 1 : 0) + (this._endTangent ? 1 : 0);
3610
- if (this._fitPoints.length + h < this._degree + 1)
3611
- throw U.ILLEGAL_PARAMETERS;
3612
- if (this._closed)
3613
- this._nurbsCurve = T.createClosedCurve(
3614
- this._fitPoints,
3615
- this._degree,
3616
- this._knotParameterization
3617
- );
3618
- else {
3619
- const c = this.toNurbsPoints(this._fitPoints);
3620
- this._nurbsCurve = T.byPoints(
3621
- c,
3622
- this._degree,
3623
- this._knotParameterization,
3624
- this._startTangent ? this.toNurbsPoint(this._startTangent) : void 0,
3625
- this._endTangent ? this.toNurbsPoint(this._endTangent) : void 0
3626
- );
3627
- }
3628
- this._controlPoints = this.toGePoints(
3629
- this._nurbsCurve.controlPoints().map((c) => [c.x, c.y, c.z || 0])
3630
- );
3631
- }
3632
- }
3633
- buildCurve() {
3634
- if (this._fitPoints && this._knotParameterization) {
3635
- if (this._closed) {
3636
- const t = T.createFitPointsForClosedCurve(
3637
- this._fitPoints
3638
- ), s = this.toNurbsPoints(t);
3639
- this._nurbsCurve = T.byPoints(
3640
- s,
3641
- this._degree,
3642
- this._knotParameterization
3643
- );
3644
- } else {
3645
- const t = this.toNurbsPoints(this._fitPoints);
3646
- this._nurbsCurve = T.byPoints(
3647
- t,
3648
- this._degree,
3649
- this._knotParameterization,
3650
- this._startTangent ? this.toNurbsPoint(this._startTangent) : void 0,
3651
- this._endTangent ? this.toNurbsPoint(this._endTangent) : void 0
3652
- );
3653
- }
3654
- this._controlPoints = this.toGePoints(
3655
- this._nurbsCurve.controlPoints().map((t) => [t.x, t.y, t.z || 0])
3656
- );
3657
- } else if (this._controlPoints)
3658
- if (this._closed) {
3659
- const t = T.createFitPointsForClosedCurve(
3660
- this._controlPoints
3661
- ), s = this.toNurbsPoints(t);
3662
- this._nurbsCurve = T.byPoints(
3663
- s,
3664
- this._degree,
3665
- this._knotParameterization
3666
- ), this._controlPoints = this.toGePoints(
3667
- this._nurbsCurve.controlPoints().map((e) => [e.x, e.y, e.z || 0])
3668
- );
3669
- } else {
3670
- const t = this._nurbsCurve.knots(), s = this._nurbsCurve.weights();
3671
- this._nurbsCurve = T.byKnotsControlPointsWeights(
3672
- this._degree,
3673
- t,
3674
- this._controlPoints,
3675
- s
3676
- );
3677
- }
3678
- }
3679
- setClosed(t) {
3680
- this._closed !== t && (this._closed = t, this._boundingBoxNeedsUpdate = !0, this.buildCurve());
3681
- }
3682
- get degree() {
3683
- return this._degree;
3684
- }
3685
- get knotParameterization() {
3686
- return this._knotParameterization;
3687
- }
3688
- get controlPoints() {
3689
- return this._controlPoints.map((t) => ({
3690
- x: t.x,
3691
- y: t.y,
3692
- z: t.z || 0
3693
- }));
3694
- }
3695
- get fitPoints() {
3696
- var t;
3697
- return (t = this._fitPoints) == null ? void 0 : t.map((s) => ({
3698
- x: s.x,
3699
- y: s.y,
3700
- z: s.z || 0
3701
- }));
3702
- }
3703
- get knots() {
3704
- return [...this._nurbsCurve.knots()];
3705
- }
3706
- get weights() {
3707
- return [...this._nurbsCurve.weights()];
3708
- }
3709
- get startPoint() {
3710
- const t = this._nurbsCurve.knots(), s = this._nurbsCurve.degree(), e = t[s], n = this._nurbsCurve.point(e);
3711
- return new w(n[0], n[1], n[2]);
3712
- }
3713
- get endPoint() {
3714
- const t = this._nurbsCurve.knots(), s = this._nurbsCurve.degree(), e = t[t.length - s - 1], n = this._nurbsCurve.point(e);
3715
- return new w(n[0], n[1], n[2]);
3716
- }
3717
- get length() {
3718
- return this._nurbsCurve.length();
3719
- }
3720
- getFitPointAt(t) {
3721
- if (!this._fitPoints)
3722
- throw new Error("No fit points in this spline");
3723
- const s = this._fitPoints.length, e = t < 0 || t >= s ? s - 1 : t, n = this._fitPoints[e];
3724
- return { x: n.x, y: n.y, z: n.z || 0 };
3725
- }
3726
- getControlPointAt(t) {
3727
- const s = this._controlPoints.length, e = t < 0 || t >= s ? s - 1 : t;
3728
- return this._controlPoints[e];
3729
- }
3730
- getPoints(t = 100) {
3731
- const s = this._nurbsCurve, e = [], n = s.knots(), i = this._nurbsCurve.degree(), r = n[i], o = n[n.length - i - 1], a = (o - r) / (t - 1);
3732
- for (let h = 0; h < t; h++) {
3733
- const c = h === t - 1 ? o : r + h * a, l = s.point(c);
3734
- e.push(new w(l[0], l[1], l[2]));
3735
- }
3736
- return e;
3737
- }
3738
- getCurvePoints(t, s) {
3739
- const e = [], n = t.knots(), i = t.degree(), r = n[i], a = (n[n.length - i - 1] - r) / (s - 1);
3740
- for (let h = 0; h < s; h++) {
3741
- const c = r + h * a;
3742
- e.push(t.point(c));
3743
- }
3744
- return e;
3745
- }
3746
- calculateBoundingBox() {
3747
- const t = this.getPoints(100);
3748
- return new v().setFromPoints(t);
3749
- }
3750
- get closed() {
3751
- return this._closed;
3752
- }
3753
- set closed(t) {
3754
- this.setClosed(t);
3755
- }
3756
- transform(t) {
3757
- if (this._fitPoints && this._knotParameterization)
3758
- this._fitPoints = this._fitPoints.map(
3759
- (s) => new w(s).applyMatrix4(t)
3760
- ), this._startTangent && (this._startTangent = new w(
3761
- this._startTangent
3762
- ).transformDirection(t)), this._endTangent && (this._endTangent = new w(this._endTangent).transformDirection(
3763
- t
3764
- )), this.buildCurve();
3765
- else {
3766
- const s = this._nurbsCurve.knots(), e = this._nurbsCurve.weights();
3767
- this._controlPoints = this._controlPoints.map(
3768
- (n) => new w(n).applyMatrix4(t)
3769
- ), this._nurbsCurve = T.byKnotsControlPointsWeights(
3770
- this._degree,
3771
- s,
3772
- this._controlPoints,
3773
- e.length > 0 ? e : void 0
3774
- );
3775
- }
3776
- return this._boundingBoxNeedsUpdate = !0, this;
3777
- }
3778
- clone() {
3779
- return this._fitPoints && this._knotParameterization ? new K(
3780
- this._fitPoints.map((t) => ({
3781
- x: t.x,
3782
- y: t.y,
3783
- z: t.z || 0
3784
- })),
3785
- this._knotParameterization,
3786
- this._degree,
3787
- this._closed,
3788
- this._startTangent ? {
3789
- x: this._startTangent.x,
3790
- y: this._startTangent.y,
3791
- z: this._startTangent.z || 0
3792
- } : void 0,
3793
- this._endTangent ? {
3794
- x: this._endTangent.x,
3795
- y: this._endTangent.y,
3796
- z: this._endTangent.z || 0
3797
- } : void 0
3798
- ) : new K(
3799
- this._controlPoints.map((t) => ({
3800
- x: t.x,
3801
- y: t.y,
3802
- z: t.z || 0
3803
- })),
3804
- this._nurbsCurve.knots(),
3805
- this._nurbsCurve.weights(),
3806
- this._degree,
3807
- this._closed
3808
- );
3809
- }
3810
- toNurbsPoints(t) {
3811
- const s = new Array(t.length);
3812
- return t.forEach((e, n) => {
3813
- s[n] = [e.x, e.y, e.z || 0];
3814
- }), s;
3815
- }
3816
- toGePoints(t) {
3817
- const s = new Array(t.length);
3818
- return t.forEach((e, n) => {
3819
- s[n] = { x: e[0], y: e[1], z: e[2] };
3820
- }), s;
3821
- }
3822
- toNurbsPoint(t) {
3823
- return [t.x, t.y, t.z || 0];
3824
- }
3825
- static createClosedSpline(t, s = "Uniform", e = 3) {
3826
- if (t.length < e + 1)
3827
- throw new Error(
3828
- `At least ${e + 1} points are required for a degree ${e} closed spline`
3829
- );
3830
- return new K(t, s, e, !0);
3831
- }
3832
- }
3833
- export {
3834
- rs as AcGeArea2d,
3835
- X as AcGeBox2d,
3836
- v as AcGeBox3d,
3837
- Tt as AcGeCatmullRomCurve3d,
3838
- $ as AcGeCircArc2d,
3839
- At as AcGeCircArc3d,
3840
- rt as AcGeCurve2d,
3841
- G as AcGeEllipseArc2d,
3842
- wt as AcGeEllipseArc3d,
3843
- Xt as AcGeEuler,
3844
- ks as AcGeGeometryUtil,
3845
- Pt as AcGeLine2d,
3846
- Mt as AcGeLine3d,
3847
- F as AcGeLoop2d,
3848
- M as AcGeMathUtil,
3849
- it as AcGeMatrix2d,
3850
- O as AcGeMatrix3d,
3851
- T as AcGeNurbsCurve,
3852
- Ct as AcGePlane,
3853
- S as AcGePoint2d,
3854
- w as AcGePoint3d,
3855
- os as AcGePolyline2d,
3856
- St as AcGeQuaternion,
3857
- is as AcGeShape2d,
3858
- K as AcGeSpline3d,
3859
- bt as AcGeTol,
3860
- B as AcGeVector2d,
3861
- _ as AcGeVector3d,
3862
- Gt as DEFAULT_TOL,
3863
- Qt as DEG2RAD,
3864
- H as FLOAT_TOL,
3865
- Ls as ORIGIN_POINT_2D,
3866
- Jt as ORIGIN_POINT_3D,
3867
- Kt as RAD2DEG,
3868
- E as TAU,
3869
- zt as basisFunction,
3870
- Ts as calculateCurveLength,
3871
- ws as ceilPowerOfTwo,
3872
- Z as clamp,
3873
- Rs as computeParameterValues,
3874
- ls as damp,
3875
- ps as degToRad,
3876
- $t as euclideanModulo,
3877
- ft as evaluateNurbsPoint,
3878
- zs as floorPowerOfTwo,
3879
- Ns as generateAveragedKnots,
3880
- Xs as generateChordKnots,
3881
- Ds as generateSqrtChordKnots,
3882
- hs as generateUUID,
3883
- Fs as generateUniformKnots,
3884
- Os as getOcsAngle,
3885
- Ys as getOcsReferenceVector,
3886
- Ht as intPartLength,
3887
- vs as interpolateControlPoints,
3888
- ss as interpolateNurbsCurve,
3889
- cs as inverseLerp,
3890
- Ms as isBetween,
3891
- Ps as isBetweenAngle,
3892
- ts as isPointInPolygon,
3893
- Bs as isPolygonIntersect,
3894
- As as isPowerOfTwo,
3895
- Wt as lerp,
3896
- as as mapLinear,
3897
- pt as normalizeAngle,
3898
- us as pingpong,
3899
- fs as radToDeg,
3900
- gs as randFloat,
3901
- ys as randFloatSpread,
3902
- xs as randInt,
3903
- bs as relativeEps,
3904
- _s as seededRandom,
3905
- ms as smootherstep,
3906
- ds as smoothstep,
3907
- Zs as transformOcsPointToWcs,
3908
- Yt as transformWcsPointToOcs
3909
- };