forked from jscad/OpenJSCAD.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jscad-modeling.min.js
1208 lines (806 loc) · 242 KB
/
jscad-modeling.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.jscadModeling = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
const cssColors=require("./cssColors"),colorNameToRgb=o=>cssColors[o.toLowerCase()];module.exports=colorNameToRgb;
},{"./cssColors":3}],2:[function(require,module,exports){
const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),colorGeom2=(o,r)=>{const e=geom2.clone(r);return e.color=o,e},colorGeom3=(o,r)=>{const e=geom3.clone(r);return e.color=o,e},colorPath2=(o,r)=>{const e=path2.clone(r);return e.color=o,e},colorPoly3=(o,r)=>{const e=poly3.clone(r);return e.color=o,e},colorize=(o,...r)=>{if(!Array.isArray(o))throw new Error("color must be an array");if(o.length<3)throw new Error("color must contain R, G and B values");if(3===o.length&&(o=[o[0],o[1],o[2],1]),0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const e=r.map(r=>geom2.isA(r)?colorGeom2(o,r):geom3.isA(r)?colorGeom3(o,r):path2.isA(r)?colorPath2(o,r):poly3.isA(r)?colorPoly3(o,r):(r.color=o,r));return 1===e.length?e[0]:e};module.exports=colorize;
},{"../geometries/geom2":25,"../geometries/geom3":40,"../geometries/path2":61,"../geometries/poly3":78,"../utils/flatten":396}],3:[function(require,module,exports){
const cssColors={black:[0,0,0],silver:[192/255,192/255,192/255],gray:[128/255,128/255,128/255],white:[1,1,1],maroon:[128/255,0,0],red:[1,0,0],purple:[128/255,0,128/255],fuchsia:[1,0,1],green:[0,128/255,0],lime:[0,1,0],olive:[128/255,128/255,0],yellow:[1,1,0],navy:[0,0,128/255],blue:[0,0,1],teal:[0,128/255,128/255],aqua:[0,1,1],aliceblue:[240/255,248/255,1],antiquewhite:[250/255,235/255,215/255],aquamarine:[127/255,1,212/255],azure:[240/255,1,1],beige:[245/255,245/255,220/255],bisque:[1,228/255,196/255],blanchedalmond:[1,235/255,205/255],blueviolet:[138/255,43/255,226/255],brown:[165/255,42/255,42/255],burlywood:[222/255,184/255,135/255],cadetblue:[95/255,158/255,160/255],chartreuse:[127/255,1,0],chocolate:[210/255,105/255,30/255],coral:[1,127/255,80/255],cornflowerblue:[100/255,149/255,237/255],cornsilk:[1,248/255,220/255],crimson:[220/255,20/255,60/255],cyan:[0,1,1],darkblue:[0,0,139/255],darkcyan:[0,139/255,139/255],darkgoldenrod:[184/255,134/255,11/255],darkgray:[169/255,169/255,169/255],darkgreen:[0,100/255,0],darkgrey:[169/255,169/255,169/255],darkkhaki:[189/255,183/255,107/255],darkmagenta:[139/255,0,139/255],darkolivegreen:[85/255,107/255,47/255],darkorange:[1,140/255,0],darkorchid:[.6,50/255,.8],darkred:[139/255,0,0],darksalmon:[233/255,150/255,122/255],darkseagreen:[143/255,188/255,143/255],darkslateblue:[72/255,61/255,139/255],darkslategray:[47/255,79/255,79/255],darkslategrey:[47/255,79/255,79/255],darkturquoise:[0,206/255,209/255],darkviolet:[148/255,0,211/255],deeppink:[1,20/255,147/255],deepskyblue:[0,191/255,1],dimgray:[105/255,105/255,105/255],dimgrey:[105/255,105/255,105/255],dodgerblue:[30/255,144/255,1],firebrick:[178/255,34/255,34/255],floralwhite:[1,250/255,240/255],forestgreen:[34/255,139/255,34/255],gainsboro:[220/255,220/255,220/255],ghostwhite:[248/255,248/255,1],gold:[1,215/255,0],goldenrod:[218/255,165/255,32/255],greenyellow:[173/255,1,47/255],grey:[128/255,128/255,128/255],honeydew:[240/255,1,240/255],hotpink:[1,105/255,180/255],indianred:[205/255,92/255,92/255],indigo:[75/255,0,130/255],ivory:[1,1,240/255],khaki:[240/255,230/255,140/255],lavender:[230/255,230/255,250/255],lavenderblush:[1,240/255,245/255],lawngreen:[124/255,252/255,0],lemonchiffon:[1,250/255,205/255],lightblue:[173/255,216/255,230/255],lightcoral:[240/255,128/255,128/255],lightcyan:[224/255,1,1],lightgoldenrodyellow:[250/255,250/255,210/255],lightgray:[211/255,211/255,211/255],lightgreen:[144/255,238/255,144/255],lightgrey:[211/255,211/255,211/255],lightpink:[1,182/255,193/255],lightsalmon:[1,160/255,122/255],lightseagreen:[32/255,178/255,170/255],lightskyblue:[135/255,206/255,250/255],lightslategray:[119/255,136/255,.6],lightslategrey:[119/255,136/255,.6],lightsteelblue:[176/255,196/255,222/255],lightyellow:[1,1,224/255],limegreen:[50/255,205/255,50/255],linen:[250/255,240/255,230/255],magenta:[1,0,1],mediumaquamarine:[.4,205/255,170/255],mediumblue:[0,0,205/255],mediumorchid:[186/255,85/255,211/255],mediumpurple:[147/255,112/255,219/255],mediumseagreen:[60/255,179/255,113/255],mediumslateblue:[123/255,104/255,238/255],mediumspringgreen:[0,250/255,154/255],mediumturquoise:[72/255,209/255,.8],mediumvioletred:[199/255,21/255,133/255],midnightblue:[25/255,25/255,112/255],mintcream:[245/255,1,250/255],mistyrose:[1,228/255,225/255],moccasin:[1,228/255,181/255],navajowhite:[1,222/255,173/255],oldlace:[253/255,245/255,230/255],olivedrab:[107/255,142/255,35/255],orange:[1,165/255,0],orangered:[1,69/255,0],orchid:[218/255,112/255,214/255],palegoldenrod:[238/255,232/255,170/255],palegreen:[152/255,251/255,152/255],paleturquoise:[175/255,238/255,238/255],palevioletred:[219/255,112/255,147/255],papayawhip:[1,239/255,213/255],peachpuff:[1,218/255,185/255],peru:[205/255,133/255,63/255],pink:[1,192/255,203/255],plum:[221/255,160/255,221/255],powderblue:[176/255,224/255,230/255],rosybrown:[188/255,143/255,143/255],royalblue:[65/255,105/255,225/255],saddlebrown:[139/255,69/255,19/255],salmon:[250/255,128/255,114/255],sandybrown:[244/255,164/255,96/255],seagreen:[46/255,139/255,87/255],seashell:[1,245/255,238/255],sienna:[160/255,82/255,45/255],skyblue:[135/255,206/255,235/255],slateblue:[106/255,90/255,205/255],slategray:[112/255,128/255,144/255],slategrey:[112/255,128/255,144/255],snow:[1,250/255,250/255],springgreen:[0,1,127/255],steelblue:[70/255,130/255,180/255],tan:[210/255,180/255,140/255],thistle:[216/255,191/255,216/255],tomato:[1,99/255,71/255],turquoise:[64/255,224/255,208/255],violet:[238/255,130/255,238/255],wheat:[245/255,222/255,179/255],whitesmoke:[245/255,245/255,245/255],yellowgreen:[154/255,205/255,50/255]};module.exports=cssColors;
},{}],4:[function(require,module,exports){
const hexToRgb=t=>{if((t=t.replace("#","")).length<6)throw new Error("the given notation must contain 3 or more hex values");const e=parseInt(t.substring(0,2),16)/255,n=parseInt(t.substring(2,4),16)/255,r=parseInt(t.substring(4,6),16)/255;if(t.length>=8){return[e,n,r,parseInt(t.substring(6,8),16)/255]}return[e,n,r]};module.exports=hexToRgb;
},{}],5:[function(require,module,exports){
const flatten=require("../utils/flatten"),hueToColorComponent=require("./hueToColorComponent"),hslToRgb=(...o)=>{if((o=flatten(o)).length<3)throw new Error("values must contain H, S and L values");const e=o[0],n=o[1],t=o[2];let r=t,l=t,u=t;if(0!==n){const o=t<.5?t*(1+n):t+n-t*n,h=2*t-o;r=hueToColorComponent(h,o,e+1/3),l=hueToColorComponent(h,o,e),u=hueToColorComponent(h,o,e-1/3)}if(o.length>3){return[r,l,u,o[3]]}return[r,l,u]};module.exports=hslToRgb;
},{"../utils/flatten":396,"./hueToColorComponent":7}],6:[function(require,module,exports){
const flatten=require("../utils/flatten"),hsvToRgb=(...e)=>{if((e=flatten(e)).length<3)throw new Error("values must contain H, S and V values");const t=e[0],a=e[1],r=e[2];let s=0,n=0,o=0;const c=Math.floor(6*t),l=6*t-c,u=r*(1-a),b=r*(1-l*a),h=r*(1-(1-l)*a);switch(c%6){case 0:s=r,n=h,o=u;break;case 1:s=b,n=r,o=u;break;case 2:s=u,n=r,o=h;break;case 3:s=u,n=b,o=r;break;case 4:s=h,n=u,o=r;break;case 5:s=r,n=u,o=b}if(e.length>3){return[s,n,o,e[3]]}return[s,n,o]};module.exports=hsvToRgb;
},{"../utils/flatten":396}],7:[function(require,module,exports){
const hueToColorComponent=(o,e,n)=>(n<0&&(n+=1),n>1&&(n-=1),n<1/6?o+6*(e-o)*n:n<.5?e:n<2/3?o+(e-o)*(2/3-n)*6:o);module.exports=hueToColorComponent;
},{}],8:[function(require,module,exports){
module.exports={colorize:require("./colorize"),colorNameToRgb:require("./colorNameToRgb"),cssColors:require("./cssColors"),hexToRgb:require("./hexToRgb"),hslToRgb:require("./hslToRgb"),hsvToRgb:require("./hsvToRgb"),hueToColorComponent:require("./hueToColorComponent"),rgbToHex:require("./rgbToHex"),rgbToHsl:require("./rgbToHsl"),rgbToHsv:require("./rgbToHsv")};
},{"./colorNameToRgb":1,"./colorize":2,"./cssColors":3,"./hexToRgb":4,"./hslToRgb":5,"./hsvToRgb":6,"./hueToColorComponent":7,"./rgbToHex":9,"./rgbToHsl":10,"./rgbToHsv":11}],9:[function(require,module,exports){
const flatten=require("../utils/flatten"),rgbToHex=(...t)=>{if((t=flatten(t)).length<3)throw new Error("values must contain R, G and B values");const e=255*t[0],r=255*t[1],n=255*t[2];let o=`#${Number(16777216+65536*e+256*r+n).toString(16).substring(1,7)}`;return t.length>3&&(o+=Number(255*t[3]).toString(16)),o};module.exports=rgbToHex;
},{"../utils/flatten":396}],10:[function(require,module,exports){
const flatten=require("../utils/flatten"),rgbToHsl=(...t)=>{if((t=flatten(t)).length<3)throw new Error("values must contain R, G and B values");const e=t[0],n=t[1],s=t[2],a=Math.max(e,n,s),r=Math.min(e,n,s);let l,o;const c=(a+r)/2;if(a===r)l=o=0;else{const t=a-r;switch(o=c>.5?t/(2-a-r):t/(a+r),a){case e:l=(n-s)/t+(n<s?6:0);break;case n:l=(s-e)/t+2;break;case s:l=(e-n)/t+4}l/=6}if(t.length>3){return[l,o,c,t[3]]}return[l,o,c]};module.exports=rgbToHsl;
},{"../utils/flatten":396}],11:[function(require,module,exports){
const flatten=require("../utils/flatten"),rgbToHsv=(...e)=>{if((e=flatten(e)).length<3)throw new Error("values must contain R, G and B values");const t=e[0],a=e[1],n=e[2],r=Math.max(t,a,n),s=Math.min(t,a,n);let l;const o=r,c=r-s,i=0===r?0:c/r;if(r===s)l=0;else{switch(r){case t:l=(a-n)/c+(a<n?6:0);break;case a:l=(n-t)/c+2;break;case n:l=(t-a)/c+4}l/=6}if(e.length>3){return[l,i,o,e[3]]}return[l,i,o]};module.exports=rgbToHsv;
},{"../utils/flatten":396}],12:[function(require,module,exports){
const lengths=require("./lengths"),arcLengthToT=(e,t)=>{const{distance:s,segments:n}=Object.assign({},{distance:0,segments:100},e),o=lengths(n,t);let r=0,c=n;for(;r<=c;){const e=Math.floor(r+(c-r)/2),t=o[e]-s;if(t<0)r=e+1;else{if(!(t>0)){c=e;break}c=e-1}}const g=c;if(o[g]===s)return g/n;const a=o[g];return(g+(s-a)/(o[g+1]-a))/n};module.exports=arcLengthToT;
},{"./lengths":16}],13:[function(require,module,exports){
const create=e=>{if(!Array.isArray(e))throw new Error("Bezier points must be a valid array/");if(e.length<2)throw new Error("Bezier points must contain at least 2 values.");const r=getPointType(e);return{points:e,pointType:r,dimensions:"float_single"===r?0:e[0].length,permutations:getPermutations(e.length-1),tangentPermutations:getPermutations(e.length-2)}},getPointType=function(e){let r=null;return e.forEach(e=>{let t="";if(Number.isFinite(e))t="float_single";else{if(!Array.isArray(e))throw new Error("Bezier points must all be numbers or arrays of number.");e.forEach(e=>{if(!Number.isFinite(e))throw new Error("Bezier point values must all be numbers.")}),t="float_"+e.length}if(null==r)r=t;else if(r!==t)throw new Error("Bezier points must be either all numbers or all arrays of numbers of the same size.")}),r},getPermutations=function(e){const r=[];for(let t=0;t<=e;t++)r.push(factorial(e)/(factorial(t)*factorial(e-t)));return r},factorial=function(e){let r=1;for(let t=2;t<=e;t++)r*=t;return r};module.exports=create;
},{}],14:[function(require,module,exports){
module.exports={create:require("./create"),valueAt:require("./valueAt"),tangentAt:require("./tangentAt"),lengths:require("./lengths"),length:require("./length"),arcLengthToT:require("./arcLengthToT")};
},{"./arcLengthToT":12,"./create":13,"./length":15,"./lengths":16,"./tangentAt":17,"./valueAt":18}],15:[function(require,module,exports){
const lengths=require("./lengths"),length=(e,t)=>lengths(e,t)[e];module.exports=length;
},{"./lengths":16}],16:[function(require,module,exports){
const valueAt=require("./valueAt"),lengths=(e,r)=>{let t=0;const n=[0];let s=valueAt(0,r);for(let a=1;a<=e;a++){const i=valueAt(a/e,r);t+=distanceBetween(i,s),n.push(t),s=i}return n},distanceBetween=(e,r)=>{if(Number.isFinite(e)&&Number.isFinite(r))return Math.abs(e-r);if(Array.isArray(e)&&Array.isArray(r)){if(e.length!==r.length)throw new Error("The operands must have the same number of dimensions.");let t=0;for(let n=0;n<e.length;n++)t+=(r[n]-e[n])*(r[n]-e[n]);return Math.sqrt(t)}throw new Error("The operands must be of the same type, either number or array.")};module.exports=lengths;
},{"./valueAt":18}],17:[function(require,module,exports){
const tangentAt=(t,n)=>{if(t<0||t>1)throw new Error("Bezier tangentAt() input must be between 0 and 1");if("float_single"===n.pointType)return bezierTangent(n,n.points,t);{const e=[];for(let o=0;o<n.dimensions;o++){const r=[];for(let t=0;t<n.points.length;t++)r.push(n.points[t][o]);e.push(bezierTangent(n,r,t))}return e}},bezierTangent=function(t,n,e){const o=n.length-1;let r=0;for(let i=0;i<o;i++){const s=o*(n[i+1]-n[i]);r+=t.tangentPermutations[i]*Math.pow(1-e,o-1-i)*Math.pow(e,i)*s}return r};module.exports=tangentAt;
},{}],18:[function(require,module,exports){
const valueAt=(t,e)=>{if(t<0||t>1)throw new Error("Bezier valueAt() input must be between 0 and 1");if("float_single"===e.pointType)return bezierFunction(e,e.points,t);{const n=[];for(let o=0;o<e.dimensions;o++){const i=[];for(let t=0;t<e.points.length;t++)i.push(e.points[t][o]);n.push(bezierFunction(e,i,t))}return n}},bezierFunction=function(t,e,n){const o=e.length-1;let i=0;for(let r=0;r<=o;r++)i+=t.permutations[r]*Math.pow(1-n,o-r)*Math.pow(n,r)*e[r];return i};module.exports=valueAt;
},{}],19:[function(require,module,exports){
module.exports={bezier:require("./bezier")};
},{"./bezier":14}],20:[function(require,module,exports){
const mat4=require("../../maths/mat4"),vec2=require("../../maths/vec2"),applyTransforms=r=>mat4.isIdentity(r.transforms)?r:(r.sides=r.sides.map(s=>{return[vec2.transform(vec2.create(),s[0],r.transforms),vec2.transform(vec2.create(),s[1],r.transforms)]}),r.transforms=mat4.create(),r);module.exports=applyTransforms;
},{"../../maths/mat4":142,"../../maths/vec2":190}],21:[function(require,module,exports){
const clone=e=>Object.assign({},e);module.exports=clone;
},{}],22:[function(require,module,exports){
const mat4=require("../../maths/mat4"),create=e=>(void 0===e&&(e=[]),{sides:e,transforms:mat4.create()});module.exports=create;
},{"../../maths/mat4":142}],23:[function(require,module,exports){
const mat4=require("../../maths/mat4"),vec2=require("../../maths/vec2"),create=require("./create"),fromCompactBinary=e=>{if(0!==e[0])throw new Error("invalid compact binary data");const r=create();r.transforms=mat4.clone(e.slice(1,17));for(let t=21;t<e.length;t+=4){const a=vec2.fromValues(e[t+0],e[t+1]),o=vec2.fromValues(e[t+2],e[t+3]);r.sides.push([a,o])}return e[17]>=0&&(r.color=[e[17],e[18],e[19],e[20]]),r};module.exports=fromCompactBinary;
},{"../../maths/mat4":142,"../../maths/vec2":190,"./create":22}],24:[function(require,module,exports){
const vec2=require("../../maths/vec2"),create=require("./create"),fromPoints=e=>{if(!Array.isArray(e))throw new Error("the given points must be an array");let r=e.length;if(r<3)throw new Error("the given points must define a closed geometry with three or more points");vec2.equals(e[0],e[r-1])&&--r;const t=[];let o=e[r-1];for(let n=0;n<r;n++){const r=e[n];t.push([vec2.clone(o),vec2.clone(r)]),o=r}return create(t)};module.exports=fromPoints;
},{"../../maths/vec2":190,"./create":22}],25:[function(require,module,exports){
module.exports={clone:require("./clone"),create:require("./create"),fromPoints:require("./fromPoints"),fromCompactBinary:require("./fromCompactBinary"),isA:require("./isA"),reverse:require("./reverse"),toOutlines:require("./toOutlines"),toPoints:require("./toPoints"),toSides:require("./toSides"),toString:require("./toString"),toCompactBinary:require("./toCompactBinary"),transform:require("./transform"),validate:require("./validate")};
},{"./clone":21,"./create":22,"./fromCompactBinary":23,"./fromPoints":24,"./isA":26,"./reverse":27,"./toCompactBinary":28,"./toOutlines":29,"./toPoints":30,"./toSides":31,"./toString":32,"./transform":33,"./validate":34}],26:[function(require,module,exports){
const isA=s=>!!(s&&"object"==typeof s&&"sides"in s&&"transforms"in s&&Array.isArray(s.sides)&&"length"in s.transforms);module.exports=isA;
},{}],27:[function(require,module,exports){
const create=require("./create"),toSides=require("./toSides"),reverse=e=>{const r=toSides(e).map(e=>[e[1],e[0]]);return r.reverse(),create(r)};module.exports=reverse;
},{"./create":22,"./toSides":31}],28:[function(require,module,exports){
const toCompactBinary=o=>{const t=o.sides,r=o.transforms;let n=[-1,-1,-1,-1];o.color&&(n=o.color);const e=new Float32Array(21+4*t.length);e[0]=0,e[1]=r[0],e[2]=r[1],e[3]=r[2],e[4]=r[3],e[5]=r[4],e[6]=r[5],e[7]=r[6],e[8]=r[7],e[9]=r[8],e[10]=r[9],e[11]=r[10],e[12]=r[11],e[13]=r[12],e[14]=r[13],e[15]=r[14],e[16]=r[15],e[17]=n[0],e[18]=n[1],e[19]=n[2],e[20]=n[3];for(let o=0;o<t.length;o++){const r=4*o+21,n=t[o][0],s=t[o][1];e[r+0]=n[0],e[r+1]=n[1],e[r+2]=s[0],e[r+3]=s[1]}return e};module.exports=toCompactBinary;
},{}],29:[function(require,module,exports){
const vec2=require("../../maths/vec2"),toSides=require("./toSides"),toSharedVertices=e=>{const t=new Map,r=e=>{const r=e.toString();return t.has(r)?t.get(r):(t.set(r,e),e)};return e.map(e=>e.map(r))},toVertexMap=e=>{const t=new Map;return toSharedVertices(e).forEach(e=>{t.has(e[0])?t.get(e[0]).push(e):t.set(e[0],[e])}),t},toOutlines=e=>{const t=toVertexMap(toSides(e)),r=[];for(;;){let e;for(const[r,o]of t){if(e=o.shift())break;t.delete(r)}if(void 0===e)break;const o=[],s=e[0];for(;;){o.push(e[0]);const r=e[1];if(r===s)break;const n=t.get(r);if(!n)throw new Error(`geometry is not closed at vertex ${r}`);const c=popNextSide(e,n);0===n.length&&t.delete(r),e=c}o.length>0&&o.push(o.shift()),r.push(o)}return t.clear(),r},popNextSide=(e,t)=>{if(1===t.length)return t.pop();const r=vec2.create(),o=vec2.angleDegrees(vec2.subtract(r,e[1],e[0]));let s,n;t.forEach((e,t)=>{let c=vec2.angleDegrees(vec2.subtract(r,e[1],e[0]))-o;c<-180&&(c+=360),c>=180&&(c-=360),(void 0===n||c>s)&&(n=t,s=c)});const c=t[n];return t.splice(n,1),c};module.exports=toOutlines;
},{"../../maths/vec2":190,"./toSides":31}],30:[function(require,module,exports){
const toSides=require("./toSides"),toPoints=t=>{const o=toSides(t).map(t=>t[0]);return o.length>0&&o.push(o.shift()),o};module.exports=toPoints;
},{"./toSides":31}],31:[function(require,module,exports){
const applyTransforms=require("./applyTransforms"),toSides=s=>applyTransforms(s).sides;module.exports=toSides;
},{"./applyTransforms":20}],32:[function(require,module,exports){
const vec2=require("../../maths/vec2"),toSides=require("./toSides"),toString=e=>{const t=toSides(e);let o="geom2 ("+t.length+" sides):\n[\n";return t.forEach(e=>{o+=" ["+vec2.toString(e[0])+", "+vec2.toString(e[1])+"]\n"}),o+="]\n"};module.exports=toString;
},{"../../maths/vec2":190,"./toSides":31}],33:[function(require,module,exports){
const mat4=require("../../maths/mat4"),reverse=require("./reverse.js"),transform=(r,e)=>{const s=mat4.multiply(mat4.create(),r,e.transforms),t=Object.assign({},e,{transforms:s});return r[0]*r[5]-r[4]*r[1]<0?reverse(t):t};module.exports=transform;
},{"../../maths/mat4":142,"./reverse.js":27}],34:[function(require,module,exports){
const vec2=require("../../maths/vec2"),isA=require("./isA"),toOutlines=require("./toOutlines"),validate=e=>{if(!isA(e))throw new Error("invalid geom2 structure");if(toOutlines(e),e.sides.forEach(e=>{if(vec2.equals(e[0],e[1]))throw new Error(`geom2 self-edge ${e[0]}`)}),!e.transforms.every(Number.isFinite))throw new Error(`geom2 invalid transforms ${e.transforms}`)};module.exports=validate;
},{"../../maths/vec2":190,"./isA":26,"./toOutlines":29}],35:[function(require,module,exports){
const mat4=require("../../maths/mat4"),poly3=require("../poly3"),applyTransforms=r=>mat4.isIdentity(r.transforms)?r:(r.polygons=r.polygons.map(s=>poly3.transform(r.transforms,s)),r.transforms=mat4.create(),r);module.exports=applyTransforms;
},{"../../maths/mat4":142,"../poly3":78}],36:[function(require,module,exports){
const clone=e=>Object.assign({},e);module.exports=clone;
},{}],37:[function(require,module,exports){
const mat4=require("../../maths/mat4"),create=e=>(void 0===e&&(e=[]),{polygons:e,transforms:mat4.create()});module.exports=create;
},{"../../maths/mat4":142}],38:[function(require,module,exports){
const vec3=require("../../maths/vec3"),mat4=require("../../maths/mat4"),poly3=require("../poly3"),create=require("./create"),fromCompactBinary=e=>{if(1!==e[0])throw new Error("invalid compact binary data");const r=create();r.transforms=mat4.clone(e.slice(1,17));const o=e[21];let t=22,a=e.length-3*o;for(;a<e.length;){const o=e[t];t++;const c=[];for(let r=0;r<o;r++)c.push(vec3.fromValues(e[a],e[a+1],e[a+2])),a+=3;r.polygons.push(poly3.create(c))}return e[17]>=0&&(r.color=[e[17],e[18],e[19],e[20]]),r};module.exports=fromCompactBinary;
},{"../../maths/mat4":142,"../../maths/vec3":221,"../poly3":78,"./create":37}],39:[function(require,module,exports){
const poly3=require("../poly3"),create=require("./create"),fromPoints=r=>{if(!Array.isArray(r))throw new Error("the given points must be an array");const e=r.map((r,e)=>{return poly3.create(r)});return create(e)};module.exports=fromPoints;
},{"../poly3":78,"./create":37}],40:[function(require,module,exports){
module.exports={clone:require("./clone"),create:require("./create"),fromPoints:require("./fromPoints"),fromCompactBinary:require("./fromCompactBinary"),invert:require("./invert"),isA:require("./isA"),toPoints:require("./toPoints"),toPolygons:require("./toPolygons"),toString:require("./toString"),toCompactBinary:require("./toCompactBinary"),transform:require("./transform"),validate:require("./validate")};
},{"./clone":36,"./create":37,"./fromCompactBinary":38,"./fromPoints":39,"./invert":41,"./isA":42,"./toCompactBinary":43,"./toPoints":44,"./toPolygons":45,"./toString":46,"./transform":47,"./validate":48}],41:[function(require,module,exports){
const poly3=require("../poly3"),create=require("./create"),toPolygons=require("./toPolygons"),invert=e=>{const o=toPolygons(e).map(e=>poly3.invert(e));return create(o)};module.exports=invert;
},{"../poly3":78,"./create":37,"./toPolygons":45}],42:[function(require,module,exports){
const isA=o=>!!(o&&"object"==typeof o&&"polygons"in o&&"transforms"in o&&Array.isArray(o.polygons)&&"length"in o.transforms);module.exports=isA;
},{}],43:[function(require,module,exports){
const poly3=require("../poly3"),toCompactBinary=o=>{const t=o.polygons,e=o.transforms,r=t.length,n=t.reduce((o,t)=>o+t.vertices.length,0);let l=[-1,-1,-1,-1];o.color&&(l=o.color);const c=new Float32Array(22+r+3*n);c[0]=1,c[1]=e[0],c[2]=e[1],c[3]=e[2],c[4]=e[3],c[5]=e[4],c[6]=e[5],c[7]=e[6],c[8]=e[7],c[9]=e[8],c[10]=e[9],c[11]=e[10],c[12]=e[11],c[13]=e[12],c[14]=e[13],c[15]=e[14],c[16]=e[15],c[17]=l[0],c[18]=l[1],c[19]=l[2],c[20]=l[3],c[21]=n;let s=22,a=s+r;return t.forEach(o=>{const t=poly3.toPoints(o);c[s]=t.length,s++;for(let o=0;o<t.length;o++){const e=t[o];c[a+0]=e[0],c[a+1]=e[1],c[a+2]=e[2],a+=3}}),c};module.exports=toCompactBinary;
},{"../poly3":78}],44:[function(require,module,exports){
const poly3=require("../poly3"),toPolygons=require("./toPolygons"),toPoints=o=>{return toPolygons(o).map(o=>poly3.toPoints(o))};module.exports=toPoints;
},{"../poly3":78,"./toPolygons":45}],45:[function(require,module,exports){
const applyTransforms=require("./applyTransforms"),toPolygons=o=>applyTransforms(o).polygons;module.exports=toPolygons;
},{"./applyTransforms":35}],46:[function(require,module,exports){
const poly3=require("../poly3"),toPolygons=require("./toPolygons"),toString=o=>{const t=toPolygons(o);let n="geom3 ("+t.length+" polygons):\n";return t.forEach(o=>{n+=" "+poly3.toString(o)+"\n"}),n};module.exports=toString;
},{"../poly3":78,"./toPolygons":45}],47:[function(require,module,exports){
const mat4=require("../../maths/mat4"),transform=(t,r)=>{const s=mat4.multiply(mat4.create(),t,r.transforms);return Object.assign({},r,{transforms:s})};module.exports=transform;
},{"../../maths/mat4":142}],48:[function(require,module,exports){
const poly3=require("../poly3"),isA=require("./isA"),validate=e=>{if(!isA(e))throw new Error("invalid geom3 structure");if(e.polygons.forEach(poly3.validate),validateManifold(e),!e.transforms.every(Number.isFinite))throw new Error(`geom3 invalid transforms ${e.transforms}`)},validateManifold=e=>{const o=new Map;e.polygons.forEach(({vertices:e})=>{e.forEach((r,n)=>{const t=`${`${r}`}/${`${e[(n+1)%e.length]}`}`,i=o.has(t)?o.get(t):0;o.set(t,i+1)})});const r=[];if(o.forEach((e,n)=>{const t=n.split("/").reverse().join("/");e!==o.get(t)&&r.push(n.replace("/"," -> "))}),r.length>0)throw new Error(`non-manifold edges ${r.length}\n${r.join("\n")}`)};module.exports=validate;
},{"../poly3":78,"./isA":42}],49:[function(require,module,exports){
module.exports={geom2:require("./geom2"),geom3:require("./geom3"),path2:require("./path2"),poly2:require("./poly2"),poly3:require("./poly3")};
},{"./geom2":25,"./geom3":40,"./path2":61,"./poly2":72,"./poly3":78}],50:[function(require,module,exports){
const{TAU:TAU}=require("../../maths/constants"),vec2=require("../../maths/vec2"),fromPoints=require("./fromPoints"),toPoints=require("./toPoints"),appendArc=(e,t)=>{let{endpoint:r,radius:a,xaxisrotation:o,clockwise:n,large:s,segments:c}=Object.assign({},{radius:[0,0],xaxisrotation:0,clockwise:!1,large:!1,segments:16},e);if(!Array.isArray(r))throw new Error("endpoint must be an array of X and Y values");if(r.length<2)throw new Error("endpoint must contain X and Y values");if(r=vec2.clone(r),!Array.isArray(a))throw new Error("radius must be an array of X and Y values");if(a.length<2)throw new Error("radius must contain X and Y values");if(c<4)throw new Error("segments must be four or more");if(t.isClosed)throw new Error("the given path cannot be closed");const i=toPoints(t);if(i.length<1)throw new Error("the given path must contain one or more points (as the starting point for the arc)");let h=a[0],u=a[1];const l=i[i.length-1];h=Math.round(1e5*h)/1e5,u=Math.round(1e5*u)/1e5,r=vec2.fromValues(Math.round(1e5*r[0])/1e5,Math.round(1e5*r[1])/1e5);const d=!n;let v=[];if(0===h||0===u)v.push(r);else{h=Math.abs(h),u=Math.abs(u);const t=o,a=Math.cos(t),n=Math.sin(t),i=vec2.subtract(vec2.create(),l,r);vec2.scale(i,i,.5);const f=Math.round(1e5*(a*i[0]+n*i[1]))/1e5,m=Math.round(1e5*(-n*i[0]+a*i[1]))/1e5,M=vec2.fromValues(f,m),p=M[0]*M[0]/(h*h)+M[1]*M[1]/(u*u);if(p>1){const e=Math.sqrt(p);h*=e,u*=e,h=Math.round(1e5*h)/1e5,u=Math.round(1e5*u)/1e5}let w=Math.sqrt((h*h*u*u-h*h*M[1]*M[1]-u*u*M[0]*M[0])/(h*h*M[1]*M[1]+u*u*M[0]*M[0]));d===s&&(w=-w);const g=vec2.fromValues(h*M[1]/u,-u*M[0]/h);vec2.scale(g,g,w);let A=vec2.fromValues(a*g[0]-n*g[1],n*g[0]+a*g[1]);A=vec2.add(A,A,vec2.scale(vec2.create(),vec2.add(vec2.create(),l,r),.5));const b=vec2.fromValues((M[0]-g[0])/h,(M[1]-g[1])/u),E=vec2.fromValues((-M[0]-g[0])/h,(-M[1]-g[1])/u),V=vec2.angleRadians(b);let q=vec2.angleRadians(E)-V;q%=TAU,!d&&q>0?q-=TAU:d&&q<0&&(q+=TAU);let y=Math.ceil(Math.abs(q)/TAU*c)+1;y<1&&(y=1);for(let e=1;e<y;e++){const t=V+e/y*q,r=Math.cos(t),o=Math.sin(t),s=vec2.fromValues(a*h*r-n*u*o,n*h*r+a*u*o);vec2.add(s,s,A),v.push(s)}y&&v.push(e.endpoint)}return v=i.concat(v),fromPoints({},v)};module.exports=appendArc;
},{"../../maths/constants":93,"../../maths/vec2":190,"./fromPoints":60,"./toPoints":65}],51:[function(require,module,exports){
const{TAU:TAU}=require("../../maths/constants"),vec2=require("../../maths/vec2"),vec3=require("../../maths/vec2"),appendPoints=require("./appendPoints"),toPoints=require("./toPoints"),appendBezier=(e,t)=>{let{controlPoints:o,segments:r}=Object.assign({},{segments:16},e);if(!Array.isArray(o))throw new Error("controlPoints must be an array of one or more points");if(o.length<1)throw new Error("controlPoints must be an array of one or more points");if(r<4)throw new Error("segments must be four or more");if(t.isClosed)throw new Error("the given geometry cannot be closed");const n=toPoints(t);if(n.length<1)throw new Error("the given path must contain one or more points (as the starting point for the bezier curve)");if(null===(o=o.slice())[0]){if(o.length<2)throw new Error("a null control point must be passed with one more control points");let e=n[n.length-2];if("lastBezierControlPoint"in t&&(e=t.lastBezierControlPoint),!Array.isArray(e))throw new Error("the given path must contain TWO or more points if given a null control point");const r=vec2.scale(vec2.create(),n[n.length-1],2);vec2.subtract(r,r,e),o[0]=r}o.unshift(n[n.length-1]);const s=o.length-1,i=[];let c=1;for(let e=0;e<=s;++e)e>0&&(c*=e),i.push(c);const a=[];for(let e=0;e<=s;++e){const t=i[s]/(i[e]*i[s-e]);a.push(t)}const l=vec2.create(),h=vec2.create(),p=vec3.create(),u=e=>{let t=1,r=Math.pow(1-e,s);const n=1!==e?1/(1-e):1,i=vec2.create();for(let c=0;c<=s;++c){c===s&&(r=1);const h=a[c]*t*r,p=vec2.scale(l,o[c],h);vec2.add(i,i,p),t*=e,r*=n}return i},v=[],m=[],f=s+1;for(let e=0;e<f;++e){const t=e/(f-1),o=u(t);v.push(o),m.push(t)}let g=1;const w=TAU/r,P=Math.sin(w);for(;g<v.length-1;){const e=vec2.subtract(l,v[g],v[g-1]);vec2.normalize(e,e);const t=vec2.subtract(h,v[g+1],v[g]);vec2.normalize(t,t);const o=vec2.cross(p,e,t);if(Math.abs(o[2])>P){const e=m[g-1],t=m[g+1],o=e+1*(t-e)/3,r=e+2*(t-e)/3,n=u(o),s=u(r);v.splice(g,1,n,s),m.splice(g,1,o,r),--g<1&&(g=1)}else++g}v.shift();const b=appendPoints(v,t);return b.lastBezierControlPoint=o[o.length-2],b};module.exports=appendBezier;
},{"../../maths/constants":93,"../../maths/vec2":190,"./appendPoints":52,"./toPoints":65}],52:[function(require,module,exports){
const concat=require("./concat"),create=require("./create"),appendPoints=(e,c)=>concat(c,create(e));module.exports=appendPoints;
},{"./concat":56,"./create":57}],53:[function(require,module,exports){
const mat4=require("../../maths/mat4"),vec2=require("../../maths/vec2"),applyTransforms=r=>mat4.isIdentity(r.transforms)?r:(r.points=r.points.map(s=>vec2.transform(vec2.create(),s,r.transforms)),r.transforms=mat4.create(),r);module.exports=applyTransforms;
},{"../../maths/mat4":142,"../../maths/vec2":190}],54:[function(require,module,exports){
const clone=e=>Object.assign({},e);module.exports=clone;
},{}],55:[function(require,module,exports){
const{EPS:EPS}=require("../../maths/constants"),vec2=require("../../maths/vec2"),clone=require("./clone"),close=e=>{if(e.isClosed)return e;const t=clone(e);if(t.isClosed=!0,t.points.length>1){const e=t.points,n=e[0];let o=e[e.length-1];for(;vec2.distance(n,o)<EPS*EPS&&(e.pop(),1!==e.length);)o=e[e.length-1]}return t};module.exports=close;
},{"../../maths/constants":93,"../../maths/vec2":190,"./clone":54}],56:[function(require,module,exports){
const fromPoints=require("./fromPoints"),toPoints=require("./toPoints"),{equals:equals}=require("../../maths/vec2"),concat=(...t)=>{let o=!1,e=[];return t.forEach((t,n)=>{const s=toPoints(t).slice();if(e.length>0&&s.length>0&&equals(s[0],e[e.length-1])&&s.shift(),s.length>0&&o)throw new Error(`Cannot concatenate to a closed path; check the ${n}th path`);o=t.isClosed,e=e.concat(s)}),fromPoints({closed:o},e)};module.exports=concat;
},{"../../maths/vec2":190,"./fromPoints":60,"./toPoints":65}],57:[function(require,module,exports){
const mat4=require("../../maths/mat4"),create=e=>(void 0===e&&(e=[]),{points:e,isClosed:!1,transforms:mat4.create()});module.exports=create;
},{"../../maths/mat4":142}],58:[function(require,module,exports){
const vec2=require("../../maths/vec2"),toPoints=require("./toPoints"),equals=(e,t)=>{if(e.isClosed!==t.isClosed)return!1;if(e.points.length!==t.points.length)return!1;const o=toPoints(e),s=toPoints(t),i=o.length;let r=0;do{let t=!1;for(let e=0;e<i;e++)if(!vec2.equals(o[e],s[(e+r)%i])){t=!0;break}if(!1===t)return!0;if(!e.isClosed)return!1}while(++r<i);return!1};module.exports=equals;
},{"../../maths/vec2":190,"./toPoints":65}],59:[function(require,module,exports){
const mat4=require("../../maths/mat4"),vec2=require("../../maths/vec2"),create=require("./create"),fromCompactBinary=r=>{if(2!==r[0])throw new Error("invalid compact binary data");const e=create();e.transforms=mat4.clone(r.slice(1,17)),e.isClosed=!!r[17];for(let t=22;t<r.length;t+=2){const o=vec2.fromValues(r[t],r[t+1]);e.points.push(o)}return r[18]>=0&&(e.color=[r[18],r[19],r[20],r[21]]),e};module.exports=fromCompactBinary;
},{"../../maths/mat4":142,"../../maths/vec2":190,"./create":57}],60:[function(require,module,exports){
const{EPS:EPS}=require("../../maths/constants"),vec2=require("../../maths/vec2"),close=require("./close"),create=require("./create"),fromPoints=(e,t)=>{let{closed:s}=Object.assign({},{closed:!1},e),o=create();if(o.points=t.map(e=>vec2.clone(e)),o.points.length>1){const e=o.points[0],t=o.points[o.points.length-1];vec2.distance(e,t)<EPS*EPS&&(s=!0)}return!0===s&&(o=close(o)),o};module.exports=fromPoints;
},{"../../maths/constants":93,"../../maths/vec2":190,"./close":55,"./create":57}],61:[function(require,module,exports){
module.exports={appendArc:require("./appendArc"),appendBezier:require("./appendBezier"),appendPoints:require("./appendPoints"),clone:require("./clone"),close:require("./close"),concat:require("./concat"),create:require("./create"),equals:require("./equals"),fromPoints:require("./fromPoints"),fromCompactBinary:require("./fromCompactBinary"),isA:require("./isA"),reverse:require("./reverse"),toPoints:require("./toPoints"),toString:require("./toString"),toCompactBinary:require("./toCompactBinary"),transform:require("./transform"),validate:require("./validate")};
},{"./appendArc":50,"./appendBezier":51,"./appendPoints":52,"./clone":54,"./close":55,"./concat":56,"./create":57,"./equals":58,"./fromCompactBinary":59,"./fromPoints":60,"./isA":62,"./reverse":63,"./toCompactBinary":64,"./toPoints":65,"./toString":66,"./transform":67,"./validate":68}],62:[function(require,module,exports){
const isA=s=>!!(s&&"object"==typeof s&&"points"in s&&"transforms"in s&&"isClosed"in s&&Array.isArray(s.points)&&"length"in s.transforms);module.exports=isA;
},{}],63:[function(require,module,exports){
const clone=require("./clone"),reverse=e=>{const r=clone(e);return r.points=e.points.slice().reverse(),r};module.exports=reverse;
},{"./clone":54}],64:[function(require,module,exports){
const toCompactBinary=o=>{const t=o.points,n=o.transforms;let r=[-1,-1,-1,-1];o.color&&(r=o.color);const s=new Float32Array(22+2*t.length);s[0]=2,s[1]=n[0],s[2]=n[1],s[3]=n[2],s[4]=n[3],s[5]=n[4],s[6]=n[5],s[7]=n[6],s[8]=n[7],s[9]=n[8],s[10]=n[9],s[11]=n[10],s[12]=n[11],s[13]=n[12],s[14]=n[13],s[15]=n[14],s[16]=n[15],s[17]=o.isClosed?1:0,s[18]=r[0],s[19]=r[1],s[20]=r[2],s[21]=r[3];for(let o=0;o<t.length;o++){const n=2*o+22,r=t[o];s[n]=r[0],s[n+1]=r[1]}return s};module.exports=toCompactBinary;
},{}],65:[function(require,module,exports){
const applyTransforms=require("./applyTransforms"),toPoints=o=>applyTransforms(o).points;module.exports=toPoints;
},{"./applyTransforms":53}],66:[function(require,module,exports){
const vec2=require("../../maths/vec2"),toPoints=require("./toPoints"),toString=t=>{const o=toPoints(t);let n="path ("+o.length+" points, "+t.isClosed+"):\n[\n";return o.forEach(t=>{n+=" "+vec2.toString(t)+",\n"}),n+="]\n"};module.exports=toString;
},{"../../maths/vec2":190,"./toPoints":65}],67:[function(require,module,exports){
const mat4=require("../../maths/mat4"),transform=(t,r)=>{const s=mat4.multiply(mat4.create(),t,r.transforms);return Object.assign({},r,{transforms:s})};module.exports=transform;
},{"../../maths/mat4":142}],68:[function(require,module,exports){
const vec2=require("../../maths/vec2"),isA=require("./isA"),validate=r=>{if(!isA(r))throw new Error("invalid path2 structure");if(r.points.length>1)for(let i=0;i<r.points.length;i++)if(vec2.equals(r.points[i],r.points[(i+1)%r.points.length]))throw new Error(`path2 duplicate points ${r.points[i]}`);if(r.points.forEach(r=>{if(!r.every(Number.isFinite))throw new Error(`path2 invalid point ${r}`)}),!r.transforms.every(Number.isFinite))throw new Error(`path2 invalid transforms ${r.transforms}`)};module.exports=validate;
},{"../../maths/vec2":190,"./isA":62}],69:[function(require,module,exports){
const measureArea=require("./measureArea"),flip=require("./flip"),arePointsInside=(e,r)=>{if(0===e.length)return 0;const n=r.vertices;return n.length<3?0:(measureArea(r)<0&&(r=flip(r)),e.reduce((e,r)=>e+isPointInside(r,n),0)===e.length?1:0)},isPointInside=(e,r)=>{const n=r.length,t=e[0],i=e[1];let s=r[n-1],o=r[0],l=s[1]>i,u=0,a=0;for(let e=n+1;--e;){const e=o[1]>i;if(l!==e){const e=s[0]>t,r=o[0]>t;e&&r?u=!u:o[0]-(o[1]-i)*(s[0]-o[0])/(s[1]-o[1])>=t&&(u=!u)}l=e,s=o,o=r[++a]}return u};module.exports=arePointsInside;
},{"./flip":71,"./measureArea":73}],70:[function(require,module,exports){
const create=e=>((void 0===e||e.length<3)&&(e=[]),{vertices:e});module.exports=create;
},{}],71:[function(require,module,exports){
const create=require("./create"),flip=e=>{const r=e.vertices.slice().reverse();return create(r)};module.exports=flip;
},{"./create":70}],72:[function(require,module,exports){
module.exports={arePointsInside:require("./arePointsInside"),create:require("./create"),flip:require("./flip"),measureArea:require("./measureArea")};
},{"./arePointsInside":69,"./create":70,"./flip":71,"./measureArea":73}],73:[function(require,module,exports){
const area=require("../../maths/utils/area"),measureArea=e=>area(e.vertices);module.exports=measureArea;
},{"../../maths/utils/area":167}],74:[function(require,module,exports){
const create=require("./create"),vec3=require("../../maths/vec3"),clone=(...e)=>{let c,r;return 1===e.length?(c=create(),r=e[0]):(c=e[0],r=e[1]),c.vertices=r.vertices.map(e=>vec3.clone(e)),c};module.exports=clone;
},{"../../maths/vec3":221,"./create":75}],75:[function(require,module,exports){
const create=e=>((void 0===e||e.length<3)&&(e=[]),{vertices:e});module.exports=create;
},{}],76:[function(require,module,exports){
const vec3=require("../../maths/vec3"),create=require("./create"),fromPoints=e=>{const r=e.map(e=>vec3.clone(e));return create(r)};module.exports=fromPoints;
},{"../../maths/vec3":221,"./create":75}],77:[function(require,module,exports){
const create=require("./create"),fromPointsAndPlane=(e,n)=>{const r=create(e);return r.plane=n,r};module.exports=fromPointsAndPlane;
},{"./create":75}],78:[function(require,module,exports){
module.exports={clone:require("./clone"),create:require("./create"),fromPoints:require("./fromPoints"),fromPointsAndPlane:require("./fromPointsAndPlane"),invert:require("./invert"),isA:require("./isA"),isConvex:require("./isConvex"),measureArea:require("./measureArea"),measureBoundingBox:require("./measureBoundingBox"),measureBoundingSphere:require("./measureBoundingSphere"),measureSignedVolume:require("./measureSignedVolume"),plane:require("./plane"),toPoints:require("./toPoints"),toString:require("./toString"),transform:require("./transform"),validate:require("./validate")};
},{"./clone":74,"./create":75,"./fromPoints":76,"./fromPointsAndPlane":77,"./invert":79,"./isA":80,"./isConvex":81,"./measureArea":82,"./measureBoundingBox":83,"./measureBoundingSphere":84,"./measureSignedVolume":85,"./plane":86,"./toPoints":87,"./toString":88,"./transform":89,"./validate":90}],79:[function(require,module,exports){
const plane=require("../../maths/plane"),create=require("./create"),invert=e=>{const r=e.vertices.slice().reverse(),a=create(r);return e.plane&&(a.plane=plane.flip(plane.create(),e.plane)),a};module.exports=invert;
},{"../../maths/plane":162,"./create":75}],80:[function(require,module,exports){
const isA=e=>!!(e&&"object"==typeof e&&"vertices"in e&&Array.isArray(e.vertices));module.exports=isA;
},{}],81:[function(require,module,exports){
const plane=require("../../maths/plane"),vec3=require("../../maths/vec3"),isConvex=e=>areVerticesConvex(e.vertices),areVerticesConvex=e=>{const t=e.length;if(t>2){const r=plane.fromPoints(plane.create(),...e);let c=e[t-2],n=e[t-1];for(let o=0;o<t;o++){const t=e[o];if(!isConvexPoint(c,n,t,r))return!1;c=n,n=t}}return!0},isConvexPoint=(e,t,r,c)=>{const n=vec3.cross(vec3.create(),vec3.subtract(vec3.create(),t,e),vec3.subtract(vec3.create(),r,t));return vec3.dot(n,c)>=0};module.exports=isConvex;
},{"../../maths/plane":162,"../../maths/vec3":221}],82:[function(require,module,exports){
const plane=require("./plane"),measureArea=e=>{const r=e.vertices.length;if(r<3)return 0;const a=e.vertices,t=plane(e),s=Math.abs(t[0]),n=Math.abs(t[1]),c=Math.abs(t[2]);if(s+n+c===0)return 0;let l=3;s>n&&s>c?l=1:n>c&&(l=2);let o=0,u=0,f=1,i=2;switch(l){case 1:for(f=1;f<r;f++)u=f-1,i=(f+1)%r,o+=a[f][1]*(a[i][2]-a[u][2]);o+=a[0][1]*(a[1][2]-a[r-1][2]),o/=2*t[0];break;case 2:for(f=1;f<r;f++)u=f-1,i=(f+1)%r,o+=a[f][2]*(a[i][0]-a[u][0]);o+=a[0][2]*(a[1][0]-a[r-1][0]),o/=2*t[1];break;case 3:default:for(f=1;f<r;f++)u=f-1,i=(f+1)%r,o+=a[f][0]*(a[i][1]-a[u][1]);o+=a[0][0]*(a[1][1]-a[r-1][1]),o/=2*t[2]}return o};module.exports=measureArea;
},{"./plane":86}],83:[function(require,module,exports){
const vec3=require("../../maths/vec3"),measureBoundingBox=e=>{const c=e.vertices,n=c.length,o=0===n?vec3.create():vec3.clone(c[0]),r=vec3.clone(o);for(let e=1;e<n;e++)vec3.min(o,o,c[e]),vec3.max(r,r,c[e]);return[o,r]};module.exports=measureBoundingBox;
},{"../../maths/vec3":221}],84:[function(require,module,exports){
const vec4=require("../../maths/vec4"),cache=new WeakMap,measureBoundingSphere=e=>{const r=cache.get(e);if(r)return r;const t=e.vertices,c=vec4.create();if(0===t.length)return c[0]=0,c[1]=0,c[2]=0,c[3]=0,c;let n=t[0],a=n,s=n,h=n,o=n,u=n;t.forEach(e=>{n[0]>e[0]&&(n=e),a[1]>e[1]&&(a=e),s[2]>e[2]&&(s=e),h[0]<e[0]&&(h=e),o[1]<e[1]&&(o=e),u[2]<e[2]&&(u=e)}),c[0]=.5*(n[0]+h[0]),c[1]=.5*(a[1]+o[1]),c[2]=.5*(s[2]+u[2]);const i=c[0]-h[0],g=c[1]-o[1],m=c[2]-u[2];return c[3]=Math.sqrt(i*i+g*g+m*m),cache.set(e,c),c};module.exports=measureBoundingSphere;
},{"../../maths/vec4":247}],85:[function(require,module,exports){
const vec3=require("../../maths/vec3"),measureSignedVolume=e=>{let r=0;const t=e.vertices,c=vec3.create();for(let e=0;e<t.length-2;e++)vec3.cross(c,t[e+1],t[e+2]),r+=vec3.dot(t[0],c);return r/=6};module.exports=measureSignedVolume;
},{"../../maths/vec3":221}],86:[function(require,module,exports){
const mplane=require("../../maths/plane/"),plane=e=>(e.plane||(e.plane=mplane.fromPoints(mplane.create(),...e.vertices)),e.plane);module.exports=plane;
},{"../../maths/plane/":162}],87:[function(require,module,exports){
const toPoints=o=>o.vertices;module.exports=toPoints;
},{}],88:[function(require,module,exports){
const vec3=require("../../maths/vec3/"),toString=e=>{let t="poly3: vertices: [";return e.vertices.forEach(e=>{t+=`${vec3.toString(e)}, `}),t+="]"};module.exports=toString;
},{"../../maths/vec3/":221}],89:[function(require,module,exports){
const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),create=require("./create"),transform=(e,r)=>{const t=r.vertices.map(r=>vec3.transform(vec3.create(),r,e));return mat4.isMirroring(e)&&t.reverse(),create(t)};module.exports=transform;
},{"../../maths/mat4":142,"../../maths/vec3":221,"./create":75}],90:[function(require,module,exports){
const signedDistanceToPoint=require("../../maths/plane/signedDistanceToPoint"),{NEPS:NEPS}=require("../../maths/constants"),vec3=require("../../maths/vec3"),isA=require("./isA"),isConvex=require("./isConvex"),measureArea=require("./measureArea"),plane=require("./plane"),validate=e=>{if(!isA(e))throw new Error("invalid poly3 structure");if(e.vertices.length<3)throw new Error(`poly3 not enough vertices ${e.vertices.length}`);if(measureArea(e)<=0)throw new Error("poly3 area must be greater than zero");for(let r=0;r<e.vertices.length;r++)if(vec3.equals(e.vertices[r],e.vertices[(r+1)%e.vertices.length]))throw new Error(`poly3 duplicate vertex ${e.vertices[r]}`);if(!isConvex(e))throw new Error("poly3 must be convex");if(e.vertices.forEach(e=>{if(!e.every(Number.isFinite))throw new Error(`poly3 invalid vertex ${e}`)}),e.vertices.length>3){const r=plane(e);e.vertices.forEach(e=>{const t=Math.abs(signedDistanceToPoint(r,e));if(t>NEPS)throw new Error(`poly3 must be coplanar: vertex ${e} distance ${t}`)})}};module.exports=validate;
},{"../../maths/constants":93,"../../maths/plane/signedDistanceToPoint":164,"../../maths/vec3":221,"./isA":80,"./isConvex":81,"./measureArea":82,"./plane":86}],91:[function(require,module,exports){
module.exports={colors:require("./colors"),curves:require("./curves"),geometries:require("./geometries"),maths:require("./maths"),measurements:require("./measurements"),primitives:require("./primitives"),text:require("./text"),utils:require("./utils"),booleans:require("./operations/booleans"),expansions:require("./operations/expansions"),extrusions:require("./operations/extrusions"),hulls:require("./operations/hulls"),modifiers:require("./operations/modifiers"),transforms:require("./operations/transforms")};
},{"./colors":8,"./curves":19,"./geometries":49,"./maths":94,"./measurements":251,"./operations/booleans":265,"./operations/expansions":294,"./operations/extrusions":317,"./operations/hulls":339,"./operations/modifiers":350,"./operations/transforms":360,"./primitives":376,"./text":390,"./utils":398}],92:[function(require,module,exports){
const mat4=require("./mat4"),vec2=require("./vec2"),vec3=require("./vec3"),OrthoNormalBasis=function(e,t){arguments.length<2&&(t=vec3.orthogonal(vec3.create(),e)),this.v=vec3.normalize(vec3.create(),vec3.cross(vec3.create(),e,t)),this.u=vec3.cross(vec3.create(),this.v,e),this.plane=e,this.planeorigin=vec3.scale(vec3.create(),e,e[3])};OrthoNormalBasis.GetCartesian=function(e,t){const i=e+"/"+t;let s,n;if("X/Y"===i)s=[0,0,1],n=[1,0,0];else if("Y/-X"===i)s=[0,0,1],n=[0,1,0];else if("-X/-Y"===i)s=[0,0,1],n=[-1,0,0];else if("-Y/X"===i)s=[0,0,1],n=[0,-1,0];else if("-X/Y"===i)s=[0,0,-1],n=[-1,0,0];else if("-Y/-X"===i)s=[0,0,-1],n=[0,-1,0];else if("X/-Y"===i)s=[0,0,-1],n=[1,0,0];else if("Y/X"===i)s=[0,0,-1],n=[0,1,0];else if("X/Z"===i)s=[0,-1,0],n=[1,0,0];else if("Z/-X"===i)s=[0,-1,0],n=[0,0,1];else if("-X/-Z"===i)s=[0,-1,0],n=[-1,0,0];else if("-Z/X"===i)s=[0,-1,0],n=[0,0,-1];else if("-X/Z"===i)s=[0,1,0],n=[-1,0,0];else if("-Z/-X"===i)s=[0,1,0],n=[0,0,-1];else if("X/-Z"===i)s=[0,1,0],n=[1,0,0];else if("Z/X"===i)s=[0,1,0],n=[0,0,1];else if("Y/Z"===i)s=[1,0,0],n=[0,1,0];else if("Z/-Y"===i)s=[1,0,0],n=[0,0,1];else if("-Y/-Z"===i)s=[1,0,0],n=[0,-1,0];else if("-Z/Y"===i)s=[1,0,0],n=[0,0,-1];else if("-Y/Z"===i)s=[-1,0,0],n=[0,-1,0];else if("-Z/-Y"===i)s=[-1,0,0],n=[0,0,-1];else if("Y/-Z"===i)s=[-1,0,0],n=[0,1,0];else{if("Z/Y"!==i)throw new Error("OrthoNormalBasis.GetCartesian: invalid combination of axis identifiers. Should pass two string arguments from [X,Y,Z,-X,-Y,-Z], being two different axes.");s=[-1,0,0],n=[0,0,1]}return new OrthoNormalBasis(new Plane(new Vector3D(s),0),new Vector3D(n))},OrthoNormalBasis.Z0Plane=function(){const e=new Plane(new Vector3D([0,0,1]),0);return new OrthoNormalBasis(e,new Vector3D([1,0,0]))},OrthoNormalBasis.prototype={getProjectionMatrix:function(){return mat4.fromValues(this.u[0],this.v[0],this.plane[0],0,this.u[1],this.v[1],this.plane[1],0,this.u[2],this.v[2],this.plane[2],0,0,0,-this.plane[3],1)},getInverseProjectionMatrix:function(){const e=vec3.scale(vec3.create(),this.plane,this.plane[3]);return mat4.fromValues(this.u[0],this.u[1],this.u[2],0,this.v[0],this.v[1],this.v[2],0,this.plane[0],this.plane[1],this.plane[2],0,e[0],e[1],e[2],1)},to2D:function(e){return vec2.fromValues(vec3.dot(e,this.u),vec3.dot(e,this.v))},to3D:function(e){const t=vec3.scale(vec3.create(),this.u,e[0]),i=vec3.scale(vec3.create(),this.v,e[1]),s=vec3.add(t,t,this.planeorigin);return vec3.add(i,i,s)},line3Dto2D:function(e){const t=e.point,i=e.direction.plus(t),s=this.to2D(t),n=this.to2D(i);return Line2D.fromPoints(s,n)},line2Dto3D:function(e){const t=e.origin(),i=e.direction().plus(t),s=this.to3D(t),n=this.to3D(i);return Line3D.fromPoints(s,n)},transform:function(e){const t=this.plane.transform(e),i=this.u.transform(e),s=new Vector3D(0,0,0).transform(e),n=i.minus(s);return new OrthoNormalBasis(t,n)}},module.exports=OrthoNormalBasis;
},{"./mat4":142,"./vec2":190,"./vec3":221}],93:[function(require,module,exports){
const spatialResolution=1e5,EPS=1e-5,NEPS=1e-13,TAU=2*Math.PI;module.exports={EPS:EPS,NEPS:NEPS,TAU:TAU,spatialResolution:1e5};
},{}],94:[function(require,module,exports){
module.exports={constants:require("./constants"),line2:require("./line2"),line3:require("./line3"),mat4:require("./mat4"),plane:require("./plane"),utils:require("./utils"),vec2:require("./vec2"),vec3:require("./vec3"),vec4:require("./vec4")};
},{"./constants":93,"./line2":104,"./line3":121,"./mat4":142,"./plane":162,"./utils":168,"./vec2":190,"./vec3":221,"./vec4":247}],95:[function(require,module,exports){
const create=require("./create"),clone=e=>{const r=create();return r[0]=e[0],r[1]=e[1],r[2]=e[2],r};module.exports=clone;
},{"./create":98}],96:[function(require,module,exports){
const vec2=require("../vec2"),direction=require("./direction"),origin=require("./origin"),closestPoint=(e,c)=>{const i=origin(e),r=direction(e),o=vec2.subtract(vec2.create(),c,i),t=vec2.dot(o,r);return vec2.scale(o,r,t),vec2.add(o,o,i),o};module.exports=closestPoint;
},{"../vec2":190,"./direction":99,"./origin":106}],97:[function(require,module,exports){
const copy=(o,c)=>(o[0]=c[0],o[1]=c[1],o[2]=c[2],o);module.exports=copy;
},{}],98:[function(require,module,exports){
const create=()=>[0,1,0];module.exports=create;
},{}],99:[function(require,module,exports){
const vec2=require("../vec2"),direction=e=>{const c=vec2.normal(vec2.create(),e);return vec2.negate(c,c),c};module.exports=direction;
},{"../vec2":190}],100:[function(require,module,exports){
const vec2=require("../vec2"),distanceToPoint=(e,t)=>{let o=vec2.dot(t,e);return o=Math.abs(o-e[2])};module.exports=distanceToPoint;
},{"../vec2":190}],101:[function(require,module,exports){
const equals=(e,s)=>e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2];module.exports=equals;
},{}],102:[function(require,module,exports){
const vec2=require("../vec2"),fromPoints=(e,c,o)=>{const r=vec2.subtract(vec2.create(),o,c);vec2.normal(r,r),vec2.normalize(r,r);const t=vec2.dot(c,r);return e[0]=r[0],e[1]=r[1],e[2]=t,e};module.exports=fromPoints;
},{"../vec2":190}],103:[function(require,module,exports){
const create=require("./create"),fromValues=(e,r,t)=>{const o=create();return o[0]=e,o[1]=r,o[2]=t,o};module.exports=fromValues;
},{"./create":98}],104:[function(require,module,exports){
module.exports={clone:require("./clone"),closestPoint:require("./closestPoint"),copy:require("./copy"),create:require("./create"),direction:require("./direction"),distanceToPoint:require("./distanceToPoint"),equals:require("./equals"),fromPoints:require("./fromPoints"),fromValues:require("./fromValues"),intersectPointOfLines:require("./intersectPointOfLines"),origin:require("./origin"),reverse:require("./reverse"),toString:require("./toString"),transform:require("./transform"),xAtY:require("./xAtY")};
},{"./clone":95,"./closestPoint":96,"./copy":97,"./create":98,"./direction":99,"./distanceToPoint":100,"./equals":101,"./fromPoints":102,"./fromValues":103,"./intersectPointOfLines":105,"./origin":106,"./reverse":107,"./toString":108,"./transform":109,"./xAtY":110}],105:[function(require,module,exports){
const vec2=require("../vec2"),{solve2Linear:solve2Linear}=require("../utils"),intersectToLine=(e,r)=>{const n=solve2Linear(e[0],e[1],r[0],r[1],e[2],r[2]);return vec2.clone(n)};module.exports=intersectToLine;
},{"../utils":168,"../vec2":190}],106:[function(require,module,exports){
const vec2=require("../vec2"),origin=e=>vec2.scale(vec2.create(),e,e[2]);module.exports=origin;
},{"../vec2":190}],107:[function(require,module,exports){
const vec2=require("../vec2"),copy=require("./copy"),fromValues=require("./fromValues"),reverse=(e,r)=>{const c=vec2.negate(vec2.create(),r),o=-r[2];return copy(e,fromValues(c[0],c[1],o))};module.exports=reverse;
},{"../vec2":190,"./copy":97,"./fromValues":103}],108:[function(require,module,exports){
const toString=t=>`line2: (${t[0].toFixed(7)}, ${t[1].toFixed(7)}, ${t[2].toFixed(7)})`;module.exports=toString;
},{}],109:[function(require,module,exports){
const vec2=require("../vec2"),fromPoints=require("./fromPoints"),origin=require("./origin"),direction=require("./direction"),transform=(r,o,i)=>{const e=origin(o),n=direction(o);return vec2.transform(e,e,i),vec2.transform(n,n,i),fromPoints(r,e,n)};module.exports=transform;
},{"../vec2":190,"./direction":99,"./fromPoints":102,"./origin":106}],110:[function(require,module,exports){
const origin=require("./origin"),xAtY=(i,r)=>{let e=(i[2]-i[1]*r)/i[0];if(Number.isNaN(e)){e=origin(i)[0]}return e};module.exports=xAtY;
},{"./origin":106}],111:[function(require,module,exports){
const vec3=require("../vec3"),create=require("./create"),clone=e=>{const c=create();return vec3.copy(c[0],e[0]),vec3.copy(c[1],e[1]),c};module.exports=clone;
},{"../vec3":221,"./create":114}],112:[function(require,module,exports){
const vec3=require("../vec3"),closestPoint=(e,c)=>{const t=e[0],o=e[1],s=vec3.dot(vec3.subtract(vec3.create(),c,t),o)/vec3.dot(o,o),v=vec3.scale(vec3.create(),o,s);return vec3.add(v,v,t),v};module.exports=closestPoint;
},{"../vec3":221}],113:[function(require,module,exports){
const vec3=require("../vec3"),copy=(c,e)=>(vec3.copy(c[0],e[0]),vec3.copy(c[1],e[1]),c);module.exports=copy;
},{"../vec3":221}],114:[function(require,module,exports){
const vec3=require("../vec3"),create=()=>[vec3.fromValues(0,0,0),vec3.fromValues(0,0,1)];module.exports=create;
},{"../vec3":221}],115:[function(require,module,exports){
const direction=o=>o[1];module.exports=direction;
},{}],116:[function(require,module,exports){
const vec3=require("../vec3"),closestPoint=require("./closestPoint"),distanceToPoint=(e,t)=>{const c=closestPoint(e,t),o=vec3.subtract(vec3.create(),t,c);return vec3.length(o)};module.exports=distanceToPoint;
},{"../vec3":221,"./closestPoint":112}],117:[function(require,module,exports){
const vec3=require("../vec3"),equals=(e,s)=>!!vec3.equals(e[1],s[1])&&!!vec3.equals(e[0],s[0]);module.exports=equals;
},{"../vec3":221}],118:[function(require,module,exports){
const vec3=require("../vec3"),{solve2Linear:solve2Linear}=require("../utils"),{EPS:EPS}=require("../constants"),fromPointAndDirection=require("./fromPointAndDirection"),fromPlanes=(e,r,o)=>{let n=vec3.cross(vec3.create(),r,o),s=vec3.length(n);if(s<EPS)throw new Error("parallel planes do not intersect");s=1/s,n=vec3.scale(n,n,s);const t=Math.abs(n[0]),a=Math.abs(n[1]),i=Math.abs(n[2]);let l,c;return t>=a&&t>=i?(c=solve2Linear(r[1],r[2],o[1],o[2],r[3],o[3]),l=vec3.fromValues(0,c[0],c[1])):a>=t&&a>=i?(c=solve2Linear(r[0],r[2],o[0],o[2],r[3],o[3]),l=vec3.fromValues(c[0],0,c[1])):(c=solve2Linear(r[0],r[1],o[0],o[1],r[3],o[3]),l=vec3.fromValues(c[0],c[1],0)),fromPointAndDirection(e,l,n)};module.exports=fromPlanes;
},{"../constants":93,"../utils":168,"../vec3":221,"./fromPointAndDirection":119}],119:[function(require,module,exports){
const vec3=require("../vec3"),fromPointAndDirection=(e,c,o)=>{const r=vec3.normalize(vec3.create(),o);return vec3.copy(e[0],c),vec3.copy(e[1],r),e};module.exports=fromPointAndDirection;
},{"../vec3":221}],120:[function(require,module,exports){
const vec3=require("../vec3"),fromPointAndDirection=require("./fromPointAndDirection"),fromPoints=(o,r,e)=>{const t=vec3.subtract(vec3.create(),e,r);return fromPointAndDirection(o,r,t)};module.exports=fromPoints;
},{"../vec3":221,"./fromPointAndDirection":119}],121:[function(require,module,exports){
module.exports={clone:require("./clone"),closestPoint:require("./closestPoint"),copy:require("./copy"),create:require("./create"),direction:require("./direction"),distanceToPoint:require("./distanceToPoint"),equals:require("./equals"),fromPlanes:require("./fromPlanes"),fromPointAndDirection:require("./fromPointAndDirection"),fromPoints:require("./fromPoints"),intersectPointOfLineAndPlane:require("./intersectPointOfLineAndPlane"),origin:require("./origin"),reverse:require("./reverse"),toString:require("./toString"),transform:require("./transform")};
},{"./clone":111,"./closestPoint":112,"./copy":113,"./create":114,"./direction":115,"./distanceToPoint":116,"./equals":117,"./fromPlanes":118,"./fromPointAndDirection":119,"./fromPoints":120,"./intersectPointOfLineAndPlane":122,"./origin":123,"./reverse":124,"./toString":125,"./transform":126}],122:[function(require,module,exports){
const vec3=require("../vec3"),intersectToPlane=(e,c)=>{const t=c,r=c[3],o=e[0],v=e[1],n=(r-vec3.dot(t,o))/vec3.dot(t,v);return vec3.add(vec3.create(),o,vec3.scale(vec3.create(),v,n))};module.exports=intersectToPlane;
},{"../vec3":221}],123:[function(require,module,exports){
const origin=o=>o[0];module.exports=origin;
},{}],124:[function(require,module,exports){
const vec3=require("../vec3"),fromPointAndDirection=require("./fromPointAndDirection"),reverse=(e,r)=>{const n=vec3.clone(r[0]),o=vec3.negate(vec3.create(),r[1]);return fromPointAndDirection(e,n,o)};module.exports=reverse;
},{"../vec3":221,"./fromPointAndDirection":119}],125:[function(require,module,exports){
const toString=t=>{const o=t[0],i=t[1];return`line3: point: (${o[0].toFixed(7)}, ${o[1].toFixed(7)}, ${o[2].toFixed(7)}) direction: (${i[0].toFixed(7)}, ${i[1].toFixed(7)}, ${i[2].toFixed(7)})`};module.exports=toString;
},{}],126:[function(require,module,exports){
const vec3=require("../vec3"),fromPointAndDirection=require("./fromPointAndDirection"),transform=(r,e,t)=>{const o=e[0],c=e[1],n=vec3.add(vec3.create(),o,c),i=vec3.transform(vec3.create(),o,t),a=vec3.transform(n,n,t),m=vec3.subtract(a,a,i);return fromPointAndDirection(r,i,m)};module.exports=transform;
},{"../vec3":221,"./fromPointAndDirection":119}],127:[function(require,module,exports){
const add=(d,o,a)=>(d[0]=o[0]+a[0],d[1]=o[1]+a[1],d[2]=o[2]+a[2],d[3]=o[3]+a[3],d[4]=o[4]+a[4],d[5]=o[5]+a[5],d[6]=o[6]+a[6],d[7]=o[7]+a[7],d[8]=o[8]+a[8],d[9]=o[9]+a[9],d[10]=o[10]+a[10],d[11]=o[11]+a[11],d[12]=o[12]+a[12],d[13]=o[13]+a[13],d[14]=o[14]+a[14],d[15]=o[15]+a[15],d);module.exports=add;
},{}],128:[function(require,module,exports){
const create=require("./create"),clone=e=>{const r=create();return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r[4]=e[4],r[5]=e[5],r[6]=e[6],r[7]=e[7],r[8]=e[8],r[9]=e[9],r[10]=e[10],r[11]=e[11],r[12]=e[12],r[13]=e[13],r[14]=e[14],r[15]=e[15],r};module.exports=clone;
},{"./create":130}],129:[function(require,module,exports){
const copy=(o,c)=>(o[0]=c[0],o[1]=c[1],o[2]=c[2],o[3]=c[3],o[4]=c[4],o[5]=c[5],o[6]=c[6],o[7]=c[7],o[8]=c[8],o[9]=c[9],o[10]=c[10],o[11]=c[11],o[12]=c[12],o[13]=c[13],o[14]=c[14],o[15]=c[15],o);module.exports=copy;
},{}],130:[function(require,module,exports){
const create=()=>[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];module.exports=create;
},{}],131:[function(require,module,exports){
const equals=(e,s)=>e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3]&&e[4]===s[4]&&e[5]===s[5]&&e[6]===s[6]&&e[7]===s[7]&&e[8]===s[8]&&e[9]===s[9]&&e[10]===s[10]&&e[11]===s[11]&&e[12]===s[12]&&e[13]===s[13]&&e[14]===s[14]&&e[15]===s[15];module.exports=equals;
},{}],132:[function(require,module,exports){
const{EPS:EPS}=require("../constants"),{sin:sin,cos:cos}=require("../utils/trigonometry"),identity=require("./identity"),fromRotation=(t,o,i)=>{let[n,r,s]=i;const e=n*n+r*r+s*s;if(Math.abs(e)<EPS)return identity(t);const c=1/Math.sqrt(e);n*=c,r*=c,s*=c;const u=sin(o),a=cos(o),d=1-a;return t[0]=n*n*d+a,t[1]=r*n*d+s*u,t[2]=s*n*d-r*u,t[3]=0,t[4]=n*r*d-s*u,t[5]=r*r*d+a,t[6]=s*r*d+n*u,t[7]=0,t[8]=n*s*d+r*u,t[9]=r*s*d-n*u,t[10]=s*s*d+a,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t};module.exports=fromRotation;
},{"../constants":93,"../utils/trigonometry":172,"./identity":141}],133:[function(require,module,exports){
const fromScaling=(o,c)=>(o[0]=c[0],o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=c[1],o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=c[2],o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o);module.exports=fromScaling;
},{}],134:[function(require,module,exports){
const{sin:sin,cos:cos}=require("../utils/trigonometry"),fromTaitBryanRotation=(o,s,n,t)=>{const i=sin(s),r=cos(s),c=sin(n),a=cos(n),e=sin(t),m=cos(t);return o[0]=a*r,o[1]=a*i,o[2]=-c,o[3]=0,o[4]=e*c*r-m*i,o[5]=m*r+e*c*i,o[6]=e*a,o[7]=0,o[8]=e*i+m*c*r,o[9]=m*c*i-e*r,o[10]=m*a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o};module.exports=fromTaitBryanRotation;
},{"../utils/trigonometry":172}],135:[function(require,module,exports){
const fromTranslation=(o,n)=>(o[0]=1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=1,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=1,o[11]=0,o[12]=n[0],o[13]=n[1],o[14]=n[2],o[15]=1,o);module.exports=fromTranslation;
},{}],136:[function(require,module,exports){
const create=require("./create"),fromValues=(e,r,t,o,a,c,s,u,l,m,n,f,V,d,i,p)=>{const q=create();return q[0]=e,q[1]=r,q[2]=t,q[3]=o,q[4]=a,q[5]=c,q[6]=s,q[7]=u,q[8]=l,q[9]=m,q[10]=n,q[11]=f,q[12]=V,q[13]=d,q[14]=i,q[15]=p,q};module.exports=fromValues;
},{"./create":130}],137:[function(require,module,exports){
const vec3=require("../vec3"),fromRotation=require("./fromRotation"),fromVectorRotation=(o,e,t)=>{const r=vec3.normalize(vec3.create(),e),c=vec3.normalize(vec3.create(),t),n=vec3.cross(vec3.create(),c,r),a=vec3.dot(c,r);if(-1===a)return fromRotation(o,Math.PI,vec3.orthogonal(n,r));const i=1/(1+a);return o[0]=n[0]*n[0]*i+a,o[1]=n[1]*n[0]*i-n[2],o[2]=n[2]*n[0]*i+n[1],o[3]=0,o[4]=n[0]*n[1]*i+n[2],o[5]=n[1]*n[1]*i+a,o[6]=n[2]*n[1]*i-n[0],o[7]=0,o[8]=n[0]*n[2]*i-n[1],o[9]=n[1]*n[2]*i+n[0],o[10]=n[2]*n[2]*i+a,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o};module.exports=fromVectorRotation;
},{"../vec3":221,"./fromRotation":132}],138:[function(require,module,exports){
const{sin:sin,cos:cos}=require("../utils/trigonometry"),fromXRotation=(o,t)=>{const s=sin(t),n=cos(t);return o[0]=1,o[1]=0,o[2]=0,o[3]=0,o[4]=0,o[5]=n,o[6]=s,o[7]=0,o[8]=0,o[9]=-s,o[10]=n,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o};module.exports=fromXRotation;
},{"../utils/trigonometry":172}],139:[function(require,module,exports){
const{sin:sin,cos:cos}=require("../utils/trigonometry"),fromYRotation=(o,t)=>{const s=sin(t),n=cos(t);return o[0]=n,o[1]=0,o[2]=-s,o[3]=0,o[4]=0,o[5]=1,o[6]=0,o[7]=0,o[8]=s,o[9]=0,o[10]=n,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o};module.exports=fromYRotation;
},{"../utils/trigonometry":172}],140:[function(require,module,exports){
const{sin:sin,cos:cos}=require("../utils/trigonometry"),fromZRotation=(o,t)=>{const s=sin(t),n=cos(t);return o[0]=n,o[1]=s,o[2]=0,o[3]=0,o[4]=-s,o[5]=n,o[6]=0,o[7]=0,o[8]=0,o[9]=0,o[10]=1,o[11]=0,o[12]=0,o[13]=0,o[14]=0,o[15]=1,o};module.exports=fromZRotation;
},{"../utils/trigonometry":172}],141:[function(require,module,exports){
const identity=t=>(t[0]=1,t[1]=0,t[2]=0,t[3]=0,t[4]=0,t[5]=1,t[6]=0,t[7]=0,t[8]=0,t[9]=0,t[10]=1,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,t);module.exports=identity;
},{}],142:[function(require,module,exports){
module.exports={add:require("./add"),clone:require("./clone"),copy:require("./copy"),create:require("./create"),invert:require("./invert"),equals:require("./equals"),fromRotation:require("./fromRotation"),fromScaling:require("./fromScaling"),fromTaitBryanRotation:require("./fromTaitBryanRotation"),fromTranslation:require("./fromTranslation"),fromValues:require("./fromValues"),fromVectorRotation:require("./fromVectorRotation"),fromXRotation:require("./fromXRotation"),fromYRotation:require("./fromYRotation"),fromZRotation:require("./fromZRotation"),identity:require("./identity"),isIdentity:require("./isIdentity"),isOnlyTransformScale:require("./isOnlyTransformScale"),isMirroring:require("./isMirroring"),mirrorByPlane:require("./mirrorByPlane"),multiply:require("./multiply"),rotate:require("./rotate"),rotateX:require("./rotateX"),rotateY:require("./rotateY"),rotateZ:require("./rotateZ"),scale:require("./scale"),subtract:require("./subtract"),toString:require("./toString"),translate:require("./translate")};
},{"./add":127,"./clone":128,"./copy":129,"./create":130,"./equals":131,"./fromRotation":132,"./fromScaling":133,"./fromTaitBryanRotation":134,"./fromTranslation":135,"./fromValues":136,"./fromVectorRotation":137,"./fromXRotation":138,"./fromYRotation":139,"./fromZRotation":140,"./identity":141,"./invert":143,"./isIdentity":144,"./isMirroring":145,"./isOnlyTransformScale":146,"./mirrorByPlane":147,"./multiply":148,"./rotate":149,"./rotateX":150,"./rotateY":151,"./rotateZ":152,"./scale":153,"./subtract":154,"./toString":155,"./translate":156}],143:[function(require,module,exports){
const invert=(t,e)=>{const n=e[0],r=e[1],l=e[2],o=e[3],s=e[4],u=e[5],c=e[6],i=e[7],v=e[8],d=e[9],m=e[10],p=e[11],x=e[12],a=e[13],b=e[14],f=e[15],g=n*u-r*s,h=n*c-l*s,j=n*i-o*s,k=r*c-l*u,q=r*i-o*u,w=l*i-o*c,y=v*a-d*x,z=v*b-m*x,A=v*f-p*x,B=d*b-m*a,C=d*f-p*a,D=m*f-p*b;let E=g*D-h*C+j*B+k*A-q*z+w*y;return E?(E=1/E,t[0]=(u*D-c*C+i*B)*E,t[1]=(l*C-r*D-o*B)*E,t[2]=(a*w-b*q+f*k)*E,t[3]=(m*q-d*w-p*k)*E,t[4]=(c*A-s*D-i*z)*E,t[5]=(n*D-l*A+o*z)*E,t[6]=(b*j-x*w-f*h)*E,t[7]=(v*w-m*j+p*h)*E,t[8]=(s*C-u*A+i*y)*E,t[9]=(r*A-n*C-o*y)*E,t[10]=(x*q-a*j+f*g)*E,t[11]=(d*j-v*q-p*g)*E,t[12]=(u*z-s*B-c*y)*E,t[13]=(n*B-r*z+l*y)*E,t[14]=(a*h-x*k-b*g)*E,t[15]=(v*k-d*h+m*g)*E,t):null};module.exports=invert;
},{}],144:[function(require,module,exports){
const isIdentity=t=>1===t[0]&&0===t[1]&&0===t[2]&&0===t[3]&&0===t[4]&&1===t[5]&&0===t[6]&&0===t[7]&&0===t[8]&&0===t[9]&&1===t[10]&&0===t[11]&&0===t[12]&&0===t[13]&&0===t[14]&&1===t[15];module.exports=isIdentity;
},{}],145:[function(require,module,exports){
const isMirroring=r=>{const i=r[4]*r[9]-r[8]*r[5],o=r[8]*r[1]-r[0]*r[9],n=r[0]*r[5]-r[4]*r[1];return i*r[2]+o*r[6]+n*r[10]<0};module.exports=isMirroring;
},{}],146:[function(require,module,exports){
const isOnlyTransformScale=s=>isZero(s[1])&&isZero(s[2])&&isZero(s[3])&&isZero(s[4])&&isZero(s[6])&&isZero(s[7])&&isZero(s[8])&&isZero(s[9])&&isZero(s[11])&&1===s[15],isZero=s=>Math.abs(s)<Number.EPSILON;module.exports=isOnlyTransformScale;
},{}],147:[function(require,module,exports){
const mirrorByPlane=(r,o)=>{const[e,n,t,l]=o;return r[0]=1-2*e*e,r[1]=-2*n*e,r[2]=-2*t*e,r[3]=0,r[4]=-2*e*n,r[5]=1-2*n*n,r[6]=-2*t*n,r[7]=0,r[8]=-2*e*t,r[9]=-2*n*t,r[10]=1-2*t*t,r[11]=0,r[12]=2*e*l,r[13]=2*n*l,r[14]=2*t*l,r[15]=1,r};module.exports=mirrorByPlane;
},{}],148:[function(require,module,exports){
const multiply=(t,l,e)=>{const o=l[0],u=l[1],m=l[2],n=l[3],p=l[4],r=l[5],s=l[6],c=l[7],i=l[8],y=l[9],d=l[10],x=l[11],a=l[12],b=l[13],f=l[14],g=l[15];let h=e[0],j=e[1],k=e[2],q=e[3];return t[0]=h*o+j*p+k*i+q*a,t[1]=h*u+j*r+k*y+q*b,t[2]=h*m+j*s+k*d+q*f,t[3]=h*n+j*c+k*x+q*g,h=e[4],j=e[5],k=e[6],q=e[7],t[4]=h*o+j*p+k*i+q*a,t[5]=h*u+j*r+k*y+q*b,t[6]=h*m+j*s+k*d+q*f,t[7]=h*n+j*c+k*x+q*g,h=e[8],j=e[9],k=e[10],q=e[11],t[8]=h*o+j*p+k*i+q*a,t[9]=h*u+j*r+k*y+q*b,t[10]=h*m+j*s+k*d+q*f,t[11]=h*n+j*c+k*x+q*g,h=e[12],j=e[13],k=e[14],q=e[15],t[12]=h*o+j*p+k*i+q*a,t[13]=h*u+j*r+k*y+q*b,t[14]=h*m+j*s+k*d+q*f,t[15]=h*n+j*c+k*x+q*g,t};module.exports=multiply;
},{}],149:[function(require,module,exports){
const{EPS:EPS}=require("../constants"),{sin:sin,cos:cos}=require("../utils/trigonometry"),copy=require("./copy"),rotate=(t,o,r,s)=>{let[e,n,c]=s;const i=e*e+n*n+c*c;if(Math.abs(i)<EPS)return copy(t,o);const u=1/Math.sqrt(i);e*=u,n*=u,c*=u;const a=sin(r),p=cos(r),q=1-p,y=o[0],l=o[1],E=o[2],P=o[3],S=o[4],h=o[5],m=o[6],M=o[7],b=o[8],d=o[9],f=o[10],g=o[11],x=e*e*q+p,j=n*e*q+c*a,k=c*e*q-n*a,v=e*n*q-c*a,w=n*n*q+p,z=c*n*q+e*a,A=e*c*q+n*a,B=n*c*q-e*a,C=c*c*q+p;return t[0]=y*x+S*j+b*k,t[1]=l*x+h*j+d*k,t[2]=E*x+m*j+f*k,t[3]=P*x+M*j+g*k,t[4]=y*v+S*w+b*z,t[5]=l*v+h*w+d*z,t[6]=E*v+m*w+f*z,t[7]=P*v+M*w+g*z,t[8]=y*A+S*B+b*C,t[9]=l*A+h*B+d*C,t[10]=E*A+m*B+f*C,t[11]=P*A+M*B+g*C,o!==t&&(t[12]=o[12],t[13]=o[13],t[14]=o[14],t[15]=o[15]),t};module.exports=rotate;
},{"../constants":93,"../utils/trigonometry":172,"./copy":129}],150:[function(require,module,exports){
const{sin:sin,cos:cos}=require("../utils/trigonometry"),rotateX=(o,t,s)=>{const r=sin(s),e=cos(s),n=t[4],i=t[5],c=t[6],u=t[7],a=t[8],l=t[9],m=t[10],X=t[11];return t!==o&&(o[0]=t[0],o[1]=t[1],o[2]=t[2],o[3]=t[3],o[12]=t[12],o[13]=t[13],o[14]=t[14],o[15]=t[15]),o[4]=n*e+a*r,o[5]=i*e+l*r,o[6]=c*e+m*r,o[7]=u*e+X*r,o[8]=a*e-n*r,o[9]=l*e-i*r,o[10]=m*e-c*r,o[11]=X*e-u*r,o};module.exports=rotateX;
},{"../utils/trigonometry":172}],151:[function(require,module,exports){
const{sin:sin,cos:cos}=require("../utils/trigonometry"),rotateY=(o,t,s)=>{const r=sin(s),e=cos(s),n=t[0],i=t[1],c=t[2],u=t[3],a=t[8],l=t[9],m=t[10],Y=t[11];return t!==o&&(o[4]=t[4],o[5]=t[5],o[6]=t[6],o[7]=t[7],o[12]=t[12],o[13]=t[13],o[14]=t[14],o[15]=t[15]),o[0]=n*e-a*r,o[1]=i*e-l*r,o[2]=c*e-m*r,o[3]=u*e-Y*r,o[8]=n*r+a*e,o[9]=i*r+l*e,o[10]=c*r+m*e,o[11]=u*r+Y*e,o};module.exports=rotateY;
},{"../utils/trigonometry":172}],152:[function(require,module,exports){
const{sin:sin,cos:cos}=require("../utils/trigonometry"),rotateZ=(o,t,s)=>{const r=sin(s),e=cos(s),n=t[0],i=t[1],c=t[2],u=t[3],a=t[4],l=t[5],m=t[6],Z=t[7];return t!==o&&(o[8]=t[8],o[9]=t[9],o[10]=t[10],o[11]=t[11],o[12]=t[12],o[13]=t[13],o[14]=t[14],o[15]=t[15]),o[0]=n*e+a*r,o[1]=i*e+l*r,o[2]=c*e+m*r,o[3]=u*e+Z*r,o[4]=a*e-n*r,o[5]=l*e-i*r,o[6]=m*e-c*r,o[7]=Z*e-u*r,o};module.exports=rotateZ;
},{"../utils/trigonometry":172}],153:[function(require,module,exports){
const scale=(e,s,c)=>{const o=c[0],t=c[1],l=c[2];return e[0]=s[0]*o,e[1]=s[1]*o,e[2]=s[2]*o,e[3]=s[3]*o,e[4]=s[4]*t,e[5]=s[5]*t,e[6]=s[6]*t,e[7]=s[7]*t,e[8]=s[8]*l,e[9]=s[9]*l,e[10]=s[10]*l,e[11]=s[11]*l,e[12]=s[12],e[13]=s[13],e[14]=s[14],e[15]=s[15],e};module.exports=scale;
},{}],154:[function(require,module,exports){
const subtract=(t,s,c)=>(t[0]=s[0]-c[0],t[1]=s[1]-c[1],t[2]=s[2]-c[2],t[3]=s[3]-c[3],t[4]=s[4]-c[4],t[5]=s[5]-c[5],t[6]=s[6]-c[6],t[7]=s[7]-c[7],t[8]=s[8]-c[8],t[9]=s[9]-c[9],t[10]=s[10]-c[10],t[11]=s[11]-c[11],t[12]=s[12]-c[12],t[13]=s[13]-c[13],t[14]=s[14]-c[14],t[15]=s[15]-c[15],t);module.exports=subtract;
},{}],155:[function(require,module,exports){
const toString=t=>t.map(t=>t.toFixed(7)).toString();module.exports=toString;
},{}],156:[function(require,module,exports){
const translate=(t,e,n)=>{const r=n[0],s=n[1],a=n[2];let l,o,c,u,d,m,p,x,b,f,g,h;return e===t?(t[12]=e[0]*r+e[4]*s+e[8]*a+e[12],t[13]=e[1]*r+e[5]*s+e[9]*a+e[13],t[14]=e[2]*r+e[6]*s+e[10]*a+e[14],t[15]=e[3]*r+e[7]*s+e[11]*a+e[15]):(l=e[0],o=e[1],c=e[2],u=e[3],d=e[4],m=e[5],p=e[6],x=e[7],b=e[8],f=e[9],g=e[10],h=e[11],t[0]=l,t[1]=o,t[2]=c,t[3]=u,t[4]=d,t[5]=m,t[6]=p,t[7]=x,t[8]=b,t[9]=f,t[10]=g,t[11]=h,t[12]=l*r+d*s+b*a+e[12],t[13]=o*r+m*s+f*a+e[13],t[14]=c*r+p*s+g*a+e[14],t[15]=u*r+x*s+h*a+e[15]),t};module.exports=translate;
},{}],157:[function(require,module,exports){
const flip=(l,o)=>(l[0]=-o[0],l[1]=-o[1],l[2]=-o[2],l[3]=-o[3],l);module.exports=flip;
},{}],158:[function(require,module,exports){
const vec3=require("../vec3"),fromNormalAndPoint=require("./fromNormalAndPoint"),fromNoisyPoints=(e,...c)=>{e[0]=0,e[1]=0,e[2]=0,e[3]=0;const o=c.length;c.forEach(c=>{vec3.add(e,e,c)}),vec3.scale(e,e,1/o);let t=0,r=0,a=0,v=0,d=0,n=0;const s=vec3.create();c.forEach(c=>{vec3.subtract(s,c,e),t+=s[0]*s[0],r+=s[0]*s[1],a+=s[0]*s[2],v+=s[1]*s[1],d+=s[1]*s[2],n+=s[2]*s[2]}),t/=o,r/=o,a/=o,v/=o,d/=o,n/=o,s[0]=0,s[1]=0,s[2]=0;const l=vec3.create();let i=v*n-d*d;l[0]=i,l[1]=a*d-r*n,l[2]=r*d-a*v;let m=i*i;return vec3.add(s,s,vec3.scale(l,l,m)),i=t*n-a*a,l[0]=a*d-r*n,l[1]=i,l[2]=r*a-d*t,m=i*i,vec3.dot(s,l)<0&&(m=-m),vec3.add(s,s,vec3.scale(l,l,m)),i=t*v-r*r,l[0]=r*d-a*v,l[1]=r*a-d*t,l[2]=i,m=i*i,vec3.dot(s,l)<0&&(m=-m),vec3.add(s,s,vec3.scale(l,l,m)),fromNormalAndPoint(e,s,e)};module.exports=fromNoisyPoints;
},{"../vec3":221,"./fromNormalAndPoint":159}],159:[function(require,module,exports){
const vec3=require("../vec3"),fromNormalAndPoint=(e,o,r)=>{const c=vec3.normalize(vec3.create(),o),n=vec3.dot(r,c);return e[0]=c[0],e[1]=c[1],e[2]=c[2],e[3]=n,e};module.exports=fromNormalAndPoint;
},{"../vec3":221}],160:[function(require,module,exports){
const vec3=require("../vec3"),fromPoints=(e,...c)=>{const r=c.length,t=vec3.create(),o=vec3.create(),v=e=>{const v=c[e],n=c[(e+1)%r],s=c[(e+2)%r];return vec3.subtract(t,n,v),vec3.subtract(o,s,v),vec3.cross(t,t,o),vec3.normalize(t,t),t};return e[0]=0,e[1]=0,e[2]=0,3===r?vec3.copy(e,v(0)):(c.forEach((c,r)=>{vec3.add(e,e,v(r))}),vec3.normalize(e,e)),e[3]=vec3.dot(e,c[0]),e};module.exports=fromPoints;
},{"../vec3":221}],161:[function(require,module,exports){
const{EPS:EPS}=require("../constants"),vec3=require("../vec3"),fromPointsRandom=(e,c,o,t)=>{let r=vec3.subtract(vec3.create(),o,c),v=vec3.subtract(vec3.create(),t,c);vec3.length(r)<EPS&&(r=vec3.orthogonal(r,v)),vec3.length(v)<EPS&&(v=vec3.orthogonal(v,r));let n=vec3.cross(vec3.create(),r,v);vec3.length(n)<EPS&&(v=vec3.orthogonal(v,r),n=vec3.cross(n,r,v)),n=vec3.normalize(n,n);const s=vec3.dot(n,c);return e[0]=n[0],e[1]=n[1],e[2]=n[2],e[3]=s,e};module.exports=fromPointsRandom;
},{"../constants":93,"../vec3":221}],162:[function(require,module,exports){
module.exports={clone:require("../vec4/clone"),copy:require("../vec4/copy"),create:require("../vec4/create"),equals:require("../vec4/equals"),flip:require("./flip"),fromNormalAndPoint:require("./fromNormalAndPoint"),fromValues:require("../vec4/fromValues"),fromNoisyPoints:require("./fromNoisyPoints"),fromPoints:require("./fromPoints"),fromPointsRandom:require("./fromPointsRandom"),projectionOfPoint:require("./projectionOfPoint"),signedDistanceToPoint:require("./signedDistanceToPoint"),toString:require("../vec4/toString"),transform:require("./transform")};
},{"../vec4/clone":240,"../vec4/copy":241,"../vec4/create":242,"../vec4/equals":244,"../vec4/fromValues":246,"../vec4/toString":248,"./flip":157,"./fromNoisyPoints":158,"./fromNormalAndPoint":159,"./fromPoints":160,"./fromPointsRandom":161,"./projectionOfPoint":163,"./signedDistanceToPoint":164,"./transform":165}],163:[function(require,module,exports){
const vec3=require("../vec3"),projectionOfPoint=(e,o)=>{const r=o[0]*e[0]+o[1]*e[1]+o[2]*e[2]-e[3],t=o[0]-r*e[0],c=o[1]-r*e[1],n=o[2]-r*e[2];return vec3.fromValues(t,c,n)};module.exports=projectionOfPoint;
},{"../vec3":221}],164:[function(require,module,exports){
const vec3=require("../vec3"),signedDistanceToPoint=(e,o)=>vec3.dot(e,o)-e[3];module.exports=signedDistanceToPoint;
},{"../vec3":221}],165:[function(require,module,exports){
const mat4=require("../mat4"),vec3=require("../vec3"),fromPoints=require("./fromPoints"),flip=require("./flip"),transform=(e,r,c)=>{const t=mat4.isMirroring(c),o=vec3.orthogonal(vec3.create(),r),a=vec3.cross(o,r,o),v=vec3.cross(vec3.create(),r,a);let s=vec3.fromScalar(vec3.create(),r[3]);vec3.multiply(s,s,r);let i=vec3.add(vec3.create(),s,a),m=vec3.add(vec3.create(),s,v);return s=vec3.transform(s,s,c),i=vec3.transform(i,i,c),m=vec3.transform(m,m,c),fromPoints(e,s,i,m),t&&flip(e,e),e};module.exports=transform;
},{"../mat4":142,"../vec3":221,"./flip":157,"./fromPoints":160}],166:[function(require,module,exports){
const{NEPS:NEPS}=require("../constants"),aboutEqualNormals=(a,s)=>Math.abs(a[0]-s[0])<=NEPS&&Math.abs(a[1]-s[1])<=NEPS&&Math.abs(a[2]-s[2])<=NEPS;module.exports=aboutEqualNormals;
},{"../constants":93}],167:[function(require,module,exports){
const area=e=>{let t=0;for(let r=0;r<e.length;r++){const l=(r+1)%e.length;t+=e[r][0]*e[l][1],t-=e[l][0]*e[r][1]}return t/2};module.exports=area;
},{}],168:[function(require,module,exports){
module.exports={aboutEqualNormals:require("./aboutEqualNormals"),area:require("./area"),cos:require("./trigonometry").cos,interpolateBetween2DPointsForY:require("./interpolateBetween2DPointsForY"),intersect:require("./intersect"),sin:require("./trigonometry").sin,solve2Linear:require("./solve2Linear")};
},{"./aboutEqualNormals":166,"./area":167,"./interpolateBetween2DPointsForY":169,"./intersect":170,"./solve2Linear":171,"./trigonometry":172}],169:[function(require,module,exports){
const interpolateBetween2DPointsForY=(e,t,o)=>{let n,r=o-e[1],i=t[1]-e[1];return i<0&&(r=-r,i=-i),n=r<=0?0:r>=i?1:i<1e-10?.5:r/i,e[0]+n*(t[0]-e[0])};module.exports=interpolateBetween2DPointsForY;
},{}],170:[function(require,module,exports){
const intersect=(t,e,r,n)=>{if(t[0]===e[0]&&t[1]===e[1]||r[0]===n[0]&&r[1]===n[1])return;const s=(n[1]-r[1])*(e[0]-t[0])-(n[0]-r[0])*(e[1]-t[1]);if(Math.abs(s)<Number.MIN_VALUE)return;const o=((n[0]-r[0])*(t[1]-r[1])-(n[1]-r[1])*(t[0]-r[0]))/s,c=((e[0]-t[0])*(t[1]-r[1])-(e[1]-t[1])*(t[0]-r[0]))/s;return o<0||o>1||c<0||c>1?void 0:[t[0]+o*(e[0]-t[0]),t[1]+o*(e[1]-t[1])]};module.exports=intersect;
},{}],171:[function(require,module,exports){
const solve2Linear=(e,o,n,r,s,t)=>{const l=1/(e*r-o*n);let a=s*r-o*t,c=-s*n+e*t;return[a*=l,c*=l]};module.exports=solve2Linear;
},{}],172:[function(require,module,exports){
const{NEPS:NEPS}=require("../constants"),rezero=s=>Math.abs(s)<NEPS?0:s,sin=s=>rezero(Math.sin(s)),cos=s=>rezero(Math.cos(s));module.exports={sin:sin,cos:cos};
},{"../constants":93}],173:[function(require,module,exports){
const abs=(a,s)=>(a[0]=Math.abs(s[0]),a[1]=Math.abs(s[1]),a);module.exports=abs;
},{}],174:[function(require,module,exports){
const add=(d,o,a)=>(d[0]=o[0]+a[0],d[1]=o[1]+a[1],d);module.exports=add;
},{}],175:[function(require,module,exports){
module.exports=require("./angleRadians");
},{"./angleRadians":177}],176:[function(require,module,exports){
const angleRadians=require("./angleRadians"),angleDegrees=e=>57.29577951308232*angleRadians(e);module.exports=angleDegrees;
},{"./angleRadians":177}],177:[function(require,module,exports){
const angleRadians=a=>Math.atan2(a[1],a[0]);module.exports=angleRadians;
},{}],178:[function(require,module,exports){
const create=require("./create"),clone=e=>{const r=create();return r[0]=e[0],r[1]=e[1],r};module.exports=clone;
},{"./create":180}],179:[function(require,module,exports){
const copy=(o,c)=>(o[0]=c[0],o[1]=c[1],o);module.exports=copy;
},{}],180:[function(require,module,exports){
const create=()=>[0,0];module.exports=create;
},{}],181:[function(require,module,exports){
const cross=(s,o,c)=>(s[0]=0,s[1]=0,s[2]=o[0]*c[1]-o[1]*c[0],s);module.exports=cross;
},{}],182:[function(require,module,exports){
const distance=(t,s)=>{const e=s[0]-t[0],n=s[1]-t[1];return Math.sqrt(e*e+n*n)};module.exports=distance;
},{}],183:[function(require,module,exports){
const divide=(d,e,i)=>(d[0]=e[0]/i[0],d[1]=e[1]/i[1],d);module.exports=divide;
},{}],184:[function(require,module,exports){
const dot=(o,t)=>o[0]*t[0]+o[1]*t[1];module.exports=dot;
},{}],185:[function(require,module,exports){
const equals=(e,s)=>e[0]===s[0]&&e[1]===s[1];module.exports=equals;
},{}],186:[function(require,module,exports){
const fromAngleRadians=require("./fromAngleRadians"),fromAngleDegrees=(e,r)=>fromAngleRadians(e,.017453292519943295*r);module.exports=fromAngleDegrees;
},{"./fromAngleRadians":187}],187:[function(require,module,exports){
const{sin:sin,cos:cos}=require("../utils/trigonometry"),fromAngleRadians=(s,o)=>(s[0]=cos(o),s[1]=sin(o),s);module.exports=fromAngleRadians;
},{"../utils/trigonometry":172}],188:[function(require,module,exports){
const fromScalar=(o,r)=>(o[0]=r,o[1]=r,o);module.exports=fromScalar;
},{}],189:[function(require,module,exports){
const create=require("./create"),fromValues=(e,r)=>{const t=create();return t[0]=e,t[1]=r,t};module.exports=fromValues;
},{"./create":180}],190:[function(require,module,exports){
module.exports={abs:require("./abs"),add:require("./add"),angle:require("./angle"),angleDegrees:require("./angleDegrees"),angleRadians:require("./angleRadians"),clone:require("./clone"),copy:require("./copy"),create:require("./create"),cross:require("./cross"),distance:require("./distance"),divide:require("./divide"),dot:require("./dot"),equals:require("./equals"),fromAngleDegrees:require("./fromAngleDegrees"),fromAngleRadians:require("./fromAngleRadians"),fromScalar:require("./fromScalar"),fromValues:require("./fromValues"),length:require("./length"),lerp:require("./lerp"),max:require("./max"),min:require("./min"),multiply:require("./multiply"),negate:require("./negate"),normal:require("./normal"),normalize:require("./normalize"),rotate:require("./rotate"),scale:require("./scale"),snap:require("./snap"),squaredDistance:require("./squaredDistance"),squaredLength:require("./squaredLength"),subtract:require("./subtract"),toString:require("./toString"),transform:require("./transform")};
},{"./abs":173,"./add":174,"./angle":175,"./angleDegrees":176,"./angleRadians":177,"./clone":178,"./copy":179,"./create":180,"./cross":181,"./distance":182,"./divide":183,"./dot":184,"./equals":185,"./fromAngleDegrees":186,"./fromAngleRadians":187,"./fromScalar":188,"./fromValues":189,"./length":191,"./lerp":192,"./max":193,"./min":194,"./multiply":195,"./negate":196,"./normal":197,"./normalize":198,"./rotate":199,"./scale":200,"./snap":201,"./squaredDistance":202,"./squaredLength":203,"./subtract":204,"./toString":205,"./transform":206}],191:[function(require,module,exports){
const length=t=>Math.sqrt(t[0]*t[0]+t[1]*t[1]);module.exports=length;
},{}],192:[function(require,module,exports){
const lerp=(e,r,o,t)=>{const l=r[0],n=r[1];return e[0]=l+t*(o[0]-l),e[1]=n+t*(o[1]-n),e};module.exports=lerp;
},{}],193:[function(require,module,exports){
const max=(a,m,x)=>(a[0]=Math.max(m[0],x[0]),a[1]=Math.max(m[1],x[1]),a);module.exports=max;
},{}],194:[function(require,module,exports){
const min=(m,n,i)=>(m[0]=Math.min(n[0],i[0]),m[1]=Math.min(n[1],i[1]),m);module.exports=min;
},{}],195:[function(require,module,exports){
const multiply=(l,t,m)=>(l[0]=t[0]*m[0],l[1]=t[1]*m[1],l);module.exports=multiply;
},{}],196:[function(require,module,exports){
const negate=(e,t)=>(e[0]=-t[0],e[1]=-t[1],e);module.exports=negate;
},{}],197:[function(require,module,exports){
const{TAU:TAU}=require("../constants"),create=require("./create"),rotate=require("./rotate"),normal=(e,r)=>rotate(e,r,create(),TAU/4);module.exports=normal;
},{"../constants":93,"./create":180,"./rotate":199}],198:[function(require,module,exports){
const normalize=(t,e)=>{const o=e[0],r=e[1];let n=o*o+r*r;return n>0&&(n=1/Math.sqrt(n)),t[0]=o*n,t[1]=r*n,t};module.exports=normalize;
},{}],199:[function(require,module,exports){
const rotate=(t,o,e,r)=>{const s=o[0]-e[0],a=o[1]-e[1],n=Math.cos(r),c=Math.sin(r);return t[0]=s*n-a*c+e[0],t[1]=s*c+a*n+e[1],t};module.exports=rotate;
},{}],200:[function(require,module,exports){
const scale=(e,s,c)=>(e[0]=s[0]*c,e[1]=s[1]*c,e);module.exports=scale;
},{}],201:[function(require,module,exports){
const snap=(n,o,a)=>(n[0]=Math.round(o[0]/a)*a+0,n[1]=Math.round(o[1]/a)*a+0,n);module.exports=snap;
},{}],202:[function(require,module,exports){
const squaredDistance=(e,s)=>{const t=s[0]-e[0],n=s[1]-e[1];return t*t+n*n};module.exports=squaredDistance;
},{}],203:[function(require,module,exports){
const squaredLength=e=>{const t=e[0],n=e[1];return t*t+n*n};module.exports=squaredLength;
},{}],204:[function(require,module,exports){
const subtract=(t,s,c)=>(t[0]=s[0]-c[0],t[1]=s[1]-c[1],t);module.exports=subtract;
},{}],205:[function(require,module,exports){
const toString=t=>`[${t[0].toFixed(7)}, ${t[1].toFixed(7)}]`;module.exports=toString;
},{}],206:[function(require,module,exports){
const transform=(r,o,t)=>{const n=o[0],s=o[1];return r[0]=t[0]*n+t[4]*s+t[12],r[1]=t[1]*n+t[5]*s+t[13],r};module.exports=transform;
},{}],207:[function(require,module,exports){
const abs=(a,s)=>(a[0]=Math.abs(s[0]),a[1]=Math.abs(s[1]),a[2]=Math.abs(s[2]),a);module.exports=abs;
},{}],208:[function(require,module,exports){
const add=(d,o,a)=>(d[0]=o[0]+a[0],d[1]=o[1]+a[1],d[2]=o[2]+a[2],d);module.exports=add;
},{}],209:[function(require,module,exports){
const dot=require("./dot"),angle=(t,a)=>{const o=t[0],e=t[1],r=t[2],n=a[0],s=a[1],h=a[2],M=Math.sqrt(o*o+e*e+r*r)*Math.sqrt(n*n+s*s+h*h),d=M&&dot(t,a)/M;return Math.acos(Math.min(Math.max(d,-1),1))};module.exports=angle;
},{"./dot":216}],210:[function(require,module,exports){
const create=require("./create"),clone=e=>{const r=create();return r[0]=e[0],r[1]=e[1],r[2]=e[2],r};module.exports=clone;
},{"./create":212}],211:[function(require,module,exports){
const copy=(o,c)=>(o[0]=c[0],o[1]=c[1],o[2]=c[2],o);module.exports=copy;
},{}],212:[function(require,module,exports){
const create=()=>[0,0,0];module.exports=create;
},{}],213:[function(require,module,exports){
const cross=(s,o,r)=>{const c=o[0],t=o[1],e=o[2],n=r[0],u=r[1],d=r[2];return s[0]=t*d-e*u,s[1]=e*n-c*d,s[2]=c*u-t*n,s};module.exports=cross;
},{}],214:[function(require,module,exports){
const distance=(t,s)=>{const e=s[0]-t[0],n=s[1]-t[1],c=s[2]-t[2];return Math.sqrt(e*e+n*n+c*c)};module.exports=distance;
},{}],215:[function(require,module,exports){
const divide=(d,e,i)=>(d[0]=e[0]/i[0],d[1]=e[1]/i[1],d[2]=e[2]/i[2],d);module.exports=divide;
},{}],216:[function(require,module,exports){
const dot=(o,t)=>o[0]*t[0]+o[1]*t[1]+o[2]*t[2];module.exports=dot;
},{}],217:[function(require,module,exports){
const equals=(e,s)=>e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2];module.exports=equals;
},{}],218:[function(require,module,exports){
const fromScalar=(o,r)=>(o[0]=r,o[1]=r,o[2]=r,o);module.exports=fromScalar;
},{}],219:[function(require,module,exports){
const create=require("./create"),fromValues=(e,r,t)=>{const o=create();return o[0]=e,o[1]=r,o[2]=t,o};module.exports=fromValues;
},{"./create":212}],220:[function(require,module,exports){
const fromVector2=(o,r,e=0)=>(o[0]=r[0],o[1]=r[1],o[2]=e,o);module.exports=fromVector2;
},{}],221:[function(require,module,exports){
module.exports={abs:require("./abs"),add:require("./add"),angle:require("./angle"),clone:require("./clone"),copy:require("./copy"),create:require("./create"),cross:require("./cross"),distance:require("./distance"),divide:require("./divide"),dot:require("./dot"),equals:require("./equals"),fromScalar:require("./fromScalar"),fromValues:require("./fromValues"),fromVec2:require("./fromVec2"),length:require("./length"),lerp:require("./lerp"),max:require("./max"),min:require("./min"),multiply:require("./multiply"),negate:require("./negate"),normalize:require("./normalize"),orthogonal:require("./orthogonal"),rotateX:require("./rotateX"),rotateY:require("./rotateY"),rotateZ:require("./rotateZ"),scale:require("./scale"),snap:require("./snap"),squaredDistance:require("./squaredDistance"),squaredLength:require("./squaredLength"),subtract:require("./subtract"),toString:require("./toString"),transform:require("./transform")};
},{"./abs":207,"./add":208,"./angle":209,"./clone":210,"./copy":211,"./create":212,"./cross":213,"./distance":214,"./divide":215,"./dot":216,"./equals":217,"./fromScalar":218,"./fromValues":219,"./fromVec2":220,"./length":222,"./lerp":223,"./max":224,"./min":225,"./multiply":226,"./negate":227,"./normalize":228,"./orthogonal":229,"./rotateX":230,"./rotateY":231,"./rotateZ":232,"./scale":233,"./snap":234,"./squaredDistance":235,"./squaredLength":236,"./subtract":237,"./toString":238,"./transform":239}],222:[function(require,module,exports){
const length=t=>{const e=t[0],n=t[1],o=t[2];return Math.sqrt(e*e+n*n+o*o)};module.exports=length;
},{}],223:[function(require,module,exports){
const lerp=(e,l,o,p)=>(e[0]=l[0]+p*(o[0]-l[0]),e[1]=l[1]+p*(o[1]-l[1]),e[2]=l[2]+p*(o[2]-l[2]),e);module.exports=lerp;
},{}],224:[function(require,module,exports){
const max=(a,m,x)=>(a[0]=Math.max(m[0],x[0]),a[1]=Math.max(m[1],x[1]),a[2]=Math.max(m[2],x[2]),a);module.exports=max;
},{}],225:[function(require,module,exports){
const min=(m,n,i)=>(m[0]=Math.min(n[0],i[0]),m[1]=Math.min(n[1],i[1]),m[2]=Math.min(n[2],i[2]),m);module.exports=min;
},{}],226:[function(require,module,exports){
const multiply=(l,t,m)=>(l[0]=t[0]*m[0],l[1]=t[1]*m[1],l[2]=t[2]*m[2],l);module.exports=multiply;
},{}],227:[function(require,module,exports){
const negate=(e,t)=>(e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e);module.exports=negate;
},{}],228:[function(require,module,exports){
const normalize=(t,e)=>{const o=e[0],r=e[1],n=e[2];let l=o*o+r*r+n*n;return l>0&&(l=1/Math.sqrt(l)),t[0]=o*l,t[1]=r*l,t[2]=n*l,t};module.exports=normalize;
},{}],229:[function(require,module,exports){
const abs=require("./abs"),create=require("./create"),cross=require("./cross"),orthogonal=(r,e)=>{const o=abs(create(),e),s=0+(o[0]<o[1]&&o[0]<o[2]),t=0+(o[1]<=o[0]&&o[1]<o[2]),a=0+(o[2]<=o[0]&&o[2]<=o[1]);return cross(r,e,[s,t,a])};module.exports=orthogonal;
},{"./abs":207,"./create":212,"./cross":213}],230:[function(require,module,exports){
const rotateX=(t,o,s,a)=>{const e=[],n=[];return e[0]=o[0]-s[0],e[1]=o[1]-s[1],e[2]=o[2]-s[2],n[0]=e[0],n[1]=e[1]*Math.cos(a)-e[2]*Math.sin(a),n[2]=e[1]*Math.sin(a)+e[2]*Math.cos(a),t[0]=n[0]+s[0],t[1]=n[1]+s[1],t[2]=n[2]+s[2],t};module.exports=rotateX;
},{}],231:[function(require,module,exports){
const rotateY=(t,o,s,a)=>{const e=[],n=[];return e[0]=o[0]-s[0],e[1]=o[1]-s[1],e[2]=o[2]-s[2],n[0]=e[2]*Math.sin(a)+e[0]*Math.cos(a),n[1]=e[1],n[2]=e[2]*Math.cos(a)-e[0]*Math.sin(a),t[0]=n[0]+s[0],t[1]=n[1]+s[1],t[2]=n[2]+s[2],t};module.exports=rotateY;
},{}],232:[function(require,module,exports){
const rotateZ=(t,o,s,a)=>{const e=[],n=[];return e[0]=o[0]-s[0],e[1]=o[1]-s[1],n[0]=e[0]*Math.cos(a)-e[1]*Math.sin(a),n[1]=e[0]*Math.sin(a)+e[1]*Math.cos(a),t[0]=n[0]+s[0],t[1]=n[1]+s[1],t[2]=o[2],t};module.exports=rotateZ;
},{}],233:[function(require,module,exports){
const scale=(e,s,c)=>(e[0]=s[0]*c,e[1]=s[1]*c,e[2]=s[2]*c,e);module.exports=scale;
},{}],234:[function(require,module,exports){
const snap=(n,o,a)=>(n[0]=Math.round(o[0]/a)*a+0,n[1]=Math.round(o[1]/a)*a+0,n[2]=Math.round(o[2]/a)*a+0,n);module.exports=snap;
},{}],235:[function(require,module,exports){
const squaredDistance=(e,s)=>{const t=s[0]-e[0],n=s[1]-e[1],r=s[2]-e[2];return t*t+n*n+r*r};module.exports=squaredDistance;
},{}],236:[function(require,module,exports){
const squaredLength=e=>{const t=e[0],n=e[1],r=e[2];return t*t+n*n+r*r};module.exports=squaredLength;
},{}],237:[function(require,module,exports){
const subtract=(t,s,c)=>(t[0]=s[0]-c[0],t[1]=s[1]-c[1],t[2]=s[2]-c[2],t);module.exports=subtract;
},{}],238:[function(require,module,exports){
const toString=t=>`[${t[0].toFixed(7)}, ${t[1].toFixed(7)}, ${t[2].toFixed(7)}]`;module.exports=toString;
},{}],239:[function(require,module,exports){
const transform=(r,t,o)=>{const n=t[0],s=t[1],e=t[2];let m=o[3]*n+o[7]*s+o[11]*e+o[15];return m=m||1,r[0]=(o[0]*n+o[4]*s+o[8]*e+o[12])/m,r[1]=(o[1]*n+o[5]*s+o[9]*e+o[13])/m,r[2]=(o[2]*n+o[6]*s+o[10]*e+o[14])/m,r};module.exports=transform;
},{}],240:[function(require,module,exports){
const create=require("./create"),clone=e=>{const r=create();return r[0]=e[0],r[1]=e[1],r[2]=e[2],r[3]=e[3],r};module.exports=clone;
},{"./create":242}],241:[function(require,module,exports){
const copy=(o,c)=>(o[0]=c[0],o[1]=c[1],o[2]=c[2],o[3]=c[3],o);module.exports=copy;
},{}],242:[function(require,module,exports){
const create=()=>[0,0,0,0];module.exports=create;
},{}],243:[function(require,module,exports){
const dot=(o,t)=>o[0]*t[0]+o[1]*t[1]+o[2]*t[2]+o[3]*t[3];module.exports=dot;
},{}],244:[function(require,module,exports){
const equals=(e,s)=>e[0]===s[0]&&e[1]===s[1]&&e[2]===s[2]&&e[3]===s[3];module.exports=equals;
},{}],245:[function(require,module,exports){
const fromScalar=(o,r)=>(o[0]=r,o[1]=r,o[2]=r,o[3]=r,o);module.exports=fromScalar;
},{}],246:[function(require,module,exports){
const create=require("./create"),fromValues=(e,r,t,o)=>{const a=create();return a[0]=e,a[1]=r,a[2]=t,a[3]=o,a};module.exports=fromValues;
},{"./create":242}],247:[function(require,module,exports){
module.exports={clone:require("./clone"),copy:require("./copy"),create:require("./create"),dot:require("./dot"),equals:require("./equals"),fromScalar:require("./fromScalar"),fromValues:require("./fromValues"),toString:require("./toString"),transform:require("./transform")};
},{"./clone":240,"./copy":241,"./create":242,"./dot":243,"./equals":244,"./fromScalar":245,"./fromValues":246,"./toString":248,"./transform":249}],248:[function(require,module,exports){
const toString=t=>`(${t[0].toFixed(9)}, ${t[1].toFixed(9)}, ${t[2].toFixed(9)}, ${t[3].toFixed(9)})`;module.exports=toString;
},{}],249:[function(require,module,exports){
const transform=(r,o,t)=>{const[n,s,e,m]=o;return r[0]=t[0]*n+t[4]*s+t[8]*e+t[12]*m,r[1]=t[1]*n+t[5]*s+t[9]*e+t[13]*m,r[2]=t[2]*n+t[6]*s+t[10]*e+t[14]*m,r[3]=t[3]*n+t[7]*s+t[11]*e+t[15]*m,r};module.exports=transform;
},{}],250:[function(require,module,exports){
const{EPS:EPS}=require("../maths/constants"),calculateEpsilonFromBounds=(o,t)=>{let e=0;for(let l=0;l<t;l++)e+=o[1][l]-o[0][l];return EPS*e/t};module.exports=calculateEpsilonFromBounds;
},{"../maths/constants":93}],251:[function(require,module,exports){
module.exports={measureAggregateArea:require("./measureAggregateArea"),measureAggregateBoundingBox:require("./measureAggregateBoundingBox"),measureAggregateEpsilon:require("./measureAggregateEpsilon"),measureAggregateVolume:require("./measureAggregateVolume"),measureArea:require("./measureArea"),measureBoundingBox:require("./measureBoundingBox"),measureBoundingSphere:require("./measureBoundingSphere"),measureCenter:require("./measureCenter"),measureCenterOfMass:require("./measureCenterOfMass"),measureDimensions:require("./measureDimensions"),measureEpsilon:require("./measureEpsilon"),measureVolume:require("./measureVolume")};
},{"./measureAggregateArea":252,"./measureAggregateBoundingBox":253,"./measureAggregateEpsilon":254,"./measureAggregateVolume":255,"./measureArea":256,"./measureBoundingBox":257,"./measureBoundingSphere":258,"./measureCenter":259,"./measureCenterOfMass":260,"./measureDimensions":261,"./measureEpsilon":262,"./measureVolume":263}],252:[function(require,module,exports){
const flatten=require("../utils/flatten"),measureArea=require("./measureArea"),measureAggregateArea=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateArea: no geometries supplied");const r=measureArea(e);if(1===e.length)return r;return r.reduce((e,r)=>e+r,0)};module.exports=measureAggregateArea;
},{"../utils/flatten":396,"./measureArea":256}],253:[function(require,module,exports){
const flatten=require("../utils/flatten"),vec3min=require("../maths/vec3/min"),vec3max=require("../maths/vec3/max"),measureBoundingBox=require("./measureBoundingBox"),measureAggregateBoundingBox=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateBoundingBox: no geometries supplied");const r=measureBoundingBox(e);if(1===e.length)return r;const u=[[Number.MAX_VALUE,Number.MAX_VALUE,Number.MAX_VALUE],[-Number.MAX_VALUE,-Number.MAX_VALUE,-Number.MAX_VALUE]];return r.reduce((e,r)=>e=[vec3min(e[0],e[0],r[0]),vec3max(e[1],e[1],r[1])],u)};module.exports=measureAggregateBoundingBox;
},{"../maths/vec3/max":224,"../maths/vec3/min":225,"../utils/flatten":396,"./measureBoundingBox":257}],254:[function(require,module,exports){
const flatten=require("../utils/flatten"),measureAggregateBoundingBox=require("./measureAggregateBoundingBox"),calculateEpsilonFromBounds=require("./calculateEpsilonFromBounds"),{geom2:geom2,geom3:geom3,path2:path2}=require("../geometries"),measureAggregateEpsilon=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateEpsilon: no geometries supplied");const o=measureAggregateBoundingBox(e);let r=0;return r=e.reduce((e,o)=>path2.isA(o)||geom2.isA(o)?Math.max(e,2):geom3.isA(o)?Math.max(e,3):0,r),calculateEpsilonFromBounds(o,r)};module.exports=measureAggregateEpsilon;
},{"../geometries":49,"../utils/flatten":396,"./calculateEpsilonFromBounds":250,"./measureAggregateBoundingBox":253}],255:[function(require,module,exports){
const flatten=require("../utils/flatten"),measureVolume=require("./measureVolume"),measureAggregateVolume=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("measureAggregateVolume: no geometries supplied");const r=measureVolume(e);if(1===e.length)return r;return r.reduce((e,r)=>e+r,0)};module.exports=measureAggregateVolume;
},{"../utils/flatten":396,"./measureVolume":263}],256:[function(require,module,exports){
const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureAreaOfPath2=()=>0,measureAreaOfGeom2=e=>{let r=cache.get(e);if(r)return r;return r=geom2.toSides(e).reduce((e,r)=>e+(r[0][0]*r[1][1]-r[0][1]*r[1][0]),0),r*=.5,cache.set(e,r),r},measureAreaOfGeom3=e=>{let r=cache.get(e);if(r)return r;return r=geom3.toPolygons(e).reduce((e,r)=>e+poly3.measureArea(r),0),cache.set(e,r),r},measureArea=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const r=e.map(e=>path2.isA(e)?0:geom2.isA(e)?measureAreaOfGeom2(e):geom3.isA(e)?measureAreaOfGeom3(e):0);return 1===r.length?r[0]:r};module.exports=measureArea;
},{"../geometries/geom2":25,"../geometries/geom3":40,"../geometries/path2":61,"../geometries/poly3":78,"../utils/flatten":396}],257:[function(require,module,exports){
const flatten=require("../utils/flatten"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureBoundingBoxOfPath2=e=>{let o=cache.get(e);if(o)return o;const t=path2.toPoints(e);let n;n=0===t.length?vec2.create():vec2.clone(t[0]);let r=vec2.clone(n);return t.forEach(e=>{vec2.min(n,n,e),vec2.max(r,r,e)}),n=[n[0],n[1],0],r=[r[0],r[1],0],o=[n,r],cache.set(e,o),o},measureBoundingBoxOfGeom2=e=>{let o=cache.get(e);if(o)return o;const t=geom2.toPoints(e);let n;n=0===t.length?vec2.create():vec2.clone(t[0]);let r=vec2.clone(n);return t.forEach(e=>{vec2.min(n,n,e),vec2.max(r,r,e)}),n=[n[0],n[1],0],r=[r[0],r[1],0],o=[n,r],cache.set(e,o),o},measureBoundingBoxOfGeom3=e=>{let o=cache.get(e);if(o)return o;const t=geom3.toPolygons(e);let n=vec3.create();if(t.length>0){const e=poly3.toPoints(t[0]);vec3.copy(n,e[0])}let r=vec3.clone(n);return t.forEach(e=>{poly3.toPoints(e).forEach(e=>{vec3.min(n,n,e),vec3.max(r,r,e)})}),n=[n[0],n[1],n[2]],r=[r[0],r[1],r[2]],o=[n,r],cache.set(e,o),o},measureBoundingBox=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const o=e.map(e=>path2.isA(e)?measureBoundingBoxOfPath2(e):geom2.isA(e)?measureBoundingBoxOfGeom2(e):geom3.isA(e)?measureBoundingBoxOfGeom3(e):[[0,0,0],[0,0,0]]);return 1===o.length?o[0]:o};module.exports=measureBoundingBox;
},{"../geometries/geom2":25,"../geometries/geom3":40,"../geometries/path2":61,"../geometries/poly3":78,"../maths/vec2":190,"../maths/vec3":221,"../utils/flatten":396}],258:[function(require,module,exports){
const flatten=require("../utils/flatten"),vec2=require("../maths/vec2"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cacheOfBoundingSpheres=new WeakMap,measureBoundingSphereOfPath2=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=path2.toPoints(e);if(c.length>0){let e=0;const t=vec3.create();c.forEach(o=>{vec3.add(r,r,vec3.fromVec2(t,o,0)),e++}),vec3.scale(r,r,1/e),c.forEach(e=>{o=Math.max(o,vec2.squaredDistance(r,e))}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphereOfGeom2=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=geom2.toSides(e);if(c.length>0){let e=0;const t=vec3.create();c.forEach(o=>{vec3.add(r,r,vec3.fromVec2(t,o[0],0)),e++}),vec3.scale(r,r,1/e),c.forEach(e=>{o=Math.max(o,vec2.squaredDistance(r,e[0]))}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphereOfGeom3=e=>{let t=cacheOfBoundingSpheres.get(e);if(void 0!==t)return t;const r=vec3.create();let o=0;const c=geom3.toPolygons(e);if(c.length>0){let e=0;c.forEach(t=>{poly3.toPoints(t).forEach(t=>{vec3.add(r,r,t),e++})}),vec3.scale(r,r,1/e),c.forEach(e=>{poly3.toPoints(e).forEach(e=>{o=Math.max(o,vec3.squaredDistance(r,e))})}),o=Math.sqrt(o)}return t=[r,o],cacheOfBoundingSpheres.set(e,t),t},measureBoundingSphere=(...e)=>{const t=(e=flatten(e)).map(e=>path2.isA(e)?measureBoundingSphereOfPath2(e):geom2.isA(e)?measureBoundingSphereOfGeom2(e):geom3.isA(e)?measureBoundingSphereOfGeom3(e):[[0,0,0],0]);return 1===t.length?t[0]:t};module.exports=measureBoundingSphere;
},{"../geometries/geom2":25,"../geometries/geom3":40,"../geometries/path2":61,"../geometries/poly3":78,"../maths/vec2":190,"../maths/vec3":221,"../utils/flatten":396}],259:[function(require,module,exports){
const flatten=require("../utils/flatten"),measureBoundingBox=require("./measureBoundingBox"),measureCenter=(...e)=>{const n=(e=flatten(e)).map(e=>{const n=measureBoundingBox(e);return[n[0][0]+(n[1][0]-n[0][0])/2,n[0][1]+(n[1][1]-n[0][1])/2,n[0][2]+(n[1][2]-n[0][2])/2]});return 1===n.length?n[0]:n};module.exports=measureCenter;
},{"../utils/flatten":396,"./measureBoundingBox":257}],260:[function(require,module,exports){
const flatten=require("../utils/flatten"),vec3=require("../maths/vec3"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),cacheOfCenterOfMass=new WeakMap,measureCenterOfMassGeom2=e=>{let t=cacheOfCenterOfMass.get(e);if(void 0!==t)return t;const s=geom2.toSides(e);let r=0,c=0,a=0;if(s.length>0){for(let e=0;e<s.length;e++){const t=s[e][0],o=s[e][1],n=t[0]*o[1]-t[1]*o[0];r+=n,c+=(t[0]+o[0])*n,a+=(t[1]+o[1])*n}const e=1/(6*(r/=2));c*=e,a*=e}return t=vec3.fromValues(c,a,0),cacheOfCenterOfMass.set(e,t),t},measureCenterOfMassGeom3=e=>{let t=cacheOfCenterOfMass.get(e);if(void 0!==t)return t;t=vec3.create();const s=geom3.toPolygons(e);if(0===s.length)return t;let r=0;const c=vec3.create();return s.forEach(e=>{const s=e.vertices;for(let e=0;e<s.length-2;e++){vec3.cross(c,s[e+1],s[e+2]);const a=vec3.dot(s[0],c)/6;r+=a,vec3.add(c,s[0],s[e+1]),vec3.add(c,c,s[e+2]);const o=vec3.scale(c,c,.25*a);vec3.add(t,t,o)}}),vec3.scale(t,t,1/r),cacheOfCenterOfMass.set(e,t),t},measureCenterOfMass=(...e)=>{const t=(e=flatten(e)).map(e=>geom2.isA(e)?measureCenterOfMassGeom2(e):geom3.isA(e)?measureCenterOfMassGeom3(e):[0,0,0]);return 1===t.length?t[0]:t};module.exports=measureCenterOfMass;
},{"../geometries/geom2":25,"../geometries/geom3":40,"../maths/vec3":221,"../utils/flatten":396}],261:[function(require,module,exports){
const flatten=require("../utils/flatten"),measureBoundingBox=require("./measureBoundingBox"),measureDimensions=(...e)=>{const n=(e=flatten(e)).map(e=>{const n=measureBoundingBox(e);return[n[1][0]-n[0][0],n[1][1]-n[0][1],n[1][2]-n[0][2]]});return 1===n.length?n[0]:n};module.exports=measureDimensions;
},{"../utils/flatten":396,"./measureBoundingBox":257}],262:[function(require,module,exports){
const flatten=require("../utils/flatten"),{geom2:geom2,geom3:geom3,path2:path2}=require("../geometries"),calculateEpsilonFromBounds=require("./calculateEpsilonFromBounds"),measureBoundingBox=require("./measureBoundingBox"),measureEpsilonOfPath2=e=>calculateEpsilonFromBounds(measureBoundingBox(e),2),measureEpsilonOfGeom2=e=>calculateEpsilonFromBounds(measureBoundingBox(e),2),measureEpsilonOfGeom3=e=>calculateEpsilonFromBounds(measureBoundingBox(e),3),measureEpsilon=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const o=e.map(e=>path2.isA(e)?measureEpsilonOfPath2(e):geom2.isA(e)?measureEpsilonOfGeom2(e):geom3.isA(e)?measureEpsilonOfGeom3(e):0);return 1===o.length?o[0]:o};module.exports=measureEpsilon;
},{"../geometries":49,"../utils/flatten":396,"./calculateEpsilonFromBounds":250,"./measureBoundingBox":257}],263:[function(require,module,exports){
const flatten=require("../utils/flatten"),geom2=require("../geometries/geom2"),geom3=require("../geometries/geom3"),path2=require("../geometries/path2"),poly3=require("../geometries/poly3"),cache=new WeakMap,measureVolumeOfPath2=()=>0,measureVolumeOfGeom2=()=>0,measureVolumeOfGeom3=e=>{let r=cache.get(e);if(r)return r;return r=geom3.toPolygons(e).reduce((e,r)=>e+poly3.measureSignedVolume(r),0),cache.set(e,r),r},measureVolume=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const r=e.map(e=>path2.isA(e)?0:geom2.isA(e)?0:geom3.isA(e)?measureVolumeOfGeom3(e):0);return 1===r.length?r[0]:r};module.exports=measureVolume;
},{"../geometries/geom2":25,"../geometries/geom3":40,"../geometries/path2":61,"../geometries/poly3":78,"../utils/flatten":396}],264:[function(require,module,exports){
const vec2=require("../../maths/vec2"),geom2=require("../../geometries/geom2"),fromFakePolygon=(e,o)=>{if(o.vertices.length<4)return null;const r=[],n=o.vertices.filter((e,o)=>e[2]>0&&(r.push(o),!0));if(2!==n.length)throw new Error("Assertion failed: fromFakePolygon: not enough points found");const t=n.map(o=>{const r=Math.round(o[0]/e)*e+0,n=Math.round(o[1]/e)*e+0;return vec2.fromValues(r,n)});if(vec2.equals(t[0],t[1]))return null;const s=r[1]-r[0];if(1!==s&&3!==s)throw new Error("Assertion failed: fromFakePolygon: unknown index ordering");return 1===s&&t.reverse(),t},fromFakePolygons=(e,o)=>{const r=o.map(o=>fromFakePolygon(e,o)).filter(e=>null!==e);return geom2.create(r)};module.exports=fromFakePolygons;
},{"../../geometries/geom2":25,"../../maths/vec2":190}],265:[function(require,module,exports){
module.exports={intersect:require("./intersect"),scission:require("./scission"),subtract:require("./subtract"),union:require("./union")};
},{"./intersect":266,"./scission":271,"./subtract":273,"./union":284}],266:[function(require,module,exports){
const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),intersectGeom2=require("./intersectGeom2"),intersectGeom3=require("./intersectGeom3"),intersect=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only intersect of the types are supported");const r=e[0];return geom2.isA(r)?intersectGeom2(e):geom3.isA(r)?intersectGeom3(e):r};module.exports=intersect;
},{"../../geometries/geom2":25,"../../geometries/geom3":40,"../../utils/areAllShapesTheSameType":394,"../../utils/flatten":396,"./intersectGeom2":267,"./intersectGeom3":268}],267:[function(require,module,exports){
const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),intersectGeom3=require("./intersectGeom3"),intersect=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),r=intersectGeom3(o),t=measureEpsilon(r);return fromFakePolygons(t,geom3.toPolygons(r))};module.exports=intersect;
},{"../../geometries/geom3":40,"../../measurements/measureEpsilon":262,"../../utils/flatten":396,"./fromFakePolygons":264,"./intersectGeom3":268,"./to3DWalls":277}],268:[function(require,module,exports){
const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),intersectSub=require("./intersectGeom3Sub"),intersect=(...e)=>{let t=(e=flatten(e)).shift();return e.forEach(e=>{t=intersectSub(t,e)}),t=retessellate(t)};module.exports=intersect;
},{"../../utils/flatten":396,"../modifiers/retessellate":354,"./intersectGeom3Sub":269}],269:[function(require,module,exports){
const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),intersectGeom3Sub=(e,o)=>{if(!mayOverlap(e,o))return geom3.create();const r=new Tree(geom3.toPolygons(e)),t=new Tree(geom3.toPolygons(o));r.invert(),t.clipTo(r),t.invert(),r.clipTo(t),t.clipTo(r),r.addPolygons(t.allPolygons()),r.invert();const n=r.allPolygons();return geom3.create(n)};module.exports=intersectGeom3Sub;
},{"../../geometries/geom3":40,"./mayOverlap":270,"./trees":281}],270:[function(require,module,exports){
const{EPS:EPS}=require("../../maths/constants"),measureBoundingBox=require("../../measurements/measureBoundingBox"),mayOverlap=(e,n)=>{if(0===e.polygons.length||0===n.polygons.length)return!1;const o=measureBoundingBox(e),r=o[0],s=o[1],u=measureBoundingBox(n),a=u[0],t=u[1];return!(a[0]-s[0]>EPS)&&(!(r[0]-t[0]>EPS)&&(!(a[1]-s[1]>EPS)&&(!(r[1]-t[1]>EPS)&&(!(a[2]-s[2]>EPS)&&!(r[2]-t[2]>EPS)))))};module.exports=mayOverlap;
},{"../../maths/constants":93,"../../measurements/measureBoundingBox":257}],271:[function(require,module,exports){
const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),scissionGeom3=require("./scissionGeom3"),scission=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");const s=e.map(e=>geom3.isA(e)?scissionGeom3(e):e);return 1===s.length?s[0]:s};module.exports=scission;
},{"../../geometries/geom3":40,"../../utils/flatten":396,"./scissionGeom3":272}],272:[function(require,module,exports){
const vec3=require("../../maths/vec3"),measureEpsilon=require("../../measurements/measureEpsilon"),geom3=require("../../geometries/geom3"),sortNb=e=>e.sort((e,s)=>e-s).filter((e,s,o)=>!s||e!==o[s-1]),insertMapping=(e,s,o)=>{const t=`${s}`,n=e.get(t);void 0===n?e.set(t,[o]):n.push(o)},findMapping=(e,s)=>{const o=`${s}`;return e.get(o)},scissionGeom3=e=>{const s=measureEpsilon(e),o=geom3.toPolygons(e),t=o.length,n=new Map,r=vec3.create();o.forEach((e,o)=>{e.vertices.forEach(e=>{insertMapping(n,vec3.snap(r,e,s),o)})});const c=o.map(e=>{let o=[];return e.vertices.forEach(e=>{o=o.concat(findMapping(n,vec3.snap(r,e,s)))}),{e:1,d:sortNb(o)}});n.clear();let i=0;const a=c.length;for(let e=0;e<a;e++){const s=c[e];if(s.e>0){const o=new Array(t);o[e]=!0;do{i=0,o.forEach((e,s)=>{const t=c[s];if(t.e>0){t.e=-1;for(let e=0;e<t.d.length;e++)o[t.d[e]]=!0;i++}})}while(i>0);s.indexes=o}}const p=[];for(let e=0;e<a;e++)if(c[e].indexes){const s=[];c[e].indexes.forEach((e,t)=>s.push(o[t])),p.push(geom3.create(s))}return p};module.exports=scissionGeom3;
},{"../../geometries/geom3":40,"../../maths/vec3":221,"../../measurements/measureEpsilon":262}],273:[function(require,module,exports){
const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),subtractGeom2=require("./subtractGeom2"),subtractGeom3=require("./subtractGeom3"),subtract=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only subtract of the types are supported");const r=e[0];return geom2.isA(r)?subtractGeom2(e):geom3.isA(r)?subtractGeom3(e):r};module.exports=subtract;
},{"../../geometries/geom2":25,"../../geometries/geom3":40,"../../utils/areAllShapesTheSameType":394,"../../utils/flatten":396,"./subtractGeom2":274,"./subtractGeom3":275}],274:[function(require,module,exports){
const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),subtractGeom3=require("./subtractGeom3"),subtract=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),r=subtractGeom3(o),t=measureEpsilon(r);return fromFakePolygons(t,geom3.toPolygons(r))};module.exports=subtract;
},{"../../geometries/geom3":40,"../../measurements/measureEpsilon":262,"../../utils/flatten":396,"./fromFakePolygons":264,"./subtractGeom3":275,"./to3DWalls":277}],275:[function(require,module,exports){
const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),subtractSub=require("./subtractGeom3Sub"),subtract=(...t)=>{let e=(t=flatten(t)).shift();return t.forEach(t=>{e=subtractSub(e,t)}),e=retessellate(e)};module.exports=subtract;
},{"../../utils/flatten":396,"../modifiers/retessellate":354,"./subtractGeom3Sub":276}],276:[function(require,module,exports){
const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),subtractGeom3Sub=(e,o)=>{if(!mayOverlap(e,o))return geom3.clone(e);const r=new Tree(geom3.toPolygons(e)),t=new Tree(geom3.toPolygons(o));r.invert(),r.clipTo(t),t.clipTo(r,!0),r.addPolygons(t.allPolygons()),r.invert();const l=r.allPolygons();return geom3.create(l)};module.exports=subtractGeom3Sub;
},{"../../geometries/geom3":40,"./mayOverlap":270,"./trees":281}],277:[function(require,module,exports){
const vec3=require("../../maths/vec3"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),to3DWall=(e,o,r)=>{const c=[vec3.fromVec2(vec3.create(),r[0],e),vec3.fromVec2(vec3.create(),r[1],e),vec3.fromVec2(vec3.create(),r[1],o),vec3.fromVec2(vec3.create(),r[0],o)];return poly3.create(c)},to3DWalls=(e,o)=>{const r=geom2.toSides(o).map(o=>to3DWall(e.z0,e.z1,o));return geom3.create(r)};module.exports=to3DWalls;
},{"../../geometries/geom2":25,"../../geometries/geom3":40,"../../geometries/poly3":78,"../../maths/vec3":221}],278:[function(require,module,exports){
const plane=require("../../../maths/plane"),poly3=require("../../../geometries/poly3");class Node{constructor(e){this.plane=null,this.front=null,this.back=null,this.polygontreenodes=[],this.parent=e}invert(){const e=[this];let o;for(let n=0;n<e.length;n++){(o=e[n]).plane&&(o.plane=plane.flip(plane.create(),o.plane)),o.front&&e.push(o.front),o.back&&e.push(o.back);const t=o.front;o.front=o.back,o.back=t}}clipPolygons(e,o){let n,t={node:this,polygontreenodes:e};const l=[];do{if(n=t.node,e=t.polygontreenodes,n.plane){const t=n.plane,s=[],p=[],r=o?s:p,d=e.length;for(let o=0;o<d;o++){const n=e[o];n.isRemoved()||n.splitByPlane(t,r,s,p,s)}n.front&&p.length>0&&l.push({node:n.front,polygontreenodes:p});const h=s.length;if(n.back&&h>0)l.push({node:n.back,polygontreenodes:s});else for(let e=0;e<h;e++)s[e].remove()}t=l.pop()}while(void 0!==t)}clipTo(e,o){let n=this;const t=[];do{n.polygontreenodes.length>0&&e.rootnode.clipPolygons(n.polygontreenodes,o),n.front&&t.push(n.front),n.back&&t.push(n.back),n=t.pop()}while(void 0!==n)}addPolygonTreeNodes(e){let o={node:this,polygontreenodes:e};const n=[];do{const e=o.node,t=o.polygontreenodes;if(0===t.length){o=n.pop();continue}if(!e.plane){let o=0;const n=t[o=Math.floor(t.length/2)].getPolygon();e.plane=poly3.plane(n)}const l=[],s=[],p=t.length;for(let o=0;o<p;++o)t[o].splitByPlane(e.plane,e.polygontreenodes,s,l,s);if(l.length>0){e.front||(e.front=new Node(e)),p===l.length&&0===s.length?e.front.polygontreenodes=l:n.push({node:e.front,polygontreenodes:l})}if(s.length>0){e.back||(e.back=new Node(e)),p===s.length&&0===l.length?e.back.polygontreenodes=s:n.push({node:e.back,polygontreenodes:s})}o=n.pop()}while(void 0!==o)}}module.exports=Node;
},{"../../../geometries/poly3":78,"../../../maths/plane":162}],279:[function(require,module,exports){
const{EPS:EPS}=require("../../../maths/constants"),vec3=require("../../../maths/vec3"),poly3=require("../../../geometries/poly3"),splitPolygonByPlane=require("./splitPolygonByPlane");class PolygonTreeNode{constructor(e,t){this.parent=e,this.children=[],this.polygon=t,this.removed=!1}addPolygons(e){if(!this.isRootNode())throw new Error("Assertion failed");const t=this;e.forEach(e=>{t.addChild(e)})}remove(){if(!this.removed){this.removed=!0,this.polygon=null;const e=this.parent.children,t=e.indexOf(this);if(t<0)throw new Error("Assertion failed");e.splice(t,1),this.parent.recursivelyInvalidatePolygon()}}isRemoved(){return this.removed}isRootNode(){return!this.parent}invert(){if(!this.isRootNode())throw new Error("Assertion failed");this.invertSub()}getPolygon(){if(!this.polygon)throw new Error("Assertion failed");return this.polygon}getPolygons(e){let t=[this];const o=[t];let n,l,s,i;for(n=0;n<o.length;++n)for(l=0,s=(t=o[n]).length;l<s;l++)(i=t[l]).polygon?e.push(i.polygon):i.children.length>0&&o.push(i.children)}splitByPlane(e,t,o,n,l){if(this.children.length){const s=[this.children];let i,r,h,c,d;for(i=0;i<s.length;i++)for(d=s[i],r=0,h=d.length;r<h;r++)(c=d[r]).children.length>0?s.push(c.children):c._splitByPlane(e,t,o,n,l)}else this._splitByPlane(e,t,o,n,l)}_splitByPlane(e,t,o,n,l){const s=this.polygon;if(s){const i=poly3.measureBoundingSphere(s),r=i[3]+EPS,h=i,c=vec3.dot(e,h)-e[3];if(c>r)n.push(this);else if(c<-r)l.push(this);else{const i=splitPolygonByPlane(e,s);switch(i.type){case 0:t.push(this);break;case 1:o.push(this);break;case 2:n.push(this);break;case 3:l.push(this);break;case 4:if(i.front){const e=this.addChild(i.front);n.push(e)}if(i.back){const e=this.addChild(i.back);l.push(e)}}}}}addChild(e){const t=new PolygonTreeNode(this,e);return this.children.push(t),t}invertSub(){let e=[this];const t=[e];let o,n,l,s;for(o=0;o<t.length;o++)for(n=0,l=(e=t[o]).length;n<l;n++)(s=e[n]).polygon&&(s.polygon=poly3.invert(s.polygon)),s.children.length>0&&t.push(s.children)}recursivelyInvalidatePolygon(){this.polygon=null,this.parent&&this.parent.recursivelyInvalidatePolygon()}clear(){let e=[this];const t=[e];for(let o=0;o<t.length;++o){const n=(e=t[o]).length;for(let o=0;o<n;o++){const n=e[o];n.polygon&&(n.polygon=null),n.parent&&(n.parent=null),n.children.length>0&&t.push(n.children),n.children=[]}}}toString(){let e="",t=[this];const o=[t];let n,l,s,i;for(n=0;n<o.length;++n){t=o[n];const r=" ".repeat(n);for(l=0,s=t.length;l<s;l++)e+=`${r}PolygonTreeNode (${(i=t[l]).isRootNode()}): ${i.children.length}`,i.polygon?e+=`\n ${r}polygon: ${i.polygon.vertices}\n`:e+="\n",i.children.length>0&&o.push(i.children)}return e}}module.exports=PolygonTreeNode;
},{"../../../geometries/poly3":78,"../../../maths/constants":93,"../../../maths/vec3":221,"./splitPolygonByPlane":283}],280:[function(require,module,exports){
const Node=require("./Node"),PolygonTreeNode=require("./PolygonTreeNode");class Tree{constructor(o){this.polygonTree=new PolygonTreeNode,this.rootnode=new Node(null),o&&this.addPolygons(o)}invert(){this.polygonTree.invert(),this.rootnode.invert()}clipTo(o,e=!1){this.rootnode.clipTo(o,e)}allPolygons(){const o=[];return this.polygonTree.getPolygons(o),o}addPolygons(o){const e=new Array(o.length);for(let r=0;r<o.length;r++)e[r]=this.polygonTree.addChild(o[r]);this.rootnode.addPolygonTreeNodes(e)}clear(){this.polygonTree.clear()}toString(){return"Tree: "+this.polygonTree.toString("")}}module.exports=Tree;
},{"./Node":278,"./PolygonTreeNode":279}],281:[function(require,module,exports){
module.exports={Tree:require("./Tree")};
},{"./Tree":280}],282:[function(require,module,exports){
const vec3=require("../../../maths/vec3"),splitLineSegmentByPlane=(e,t,c)=>{const n=vec3.subtract(vec3.create(),c,t);let s=(e[3]-vec3.dot(e,t))/vec3.dot(e,n);return Number.isNaN(s)&&(s=0),s>1&&(s=1),s<0&&(s=0),vec3.scale(n,n,s),vec3.add(n,t,n),n};module.exports=splitLineSegmentByPlane;
},{"../../../maths/vec3":221}],283:[function(require,module,exports){
const{EPS:EPS}=require("../../../maths/constants"),plane=require("../../../maths/plane"),vec3=require("../../../maths/vec3"),poly3=require("../../../geometries/poly3"),splitLineSegmentByPlane=require("./splitLineSegmentByPlane"),splitPolygonByPlane=(e,t)=>{const l={type:null,front:null,back:null},n=t.vertices,s=n.length,o=poly3.plane(t);if(plane.equals(o,e))l.type=0;else{let t=!1,p=!1;const i=[],c=-EPS;for(let l=0;l<s;l++){const s=vec3.dot(e,n[l])-e[3],o=s<c;i.push(o),s>EPS&&(t=!0),s<c&&(p=!0)}if(t||p)if(p)if(t){l.type=4;const t=[],p=[];let c=i[0];for(let l=0;l<s;l++){const o=n[l];let r=l+1;r>=s&&(r=0);const a=i[r];if(c===a)c?p.push(o):t.push(o);else{const l=n[r],s=splitLineSegmentByPlane(e,o,l);c?(p.push(o),p.push(s),t.push(s)):(t.push(o),t.push(s),p.push(s))}c=a}const r=EPS*EPS;if(p.length>=3){let e=p[p.length-1];for(let t=0;t<p.length;t++){const l=p[t];vec3.squaredDistance(l,e)<r&&(p.splice(t,1),t--),e=l}}if(t.length>=3){let e=t[t.length-1];for(let l=0;l<t.length;l++){const n=t[l];vec3.squaredDistance(n,e)<r&&(t.splice(l,1),l--),e=n}}t.length>=3&&(l.front=poly3.fromPointsAndPlane(t,o)),p.length>=3&&(l.back=poly3.fromPointsAndPlane(p,o))}else l.type=3;else l.type=2;else{const t=vec3.dot(e,o);l.type=t>=0?0:1}}return l};module.exports=splitPolygonByPlane;
},{"../../../geometries/poly3":78,"../../../maths/constants":93,"../../../maths/plane":162,"../../../maths/vec3":221,"./splitLineSegmentByPlane":282}],284:[function(require,module,exports){
const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),unionGeom2=require("./unionGeom2"),unionGeom3=require("./unionGeom3"),union=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only unions of the same type are supported");const o=e[0];return geom2.isA(o)?unionGeom2(e):geom3.isA(o)?unionGeom3(e):o};module.exports=union;
},{"../../geometries/geom2":25,"../../geometries/geom3":40,"../../utils/areAllShapesTheSameType":394,"../../utils/flatten":396,"./unionGeom2":285,"./unionGeom3":286}],285:[function(require,module,exports){
const flatten=require("../../utils/flatten"),geom3=require("../../geometries/geom3"),measureEpsilon=require("../../measurements/measureEpsilon"),fromFakePolygons=require("./fromFakePolygons"),to3DWalls=require("./to3DWalls"),unionGeom3=require("./unionGeom3"),union=(...e)=>{const o=(e=flatten(e)).map(e=>to3DWalls({z0:-1,z1:1},e)),n=unionGeom3(o),r=measureEpsilon(n);return fromFakePolygons(r,geom3.toPolygons(n))};module.exports=union;
},{"../../geometries/geom3":40,"../../measurements/measureEpsilon":262,"../../utils/flatten":396,"./fromFakePolygons":264,"./to3DWalls":277,"./unionGeom3":286}],286:[function(require,module,exports){
const flatten=require("../../utils/flatten"),retessellate=require("../modifiers/retessellate"),unionSub=require("./unionGeom3Sub"),union=(...e)=>{let t;for(e=flatten(e),t=1;t<e.length;t+=2)e.push(unionSub(e[t-1],e[t]));let n=e[t-1];return n=retessellate(n)};module.exports=union;
},{"../../utils/flatten":396,"../modifiers/retessellate":354,"./unionGeom3Sub":287}],287:[function(require,module,exports){
const geom3=require("../../geometries/geom3"),mayOverlap=require("./mayOverlap"),{Tree:Tree}=require("./trees"),unionSub=(e,o)=>{if(!mayOverlap(e,o))return unionForNonIntersecting(e,o);const n=new Tree(geom3.toPolygons(e)),r=new Tree(geom3.toPolygons(o));n.clipTo(r,!1),r.clipTo(n),r.invert(),r.clipTo(n),r.invert();const t=n.allPolygons().concat(r.allPolygons());return geom3.create(t)},unionForNonIntersecting=(e,o)=>{let n=geom3.toPolygons(e);return n=n.concat(geom3.toPolygons(o)),geom3.create(n)};module.exports=unionSub;
},{"../../geometries/geom3":40,"./mayOverlap":270,"./trees":281}],288:[function(require,module,exports){
const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),expandGeom2=require("./expandGeom2"),expandGeom3=require("./expandGeom3"),expandPath2=require("./expandPath2"),expand=(e,...r)=>{if(0===(r=flatten(r)).length)throw new Error("wrong number of arguments");const t=r.map(r=>path2.isA(r)?expandPath2(e,r):geom2.isA(r)?expandGeom2(e,r):geom3.isA(r)?expandGeom3(e,r):r);return 1===t.length?t[0]:t};module.exports=expand;
},{"../../geometries/geom2":25,"../../geometries/geom3":40,"../../geometries/path2":61,"../../utils/flatten":396,"./expandGeom2":289,"./expandGeom3":290,"./expandPath2":291}],289:[function(require,module,exports){
const geom2=require("../../geometries/geom2"),offsetFromPoints=require("./offsetFromPoints"),expandGeom2=(e,o)=>{const{delta:r,corners:s,segments:t}=Object.assign({},{delta:1,corners:"edge",segments:16},e);if("edge"!==s&&"chamfer"!==s&&"round"!==s)throw new Error('corners must be "edge", "chamfer", or "round"');const n=geom2.toOutlines(o).map(o=>offsetFromPoints(e={delta:r,corners:s,closed:!0,segments:t},o)).reduce((e,o)=>e.concat(geom2.toSides(geom2.fromPoints(o))),[]);return geom2.create(n)};module.exports=expandGeom2;
},{"../../geometries/geom2":25,"./offsetFromPoints":296}],290:[function(require,module,exports){
const geom3=require("../../geometries/geom3"),union=require("../booleans/union"),expandShell=require("./expandShell"),expandGeom3=(e,n)=>{const{delta:o,corners:r,segments:t}=Object.assign({},{delta:1,corners:"round",segments:12},e);if("round"!==r)throw new Error('corners must be "round" for 3D geometries');if(0===geom3.toPolygons(n).length)throw new Error("the given geometry cannot be empty");const s=expandShell(e={delta:o,corners:r,segments:t},n);return union(n,s)};module.exports=expandGeom3;
},{"../../geometries/geom3":40,"../booleans/union":284,"./expandShell":292}],291:[function(require,module,exports){
const area=require("../../maths/utils/area"),vec2=require("../../maths/vec2"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),offsetFromPoints=require("./offsetFromPoints"),createGeometryFromClosedOffsets=e=>{let{external:t,internal:r}=e;area(t)<0?t=t.reverse():r=r.reverse();const o=path2.fromPoints({closed:!0},t),s=path2.fromPoints({closed:!0},r),n=geom2.toSides(geom2.fromPoints(path2.toPoints(o))),a=geom2.toSides(geom2.fromPoints(path2.toPoints(s)));return n.push(...a),geom2.create(n)},createGeometryFromExpandedOpenPath=(e,t,r,o)=>{const{points:s,external:n,internal:a}=e,c=Math.floor(t/2),m=[],i=[];if("round"===r&&c>0){const e=Math.PI/c,t=s[s.length-1],r=vec2.angle(vec2.subtract(vec2.create(),n[n.length-1],t)),d=s[0],l=vec2.angle(vec2.subtract(vec2.create(),a[0],d));for(let s=1;s<c;s++){let n=r+e*s,a=vec2.fromAngleRadians(vec2.create(),n);vec2.scale(a,a,o),vec2.add(a,a,t),m.push(a),n=l+e*s,a=vec2.fromAngleRadians(vec2.create(),n),vec2.scale(a,a,o),vec2.add(a,a,d),i.push(a)}}const d=[];return d.push(...n,...m,...a.reverse(),...i),geom2.fromPoints(d)},expandPath2=(e,t)=>{e=Object.assign({},{delta:1,corners:"edge",segments:16},e);const{delta:r,corners:o,segments:s}=e;if(r<=0)throw new Error("the given delta must be positive for paths");if("edge"!==o&&"chamfer"!==o&&"round"!==o)throw new Error('corners must be "edge", "chamfer", or "round"');const n=t.isClosed,a=path2.toPoints(t);if(0===a.length)throw new Error("the given geometry cannot be empty");const c={points:a,external:offsetFromPoints({delta:r,corners:o,segments:s,closed:n},a),internal:offsetFromPoints({delta:-r,corners:o,segments:s,closed:n},a)};return t.isClosed?createGeometryFromClosedOffsets(c):createGeometryFromExpandedOpenPath(c,s,o,r)};module.exports=expandPath2;
},{"../../geometries/geom2":25,"../../geometries/path2":61,"../../maths/utils/area":167,"../../maths/vec2":190,"./offsetFromPoints":296}],292:[function(require,module,exports){
const{EPS:EPS,TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),fnNumberSort=require("../../utils/fnNumberSort"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),sphere=require("../../primitives/sphere"),retessellate=require("../modifiers/retessellate"),unionGeom3Sub=require("../booleans/unionGeom3Sub"),extrudePolygon=require("./extrudePolygon"),mapPlaneToVertex=(e,t,o)=>{const n=t.toString();if(e.has(n)){e.get(n)[1].push(o)}else{const s=[t,[o]];e.set(n,s)}},mapPlaneToEdge=(e,t,o)=>{const n=t[0].toString(),s=t[1].toString(),r=n<s?`${n},${s}`:`${s},${n}`;if(e.has(r)){e.get(r)[1].push(o)}else{const n=[t,[o]];e.set(r,n)}},addUniqueAngle=(e,t)=>{e.findIndex(e=>e===t)<0&&e.push(t)},expandShell=(e,t)=>{const{delta:o,segments:n}=Object.assign({},{delta:1,segments:12},e);let s=geom3.create();const r=new Map,c=new Map,a=vec3.create(),l=vec3.create();return geom3.toPolygons(t).forEach((e,t)=>{const n=vec3.scale(vec3.create(),poly3.plane(e),2*o),a=poly3.transform(mat4.fromTranslation(mat4.create(),vec3.scale(vec3.create(),n,-.5)),e),l=extrudePolygon(n,a);s=unionGeom3Sub(s,l);const u=e.vertices;for(let t=0;t<u.length;t++){mapPlaneToVertex(r,u[t],poly3.plane(e));const o=(t+1)%u.length,n=[u[t],u[o]];mapPlaneToEdge(c,n,poly3.plane(e))}}),c.forEach(e=>{const t=e[0],r=e[1],c=t[0],u=t[1],i=vec3.subtract(vec3.create(),u,c);vec3.normalize(i,i);const m=r[0],g=vec3.cross(vec3.create(),m,i);let p=[];for(let e=0;e<n;e++)addUniqueAngle(p,e*TAU/n);for(let e=0,t=r.length;e<t;e++){const t=r[e],o=vec3.dot(g,t),n=vec3.dot(m,t);let s=Math.atan2(o,n);s<0&&(s+=TAU),addUniqueAngle(p,s),(s=Math.atan2(-o,-n))<0&&(s+=TAU),addUniqueAngle(p,s)}const h=(p=p.sort(fnNumberSort)).length;let v,d;const f=[],S=[],q=[];for(let e=-1;e<h;e++){const t=p[e<0?e+h:e],n=Math.sin(t),s=Math.cos(t);vec3.scale(a,m,s*o),vec3.scale(l,g,n*o),vec3.add(a,a,l);const r=vec3.add(vec3.create(),c,a),i=vec3.add(vec3.create(),u,a);let y=!1;if(e>=0&&vec3.distance(r,v)<EPS&&(y=!0),!y){if(e>=0){f.push(r),S.push(i);const e=[d,i,r,v],t=poly3.create(e);q.push(t)}v=r,d=i}}S.reverse(),q.push(poly3.create(f)),q.push(poly3.create(S));const y=geom3.create(q);s=unionGeom3Sub(s,y)}),r.forEach(e=>{const t=e[0],r=e[1],c=r[0];let u=null,i=0;for(let e=1;e<r.length;e++){const t=r[e],o=vec3.cross(a,c,t),n=vec3.length(o);n>.05&&n>i&&(i=n,u=t)}u||(u=vec3.orthogonal(a,c));const m=vec3.cross(a,c,u);vec3.normalize(m,m);const g=vec3.cross(l,m,c),p=sphere({center:[t[0],t[1],t[2]],radius:o,segments:n,axes:[c,m,g]});s=unionGeom3Sub(s,p)}),retessellate(s)};module.exports=expandShell;
},{"../../geometries/geom3":40,"../../geometries/poly3":78,"../../maths/constants":93,"../../maths/mat4":142,"../../maths/vec3":221,"../../primitives/sphere":384,"../../utils/fnNumberSort":397,"../booleans/unionGeom3Sub":287,"../modifiers/retessellate":354,"./extrudePolygon":293}],293:[function(require,module,exports){
const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),extrudePolygon=(e,r)=>{vec3.dot(poly3.plane(r),e)>0&&(r=poly3.invert(r));const t=[r],o=poly3.transform(mat4.fromTranslation(mat4.create(),e),r),s=r.vertices.length;for(let e=0;e<s;e++){const c=e<s-1?e+1:0,i=poly3.create([r.vertices[e],o.vertices[e],o.vertices[c],r.vertices[c]]);t.push(i)}return t.push(poly3.invert(o)),geom3.create(t)};module.exports=extrudePolygon;
},{"../../geometries/geom3":40,"../../geometries/poly3":78,"../../maths/mat4":142,"../../maths/vec3":221}],294:[function(require,module,exports){
module.exports={expand:require("./expand"),offset:require("./offset")};
},{"./expand":288,"./offset":295}],295:[function(require,module,exports){
const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),offsetGeom2=require("./offsetGeom2"),offsetPath2=require("./offsetPath2"),offset=(e,...t)=>{if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");const o=t.map(t=>path2.isA(t)?offsetPath2(e,t):geom2.isA(t)?offsetGeom2(e,t):t);return 1===o.length?o[0]:o};module.exports=offset;
},{"../../geometries/geom2":25,"../../geometries/path2":61,"../../utils/flatten":396,"./offsetGeom2":297,"./offsetPath2":298}],296:[function(require,module,exports){
const{EPS:EPS,TAU:TAU}=require("../../maths/constants"),intersect=require("../../maths/utils/intersect"),line2=require("../../maths/line2"),vec2=require("../../maths/vec2"),area=require("../../maths/utils/area"),offsetFromPoints=(e,t)=>{let{delta:s,corners:c,closed:n,segments:a}=Object.assign({},{delta:1,corners:"edge",closed:!1,segments:16},e);if(Math.abs(s)<EPS)return t;let r=e.closed?area(t):1;0===r&&(r=1);const o=r>0&&s>=0||r<0&&s<0;s=Math.abs(s);let i=null,l=[];const u=[],v=vec2.create(),f=t.length;for(let e=0;e<f;e++){const c=(e+1)%f,a=t[e],r=t[c];o?vec2.subtract(v,a,r):vec2.subtract(v,r,a),vec2.normal(v,v),vec2.normalize(v,v),vec2.scale(v,v,s);const h=vec2.add(vec2.create(),a,v),d=vec2.add(vec2.create(),r,v),m=[h,d];if(null!=i&&(n||!n&&0!==c)){const e=intersect(i[0],i[1],m[0],m[1]);e?(l.pop(),m[0]=e):u.push({c:a,s0:i,s1:m})}i=[h,d],(0!==c||n)&&(l.push(m[0]),l.push(m[1]))}if(n&&null!=i){const e=l[0],s=l[1],c=intersect(i[0],i[1],e,s);if(c)l[0]=c,l.pop();else{const c=t[0],n=[e,s];u.push({c:c,s0:i,s1:n})}}if("edge"===c){const e=new Map;l.forEach((t,s)=>e.set(t,s));const t=line2.create(),s=line2.create();u.forEach(c=>{line2.fromPoints(t,c.s0[0],c.s0[1]),line2.fromPoints(s,c.s1[0],c.s1[1]);const n=line2.intersectPointOfLines(t,s);if(Number.isFinite(n[0])&&Number.isFinite(n[1])){const t=c.s0[1],s=e.get(t);l[s]=n,l[(s+1)%l.length]=void 0}else{const t=c.s1[0],s=e.get(t);l[s]=void 0}}),l=l.filter(e=>void 0!==e)}if("round"===c){let e=Math.floor(a/4);const t=vec2.create();u.forEach(c=>{let n=vec2.angle(vec2.subtract(t,c.s1[0],c.c));if(n-=vec2.angle(vec2.subtract(t,c.s0[1],c.c)),o&&n<0&&(n+=Math.PI)<0&&(n+=Math.PI),!o&&n>0&&(n-=Math.PI)>0&&(n-=Math.PI),0!==n){const r=n/(e=Math.floor(a*(Math.abs(n)/TAU))),o=vec2.angle(vec2.subtract(t,c.s0[1],c.c)),i=[];for(let t=1;t<e;t++){const e=o+r*t,n=vec2.fromAngleRadians(vec2.create(),e);vec2.scale(n,n,s),vec2.add(n,n,c.c),i.push(n)}if(i.length>0){const e=c.s0[1];let t=l.findIndex(t=>vec2.equals(e,t));t=(t+1)%l.length,l.splice(t,0,...i)}}else{const e=c.s1[0],t=l.findIndex(t=>vec2.equals(e,t));l.splice(t,1)}})}return l};module.exports=offsetFromPoints;
},{"../../maths/constants":93,"../../maths/line2":104,"../../maths/utils/area":167,"../../maths/utils/intersect":170,"../../maths/vec2":190}],297:[function(require,module,exports){
const geom2=require("../../geometries/geom2"),poly2=require("../../geometries/poly2"),offsetFromPoints=require("./offsetFromPoints"),offsetGeom2=(e,o)=>{const{delta:r,corners:s,segments:t}=Object.assign({},{delta:1,corners:"edge",segments:0},e);if("edge"!==s&&"chamfer"!==s&&"round"!==s)throw new Error('corners must be "edge", "chamfer", or "round"');const n=geom2.toOutlines(o),m=n.map(o=>{const m=n.reduce((e,r)=>e+poly2.arePointsInside(o,poly2.create(r)),0);return offsetFromPoints(e={delta:m%2==0?r:-r,corners:s,closed:!0,segments:t},o)}).reduce((e,o)=>e.concat(geom2.toSides(geom2.fromPoints(o))),[]);return geom2.create(m)};module.exports=offsetGeom2;
},{"../../geometries/geom2":25,"../../geometries/poly2":72,"./offsetFromPoints":296}],298:[function(require,module,exports){
const path2=require("../../geometries/path2"),offsetFromPoints=require("./offsetFromPoints"),offsetPath2=(e,o)=>{const s={delta:1,corners:"edge",closed:o.isClosed,segments:16},{delta:t,corners:r,closed:n,segments:c}=Object.assign({},s,e);if("edge"!==r&&"chamfer"!==r&&"round"!==r)throw new Error('corners must be "edge", "chamfer", or "round"');const d=offsetFromPoints(e={delta:t,corners:r,closed:n,segments:c},path2.toPoints(o));return path2.fromPoints({closed:n},d)};module.exports=offsetPath2;
},{"../../geometries/path2":61,"./offsetFromPoints":296}],299:[function(require,module,exports){
const{area:area}=require("../../../maths/utils"),{toOutlines:toOutlines}=require("../../../geometries/geom2"),{arePointsInside:arePointsInside}=require("../../../geometries/poly2"),assignHoles=e=>{const s=toOutlines(e),o=[],t=[];s.forEach((e,s)=>{const n=area(e);n<0?t.push(s):n>0&&o.push(s)});const n=[],r=[];return o.forEach((e,o)=>{const i=s[e];n[o]=[],t.forEach((e,t)=>{const a=s[e];arePointsInside([a[0]],{vertices:i})&&(n[o].push(e),r[t]||(r[t]=[]),r[t].push(o))})}),t.forEach((e,s)=>{if(r[s]&&r[s].length>1){const o=minIndex(r[s],e=>n[e].length);r[s].forEach((s,t)=>{t!==o&&(n[s]=n[s].filter(s=>s!==e))})}}),n.map((e,t)=>({solid:s[o[t]],holes:e.map(e=>s[e])}))},minIndex=(e,s)=>{let o,t;return e.forEach((e,n)=>{const r=s(e);(void 0===t||r<t)&&(o=n,t=r)}),o};module.exports=assignHoles;
},{"../../../geometries/geom2":25,"../../../geometries/poly2":72,"../../../maths/utils":168}],300:[function(require,module,exports){
const{filterPoints:filterPoints,linkedPolygon:linkedPolygon,locallyInside:locallyInside,splitPolygon:splitPolygon}=require("./linkedPolygon"),{area:area,pointInTriangle:pointInTriangle}=require("./triangle"),eliminateHoles=(e,t,n,l)=>{const i=[];for(let n=0,o=t.length;n<o;n++){const r=t[n]*l,x=n<o-1?t[n+1]*l:e.length,s=linkedPolygon(e,r,x,l,!1);s===s.next&&(s.steiner=!0),i.push(getLeftmost(s))}i.sort((e,t)=>e.x-t.x);for(let e=0;e<i.length;e++)n=eliminateHole(i[e],n),n=filterPoints(n,n.next);return n},eliminateHole=(e,t)=>{const n=findHoleBridge(e,t);if(!n)return t;const l=splitPolygon(n,e),i=filterPoints(n,n.next);return filterPoints(l,l.next),t===n?i:t},findHoleBridge=(e,t)=>{let n=t;const l=e.x,i=e.y;let o,r=-1/0;do{if(i<=n.y&&i>=n.next.y&&n.next.y!==n.y){const e=n.x+(i-n.y)*(n.next.x-n.x)/(n.next.y-n.y);if(e<=l&&e>r){if(r=e,e===l){if(i===n.y)return n;if(i===n.next.y)return n.next}o=n.x<n.next.x?n:n.next}}n=n.next}while(n!==t);if(!o)return null;if(l===r)return o;const x=o,s=o.x,y=o.y;let a=1/0;n=o;do{if(l>=n.x&&n.x>=s&&l!==n.x&&pointInTriangle(i<y?l:r,i,s,y,i<y?r:l,i,n.x,n.y)){const t=Math.abs(i-n.y)/(l-n.x);locallyInside(n,e)&&(t<a||t===a&&(n.x>o.x||n.x===o.x&§orContainsSector(o,n)))&&(o=n,a=t)}n=n.next}while(n!==x);return o},sectorContainsSector=(e,t)=>area(e.prev,e,t.prev)<0&&area(t.next,e,e.next)<0,getLeftmost=e=>{let t=e,n=e;do{(t.x<n.x||t.x===n.x&&t.y<n.y)&&(n=t),t=t.next}while(t!==e);return n};module.exports=eliminateHoles;
},{"./linkedPolygon":304,"./triangle":306}],301:[function(require,module,exports){
const eliminateHoles=require("./eliminateHoles"),{removeNode:removeNode,sortLinked:sortLinked}=require("./linkedList"),{cureLocalIntersections:cureLocalIntersections,filterPoints:filterPoints,isValidDiagonal:isValidDiagonal,linkedPolygon:linkedPolygon,splitPolygon:splitPolygon}=require("./linkedPolygon"),{area:area,pointInTriangle:pointInTriangle}=require("./triangle"),triangulate=(e,r,n=2)=>{const t=r&&r.length,i=t?r[0]*n:e.length;let x=linkedPolygon(e,0,i,n,!0);const l=[];if(!x||x.next===x.prev)return l;let o,a,y,s,p;if(t&&(x=eliminateHoles(e,r,x,n)),e.length>80*n){o=y=e[0],a=s=e[1];for(let r=n;r<i;r+=n){const n=e[r],t=e[r+1];n<o&&(o=n),t<a&&(a=t),n>y&&(y=n),t>s&&(s=t)}p=0!==(p=Math.max(y-o,s-a))?1/p:0}return earcutLinked(x,l,n,o,a,p),l},earcutLinked=(e,r,n,t,i,x,l)=>{if(!e)return;!l&&x&&indexCurve(e,t,i,x);let o,a,y=e;for(;e.prev!==e.next;)if(o=e.prev,a=e.next,x?isEarHashed(e,t,i,x):isEar(e))r.push(o.i/n),r.push(e.i/n),r.push(a.i/n),removeNode(e),e=a.next,y=a.next;else if((e=a)===y){l?1===l?(e=cureLocalIntersections(filterPoints(e),r,n),earcutLinked(e,r,n,t,i,x,2)):2===l&&splitEarcut(e,r,n,t,i,x):earcutLinked(filterPoints(e),r,n,t,i,x,1);break}},isEar=e=>{const r=e.prev,n=e,t=e.next;if(area(r,n,t)>=0)return!1;let i=e.next.next;for(;i!==e.prev;){if(pointInTriangle(r.x,r.y,n.x,n.y,t.x,t.y,i.x,i.y)&&area(i.prev,i,i.next)>=0)return!1;i=i.next}return!0},isEarHashed=(e,r,n,t)=>{const i=e.prev,x=e,l=e.next;if(area(i,x,l)>=0)return!1;const o=i.x<x.x?i.x<l.x?i.x:l.x:x.x<l.x?x.x:l.x,a=i.y<x.y?i.y<l.y?i.y:l.y:x.y<l.y?x.y:l.y,y=i.x>x.x?i.x>l.x?i.x:l.x:x.x>l.x?x.x:l.x,s=i.y>x.y?i.y>l.y?i.y:l.y:x.y>l.y?x.y:l.y,p=zOrder(o,a,r,n,t),u=zOrder(y,s,r,n,t);let d=e.prevZ,v=e.nextZ;for(;d&&d.z>=p&&v&&v.z<=u;){if(d!==e.prev&&d!==e.next&&pointInTriangle(i.x,i.y,x.x,x.y,l.x,l.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;if(d=d.prevZ,v!==e.prev&&v!==e.next&&pointInTriangle(i.x,i.y,x.x,x.y,l.x,l.y,v.x,v.y)&&area(v.prev,v,v.next)>=0)return!1;v=v.nextZ}for(;d&&d.z>=p;){if(d!==e.prev&&d!==e.next&&pointInTriangle(i.x,i.y,x.x,x.y,l.x,l.y,d.x,d.y)&&area(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;v&&v.z<=u;){if(v!==e.prev&&v!==e.next&&pointInTriangle(i.x,i.y,x.x,x.y,l.x,l.y,v.x,v.y)&&area(v.prev,v,v.next)>=0)return!1;v=v.nextZ}return!0},splitEarcut=(e,r,n,t,i,x)=>{let l=e;do{let e=l.next.next;for(;e!==l.prev;){if(l.i!==e.i&&isValidDiagonal(l,e)){let o=splitPolygon(l,e);return l=filterPoints(l,l.next),o=filterPoints(o,o.next),earcutLinked(l,r,n,t,i,x),void earcutLinked(o,r,n,t,i,x)}e=e.next}l=l.next}while(l!==e)},indexCurve=(e,r,n,t)=>{let i=e;do{null===i.z&&(i.z=zOrder(i.x,i.y,r,n,t)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==e);i.prevZ.nextZ=null,i.prevZ=null,sortLinked(i,e=>e.z)},zOrder=(e,r,n,t,i)=>(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-n)*i)|e<<8))|e<<4))|e<<2))|e<<1))|(r=1431655765&((r=858993459&((r=252645135&((r=16711935&((r=32767*(r-t)*i)|r<<8))|r<<4))|r<<2))|r<<1))<<1;module.exports=triangulate;
},{"./eliminateHoles":300,"./linkedList":302,"./linkedPolygon":304,"./triangle":306}],302:[function(require,module,exports){
const sortLinked=require("./linkedListSort");class Node{constructor(e,t,n){this.i=e,this.x=t,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}}const insertNode=(e,t,n,r)=>{const o=new Node(e,t,n);return r?(o.next=r.next,o.prev=r,r.next.prev=o,r.next=o):(o.prev=o,o.next=o),o},removeNode=e=>{e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)};module.exports={Node:Node,insertNode:insertNode,removeNode:removeNode,sortLinked:sortLinked};
},{"./linkedListSort":303}],303:[function(require,module,exports){
const sortLinked=(e,t)=>{let l,n,o,r,x,Z=1;do{n=e,e=null;let u=null;for(x=0;n;){x++,o=n;let d=0;for(l=0;l<Z&&(d++,o=o.nextZ);l++);let s=Z;for(;d>0||s>0&&o;)0!==d&&(0===s||!o||t(n)<=t(o))?(r=n,n=n.nextZ,d--):(r=o,o=o.nextZ,s--),u?u.nextZ=r:e=r,r.prevZ=u,u=r;n=o}u.nextZ=null,Z*=2}while(x>1);return e};module.exports=sortLinked;
},{}],304:[function(require,module,exports){
const{Node:Node,insertNode:insertNode,removeNode:removeNode}=require("./linkedList"),{area:area}=require("./triangle"),linkedPolygon=(e,n,t,r,i)=>{let o;if(i===signedArea(e,n,t,r)>0)for(let i=n;i<t;i+=r)o=insertNode(i,e[i],e[i+1],o);else for(let i=t-r;i>=n;i-=r)o=insertNode(i,e[i],e[i+1],o);return o&&equals(o,o.next)&&(removeNode(o),o=o.next),o},filterPoints=(e,n)=>{if(!e)return e;n||(n=e);let t,r=e;do{if(t=!1,r.steiner||!equals(r,r.next)&&0!==area(r.prev,r,r.next))r=r.next;else{if(removeNode(r),(r=n=r.prev)===r.next)break;t=!0}}while(t||r!==n);return n},cureLocalIntersections=(e,n,t)=>{let r=e;do{const i=r.prev,o=r.next.next;!equals(i,o)&&intersects(i,r,r.next,o)&&locallyInside(i,o)&&locallyInside(o,i)&&(n.push(i.i/t),n.push(r.i/t),n.push(o.i/t),removeNode(r),removeNode(r.next),r=e=o),r=r.next}while(r!==e);return filterPoints(r)},intersectsPolygon=(e,n)=>{let t=e;do{if(t.i!==e.i&&t.next.i!==e.i&&t.i!==n.i&&t.next.i!==n.i&&intersects(t,t.next,e,n))return!0;t=t.next}while(t!==e);return!1},locallyInside=(e,n)=>area(e.prev,e,e.next)<0?area(e,n,e.next)>=0&&area(e,e.prev,n)>=0:area(e,n,e.prev)<0||area(e,e.next,n)<0,middleInside=(e,n)=>{let t=e,r=!1;const i=(e.x+n.x)/2,o=(e.y+n.y)/2;do{t.y>o!=t.next.y>o&&t.next.y!==t.y&&i<(t.next.x-t.x)*(o-t.y)/(t.next.y-t.y)+t.x&&(r=!r),t=t.next}while(t!==e);return r},splitPolygon=(e,n)=>{const t=new Node(e.i,e.x,e.y),r=new Node(n.i,n.x,n.y),i=e.next,o=n.prev;return e.next=n,n.prev=e,t.next=i,i.prev=t,r.next=t,t.prev=r,o.next=r,r.prev=o,r},isValidDiagonal=(e,n)=>e.next.i!==n.i&&e.prev.i!==n.i&&!intersectsPolygon(e,n)&&(locallyInside(e,n)&&locallyInside(n,e)&&middleInside(e,n)&&(area(e.prev,e,n.prev)||area(e,n.prev,n))||equals(e,n)&&area(e.prev,e,e.next)>0&&area(n.prev,n,n.next)>0),intersects=(e,n,t,r)=>{const i=Math.sign(area(e,n,t)),o=Math.sign(area(e,n,r)),l=Math.sign(area(t,r,e)),a=Math.sign(area(t,r,n));return i!==o&&l!==a||(!(0!==i||!onSegment(e,t,n))||(!(0!==o||!onSegment(e,r,n))||(!(0!==l||!onSegment(t,e,r))||!(0!==a||!onSegment(t,n,r)))))},onSegment=(e,n,t)=>n.x<=Math.max(e.x,t.x)&&n.x>=Math.min(e.x,t.x)&&n.y<=Math.max(e.y,t.y)&&n.y>=Math.min(e.y,t.y),signedArea=(e,n,t,r)=>{let i=0;for(let o=n,l=t-r;o<t;o+=r)i+=(e[l]-e[o])*(e[o+1]+e[l+1]),l=o;return i},equals=(e,n)=>e.x===n.x&&e.y===n.y;module.exports={cureLocalIntersections:cureLocalIntersections,filterPoints:filterPoints,isValidDiagonal:isValidDiagonal,linkedPolygon:linkedPolygon,locallyInside:locallyInside,splitPolygon:splitPolygon};
},{"./linkedList":302,"./triangle":306}],305:[function(require,module,exports){
const geom2=require("../../../geometries/geom2"),plane=require("../../../maths/plane"),vec2=require("../../../maths/vec2"),vec3=require("../../../maths/vec3"),calculatePlane=require("../slice/calculatePlane"),assignHoles=require("./assignHoles");class PolygonHierarchy{constructor(e){this.plane=calculatePlane(e);const s=vec3.orthogonal(vec3.create(),this.plane),c=vec3.cross(vec3.create(),this.plane,s);this.v=vec3.normalize(c,c),this.u=vec3.cross(vec3.create(),this.v,this.plane),this.basisMap=new Map;const t=e.edges.map(e=>e.map(e=>this.to2D(e))),a=geom2.create(t);this.roots=assignHoles(a)}to2D(e){const s=vec2.fromValues(vec3.dot(e,this.u),vec3.dot(e,this.v));return this.basisMap.set(s,e),s}to3D(e){const s=this.basisMap.get(e);if(s)return s;{console.log("Warning: point not in original slice");const s=vec3.scale(vec3.create(),this.u,e[0]),c=vec3.scale(vec3.create(),this.v,e[1]),t=vec3.scale(vec3.create(),plane,plane[3]),a=vec3.add(s,s,t);return vec3.add(c,c,a)}}}module.exports=PolygonHierarchy;
},{"../../../geometries/geom2":25,"../../../maths/plane":162,"../../../maths/vec2":190,"../../../maths/vec3":221,"../slice/calculatePlane":319,"./assignHoles":299}],306:[function(require,module,exports){
const pointInTriangle=(n,a,e,r,i,o,t,x)=>(i-t)*(a-x)-(n-t)*(o-x)>=0&&(n-t)*(r-x)-(e-t)*(a-x)>=0&&(e-t)*(o-x)-(i-t)*(r-x)>=0,area=(n,a,e)=>(a.y-n.y)*(e.x-a.x)-(a.x-n.x)*(e.y-a.y);module.exports={area:area,pointInTriangle:pointInTriangle};
},{}],307:[function(require,module,exports){
const mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),slice=require("./slice"),repairSlice=require("./slice/repair"),extrudeWalls=require("./extrudeWalls"),defaultCallback=(e,r,l)=>{let t=null;return geom2.isA(l)&&(t=slice.fromSides(geom2.toSides(l))),poly3.isA(l)&&(t=slice.fromPoints(poly3.toPoints(l))),0===e||1===e?slice.transform(mat4.fromTranslation(mat4.create(),[0,0,e]),t):null},extrudeFromSlices=(e,r)=>{const l={numberOfSlices:2,capStart:!0,capEnd:!0,close:!1,repair:!0,callback:defaultCallback},{numberOfSlices:t,capStart:o,capEnd:c,close:s,repair:i,callback:a}=Object.assign({},l,e);if(t<2)throw new Error("numberOfSlices must be 2 or more");i&&(r=repairSlice(r));const n=t-1;let u=null,m=null,f=null,g=[];for(let e=0;e<t;e++){const l=a(e/n,e,r);if(l){if(!slice.isA(l))throw new Error("the callback function must return slice objects");if(0===slice.toEdges(l).length)throw new Error("the callback function must return slices with one or more edges");f&&(g=g.concat(extrudeWalls(f,l))),0===e&&(u=l),e===t-1&&(m=l),f=l}}if(c){const e=slice.toPolygons(m);g=g.concat(e)}if(o){const e=slice.toPolygons(u).map(poly3.invert);g=g.concat(e)}return o||c||s&&!slice.equals(m,u)&&(g=g.concat(extrudeWalls(m,u))),geom3.create(g)};module.exports=extrudeFromSlices;
},{"../../geometries/geom2":25,"../../geometries/geom3":40,"../../geometries/poly3":78,"../../maths/mat4":142,"./extrudeWalls":316,"./slice":325,"./slice/repair":327}],308:[function(require,module,exports){
const{TAU:TAU}=require("../../maths/constants"),slice=require("./slice"),mat4=require("../../maths/mat4"),extrudeFromSlices=require("./extrudeFromSlices"),geom2=require("../../geometries/geom2"),extrudeHelical=(e,t)=>{const r={angle:TAU,startAngle:0,pitch:10,endOffset:0,segmentsPerRotation:32},{angle:a,endOffset:s,segmentsPerRotation:o,startAngle:i}=Object.assign({},r,e);let n;n=!e.pitch&&e.height?e.height/(a/TAU):e.pitch?e.pitch:r.pitch;if(o<3)throw new Error("The number of segments per rotation needs to be at least 3.");const m=geom2.toSides(t);if(0===m.length)throw new Error("the given geometry cannot be empty");const c=m.filter(e=>e[0][0]>=0);let l=slice.fromSides(m);0===c.length&&(l=slice.reverse(l));const h=Math.round(o/TAU*Math.abs(a)),g=h>=2?h:2,u=mat4.create();let f;return extrudeFromSlices({numberOfSlices:g+1,callback:(e,t,r)=>{const o=i+a/g*t,m=s/g*t,c=(o-i)/TAU*n;return mat4.multiply(u,mat4.fromTranslation(mat4.create(),[m,0,c*Math.sign(a)]),mat4.fromXRotation(mat4.create(),-TAU/4*Math.sign(a))),f=mat4.create(),mat4.multiply(f,mat4.fromZRotation(mat4.create(),o),u),slice.transform(f,r)}},l)};module.exports=extrudeHelical;
},{"../../geometries/geom2":25,"../../maths/constants":93,"../../maths/mat4":142,"./extrudeFromSlices":307,"./slice":325}],309:[function(require,module,exports){
const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeLinearPath2=require("./extrudeLinearPath2"),extrudeLinear=(e,...t)=>{const{height:r,twistAngle:i,twistSteps:n,repair:a}=Object.assign({},{height:1,twistAngle:0,twistSteps:1,repair:!0},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");e={offset:[0,0,r],twistAngle:i,twistSteps:n,repair:a};const s=t.map(t=>path2.isA(t)?extrudeLinearPath2(e,t):geom2.isA(t)?extrudeLinearGeom2(e,t):t);return 1===s.length?s[0]:s};module.exports=extrudeLinear;
},{"../../geometries/geom2":25,"../../geometries/path2":61,"../../utils/flatten":396,"./extrudeLinearGeom2":310,"./extrudeLinearPath2":311}],310:[function(require,module,exports){
const mat4=require("../../maths/mat4"),vec3=require("../../maths/vec3"),geom2=require("../../geometries/geom2"),slice=require("./slice"),extrudeFromSlices=require("./extrudeFromSlices"),extrudeGeom2=(e,t)=>{let{offset:r,twistAngle:s,twistSteps:o,repair:i}=Object.assign({},{offset:[0,0,1],twistAngle:0,twistSteps:12,repair:!0},e);if(o<1)throw new Error("twistSteps must be 1 or more");0===s&&(o=1);const c=vec3.clone(r),m=geom2.toSides(t);if(0===m.length)throw new Error("the given geometry cannot be empty");const a=slice.fromSides(m);c[2]<0&&slice.reverse(a,a);const n=mat4.create();return extrudeFromSlices(e={numberOfSlices:o+1,capStart:!0,capEnd:!0,repair:i,callback:(e,t,r)=>{const i=t/o*s,m=vec3.scale(vec3.create(),c,t/o);return mat4.multiply(n,mat4.fromZRotation(n,i),mat4.fromTranslation(mat4.create(),m)),slice.transform(n,r)}},a)};module.exports=extrudeGeom2;
},{"../../geometries/geom2":25,"../../maths/mat4":142,"../../maths/vec3":221,"./extrudeFromSlices":307,"./slice":325}],311:[function(require,module,exports){
const geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudePath2=(e,r)=>{if(!r.isClosed)throw new Error("extruded path must be closed");const t=path2.toPoints(r),o=geom2.fromPoints(t);return extrudeLinearGeom2(e,o)};module.exports=extrudePath2;
},{"../../geometries/geom2":25,"../../geometries/path2":61,"./extrudeLinearGeom2":310}],312:[function(require,module,exports){
const flatten=require("../../utils/flatten"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),extrudeRectangularPath2=require("./extrudeRectangularPath2"),extrudeRectangularGeom2=require("./extrudeRectangularGeom2"),extrudeRectangular=(e,...t)=>{const{size:r,height:a}=Object.assign({},{size:1,height:1},e);if(0===(t=flatten(t)).length)throw new Error("wrong number of arguments");if(r<=0)throw new Error("size must be positive");if(a<=0)throw new Error("height must be positive");const u=t.map(t=>path2.isA(t)?extrudeRectangularPath2(e,t):geom2.isA(t)?extrudeRectangularGeom2(e,t):t);return 1===u.length?u[0]:u};module.exports=extrudeRectangular;
},{"../../geometries/geom2":25,"../../geometries/path2":61,"../../utils/flatten":396,"./extrudeRectangularGeom2":313,"./extrudeRectangularPath2":314}],313:[function(require,module,exports){
const{area:area}=require("../../maths/utils"),geom2=require("../../geometries/geom2"),path2=require("../../geometries/path2"),expand=require("../expansions/expand"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeRectangularGeom2=(e,r)=>{const{size:t,height:o}=Object.assign({},{size:1,height:1},e);e.delta=t,e.offset=[0,0,o];const a=geom2.toOutlines(r);if(0===a.length)throw new Error("the given geometry cannot be empty");const n=a.map(r=>(area(r)<0&&r.reverse(),expand(e,path2.fromPoints({closed:!0},r)))).reduce((e,r)=>e.concat(geom2.toSides(r)),[]),i=geom2.create(n);return extrudeLinearGeom2(e,i)};module.exports=extrudeRectangularGeom2;
},{"../../geometries/geom2":25,"../../geometries/path2":61,"../../maths/utils":168,"../expansions/expand":288,"./extrudeLinearGeom2":310}],314:[function(require,module,exports){
const path2=require("../../geometries/path2"),expand=require("../expansions/expand"),extrudeLinearGeom2=require("./extrudeLinearGeom2"),extrudeRectangularPath2=(e,t)=>{const{size:r,height:n}=Object.assign({},{size:1,height:1},e);if(e.delta=r,e.offset=[0,0,n],0===path2.toPoints(t).length)throw new Error("the given geometry cannot be empty");const a=expand(e,t);return extrudeLinearGeom2(e,a)};module.exports=extrudeRectangularPath2;
},{"../../geometries/path2":61,"../expansions/expand":288,"./extrudeLinearGeom2":310}],315:[function(require,module,exports){
const{TAU:TAU}=require("../../maths/constants"),mat4=require("../../maths/mat4"),{mirrorX:mirrorX}=require("../transforms/mirror"),geom2=require("../../geometries/geom2"),slice=require("./slice"),extrudeFromSlices=require("./extrudeFromSlices"),extrudeRotate=(e,t)=>{const r={segments:12,startAngle:0,angle:TAU,overflow:"cap"};let{segments:a,startAngle:o,angle:s,overflow:m}=Object.assign({},r,e);if(a<3)throw new Error("segments must be greater then 3");o=Math.abs(o)>TAU?o%TAU:o,s=Math.abs(s)>TAU?s%TAU:s;let n=o+s;if((n=Math.abs(n)>TAU?n%TAU:n)<o){const e=o;o=n,n=e}let l=n-o;if(l<=0&&(l=TAU),Math.abs(l)<TAU){const e=TAU/a;a=Math.floor(Math.abs(l)/e),Math.abs(l)>a*e&&a++}let i=geom2.toSides(t);if(0===i.length)throw new Error("the given geometry cannot be empty");const c=i.filter(e=>e[0][0]<0),g=i.filter(e=>e[0][0]>=0);c.length>0&&g.length>0&&"cap"===m&&(c.length>g.length?(i=i.map(e=>{let t=e[0],r=e[1];return[t=[Math.min(t[0],0),t[1]],r=[Math.min(r[0],0),r[1]]]}),t=geom2.create(i),t=mirrorX(t)):g.length>=c.length&&(i=i.map(e=>{let t=e[0],r=e[1];return[t=[Math.max(t[0],0),t[1]],r=[Math.max(r[0],0),r[1]]]}),t=geom2.create(i)));const h=l/a,u=Math.abs(l)<TAU,A=slice.fromSides(geom2.toSides(t));slice.reverse(A,A);const f=mat4.create();return extrudeFromSlices(e={numberOfSlices:a+1,capStart:u,capEnd:u,close:!u,callback:(e,t,r)=>{let s=h*t+o;return l===TAU&&t===a&&(s=o),mat4.multiply(f,mat4.fromZRotation(f,s),mat4.fromXRotation(mat4.create(),TAU/4)),slice.transform(f,r)}},A)};module.exports=extrudeRotate;
},{"../../geometries/geom2":25,"../../maths/constants":93,"../../maths/mat4":142,"../transforms/mirror":361,"./extrudeFromSlices":307,"./slice":325}],316:[function(require,module,exports){
const{EPS:EPS}=require("../../maths/constants"),vec3=require("../../maths/vec3"),poly3=require("../../geometries/poly3"),slice=require("./slice"),gcd=(e,t)=>e===t?e:e<t?gcd(t,e):1===t?1:0===t?e:gcd(t,e%t),lcm=(e,t)=>e*t/gcd(e,t),repartitionEdges=(e,t)=>{const r=e/t.length;if(1===r)return t;const s=vec3.fromValues(r,r,r),c=[];return t.forEach(e=>{const t=vec3.subtract(vec3.create(),e[1],e[0]);vec3.divide(t,t,s);let l=e[0];for(let e=1;e<=r;++e){const e=vec3.add(vec3.create(),l,t);c.push([l,e]),l=e}}),c},EPSAREA=EPS*EPS/2*Math.sin(Math.PI/3),extrudeWalls=(e,t)=>{let r=slice.toEdges(e),s=slice.toEdges(t);if(r.length!==s.length){const e=lcm(r.length,s.length);e!==r.length&&(r=repartitionEdges(e,r)),e!==s.length&&(s=repartitionEdges(e,s))}const c=[];return r.forEach((e,t)=>{const r=s[t],l=poly3.create([e[0],e[1],r[1]]),o=poly3.measureArea(l);Number.isFinite(o)&&o>EPSAREA&&c.push(l);const n=poly3.create([e[0],r[1],r[0]]),i=poly3.measureArea(n);Number.isFinite(i)&&i>EPSAREA&&c.push(n)}),c};module.exports=extrudeWalls;
},{"../../geometries/poly3":78,"../../maths/constants":93,"../../maths/vec3":221,"./slice":325}],317:[function(require,module,exports){
module.exports={extrudeFromSlices:require("./extrudeFromSlices"),extrudeLinear:require("./extrudeLinear"),extrudeRectangular:require("./extrudeRectangular"),extrudeRotate:require("./extrudeRotate"),extrudeHelical:require("./extrudeHelical"),project:require("./project"),slice:require("./slice")};
},{"./extrudeFromSlices":307,"./extrudeHelical":308,"./extrudeLinear":309,"./extrudeRectangular":312,"./extrudeRotate":315,"./project":318,"./slice":325}],318:[function(require,module,exports){
const flatten=require("../../utils/flatten"),aboutEqualNormals=require("../../maths/utils/aboutEqualNormals"),plane=require("../../maths/plane"),mat4=require("../../maths/mat4"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),poly3=require("../../geometries/poly3"),measureEpsilon=require("../../measurements/measureEpsilon"),unionGeom2=require("../booleans/unionGeom2"),projectGeom3=(e,o)=>{const r=plane.fromNormalAndPoint(plane.create(),e.axis,e.origin);if(Number.isNaN(r[0])||Number.isNaN(r[1])||Number.isNaN(r[2])||Number.isNaN(r[3]))throw new Error("project: invalid axis or origin");const t=measureEpsilon(o),a=t*t*Math.sqrt(3)/4;if(0===t)return geom2.create();const n=geom3.toPolygons(o);let s=[];for(let e=0;e<n.length;e++){const o=n[e].vertices.map(e=>plane.projectionOfPoint(r,e)),t=poly3.create(o),i=poly3.plane(t);aboutEqualNormals(r,i)&&(poly3.measureArea(t)<a||s.push(t))}if(!aboutEqualNormals(r,[0,0,1])){const e=mat4.fromVectorRotation(mat4.create(),r,[0,0,1]);s=s.map(o=>poly3.transform(e,o))}const i=(s=s.sort((e,o)=>poly3.measureArea(o)-poly3.measureArea(e))).map(e=>geom2.fromPoints(e.vertices));return unionGeom2(i)},project=(e,...o)=>{const{axis:r,origin:t}=Object.assign({},{axis:[0,0,1],origin:[0,0,0]},e);if(0===(o=flatten(o)).length)throw new Error("wrong number of arguments");e={axis:r,origin:t};const a=o.map(o=>geom3.isA(o)?projectGeom3(e,o):o);return 1===a.length?a[0]:a};module.exports=project;
},{"../../geometries/geom2":25,"../../geometries/geom3":40,"../../geometries/poly3":78,"../../maths/mat4":142,"../../maths/plane":162,"../../maths/utils/aboutEqualNormals":166,"../../measurements/measureEpsilon":262,"../../utils/flatten":396,"../booleans/unionGeom2":285}],319:[function(require,module,exports){
const plane=require("../../../maths/plane"),vec3=require("../../../maths/vec3"),calculatePlane=e=>{const c=e.edges;if(c.length<3)throw new Error("slices must have 3 or more edges to calculate a plane");const a=c.reduce((e,c)=>vec3.add(vec3.create(),e,c[0]),vec3.create());let t;vec3.scale(a,a,1/c.length);let l=0;c.forEach(e=>{if(!vec3.equals(e[0],e[1])){const c=vec3.squaredDistance(a,e[0]);c>l&&(t=e,l=c)}});const r=c.find(e=>vec3.equals(e[1],t[0]));return plane.fromPoints(plane.create(),r[0],t[0],t[1])};module.exports=calculatePlane;
},{"../../../maths/plane":162,"../../../maths/vec3":221}],320:[function(require,module,exports){
const create=require("./create"),vec3=require("../../../maths/vec3"),clone=(...e)=>{let c,r;return 1===e.length?(c=create(),r=e[0]):(c=e[0],r=e[1]),c.edges=r.edges.map(e=>[vec3.clone(e[0]),vec3.clone(e[1])]),c};module.exports=clone;
},{"../../../maths/vec3":221,"./create":321}],321:[function(require,module,exports){
const create=e=>(e||(e=[]),{edges:e});module.exports=create;
},{}],322:[function(require,module,exports){
const vec3=require("../../../maths/vec3"),equals=(e,s)=>{const r=e.edges,t=s.edges;return r.length===t.length&&r.reduce((e,s,r)=>{const u=t[r],c=vec3.squaredDistance(s[0],u[0]);return e&&c<Number.EPSILON},!0)};module.exports=equals;
},{"../../../maths/vec3":221}],323:[function(require,module,exports){
const vec3=require("../../../maths/vec3"),create=require("./create"),fromPoints=e=>{if(!Array.isArray(e))throw new Error("the given points must be an array");if(e.length<3)throw new Error("the given points must contain THREE or more points");const r=[];let t=e[e.length-1];return e.forEach(e=>{2===e.length&&r.push([vec3.fromVec2(vec3.create(),t),vec3.fromVec2(vec3.create(),e)]),3===e.length&&r.push([t,e]),t=e}),create(r)};module.exports=fromPoints;
},{"../../../maths/vec3":221,"./create":321}],324:[function(require,module,exports){
const vec3=require("../../../maths/vec3"),create=require("./create"),fromSides=e=>{if(!Array.isArray(e))throw new Error("the given sides must be an array");const r=[];return e.forEach(e=>{r.push([vec3.fromVec2(vec3.create(),e[0]),vec3.fromVec2(vec3.create(),e[1])])}),create(r)};module.exports=fromSides;
},{"../../../maths/vec3":221,"./create":321}],325:[function(require,module,exports){
module.exports={calculatePlane:require("./calculatePlane"),clone:require("./clone"),create:require("./create"),equals:require("./equals"),fromPoints:require("./fromPoints"),fromSides:require("./fromSides"),isA:require("./isA"),reverse:require("./reverse"),toEdges:require("./toEdges"),toPolygons:require("./toPolygons"),toString:require("./toString"),transform:require("./transform")};
},{"./calculatePlane":319,"./clone":320,"./create":321,"./equals":322,"./fromPoints":323,"./fromSides":324,"./isA":326,"./reverse":328,"./toEdges":329,"./toPolygons":330,"./toString":331,"./transform":332}],326:[function(require,module,exports){
const isA=e=>!!(e&&"object"==typeof e&&"edges"in e&&Array.isArray(e.edges));module.exports=isA;
},{}],327:[function(require,module,exports){
const vec3=require("../../../maths/vec3"),create=require("./create"),repair=e=>{if(!e.edges)return e;let t=e.edges;const r=new Map,c=new Map;(t=t.filter(e=>!vec3.equals(e[0],e[1]))).forEach(e=>{const t=e[0].toString(),s=e[1].toString();r.set(t,e[0]),r.set(s,e[1]),c.set(t,(c.get(t)||0)+1),c.set(s,(c.get(s)||0)-1)});const s=[],a=[];return c.forEach((e,t)=>{e<0&&s.push(t),e>0&&a.push(t)}),s.forEach(e=>{const c=r.get(e);let s,n=1/0;a.forEach(e=>{const t=r.get(e),a=vec3.distance(c,t);a<n&&(n=a,s=t)}),console.warn(`slice.repair: repairing vertex gap ${c} to ${s} distance ${n}`),t=t.map(t=>t[0].toString()===e?[s,t[1]]:t[1].toString()===e?[t[0],s]:t)}),create(t)};module.exports=repair;
},{"../../../maths/vec3":221,"./create":321}],328:[function(require,module,exports){
const create=require("./create"),reverse=(...e)=>{let r,t;return 1===e.length?(r=create(),t=e[0]):(r=e[0],t=e[1]),r.edges=t.edges.map(e=>[e[1],e[0]]),r};module.exports=reverse;
},{"./create":321}],329:[function(require,module,exports){
const toEdges=e=>e.edges;module.exports=toEdges;
},{}],330:[function(require,module,exports){
const poly3=require("../../../geometries/poly3"),earcut=require("../earcut"),PolygonHierarchy=require("../earcut/polygonHierarchy"),toPolygons=o=>{const e=new PolygonHierarchy(o),r=[];return e.roots.forEach(({solid:o,holes:t})=>{let l=o.length;const n=[];t.forEach((o,e)=>{n.push(l),l+=o.length});const s=[o,...t].flat(),c=s.flat(),a=o=>e.to3D(s[o]),h=earcut(c,n);for(let o=0;o<h.length;o+=3){const t=h.slice(o,o+3).map(a);r.push(poly3.fromPointsAndPlane(t,e.plane))}}),r};module.exports=toPolygons;
},{"../../../geometries/poly3":78,"../earcut":301,"../earcut/polygonHierarchy":305}],331:[function(require,module,exports){
const vec3=require("../../../maths/vec3"),edgesToString=e=>e.reduce((e,t)=>e+=`[${vec3.toString(t[0])}, ${vec3.toString(t[1])}], `,""),toString=e=>`[${edgesToString(e.edges)}]`;module.exports=toString;
},{"../../../maths/vec3":221}],332:[function(require,module,exports){
const vec3=require("../../../maths/vec3"),create=require("./create"),transform=(e,r)=>{const t=r.edges.map(r=>[vec3.transform(vec3.create(),r[0],e),vec3.transform(vec3.create(),r[1],e)]);return create(t)};module.exports=transform;
},{"../../../maths/vec3":221,"./create":321}],333:[function(require,module,exports){
const flatten=require("../../utils/flatten"),areAllShapesTheSameType=require("../../utils/areAllShapesTheSameType"),geom2=require("../../geometries/geom2"),geom3=require("../../geometries/geom3"),path2=require("../../geometries/path2"),hullPath2=require("./hullPath2"),hullGeom2=require("./hullGeom2"),hullGeom3=require("./hullGeom3"),hull=(...e)=>{if(0===(e=flatten(e)).length)throw new Error("wrong number of arguments");if(!areAllShapesTheSameType(e))throw new Error("only hulls of the same type are supported");const l=e[0];return path2.isA(l)?hullPath2(e):geom2.isA(l)?hullGeom2(e):geom3.isA(l)?hullGeom3(e):l};module.exports=hull;
},{"../../geometries/geom2":25,"../../geometries/geom3":40,"../../geometries/path2":61,"../../utils/areAllShapesTheSameType":394,"../../utils/flatten":396,"./hullGeom2":335,"./hullGeom3":336,"./hullPath2":337}],334:[function(require,module,exports){