This repository has been archived by the owner on Aug 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplayer.html
executable file
·891 lines (889 loc) · 456 KB
/
player.html
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
<!--
Materials Informatics HTML5 Player:
in-browser ultra-fast and lightweight
renderer of crystallographic data
Author: Evgeny Blokhin /
Tilde Materials Informatics
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=Edge" />
<meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0" />
<title>Materials Informatics Web-viewer</title>
<style>
body{margin:0;padding:0;overflow:hidden;font-family:Georgia,serif;}
html, body{height:100%;-webkit-text-size-adjust:100%;text-size-adjust:100%;}
#player{z-index:2;position:fixed;cursor:move;}
#infopanel{position:fixed;top:20px;left:8px;width:150px;height:150px;text-align:left;z-index:3;line-height:22px;font-size:0.9em;color:#888;}
#zoompanel{position:fixed;top:90px;right:8px;width:50px;height:102px;z-index:3;cursor:pointer;background:no-repeat url(data:image/gif;base64,R0lGODlhMgBmAKEBAAAAAP///8zMzP///yH5BAEKAAMALAAAAAAyAGYAAAL+nI+py+0uopzi2UtzvhxNLHXWJ4YiY55Gqg6sRzVvNx+bHKk5FPNV+cOReMBR77EzgoY+0LK2SOI4N2MQdfVBo9mEFHlUTqlhcNd2xjLFXLTmDWd+Ye64vepK5+v3/nWOxudnR4clOAhX2Ea2Bjb2BPioEMnVSGTIuDVJqQljiSmpRblpBqnnNZp3Kki2ZNW5khq7qgoL62bW+akmunqLqocHLFvZctiyq1VLu/m7zKcj7DlTljmoRoyd2Gs8zczaHb78La6dXd6cjC6kvl7p7D4LH19LH21cbT+8rT/+fk7jVruA5DyVm2ewG8BQAd0t3BMPIMJSrexle9iQjcWCVBiLXOoHkSG9LR1PcCqoMFgQRH4UkZLHkl/Il+Ni4jl5yKYclTl1SsEJ0+dOkRuJjlSJMtqpkow+9uPIlKLTo7QmWmkaUWJSqU/QDRwmLt+rlGJzoYxRlh2xKmnVvniTbmvNOGrDETIr12tbkP749sobVprfY4P/Aba7F+RXxT8KAAA7);}
#tunebox{position:fixed;top:50%;right:6px;width:40px;height:80px;margin-top:-40px;z-index:3;cursor:pointer;background:url(data:image/gif;base64,R0lGODlhKABQAMIEAMvLy8zMzM3Nzc7Ozv///////////////yH5BAEKAAQALAAAAAAoAFAAAAP+SLrc/jDKSau9OOgtdsCT94GXSGbbiWpqmbaVB1cdO1PyLeV6xPeOmg3oMBGLr2Pjp1Qwm09l9DglGpvOau+KJXgE3WwSKxp1uSrzY4AGqSHltKX8xoHn8dgQT/eNL2x0gnsng306gYJhi4yNjo+QkU5eHyOVlV6TmW6Um5iZlpp8hqR/S6WobUipqCF1bq8Lqih6M1MshCS5DLMum362pmK7tDhmHgCUKcu4saeiNpafnbcyu8e/zTvWrybHl8Syl8rS2FnkcDnfoufUzu7i0WPqwrzves69eNudMFr9LcKRu2fMlUB89w4ae/ev4DaFBhOyKrVwoqJa0TyF6gcMURZHjZrkSRpJ0lECADs=) no-repeat;}
#optionpanel{position:fixed;bottom:4px;left:0;width:100%;height:20px;z-index:3;text-align:center;font-size:1.1em;}
#optionpanel input{margin:4px 2px 0 2px;cursor:pointer;}
#optionpanel label{line-height:22px;vertical-align:top;cursor:pointer;color:#666;}
#landing{display:none;position:fixed;left:0;top:0;right:0;bottom:0;height:auto;z-index:5;background:#fff;margin:0;text-align:center;font-size:1.25em;padding:10px;line-height:1.8em;}
#landing a{color:#666;text-decoration:none;border-bottom:1px solid #999;}
h1{margin:10px auto 35px;font-size:1.5em;color:#999;font-weight:normal;}
#legend{width:290px;margin:20px auto 0;border-radius:15px;background:#f0f0f0;color:#666;padding:5px;}
#triangle{width:0;height:0;margin:-2px auto 20px;border-left:20px solid transparent;border-right:20px solid transparent;border-top:20px solid #f0f0f0;}
#notifybox{display:none;z-index:7;position:fixed;top:4px;left:4px;width:500px;background:#333;color:#fff;font-weight:bold;border-radius:5px;}
#cross{float:right;width:24px;height:24px;font-size:10px;text-align:center;cursor:pointer;background:url(data:image/gif;base64,R0lGODlhEAAQAJEAAAAAAP///1VVVf///yH5BAEAAAMALAAAAAAQABAAAAIjnI+py6L+BDRy0gqxHVqvLjGcJ3Yl+IEhQpLX+m7wMYv2PRQAOw==) center center no-repeat;}
#message{margin:20px;}
#fileapi{color:#999;}
#versionbox{display:none;z-index:6;position:fixed;bottom:2px;right:2px;font-size:0.9em;color:#999;}
#cmdbox{display:none;z-index:4;position:fixed;bottom:2px;left:4px;cursor:pointer;font-size:1.1em;color:#999;border-bottom:1px solid #999;}
#ribbon{display:none;}
@media screen and (min-width:1200px){
#cmdbox{display:block;}
#versionbox{display:block;}
}
#preloader{z-index:1;position:fixed;top:50%;left:50%;margin-left:-63px;width:125px;height:60px;font-size:10px;}
#preloader > div {height:100%;width:15px;display:inline-block;margin:0 5px;background:#666;-webkit-animation:stretchdelay 1.2s infinite ease-in-out;animation:stretchdelay 1.2s infinite ease-in-out;}
#preloader > div.rect2 {-webkit-animation-delay:-1.1s;animation-delay:-1.1s;}
#preloader > div.rect3 {-webkit-animation-delay:-1.0s;animation-delay:-1.0s;}
#preloader > div.rect4 {-webkit-animation-delay:-0.9s;animation-delay:-0.9s;}
#preloader > div.rect5 {-webkit-animation-delay:-0.8s;animation-delay:-0.8s;}
@-webkit-keyframes stretchdelay {
0%, 40%, 100% { -webkit-transform: scaleY(0.4) }
20% { -webkit-transform: scaleY(1.0) }}
@keyframes stretchdelay {
0%, 40%, 100% {
transform: scaleY(0.4);
-webkit-transform: scaleY(0.4);
} 20% {
transform: scaleY(1.0);
-webkit-transform: scaleY(1.0);
}}
.github-fork-ribbon {position:absolute;padding:2px 0;background-color:#f00;background-image:-webkit-gradient(linear, left top, left bottom, from(rgba(0, 0, 0, 0)), to(rgba(0, 0, 0, 0.15)));background-image:-webkit-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));background-image:-moz-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));background-image:-ms-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));background-image:-o-linear-gradient(top, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));background-image:linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15));-webkit-box-shadow:0 2px 3px 0 rgba(0, 0, 0, 0.5);-moz-box-shadow:0 2px 3px 0 rgba(0, 0, 0, 0.5);box-shadow:0 2px 3px 0 rgba(0, 0, 0, 0.5);font:500 9px "Helvetica Neue", Helvetica, Arial, sans-serif;z-index:9999;pointer-events:auto;}
.github-fork-ribbon a, .github-fork-ribbon a:hover {color:#fff;text-decoration:none;text-shadow:0 -1px rgba(0, 0, 0, 0.5);text-align:center;width:100px;line-height:12px;display:inline-block;padding:2px 0;border-width:1px 0;border-style:dotted;border-color:#fff;border-color:rgba(255, 255, 255, 1);}
.github-fork-ribbon-wrapper {width:100px;height:100px;position:absolute;overflow:hidden;top:0;z-index:9999;pointer-events:none;}
.github-fork-ribbon-wrapper.right {right:0;}
.github-fork-ribbon-wrapper.right .github-fork-ribbon {top:16px;right:-22px;-webkit-transform:rotate(45deg);-moz-transform:rotate(45deg);-ms-transform:rotate(45deg);-o-transform:rotate(45deg);transform:rotate(45deg);}
</style>
</head>
<body>
<div id="ribbon" class="github-fork-ribbon-wrapper right"><div class="github-fork-ribbon"><a href="https://github.com/tilde-lab/player.html" target="_blank" rel="noopener noreferrer">See on GitHub</a></div>
</div>
<div id="preloader"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div>
<script type="text/javascript">if(typeof window.Int16Array!=='function'||typeof window.Float32Array!=='function')document.write("<scri"+"pt src='https://tilde.pro/typedarray.min.js'></scr"+"ipt>")</script>
<script type="text/javascript">
/*
RequireJS domReady 2.0.1 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/requirejs/domReady for details
*/
'use strict';var player=function(ea){function ba(s){if(Z[s])return Z[s].exports;var m=Z[s]={exports:{},id:s,loaded:!1};ea[s].call(m.exports,m,m.exports,ba);m.loaded=!0;return m.exports}var Z={};ba.m=ea;ba.c=Z;ba.p="";return ba(0)}([function(ea,ba,Z){!function(){var s=[Z(1),Z(4),Z(6),Z(3)];(function(m,k,w,b){function a(a){a=a||window.event;a.cancelBubble?a.cancelBubble=!0:(a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault())}function c(a){if(window.parent&&window.parent.wmgui&&
window.parent.wmgui.notify)window.parent.wmgui.notify(a);else{var c=document.getElementById("notifybox"),b=document.getElementById("message");c.style.display="block";b.innerHTML="";setTimeout(function(){b.innerHTML=a},250)}}function d(a,c){var b=document.createElement("div");b.setAttribute("id",a);c&&(b.innerHTML=c);document.body.appendChild(b);return b}function e(a,c,b){b||(b=14540253);var d=new A.Geometry;d.vertices.push(new A.Vector3(a[0],a[1],a[2]));d.vertices.push(new A.Vector3(c[0],c[1],c[2]));
a=new A.LineBasicMaterial({color:b});z.atombox.add(new A.Line(d,a))}function f(a){var c=document.createElement("canvas"),b=c.getContext("2d"),d=3.5*b.measureText(a).width;c.width=d;c.height=30;b.font="normal 30px Arial";b.textAlign="center";b.textBaseline="middle";b.fillStyle="W"==z.colorset?"#000000":"#FFFFFF";b.fillText(a,c.width/2,c.height/2);a=new A.Texture(c);a.needsUpdate=!0;a=new A.SpriteMaterial({map:a,depthTest:!1});a=new A.Sprite(a);a.renderOrder=1;c=new A.Object3D;a.scale.set(d,30,1);c.add(a);
c.name="label";return c}function g(){z.loaded=!0;z.container=d("player");z.scene=new A.Scene;z.camera=new A.PerspectiveCamera(45,window.innerWidth/window.innerHeight,.1,2E4);z.camera.position.set(0,0,1800);var c=new A.AmbientLight(10066329);z.scene.add(c);c=new A.PointLight(6710886,1);c.position.set(1500,1500,1500);z.scene.add(c);z.renderer=z.webgl?new A.WebGLRenderer({antialias:!0,alpha:!0}):new A.CanvasRenderer;"W"==z.colorset?z.renderer.setClearColor(16777215,1):z.renderer.setClearColor(0,1);z.renderer.setPixelRatio(window.devicePixelRatio);
z.renderer.setSize(window.innerWidth,window.innerHeight);z.container.appendChild(z.renderer.domElement);d("zoompanel").onclick=function(c){a(c);c=c.pageY?c.pageY:c.clientY;var b=document.getElementById("zoompanel").offsetTop;z.camera.fov-=7.5*(50>c-b?1:-1);z.camera.updateProjectionMatrix()};z.controls=new A.TrackballControls(z.camera);z.controls.rotateSpeed=7.5;z.controls.staticMoving=!0;h()}function h(){var a=z.scene.getObjectByName("atombox");if(a){z.scene.remove(a);var c=a.children.length-1;for(c;0<=
c;c--){var b=a.children[c];b.geometry&&b.geometry.dispose();b.material&&b.material.dispose();b.dispose&&b.dispose()}z.controls.reset()}z.atombox=new A.Object3D;(a=document.getElementById("infopanel"))&&a.parentNode.removeChild(a);z.obj3d.descr&&d("infopanel","<span style=color:#900><i>a</i>="+(Math.round(1E3*parseFloat(z.obj3d.descr.a))/1E3).toFixed(3)+"Å</span><br /><span style=color:#090><i>b</i>="+(Math.round(1E3*parseFloat(z.obj3d.descr.b))/1E3).toFixed(3)+"Å</span><br /><span style=color:#09f><i>c</i>="+
(Math.round(1E3*parseFloat(z.obj3d.descr.c))/1E3).toFixed(3)+"Å</span><br /><i>α</i>="+(Math.round(100*parseFloat(z.obj3d.descr.alpha))/100).toFixed(2)+"°<br /><i>β</i>="+(Math.round(100*parseFloat(z.obj3d.descr.beta))/100).toFixed(2)+"°<br /><i>γ</i>="+(Math.round(100*parseFloat(z.obj3d.descr.gamma))/100).toFixed(2)+"°<br />");(a=document.getElementById("optionpanel"))&&a.parentNode.removeChild(a);a=d("optionpanel","<input type=radio name=optionpanel class=optionpanel id=optionpanel_empty /><label for=optionpanel_empty>none</label> <input type=radio name=optionpanel class=optionpanel id=optionpanel_S checked=checked /><label for=optionpanel_S>elements</label> <input type=radio name=optionpanel class=optionpanel id=optionpanel_N /><label for=optionpanel_N>id's</label>");
if(Object.keys(z.obj3d.overlayed).length)for(var h in z.obj3d.overlayed)a.innerHTML+=" <input type=radio name=optionpanel class=optionpanel id=optionpanel_"+h+" /><label for=optionpanel_"+h+">"+z.obj3d.overlayed[h]+"</label>",z.available_overlays.push(h);a=document.getElementsByClassName("optionpanel");for(h=a.length-1;0<=h;h--)a[h].onclick=function(){var a=this.id.replace("optionpanel_","");if(-1!==z.available_overlays.indexOf(a)){var c=z.scene.getObjectByName("atombox"),c=c.children,b=c.filter(function(a){return"label"==
a.name}),d=0,e=b.length;for(d;d<e;d++)z.atombox.remove(b[d]),z.scene.remove(b[d]);if("empty"!==a){c=c.filter(function(a){return"atom"==a.name});e=c.length;for(d=0;d<e;d++)b=f(c[d].overlays[a]),b.position.set(c[d].position.x,c[d].position.y,c[d].position.z),z.atombox.add(b);z.current_overlay=a}}z.renderer.render(z.scene,z.camera)};z.current_overlay=z.default_overlay;c=z.webgl?{w:10,h:8}:{w:8,h:6};h=0;a=z.obj3d.atoms.length;for(h;h<a;h++){var b=parseInt(100*z.obj3d.atoms[h].x),g=parseInt(100*z.obj3d.atoms[h].y),
n=parseInt(100*z.obj3d.atoms[h].z),l=new A.Mesh(new A.SphereBufferGeometry(65*z.obj3d.atoms[h].r,c.w,c.h),new A.MeshLambertMaterial({color:z.obj3d.atoms[h].c,overdraw:.75}));l.position.set(b,g,n);l.name="atom";l.overlays=z.obj3d.atoms[h].overlays;z.atombox.add(l);"empty"!==z.current_overlay&&(l=f(l.overlays[z.current_overlay]),l.position.set(b,g,n),z.atombox.add(l))}if(z.obj3d.cell.length){var r,a=[];for(h=0;3>h;h++)c=Math.round(1E3*parseFloat(z.obj3d.cell[h][0]))/10,b=Math.round(1E3*parseFloat(z.obj3d.cell[h][1]))/
10,g=Math.round(1E3*parseFloat(z.obj3d.cell[h][2]))/10,a.push([c,b,g]),0==h?r=10027008:1==h?r=39168:2==h&&(r=39423),z.atombox.add(new A.ArrowHelper((new A.Vector3(c,b,g)).normalize(),new A.Vector3(0,0,0),Math.sqrt(c*c+b*b+g*g),r,75,10));h=[a[0][0]+a[1][0],a[0][1]+a[1][1],a[0][2]+a[1][2]];c=[a[0][0]+a[2][0],a[0][1]+a[2][1],a[0][2]+a[2][2]];b=[h[0]+a[2][0],h[1]+a[2][1],h[2]+a[2][2]];g=[a[1][0]+a[2][0],a[1][1]+a[2][1],a[1][2]+a[2][2]];r=[];r.push([a[0],h]);r.push([a[0],c]);r.push([a[1],g]);r.push([a[1],
h]);r.push([a[2],g]);r.push([a[2],c]);r.push([h,b]);r.push([c,b]);r.push([b,g]);h=0;a=r.length;for(h;h<a;h++)e(r[h][0],r[h][1])}z.atombox.name="atombox";z.scene.add(z.atombox);u()}function n(){z.loaded&&(z.camera.aspect=window.innerWidth/window.innerHeight,z.camera.updateProjectionMatrix(),z.renderer.setSize(window.innerWidth,window.innerHeight),z.controls.handleResize(),u())}function u(){K(u);z.renderer.render(z.scene,z.camera);z.controls.update()}function r(){var a=document.location.hash.substr(1);
if(-1==a.indexOf("://"))return z.loaded||t(),c("Error: not a valid url!");I(a)}function t(){if(z.local_supported){var a=document.getElementById("landing");"B"==z.colorset&&(a.style.background="#222");a.style.display="block";document.getElementById("ribbon").style.display="block"}else q()}function x(c){a(c);c=c.pageY?c.pageY:c.clientY;var b=document.getElementById("tunebox").offsetTop;40>c-b?(c=p("colorset"))&&"W"!=c?l("colorset","W"):l("colorset","B"):(c=p("forcewebgl"))&&"Y"!=c?l("forcewebgl","Y"):
l("forcewebgl","N");document.location.reload()}function l(a,c){document.cookie=c?a+"="+c.toString()+"; expires=Fri, 31 Dec 2100 23:59:59 GMT":a+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT"}function p(a){return"forcewebgl"==a?document.cookie.replace(/(?:(?:^|.*;\s*)forcewebgl\s*\=\s*([^;]*).*$)|^.*$/,"$1"):"colorset"==a?document.cookie.replace(/(?:(?:^|.*;\s*)colorset\s*\=\s*([^;]*).*$)|^.*$/,"$1"):!1}function q(c){a(c);C(z.sample,!1)}function I(a){var b=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");
b.onreadystatechange=function(){4==b.readyState&&(200==b.status?C(b.responseText,!0):(c("Error: HTTP "+b.status+" status received during retrieving data from the server"),z.loaded||t()))};b.open("GET",a);b.send(1)}function C(a,c){z.obj3d=m.to_player(a);z.obj3d?(document.getElementById("landing").style.display="none",document.getElementById("ribbon").style.display="none",z.loaded?h():g(),z.obj3d.info&&(document.title=z.obj3d.info)):z.loaded||t()}function y(b){a(b);if(1<b.dataTransfer.files.length)return c("Error: only one file at the time may be rendered!");
b=b.dataTransfer.files[0];if(!b||!b.size)return c("Error: file cannot be read (unaccessible?)");var d=new FileReader;d.onloadend=function(a){C(a.target.result,!1)};d.abort=function(){c("Error: file reading has been cancelled!")};d.onerror=function(a){c("Error: file reading has been cancelled: "+a.target.error.name)};d.readAsText(b)}function B(c){a(c);c.dataTransfer.dropEffect="copy"}var z={version:"0.16.3",loaded:!1,container:null,stats:null,camera:null,scene:null,renderer:null,controls:null,atombox:null,
available_overlays:["empty","S","N"],default_overlay:"S"};z.current_overlay=z.default_overlay;z.obj3d=!1;z.local_supported=window.File&&window.FileReader&&window.FileList&&window.Blob;z.webgl=function(){try{var a=document.createElement("canvas");return!(!window.WebGLRenderingContext||!a.getContext("webgl")&&!a.getContext("experimental-webgl"))}catch(c){return!1}}();z.colorset="W";z.sample="data_example\n_cell_length_a 24\n_cell_length_b 5.91\n_cell_length_c 5.85\n_cell_angle_alpha 90\n_cell_angle_beta 90\n_cell_angle_gamma 90\n_symmetry_space_group_name_H-M 'P1'\nloop_\n_symmetry_equiv_pos_as_xyz\nx,y,z\nloop_\n_atom_site_label\n_atom_site_type_symbol\n_atom_site_fract_x\n_atom_site_fract_y\n_atom_site_fract_z\n_atom_site_charge\nO1 O 0.425 0.262 0.009 -2.0\nO2 O -0.425 0.262 0.009 -2.0\nH3 H 0.444 0.258 0.154 1.0\nH4 H -0.444 0.258 0.154 1.0\nH5 H 0.396 0.124 0.012 1.0\nH6 H -0.396 0.124 0.012 1.0\nO7 O 0.425 0.236 0.510 -2.0\nO8 O -0.425 0.236 0.510 -2.0\nH9 H 0.444 0.239 0.656 1.0\nH10 H -0.444 0.239 0.656 1.0\nH11 H 0.396 0.374 0.512 1.0\nH12 H -0.396 0.374 0.512 1.0\nSr13 Sr 0.342 0.964 0.467 2.0\nSr14 Sr -0.342 0.964 0.467 2.0\nSr15 Sr 0.342 0.535 0.967 2.0\nSr16 Sr -0.342 0.535 0.967 2.0\nO17 O 0.348 0.971 0.019 -2.0\nO18 O -0.348 0.971 0.019 -2.0\nO19 O 0.348 0.528 0.519 -2.0\nO20 O -0.348 0.528 0.519 -2.0\nO21 O 0.263 0.803 0.701 -2.0\nO22 O -0.263 0.803 0.701 -2.0\nO23 O 0.264 0.695 0.200 -2.0\nO24 O -0.264 0.695 0.200 -2.0\nZr25 Zr 0.261 0.000 0.998 4.0\nZr26 Zr -0.261 0.000 0.998 4.0\nZr27 Zr 0.261 0.499 0.498 4.0\nZr28 Zr -0.261 0.499 0.498 4.0\nO29 O 0.257 0.304 0.806 -2.0\nO30 O -0.257 0.304 0.806 -2.0\nO31 O 0.257 0.195 0.306 -2.0\nO32 O -0.257 0.195 0.306 -2.0\nSr33 Sr 0.173 0.993 0.524 2.0\nSr34 Sr -0.173 0.993 0.524 2.0\nSr35 Sr 0.173 0.506 0.024 2.0\nSr36 Sr -0.173 0.506 0.024 2.0\nO37 O 0.173 0.947 0.986 -2.0\nO38 O -0.173 0.947 0.986 -2.0\nO39 O 0.173 0.551 0.486 -2.0\nO40 O -0.173 0.551 0.486 -2.0\nO41 O 0.098 0.204 0.295 -2.0\nO42 O -0.098 0.204 0.295 -2.0\nO43 O 0.098 0.295 0.795 -2.0\nO44 O -0.098 0.295 0.795 -2.0\nZr45 Zr 0.086 0.004 0.998 4.0\nZr46 Zr -0.086 0.004 0.998 4.0\nZr47 Zr 0.086 0.495 0.498 4.0\nZr48 Zr -0.086 0.495 0.498 4.0\nO49 O 0.074 0.709 0.211 -2.0\nO50 O -0.074 0.709 0.211 -2.0\nO51 O 0.074 0.790 0.711 -2.0\nO52 O -0.074 0.790 0.711 -2.0\nSr53 Sr 0 0.991 0.467 2.0\nSr54 Sr 0 0.508 0.967 2.0\nO55 O 0 0.076 0.020 -2.0\nO56 O 0 0.423 0.520 -2.0";
var A=w.THREE||w,K=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame||function(a){return setTimeout(a,1E3/60)};b(function(){var a=p("forcewebgl");"N"==a?z.webgl=!1:"Y"==a&&(z.webgl=!0);if(a=p("colorset"))z.colorset=a;var b=d("notifybox",'<div id="cross"></div><div id="message"></div>');document.getElementById("cross").onclick=function(){b.style.display="none"};d("versionbox","v"+z.version);d("cmdbox","Load new").onclick=
t;d("tunebox").onclick=x;d("landing",'<h1>CIF & POSCAR web-viewer</h1><div id="legend">Choose a <b>CIF</b> or <b>POSCAR</b> file (drag <b><i>&</i></b> drop is supported). Files are processed offline in the browser, no remote server is used. <a href=/ id="play_demo">Example</a>.</div><div id="triangle"></div><input type="file" id="fileapi" />');document.getElementById("play_demo").onclick=q;m=m(k,{warning:c,error:c});window.addEventListener("resize",n,!1);window.addEventListener("hashchange",r,!1);
if(z.local_supported){window.addEventListener("dragover",B,!1);window.addEventListener("drop",y,!1);var a=document.getElementById("fileapi"),e=new FileReader;a.onchange=function(){if(!this.files[0]||!this.files[0].size)return c("Error: file cannot be read (unaccessible?)");e.currentFilename=this.files[0].name;e.readAsText(this.files[0])};e.onloadend=function(a){C(a.target.result,!1)}}window.parent&&window.parent.playerdata?(a="object"===typeof window.parent.playerdata&&document.location.search?window.parent.playerdata[document.location.search.substr(1)]:
window.parent.playerdata,C(a,!1)):document.location.hash.length?r():t()})}).apply(null,s)}()},function(ea,ba,Z){"use strict";String.prototype.startswith=function(s){return 0===this.indexOf(s)};String.prototype.endswith=function(s,m){var k=this.toString();if(void 0===m||m>k.length)m=k.length;m-=s.length;k=k.indexOf(s,m);return-1!==k&&k===m};String.prototype.trim=function(){return this.replace(/^\s+|\s+$/g,"")};String.prototype.isnumeric=function(){return!isNaN(parseFloat(this))&&isFinite(this)};ba=
function(s,m){function k(a){if(0<a.indexOf("_cell_angle_gamma ")&&0<a.indexOf("loop_"))return"CIF";a=a.toString().replace(/(\r\n|\r)/gm,"\n").split("\n");return 6<a.length&&("direct"==a[6].toLowerCase().substr(0,6)||"direct"==a[7].toLowerCase().substr(0,6))?"POSCAR":"unknown"}function w(a,c,b,d,e,r){if(!(a&&c&&b&&d&&e&&r))return m.error("Error: invalid cell definition!"),!1;d=d*Math.PI/180;e=e*Math.PI/180;r=r*Math.PI/180;var t=[0,0,1],x=[1,0,0],t=s.divide(t,s.norm(t)),x=s.subtract(x,s.multiply(s.dot(x,
t),t)),x=s.divide(x,s.norm(x)),l=s.cross(t,x);a=s.multiply(a,[1,0,0]);c=s.multiply(c,[s.cos(r),s.sin(r),0]);var p=s.cos(e);d=s.divide(s.subtract(s.cos(d),s.multiply(s.cos(e),s.cos(r))),s.sin(r));e=s.sqrt(s.subtract(s.subtract(1,s.multiply(p,p)),s.multiply(d,d)));b=s.multiply(b,[p,d,e]);return s.multiply([a,c,b],[x,l,t])}function b(a){a.symops&&m.warning("Warning! Reading of symmetry operations is not yet implemented, expect error now.");var c;c=6==Object.keys(a.cell).length?w(a.cell.a,a.cell.b,a.cell.c,
a.cell.alpha,a.cell.beta,a.cell.gamma):a.cell;var b=[],d=[],e=[],r=[],b=c[0].map(function(a,b){return c.map(function(a){return a[b]})}),d=d.concat.apply(d,b),t=0,x=a.atoms.length;if(a.types)for(t;t<x;t++)r.push([a.atoms[t].x,a.atoms[t].y,a.atoms[t].z]);else{var l=[],b={};for(t;t<x;t++)-1==Object.keys(b).indexOf(a.atoms[t].symbol)?b[a.atoms[t].symbol]=[[a.atoms[t].x,a.atoms[t].y,a.atoms[t].z]]:b[a.atoms[t].symbol].push([a.atoms[t].x,a.atoms[t].y,a.atoms[t].z]);var t=1,p;for(p in b){for(x=0;x<b[p].length;x++)r.push(b[p][x]),
l.push(t);t++}}e=e.concat.apply(e,r);r=!1;r=(a.sg_name?a.sg_name:"")+(a.ng_name?" ("+a.ng_name+")":"");return{cell:d,atoms:e,types:l||a.types,symlabel:r}}function a(a){var c=[],b=[],n=[];a=a.toString().replace(/(\r\n|\r)/gm,"\n").split("\n");var u={cell:{},atoms:[]},r=!1,t=!1,x=!1,l="",p="",p=[],q="a b c alpha beta gamma".split(" "),I=["_atom_site_label","_atom_site_type_symbol","_atom_site_fract_x","_atom_site_fract_y","_atom_site_fract_z"],C=["label","symbol","x","y","z"],k=[0,1],B=[],z;for(z in e)B.push(I.length),
I.push(z);z=0;var A=a.length;for(z;z<A;z++)if(!a[z].startswith("#"))if(p=a[z].toLowerCase().trim()){t=!1;if(p.startswith("data_"))t=!0,r=!1,n=[],x=!1,l=p.substr(5);else if(p.startswith("_cell_")){r=!1;p=p.split(" ");t=p[0].split("_");t=t[t.length-1];-1!==q.indexOf(t)&&p[p.length-1]&&(u.cell[t]=parseFloat(p[p.length-1]));continue}else if(p.startswith("_symmetry_space_group_name_h-m")||p.startswith("_space_group.patterson_name_h-m")){r=!1;u.sg_name=a[z].substr(31).replace(/"/g,"").replace(/'/g,"").trim();
continue}else if(p.startswith("_space_group.it_number")||p.startswith("_space_group_it_number")||p.startswith("_symmetry_int_tables_number")){r=!1;p=p.split(" ");u.ng_name=p[p.length-1].trim();continue}else{if(p.startswith("_cif_error"))return m.error(p.substr(12,p.length-13)),!1;if(p.startswith("loop_")){r=!0;n=[];x=!1;continue}}if(r)if(p.startswith("_symmetry_equiv")||p.startswith("_space_group"))x=!0;else if(p.startswith("_"))n.push(p);else if(x)b.push(p.replace(/"/g,"").replace(/'/g,""));else{var t=
{overlays:{}},p=p.replace(/\t/g," ").split(" ").filter(function(a){return a?!0:!1}),K=0,F=n.length;for(K;K<F;K++){var G=I.indexOf(n[K]);-1!=G&&(-1<k.indexOf(G)?p[K]=p[K].charAt(0).toUpperCase()+p[K].slice(1).toLowerCase():p[K]=parseFloat(p[K]),-1<B.indexOf(G)?t.overlays[I[G]]=p[K]:t[C[G]]=p[K])}void 0!==t.x&&void 0!==t.y&&void 0!==t.z&&(t.label&&(t.overlays.label=t.label,t.symbol||(t.symbol=t.label.replace(/[0-9]/g,""))),!d.JmolColors[t.symbol]&&2<t.symbol.length&&(t.symbol=t.symbol.substr(0,t.symbol.length-
1)),!d.JmolColors[t.symbol]&&1<t.symbol.length&&(t.symbol=t.symbol.substr(0,t.symbol.length-1)),t.symbol&&u.atoms.push(t))}else t&&u.atoms.length&&(u.info=l,1<b.length&&(u.symops=b),c.push(u),u={cell:{},atoms:[]},b=[])}else r=!1,n=[],x=!1;u.cell.gamma&&(u.info=l,1<b.length&&(u.symops=b),c.push(u));if(c.length)return c[c.length-1];m.error("Error: unexpected CIF format!");return!1}function c(a){a=a.toString().replace(/(\r\n|\r)/gm,"\n").split("\n");var c=[],b=[],e=1,u=[],r=[],t=[],x=[],l=["x","y","z",
"symbol"],p=0,q=0,I=a.length,C=[],k=0,C=[],B=[];p;a:for(;p<I;p++)if(0==p){C=a[p].split(" ").filter(function(a){return a?!0:!1});B=Object.keys(d.AseRadii);for(q=0;q<C.length;q++)if(-1==B.indexOf(C[q]))continue a;r=C}else if(1==p)e=parseFloat(a[p]);else if(-1!==[2,3,4].indexOf(p))c.push(a[p].split(" ").filter(function(a){return a?!0:!1}).map(Number));else if(5==p)if(C=a[p].split(" ").filter(function(a){return a?!0:!1}),C[0].isnumeric())for(u=C.map(Number),q=0;q<u.length;q++)for(C=0;C<u[q];C++)x.push(q+
1);else r=C;else if(6==p){if("direct"==a[p].toLowerCase().substr(0,6))continue a;C=a[p].split(" ").filter(function(a){return a?!0:!1});if(C[0].isnumeric())for(u=C.map(Number),q=0;q<u.length;q++)for(C=0;C<u[q];C++)x.push(q+1);else r=C}else if(6<p){if(7==p){if(r.length)for(q=0;q<r.length;q++)for(C=0;C<u[q];C++)t.push(r[q]);if("direct"==a[p].toLowerCase().substr(0,6))continue a}B={};C=a[p].replace("#","").replace("!","").split(" ").filter(function(a){return a?!0:!1});if(!C.length)break;else if(3==C.length)t.length?
C.push(t[k]):C.push("Xx");else if(3>C.length)return m.error("Error: invalid atom definition!"),!1;for(q=0;4>q;q++)B[l[q]]=3>q?parseFloat(C[q]):C[q];B.symbol=B.symbol.replace(/\W+/,"").replace(/\d+/,"");B.symbol.length||(B.symbol="Xx");b.push(B);k++}c=s.multiply(c,e);if(b.length)return{cell:c,atoms:b,types:x};m.error("Error: unexpected POSCAR format!");return!1}var d={JmolColors:{D:"#FFFFC0",H:"#FFFFFF",He:"#D9FFFF",Li:"#CC80FF",Be:"#C2FF00",B:"#FFB5B5",C:"#909090",N:"#3050F8",O:"#FF0D0D",F:"#90E050",
Ne:"#B3E3F5",Na:"#AB5CF2",Mg:"#8AFF00",Al:"#BFA6A6",Si:"#F0C8A0",P:"#FF8000",S:"#FFFF30",Cl:"#1FF01F",Ar:"#80D1E3",K:"#8F40D4",Ca:"#3DFF00",Sc:"#E6E6E6",Ti:"#BFC2C7",V:"#A6A6AB",Cr:"#8A99C7",Mn:"#9C7AC7",Fe:"#E06633",Co:"#F090A0",Ni:"#50D050",Cu:"#C88033",Zn:"#7D80B0",Ga:"#C28F8F",Ge:"#668F8F",As:"#BD80E3",Se:"#FFA100",Br:"#A62929",Kr:"#5CB8D1",Rb:"#702EB0",Sr:"#00FF00",Y:"#94FFFF",Zr:"#94E0E0",Nb:"#73C2C9",Mo:"#54B5B5",Tc:"#3B9E9E",Ru:"#248F8F",Rh:"#0A7D8C",Pd:"#006985",Ag:"#C0C0C0",Cd:"#FFD98F",
In:"#A67573",Sn:"#668080",Sb:"#9E63B5",Te:"#D47A00",I:"#940094",Xe:"#429EB0",Cs:"#57178F",Ba:"#00C900",La:"#70D4FF",Ce:"#FFFFC7",Pr:"#D9FFC7",Nd:"#C7FFC7",Pm:"#A3FFC7",Sm:"#8FFFC7",Eu:"#61FFC7",Gd:"#45FFC7",Tb:"#30FFC7",Dy:"#1FFFC7",Ho:"#00FF9C",Er:"#00E675",Tm:"#00D452",Yb:"#00BF38",Lu:"#00AB24",Hf:"#4DC2FF",Ta:"#4DA6FF",W:"#2194D6",Re:"#267DAB",Os:"#266696",Ir:"#175487",Pt:"#D0D0E0",Au:"#FFD123",Hg:"#B8B8D0",Tl:"#A6544D",Pb:"#575961",Bi:"#9E4FB5",Po:"#AB5C00",At:"#754F45",Rn:"#428296",Fr:"#420066",
Ra:"#007D00",Ac:"#70ABFA",Th:"#00BAFF",Pa:"#00A1FF",U:"#008FFF",Np:"#0080FF",Pu:"#006BFF",Am:"#545CF2",Cm:"#785CE3",Bk:"#8A4FE3",Cf:"#A136D4",Es:"#B31FD4",Fm:"#B31FBA",Md:"#B30DA6",No:"#BD0D87",Lr:"#C70066",Rf:"#CC0059",Db:"#D1004F",Sg:"#D90045",Bh:"#E00038",Hs:"#E6002E",Mt:"#EB0026"},AseRadii:{X:.66,H:.31,He:.28,Li:1.28,Be:.96,B:.84,C:.76,N:.71,O:.66,F:.57,Ne:.58,Na:1.66,Mg:1.41,Al:1.21,Si:1.11,P:1.07,S:1.05,Cl:1.02,Ar:1.06,K:2.03,Ca:1.76,Sc:1.7,Ti:1.6,V:1.53,Cr:1.39,Mn:1.39,Fe:1.32,Co:1.26,Ni:1.24,
Cu:1.32,Zn:1.22,Ga:1.22,Ge:1.2,As:1.19,Se:1.2,Br:1.2,Kr:1.16,Rb:2.2,Sr:1.95,Y:1.9,Zr:1.75,Nb:1.64,Mo:1.54,Tc:1.47,Ru:1.46,Rh:1.42,Pd:1.39,Ag:1.45,Cd:1.44,In:1.42,Sn:1.39,Sb:1.39,Te:1.38,I:1.39,Xe:1.4,Cs:2.44,Ba:2.15,La:2.07,Ce:2.04,Pr:2.03,Nd:2.01,Pm:1.99,Sm:1.98,Eu:1.98,Gd:1.96,Tb:1.94,Dy:1.92,Ho:1.92,Er:1.89,Tm:1.9,Yb:1.87,Lu:1.87,Hf:1.75,Ta:1.7,W:1.62,Re:1.51,Os:1.44,Ir:1.41,Pt:1.36,Au:1.36,Hg:1.32,Tl:1.45,Pb:1.46,Bi:1.48,Po:1.4,At:1.5,Rn:1.5,Fr:2.6,Ra:2.21,Ac:2.15,Th:2.06,Pa:2,U:1.96,Np:1.9,Pu:1.87,
Am:1.8,Cm:1.69,Bk:3,Cf:3,Es:3,Fm:3,Md:3,No:3,Lr:3,Rf:3,Db:3,Sg:3,Bh:3,Hs:3,Mt:3}},e={_atom_site_occupancy:"site occupancies",_atom_site_charge:"formal charges",label:"labels"};return{to_player:function(b){var g;switch(k(b)){case "CIF":g=a(b);break;case "POSCAR":g=c(b);break;default:m.error("Error: file format cannot be recognized!")}if(!g)return!1;b=g;var h=!1;6==Object.keys(b.cell).length?(g=w(b.cell.a,b.cell.b,b.cell.c,b.cell.alpha,b.cell.beta,b.cell.gamma),h=b.cell):g=b.cell;b.atoms.length||m.warning("Note: no atomic coordinates");
var h={atoms:[],cell:g,descr:h,overlayed:{},info:b.info},n,u,r,t={},x=0,l=b.atoms.length,p={};for(x;x<l;x++){var q=[b.atoms[x].x,b.atoms[x].y,b.atoms[x].z],I=q.join(",");if(p.hasOwnProperty(I))for(r in h.atoms[p[I]].overlays)n="S"==r?"+"+b.atoms[x].symbol:"N"==r?", "+(x+1):"_atom_site_occupancy"==r?"+"+b.atoms[x].overlays[r]:" "+b.atoms[x].overlays[r],h.atoms[p[I]].overlays[r]+=n;else{n=d.JmolColors[b.atoms[x].symbol]?d.JmolColors[b.atoms[x].symbol]:"0xffff00";u=d.AseRadii[b.atoms[x].symbol]?d.AseRadii[b.atoms[x].symbol]:
.66;t={S:b.atoms[x].symbol,N:x+1};for(r in b.atoms[x].overlays)t[r]=b.atoms[x].overlays[r];q=s.multiply(q,g);h.atoms.push({x:q[0],y:q[1],z:q[2],c:n,r:u,overlays:t});p[I]=h.atoms.length-1}}for(var C in t)"S"!==C&&"N"!==C&&(h.overlayed[C]=e[C]);return h},to_flatten:function(d){var e;switch(k(d)){case "CIF":e=a(d);break;case "POSCAR":e=c(d);break;default:m.error("Error: file format cannot be recognized!")}return e?b(e):!1},version:"0.0.3.2"}};"undefined"!==typeof ea&&ea.exports?ea.exports=ba:"function"===
typeof Z(2).specified&&!(void 0!==ba&&(ea.exports=ba))},function(ea,ba,Z){function s(k){return Z(m(k))}function m(m){var b;if(!(b=k[m]))throw Error("Cannot find module '"+m+"'.");return b}var k={"./domReady":3,"./domReady.js":3,"./math.custom":4,"./math.custom.js":4,"./matinfio":1,"./matinfio.js":1,"./require":5,"./require.js":5,"./three.custom":6,"./three.custom.js":6};s.keys=function(){return Object.keys(k)};s.resolve=m;ea.exports=s;s.id=2},function(ea,ba,Z){var s;!(s=function(){function m(){if(!d){d=
!0;a&&clearInterval(a);var c=f;if(d&&c.length){f=[];var b;for(b=0;b<c.length;b+=1)c[b](e)}}}function k(a){d?a(e):f.push(a);return k}var w,b,a,c="undefined"!==typeof window&&window.document,d=!c,e=c?document:null,f=[];if(c){if(document.addEventListener)document.addEventListener("DOMContentLoaded",m,!1),window.addEventListener("load",m,!1);else if(window.attachEvent){window.attachEvent("onload",m);b=document.createElement("div");try{w=null===window.frameElement}catch(g){}b.doScroll&&w&&window.external&&
(a=setInterval(function(){try{b.doScroll(),m()}catch(a){}},30))}"complete"===document.readyState&&m()}k.version="2.0.1";k.load=function(a,c,b,d){d.isBuild?b(null):k(b)};return k}.call(ba,Z,ba,ea),void 0!==s&&(ea.exports=s))},function(ea,ba,Z){(function(s,m){ea.exports=m()})(this,function(){return function(s){function m(w){if(k[w])return k[w].exports;var b=k[w]={exports:{},id:w,loaded:!1};s[w].call(b.exports,b,b.exports,m);b.loaded=!0;return b.exports}var k={};m.m=s;m.c=k;m.p="";return m(0)}([function(s,
m,k){m=k(1).create();m.import(k(13));m.import(k(23));m.import(k(24));m.import(k(26));m.import(k(27));m.import(k(28));m.import(k(55));m.import(k(43));m.import(k(60));m.import(k(62));m.import(k(63));s.exports=m},function(s,m,k){s.exports=k(2)},function(s,m,k){var w=k(3).isFactory;k(3);var b=k(4),a=k(8),c=k(10),d=k(12);m.create=function(e){function f(a){if(!w(a))throw Error("Factory object with properties `type`, `name`, and `factory` expected");var c=g.indexOf(a);-1===c?(c=!0===a.math?a.factory(n.type,
u,f,n.typed,n):a.factory(n.type,u,f,n.typed),g.push(a),h.push(c)):c=h[c];return c}if("function"!==typeof Object.create)throw Error("ES5 not supported by this JavaScript engine. Please load the es5-shim and es5-sham library for compatibility.");var g=[],h=[],n=a.mixin({});n.type={};n.expression={transform:Object.create(n)};n.typed=b.create(n.type);var u={epsilon:1E-12,matrix:"Matrix",number:"number",precision:64,predictable:!1};n["import"]=f(c);n.config=f(d);e&&n.config(e);return n}},function(s,m){m.clone=
function w(b){var a=typeof b;if("number"===a||"string"===a||"boolean"===a||null===b||void 0===b)return b;if("function"===typeof b.clone)return b.clone();if(Array.isArray(b))return b.map(function(a){return w(a)});if(b instanceof Number)return new Number(b.valueOf());if(b instanceof String)return new String(b.valueOf());if(b instanceof Boolean)return new Boolean(b.valueOf());if(b instanceof Date)return new Date(b.valueOf());if(b&&!0===b.isBigNumber)return b;if(b instanceof RegExp)throw new TypeError("Cannot clone "+
b);var a={},c;for(c in b)b.hasOwnProperty(c)&&(a[c]=w(b[c]));return a};m.extend=function(m,b){for(var a in b)b.hasOwnProperty(a)&&(m[a]=b[a]);return m};m.deepExtend=function b(a,c){if(Array.isArray(c))throw new TypeError("Arrays are not supported by deepExtend");for(var d in c)if(c.hasOwnProperty(d))if(c[d]&&c[d].constructor===Object)void 0===a[d]&&(a[d]={}),a[d].constructor===Object?b(a[d],c[d]):a[d]=c[d];else{if(Array.isArray(c[d]))throw new TypeError("Arrays are not supported by deepExtend");a[d]=
c[d]}return a};m.deepEqual=function(b,a){var c,d;if(Array.isArray(b)){if(!Array.isArray(a)||b.length!=a.length)return!1;c=0;for(d=b.length;c<d;c++)if(!m.deepEqual(b[c],a[c]))return!1;return!0}if(b instanceof Object){if(Array.isArray(a)||!(a instanceof Object))return!1;for(c in b)if(!m.deepEqual(b[c],a[c]))return!1;for(c in a)if(!m.deepEqual(b[c],a[c]))return!1;return!0}return typeof b===typeof a&&b==a};m.canDefineProperty=function(){try{if(Object.defineProperty)return Object.defineProperty({},"x",
{get:function(){}}),!0}catch(b){}return!1};m.lazy=function(b,a,c){if(m.canDefineProperty()){var d=!0,e;Object.defineProperty(b,a,{get:function(){d&&(e=c(),d=!1);return e},set:function(a){e=a;d=!1},configurable:!0,enumerable:!0})}else b[a]=c()};m.traverse=function(b,a){var c=b;if(a)for(var d=a.split("."),e=0;e<d.length;e++){var f=d[e];f in c||(c[f]={});c=c[f]}return c};m.isFactory=function(b){return b&&"function"===typeof b.factory}},function(s,m,k){var w=k(5),b=k(6).digits,a=function(){a=w.create;
return w};m.create=function(c){var d=a();d.types=[{name:"number",test:function(a){return"number"===typeof a}},{name:"Complex",test:function(a){return a&&a.isComplex}},{name:"BigNumber",test:function(a){return a&&a.isBigNumber}},{name:"Fraction",test:function(a){return a&&a.isFraction}},{name:"Unit",test:function(a){return a&&a.isUnit}},{name:"string",test:function(a){return"string"===typeof a}},{name:"Array",test:Array.isArray},{name:"Matrix",test:function(a){return a&&a.isMatrix}},{name:"DenseMatrix",
test:function(a){return a&&a.isDenseMatrix}},{name:"SparseMatrix",test:function(a){return a&&a.isSparseMatrix}},{name:"ImmutableDenseMatrix",test:function(a){return a&&a.isImmutableDenseMatrix}},{name:"Range",test:function(a){return a&&a.isRange}},{name:"Index",test:function(a){return a&&a.isIndex}},{name:"boolean",test:function(a){return"boolean"===typeof a}},{name:"ResultSet",test:function(a){return a&&a.isResultSet}},{name:"Help",test:function(a){return a&&a.isHelp}},{name:"function",test:function(a){return"function"===
typeof a}},{name:"Date",test:function(a){return a instanceof Date}},{name:"RegExp",test:function(a){return a instanceof RegExp}},{name:"Object",test:function(a){return"object"===typeof a}},{name:"null",test:function(a){return null===a}},{name:"undefined",test:function(a){return void 0===a}}];d.conversions=[{from:"number",to:"BigNumber",convert:function(a){if(15<b(a))throw new TypeError("Cannot implicitly convert a number with >15 significant digits to BigNumber (value: "+a+"). Use function bignumber(x) to convert to BigNumber.");
return new c.BigNumber(a)}},{from:"number",to:"Complex",convert:function(a){return new c.Complex(a,0)}},{from:"number",to:"string",convert:function(a){return a+""}},{from:"BigNumber",to:"Complex",convert:function(a){return new c.Complex(a.toNumber(),0)}},{from:"Fraction",to:"Complex",convert:function(a){return new c.Complex(a.valueOf(),0)}},{from:"number",to:"Fraction",convert:function(a){if(15<b(a))throw new TypeError("Cannot implicitly convert a number with >15 significant digits to Fraction (value: "+
a+"). Use function fraction(x) to convert to Fraction.");return new c.Fraction(a)}},{from:"string",to:"number",convert:function(a){var c=Number(a);if(isNaN(c))throw Error('Cannot convert "'+a+'" to a number');return c}},{from:"boolean",to:"number",convert:function(a){return+a}},{from:"boolean",to:"BigNumber",convert:function(a){return new c.BigNumber(+a)}},{from:"boolean",to:"Fraction",convert:function(a){return new c.Fraction(+a)}},{from:"boolean",to:"string",convert:function(a){return+a}},{from:"null",
to:"number",convert:function(){return 0}},{from:"null",to:"string",convert:function(){return"null"}},{from:"null",to:"BigNumber",convert:function(){return new c.BigNumber(0)}},{from:"null",to:"Fraction",convert:function(){return new c.Fraction(0)}},{from:"Array",to:"Matrix",convert:function(a){return new c.DenseMatrix(a)}},{from:"Matrix",to:"Array",convert:function(a){return a.valueOf()}}];return d}},function(s,m,k){var w,b,a;"use strict";(function(c,d){!(b=[],w=d,a="function"===typeof w?w.apply(m,
b):w,void 0!==a&&(s.exports=a))})(this,function(){function a(){function b(a){for(var c,d=0;d<y.types.length;d++){var e=y.types[d];if(e.name===a){c=e.test;break}}if(!c){for(var f,d=0;d<y.types.length;d++)if(e=y.types[d],e.name.toLowerCase()==a.toLowerCase()){f=e.name;break}throw Error('Unknown type "'+a+'"'+(f?'. Did you mean "'+f+'"?':""));}return c}function e(a){for(var c="",b=0;b<a.length;b++){var d=a[b];if(d.signatures&&""!=d.name)if(""==c)c=d.name;else if(c!=d.name)throw a=Error("Function names do not match (expected: "+
c+", actual: "+d.name+")"),a.data={actual:d.name,expected:c},a;}return c}function f(a,c,b,d,e){var f=l(d);e=e?e.split(","):null;var h=a||"unnamed",g=e&&-1!==e.indexOf("any");a={fn:a,index:b,actual:d,expected:e};c=e?c>b&&!g?"Unexpected type of argument in function "+h+" (expected: "+e.join(" or ")+", actual: "+f+", index: "+b+")":"Too few arguments in function "+h+" (expected: "+e.join(" or ")+", index: "+b+")":"Too many arguments in function "+h+" (expected: "+b+", actual: "+c+")";c=new TypeError(c);
c.data=a;return c}function g(a){this.name=a||"refs";this.categories={}}function h(a,c){if("string"===typeof a){var b=a.trim(),d="..."===b.substr(0,3);d&&(b=b.substr(3));if(""===b)this.types=["any"];else for(this.types=b.split("|"),b=0;b<this.types.length;b++)this.types[b]=this.types[b].trim()}else if(Array.isArray(a))this.types=a;else{if(a instanceof h)return a.clone();throw Error("String or Array expected");}this.conversions=[];this.varArgs=d||c||!1;this.anyType=-1!==this.types.indexOf("any")}function n(a,
c){var b;if("string"===typeof a)b=""!==a?a.split(","):[];else if(Array.isArray(a))b=a;else throw Error("string or Array expected");this.params=Array(b.length);for(var d=0;d<b.length;d++){var e=new h(b[d]);this.params[d]=e;if(d===b.length-1)this.varArgs=e.varArgs;else if(e.varArgs)throw new SyntaxError('Unexpected variable arguments operator "..."');}this.fn=c}function u(a,c,b){this.path=a||[];this.param=a[a.length-1]||null;this.signature=c||null;this.childs=b||[]}function r(a){var c,b={},d=[],e,f;
for(f in a)if(a.hasOwnProperty(f)&&(c=new n(f,a[f]),!c.ignore()))for(c=c.expand(),e=0;e<c.length;e++){var h=c[e],g=h.toString(),l=b[g];if(l)if(l=n.compare(h,l),0>l)b[g]=h;else{if(0===l)throw Error('Signature "'+g+'" is defined twice');}else b[g]=h}for(g in b)b.hasOwnProperty(g)&&d.push(b[g]);d.sort(function(a,c){return n.compare(a,c)});for(e=0;e<d.length;e++)if(c=d[e],c.varArgs)for(a=c.params.length-1,b=c.params[a],f=0;f<b.types.length;){if(b.conversions[f])for(g=b.types[f],h=0;h<d.length;h++){var l=
d[h],u=l.params[a];if(l!==c&&u&&-1!==u.types.indexOf(g)&&!u.conversions[a]){b.types.splice(f,1);b.conversions.splice(f,1);f--;break}}f++}return d}function t(a,c){var b,d,e=c.length,f,g=[];for(b=0;b<a.length;b++)d=a[b],d.params.length!==e||f||(f=d),void 0!=d.params[e]&&g.push(d);g.sort(function(a,c){return h.compare(a.params[e],c.params[e])});var l=[];for(b=0;b<g.length;b++){d=g[b];var n=d.params[e],r=l.filter(function(a){return a.param.overlapping(n)})[0];if(r){if(r.param.varArgs)throw Error('Conflicting types "'+
r.param+'" and "'+n+'"');r.signatures.push(d)}else l.push({param:n,signatures:[d]})}d=Array(l.length);for(b=0;b<l.length;b++)g=l[b],d[b]=t(g.signatures,c.concat(g.param));return new u(c,f,d)}function x(a,c){var b=new g,d=r(c);if(0==d.length)throw Error("No signatures provided");for(var e=t(d,[]),h=[],l=a||"",n=0,u=0;u<d.length;u++){var p=d[u].params.length;p>n&&(n=p)}u=[];for(p=0;p<n;p++)u[p]="arg"+p;h.push("function "+l+"("+u.join(", ")+") {");h.push(' "use strict";');h.push(" var name = '"+l+
"';");h.push(e.toCode(b," "));h.push("}");e=[b.toCode(),"return "+h.join("\n")].join("\n");b=(new Function(b.name,"createError",e))(b,f);e={};for(h=0;h<d.length;h++)l=d[h],l.fn&&!l.hasConversions()&&(n=l.params.join(","),e[n]=l.fn);b.signatures=e;return b}function l(a){for(var b,c=0;c<y.types.length;c++){var d=y.types[c];if("Object"===d.name)b=d;else if(d.test(a))return d.name}return b&&b.test(a)?b.name:"unknown"}g.prototype.add=function(a,b){var c=b||"fn";this.categories[c]||(this.categories[c]=
[]);var d=this.categories[c].indexOf(a);-1==d&&(d=this.categories[c].length,this.categories[c].push(a));return c+d};g.prototype.toCode=function(){var a=[],c=this.name+".categories",b=this.categories,d;for(d in b)if(b.hasOwnProperty(d))for(var e=b[d],f=0;f<e.length;f++)a.push("var "+d+f+" = "+c+"['"+d+"']["+f+"];");return a.join("\n")};h.compare=function(a,b){if(a.anyType)return 1;if(b.anyType)return-1;if(-1!==a.types.indexOf("Object"))return 1;if(-1!==b.types.indexOf("Object"))return-1;if(a.hasConversions()){if(b.hasConversions()){var c,
d,e;for(c=0;c<a.conversions.length;c++)if(void 0!==a.conversions[c]){d=a.conversions[c];break}for(c=0;c<b.conversions.length;c++)if(void 0!==b.conversions[c]){e=b.conversions[c];break}return y.conversions.indexOf(d)-y.conversions.indexOf(e)}return 1}if(b.hasConversions())return-1;var f,h;for(c=0;c<y.types.length;c++)if(y.types[c].name===a.types[0]){f=c;break}for(c=0;c<y.types.length;c++)if(y.types[c].name===b.types[0]){h=c;break}return f-h};h.prototype.overlapping=function(a){for(var c=0;c<this.types.length;c++)if(-1!==
a.types.indexOf(this.types[c]))return!0;return!1};h.prototype.clone=function(){var a=new h(this.types.slice(),this.varArgs);a.conversions=this.conversions.slice();return a};h.prototype.hasConversions=function(){return 0<this.conversions.length};h.prototype.contains=function(a){for(var c=0;c<this.types.length;c++)if(a[this.types[c]])return!0;return!1};h.prototype.toString=function(a){for(var c=[],b={},d=0;d<this.types.length;d++){var e=this.conversions[d],e=a&&e?e.to:this.types[d];e in b||(b[e]=!0,
c.push(e))}return(this.varArgs?"...":"")+c.join("|")};n.prototype.clone=function(){return new n(this.params.slice(),this.fn)};n.prototype.expand=function(){function a(b,d){if(d.length<b.params.length){var e,f,g,l=b.params[d.length];if(l.varArgs){f=l.clone();for(e=0;e<y.conversions.length;e++)if(g=y.conversions[e],-1===l.types.indexOf(g.from)&&-1!==l.types.indexOf(g.to)){var u=f.types.length;f.types[u]=g.from;f.conversions[u]=g}a(b,d.concat(f))}else{for(e=0;e<l.types.length;e++)a(b,d.concat(new h(l.types[e])));
for(e=0;e<y.conversions.length;e++)g=y.conversions[e],-1===l.types.indexOf(g.from)&&-1!==l.types.indexOf(g.to)&&(f=new h(g.from),f.conversions[0]=g,a(b,d.concat(f)))}}else c.push(new n(d,b.fn))}var c=[];a(this,[]);return c};n.compare=function(a,c){if(a.params.length>c.params.length)return 1;if(a.params.length<c.params.length)return-1;var b,d=a.params.length,e=0,f=0;for(b=0;b<d;b++)a.params[b].hasConversions()&&e++,c.params[b].hasConversions()&&f++;if(e>f)return 1;if(e<f)return-1;for(b=0;b<a.params.length;b++)if(d=
h.compare(a.params[b],c.params[b]),0!==d)return d;return 0};n.prototype.hasConversions=function(){for(var a=0;a<this.params.length;a++)if(this.params[a].hasConversions())return!0;return!1};n.prototype.ignore=function(){for(var a={},c=0;c<y.ignore.length;c++)a[y.ignore[c]]=!0;for(c=0;c<this.params.length;c++)if(this.params[c].contains(a))return!0;return!1};n.prototype.toCode=function(a,c){for(var b=Array(this.params.length),d=0;d<this.params.length;d++){var e=this.params[d],f=e.conversions[0];b[d]=
e.varArgs?"varArgs":f?a.add(f.convert,"convert")+"(arg"+d+")":"arg"+d}return(d=this.fn?a.add(this.fn,"signature"):void 0)?c+"return "+d+"("+b.join(", ")+"); // signature: "+this.params.join(", "):""};n.prototype.toString=function(){return this.params.join(", ")};u.prototype.toCode=function(a,c,e){var f=[];if(this.param){var h=this.path.length-1,g=this.param.conversions[0],g="// type: "+(g?g.from+" (convert to "+g.to+")":this.param);if(this.param.varArgs){if(this.param.anyType)f.push(c+"if (arguments.length > "+
h+") {"),f.push(c+" var varArgs = [];"),f.push(c+" for (var i = "+h+"; i < arguments.length; i++) {"),f.push(c+" varArgs.push(arguments[i]);");else{var l=function(c,e){for(var f=[],h=0;h<c.length;h++)f[h]=a.add(b(c[h]),"test")+"("+e+")";return f.join(" || ")}.bind(this);e=this.param.types;for(var n=[],u=0;u<e.length;u++)void 0===this.param.conversions[u]&&n.push(e[u]);f.push(c+"if ("+l(e,"arg"+h)+") { "+g);f.push(c+" var varArgs = [arg"+h+"];");f.push(c+" for (var i = "+(h+1)+"; i < arguments.length; i++) {");
f.push(c+" if ("+l(n,"arguments[i]")+") {");f.push(c+" varArgs.push(arguments[i]);");for(u=0;u<e.length;u++)if(h=this.param.conversions[u])l=a.add(b(e[u]),"test"),h=a.add(h.convert,"convert"),f.push(c+" }"),f.push(c+" else if ("+l+"(arguments[i])) {"),f.push(c+" varArgs.push("+h+"(arguments[i]));");f.push(c+" } else {");f.push(c+" throw createError(name, arguments.length, i, arguments[i], '"+n.join(",")+"');");f.push(c+" }")}f.push(c+" }");f.push(this.signature.toCode(a,
c+" "));f.push(c+"}")}else this.param.anyType?(f.push(c+"// type: any"),f.push(this._innerCode(a,c,e))):(n=this.param.types[0],l="any"!==n?a.add(b(n),"test"):null,f.push(c+"if ("+l+"(arg"+h+")) { "+g),f.push(this._innerCode(a,c+" ",e)),f.push(c+"}"))}else f.push(this._innerCode(a,c,e));return f.join("\n")};u.prototype._innerCode=function(a,c,b){var d=[],e;this.signature&&(d.push(c+"if (arguments.length === "+this.path.length+") {"),d.push(this.signature.toCode(a,c+" ")),d.push(c+"}"));var f;for(e=
0;e<this.childs.length;e++)if(this.childs[e].param.anyType){f=this.childs[e];break}for(e=0;e<this.childs.length;e++)d.push(this.childs[e].toCode(a,c,f));b&&!this.param.anyType&&d.push(b.toCode(a,c,f));(a=this._exceptions(a,c))&&d.push(a);return d.join("\n")};u.prototype._exceptions=function(a,c){var b=this.path.length;if(0===this.childs.length)return[c+"if (arguments.length > "+b+") {",c+" throw createError(name, arguments.length, "+b+", arguments["+b+"]);",c+"}"].join("\n");for(var d={},e=[],f=
0;f<this.childs.length;f++){var h=this.childs[f];if(h.param)for(var g=0;g<h.param.types.length;g++){var l=h.param.types[g];l in d||h.param.conversions[g]||(d[l]=!0,e.push(l))}}return c+"throw createError(name, arguments.length, "+b+", arguments["+b+"], '"+e.join(",")+"');"};var p=[{name:"number",test:function(a){return"number"===typeof a}},{name:"string",test:function(a){return"string"===typeof a}},{name:"boolean",test:function(a){return"boolean"===typeof a}},{name:"Function",test:function(a){return"function"===
typeof a}},{name:"Array",test:Array.isArray},{name:"Date",test:function(a){return a instanceof Date}},{name:"RegExp",test:function(a){return a instanceof RegExp}},{name:"Object",test:function(a){return"object"===typeof a}},{name:"null",test:function(a){return null===a}},{name:"undefined",test:function(a){return void 0===a}}],q={},I=[],k=[],y={config:q,types:p,conversions:I,ignore:k},y=x("typed",{Object:function(a){var c=[],b;for(b in a)a.hasOwnProperty(b)&&c.push(a[b]);c=e(c);return x(c,a)},"string, Object":x,
"...Function":function(a){for(var c=e(a),b={},d=0;d<a.length;d++){var f=a[d];if("object"!==typeof f.signatures)throw a=new TypeError("Function is no typed-function (index: "+d+")"),a.data={index:d},a;for(var h in f.signatures)if(f.signatures.hasOwnProperty(h))if(b.hasOwnProperty(h)){if(f.signatures[h]!==b[h])throw a=Error('Signature "'+h+'" is defined twice'),a.data={signature:h},a;}else b[h]=f.signatures[h]}return x(c,b)}});y.config=q;y.types=p;y.conversions=I;y.ignore=k;y.create=a;y.find=function(a,
c){if(!a.signatures)throw new TypeError("Function is no typed-function");var b;if("string"===typeof c){b=c.split(",");for(var d=0;d<b.length;d++)b[d]=b[d].trim()}else if(Array.isArray(c))b=c;else throw new TypeError("String array or a comma separated string expected");d=b.join(",");if(d=a.signatures[d])return d;throw new TypeError("Signature not found (signature: "+(a.name||"unnamed")+"("+b.join(", ")+"))");};y.convert=function(a,c){var b=l(a);if(c===b)return a;for(var d=0;d<y.conversions.length;d++){var e=
y.conversions[d];if(e.from===b&&e.to===c)return e.convert(a)}throw Error("Cannot convert from "+b+" to "+c);};y.addType=function(a){if(!a||"string"!==typeof a.name||"function"!==typeof a.test)throw new TypeError("Object with properties {name: string, test: function} expected");y.types.push(a)};y.addConversion=function(a){if(!a||"string"!==typeof a.from||"string"!==typeof a.to||"function"!==typeof a.convert)throw new TypeError("Object with properties {from: string, to: string, convert: function} expected");
y.conversions.push(a)};return y}return a()})},function(s,m,k){var w=k(7);m.isNumber=function(b){return"number"===typeof b};m.isInteger=function(b){return isFinite(b)?b==Math.round(b):!1};m.sign=Math.sign||function(b){return 0<b?1:0>b?-1:0};m.format=function(b,a){if("function"===typeof a)return a(b);if(Infinity===b)return"Infinity";if(-Infinity===b)return"-Infinity";if(isNaN(b))return"NaN";var c="auto",d=void 0;a&&(a.notation&&(c=a.notation),m.isNumber(a)?d=a:a.precision&&(d=a.precision));switch(c){case "fixed":return m.toFixed(b,
d);case "exponential":return m.toExponential(b,d);case "engineering":return m.toEngineering(b,d);case "auto":return m.toPrecision(b,d,a&&a.exponential).replace(/((\.\d*?)(0+))($|e)/,function(a,c,b,d,n){return"."!==b?b+n:n});default:throw Error('Unknown notation "'+c+'". Choose "auto", "exponential", or "fixed".');}};m.toExponential=function(b,a){return(new w(b)).toExponential(a)};m.toEngineering=function(b,a){return(new w(b)).toEngineering(a)};m.toFixed=function(b,a){return(new w(b)).toFixed(a)};
m.toPrecision=function(b,a,c){return(new w(b)).toPrecision(a,c)};m.digits=function(b){return b.toExponential().replace(/e.*$/,"").replace(/^0\.?0*|\./,"").length};m.DBL_EPSILON=Number.EPSILON||2.220446049250313E-16;m.nearlyEqual=function(b,a,c){if(null==c)return b==a;if(b==a)return!0;if(isNaN(b)||isNaN(a))return!1;if(isFinite(b)&&isFinite(a)){var d=Math.abs(b-a);return d<m.DBL_EPSILON?!0:d<=Math.max(Math.abs(b),Math.abs(a))*c}return!1}},function(s,m){function k(b){var a=String(b).toLowerCase().match(/^0*?(-?)(\d+\.?\d*)(e([+-]?\d+))?$/);
if(!a)throw new SyntaxError("Invalid number");b=a[1];var c=a[2],d=parseFloat(a[4]||"0"),a=c.indexOf("."),d=d+(-1!==a?a-1:c.length-1);this.sign=b;this.coefficients=c.replace(".","").replace(/^0*/,function(a){d-=a.length;return""}).replace(/0*$/,"").split("").map(function(a){return parseInt(a)});0===this.coefficients.length&&(this.coefficients.push(0),d++);this.exponent=d}function w(b){for(var a=[],c=0;c<b;c++)a.push(0);return a}k.prototype.toEngineering=function(b){b=this.roundDigits(b);var a=b.exponent,
c=b.coefficients,d=0===a%3?a:0>a?a-3-a%3:a-a%3,e=0<=a?a:Math.abs(d);c.length-1<e&&(c=c.concat(w(e-(c.length-1))));for(var f=Math.abs(a-d),e=1,g="";0<=--f;)e++;f=c.slice(e).join("");f=f.match(/[1-9]/)?"."+f:"";g=c.slice(0,e).join("")+f;g+="e"+(0<=a?"+":"")+d.toString();return b.sign+g};k.prototype.toFixed=function(b){var a=this.roundDigits(this.exponent+1+(b||0)),c=a.coefficients,a=a.exponent+1,d=a+(b||0);c.length<d&&(c=c.concat(w(d-c.length)));0>a&&(c=w(-a+1).concat(c),a=1);b&&c.splice(a,0,0===a?
"0.":".");return this.sign+c.join("")};k.prototype.toExponential=function(b){var a=b?this.roundDigits(b):this.clone(),c=a.coefficients,a=a.exponent;c.length<b&&(c=c.concat(w(b-c.length)));b=c.shift();return this.sign+b+(0<c.length?"."+c.join(""):"")+"e"+(0<=a?"+":"")+a};k.prototype.toPrecision=function(b,a){var c=a&&void 0!==a.lower?a.lower:.001,d=a&&void 0!==a.upper?a.upper:1E5,e=Math.abs(Math.pow(10,this.exponent));if(e<c||e>=d)return this.toExponential(b);d=b?this.roundDigits(b):this.clone();c=
d.coefficients;d=d.exponent;c.length<b&&(c=c.concat(w(b-c.length)));c=c.concat(w(d-c.length+1+(c.length<b?b-c.length:0)));c=w(-d).concat(c);d=0<d?d:0;d<c.length-1&&c.splice(d+1,0,".");return this.sign+c.join("")};k.prototype.clone=function(){var b=new k("0");b.sign=this.sign;b.coefficients=this.coefficients.slice(0);b.exponent=this.exponent;return b};k.prototype.roundDigits=function(b){for(var a=this.clone(),c=a.coefficients;0>=b;)c.unshift(0),a.exponent++,b++;if(c.length>b&&5<=c.splice(b,c.length-
b)[0])for(b-=1,c[b]++;10===c[b];)c.pop(),0===b&&(c.unshift(0),a.exponent++,b++),b--,c[b]++;return a};s.exports=k},function(s,m,k){var w=k(9);m.mixin=function(b){var a=new w;b.on=a.on.bind(a);b.off=a.off.bind(a);b.once=a.once.bind(a);b.emit=a.emit.bind(a);return b}},function(s,m){function k(){}k.prototype={on:function(k,b,a){var c=this.e||(this.e={});(c[k]||(c[k]=[])).push({fn:b,ctx:a});return this},once:function(k,b,a){function c(){d.off(k,c);b.apply(a,arguments)}var d=this;c._=b;return this.on(k,
c,a)},emit:function(k){var b=[].slice.call(arguments,1),a=((this.e||(this.e={}))[k]||[]).slice(),c=0,d=a.length;for(c;c<d;c++)a[c].fn.apply(a[c].ctx,b);return this},off:function(k,b){var a=this.e||(this.e={}),c=a[k],d=[];if(c&&b)for(var e=0,f=c.length;e<f;e++)c[e].fn!==b&&c[e].fn._!==b&&d.push(c[e]);d.length?a[k]=d:delete a[k];return this}};s.exports=k},function(s,m,k){var w=k(3).lazy,b=k(3).isFactory,a=k(3).traverse;k(3);var c=k(11);m.math=!0;m.name="import";m.factory=function(d,e,f,g,h){function n(a,
d){var e=arguments.length;if(1!=e&&2!=e)throw new c("import",e,1,2);d||(d={});if(b(a))x(a,d);else if(Array.isArray(a))a.forEach(function(a){n(a,d)});else if("object"===typeof a)for(var f in a)a.hasOwnProperty(f)&&(e=a[f],"function"==typeof e||"number"===typeof e||"string"===typeof e||"boolean"===typeof e||null===e||e&&!0===e.isUnit||e&&!0===e.isComplex||e&&!0===e.isBigNumber||e&&!0===e.isFraction||e&&!0===e.isMatrix||e&&!0===Array.isArray(e)?u(f,e,d):b(a)?x(a,d):n(e,d));else if(!d.silent)throw new TypeError("Factory, Object, or Array expected");
}function u(a,c,b){b.wrap&&"function"===typeof c&&(c=t(c));if(l(h[a])&&l(c))c=b.override?g(a,c.signatures):g(h[a],c),h[a]=c,r(a,c),h.emit("import",a,function(){return c});else if(void 0===h[a]||b.override)h[a]=c,r(a,c),h.emit("import",a,function(){return c});else if(!b.silent)throw Error('Cannot import "'+a+'": already exists');}function r(a,c){c&&"function"===typeof c.transform&&(h.expression.transform[a]=c.transform)}function t(a){var c=function(){for(var c=[],b=0,d=arguments.length;b<d;b++){var e=
arguments[b];c[b]=e&&e.valueOf()}return a.apply(h,c)};a.transform&&(c.transform=a.transform);return c}function x(c,b){if("string"===typeof c.name){var d=c.name,e=c.path?a(h,c.path):h,n=e.hasOwnProperty(d)?e[d]:void 0,u=function(){var a=f(c);if(l(n)&&l(a))return b.override||(a=g(n,a)),a;if(void 0===n||b.override)return a;if(!b.silent)throw Error('Cannot import "'+d+'": already exists');};!1!==c.lazy?w(e,d,u):e[d]=u();h.emit("import",d,u,c.path)}else f(c)}function l(a){return"function"===typeof a&&
"object"===typeof a.signatures}return n};m.lazy=!0},function(s,m){function k(m,b,a,c){if(!(this instanceof k))throw new SyntaxError("Constructor must be called with the new operator");this.fn=m;this.count=b;this.min=a;this.max=c;this.message="Wrong number of arguments in function "+m+" ("+b+" provided, "+a+(void 0!=c?"-"+c:"")+" expected)";this.stack=Error().stack}k.prototype=Error();k.prototype.constructor=Error;k.prototype.name="ArgumentsError";k.prototype.isArgumentsError=!0;s.exports=k},function(s,
m,k){function w(a,b){return a.map(function(a){return a.toLowerCase()}).indexOf(b.toLowerCase())}function b(a,b,e){if(void 0!==a[b]&&-1===e.indexOf(a[b])){var f=w(e,a[b]);-1!==f?(console.warn('Warning: Wrong casing for configuration option "'+b+'", should be "'+e[f]+'" instead of "'+a[b]+'".'),a[b]=e[f]):console.warn('Warning: Unknown value "'+a[b]+'" for configuration option "'+b+'". Available options: '+e.map(JSON.stringify).join(", ")+".")}}var a=k(3);m.name="config";m.math=!0;m.factory=function(c,
d,e,f,g){function h(c){if(c){var e=a.clone(d);b(c,"matrix",n);b(c,"number",u);a.deepExtend(d,c);c=a.clone(d);g.emit("config",c,e);return c}return a.clone(d)}var n=["Matrix","Array"],u=["number","BigNumber","Fraction"];h.MATRIX=n;h.NUMBER=u;return h}},function(s,m,k){var w=k(14).string.isString;m.name="Matrix";m.path="type";m.factory=function(b,a,c,d){function e(){if(!(this instanceof e))throw new SyntaxError("Constructor must be called with the new operator");}e.prototype.type="Matrix";e.prototype.isMatrix=
!0;e.storage=function(a){if(!w(a))throw new TypeError("format must be a string value");var c=e._storage[a];if(!c)throw new SyntaxError("Unsupported matrix storage format: "+a);return c};e._storage={};e.prototype.storage=function(){throw Error("Cannot invoke storage on a Matrix interface");};e.prototype.datatype=function(){throw Error("Cannot invoke datatype on a Matrix interface");};e.prototype.create=function(a,c){throw Error("Cannot invoke create on a Matrix interface");};e.prototype.subset=function(a,
c,b){throw Error("Cannot invoke subset on a Matrix interface");};e.prototype.get=function(a){throw Error("Cannot invoke get on a Matrix interface");};e.prototype.set=function(a,c,b){throw Error("Cannot invoke set on a Matrix interface");};e.prototype.resize=function(a,c){throw Error("Cannot invoke resize on a Matrix interface");};e.prototype.clone=function(){throw Error("Cannot invoke clone on a Matrix interface");};e.prototype.size=function(){throw Error("Cannot invoke size on a Matrix interface");
};e.prototype.map=function(a,c){throw Error("Cannot invoke map on a Matrix interface");};e.prototype.forEach=function(a){throw Error("Cannot invoke forEach on a Matrix interface");};e.prototype.toArray=function(){throw Error("Cannot invoke toArray on a Matrix interface");};e.prototype.valueOf=function(){throw Error("Cannot invoke valueOf on a Matrix interface");};e.prototype.format=function(a){throw Error("Cannot invoke format on a Matrix interface");};e.prototype.toString=function(){throw Error("Cannot invoke toString on a Matrix interface");
};return e}},function(s,m,k){m.array=k(15);m["boolean"]=k(21);m["function"]=k(22);m.number=k(6);m.object=k(3);m.string=k(16);m.types=k(18);m.emitter=k(8)},function(s,m,k){function w(a,c,b){var d=a.length;if(d!=c[b])throw new f(d,c[b]);if(b<c.length-1){var e=b+1;for(b=0;b<d;b++){if(!Array.isArray(a[b]))throw new f(c.length-1,c.length,"<");w(a[b],c,e)}}else for(b=0;b<d;b++)if(Array.isArray(a[b]))throw new f(c.length+1,c.length,">");}function b(a,c,d,e){var f,g=c[d],l=Math.min(a.length,g);a.length=g;
if(d<c.length-1){var p=d+1;for(d=0;d<l;d++)f=a[d],Array.isArray(f)||(f=[f],a[d]=f),b(f,c,p,e);for(d=l;d<g;d++)f=[],a[d]=f,b(f,c,p,e)}else{for(d=0;d<l;d++)for(;Array.isArray(a[d]);)a[d]=a[d][0];if(e!==m.UNINITIALIZED)for(d=l;d<g;d++)a[d]=e}}function a(c,b,d){var e;if(d<b){var f=d+1;d=0;for(e=c.length;d<e;d++)c[d]=a(c[d],b,f)}else for(;Array.isArray(c);)c=c[0];return c}function c(a,b,d){var e;if(Array.isArray(a)){var f=d+1;d=0;for(e=a.length;d<e;d++)a[d]=c(a[d],b,f)}else for(;d<b;d++)a=[a];return a}
var d=k(6),e=k(16);k(3);k(18);var f=k(19),g=k(20);m.size=function(a){for(var c=[];Array.isArray(a);)c.push(a.length),a=a[0];return c};m.validate=function(a,c){if(0==c.length){if(Array.isArray(a))throw new f(a.length,0);}else w(a,c,0)};m.validateIndex=function(a,c){if(!d.isNumber(a)||!d.isInteger(a))throw new TypeError("Index must be an integer (value: "+a+")");if(0>a||"number"===typeof c&&a>=c)throw new g(a,c);};m.UNINITIALIZED={};m.resize=function(a,c,f){if(!Array.isArray(a)||!Array.isArray(c))throw new TypeError("Array expected");
if(0===c.length)throw Error("Resizing to scalar is not supported");c.forEach(function(a){if(!d.isNumber(a)||!d.isInteger(a)||0>a)throw new TypeError("Invalid size, must contain positive integers (size: "+e.format(c)+")");});b(a,c,0,void 0!==f?f:0);return a};m.squeeze=function(c,b){for(var d=b||m.size(c);Array.isArray(c)&&1===c.length;)c=c[0],d.shift();for(var e=d.length;1===d[e-1];)e--;e<d.length&&(c=a(c,e,0),d.length=e);return c};m.unsqueeze=function(a,b,d,e){e=e||m.size(a);if(d)for(var f=0;f<d;f++)a=
[a],e.unshift(1);for(a=c(a,b,0);e.length<b;)e.push(1);return a};m.flatten=function(a){if(!Array.isArray(a))return a;var c=[];a.forEach(function r(a){Array.isArray(a)?a.forEach(r):c.push(a)});return c};m.isArray=Array.isArray},function(s,m,k){function w(a,b){if(Array.isArray(a)){for(var e="[",f=a.length,g=0;g<f;g++)0!=g&&(e+=", "),e+=w(a[g],b);return e+"]"}return m.format(a,b)}var b=k(6).format,a=k(17).format;m.isString=function(a){return"string"===typeof a};m.endsWith=function(a,b){return a.substring(a.length-
b.length,a.length)===b};m.format=function(c,d){if("number"===typeof c)return b(c,d);if(c&&!0===c.isBigNumber)return a(c,d);if(c&&!0===c.isFraction)return d&&"decimal"===d.fraction?c.toString():c.s*c.n+"/"+c.d;if(Array.isArray(c))return w(c,d);if(m.isString(c))return'"'+c+'"';if("function"===typeof c)return c.syntax?String(c.syntax):"function";if(c&&"object"===typeof c){if("function"===typeof c.format)return c.format(d);if(c&&c.toString()!=={}.toString())return c.toString();var e=[],f;for(f in c)c.hasOwnProperty(f)&&
e.push('"'+f+'": '+m.format(c[f],d));return"{"+e.join(", ")+"}"}return String(c)}},function(s,m){m.format=function(k,w){if("function"===typeof w)return w(k);if(!k.isFinite())return k.isNaN()?"NaN":k.gt(0)?"Infinity":"-Infinity";var b="auto",a=void 0;void 0!==w&&(w.notation&&(b=w.notation),"number"===typeof w?a=w:w.precision&&(a=w.precision));switch(b){case "fixed":return m.toFixed(k,a);case "exponential":return m.toExponential(k,a);case "auto":var b=.001,c=1E5;w&&w.exponential&&(void 0!==w.exponential.lower&&
(b=w.exponential.lower),void 0!==w.exponential.upper&&(c=w.exponential.upper));k.constructor.config({toExpNeg:Math.round(Math.log(b)/Math.LN10),toExpPos:Math.round(Math.log(c)/Math.LN10)});if(k.isZero())return"0";var d=k.abs();return(d.gte(b)&&d.lt(c)?k.toSignificantDigits(a).toFixed():m.toExponential(k,a)).replace(/((\.\d*?)(0+))($|e)/,function(a,c,b,d,n){return"."!==b?b+n:n});default:throw Error('Unknown notation "'+b+'". Choose "auto", "exponential", or "fixed".');}};m.toExponential=function(k,
m){return void 0!==m?k.toExponential(m-1):k.toExponential()};m.toFixed=function(k,m){return k.toFixed(m||0)}},function(s,m){m.type=function(k){var m=typeof k;return"object"===m?null===k?"null":k instanceof Boolean?"boolean":k instanceof Number?"number":k instanceof String?"string":Array.isArray(k)?"Array":k instanceof Date?"Date":k instanceof RegExp?"RegExp":"Object":"function"===m?"Function":m};m.isScalar=function(k){return!(k&&k.isMatrix||Array.isArray(k))}},function(s,m){function k(m,b,a){if(!(this instanceof
k))throw new SyntaxError("Constructor must be called with the new operator");this.actual=m;this.expected=b;this.relation=a;this.message="Dimension mismatch ("+(Array.isArray(m)?"["+m.join(", ")+"]":m)+" "+(this.relation||"!=")+" "+(Array.isArray(b)?"["+b.join(", ")+"]":b)+")";this.stack=Error().stack}k.prototype=new RangeError;k.prototype.constructor=RangeError;k.prototype.name="DimensionError";k.prototype.isDimensionError=!0;s.exports=k},function(s,m){function k(m,b,a){if(!(this instanceof k))throw new SyntaxError("Constructor must be called with the new operator");
this.index=m;3>arguments.length?(this.min=0,this.max=b):(this.min=b,this.max=a);this.message=void 0!==this.min&&this.index<this.min?"Index out of range ("+this.index+" < "+this.min+")":void 0!==this.max&&this.index>=this.max?"Index out of range ("+this.index+" > "+(this.max-1)+")":"Index out of range ("+this.index+")";this.stack=Error().stack}k.prototype=new RangeError;k.prototype.constructor=RangeError;k.prototype.name="IndexError";k.prototype.isIndexError=!0;s.exports=k},function(s,m){m.isBoolean=
function(k){return"boolean"==typeof k}},function(s,m){m.memoize=function(k,m){return function a(){"object"!==typeof a.cache&&(a.cache={});for(var c=[],d=0;d<arguments.length;d++)c[d]=arguments[d];d=m?m(c):JSON.stringify(c);return d in a.cache?a.cache[d]:a.cache[d]=k.apply(k,c)}}},function(s,m,k){var w=k(14),b=k(19),a=w.string,c=w.array,d=w.object;s=w.number;var e=Array.isArray,f=s.isNumber,g=s.isInteger,h=a.isString,n=c.validateIndex;m.name="DenseMatrix";m.path="type";m.factory=function(u,r,t,x){function l(a,
b){if(!(this instanceof l))throw new SyntaxError("Constructor must be called with the new operator");if(b&&!h(b))throw Error("Invalid datatype: "+b);if(a&&!0===a.isMatrix)"DenseMatrix"===a.type?(this._data=d.clone(a._data),this._size=d.clone(a._size)):(this._data=a.toArray(),this._size=a.size()),this._datatype=b||a._datatype;else if(a&&e(a.data)&&e(a.size))this._data=a.data,this._size=a.size,this._datatype=b||a.datatype;else{if(e(a))this._data=m(a),this._size=c.size(this._data),c.validate(this._data,
this._size);else{if(a)throw new TypeError("Unsupported type of data ("+w.types.type(a)+")");this._data=[];this._size=[0]}this._datatype=b}}function p(a,c,b,d){var e=d==b-1,f=c.dimension(d);return e?f.map(function(c){return a[c]}).valueOf():f.map(function(e){return p(a[e],c,b,d+1)}).valueOf()}function q(a,e,f,h){if(!e||!0!==e.isIndex)throw new TypeError("Invalid index");var g=e.size(),l=e.isScalar(),n;f&&!0===f.isMatrix?(n=f.size(),f=f.valueOf()):n=c.size(f);if(l){if(0!==n.length)throw new TypeError("Scalar expected");
a.set(e.min(),f,h)}else{if(g.length<a._size.length)throw new b(g.length,a._size.length,"<");if(n.length<g.length){for(var u=l=0;1===g[l]&&1===n[l];)l++;for(;1===g[l];)u++,l++;f=c.unsqueeze(f,g.length,u,n)}if(!d.deepEqual(g,n))throw new b(g,n,">");n=e.max().map(function(a){return a+1});C(a,n,h);I(a._data,e,f,g.length,0)}return a}function I(a,c,b,d,e){var f=e==d-1,h=c.dimension(e);f?h.forEach(function(c,d){n(c);a[c]=b[d[0]]}):h.forEach(function(f,h){n(f);I(a[f],c,b[h[0]],d,e+1)})}function C(a,c,b){for(var d=
a._size.slice(0),e=!1;d.length<c.length;)d.push(0),e=!0;for(var f=0,h=c.length;f<h;f++)c[f]>d[f]&&(d[f]=c[f],e=!0);e&&B(a,d,b)}function m(a){for(var c=0,b=a.length;c<b;c++){var d=a[c];e(d)?a[c]=m(d):d&&!0===d.isMatrix&&(a[c]=m(d.valueOf()))}return a}r=t(k(13));l.prototype=new r;l.prototype.type="DenseMatrix";l.prototype.isDenseMatrix=!0;l.prototype.storage=function(){return"dense"};l.prototype.datatype=function(){return this._datatype};l.prototype.create=function(a,c){return new l(a,c)};l.prototype.subset=
function(a,c,d){switch(arguments.length){case 1:var e;if(!a||!0!==a.isIndex)throw new TypeError("Invalid index");if(a.isScalar())e=this.get(a.min());else{e=a.size();if(e.length!=this._size.length)throw new b(e.length,this._size.length);for(var f=a.min(),h=a.max(),g=0,u=this._size.length;g<u;g++)n(f[g],this._size[g]),n(h[g],this._size[g]);e=new l(p(this._data,a,e.length,0),this._datatype)}return e;case 2:case 3:return q(this,a,c,d);default:throw new SyntaxError("Wrong number of arguments");}};l.prototype.get=
function(a){if(!e(a))throw new TypeError("Array expected");if(a.length!=this._size.length)throw new b(a.length,this._size.length);for(var c=0;c<a.length;c++)n(a[c],this._size[c]);for(var c=this._data,d=0,f=a.length;d<f;d++){var h=a[d];n(h,c.length);c=c[h]}return c};l.prototype.set=function(a,c,d){if(!e(a))throw new TypeError("Array expected");if(a.length<this._size.length)throw new b(a.length,this._size.length,"<");var f,h;f=a.map(function(a){return a+1});C(this,f,d);var g=this._data;d=0;for(f=a.length-
1;d<f;d++)h=a[d],n(h,g.length),g=g[h];h=a[a.length-1];n(h,g.length);g[h]=c;return this};l.prototype.resize=function(a,c,b){if(!e(a))throw new TypeError("Array expected");b=b?this.clone():this;return B(b,a,c)};var B=function(a,b,d){if(0===b.length){for(a=a._data;e(a);)a=a[0];return a}a._size=b.slice(0);a._data=c.resize(a._data,a._size,d);return a};l.prototype.clone=function(){return new l({data:d.clone(this._data),size:d.clone(this._size),datatype:this._datatype})};l.prototype.size=function(){return this._size.slice(0)};
l.prototype.map=function(a){var c=this,b=function(d,f){return e(d)?d.map(function(a,c){return b(a,f.concat(c))}):a(d,f,c)};return new l({data:b(this._data,[]),size:d.clone(this._size),datatype:this._datatype})};l.prototype.forEach=function(a){var c=this,b=function(d,f){e(d)?d.forEach(function(a,c){b(a,f.concat(c))}):a(d,f,c)};b(this._data,[])};l.prototype.toArray=function(){return d.clone(this._data)};l.prototype.valueOf=function(){return this._data};l.prototype.format=function(c){return a.format(this._data,
c)};l.prototype.toString=function(){return a.format(this._data)};l.prototype.toJSON=function(){return{mathjs:"DenseMatrix",data:this._data,size:this._size,datatype:this._datatype}};l.prototype.diagonal=function(a){if(a){if(!0===a.isBigNumber&&(a=a.toNumber()),!f(a)||!g(a))throw new TypeError("The parameter k must be an integer number");}else a=0;var c=0<a?a:0;a=0>a?-a:0;for(var b=Math.min(this._size[0]-a,this._size[1]-c),d=[],e=0;e<b;e++)d[e]=this._data[e+a][e+c];return new l({data:d,size:[b],datatype:this._datatype})};
l.diagonal=function(a,b,d,n,r){if(!e(a))throw new TypeError("Array expected, size parameter");if(2!==a.length)throw Error("Only two dimensions matrix are supported");a=a.map(function(a){a&&!0===a.isBigNumber&&(a=a.toNumber());if(!f(a)||!g(a)||1>a)throw Error("Size values must be positive integers");return a});if(d){if(d&&!0===d.isBigNumber&&(d=d.toNumber()),!f(d)||!g(d))throw new TypeError("The parameter k must be an integer number");}else d=0;n&&h(r)&&(n=x.convert(n,r));r=0<d?d:0;d=0>d?-d:0;var p=
a[0],q=a[1],t=Math.min(p-d,q-r),I;if(e(b)){if(b.length!==t)throw Error("Invalid value array length");I=function(a){return b[a]}}else if(b&&!0===b.isMatrix){I=b.size();if(1!==I.length||I[0]!==t)throw Error("Invalid matrix length");I=function(a){return b.get([a])}}else I=function(){return b};n||(n=I(0)&&!0===I(0).isBigNumber?new u.BigNumber(0):0);var k=[];if(0<a.length)for(k=c.resize(k,a,n),a=0;a<t;a++)k[a+d][a+r]=I(a);return new l({data:k,size:[p,q]})};l.fromJSON=function(a){return new l(a)};l.prototype.swapRows=
function(a,c){if(!(f(a)&&g(a)&&f(c)&&g(c)))throw Error("Row index must be positive integers");if(2!==this._size.length)throw Error("Only two dimensional matrix is supported");n(a,this._size[0]);n(c,this._size[0]);l._swapRows(a,c,this._data);return this};l._swapRows=function(a,c,b){var d=b[a];b[a]=b[c];b[c]=d};u.Matrix._storage.dense=l;return u.Matrix._storage["default"]=l};m.lazy=!1},function(s,m,k){var w=k(25);m.name="sin";m.factory=function(b,a,c,d){var e=d("sin",{number:Math.sin,Complex:function(a){return a.sin()},
BigNumber:function(a){return a.sin()},Unit:function(a){if(!a.hasBase(b.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function sin is no angle");return e(a.value)},"Array | Matrix":function(a){return w(a,e,!0)}});e.toTex={1:"\\sin\\left(${args[0]}\\right)"};return e}},function(s,m){s.exports=function w(b,a,c){return b&&"function"===typeof b.map?b.map(function(b){return w(b,a,c)}):a(b)}},function(s,m,k){var w=k(25);m.name="cos";m.factory=function(b,a,c,d){var e=d("cos",{number:Math.cos,Complex:function(a){return a.cos()},
BigNumber:function(a){return a.cos()},Unit:function(a){if(!a.hasBase(b.Unit.BASE_UNITS.ANGLE))throw new TypeError("Unit in function cos is no angle");return e(a.value)},"Array | Matrix":function(a){return w(a,e)}});e.toTex={1:"\\cos\\left(${args[0]}\\right)"};return e}},function(s,m,k){var w=k(25);m.name="sqrt";m.factory=function(b,a,c,d){function e(c){return 0<=c||a.predictable?Math.sqrt(c):(new b.Complex(c,0)).sqrt()}var f=d("sqrt",{number:e,Complex:function(a){return a.sqrt()},BigNumber:function(c){return!c.isNegative()||
a.predictable?c.sqrt():e(c.toNumber())},"Array | Matrix":function(a){return w(a,f,!0)},Unit:function(a){return a.pow(.5)}});f.toTex={1:"\\sqrt{${args[0]}}"};return f}},function(s,m,k){m.name="norm";m.factory=function(m,b,a,c){function d(a,c){var b=a.size();if(1==b.length){if(c===Number.POSITIVE_INFINITY||"inf"===c){var x=0;a.forEach(function(a){a=e(a);r(a,x)&&(x=a)},!0);return x}if(c===Number.NEGATIVE_INFINITY||"-inf"===c){var q;a.forEach(function(a){a=e(a);if(!q||t(a,q))q=a},!0);return q||0}if("fro"===
c)return d(a,2);if("number"===typeof c&&!isNaN(c)){if(!u(c,0)){var k=0;a.forEach(function(a){k=f(g(e(a),c),k)},!0);return g(k,1/c)}return Number.POSITIVE_INFINITY}throw Error("Unsupported parameter value");}if(2==b.length){if(1===c){var m=[],F=0;a.forEach(function(a,c){var b=c[1],d=f(m[b]||0,e(a));r(d,F)&&(F=d);m[b]=d},!0);return F}if(c===Number.POSITIVE_INFINITY||"inf"===c){var w=[],E=0;a.forEach(function(a,c){var b=c[0],d=f(w[b]||0,e(a));r(d,E)&&(E=d);w[b]=d},!0);return E}if("fro"===c)return h(l(n(p(a),
a)));if(2===c)throw Error("Unsupported parameter value, missing implementation of matrix singular value decomposition");throw Error("Unsupported parameter value");}}var e=a(k(29)),f=a(k(30)),g=a(k(41)),h=a(k(27)),n=a(k(43)),u=a(k(36)),r=a(k(48)),t=a(k(52)),x=a(k(31)),l=a(k(53)),p=a(k(54)),q=c("norm",{number:Math.abs,Complex:function(a){return a.abs()},BigNumber:function(a){return a.abs()},"boolean | null":function(a){return Math.abs(a)},Array:function(a){return d(x(a),2)},Matrix:function(a){return d(a,
2)},"number | Complex | BigNumber | boolean | null, number | BigNumber | string":function(a){return q(a)},"Array, number | BigNumber | string":function(a,c){return d(x(a),c)},"Matrix, number | BigNumber | string":function(a,c){return d(a,c)}});q.toTex={1:"\\left\\|${args[0]}\\right\\|",2:void 0};return q}},function(s,m,k){var w=k(25);m.name="abs";m.factory=function(b,a,c,d){var e=d("abs",{number:Math.abs,Complex:function(a){return a.abs()},BigNumber:function(a){return a.abs()},Fraction:function(a){return a.abs()},
"Array | Matrix":function(a){return w(a,e,!0)},Unit:function(a){return a.abs()}});e.toTex={1:"\\left|${args[0]}\\right|"};return e}},function(s,m,k){var w=k(3).extend;m.name="add";m.factory=function(b,a,c,d){var e=c(k(31)),f=c(k(32));b=k(33);var g=c(k(34)),h=c(k(35)),n=c(k(38)),u=c(k(39)),r=c(k(40)),t=d("add",w({"Matrix, Matrix":function(a,c){var b;switch(a.storage()){case "sparse":switch(c.storage()){case "sparse":b=h(a,c,f);break;default:b=g(c,a,f,!0)}break;default:switch(c.storage()){case "sparse":b=
g(a,c,f,!1);break;default:b=u(a,c,f)}}return b},"Array, Array":function(a,c){return t(e(a),e(c)).valueOf()},"Array, Matrix":function(a,c){return t(e(a),c)},"Matrix, Array":function(a,c){return t(a,e(c))},"Matrix, any":function(a,c){var b;switch(a.storage()){case "sparse":b=n(a,c,f,!1);break;default:b=r(a,c,f,!1)}return b},"any, Matrix":function(a,c){var b;switch(c.storage()){case "sparse":b=n(c,a,f,!0);break;default:b=r(c,a,f,!0)}return b},"Array, any":function(a,c){return r(e(a),c,f,!1).valueOf()},
"any, Array":function(a,c){return r(e(c),a,f,!0).valueOf()}},f.signatures));t.toTex={2:"\\left(${args[0]}"+b.operators.add+"${args[1]}\\right)"};return t}},function(s,m){m.name="matrix";m.factory=function(k,m,b,a){function c(a,c,b){return new (k.Matrix.storage(c||"default"))(a,b)}m=a("matrix",{"":function(){return c([])},string:function(a){return c([],a)},"string, string":function(a,b){return c([],a,b)},Array:function(a){return c(a)},Matrix:function(a){return c(a,a.storage())},"Array | Matrix, string":c,
"Array | Matrix, string, string":c});m.toTex={0:"\\begin{bmatrix}\\end{bmatrix}",1:"\\left(${args[0]}\\right)",2:"\\left(${args[0]}\\right)"};return m}},function(s,m){m.factory=function(k,m,b,a){var c=a("add",{"number, number":function(a,c){return a+c},"Complex, Complex":function(a,c){return a.add(c)},"BigNumber, BigNumber":function(a,c){return a.plus(c)},"Fraction, Fraction":function(a,c){return a.add(c)},"Unit, Unit":function(a,b){if(null==a.value)throw Error("Parameter x contains a unit with undefined value");
if(null==b.value)throw Error("Parameter y contains a unit with undefined value");if(!a.equalBase(b))throw Error("Units do not match");var f=a.clone();f.value=c(f.value,b.value);f.fixPrefix=!1;return f}});return c}},function(s,m){m.symbols={Alpha:"A",alpha:"\\alpha",Beta:"B",beta:"\\beta",Gamma:"\\Gamma",gamma:"\\gamma",Delta:"\\Delta",delta:"\\delta",Epsilon:"E",epsilon:"\\epsilon",varepsilon:"\\varepsilon",Zeta:"Z",zeta:"\\zeta",Eta:"H",eta:"\\eta",Theta:"\\Theta",theta:"\\theta",vartheta:"\\vartheta",
Iota:"I",iota:"\\iota",Kappa:"K",kappa:"\\kappa",varkappa:"\\varkappa",Lambda:"\\Lambda",lambda:"\\lambda",Mu:"M",mu:"\\mu",Nu:"N",nu:"\\nu",Xi:"\\Xi",xi:"\\xi",Omicron:"O",omicron:"o",Pi:"\\Pi",pi:"\\pi",varpi:"\\varpi",Rho:"P",rho:"\\rho",varrho:"\\varrho",Sigma:"\\Sigma",sigma:"\\sigma",varsigma:"\\varsigma",Tau:"T",tau:"\\tau",Upsilon:"\\Upsilon",upsilon:"\\upsilon",Phi:"\\Phi",phi:"\\phi",varphi:"\\varphi",Chi:"X",chi:"\\chi",Psi:"\\Psi",psi:"\\psi",Omega:"\\Omega",omega:"\\omega","true":"\\mathrm{True}",
"false":"\\mathrm{False}",i:"i",inf:"\\infty",Inf:"\\infty",infinity:"\\infty",Infinity:"\\infty",oo:"\\infty",lim:"\\lim",undefined:"\\mathbf{?}"};m.operators={transpose:"^\\top",factorial:"!",pow:"^",dotPow:".^\\wedge",unaryPlus:"+",unaryMinus:"-",bitNot:"~",not:"\\neg",multiply:"\\cdot",divide:"\\frac",dotMultiply:".\\cdot",dotDivide:".:",mod:"\\mod",add:"+",subtract:"-",to:"\\rightarrow",leftShift:"<<",rightArithShift:">>",rightLogShift:">>>",equal:"=",unequal:"\\neq",smaller:"<",larger:">",smallerEq:"\\leq",
largerEq:"\\geq",bitAnd:"\\&",bitXor:"\\underline{|}",bitOr:"|",and:"\\wedge",xor:"\\veebar",or:"\\vee"};m.defaultTemplate="\\mathrm{${name}}\\left(${args}\\right)";var k={deg:"^\\circ"};m.toSymbol=function(w,b){if("undefined"===typeof b?0:b)return k.hasOwnProperty(w)?k[w]:"\\mathrm{"+w+"}";if(m.symbols.hasOwnProperty(w))return m.symbols[w];if(-1!==w.indexOf("_")){var a=w.indexOf("_");return m.toSymbol(w.substring(0,a))+"_{"+m.toSymbol(w.substring(a+1))+"}"}return w}},function(s,m,k){var w=k(19);
m.name="algorithm01";m.factory=function(b,a,c,d){var e=b.DenseMatrix;return function(a,c,b,n){var u=a._data,r=a._size,t=a._datatype;a=c._values;var x=c._index,l=c._ptr,p=c._size,q=c._datatype;if(r.length!==p.length)throw new w(r.length,p.length);if(r[0]!==p[0]||r[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+p+")");if(!a)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");c=r[0];r=r[1];b=(t="string"===typeof t&&t===q?t:void 0)?
d.find(b,[t,t]):b;for(var I=[],q=0;q<c;q++)I[q]=[];for(var k=[],m=[],p=0;p<r;p++){for(var B=p+1,z=l[p+1],A=l[p];A<z;A++)q=x[A],k[q]=n?b(a[A],u[q][p]):b(u[q][p],a[A]),m[q]=B;for(q=0;q<c;q++)I[q][p]=m[q]===B?k[q]:u[q][p]}return new e({data:I,size:[c,r],datatype:t})}}},function(s,m,k){var w=k(19);m.name="algorithm04";m.factory=function(b,a,c,d){var e=c(k(36)),f=b.SparseMatrix;return function(a,c,b){var u=a._values,r=a._index,t=a._ptr,x=a._size,l=a._datatype;a=c._values;var p=c._index,q=c._ptr,I=c._size,
k=c._datatype;if(x.length!==I.length)throw new w(x.length,I.length);if(x[0]!==I[0]||x[1]!==I[1])throw new RangeError("Dimension mismatch. Matrix A ("+x+") must match Matrix B ("+I+")");var m=x[0],x=x[1],B;c=e;var I=0,z=b;"string"===typeof l&&l===k&&(B=l,c=d.find(e,[B,B]),I=d.convert(0,B),z=d.find(b,[B,B]));b=u&&a?[]:void 0;l=[];k=[];B=new f({values:b,index:l,ptr:k,size:[m,x],datatype:B});var m=u&&a?[]:void 0,A=u&&a?[]:void 0,K=[],F=[],G,E,s,M;for(E=0;E<x;E++){k[E]=l.length;var Q=E+1;G=t[E];M=t[E+
1];for(s=G;s<M;s++)G=r[s],l.push(G),K[G]=Q,m&&(m[G]=u[s]);G=q[E];M=q[E+1];for(s=G;s<M;s++)if(G=p[s],K[G]===Q){if(m){var L=z(m[G],a[s]);c(L,I)?K[G]=null:m[G]=L}}else l.push(G),F[G]=Q,A&&(A[G]=a[s]);if(m&&A)for(s=k[E];s<l.length;)G=l[s],K[G]===Q?(b[s]=m[G],s++):F[G]===Q?(b[s]=A[G],s++):l.splice(s,1)}k[x]=l.length;return B}}},function(s,m,k){var w=k(6).nearlyEqual,b=k(37);m.factory=function(a,c,d,e){var f=e("equalScalar",{"boolean, boolean":function(a,c){return a===c},"number, number":function(a,b){return a===
b||w(a,b,c.epsilon)},"BigNumber, BigNumber":function(a,d){return a.eq(d)||b(a,d,c.epsilon)},"Fraction, Fraction":function(a,c){return a.equals(c)},"Complex, Complex":function(a,c){return a.equals(c)},"Unit, Unit":function(a,c){if(!a.equalBase(c))throw Error("Cannot compare units with different base");return f(a.value,c.value)},"string, string":function(a,c){return a===c}});return f}},function(s,m){s.exports=function(k,m,b){if(null==b)return k.eq(m);if(k.eq(m))return!0;if(k.isNaN()||m.isNaN())return!1;
if(k.isFinite()&&m.isFinite()){var a=k.minus(m).abs();if(a.isZero())return!0;k=k.constructor.max(k.abs(),m.abs());return a.lte(k.times(b))}return!1}},function(s,m){m.name="algorithm10";m.factory=function(k,m,b,a){var c=k.DenseMatrix;return function(b,e,f,g){var h=b._values,n=b._index,u=b._ptr,r=b._size,t=b._datatype;if(!h)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");b=r[0];var r=r[1],x,l=f;"string"===typeof t&&(x=t,e=a.convert(e,x),l=a.find(f,[x,x]));f=[];x=new c({data:f,
size:[b,r],datatype:x});for(var t=[],p=[],q=0;q<r;q++){for(var k=q+1,m=u[q+1],y=u[q];y<m;y++){var B=n[y];t[B]=h[y];p[B]=k}for(m=0;m<b;m++)0===q&&(f[m]=[]),f[m][q]=p[m]===k?g?l(e,t[m]):l(t[m],e):e}return x}}},function(s,m,k){k(14);var w=k(19);m.name="algorithm13";m.factory=function(b,a,c,d){var e=b.DenseMatrix,f=function(a,c,b,d,e,t){var x=[];if(c===b.length-1)for(c=0;c<d;c++)x[c]=a(e[c],t[c]);else for(var l=0;l<d;l++)x[l]=f(a,c+1,b,b[c+1],e[l],t[l]);return x};return function(a,c,b){var u=a._data,
r=a._size,t=a._datatype,x=c._data,l=c._size,p=c._datatype;a=[];if(r.length!==l.length)throw new w(r.length,l.length);for(var q=0;q<r.length;q++){if(r[q]!==l[q])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+l+")");a[q]=r[q]}var k,r=b;"string"===typeof t&&t===p&&(k=t,d.convert(c,k),r=d.find(b,[k,k]));c=0<a.length?f(r,0,a,a[0],u,x):[];return new e({data:c,size:a,datatype:k})}}},function(s,m,k){var w=k(3).clone;m.name="algorithm14";m.factory=function(b,a,c,d){var e=
b.DenseMatrix,f=function(a,c,b,d,e,t,x){var l=[];if(c===b.length-1)for(c=0;c<d;c++)l[c]=x?a(t,e[c]):a(e[c],t);else for(var p=0;p<d;p++)l[p]=f(a,c+1,b,b[c+1],e[p],t,x);return l};return function(a,c,b,u){var r=a._data,t=a._size;a=a._datatype;var x,l=b;"string"===typeof a&&(x=a,c=d.convert(c,x),l=d.find(b,[x,x]));c=0<t.length?f(l,0,t,t[0],r,c,u):[];return new e({data:c,size:w(t),datatype:x})}}},function(s,m,k){var w=k(6).isInteger,b=k(15).size;m.name="pow";m.factory=function(a,c,d,e){function f(b,d){if(c.predictable&&
!w(d)&&0>b)try{var e=x(d),f=l(e);if((d===f||1E-14>Math.abs((d-f)/d))&&1===e.d%2)return(0===e.n%2?1:-1)*Math.pow(-b,d)}catch(h){}return w(d)||0<=b||c.predictable?Math.pow(b,d):(new a.Complex(b,0)).pow(d,0)}function g(a,c){if(!w(c)||0>c)throw new TypeError("For A^b, b must be a positive integer (value is "+c+")");var d=b(a);if(2!=d.length)throw Error("For A^b, A must be 2 dimensional (A has "+d.length+" dimensions)");if(d[0]!=d[1])throw Error("For A^b, A must be square (size is "+d[0]+"x"+d[1]+")");
for(var d=u(d[0]).valueOf(),e=a;1<=c;)1==(c&1)&&(d=r(e,d)),c>>=1,e=r(e,e);return d}function h(a,c){return t(g(a.valueOf(),c))}var n=k(33),u=d(k(42)),r=d(k(43)),t=d(k(31)),x=d(k(46)),l=d(k(47));d=e("pow",{"number, number":f,"Complex, Complex":function(a,c){return a.pow(c)},"BigNumber, BigNumber":function(b,d){return d.isInteger()||0<=b||c.predictable?b.pow(d):(new a.Complex(b.toNumber(),0)).pow(d.toNumber(),0)},"Fraction, Fraction":function(a,b){if(1!==b.d){if(c.predictable)throw Error("Function pow does not support non-integer exponents for fractions.");
return f(a.valueOf(),b.valueOf())}return a.pow(b)},"Array, number":g,"Array, BigNumber":function(a,c){return g(a,c.toNumber())},"Matrix, number":h,"Matrix, BigNumber":function(a,c){return h(a,c.toNumber())},"Unit, number":function(a,c){return a.pow(c)}});d.toTex={2:"\\left(${args[0]}\\right)"+n.operators.pow+"{${args[1]}}"};return d}},function(s,m,k){var w=k(15),b=k(6).isInteger;m.name="eye";m.factory=function(a,c,d,e){function f(a,c){switch(a.length){case 0:return c?h(c):[];case 1:return g(a[0],
a[0],c);case 2:return g(a[0],a[1],c);default:throw Error("Vector containing two values expected");}}function g(c,d,e){var f=c&&!0===c.isBigNumber?a.BigNumber:d&&!0===d.isBigNumber?a.BigNumber:null;c&&!0===c.isBigNumber&&(c=c.toNumber());d&&!0===d.isBigNumber&&(d=d.toNumber());if(!b(c)||1>c)throw Error("Parameters in function eye must be positive integers");if(!b(d)||1>d)throw Error("Parameters in function eye must be positive integers");var h=f?new a.BigNumber(1):1,f=f?new f(0):0,g=[c,d];if(e)return a.Matrix.storage(e).diagonal(g,
h,0,f);e=w.resize([],g,f);c=c<d?c:d;for(d=0;d<c;d++)e[d][d]=h;return e}var h=d(k(31));d=e("eye",{"":function(){return"Matrix"===c.matrix?h([]):[]},string:function(a){return h(a)},"number | BigNumber":function(a){return g(a,a,"Matrix"===c.matrix?"default":void 0)},"number | BigNumber, string":function(a,c){return g(a,a,c)},"number | BigNumber, number | BigNumber":function(a,b){return g(a,b,"Matrix"===c.matrix?"default":void 0)},"number | BigNumber, number | BigNumber, string":function(a,c,b){return g(a,
c,b)},Array:function(a){return f(a)},"Array, string":function(a,c){return f(a,c)},Matrix:function(a){return f(a.valueOf(),a.storage())},"Matrix, string":function(a,c){return f(a.valueOf(),c)}});d.toTex=void 0;return d}},function(s,m,k){var w=k(3).extend,b=k(15);m.name="multiply";m.factory=function(a,c,d,e){c=k(33);var f=d(k(31)),g=d(k(32)),h=d(k(44)),n=d(k(36)),u=d(k(45)),r=d(k(40)),t=a.DenseMatrix,x=a.SparseMatrix,l=e("multiply",w({"Array, Array":function(a,c){p(b.size(a),b.size(c));var d=l(f(a),
f(c));return d&&!0===d.isMatrix?d.valueOf():d},"Matrix, Matrix":function(a,c){var b=a.size(),d=c.size();p(b,d);if(1===b.length){if(1===d.length){var f=b[0];if(0===f)throw Error("Cannot multiply two empty vectors");var l=a._data,r=a._datatype,u=c._data,k=c._datatype,b=g,d=h;r&&k&&r===k&&"string"===typeof r&&(b=e.find(g,[r,r]),d=e.find(h,[r,r]));r=d(l[0],u[0]);for(k=1;k<f;k++)r=b(r,d(l[k],u[k]));return r}a:{switch(c.storage()){case "dense":var f=a._data,m=a._datatype,l=c._data,w=c._datatype,b=a._size[0],
d=c._size[1],r=g,k=h;m&&w&&m===w&&"string"===typeof m&&(u=m,r=e.find(g,[u,u]),k=e.find(h,[u,u]));m=[];for(w=0;w<d;w++){for(var s=k(f[0],l[0][w]),Q=1;Q<b;Q++)s=r(s,k(f[Q],l[Q][w]));m[w]=s}f=new t({data:m,size:[d],datatype:u});break a}throw Error("Not implemented");}return f}if(1===d.length){a:{switch(a.storage()){case "dense":f=a._data;d=a._size;m=a._datatype;u=c._data;w=c._datatype;b=d[0];d=d[1];r=g;k=h;m&&w&&m===w&&"string"===typeof m&&(l=m,r=e.find(g,[l,l]),k=e.find(h,[l,l]));m=[];for(w=0;w<b;w++){for(var s=
f[w],Q=k(s[0],u[0]),L=1;L<d;L++)Q=r(Q,k(s[L],u[L]));m[w]=Q}f=new t({data:m,size:[b],datatype:l});break a;case "sparse":var r=a._values,k=a._index,m=a._ptr,D=a._datatype;if(!r)throw Error("Cannot multiply Pattern only Matrix times Dense Matrix");var w=c._data,P=c._datatype,l=a._size[0],s=c._size[0],u=[],b=[],d=[],Q=g,L=h,N=n,T=0;D&&P&&D===P&&"string"===typeof D&&(f=D,Q=e.find(g,[f,f]),L=e.find(h,[f,f]),N=e.find(n,[f,f]),T=e.convert(0,f));for(var D=[],P=[],H=d[0]=0;H<s;H++){var J=w[H];if(!N(J,T))for(var O=
m[H+1],Y=m[H];Y<O;Y++){var V=k[Y];P[V]?D[V]=Q(D[V],L(J,r[Y])):(P[V]=!0,b.push(V),D[V]=L(J,r[Y]))}}r=b.length;for(k=0;k<r;k++)u[k]=D[b[k]];d[1]=b.length;f=new x({values:u,index:b,ptr:d,size:[l,1],datatype:f});break a}f=void 0}return f}return q(a,c)},"Matrix, Array":function(a,c){return l(a,f(c))},"Array, Matrix":function(a,c){return l(f(a,c.storage()),c)},"Matrix, any":function(a,c){var b;switch(a.storage()){case "sparse":b=u(a,c,h,!1);break;case "dense":b=r(a,c,h,!1)}return b},"any, Matrix":function(a,
c){var b;switch(c.storage()){case "sparse":b=u(c,a,h,!0);break;case "dense":b=r(c,a,h,!0)}return b},"Array, any":function(a,c){return r(f(a),c,h,!1).valueOf()},"any, Array":function(a,c){return r(f(c),a,h,!0).valueOf()}},h.signatures)),p=function(a,c){switch(a.length){case 1:switch(c.length){case 1:if(a[0]!==c[0])throw new RangeError("Dimension mismatch in multiplication. Vectors must have the same length");break;case 2:if(a[0]!==c[0])throw new RangeError("Dimension mismatch in multiplication. Vector length ("+
a[0]+") must match Matrix rows ("+c[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+c.length+" dimensions)");}break;case 2:switch(c.length){case 1:if(a[1]!==c[0])throw new RangeError("Dimension mismatch in multiplication. Matrix columns ("+a[1]+") must match Vector length ("+c[0]+")");break;case 2:if(a[1]!==c[0])throw new RangeError("Dimension mismatch in multiplication. Matrix A columns ("+a[1]+") must match Matrix B rows ("+c[0]+")");break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix B has "+
c.length+" dimensions)");}break;default:throw Error("Can only multiply a 1 or 2 dimensional matrix (Matrix A has "+a.length+" dimensions)");}},q=function(a,c){switch(a.storage()){case "dense":switch(c.storage()){case "dense":var b=a._data,d=a._size,f=a._datatype,l=c._data,r=c._datatype,u=d[0],p=d[1],q=c._size[1],k,m=g,w=h;f&&r&&f===r&&"string"===typeof f&&(k=f,m=e.find(g,[k,k]),w=e.find(h,[k,k]));for(var s=[],D=0;D<u;D++){var P=b[D];s[D]=[];for(var N=0;N<q;N++){for(var T=w(P[0],l[0][N]),H=1;H<p;H++)T=
m(T,w(P[H],l[H][N]));s[D][N]=T}}return new t({data:s,size:[u,q],datatype:k});case "sparse":var J=a._data,O=a._size,Y=a._datatype,V=c._values,sa=c._index,Na=c._ptr,ca=c._size,ua=c._datatype;if(!V)throw Error("Cannot multiply Dense Matrix times Pattern only Matrix");var X=O[0],ta=ca[1],pa,ia=g,qa=h,Ca=n,Da=0;Y&&ua&&Y===ua&&"string"===typeof Y&&(pa=Y,ia=e.find(g,[pa,pa]),qa=e.find(h,[pa,pa]),Ca=e.find(n,[pa,pa]),Da=e.convert(0,pa));for(var oa=[],xa=[],ya=[],Ka=new x({values:oa,index:xa,ptr:ya,size:[X,
ta],datatype:pa}),ka=0;ka<ta;ka++){ya[ka]=xa.length;var W=Na[ka],Ga=Na[ka+1];if(Ga>W)for(var ha=0,$=0;$<X;$++){for(var da=$+1,za,fa=W;fa<Ga;fa++){var la=sa[fa];ha!==da?(za=qa(J[$][la],V[fa]),ha=da):za=ia(za,qa(J[$][la],V[fa]))}ha!==da||Ca(za,Da)||(xa.push($),oa.push(za))}}ya[ta]=xa.length;return Ka}break;case "sparse":switch(c.storage()){case "dense":var aa=a._values,ma=a._index,ea=a._ptr,ba=a._datatype;if(!aa)throw Error("Cannot multiply Pattern only Matrix times Dense Matrix");var Z=c._data,Ea=
c._datatype,Aa=a._size[0],na=c._size[0],Ba=c._size[1],va,eb=g,ab=h,fb=n,Ra=0;ba&&Ea&&ba===Ea&&"string"===typeof ba&&(va=ba,eb=e.find(g,[va,va]),ab=e.find(h,[va,va]),fb=e.find(n,[va,va]),Ra=e.convert(0,va));for(var ra=[],S=[],Ha=[],Oa=new x({values:ra,index:S,ptr:Ha,size:[Aa,Ba],datatype:va}),v=[],gb=[],Pa=0;Pa<Ba;Pa++){Ha[Pa]=S.length;for(var ja=Pa+1,wa=0;wa<na;wa++){var U=Z[wa][Pa];if(!fb(U,Ra))for(var ga=ea[wa+1],Ia=ea[wa];Ia<ga;Ia++){var Fa=ma[Ia];gb[Fa]!==ja?(gb[Fa]=ja,S.push(Fa),v[Fa]=ab(U,aa[Ia])):
v[Fa]=eb(v[Fa],ab(U,aa[Ia]))}}for(var Ua=S.length,Va=Ha[Pa];Va<Ua;Va++)ra[Va]=v[S[Va]]}Ha[Ba]=S.length;return Oa;case "sparse":var bb=a._values,cb=a._index,Wa=a._ptr,Xa=a._datatype,Ya=c._values,yb=c._index,sb=c._ptr,tb=c._datatype,zb=a._size[0],qb=c._size[1],hb=bb&&Ya,Za,ub=g,rb=h;Xa&&tb&&Xa===tb&&"string"===typeof Xa&&(Za=Xa,ub=e.find(g,[Za,Za]),rb=e.find(h,[Za,Za]));for(var vb=hb?[]:void 0,Sa=[],ib=[],Ab=new x({values:vb,index:Sa,ptr:ib,size:[zb,qb],datatype:Za}),jb=hb?[]:void 0,kb=[],Ma,lb,mb,
$a,wb,xb,Ja,db,Ta=0;Ta<qb;Ta++){ib[Ta]=Sa.length;var nb=Ta+1;wb=sb[Ta];xb=sb[Ta+1];for($a=wb;$a<xb;$a++)if(db=yb[$a],hb)for(lb=Wa[db],mb=Wa[db+1],Ma=lb;Ma<mb;Ma++)Ja=cb[Ma],kb[Ja]!==nb?(kb[Ja]=nb,Sa.push(Ja),jb[Ja]=rb(Ya[$a],bb[Ma])):jb[Ja]=ub(jb[Ja],rb(Ya[$a],bb[Ma]));else for(lb=Wa[db],mb=Wa[db+1],Ma=lb;Ma<mb;Ma++)Ja=cb[Ma],kb[Ja]!==nb&&(kb[Ja]=nb,Sa.push(Ja));if(hb)for(var Bb=Sa.length,ob=ib[Ta];ob<Bb;ob++)vb[ob]=jb[Sa[ob]]}ib[qb]=Sa.length;return Ab}}};l.toTex={2:"\\left(${args[0]}"+c.operators.multiply+
"${args[1]}\\right)"};return l}},function(s,m){m.factory=function(k,m,b,a){var c=a("multiplyScalar",{"number, number":function(a,c){return a*c},"Complex, Complex":function(a,c){return a.mul(c)},"BigNumber, BigNumber":function(a,c){return a.times(c)},"Fraction, Fraction":function(a,c){return a.mul(c)},"number | Fraction | BigNumber | Complex, Unit":function(a,b){var f=b.clone();f.value=null===f.value?f._normalize(a):c(f.value,a);return f},"Unit, number | Fraction | BigNumber | Complex":function(a,
b){var f=a.clone();f.value=null===f.value?f._normalize(b):c(f.value,b);return f},"Unit, Unit":function(a,c){return a.multiply(c)}});return c}},function(s,m,k){m.name="algorithm11";m.factory=function(m,b,a,c){var d=a(k(36)),e=m.SparseMatrix;return function(a,b,h,n){var u=a._values,r=a._index,t=a._ptr,x=a._size,l=a._datatype;if(!u)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");var p=x[0],x=x[1],q;a=d;var k=0,m=h;"string"===typeof l&&(q=l,a=c.find(d,[q,q]),k=c.convert(0,
q),b=c.convert(b,q),m=c.find(h,[q,q]));h=[];var l=[],y=[];q=new e({values:h,index:l,ptr:y,size:[p,x],datatype:q});for(p=0;p<x;p++){y[p]=l.length;for(var B=t[p+1],z=t[p];z<B;z++){var A=r[z],w=n?m(b,u[z]):m(u[z],b);a(w,k)||(l.push(A),h.push(w))}}y[x]=l.length;return q}}},function(s,m,k){var w=k(25);m.name="fraction";m.factory=function(b,a,c,d){var e=d("fraction",{number:function(a){if(!isFinite(a)||isNaN(a))throw Error(a+" cannot be represented as a fraction");return new b.Fraction(a)},string:function(a){return new b.Fraction(a)},
"number, number":function(a,c){return new b.Fraction(a,c)},BigNumber:function(a){return new b.Fraction(a.toString())},Fraction:function(a){return a},Object:function(a){return new b.Fraction(a)},"Array | Matrix":function(a){return w(a,e)}});return e}},function(s,m,k){var w=k(25);m.name="number";m.factory=function(b,a,c,d){var e=d("number",{"":function(){return 0},number:function(a){return a},string:function(a){var c=Number(a);if(isNaN(c))throw new SyntaxError('String "'+a+'" is no valid number');return c},
BigNumber:function(a){return a.toNumber()},Fraction:function(a){return a.valueOf()},Unit:function(a){throw Error("Second argument with valueless unit expected");},"Unit, string | Unit":function(a,c){return a.toNumber(c)},"Array | Matrix":function(a){return w(a,e)}});e.toTex={0:"0",1:"\\left(${args[0]}\\right)",2:"\\left(\\left(${args[0]}\\right)${args[1]}\\right)"};return e}},function(s,m,k){var w=k(6).nearlyEqual,b=k(37);m.name="larger";m.factory=function(a,c,d,e){var f=d(k(31)),g=d(k(49)),h=d(k(50)),
n=d(k(51)),u=d(k(39)),r=d(k(40));a=k(33);var t=e("larger",{"boolean, boolean":function(a,c){return a>c},"number, number":function(a,b){return a>b&&!w(a,b,c.epsilon)},"BigNumber, BigNumber":function(a,d){return a.gt(d)&&!b(a,d,c.epsilon)},"Fraction, Fraction":function(a,c){return 1===a.compare(c)},"Complex, Complex":function(){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(a,c){if(!a.equalBase(c))throw Error("Cannot compare units with different base");
return t(a.value,c.value)},"string, string":function(a,c){return a>c},"Matrix, Matrix":function(a,c){var b;switch(a.storage()){case "sparse":switch(c.storage()){case "sparse":b=h(a,c,t);break;default:b=g(c,a,t,!0)}break;default:switch(c.storage()){case "sparse":b=g(a,c,t,!1);break;default:b=u(a,c,t)}}return b},"Array, Array":function(a,c){return t(f(a),f(c)).valueOf()},"Array, Matrix":function(a,c){return t(f(a),c)},"Matrix, Array":function(a,c){return t(a,f(c))},"Matrix, any":function(a,c){var b;
switch(a.storage()){case "sparse":b=n(a,c,t,!1);break;default:b=r(a,c,t,!1)}return b},"any, Matrix":function(a,c){var b;switch(c.storage()){case "sparse":b=n(c,a,t,!0);break;default:b=r(c,a,t,!0)}return b},"Array, any":function(a,c){return r(f(a),c,t,!1).valueOf()},"any, Array":function(a,c){return r(f(c),a,t,!0).valueOf()}});t.toTex={2:"\\left(${args[0]}"+a.operators.larger+"${args[1]}\\right)"};return t}},function(s,m,k){var w=k(19);m.name="algorithm03";m.factory=function(b,a,c,d){var e=b.DenseMatrix;
return function(a,c,b,n){var u=a._data,r=a._size,t=a._datatype;a=c._values;var x=c._index,l=c._ptr,p=c._size,q=c._datatype;if(r.length!==p.length)throw new w(r.length,p.length);if(r[0]!==p[0]||r[1]!==p[1])throw new RangeError("Dimension mismatch. Matrix A ("+r+") must match Matrix B ("+p+")");if(!a)throw Error("Cannot perform operation on Dense Matrix and Pattern Sparse Matrix");c=r[0];var r=r[1],k,p=0,m=b;"string"===typeof t&&t===q&&(k=t,p=d.convert(0,k),m=d.find(b,[k,k]));b=[];for(t=0;t<c;t++)b[t]=
[];for(var t=[],q=[],y=0;y<r;y++){for(var B=y+1,z=l[y+1],A=l[y];A<z;A++){var s=x[A];t[s]=n?m(a[A],u[s][y]):m(u[s][y],a[A]);q[s]=B}for(z=0;z<c;z++)b[z][y]=q[z]===B?t[z]:n?m(p,u[z][y]):m(u[z][y],p)}return new e({data:b,size:[c,r],datatype:k})}}},function(s,m,k){var w=k(19);m.name="algorithm07";m.factory=function(b,a,c,d){var e=b.DenseMatrix,f=function(a,c,b,d,e){var f=a._values,x=a._index,l=a._ptr;a=l[c];for(c=l[c+1];a<c;a++)l=x[a],b[l]=e,d[l]=f[a]};return function(a,c,b){var u=a._size,r=a._datatype,
t=c._size,x=c._datatype;if(u.length!==t.length)throw new w(u.length,t.length);if(u[0]!==t[0]||u[1]!==t[1])throw new RangeError("Dimension mismatch. Matrix A ("+u+") must match Matrix B ("+t+")");var t=u[0],u=u[1],l,p=0,q=b;"string"===typeof r&&r===x&&(l=r,p=d.convert(0,l),q=d.find(b,[l,l]));r=[];for(b=0;b<t;b++)r[b]=[];var x=new e({data:r,size:[t,u],datatype:l}),k=[],m=[],y=[],B=[];for(l=0;l<u;l++){var z=l+1;f(a,l,y,k,z);f(c,l,B,m,z);for(b=0;b<t;b++)r[b][l]=q(y[b]===z?k[b]:p,B[b]===z?m[b]:p)}return x}}},
function(s,m){m.name="algorithm12";m.factory=function(k,m,b,a){var c=k.DenseMatrix;return function(b,e,f,g){var h=b._values,n=b._index,u=b._ptr,r=b._size,t=b._datatype;if(!h)throw Error("Cannot perform operation on Pattern Sparse Matrix and Scalar value");b=r[0];var r=r[1],x,l=f;"string"===typeof t&&(x=t,e=a.convert(e,x),l=a.find(f,[x,x]));f=[];x=new c({data:f,size:[b,r],datatype:x});for(var t=[],p=[],q=0;q<r;q++){for(var k=q+1,m=u[q+1],y=u[q];y<m;y++){var B=n[y];t[B]=h[y];p[B]=k}for(m=0;m<b;m++)0===
q&&(f[m]=[]),f[m][q]=p[m]===k?g?l(e,t[m]):l(t[m],e):g?l(e,0):l(0,e)}return x}}},function(s,m,k){var w=k(6).nearlyEqual,b=k(37);m.name="smaller";m.factory=function(a,c,d,e){var f=d(k(31)),g=d(k(49)),h=d(k(50)),n=d(k(51)),u=d(k(39)),r=d(k(40));a=k(33);var t=e("smaller",{"boolean, boolean":function(a,c){return a<c},"number, number":function(a,b){return a<b&&!w(a,b,c.epsilon)},"BigNumber, BigNumber":function(a,d){return a.lt(d)&&!b(a,d,c.epsilon)},"Fraction, Fraction":function(a,c){return-1===a.compare(c)},
"Complex, Complex":function(a,c){throw new TypeError("No ordering relation is defined for complex numbers");},"Unit, Unit":function(a,c){if(!a.equalBase(c))throw Error("Cannot compare units with different base");return t(a.value,c.value)},"string, string":function(a,c){return a<c},"Matrix, Matrix":function(a,c){var b;switch(a.storage()){case "sparse":switch(c.storage()){case "sparse":b=h(a,c,t);break;default:b=g(c,a,t,!0)}break;default:switch(c.storage()){case "sparse":b=g(a,c,t,!1);break;default:b=
u(a,c,t)}}return b},"Array, Array":function(a,c){return t(f(a),f(c)).valueOf()},"Array, Matrix":function(a,c){return t(f(a),c)},"Matrix, Array":function(a,c){return t(a,f(c))},"Matrix, any":function(a,c){var b;switch(a.storage()){case "sparse":b=n(a,c,t,!1);break;default:b=r(a,c,t,!1)}return b},"any, Matrix":function(a,c){var b;switch(c.storage()){case "sparse":b=n(c,a,t,!0);break;default:b=r(c,a,t,!0)}return b},"Array, any":function(a,c){return r(f(a),c,t,!1).valueOf()},"any, Array":function(a,c){return r(f(c),
a,t,!0).valueOf()}});t.toTex={2:"\\left(${args[0]}"+a.operators.smaller+"${args[1]}\\right)"};return t}},function(s,m,k){var w=k(3).clone,b=k(16).format;m.name="trace";m.factory=function(a,c,d,e){var f=d(k(31)),g=d(k(30)),h=e("trace",{Array:function(a){return h(f(a))},Matrix:function(a){var c;switch(a.storage()){case "dense":a:{var d=a._size;c=a._data;switch(d.length){case 1:if(1==d[0]){c=w(c[0]);break a}throw new RangeError("Matrix must be square (size: "+b(d)+")");case 2:var e=d[0];if(e===d[1]){for(a=
d=0;a<e;a++)d=g(d,c[a][a]);c=d;break a}throw new RangeError("Matrix must be square (size: "+b(d)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+b(d)+")");}}break;case "sparse":c=a._values;var e=a._index,d=a._ptr,f=a._size;a=f[1];if(f[0]===a){f=0;if(0<c.length)for(var h=0;h<a;h++)for(var p=d[h+1],q=d[h];q<p;q++){var k=e[q];if(k===h){f=g(f,c[q]);break}if(k>h)break}c=f}else throw new RangeError("Matrix must be square (size: "+b(f)+")");}return c},any:w});h.toTex={1:"\\mathrm{tr}\\left(${args[0]}\\right)"};
return h}},function(s,m,k){var w=k(3).clone,b=k(16).format;m.name="transpose";m.factory=function(a,c,d,e){c=k(33);var f=d(k(31)),g=a.DenseMatrix,h=a.SparseMatrix,n=e("transpose",{Array:function(a){return n(f(a)).valueOf()},Matrix:function(a){var c=a.size(),d;switch(c.length){case 1:d=a.clone();break;case 2:var e=c[0],f=c[1];if(0===f)throw new RangeError("Cannot transpose a 2D matrix with no columns (size: "+b(c)+")");switch(a.storage()){case "dense":c=a._data;d=[];for(var n,q=0;q<f;q++){n=d[q]=[];
for(var k=0;k<e;k++)n[k]=w(c[k][q])}d=new g({data:d,size:[f,e],datatype:a._datatype});break;case "sparse":c=a._values;d=a._index;n=a._ptr;for(var q=c?[]:void 0,k=[],m=[],y=[],B=0;B<e;B++)y[B]=0;var z,B=0;for(z=d.length;B<z;B++)y[d[B]]++;for(z=B=0;z<e;z++)m.push(B),B+=y[z],y[z]=m[z];m.push(B);for(B=0;B<f;B++){z=n[B+1];for(var A=n[B];A<z;A++){var s=y[d[A]]++;k[s]=B;c&&(q[s]=w(c[A]))}}d=new h({values:q,index:k,ptr:m,size:[f,e],datatype:a._datatype})}break;default:throw new RangeError("Matrix must be a vector or two dimensional (size: "+
b(this._size)+")");}return d},any:function(a){return w(a)}});n.toTex={1:"\\left(${args[0]}\\right)"+c.operators.transpose};return n}},function(s,m,k){var w=k(3).extend;m.name="divide";m.factory=function(b,a,c,d){var e=c(k(56)),f=c(k(43)),g=c(k(57)),h=c(k(31)),n=c(k(45)),u=c(k(40));b=d("divide",w({"Array | Matrix, Array | Matrix":function(a,c){return f(a,g(c))},"Matrix, any":function(a,c){var b;switch(a.storage()){case "sparse":b=n(a,c,e,!1);break;case "dense":b=u(a,c,e,!1)}return b},"Array, any":function(a,
c){return u(h(a),c,e,!1).valueOf()},"any, Array | Matrix":function(a,c){return f(a,g(c))}},e.signatures));b.toTex={2:"\\frac{${args[0]}}{${args[1]}}"};return b}},function(s,m,k){m.factory=function(m,b,a,c){var d=a(k(44)),e=c("divide",{"number, number":function(a,c){return a/c},"Complex, Complex":function(a,c){return a.div(c)},"BigNumber, BigNumber":function(a,c){return a.div(c)},"Fraction, Fraction":function(a,c){return a.div(c)},"Unit, number | Fraction | BigNumber":function(a,c){var b=a.clone();
b.value=e(null===b.value?b._normalize(1):b.value,c);return b},"number | Fraction | BigNumber, Unit":function(a,c){var b=c.pow(-1);b.value=d(null===b.value?b._normalize(1):b.value,a);return b},"Unit, Unit":function(a,c){return a.divide(c)}});return e}},function(s,m,k){var w=k(14);m.name="inv";m.factory=function(b,a,c,d){function e(a,c,b){var d,e;if(1==c){c=a[0][0];if(0==c)throw Error("Cannot calculate inverse, determinant is zero");return[[g(1,c)]]}if(2==c){c=r(a);if(0==c)throw Error("Cannot calculate inverse, determinant is zero");
return[[g(a[1][1],c),g(u(a[0][1]),c)],[g(u(a[1][0]),c),g(a[0][0],c)]]}var f=a.concat();for(a=0;a<c;a++)f[a]=f[a].concat();for(var k=t(c).valueOf(),m=0;m<b;m++){for(a=m;a<c&&0==f[a][m];)a++;if(a==c||0==f[a][m])throw Error("Cannot calculate inverse, determinant is zero");a!=m&&(d=f[m],f[m]=f[a],f[a]=d,d=k[m],k[m]=k[a],k[a]=d);var z=f[m],A=k[m];for(a=0;a<c;a++){var w=f[a],s=k[a];if(a!=m){if(0!=w[m]){e=g(u(w[m]),z[m]);for(d=m;d<b;d++)w[d]=h(w[d],n(e,z[d]));for(d=0;d<b;d++)s[d]=h(s[d],n(e,A[d]))}}else{e=
z[m];for(d=m;d<b;d++)w[d]=g(w[d],e);for(d=0;d<b;d++)s[d]=g(s[d],e)}}}return k}var f=c(k(31)),g=c(k(56)),h=c(k(32)),n=c(k(43)),u=c(k(58)),r=c(k(59)),t=c(k(42));b=d("inv",{"Array | Matrix":function(a){var c=!0===a.isMatrix?a.size():w.array.size(a);switch(c.length){case 1:if(1==c[0])return!0===a.isMatrix?f([g(1,a.valueOf()[0])]):[g(1,a[0])];throw new RangeError("Matrix must be square (size: "+w.string.format(c)+")");case 2:var b=c[0],d=c[1];if(b==d)return!0===a.isMatrix?f(e(a.valueOf(),b,d),a.storage()):
e(a,b,d);throw new RangeError("Matrix must be square (size: "+w.string.format(c)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+w.string.format(c)+")");}},any:function(a){return g(1,a)}});b.toTex={1:"\\left(${args[0]}\\right)^{-1}"};return b}},function(s,m,k){var w=k(25);m.name="unaryMinus";m.factory=function(b,a,c,d){b=k(33);var e=d("unaryMinus",{number:function(a){return-a},Complex:function(a){return a.neg()},BigNumber:function(a){return a.neg()},Fraction:function(a){return a.neg()},
Unit:function(a){var c=a.clone();c.value=e(a.value);return c},"Array | Matrix":function(a){return w(a,e,!0)}});e.toTex={1:b.operators.unaryMinus+"\\left(${args[0]}\\right)"};return e}},function(s,m,k){s=k(14);var w=s.object,b=s.string;m.name="det";m.factory=function(a,c,d,e){var f=d(k(31)),g=d(k(30)),h=d(k(60)),n=d(k(43)),u=d(k(58));a=e("det",{any:function(a){return w.clone(a)},"Array | Matrix":function(a){var c;a&&!0===a.isMatrix?c=a.size():Array.isArray(a)?(a=f(a),c=a.size()):c=[];switch(c.length){case 0:return w.clone(a);
case 1:if(1==c[0])return w.clone(a.valueOf()[0]);throw new RangeError("Matrix must be square (size: "+b.format(c)+")");case 2:var d=c[0];if(d==c[1]){a=a.clone().valueOf();if(1==d)d=w.clone(a[0][0]);else if(2==d)d=h(n(a[0][0],a[1][1]),n(a[1][0],a[0][1]));else{var e=a;for(c=0;c<d-1;c++){for(var p=void 0,q=void 0,k=Array(e.length),m=0,p=1;p<e.length;p++)m=g(m,e[p][p]);for(p=0;p<e.length;p++){k[p]=Array(e.length);k[p][p]=u(m);for(q=0;q<p;q++)k[p][q]=0;for(q=p+1;q<e.length;q++)k[p][q]=e[p][q];p+1<e.length&&
(m=h(m,e[p+1][p+1]))}e=n(k,a)}d=0==d%2?u(e[0][0]):e[0][0]}return d}throw new RangeError("Matrix must be square (size: "+b.format(c)+")");default:throw new RangeError("Matrix must be two dimensional (size: "+b.format(c)+")");}}});a.toTex={1:"\\det\\left(${args[0]}\\right)"};return a}},function(s,m,k){var w=k(19);m.name="subtract";m.factory=function(b,a,c,d){b=k(33);var e=c(k(31)),f=c(k(32)),g=c(k(58)),h=c(k(34)),n=c(k(49)),u=c(k(61)),r=c(k(38)),m=c(k(39)),x=c(k(40)),l=d("subtract",{"number, number":function(a,
c){return a-c},"Complex, Complex":function(a,c){return a.sub(c)},"BigNumber, BigNumber":function(a,c){return a.minus(c)},"Fraction, Fraction":function(a,c){return a.sub(c)},"Unit, Unit":function(a,c){if(null==a.value)throw Error("Parameter x contains a unit with undefined value");if(null==c.value)throw Error("Parameter y contains a unit with undefined value");if(!a.equalBase(c))throw Error("Units do not match");var b=a.clone();b.value=l(b.value,c.value);b.fixPrefix=!1;return b},"Matrix, Matrix":function(a,
c){var b=a.size(),d=c.size();if(b.length!==d.length)throw new w(b.length,d.length);switch(a.storage()){case "sparse":switch(c.storage()){case "sparse":b=u(a,c,l);break;default:b=n(c,a,l,!0)}break;default:switch(c.storage()){case "sparse":b=h(a,c,l,!1);break;default:b=m(a,c,l)}}return b},"Array, Array":function(a,c){return l(e(a),e(c)).valueOf()},"Array, Matrix":function(a,c){return l(e(a),c)},"Matrix, Array":function(a,c){return l(a,e(c))},"Matrix, any":function(a,c){var b;switch(a.storage()){case "sparse":b=
r(a,g(c),f);break;default:b=x(a,c,l)}return b},"any, Matrix":function(a,c){var b;switch(c.storage()){case "sparse":b=r(c,a,l,!0);break;default:b=x(c,a,l,!0)}return b},"Array, any":function(a,c){return x(e(a),c,l,!1).valueOf()},"any, Array":function(a,c){return x(e(c),a,l,!0).valueOf()}});l.toTex={2:"\\left(${args[0]}"+b.operators.subtract+"${args[1]}\\right)"};return l}},function(s,m,k){var w=k(19);m.name="algorithm05";m.factory=function(b,a,c,d){var e=c(k(36)),f=b.SparseMatrix;return function(a,
c,b){var u=a._values,r=a._index,k=a._ptr,m=a._size,l=a._datatype;a=c._values;var p=c._index,q=c._ptr,I=c._size,s=c._datatype;if(m.length!==I.length)throw new w(m.length,I.length);if(m[0]!==I[0]||m[1]!==I[1])throw new RangeError("Dimension mismatch. Matrix A ("+m+") must match Matrix B ("+I+")");var y=m[0],m=m[1],B;c=e;var I=0,z=b;"string"===typeof l&&l===s&&(B=l,c=d.find(e,[B,B]),I=d.convert(0,B),z=d.find(b,[B,B]));b=u&&a?[]:void 0;l=[];s=[];B=new f({values:b,index:l,ptr:s,size:[y,m],datatype:B});
var y=b?[]:void 0,A=b?[]:void 0,K=[],F=[],G,E,R,M;for(E=0;E<m;E++){s[E]=l.length;var Q=E+1;R=k[E];for(M=k[E+1];R<M;R++)G=r[R],l.push(G),K[G]=Q,y&&(y[G]=u[R]);R=q[E];for(M=q[E+1];R<M;R++)G=p[R],K[G]!==Q&&l.push(G),F[G]=Q,A&&(A[G]=a[R]);if(b)for(R=s[E];R<l.length;){G=l[R];M=K[G];var L=F[G];if(M===Q||L===Q)G=z(M===Q?y[G]:I,L===Q?A[G]:I),c(G,I)?l.splice(R,1):(b.push(G),R++)}}s[m]=l.length;return B}}},function(s,m,k){var w=k(15).size;m.name="cross";m.factory=function(b,a,c,d){function e(a,c){var b=w(a),
d=w(c);if(1!=b.length||1!=d.length||3!=b[0]||3!=d[0])throw new RangeError("Vectors with length 3 expected (Size A = ["+b.join(", ")+"], B = ["+d.join(", ")+"])");return[g(h(a[1],c[2]),h(a[2],c[1])),g(h(a[2],c[0]),h(a[0],c[2])),g(h(a[0],c[1]),h(a[1],c[0]))]}var f=c(k(31)),g=c(k(60)),h=c(k(43));b=d("cross",{"Matrix, Matrix":function(a,c){return f(e(a.toArray(),c.toArray()))},"Matrix, Array":function(a,c){return f(e(a.toArray(),c))},"Array, Matrix":function(a,c){return f(e(a,c.toArray()))},"Array, Array":e});
b.toTex={2:"\\left(${args[0]}\\right)\\times\\left(${args[1]}\\right)"};return b}},function(s,m,k){var w=k(15).size;m.name="dot";m.factory=function(b,a,c,d){function e(a,c){var b=w(a),d=w(c),e=b[0];if(1!==b.length||1!==d.length)throw new RangeError("Vector expected");if(b[0]!=d[0])throw new RangeError("Vectors must have equal length ("+b[0]+" != "+d[0]+")");if(0==e)throw new RangeError("Cannot calculate the dot product of empty vectors");for(d=b=0;d<e;d++)b=f(b,g(a[d],c[d]));return b}var f=c(k(30)),
g=c(k(43));b=d("dot",{"Matrix, Matrix":function(a,c){return e(a.toArray(),c.toArray())},"Matrix, Array":function(a,c){return e(a.toArray(),c)},"Array, Matrix":function(a,c){return e(a,c.toArray())},"Array, Array":e});b.toTex={2:"\\left(${args[0]}\\cdot${args[1]}\\right)"};return b}}])})},function(ea,ba,Z){var s,m,k;(function(w){function b(a){return"[object Function]"===M.call(a)}function a(a){return"[object Array]"===M.call(a)}function c(a,c){if(a){var b;for(b=0;b<a.length&&(!a[b]||!c(a[b],b,a));b+=
1);}}function d(a,c){if(a){var b;for(b=a.length-1;-1<b&&(!a[b]||!c(a[b],b,a));b-=1);}}function e(a,c){return Q.call(a,c)}function f(a,c){return e(a,c)&&a[c]}function g(a,c){for(var b in a)if(e(a,b)&&c(a[b],b))break}function h(c,d,f,l){d&&g(d,function(d,g){if(f||!e(c,g))!l||"object"!==typeof d||!d||a(d)||b(d)||d instanceof RegExp?c[g]=d:(c[g]||(c[g]={}),h(c[g],d,f,l))});return c}function n(a,c){return function(){return c.apply(a,arguments)}}function u(a){throw a;}function r(a){if(!a)return a;var b=
w;c(a.split("."),function(a){b=b[a]});return b}function t(a,c,b,d){c=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+a);c.requireType=a;c.requireModules=d;b&&(c.originalError=b);return c}function x(k){function m(a,c,b){var d,e,h,g,l,n,u,r;c=c&&c.split("/");var k=$.map,p=k&&k["*"];if(a){a=a.split("/");e=a.length-1;$.nodeIdCompat&&E.test(a[e])&&(a[e]=a[e].replace(E,""));"."===a[0].charAt(0)&&c&&(e=c.slice(0,c.length-1),a=e.concat(a));e=a;for(h=0;h<e.length;h++)(g=e[h],"."===g)?(e.splice(h,1),h-=
1):".."===g&&0!==h&&(1!==h||".."!==e[2])&&".."!==e[h-1]&&0<h&&(e.splice(h-1,2),h-=2);a=a.join("/")}if(b&&k&&(c||p)){e=a.split("/");h=e.length;a:for(;0<h;h-=1){l=e.slice(0,h).join("/");if(c)for(g=c.length;0<g;g-=1)if(b=f(k,c.slice(0,g).join("/")))if(b=f(b,l)){d=b;n=h;break a}!u&&p&&f(p,l)&&(u=f(p,l),r=h)}!d&&u&&(d=u,n=r);d&&(e.splice(0,n,d),a=e.join("/"))}return(d=f($.pkgs,a))?d:a}function p(a){L&&c(document.getElementsByTagName("script"),function(c){if(c.getAttribute("data-requiremodule")===a&&c.getAttribute("data-requirecontext")===
W.contextName)return c.parentNode.removeChild(c),!0})}function q(c){var b=f($.paths,c);if(b&&a(b)&&1<b.length)return b.shift(),W.require.undef(c),W.makeRequire(null,{skipMap:!0})([c]),!0}function x(a){var c,b=a?a.indexOf("!"):-1;-1<b&&(c=a.substring(0,b),a=a.substring(b+1,a.length));return[c,a]}function z(a,c,b,d){var e,h,g=null,l=c?c.name:null,n=a,u=!0,r="";a||(u=!1,a="_@r"+(Z+=1));a=x(a);g=a[0];a=a[1];g&&(g=m(g,l,d),h=f(aa,g));a&&(g?r=h&&h.normalize?h.normalize(a,function(a){return m(a,l,d)}):-1===
a.indexOf("!")?m(a,l,d):a:(r=m(a,l,d),a=x(r),g=a[0],r=a[1],b=!0,e=W.nameToUrl(r)));b=!g||h||b?"":"_unnormalized"+(La+=1);return{prefix:g,name:r,parentMap:c,unnormalized:!!b,url:e,originalName:n,isDefine:u,id:(g?g+"!"+r:r)+b}}function A(a){var c=a.id,b=f(da,c);b||(b=da[c]=new W.Module(a));return b}function I(a,c,b){var d=a.id,h=f(da,d);if(!e(aa,d)||h&&!h.defineEmitComplete)if(h=A(a),h.error&&"error"===c)b(h.error);else h.on(c,b);else"defined"===c&&b(aa[d])}function y(a,b){var d=a.requireModules,e=
!1;if(b)b(a);else if(c(d,function(c){if(c=f(da,c))c.error=a,c.events.error&&(e=!0,c.emit("error",a))}),!e)l.onError(a)}function H(){J.length&&(c(J,function(a){var c=a[0];"string"===typeof c&&(W.defQueueMap[c]=!0);la.push(a)}),J=[])}function s(a){delete da[a];delete ba[a]}function F(a,b,d){var e=a.map.id;a.error?a.emit("error",a.error):(b[e]=!0,c(a.depMaps,function(c,e){var h=c.id,g=f(da,h);g&&!a.depMatched[e]&&!d[h]&&(f(b,h)?(a.defineDep(e,aa[h]),a.check()):F(g,b,d))}),d[e]=!0)}function C(){var a,
b,d=(a=1E3*$.waitSeconds)&&W.startTime+a<(new Date).getTime(),e=[],f=[],h=!1,l=!0;if(!M){M=!0;g(ba,function(a){var c=a.map,g=c.id;if(a.enabled&&(c.isDefine||f.push(a),!a.error))if(!a.inited&&d)q(g)?h=b=!0:(e.push(g),p(g));else if(!a.inited&&a.fetched&&c.isDefine&&(h=!0,!c.prefix))return l=!1});if(d&&e.length)return a=t("timeout","Load timeout for modules: "+e,null,e),a.contextName=W.contextName,y(a);l&&c(f,function(a){F(a,{},{})});d&&!b||!h||!L&&!D||ha||(ha=setTimeout(function(){ha=0;C()},50));M=
!1}}function K(a){e(aa,a[0])||A(z(a[0],null,!0)).init(a[1],a[2])}function G(a){a=a.currentTarget||a.srcElement;var c=W.onScriptLoad;a.detachEvent&&!N?a.detachEvent("onreadystatechange",c):a.removeEventListener("load",c,!1);c=W.onScriptError;a.detachEvent&&!N||a.removeEventListener("error",c,!1);return{node:a,id:a&&a.getAttribute("data-requiremodule")}}function Q(){var a;for(H();la.length;){a=la.shift();if(null===a[0])return y(t("mismatch","Mismatched anonymous define() module: "+a[a.length-1]));K(a)}W.defQueueMap=
{}}var M,T,W,Ga,ha,$={waitSeconds:7,baseUrl:"./",paths:{},bundles:{},pkgs:{},shim:{},config:{}},da={},ba={},fa={},la=[],aa={},ma={},ea={},Z=1,La=1;Ga={require:function(a){return a.require?a.require:a.require=W.makeRequire(a.map)},exports:function(a){a.usingExports=!0;if(a.map.isDefine)return a.exports?aa[a.map.id]=a.exports:a.exports=aa[a.map.id]={}},module:function(a){return a.module?a.module:a.module={id:a.map.id,uri:a.map.url,config:function(){return f($.config,a.map.id)||{}},exports:a.exports||
(a.exports={})}}};T=function(a){this.events=f(fa,a.id)||{};this.map=a;this.shim=f($.shim,a.id);this.depExports=[];this.depMaps=[];this.depMatched=[];this.pluginMaps={};this.depCount=0};T.prototype={init:function(a,c,b,d){d=d||{};if(!this.inited){this.factory=c;if(b)this.on("error",b);else this.events.error&&(b=n(this,function(a){this.emit("error",a)}));this.depMaps=a&&a.slice(0);this.errback=b;this.inited=!0;this.ignore=d.ignore;d.enabled||this.enabled?this.enable():this.check()}},defineDep:function(a,
c){this.depMatched[a]||(this.depMatched[a]=!0,this.depCount-=1,this.depExports[a]=c)},fetch:function(){if(!this.fetched){this.fetched=!0;W.startTime=(new Date).getTime();var a=this.map;if(this.shim)W.makeRequire(this.map,{enableBuildCallback:!0})(this.shim.deps||[],n(this,function(){return a.prefix?this.callPlugin():this.load()}));else return a.prefix?this.callPlugin():this.load()}},load:function(){var a=this.map.url;ma[a]||(ma[a]=!0,W.load(this.map.id,a))},check:function(){if(this.enabled&&!this.enabling){var a,
c,d=this.map.id;c=this.depExports;var f=this.exports,h=this.factory;if(this.inited)if(this.error)this.emit("error",this.error);else{if(!this.defining){this.defining=!0;if(1>this.depCount&&!this.defined){if(b(h)){if(this.events.error&&this.map.isDefine||l.onError!==u)try{f=W.execCb(d,h,c,f)}catch(g){a=g}else f=W.execCb(d,h,c,f);this.map.isDefine&&void 0===f&&((c=this.module)?f=c.exports:this.usingExports&&(f=this.exports));if(a)return a.requireMap=this.map,a.requireModules=this.map.isDefine?[this.map.id]:
null,a.requireType=this.map.isDefine?"define":"require",y(this.error=a)}else f=h;this.exports=f;if(this.map.isDefine&&!this.ignore&&(aa[d]=f,l.onResourceLoad))l.onResourceLoad(W,this.map,this.depMaps);s(d);this.defined=!0}this.defining=!1;this.defined&&!this.defineEmitted&&(this.defineEmitted=!0,this.emit("defined",this.exports),this.defineEmitComplete=!0)}}else e(W.defQueueMap,d)||this.fetch()}},callPlugin:function(){var a=this.map,c=a.id,b=z(a.prefix);this.depMaps.push(b);I(b,"defined",n(this,function(b){var d,
h;h=f(ea,this.map.id);var u=this.map.name,r=this.map.parentMap?this.map.parentMap.name:null,k=W.makeRequire(a.parentMap,{enableBuildCallback:!0});if(this.map.unnormalized){if(b.normalize&&(u=b.normalize(u,function(a){return m(a,r,!0)})||""),b=z(a.prefix+"!"+u,this.map.parentMap),I(b,"defined",n(this,function(a){this.init([],function(){return a},null,{enabled:!0,ignore:!0})})),h=f(da,b.id)){this.depMaps.push(b);if(this.events.error)h.on("error",n(this,function(a){this.emit("error",a)}));h.enable()}}else h?
(this.map.url=W.nameToUrl(h),this.load()):(d=n(this,function(a){this.init([],function(){return a},null,{enabled:!0})}),d.error=n(this,function(a){this.inited=!0;this.error=a;a.requireModules=[c];g(da,function(a){0===a.map.id.indexOf(c+"_unnormalized")&&s(a.map.id)});y(a)}),d.fromText=n(this,function(b,f){var h=a.name,g=z(h),n=O;f&&(b=f);n&&(O=!1);A(g);e($.config,c)&&($.config[h]=$.config[c]);try{l.exec(b)}catch(u){return y(t("fromtexteval","fromText eval for "+c+" failed: "+u,u,[c]))}n&&(O=!0);this.depMaps.push(g);
W.completeLoad(h);k([h],d)}),b.load(a.name,k,d,$))}));W.enable(b,this);this.pluginMaps[b.id]=b},enable:function(){ba[this.map.id]=this;this.enabling=this.enabled=!0;c(this.depMaps,n(this,function(a,c){var b,d;if("string"===typeof a){a=z(a,this.map.isDefine?this.map:this.map.parentMap,!1,!this.skipMap);this.depMaps[c]=a;if(b=f(Ga,a.id)){this.depExports[c]=b(this);return}this.depCount+=1;I(a,"defined",n(this,function(a){this.undefed||(this.defineDep(c,a),this.check())}));this.errback?I(a,"error",n(this,
this.errback)):this.events.error&&I(a,"error",n(this,function(a){this.emit("error",a)}))}b=a.id;d=da[b];!e(Ga,b)&&d&&!d.enabled&&W.enable(a,this)}));g(this.pluginMaps,n(this,function(a){var c=f(da,a.id);c&&!c.enabled&&W.enable(a,this)}));this.enabling=!1;this.check()},on:function(a,c){var b=this.events[a];b||(b=this.events[a]=[]);b.push(c)},emit:function(a,b){c(this.events[a],function(a){a(b)});"error"===a&&delete this.events[a]}};W={config:$,contextName:k,registry:da,defined:aa,urlFetched:ma,defQueue:la,
defQueueMap:{},Module:T,makeModuleMap:z,nextTick:l.nextTick,onError:y,configure:function(b){b.baseUrl&&"/"!==b.baseUrl.charAt(b.baseUrl.length-1)&&(b.baseUrl+="/");var d=$.shim,e={paths:!0,bundles:!0,config:!0,map:!0};g(b,function(a,c){e[c]?($[c]||($[c]={}),h($[c],a,!0,!0)):$[c]=a});b.bundles&&g(b.bundles,function(a,b){c(a,function(a){a!==b&&(ea[a]=b)})});b.shim&&(g(b.shim,function(c,b){a(c)&&(c={deps:c});!c.exports&&!c.init||c.exportsFn||(c.exportsFn=W.makeShimExports(c));d[b]=c}),$.shim=d);b.packages&&
c(b.packages,function(a){var c;a="string"===typeof a?{name:a}:a;c=a.name;a.location&&($.paths[c]=a.location);$.pkgs[c]=a.name+"/"+(a.main||"main").replace(R,"").replace(E,"")});g(da,function(a,c){a.inited||a.map.unnormalized||(a.map=z(c,null,!0))});(b.deps||b.callback)&&W.require(b.deps||[],b.callback)},makeShimExports:function(a){return function(){var c;a.init&&(c=a.init.apply(w,arguments));return c||a.exports&&r(a.exports)}},makeRequire:function(a,c){function g(d,f,h){var n,u;c.enableBuildCallback&&
f&&b(f)&&(f.__requireJsBuild=!0);if("string"===typeof d){if(b(f))return y(t("requireargs","Invalid require call"),h);if(a&&e(Ga,d))return Ga[d](da[a.id]);if(l.get)return l.get(W,d,a,g);n=z(d,a,!1,!0);n=n.id;return e(aa,n)?aa[n]:y(t("notloaded",'Module name "'+n+'" has not been loaded yet for context: '+k+(a?"":". Use require([])")))}Q();W.nextTick(function(){Q();u=A(z(null,a));u.skipMap=c.skipMap;u.init(d,f,h,{enabled:!0});C()});return g}c=c||{};h(g,{isBrowser:L,toUrl:function(c){var b,d=c.lastIndexOf("."),
e=c.split("/")[0];-1!==d&&("."!==e&&".."!==e||1<d)&&(b=c.substring(d,c.length),c=c.substring(0,d));return W.nameToUrl(m(c,a&&a.id,!0),b,!0)},defined:function(c){return e(aa,z(c,a,!1,!0).id)},specified:function(c){c=z(c,a,!1,!0).id;return e(aa,c)||e(da,c)}});a||(g.undef=function(c){H();var b=z(c,a,!0),e=f(da,c);e.undefed=!0;p(c);delete aa[c];delete ma[b.url];delete fa[c];d(la,function(a,b){a[0]===c&&la.splice(b,1)});delete W.defQueueMap[c];e&&(e.events.defined&&(fa[c]=e.events),s(c))});return g},enable:function(a){f(da,
a.id)&&A(a).enable()},completeLoad:function(a){var c,b,d=f($.shim,a)||{},h=d.exports;for(H();la.length;){b=la.shift();if(null===b[0]){b[0]=a;if(c)break;c=!0}else b[0]===a&&(c=!0);K(b)}W.defQueueMap={};b=f(da,a);if(!c&&!e(aa,a)&&b&&!b.inited){if($.enforceDefine&&(!h||!r(h)))return q(a)?void 0:y(t("nodefine","No define call for "+a,null,[a]));K([a,d.deps||[],d.exportsFn])}C()},nameToUrl:function(c,b,d){var e,h,g;(e=f($.pkgs,c))&&(c=e);if(e=f(ea,c))return W.nameToUrl(e,b,d);if(l.jsExtRegExp.test(c))e=
c+(b||"");else{e=$.paths;c=c.split("/");for(h=c.length;0<h;h-=1)if(g=c.slice(0,h).join("/"),g=f(e,g)){a(g)&&(g=g[0]);c.splice(0,h,g);break}e=c.join("/");e+=b||(/^data\:|\?/.test(e)||d?"":".js");e=("/"===e.charAt(0)||e.match(/^[\w\+\.\-]+:/)?"":$.baseUrl)+e}return $.urlArgs?e+((-1===e.indexOf("?")?"?":"&")+$.urlArgs):e},load:function(a,c){l.load(W,a,c)},execCb:function(a,c,b,d){return c.apply(d,b)},onScriptLoad:function(a){if("load"===a.type||P.test((a.currentTarget||a.srcElement).readyState))B=null,
a=G(a),W.completeLoad(a.id)},onScriptError:function(a){var c=G(a);if(!q(c.id))return y(t("scripterror","Script error for: "+c.id,a,[c.id]))}};W.require=W.makeRequire();return W}var l,p,q,I,C,y,B,z,A,K,F=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,G=/[^.]\s*require\s*\(\s*["']([^'"\s]+)["']\s*\)/g,E=/\.js$/,R=/^\.\//;p=Object.prototype;var M=p.toString,Q=p.hasOwnProperty,L=!("undefined"===typeof window||"undefined"===typeof navigator||!window.document),D=!L&&"undefined"!==typeof importScripts,P=L&&
"PLAYSTATION 3"===navigator.platform?/^complete$/:/^(complete|loaded)$/,N="undefined"!==typeof opera&&"[object Opera]"===opera.toString(),T={},H={},J=[],O=!1;if("undefined"===typeof k){if("undefined"!==typeof m){if(b(m))return;H=m;m=void 0}"undefined"!==typeof s&&!b(s)&&(H=s,s=void 0);l=m=function(c,b,d,e){var h,g="_";!a(c)&&"string"!==typeof c&&(h=c,a(b)?(c=b,b=d,d=e):c=[]);h&&h.context&&(g=h.context);(e=f(T,g))||(e=T[g]=l.s.newContext(g));h&&e.configure(h);return e.require(c,b,d)};l.config=function(a){return l(a)};
l.nextTick="undefined"!==typeof setTimeout?function(a){setTimeout(a,4)}:function(a){a()};s||(s=l);l.version="2.1.20";l.jsExtRegExp=/^\/|:|\?|\.js$/;l.isBrowser=L;p=l.s={contexts:T,newContext:x};l({});c(["toUrl","undef","defined","specified"],function(a){l[a]=function(){var c=T._;return c.require[a].apply(c,arguments)}});L&&(q=p.head=document.getElementsByTagName("head")[0],I=document.getElementsByTagName("base")[0])&&(q=p.head=I.parentNode);l.onError=u;l.createNode=function(a){var c=a.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml",
"html:script"):document.createElement("script");c.type=a.scriptType||"text/javascript";c.charset="utf-8";c.async=!0;return c};l.load=function(a,c,b){var d=a&&a.config||{},e;if(L){e=l.createNode(d,c,b);if(d.onNodeCreated)d.onNodeCreated(e,d,c,b);e.setAttribute("data-requirecontext",a.contextName);e.setAttribute("data-requiremodule",c);!e.attachEvent||e.attachEvent.toString&&0>e.attachEvent.toString().indexOf("[native code")||N?(e.addEventListener("load",a.onScriptLoad,!1),e.addEventListener("error",
a.onScriptError,!1)):(O=!0,e.attachEvent("onreadystatechange",a.onScriptLoad));e.src=b;z=e;I?q.insertBefore(e,I):q.appendChild(e);z=null;return e}if(D)try{importScripts(b),a.completeLoad(c)}catch(f){a.onError(t("importscripts","importScripts failed for "+c+" at "+b,f,[c]))}};L&&!H.skipDataMain&&d(document.getElementsByTagName("script"),function(a){q||(q=a.parentNode);if(C=a.getAttribute("data-main"))return A=C,H.baseUrl||(y=A.split("/"),A=y.pop(),K=y.length?y.join("/")+"/":"./",H.baseUrl=K),A=A.replace(E,
""),l.jsExtRegExp.test(A)&&(A=C),H.deps=H.deps?H.deps.concat(A):[A],!0});k=function(c,e,f){var h,g;"string"!==typeof c&&(f=e,e=c,c=null);a(e)||(f=e,e=null);!e&&b(f)&&(e=[],f.length&&(f.toString().replace(F,"").replace(G,function(a,c){e.push(c)}),e=(1===f.length?["require"]:["require","exports","module"]).concat(e)));O&&((h=z)||(B&&"interactive"===B.readyState||d(document.getElementsByTagName("script"),function(a){if("interactive"===a.readyState)return B=a}),h=B),h&&(c||(c=h.getAttribute("data-requiremodule")),
g=T[h.getAttribute("data-requirecontext")]));g?(g.defQueue.push([c,e,f]),g.defQueueMap[c]=!0):J.push([c,e,f])};k.amd={jQuery:!0};l.exec=function(a){return eval(a)};l(H)}})(this)},function(ea,ba,Z){var s,m,k;(function(w,b){!(m=[ba],s=b,k="function"===typeof s?s.apply(ba,m):s,void 0!==k&&(ea.exports=k))})(this,function(m){var b={REVISION:"76"};!(s=b,k="function"===typeof s?s.call(m,Z,m,ea):s,void 0!==k&&(ea.exports=k));void 0===Number.EPSILON&&(Number.EPSILON=Math.pow(2,-52));void 0===Math.sign&&(Math.sign=
function(a){return 0>a?-1:0<a?1:+a});void 0===Function.prototype.name&&void 0!==Object.defineProperty&&Object.defineProperty(Function.prototype,"name",{get:function(){return this.toString().match(/^\s*function\s*(\S*)\s*\(/)[1]}});void 0===Object.assign&&Object.defineProperty(Object,"assign",{writable:!0,configurable:!0,value:function(a){if(void 0===a||null===a)throw new TypeError("Cannot convert first argument to object");for(var c=Object(a),b=1,e=arguments.length;b!==e;++b){var f=arguments[b];if(void 0!==
f&&null!==f)for(var f=Object(f),g=Object.keys(f),h=0,n=g.length;h!==n;++h){var u=g[h],r=Object.getOwnPropertyDescriptor(f,u);void 0!==r&&r.enumerable&&(c[u]=f[u])}}return c}});b.MOUSE={LEFT:0,MIDDLE:1,RIGHT:2};b.CullFaceNone=0;b.CullFaceBack=1;b.CullFaceFront=2;b.CullFaceFrontBack=3;b.FrontFaceDirectionCW=0;b.FrontFaceDirectionCCW=1;b.BasicShadowMap=0;b.PCFShadowMap=1;b.PCFSoftShadowMap=2;b.FrontSide=0;b.BackSide=1;b.DoubleSide=2;b.FlatShading=1;b.SmoothShading=2;b.NoColors=0;b.FaceColors=1;b.VertexColors=
2;b.NoBlending=0;b.NormalBlending=1;b.AdditiveBlending=2;b.SubtractiveBlending=3;b.MultiplyBlending=4;b.CustomBlending=5;b.AddEquation=100;b.SubtractEquation=101;b.ReverseSubtractEquation=102;b.MinEquation=103;b.MaxEquation=104;b.ZeroFactor=200;b.OneFactor=201;b.SrcColorFactor=202;b.OneMinusSrcColorFactor=203;b.SrcAlphaFactor=204;b.OneMinusSrcAlphaFactor=205;b.DstAlphaFactor=206;b.OneMinusDstAlphaFactor=207;b.DstColorFactor=208;b.OneMinusDstColorFactor=209;b.SrcAlphaSaturateFactor=210;b.NeverDepth=
0;b.AlwaysDepth=1;b.LessDepth=2;b.LessEqualDepth=3;b.EqualDepth=4;b.GreaterEqualDepth=5;b.GreaterDepth=6;b.NotEqualDepth=7;b.MultiplyOperation=0;b.MixOperation=1;b.AddOperation=2;b.NoToneMapping=0;b.LinearToneMapping=1;b.ReinhardToneMapping=2;b.Uncharted2ToneMapping=3;b.CineonToneMapping=4;b.UVMapping=300;b.CubeReflectionMapping=301;b.CubeRefractionMapping=302;b.EquirectangularReflectionMapping=303;b.EquirectangularRefractionMapping=304;b.SphericalReflectionMapping=305;b.CubeUVReflectionMapping=306;
b.CubeUVRefractionMapping=307;b.RepeatWrapping=1E3;b.ClampToEdgeWrapping=1001;b.MirroredRepeatWrapping=1002;b.NearestFilter=1003;b.NearestMipMapNearestFilter=1004;b.NearestMipMapLinearFilter=1005;b.LinearFilter=1006;b.LinearMipMapNearestFilter=1007;b.LinearMipMapLinearFilter=1008;b.UnsignedByteType=1009;b.ByteType=1010;b.ShortType=1011;b.UnsignedShortType=1012;b.IntType=1013;b.UnsignedIntType=1014;b.FloatType=1015;b.HalfFloatType=1025;b.UnsignedShort4444Type=1016;b.UnsignedShort5551Type=1017;b.UnsignedShort565Type=
1018;b.AlphaFormat=1019;b.RGBFormat=1020;b.RGBAFormat=1021;b.LuminanceFormat=1022;b.LuminanceAlphaFormat=1023;b.RGBEFormat=b.RGBAFormat;b.DepthFormat=1026;b.RGB_S3TC_DXT1_Format=2001;b.RGBA_S3TC_DXT1_Format=2002;b.RGBA_S3TC_DXT3_Format=2003;b.RGBA_S3TC_DXT5_Format=2004;b.RGB_PVRTC_4BPPV1_Format=2100;b.RGB_PVRTC_2BPPV1_Format=2101;b.RGBA_PVRTC_4BPPV1_Format=2102;b.RGBA_PVRTC_2BPPV1_Format=2103;b.RGB_ETC1_Format=2151;b.LoopOnce=2200;b.LoopRepeat=2201;b.LoopPingPong=2202;b.InterpolateDiscrete=2300;b.InterpolateLinear=
2301;b.InterpolateSmooth=2302;b.ZeroCurvatureEnding=2400;b.ZeroSlopeEnding=2401;b.WrapAroundEnding=2402;b.TrianglesDrawMode=0;b.TriangleStripDrawMode=1;b.TriangleFanDrawMode=2;b.LinearEncoding=3E3;b.sRGBEncoding=3001;b.GammaEncoding=3007;b.RGBEEncoding=3002;b.LogLuvEncoding=3003;b.RGBM7Encoding=3004;b.RGBM16Encoding=3005;b.RGBDEncoding=3006;b.BasicDepthPacking=3200;b.RGBADepthPacking=3201;b.Color=function(a){return 3===arguments.length?this.fromArray(arguments):this.set(a)};b.Color.prototype={constructor:b.Color,
r:1,g:1,b:1,set:function(a){a instanceof b.Color?this.copy(a):"number"===typeof a?this.setHex(a):"string"===typeof a&&this.setStyle(a);return this},setScalar:function(a){this.b=this.g=this.r=a},setHex:function(a){a=Math.floor(a);this.r=(a>>16&255)/255;this.g=(a>>8&255)/255;this.b=(a&255)/255;return this},setRGB:function(a,c,b){this.r=a;this.g=c;this.b=b;return this},setHSL:function(){function a(a,b,e){0>e&&(e+=1);1<e&&(e-=1);return e<1/6?a+6*(b-a)*e:.5>e?b:e<2/3?a+6*(b-a)*(2/3-e):a}return function(c,
d,e){c=b.Math.euclideanModulo(c,1);d=b.Math.clamp(d,0,1);e=b.Math.clamp(e,0,1);0===d?this.r=this.g=this.b=e:(d=.5>=e?e*(1+d):e+d-e*d,e=2*e-d,this.r=a(e,d,c+1/3),this.g=a(e,d,c),this.b=a(e,d,c-1/3));return this}}(),setStyle:function(a){function c(c){void 0!==c&&1>parseFloat(c)&&console.warn("THREE.Color: Alpha component of "+a+" will be ignored.")}var d;if(d=/^((?:rgb|hsl)a?)\(\s*([^\)]*)\)/.exec(a)){var e=d[2];switch(d[1]){case "rgb":case "rgba":if(d=/^(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(e))return this.r=
Math.min(255,parseInt(d[1],10))/255,this.g=Math.min(255,parseInt(d[2],10))/255,this.b=Math.min(255,parseInt(d[3],10))/255,c(d[5]),this;if(d=/^(\d+)\%\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(e))return this.r=Math.min(100,parseInt(d[1],10))/100,this.g=Math.min(100,parseInt(d[2],10))/100,this.b=Math.min(100,parseInt(d[3],10))/100,c(d[5]),this;break;case "hsl":case "hsla":if(d=/^([0-9]*\.?[0-9]+)\s*,\s*(\d+)\%\s*,\s*(\d+)\%\s*(,\s*([0-9]*\.?[0-9]+)\s*)?$/.exec(e)){var e=parseFloat(d[1])/
360,f=parseInt(d[2],10)/100,g=parseInt(d[3],10)/100;c(d[5]);return this.setHSL(e,f,g)}}}else if(d=/^\#([A-Fa-f0-9]+)$/.exec(a)){d=d[1];e=d.length;if(3===e)return this.r=parseInt(d.charAt(0)+d.charAt(0),16)/255,this.g=parseInt(d.charAt(1)+d.charAt(1),16)/255,this.b=parseInt(d.charAt(2)+d.charAt(2),16)/255,this;if(6===e)return this.r=parseInt(d.charAt(0)+d.charAt(1),16)/255,this.g=parseInt(d.charAt(2)+d.charAt(3),16)/255,this.b=parseInt(d.charAt(4)+d.charAt(5),16)/255,this}a&&0<a.length&&(d=b.ColorKeywords[a],
void 0!==d?this.setHex(d):console.warn("THREE.Color: Unknown color "+a));return this},clone:function(){return new this.constructor(this.r,this.g,this.b)},copy:function(a){this.r=a.r;this.g=a.g;this.b=a.b;return this},copyGammaToLinear:function(a,c){void 0===c&&(c=2);this.r=Math.pow(a.r,c);this.g=Math.pow(a.g,c);this.b=Math.pow(a.b,c);return this},copyLinearToGamma:function(a,c){void 0===c&&(c=2);var b=0<c?1/c:1;this.r=Math.pow(a.r,b);this.g=Math.pow(a.g,b);this.b=Math.pow(a.b,b);return this},convertGammaToLinear:function(){var a=
this.r,c=this.g,b=this.b;this.r=a*a;this.g=c*c;this.b=b*b;return this},convertLinearToGamma:function(){this.r=Math.sqrt(this.r);this.g=Math.sqrt(this.g);this.b=Math.sqrt(this.b);return this},getHex:function(){return 255*this.r<<16^255*this.g<<8^255*this.b<<0},getHexString:function(){return("000000"+this.getHex().toString(16)).slice(-6)},getHSL:function(a){a=a||{h:0,s:0,l:0};var c=this.r,b=this.g,e=this.b,f=Math.max(c,b,e),g=Math.min(c,b,e),h,n=(g+f)/2;if(g===f)g=h=0;else{var u=f-g,g=.5>=n?u/(f+g):
u/(2-f-g);switch(f){case c:h=(b-e)/u+(b<e?6:0);break;case b:h=(e-c)/u+2;break;case e:h=(c-b)/u+4}h/=6}a.h=h;a.s=g;a.l=n;return a},getStyle:function(){return"rgb("+(255*this.r|0)+","+(255*this.g|0)+","+(255*this.b|0)+")"},offsetHSL:function(a,c,b){var e=this.getHSL();e.h+=a;e.s+=c;e.l+=b;this.setHSL(e.h,e.s,e.l);return this},add:function(a){this.r+=a.r;this.g+=a.g;this.b+=a.b;return this},addColors:function(a,c){this.r=a.r+c.r;this.g=a.g+c.g;this.b=a.b+c.b;return this},addScalar:function(a){this.r+=
a;this.g+=a;this.b+=a;return this},multiply:function(a){this.r*=a.r;this.g*=a.g;this.b*=a.b;return this},multiplyScalar:function(a){this.r*=a;this.g*=a;this.b*=a;return this},lerp:function(a,c){this.r+=(a.r-this.r)*c;this.g+=(a.g-this.g)*c;this.b+=(a.b-this.b)*c;return this},equals:function(a){return a.r===this.r&&a.g===this.g&&a.b===this.b},fromArray:function(a,c){void 0===c&&(c=0);this.r=a[c];this.g=a[c+1];this.b=a[c+2];return this},toArray:function(a,c){void 0===a&&(a=[]);void 0===c&&(c=0);a[c]=
this.r;a[c+1]=this.g;a[c+2]=this.b;return a}};b.ColorKeywords={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,
darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,
green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,
lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,
palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,
teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};b.Quaternion=function(a,c,b,e){this._x=a||0;this._y=c||0;this._z=b||0;this._w=void 0!==e?e:1};b.Quaternion.prototype={constructor:b.Quaternion,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},
get w(){return this._w},set w(a){this._w=a;this.onChangeCallback()},set:function(a,c,b,e){this._x=a;this._y=c;this._z=b;this._w=e;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._w)},copy:function(a){this._x=a.x;this._y=a.y;this._z=a.z;this._w=a.w;this.onChangeCallback();return this},setFromEuler:function(a,c){if(!1===a instanceof b.Euler)throw Error("THREE.Quaternion: .setFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
var d=Math.cos(a._x/2),e=Math.cos(a._y/2),f=Math.cos(a._z/2),g=Math.sin(a._x/2),h=Math.sin(a._y/2),n=Math.sin(a._z/2),u=a.order;"XYZ"===u?(this._x=g*e*f+d*h*n,this._y=d*h*f-g*e*n,this._z=d*e*n+g*h*f,this._w=d*e*f-g*h*n):"YXZ"===u?(this._x=g*e*f+d*h*n,this._y=d*h*f-g*e*n,this._z=d*e*n-g*h*f,this._w=d*e*f+g*h*n):"ZXY"===u?(this._x=g*e*f-d*h*n,this._y=d*h*f+g*e*n,this._z=d*e*n+g*h*f,this._w=d*e*f-g*h*n):"ZYX"===u?(this._x=g*e*f-d*h*n,this._y=d*h*f+g*e*n,this._z=d*e*n-g*h*f,this._w=d*e*f+g*h*n):"YZX"===
u?(this._x=g*e*f+d*h*n,this._y=d*h*f+g*e*n,this._z=d*e*n-g*h*f,this._w=d*e*f-g*h*n):"XZY"===u&&(this._x=g*e*f-d*h*n,this._y=d*h*f-g*e*n,this._z=d*e*n+g*h*f,this._w=d*e*f+g*h*n);if(!1!==c)this.onChangeCallback();return this},setFromAxisAngle:function(a,c){var b=c/2,e=Math.sin(b);this._x=a.x*e;this._y=a.y*e;this._z=a.z*e;this._w=Math.cos(b);this.onChangeCallback();return this},setFromRotationMatrix:function(a){var c=a.elements,b=c[0];a=c[4];var e=c[8],f=c[1],g=c[5],h=c[9],n=c[2],u=c[6],c=c[10],r=b+
g+c;0<r?(b=.5/Math.sqrt(r+1),this._w=.25/b,this._x=(u-h)*b,this._y=(e-n)*b,this._z=(f-a)*b):b>g&&b>c?(b=2*Math.sqrt(1+b-g-c),this._w=(u-h)/b,this._x=.25*b,this._y=(a+f)/b,this._z=(e+n)/b):g>c?(b=2*Math.sqrt(1+g-b-c),this._w=(e-n)/b,this._x=(a+f)/b,this._y=.25*b,this._z=(h+u)/b):(b=2*Math.sqrt(1+c-b-g),this._w=(f-a)/b,this._x=(e+n)/b,this._y=(h+u)/b,this._z=.25*b);this.onChangeCallback();return this},setFromUnitVectors:function(){var a,c;return function(d,e){void 0===a&&(a=new b.Vector3);c=d.dot(e)+
1;1E-6>c?(c=0,Math.abs(d.x)>Math.abs(d.z)?a.set(-d.y,d.x,0):a.set(0,-d.z,d.y)):a.crossVectors(d,e);this._x=a.x;this._y=a.y;this._z=a.z;this._w=c;this.normalize();return this}}(),inverse:function(){this.conjugate().normalize();return this},conjugate:function(){this._x*=-1;this._y*=-1;this._z*=-1;this.onChangeCallback();return this},dot:function(a){return this._x*a._x+this._y*a._y+this._z*a._z+this._w*a._w},lengthSq:function(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w},
length:function(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)},normalize:function(){var a=this.length();0===a?(this._z=this._y=this._x=0,this._w=1):(a=1/a,this._x*=a,this._y*=a,this._z*=a,this._w*=a);this.onChangeCallback();return this},multiply:function(a,c){return void 0!==c?(console.warn("THREE.Quaternion: .multiply() now only accepts one argument. Use .multiplyQuaternions( a, b ) instead."),this.multiplyQuaternions(a,c)):this.multiplyQuaternions(this,a)},
multiplyQuaternions:function(a,c){var b=a._x,e=a._y,f=a._z,g=a._w,h=c._x,n=c._y,u=c._z,r=c._w;this._x=b*r+g*h+e*u-f*n;this._y=e*r+g*n+f*h-b*u;this._z=f*r+g*u+b*n-e*h;this._w=g*r-b*h-e*n-f*u;this.onChangeCallback();return this},slerp:function(a,c){if(0===c)return this;if(1===c)return this.copy(a);var b=this._x,e=this._y,f=this._z,g=this._w,h=g*a._w+b*a._x+e*a._y+f*a._z;0>h?(this._w=-a._w,this._x=-a._x,this._y=-a._y,this._z=-a._z,h=-h):this.copy(a);if(1<=h)return this._w=g,this._x=b,this._y=e,this._z=
f,this;var n=Math.sqrt(1-h*h);if(.001>Math.abs(n))return this._w=.5*(g+this._w),this._x=.5*(b+this._x),this._y=.5*(e+this._y),this._z=.5*(f+this._z),this;var u=Math.atan2(n,h),h=Math.sin((1-c)*u)/n,n=Math.sin(c*u)/n;this._w=g*h+this._w*n;this._x=b*h+this._x*n;this._y=e*h+this._y*n;this._z=f*h+this._z*n;this.onChangeCallback();return this},equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._w===this._w},fromArray:function(a,c){void 0===c&&(c=0);this._x=a[c];this._y=a[c+1];
this._z=a[c+2];this._w=a[c+3];this.onChangeCallback();return this},toArray:function(a,c){void 0===a&&(a=[]);void 0===c&&(c=0);a[c]=this._x;a[c+1]=this._y;a[c+2]=this._z;a[c+3]=this._w;return a},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};Object.assign(b.Quaternion,{slerp:function(a,c,b,e){return b.copy(a).slerp(c,e)},slerpFlat:function(a,c,b,e,f,g,h){var n=b[e+0],u=b[e+1],r=b[e+2];b=b[e+3];e=f[g+0];var k=f[g+1],m=f[g+2];f=f[g+3];if(b!==f||n!==e||u!==k||
r!==m){g=1-h;var l=n*e+u*k+r*m+b*f,p=0<=l?1:-1,q=1-l*l;q>Number.EPSILON&&(q=Math.sqrt(q),l=Math.atan2(q,l*p),g=Math.sin(g*l)/q,h=Math.sin(h*l)/q);p*=h;n=n*g+e*p;u=u*g+k*p;r=r*g+m*p;b=b*g+f*p;g===1-h&&(h=1/Math.sqrt(n*n+u*u+r*r+b*b),n*=h,u*=h,r*=h,b*=h)}a[c]=n;a[c+1]=u;a[c+2]=r;a[c+3]=b}});b.Vector2=function(a,c){this.x=a||0;this.y=c||0};b.Vector2.prototype={constructor:b.Vector2,get width(){return this.x},set width(a){this.x=a},get height(){return this.y},set height(a){this.y=a},set:function(a,c){this.x=
a;this.y=c;return this},setScalar:function(a){this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setComponent:function(a,c){switch(a){case 0:this.x=c;break;case 1:this.y=c;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y)},copy:function(a){this.x=a.x;
this.y=a.y;return this},add:function(a,c){if(void 0!==c)return console.warn("THREE.Vector2: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,c);this.x+=a.x;this.y+=a.y;return this},addScalar:function(a){this.x+=a;this.y+=a;return this},addVectors:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;return this},addScaledVector:function(a,c){this.x+=a.x*c;this.y+=a.y*c;return this},sub:function(a,c){if(void 0!==c)return console.warn("THREE.Vector2: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),
this.subVectors(a,c);this.x-=a.x;this.y-=a.y;return this},subScalar:function(a){this.x-=a;this.y-=a;return this},subVectors:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;return this},multiply:function(a){this.x*=a.x;this.y*=a.y;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a):this.y=this.x=0;return this},divide:function(a){this.x/=a.x;this.y/=a.y;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,
a.y);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);return this},clamp:function(a,c){this.x=Math.max(a.x,Math.min(c.x,this.x));this.y=Math.max(a.y,Math.min(c.y,this.y));return this},clampScalar:function(){var a,c;return function(d,e){void 0===a&&(a=new b.Vector2,c=new b.Vector2);a.set(d,d);c.set(e,e);return this.clamp(a,c)}}(),clampLength:function(a,c){var b=this.length();this.multiplyScalar(Math.max(a,Math.min(c,b))/b);return this},floor:function(){this.x=Math.floor(this.x);
this.y=Math.floor(this.y);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);return this},negate:function(){this.x=-this.x;this.y=-this.y;return this},dot:function(a){return this.x*a.x+this.y*a.y},lengthSq:function(){return this.x*this.x+this.y*this.y},
length:function(){return Math.sqrt(this.x*this.x+this.y*this.y)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)},normalize:function(){return this.divideScalar(this.length())},angle:function(){var a=Math.atan2(this.y,this.x);0>a&&(a+=2*Math.PI);return a},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x;a=this.y-a.y;return c*c+a*a},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,
c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;return this},lerpVectors:function(a,c,b){this.subVectors(c,a).multiplyScalar(b).add(a);return this},equals:function(a){return a.x===this.x&&a.y===this.y},fromArray:function(a,c){void 0===c&&(c=0);this.x=a[c];this.y=a[c+1];return this},toArray:function(a,c){void 0===a&&(a=[]);void 0===c&&(c=0);a[c]=this.x;a[c+1]=this.y;return a},fromAttribute:function(a,c,b){void 0===b&&(b=0);c=c*a.itemSize+b;this.x=a.array[c];this.y=a.array[c+1];return this},rotateAround:function(a,
c){var b=Math.cos(c),e=Math.sin(c),f=this.x-a.x,g=this.y-a.y;this.x=f*b-g*e+a.x;this.y=f*e+g*b+a.y;return this}};b.Vector3=function(a,c,b){this.x=a||0;this.y=c||0;this.z=b||0};b.Vector3.prototype={constructor:b.Vector3,set:function(a,c,b){this.x=a;this.y=c;this.z=b;return this},setScalar:function(a){this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setComponent:function(a,c){switch(a){case 0:this.x=
c;break;case 1:this.y=c;break;case 2:this.z=c;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return this},add:function(a,c){if(void 0!==c)return console.warn("THREE.Vector3: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),
this.addVectors(a,c);this.x+=a.x;this.y+=a.y;this.z+=a.z;return this},addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;return this},addVectors:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;return this},addScaledVector:function(a,c){this.x+=a.x*c;this.y+=a.y*c;this.z+=a.z*c;return this},sub:function(a,c){if(void 0!==c)return console.warn("THREE.Vector3: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,c);this.x-=a.x;this.y-=a.y;this.z-=a.z;
return this},subScalar:function(a){this.x-=a;this.y-=a;this.z-=a;return this},subVectors:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;return this},multiply:function(a,c){if(void 0!==c)return console.warn("THREE.Vector3: .multiply() now only accepts one argument. Use .multiplyVectors( a, b ) instead."),this.multiplyVectors(a,c);this.x*=a.x;this.y*=a.y;this.z*=a.z;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a):this.z=this.y=this.x=0;return this},multiplyVectors:function(a,
c){this.x=a.x*c.x;this.y=a.y*c.y;this.z=a.z*c.z;return this},applyEuler:function(){var a;return function(c){!1===c instanceof b.Euler&&console.error("THREE.Vector3: .applyEuler() now expects an Euler rotation rather than a Vector3 and order.");void 0===a&&(a=new b.Quaternion);this.applyQuaternion(a.setFromEuler(c));return this}}(),applyAxisAngle:function(){var a;return function(c,d){void 0===a&&(a=new b.Quaternion);this.applyQuaternion(a.setFromAxisAngle(c,d));return this}}(),applyMatrix3:function(a){var c=
this.x,b=this.y,e=this.z;a=a.elements;this.x=a[0]*c+a[3]*b+a[6]*e;this.y=a[1]*c+a[4]*b+a[7]*e;this.z=a[2]*c+a[5]*b+a[8]*e;return this},applyMatrix4:function(a){var c=this.x,b=this.y,e=this.z;a=a.elements;this.x=a[0]*c+a[4]*b+a[8]*e+a[12];this.y=a[1]*c+a[5]*b+a[9]*e+a[13];this.z=a[2]*c+a[6]*b+a[10]*e+a[14];return this},applyProjection:function(a){var c=this.x,b=this.y,e=this.z;a=a.elements;var f=1/(a[3]*c+a[7]*b+a[11]*e+a[15]);this.x=(a[0]*c+a[4]*b+a[8]*e+a[12])*f;this.y=(a[1]*c+a[5]*b+a[9]*e+a[13])*
f;this.z=(a[2]*c+a[6]*b+a[10]*e+a[14])*f;return this},applyQuaternion:function(a){var c=this.x,b=this.y,e=this.z,f=a.x,g=a.y,h=a.z;a=a.w;var n=a*c+g*e-h*b,u=a*b+h*c-f*e,r=a*e+f*b-g*c,c=-f*c-g*b-h*e;this.x=n*a+c*-f+u*-h-r*-g;this.y=u*a+c*-g+r*-f-n*-h;this.z=r*a+c*-h+n*-g-u*-f;return this},project:function(){var a;return function(c){void 0===a&&(a=new b.Matrix4);a.multiplyMatrices(c.projectionMatrix,a.getInverse(c.matrixWorld));return this.applyProjection(a)}}(),unproject:function(){var a;return function(c){void 0===
a&&(a=new b.Matrix4);a.multiplyMatrices(c.matrixWorld,a.getInverse(c.projectionMatrix));return this.applyProjection(a)}}(),transformDirection:function(a){var c=this.x,b=this.y,e=this.z;a=a.elements;this.x=a[0]*c+a[4]*b+a[8]*e;this.y=a[1]*c+a[5]*b+a[9]*e;this.z=a[2]*c+a[6]*b+a[10]*e;this.normalize();return this},divide:function(a){this.x/=a.x;this.y/=a.y;this.z/=a.z;return this},divideScalar:function(a){return this.multiplyScalar(1/a)},min:function(a){this.x=Math.min(this.x,a.x);this.y=Math.min(this.y,
a.y);this.z=Math.min(this.z,a.z);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);return this},clamp:function(a,c){this.x=Math.max(a.x,Math.min(c.x,this.x));this.y=Math.max(a.y,Math.min(c.y,this.y));this.z=Math.max(a.z,Math.min(c.z,this.z));return this},clampScalar:function(){var a,c;return function(d,e){void 0===a&&(a=new b.Vector3,c=new b.Vector3);a.set(d,d,d);c.set(e,e,e);return this.clamp(a,c)}}(),clampLength:function(a,c){var b=
this.length();this.multiplyScalar(Math.max(a,Math.min(c,b))/b);return this},floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);return this},roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):
Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z},length:function(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)},normalize:function(){return this.divideScalar(this.length())},
setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;return this},lerpVectors:function(a,c,b){this.subVectors(c,a).multiplyScalar(b).add(a);return this},cross:function(a,c){if(void 0!==c)return console.warn("THREE.Vector3: .cross() now only accepts one argument. Use .crossVectors( a, b ) instead."),this.crossVectors(a,c);var b=this.x,e=this.y,f=this.z;this.x=e*a.z-f*a.y;this.y=f*a.x-b*a.z;this.z=
b*a.y-e*a.x;return this},crossVectors:function(a,c){var b=a.x,e=a.y,f=a.z,g=c.x,h=c.y,n=c.z;this.x=e*n-f*h;this.y=f*g-b*n;this.z=b*h-e*g;return this},projectOnVector:function(){var a,c;return function(d){void 0===a&&(a=new b.Vector3);a.copy(d).normalize();c=this.dot(a);return this.copy(a).multiplyScalar(c)}}(),projectOnPlane:function(){var a;return function(c){void 0===a&&(a=new b.Vector3);a.copy(this).projectOnVector(c);return this.sub(a)}}(),reflect:function(){var a;return function(c){void 0===
a&&(a=new b.Vector3);return this.sub(a.copy(c).multiplyScalar(2*this.dot(c)))}}(),angleTo:function(a){a=this.dot(a)/Math.sqrt(this.lengthSq()*a.lengthSq());return Math.acos(b.Math.clamp(a,-1,1))},distanceTo:function(a){return Math.sqrt(this.distanceToSquared(a))},distanceToSquared:function(a){var c=this.x-a.x,b=this.y-a.y;a=this.z-a.z;return c*c+b*b+a*a},setFromSpherical:function(a){var c=Math.sin(a.phi)*a.radius;this.x=c*Math.sin(a.theta);this.y=Math.cos(a.phi)*a.radius;this.z=c*Math.cos(a.theta);
return this},setFromMatrixPosition:function(a){return this.setFromMatrixColumn(a,3)},setFromMatrixScale:function(a){var c=this.setFromMatrixColumn(a,0).length(),b=this.setFromMatrixColumn(a,1).length();a=this.setFromMatrixColumn(a,2).length();this.x=c;this.y=b;this.z=a;return this},setFromMatrixColumn:function(a,c){"number"===typeof a&&(console.warn("THREE.Vector3: setFromMatrixColumn now expects ( matrix, index )."),c=a=c);return this.fromArray(a.elements,4*c)},equals:function(a){return a.x===this.x&&
a.y===this.y&&a.z===this.z},fromArray:function(a,c){void 0===c&&(c=0);this.x=a[c];this.y=a[c+1];this.z=a[c+2];return this},toArray:function(a,c){void 0===a&&(a=[]);void 0===c&&(c=0);a[c]=this.x;a[c+1]=this.y;a[c+2]=this.z;return a},fromAttribute:function(a,c,b){void 0===b&&(b=0);c=c*a.itemSize+b;this.x=a.array[c];this.y=a.array[c+1];this.z=a.array[c+2];return this}};b.Vector4=function(a,c,b,e){this.x=a||0;this.y=c||0;this.z=b||0;this.w=void 0!==e?e:1};b.Vector4.prototype={constructor:b.Vector4,set:function(a,
c,b,e){this.x=a;this.y=c;this.z=b;this.w=e;return this},setScalar:function(a){this.w=this.z=this.y=this.x=a;return this},setX:function(a){this.x=a;return this},setY:function(a){this.y=a;return this},setZ:function(a){this.z=a;return this},setW:function(a){this.w=a;return this},setComponent:function(a,c){switch(a){case 0:this.x=c;break;case 1:this.y=c;break;case 2:this.z=c;break;case 3:this.w=c;break;default:throw Error("index is out of range: "+a);}},getComponent:function(a){switch(a){case 0:return this.x;
case 1:return this.y;case 2:return this.z;case 3:return this.w;default:throw Error("index is out of range: "+a);}},clone:function(){return new this.constructor(this.x,this.y,this.z,this.w)},copy:function(a){this.x=a.x;this.y=a.y;this.z=a.z;this.w=void 0!==a.w?a.w:1;return this},add:function(a,c){if(void 0!==c)return console.warn("THREE.Vector4: .add() now only accepts one argument. Use .addVectors( a, b ) instead."),this.addVectors(a,c);this.x+=a.x;this.y+=a.y;this.z+=a.z;this.w+=a.w;return this},
addScalar:function(a){this.x+=a;this.y+=a;this.z+=a;this.w+=a;return this},addVectors:function(a,c){this.x=a.x+c.x;this.y=a.y+c.y;this.z=a.z+c.z;this.w=a.w+c.w;return this},addScaledVector:function(a,c){this.x+=a.x*c;this.y+=a.y*c;this.z+=a.z*c;this.w+=a.w*c;return this},sub:function(a,c){if(void 0!==c)return console.warn("THREE.Vector4: .sub() now only accepts one argument. Use .subVectors( a, b ) instead."),this.subVectors(a,c);this.x-=a.x;this.y-=a.y;this.z-=a.z;this.w-=a.w;return this},subScalar:function(a){this.x-=
a;this.y-=a;this.z-=a;this.w-=a;return this},subVectors:function(a,c){this.x=a.x-c.x;this.y=a.y-c.y;this.z=a.z-c.z;this.w=a.w-c.w;return this},multiplyScalar:function(a){isFinite(a)?(this.x*=a,this.y*=a,this.z*=a,this.w*=a):this.w=this.z=this.y=this.x=0;return this},applyMatrix4:function(a){var c=this.x,b=this.y,e=this.z,f=this.w;a=a.elements;this.x=a[0]*c+a[4]*b+a[8]*e+a[12]*f;this.y=a[1]*c+a[5]*b+a[9]*e+a[13]*f;this.z=a[2]*c+a[6]*b+a[10]*e+a[14]*f;this.w=a[3]*c+a[7]*b+a[11]*e+a[15]*f;return this},
divideScalar:function(a){return this.multiplyScalar(1/a)},setAxisAngleFromQuaternion:function(a){this.w=2*Math.acos(a.w);var c=Math.sqrt(1-a.w*a.w);1E-4>c?(this.x=1,this.z=this.y=0):(this.x=a.x/c,this.y=a.y/c,this.z=a.z/c);return this},setAxisAngleFromRotationMatrix:function(a){var c,b,e;a=a.elements;var f=a[0];e=a[4];var g=a[8],h=a[1],n=a[5],u=a[9];b=a[2];c=a[6];var r=a[10];if(.01>Math.abs(e-h)&&.01>Math.abs(g-b)&&.01>Math.abs(u-c)){if(.1>Math.abs(e+h)&&.1>Math.abs(g+b)&&.1>Math.abs(u+c)&&.1>Math.abs(f+
n+r-3))return this.set(1,0,0,0),this;a=Math.PI;f=(f+1)/2;n=(n+1)/2;r=(r+1)/2;e=(e+h)/4;g=(g+b)/4;u=(u+c)/4;f>n&&f>r?.01>f?(c=0,e=b=.707106781):(c=Math.sqrt(f),b=e/c,e=g/c):n>r?.01>n?(c=.707106781,b=0,e=.707106781):(b=Math.sqrt(n),c=e/b,e=u/b):.01>r?(b=c=.707106781,e=0):(e=Math.sqrt(r),c=g/e,b=u/e);this.set(c,b,e,a);return this}a=Math.sqrt((c-u)*(c-u)+(g-b)*(g-b)+(h-e)*(h-e));.001>Math.abs(a)&&(a=1);this.x=(c-u)/a;this.y=(g-b)/a;this.z=(h-e)/a;this.w=Math.acos((f+n+r-1)/2);return this},min:function(a){this.x=
Math.min(this.x,a.x);this.y=Math.min(this.y,a.y);this.z=Math.min(this.z,a.z);this.w=Math.min(this.w,a.w);return this},max:function(a){this.x=Math.max(this.x,a.x);this.y=Math.max(this.y,a.y);this.z=Math.max(this.z,a.z);this.w=Math.max(this.w,a.w);return this},clamp:function(a,c){this.x=Math.max(a.x,Math.min(c.x,this.x));this.y=Math.max(a.y,Math.min(c.y,this.y));this.z=Math.max(a.z,Math.min(c.z,this.z));this.w=Math.max(a.w,Math.min(c.w,this.w));return this},clampScalar:function(){var a,c;return function(d,
e){void 0===a&&(a=new b.Vector4,c=new b.Vector4);a.set(d,d,d,d);c.set(e,e,e,e);return this.clamp(a,c)}}(),floor:function(){this.x=Math.floor(this.x);this.y=Math.floor(this.y);this.z=Math.floor(this.z);this.w=Math.floor(this.w);return this},ceil:function(){this.x=Math.ceil(this.x);this.y=Math.ceil(this.y);this.z=Math.ceil(this.z);this.w=Math.ceil(this.w);return this},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);this.z=Math.round(this.z);this.w=Math.round(this.w);return this},
roundToZero:function(){this.x=0>this.x?Math.ceil(this.x):Math.floor(this.x);this.y=0>this.y?Math.ceil(this.y):Math.floor(this.y);this.z=0>this.z?Math.ceil(this.z):Math.floor(this.z);this.w=0>this.w?Math.ceil(this.w):Math.floor(this.w);return this},negate:function(){this.x=-this.x;this.y=-this.y;this.z=-this.z;this.w=-this.w;return this},dot:function(a){return this.x*a.x+this.y*a.y+this.z*a.z+this.w*a.w},lengthSq:function(){return this.x*this.x+this.y*this.y+this.z*this.z+this.w*this.w},length:function(){return Math.sqrt(this.x*
this.x+this.y*this.y+this.z*this.z+this.w*this.w)},lengthManhattan:function(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)+Math.abs(this.w)},normalize:function(){return this.divideScalar(this.length())},setLength:function(a){return this.multiplyScalar(a/this.length())},lerp:function(a,c){this.x+=(a.x-this.x)*c;this.y+=(a.y-this.y)*c;this.z+=(a.z-this.z)*c;this.w+=(a.w-this.w)*c;return this},lerpVectors:function(a,c,b){this.subVectors(c,a).multiplyScalar(b).add(a);return this},equals:function(a){return a.x===
this.x&&a.y===this.y&&a.z===this.z&&a.w===this.w},fromArray:function(a,c){void 0===c&&(c=0);this.x=a[c];this.y=a[c+1];this.z=a[c+2];this.w=a[c+3];return this},toArray:function(a,c){void 0===a&&(a=[]);void 0===c&&(c=0);a[c]=this.x;a[c+1]=this.y;a[c+2]=this.z;a[c+3]=this.w;return a},fromAttribute:function(a,c,b){void 0===b&&(b=0);c=c*a.itemSize+b;this.x=a.array[c];this.y=a.array[c+1];this.z=a.array[c+2];this.w=a.array[c+3];return this}};b.Euler=function(a,c,d,e){this._x=a||0;this._y=c||0;this._z=d||
0;this._order=e||b.Euler.DefaultOrder};b.Euler.RotationOrders="XYZ YZX ZXY XZY YXZ ZYX".split(" ");b.Euler.DefaultOrder="XYZ";b.Euler.prototype={constructor:b.Euler,get x(){return this._x},set x(a){this._x=a;this.onChangeCallback()},get y(){return this._y},set y(a){this._y=a;this.onChangeCallback()},get z(){return this._z},set z(a){this._z=a;this.onChangeCallback()},get order(){return this._order},set order(a){this._order=a;this.onChangeCallback()},set:function(a,c,b,e){this._x=a;this._y=c;this._z=
b;this._order=e||this._order;this.onChangeCallback();return this},clone:function(){return new this.constructor(this._x,this._y,this._z,this._order)},copy:function(a){this._x=a._x;this._y=a._y;this._z=a._z;this._order=a._order;this.onChangeCallback();return this},setFromRotationMatrix:function(a,c,d){var e=b.Math.clamp,f=a.elements;a=f[0];var g=f[4],h=f[8],n=f[1],u=f[5],r=f[9],k=f[2],m=f[6],f=f[10];c=c||this._order;"XYZ"===c?(this._y=Math.asin(e(h,-1,1)),.99999>Math.abs(h)?(this._x=Math.atan2(-r,f),
this._z=Math.atan2(-g,a)):(this._x=Math.atan2(m,u),this._z=0)):"YXZ"===c?(this._x=Math.asin(-e(r,-1,1)),.99999>Math.abs(r)?(this._y=Math.atan2(h,f),this._z=Math.atan2(n,u)):(this._y=Math.atan2(-k,a),this._z=0)):"ZXY"===c?(this._x=Math.asin(e(m,-1,1)),.99999>Math.abs(m)?(this._y=Math.atan2(-k,f),this._z=Math.atan2(-g,u)):(this._y=0,this._z=Math.atan2(n,a))):"ZYX"===c?(this._y=Math.asin(-e(k,-1,1)),.99999>Math.abs(k)?(this._x=Math.atan2(m,f),this._z=Math.atan2(n,a)):(this._x=0,this._z=Math.atan2(-g,
u))):"YZX"===c?(this._z=Math.asin(e(n,-1,1)),.99999>Math.abs(n)?(this._x=Math.atan2(-r,u),this._y=Math.atan2(-k,a)):(this._x=0,this._y=Math.atan2(h,f))):"XZY"===c?(this._z=Math.asin(-e(g,-1,1)),.99999>Math.abs(g)?(this._x=Math.atan2(m,u),this._y=Math.atan2(h,a)):(this._x=Math.atan2(-r,f),this._y=0)):console.warn("THREE.Euler: .setFromRotationMatrix() given unsupported order: "+c);this._order=c;if(!1!==d)this.onChangeCallback();return this},setFromQuaternion:function(){var a;return function(c,d,e){void 0===
a&&(a=new b.Matrix4);a.makeRotationFromQuaternion(c);this.setFromRotationMatrix(a,d,e);return this}}(),setFromVector3:function(a,c){return this.set(a.x,a.y,a.z,c||this._order)},reorder:function(){var a=new b.Quaternion;return function(c){a.setFromEuler(this);this.setFromQuaternion(a,c)}}(),equals:function(a){return a._x===this._x&&a._y===this._y&&a._z===this._z&&a._order===this._order},fromArray:function(a){this._x=a[0];this._y=a[1];this._z=a[2];void 0!==a[3]&&(this._order=a[3]);this.onChangeCallback();
return this},toArray:function(a,c){void 0===a&&(a=[]);void 0===c&&(c=0);a[c]=this._x;a[c+1]=this._y;a[c+2]=this._z;a[c+3]=this._order;return a},toVector3:function(a){return a?a.set(this._x,this._y,this._z):new b.Vector3(this._x,this._y,this._z)},onChange:function(a){this.onChangeCallback=a;return this},onChangeCallback:function(){}};b.Matrix3=function(){this.elements=new Float32Array([1,0,0,0,1,0,0,0,1]);0<arguments.length&&console.error("THREE.Matrix3: the constructor no longer reads arguments. use .set() instead.")};
b.Matrix3.prototype={constructor:b.Matrix3,set:function(a,c,b,e,f,g,h,n,u){var r=this.elements;r[0]=a;r[1]=e;r[2]=h;r[3]=c;r[4]=f;r[5]=n;r[6]=b;r[7]=g;r[8]=u;return this},identity:function(){this.set(1,0,0,0,1,0,0,0,1);return this},clone:function(){return(new this.constructor).fromArray(this.elements)},copy:function(a){a=a.elements;this.set(a[0],a[3],a[6],a[1],a[4],a[7],a[2],a[5],a[8]);return this},setFromMatrix4:function(a){a=a.elements;this.set(a[0],a[4],a[8],a[1],a[5],a[9],a[2],a[6],a[10]);return this},
applyToVector3Array:function(){var a;return function(c,d,e){void 0===a&&(a=new b.Vector3);void 0===d&&(d=0);void 0===e&&(e=c.length);for(var f=0;f<e;f+=3,d+=3)a.fromArray(c,d),a.applyMatrix3(this),a.toArray(c,d);return c}}(),applyToBuffer:function(){var a;return function(c,d,e){void 0===a&&(a=new b.Vector3);void 0===d&&(d=0);void 0===e&&(e=c.length/c.itemSize);for(var f=0;f<e;f++,d++)a.x=c.getX(d),a.y=c.getY(d),a.z=c.getZ(d),a.applyMatrix3(this),c.setXYZ(a.x,a.y,a.z);return c}}(),multiplyScalar:function(a){var c=
this.elements;c[0]*=a;c[3]*=a;c[6]*=a;c[1]*=a;c[4]*=a;c[7]*=a;c[2]*=a;c[5]*=a;c[8]*=a;return this},determinant:function(){var a=this.elements,c=a[0],b=a[1],e=a[2],f=a[3],g=a[4],h=a[5],n=a[6],u=a[7],a=a[8];return c*g*a-c*h*u-b*f*a+b*h*n+e*f*u-e*g*n},getInverse:function(a,c){a instanceof b.Matrix4&&console.error("THREE.Matrix3.getInverse no longer takes a Matrix4 argument.");var d=a.elements,e=this.elements,f=d[0],g=d[1],h=d[2],n=d[3],u=d[4],r=d[5],k=d[6],m=d[7],d=d[8],l=d*u-r*m,p=r*k-d*n,q=m*n-u*k,
I=f*l+g*p+h*q;if(0===I){if(c)throw Error("THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0");console.warn("THREE.Matrix3.getInverse(): can't invert matrix, determinant is 0");return this.identity()}e[0]=l;e[1]=h*m-d*g;e[2]=r*g-h*u;e[3]=p;e[4]=d*f-h*k;e[5]=h*n-r*f;e[6]=q;e[7]=g*k-m*f;e[8]=u*f-g*n;return this.multiplyScalar(1/I)},transpose:function(){var a,c=this.elements;a=c[1];c[1]=c[3];c[3]=a;a=c[2];c[2]=c[6];c[6]=a;a=c[5];c[5]=c[7];c[7]=a;return this},flattenToArrayOffset:function(a,
c){console.warn("THREE.Matrix3: .flattenToArrayOffset is deprecated - just use .toArray instead.");return this.toArray(a,c)},getNormalMatrix:function(a){return this.setFromMatrix4(a).getInverse(this).transpose()},transposeIntoArray:function(a){var c=this.elements;a[0]=c[0];a[1]=c[3];a[2]=c[6];a[3]=c[1];a[4]=c[4];a[5]=c[7];a[6]=c[2];a[7]=c[5];a[8]=c[8];return this},fromArray:function(a){this.elements.set(a);return this},toArray:function(a,c){void 0===a&&(a=[]);void 0===c&&(c=0);var b=this.elements;
a[c]=b[0];a[c+1]=b[1];a[c+2]=b[2];a[c+3]=b[3];a[c+4]=b[4];a[c+5]=b[5];a[c+6]=b[6];a[c+7]=b[7];a[c+8]=b[8];return a}};b.Matrix4=function(){this.elements=new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);0<arguments.length&&console.error("THREE.Matrix4: the constructor no longer reads arguments. use .set() instead.")};b.Matrix4.prototype={constructor:b.Matrix4,set:function(a,c,b,e,f,g,h,n,u,r,k,m,l,p,q,I){var s=this.elements;s[0]=a;s[4]=c;s[8]=b;s[12]=e;s[1]=f;s[5]=g;s[9]=h;s[13]=n;s[2]=u;s[6]=r;
s[10]=k;s[14]=m;s[3]=l;s[7]=p;s[11]=q;s[15]=I;return this},identity:function(){this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1);return this},clone:function(){return(new b.Matrix4).fromArray(this.elements)},copy:function(a){this.elements.set(a.elements);return this},copyPosition:function(a){var c=this.elements;a=a.elements;c[12]=a[12];c[13]=a[13];c[14]=a[14];return this},extractBasis:function(a,c,b){a.setFromMatrixColumn(this,0);c.setFromMatrixColumn(this,1);b.setFromMatrixColumn(this,2);return this},makeBasis:function(a,
c,b){this.set(a.x,c.x,b.x,0,a.y,c.y,b.y,0,a.z,c.z,b.z,0,0,0,0,1);return this},extractRotation:function(){var a;return function(c){void 0===a&&(a=new b.Vector3);var d=this.elements,e=c.elements,f=1/a.setFromMatrixColumn(c,0).length(),g=1/a.setFromMatrixColumn(c,1).length();c=1/a.setFromMatrixColumn(c,2).length();d[0]=e[0]*f;d[1]=e[1]*f;d[2]=e[2]*f;d[4]=e[4]*g;d[5]=e[5]*g;d[6]=e[6]*g;d[8]=e[8]*c;d[9]=e[9]*c;d[10]=e[10]*c;return this}}(),makeRotationFromEuler:function(a){!1===a instanceof b.Euler&&console.error("THREE.Matrix: .makeRotationFromEuler() now expects a Euler rotation rather than a Vector3 and order.");
var c=this.elements,d=a.x,e=a.y,f=a.z,g=Math.cos(d),d=Math.sin(d),h=Math.cos(e),e=Math.sin(e),n=Math.cos(f),f=Math.sin(f);if("XYZ"===a.order){a=g*n;var u=g*f,r=d*n,k=d*f;c[0]=h*n;c[4]=-h*f;c[8]=e;c[1]=u+r*e;c[5]=a-k*e;c[9]=-d*h;c[2]=k-a*e;c[6]=r+u*e;c[10]=g*h}else"YXZ"===a.order?(a=h*n,u=h*f,r=e*n,k=e*f,c[0]=a+k*d,c[4]=r*d-u,c[8]=g*e,c[1]=g*f,c[5]=g*n,c[9]=-d,c[2]=u*d-r,c[6]=k+a*d,c[10]=g*h):"ZXY"===a.order?(a=h*n,u=h*f,r=e*n,k=e*f,c[0]=a-k*d,c[4]=-g*f,c[8]=r+u*d,c[1]=u+r*d,c[5]=g*n,c[9]=k-a*d,c[2]=
-g*e,c[6]=d,c[10]=g*h):"ZYX"===a.order?(a=g*n,u=g*f,r=d*n,k=d*f,c[0]=h*n,c[4]=r*e-u,c[8]=a*e+k,c[1]=h*f,c[5]=k*e+a,c[9]=u*e-r,c[2]=-e,c[6]=d*h,c[10]=g*h):"YZX"===a.order?(a=g*h,u=g*e,r=d*h,k=d*e,c[0]=h*n,c[4]=k-a*f,c[8]=r*f+u,c[1]=f,c[5]=g*n,c[9]=-d*n,c[2]=-e*n,c[6]=u*f+r,c[10]=a-k*f):"XZY"===a.order&&(a=g*h,u=g*e,r=d*h,k=d*e,c[0]=h*n,c[4]=-f,c[8]=e*n,c[1]=a*f+k,c[5]=g*n,c[9]=u*f-r,c[2]=r*f-u,c[6]=d*n,c[10]=k*f+a);c[3]=0;c[7]=0;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return this},makeRotationFromQuaternion:function(a){var c=
this.elements,b=a.x,e=a.y,f=a.z,g=a.w,h=b+b,n=e+e,u=f+f;a=b*h;var r=b*n,b=b*u,k=e*n,e=e*u,f=f*u,h=g*h,n=g*n,g=g*u;c[0]=1-(k+f);c[4]=r-g;c[8]=b+n;c[1]=r+g;c[5]=1-(a+f);c[9]=e-h;c[2]=b-n;c[6]=e+h;c[10]=1-(a+k);c[3]=0;c[7]=0;c[11]=0;c[12]=0;c[13]=0;c[14]=0;c[15]=1;return this},lookAt:function(){var a,c,d;return function(e,f,g){void 0===a&&(a=new b.Vector3);void 0===c&&(c=new b.Vector3);void 0===d&&(d=new b.Vector3);var h=this.elements;d.subVectors(e,f).normalize();0===d.lengthSq()&&(d.z=1);a.crossVectors(g,
d).normalize();0===a.lengthSq()&&(d.x+=1E-4,a.crossVectors(g,d).normalize());c.crossVectors(d,a);h[0]=a.x;h[4]=c.x;h[8]=d.x;h[1]=a.y;h[5]=c.y;h[9]=d.y;h[2]=a.z;h[6]=c.z;h[10]=d.z;return this}}(),multiply:function(a,c){return void 0!==c?(console.warn("THREE.Matrix4: .multiply() now only accepts one argument. Use .multiplyMatrices( a, b ) instead."),this.multiplyMatrices(a,c)):this.multiplyMatrices(this,a)},premultiply:function(a){return this.multiplyMatrices(a,this)},multiplyMatrices:function(a,c){var b=
a.elements,e=c.elements,f=this.elements,g=b[0],h=b[4],n=b[8],u=b[12],r=b[1],k=b[5],m=b[9],l=b[13],p=b[2],q=b[6],I=b[10],s=b[14],y=b[3],B=b[7],z=b[11],b=b[15],A=e[0],w=e[4],F=e[8],G=e[12],E=e[1],R=e[5],M=e[9],Q=e[13],L=e[2],D=e[6],P=e[10],N=e[14],T=e[3],H=e[7],J=e[11],e=e[15];f[0]=g*A+h*E+n*L+u*T;f[4]=g*w+h*R+n*D+u*H;f[8]=g*F+h*M+n*P+u*J;f[12]=g*G+h*Q+n*N+u*e;f[1]=r*A+k*E+m*L+l*T;f[5]=r*w+k*R+m*D+l*H;f[9]=r*F+k*M+m*P+l*J;f[13]=r*G+k*Q+m*N+l*e;f[2]=p*A+q*E+I*L+s*T;f[6]=p*w+q*R+I*D+s*H;f[10]=p*F+q*M+
I*P+s*J;f[14]=p*G+q*Q+I*N+s*e;f[3]=y*A+B*E+z*L+b*T;f[7]=y*w+B*R+z*D+b*H;f[11]=y*F+B*M+z*P+b*J;f[15]=y*G+B*Q+z*N+b*e;return this},multiplyToArray:function(a,c,b){var e=this.elements;this.multiplyMatrices(a,c);b[0]=e[0];b[1]=e[1];b[2]=e[2];b[3]=e[3];b[4]=e[4];b[5]=e[5];b[6]=e[6];b[7]=e[7];b[8]=e[8];b[9]=e[9];b[10]=e[10];b[11]=e[11];b[12]=e[12];b[13]=e[13];b[14]=e[14];b[15]=e[15];return this},multiplyScalar:function(a){var c=this.elements;c[0]*=a;c[4]*=a;c[8]*=a;c[12]*=a;c[1]*=a;c[5]*=a;c[9]*=a;c[13]*=
a;c[2]*=a;c[6]*=a;c[10]*=a;c[14]*=a;c[3]*=a;c[7]*=a;c[11]*=a;c[15]*=a;return this},applyToVector3Array:function(){var a;return function(c,d,e){void 0===a&&(a=new b.Vector3);void 0===d&&(d=0);void 0===e&&(e=c.length);for(var f=0;f<e;f+=3,d+=3)a.fromArray(c,d),a.applyMatrix4(this),a.toArray(c,d);return c}}(),applyToBuffer:function(){var a;return function(c,d,e){void 0===a&&(a=new b.Vector3);void 0===d&&(d=0);void 0===e&&(e=c.length/c.itemSize);for(var f=0;f<e;f++,d++)a.x=c.getX(d),a.y=c.getY(d),a.z=
c.getZ(d),a.applyMatrix4(this),c.setXYZ(a.x,a.y,a.z);return c}}(),determinant:function(){var a=this.elements,c=a[0],b=a[4],e=a[8],f=a[12],g=a[1],h=a[5],n=a[9],u=a[13],r=a[2],k=a[6],m=a[10],l=a[14];return a[3]*(+f*n*k-e*u*k-f*h*m+b*u*m+e*h*l-b*n*l)+a[7]*(+c*n*l-c*u*m+f*g*m-e*g*l+e*u*r-f*n*r)+a[11]*(+c*u*k-c*h*l-f*g*k+b*g*l+f*h*r-b*u*r)+a[15]*(-e*h*r-c*n*k+c*h*m+e*g*k-b*g*m+b*n*r)},transpose:function(){var a=this.elements,c;c=a[1];a[1]=a[4];a[4]=c;c=a[2];a[2]=a[8];a[8]=c;c=a[6];a[6]=a[9];a[9]=c;c=a[3];
a[3]=a[12];a[12]=c;c=a[7];a[7]=a[13];a[13]=c;c=a[11];a[11]=a[14];a[14]=c;return this},flattenToArrayOffset:function(a,c){console.warn("THREE.Matrix3: .flattenToArrayOffset is deprecated - just use .toArray instead.");return this.toArray(a,c)},getPosition:function(){var a;return function(){void 0===a&&(a=new b.Vector3);console.warn("THREE.Matrix4: .getPosition() has been removed. Use Vector3.setFromMatrixPosition( matrix ) instead.");return a.setFromMatrixColumn(this,3)}}(),setPosition:function(a){var c=
this.elements;c[12]=a.x;c[13]=a.y;c[14]=a.z;return this},getInverse:function(a,c){var b=this.elements,e=a.elements,f=e[0],g=e[1],h=e[2],n=e[3],u=e[4],r=e[5],k=e[6],m=e[7],l=e[8],p=e[9],q=e[10],I=e[11],s=e[12],y=e[13],B=e[14],e=e[15],z=p*B*m-y*q*m+y*k*I-r*B*I-p*k*e+r*q*e,A=s*q*m-l*B*m-s*k*I+u*B*I+l*k*e-u*q*e,w=l*y*m-s*p*m+s*r*I-u*y*I-l*r*e+u*p*e,F=s*p*k-l*y*k-s*r*q+u*y*q+l*r*B-u*p*B,G=f*z+g*A+h*w+n*F;if(0===G){if(c)throw Error("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");console.warn("THREE.Matrix4.getInverse(): can't invert matrix, determinant is 0");
return this.identity()}b[0]=z;b[1]=y*q*n-p*B*n-y*h*I+g*B*I+p*h*e-g*q*e;b[2]=r*B*n-y*k*n+y*h*m-g*B*m-r*h*e+g*k*e;b[3]=p*k*n-r*q*n-p*h*m+g*q*m+r*h*I-g*k*I;b[4]=A;b[5]=l*B*n-s*q*n+s*h*I-f*B*I-l*h*e+f*q*e;b[6]=s*k*n-u*B*n-s*h*m+f*B*m+u*h*e-f*k*e;b[7]=u*q*n-l*k*n+l*h*m-f*q*m-u*h*I+f*k*I;b[8]=w;b[9]=s*p*n-l*y*n-s*g*I+f*y*I+l*g*e-f*p*e;b[10]=u*y*n-s*r*n+s*g*m-f*y*m-u*g*e+f*r*e;b[11]=l*r*n-u*p*n-l*g*m+f*p*m+u*g*I-f*r*I;b[12]=F;b[13]=l*y*h-s*p*h+s*g*q-f*y*q-l*g*B+f*p*B;b[14]=s*r*h-u*y*h-s*g*k+f*y*k+u*g*B-
f*r*B;b[15]=u*p*h-l*r*h+l*g*k-f*p*k-u*g*q+f*r*q;return this.multiplyScalar(1/G)},scale:function(a){var c=this.elements,b=a.x,e=a.y;a=a.z;c[0]*=b;c[4]*=e;c[8]*=a;c[1]*=b;c[5]*=e;c[9]*=a;c[2]*=b;c[6]*=e;c[10]*=a;c[3]*=b;c[7]*=e;c[11]*=a;return this},getMaxScaleOnAxis:function(){var a=this.elements;return Math.sqrt(Math.max(a[0]*a[0]+a[1]*a[1]+a[2]*a[2],a[4]*a[4]+a[5]*a[5]+a[6]*a[6],a[8]*a[8]+a[9]*a[9]+a[10]*a[10]))},makeTranslation:function(a,c,b){this.set(1,0,0,a,0,1,0,c,0,0,1,b,0,0,0,1);return this},
makeRotationX:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(1,0,0,0,0,c,-a,0,0,a,c,0,0,0,0,1);return this},makeRotationY:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,0,a,0,0,1,0,0,-a,0,c,0,0,0,0,1);return this},makeRotationZ:function(a){var c=Math.cos(a);a=Math.sin(a);this.set(c,-a,0,0,a,c,0,0,0,0,1,0,0,0,0,1);return this},makeRotationAxis:function(a,c){var b=Math.cos(c),e=Math.sin(c),f=1-b,g=a.x,h=a.y,n=a.z,u=f*g,k=f*h;this.set(u*g+b,u*h-e*n,u*n+e*h,0,u*h+e*n,k*h+b,k*n-e*g,0,u*n-
e*h,k*n+e*g,f*n*n+b,0,0,0,0,1);return this},makeScale:function(a,c,b){this.set(a,0,0,0,0,c,0,0,0,0,b,0,0,0,0,1);return this},compose:function(a,c,b){this.makeRotationFromQuaternion(c);this.scale(b);this.setPosition(a);return this},decompose:function(){var a,c;return function(d,e,f){void 0===a&&(a=new b.Vector3);void 0===c&&(c=new b.Matrix4);var g=this.elements,h=a.set(g[0],g[1],g[2]).length(),n=a.set(g[4],g[5],g[6]).length(),u=a.set(g[8],g[9],g[10]).length();0>this.determinant()&&(h=-h);d.x=g[12];
d.y=g[13];d.z=g[14];c.elements.set(this.elements);d=1/h;var g=1/n,k=1/u;c.elements[0]*=d;c.elements[1]*=d;c.elements[2]*=d;c.elements[4]*=g;c.elements[5]*=g;c.elements[6]*=g;c.elements[8]*=k;c.elements[9]*=k;c.elements[10]*=k;e.setFromRotationMatrix(c);f.x=h;f.y=n;f.z=u;return this}}(),makeFrustum:function(a,c,b,e,f,g){var h=this.elements;h[0]=2*f/(c-a);h[4]=0;h[8]=(c+a)/(c-a);h[12]=0;h[1]=0;h[5]=2*f/(e-b);h[9]=(e+b)/(e-b);h[13]=0;h[2]=0;h[6]=0;h[10]=-(g+f)/(g-f);h[14]=-2*g*f/(g-f);h[3]=0;h[7]=0;
h[11]=-1;h[15]=0;return this},makePerspective:function(a,c,d,e){a=d*Math.tan(b.Math.DEG2RAD*a*.5);var f=-a;return this.makeFrustum(f*c,a*c,f,a,d,e)},makeOrthographic:function(a,c,b,e,f,g){var h=this.elements,n=1/(c-a),k=1/(b-e),r=1/(g-f);h[0]=2*n;h[4]=0;h[8]=0;h[12]=-((c+a)*n);h[1]=0;h[5]=2*k;h[9]=0;h[13]=-((b+e)*k);h[2]=0;h[6]=0;h[10]=-2*r;h[14]=-((g+f)*r);h[3]=0;h[7]=0;h[11]=0;h[15]=1;return this},equals:function(a){var c=this.elements;a=a.elements;for(var b=0;16>b;b++)if(c[b]!==a[b])return!1;return!0},
fromArray:function(a){this.elements.set(a);return this},toArray:function(a,c){void 0===a&&(a=[]);void 0===c&&(c=0);var b=this.elements;a[c]=b[0];a[c+1]=b[1];a[c+2]=b[2];a[c+3]=b[3];a[c+4]=b[4];a[c+5]=b[5];a[c+6]=b[6];a[c+7]=b[7];a[c+8]=b[8];a[c+9]=b[9];a[c+10]=b[10];a[c+11]=b[11];a[c+12]=b[12];a[c+13]=b[13];a[c+14]=b[14];a[c+15]=b[15];return a}};b.Ray=function(a,c){this.origin=void 0!==a?a:new b.Vector3;this.direction=void 0!==c?c:new b.Vector3};b.Ray.prototype={constructor:b.Ray,set:function(a,c){this.origin.copy(a);
this.direction.copy(c);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.origin.copy(a.origin);this.direction.copy(a.direction);return this},at:function(a,c){return(c||new b.Vector3).copy(this.direction).multiplyScalar(a).add(this.origin)},lookAt:function(a){this.direction.copy(a).sub(this.origin).normalize()},recast:function(){var a=new b.Vector3;return function(c){this.origin.copy(this.at(c,a));return this}}(),closestPointToPoint:function(a,c){var d=c||
new b.Vector3;d.subVectors(a,this.origin);var e=d.dot(this.direction);return 0>e?d.copy(this.origin):d.copy(this.direction).multiplyScalar(e).add(this.origin)},distanceToPoint:function(a){return Math.sqrt(this.distanceSqToPoint(a))},distanceSqToPoint:function(){var a=new b.Vector3;return function(c){var b=a.subVectors(c,this.origin).dot(this.direction);if(0>b)return this.origin.distanceToSquared(c);a.copy(this.direction).multiplyScalar(b).add(this.origin);return a.distanceToSquared(c)}}(),distanceSqToSegment:function(){var a=
new b.Vector3,c=new b.Vector3,d=new b.Vector3;return function(b,f,g,h){a.copy(b).add(f).multiplyScalar(.5);c.copy(f).sub(b).normalize();d.copy(this.origin).sub(a);var n=.5*b.distanceTo(f),k=-this.direction.dot(c),r=d.dot(this.direction),m=-d.dot(c),x=d.lengthSq(),l=Math.abs(1-k*k),p;0<l?(b=k*m-r,f=k*r-m,p=n*l,0<=b?f>=-p?f<=p?(n=1/l,b*=n,f*=n,k=b*(b+k*f+2*r)+f*(k*b+f+2*m)+x):(f=n,b=Math.max(0,-(k*f+r)),k=-b*b+f*(f+2*m)+x):(f=-n,b=Math.max(0,-(k*f+r)),k=-b*b+f*(f+2*m)+x):f<=-p?(b=Math.max(0,-(-k*n+
r)),f=0<b?-n:Math.min(Math.max(-n,-m),n),k=-b*b+f*(f+2*m)+x):f<=p?(b=0,f=Math.min(Math.max(-n,-m),n),k=f*(f+2*m)+x):(b=Math.max(0,-(k*n+r)),f=0<b?n:Math.min(Math.max(-n,-m),n),k=-b*b+f*(f+2*m)+x)):(f=0<k?-n:n,b=Math.max(0,-(k*f+r)),k=-b*b+f*(f+2*m)+x);g&&g.copy(this.direction).multiplyScalar(b).add(this.origin);h&&h.copy(c).multiplyScalar(f).add(a);return k}}(),intersectSphere:function(){var a=new b.Vector3;return function(c,b){a.subVectors(c.center,this.origin);var e=a.dot(this.direction),f=a.dot(a)-
e*e,g=c.radius*c.radius;if(f>g)return null;g=Math.sqrt(g-f);f=e-g;e+=g;return 0>f&&0>e?null:0>f?this.at(e,b):this.at(f,b)}}(),intersectsSphere:function(a){return this.distanceToPoint(a.center)<=a.radius},distanceToPlane:function(a){var c=a.normal.dot(this.direction);if(0===c)return 0===a.distanceToPoint(this.origin)?0:null;a=-(this.origin.dot(a.normal)+a.constant)/c;return 0<=a?a:null},intersectPlane:function(a,c){var b=this.distanceToPlane(a);return null===b?null:this.at(b,c)},intersectsPlane:function(a){var c=
a.distanceToPoint(this.origin);return 0===c||0>a.normal.dot(this.direction)*c?!0:!1},intersectBox:function(a,c){var b,e,f,g,h;e=1/this.direction.x;g=1/this.direction.y;h=1/this.direction.z;var n=this.origin;0<=e?(b=(a.min.x-n.x)*e,e*=a.max.x-n.x):(b=(a.max.x-n.x)*e,e*=a.min.x-n.x);0<=g?(f=(a.min.y-n.y)*g,g*=a.max.y-n.y):(f=(a.max.y-n.y)*g,g*=a.min.y-n.y);if(b>g||f>e)return null;if(f>b||b!==b)b=f;if(g<e||e!==e)e=g;0<=h?(f=(a.min.z-n.z)*h,h*=a.max.z-n.z):(f=(a.max.z-n.z)*h,h*=a.min.z-n.z);if(b>h||f>
e)return null;if(f>b||b!==b)b=f;if(h<e||e!==e)e=h;return 0>e?null:this.at(0<=b?b:e,c)},intersectsBox:function(){var a=new b.Vector3;return function(b){return null!==this.intersectBox(b,a)}}(),intersectTriangle:function(){var a=new b.Vector3,c=new b.Vector3,d=new b.Vector3,e=new b.Vector3;return function(b,g,h,n,k){c.subVectors(g,b);d.subVectors(h,b);e.crossVectors(c,d);g=this.direction.dot(e);if(0<g){if(n)return null;n=1}else if(0>g)n=-1,g=-g;else return null;a.subVectors(this.origin,b);b=n*this.direction.dot(d.crossVectors(a,
d));if(0>b)return null;h=n*this.direction.dot(c.cross(a));if(0>h||b+h>g)return null;b=-n*a.dot(e);return 0>b?null:this.at(b/g,k)}}(),applyMatrix4:function(a){this.direction.add(this.origin).applyMatrix4(a);this.origin.applyMatrix4(a);this.direction.sub(this.origin);this.direction.normalize();return this},equals:function(a){return a.origin.equals(this.origin)&&a.direction.equals(this.direction)}};b.Box2=function(a,c){this.min=void 0!==a?a:new b.Vector2(Infinity,Infinity);this.max=void 0!==c?c:new b.Vector2(-Infinity,
-Infinity)};b.Box2.prototype={constructor:b.Box2,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromPoints:function(a){this.makeEmpty();for(var b=0,d=a.length;b<d;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new b.Vector2;return function(b,d){var e=a.copy(d).multiplyScalar(.5);this.min.copy(b).sub(e);this.max.copy(b).add(e);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);
return this},makeEmpty:function(){this.min.x=this.min.y=Infinity;this.max.x=this.max.y=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y},center:function(a){return(a||new b.Vector2).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(a){return(a||new b.Vector2).subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);
this.max.addScalar(a);return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y?!0:!1},getParameter:function(a,c){return(c||new b.Vector2).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y))},intersectsBox:function(a){return a.max.x<this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y?
!1:!0},clampPoint:function(a,c){return(c||new b.Vector2).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new b.Vector2;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},translate:function(a){this.min.add(a);this.max.add(a);return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};
b.Box3=function(a,c){this.min=void 0!==a?a:new b.Vector3(Infinity,Infinity,Infinity);this.max=void 0!==c?c:new b.Vector3(-Infinity,-Infinity,-Infinity)};b.Box3.prototype={constructor:b.Box3,set:function(a,b){this.min.copy(a);this.max.copy(b);return this},setFromArray:function(a){for(var b=Infinity,d=Infinity,e=Infinity,f=-Infinity,g=-Infinity,h=-Infinity,n=0,k=a.length;n<k;n+=3){var r=a[n],m=a[n+1],x=a[n+2];r<b&&(b=r);m<d&&(d=m);x<e&&(e=x);r>f&&(f=r);m>g&&(g=m);x>h&&(h=x)}this.min.set(b,d,e);this.max.set(f,
g,h)},setFromPoints:function(a){this.makeEmpty();for(var b=0,d=a.length;b<d;b++)this.expandByPoint(a[b]);return this},setFromCenterAndSize:function(){var a=new b.Vector3;return function(b,d){var e=a.copy(d).multiplyScalar(.5);this.min.copy(b).sub(e);this.max.copy(b).add(e);return this}}(),setFromObject:function(){var a=new b.Vector3;return function(c){var d=this;c.updateMatrixWorld(!0);this.makeEmpty();c.traverse(function(c){var f=c.geometry;if(void 0!==f)if(f instanceof b.Geometry)for(var g=f.vertices,
f=0,h=g.length;f<h;f++)a.copy(g[f]),a.applyMatrix4(c.matrixWorld),d.expandByPoint(a);else if(f instanceof b.BufferGeometry&&void 0!==f.attributes.position)for(g=f.attributes.position.array,f=0,h=g.length;f<h;f+=3)a.fromArray(g,f),a.applyMatrix4(c.matrixWorld),d.expandByPoint(a)});return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.min.copy(a.min);this.max.copy(a.max);return this},makeEmpty:function(){this.min.x=this.min.y=this.min.z=Infinity;this.max.x=
this.max.y=this.max.z=-Infinity;return this},isEmpty:function(){return this.max.x<this.min.x||this.max.y<this.min.y||this.max.z<this.min.z},center:function(a){return(a||new b.Vector3).addVectors(this.min,this.max).multiplyScalar(.5)},size:function(a){return(a||new b.Vector3).subVectors(this.max,this.min)},expandByPoint:function(a){this.min.min(a);this.max.max(a);return this},expandByVector:function(a){this.min.sub(a);this.max.add(a);return this},expandByScalar:function(a){this.min.addScalar(-a);this.max.addScalar(a);
return this},containsPoint:function(a){return a.x<this.min.x||a.x>this.max.x||a.y<this.min.y||a.y>this.max.y||a.z<this.min.z||a.z>this.max.z?!1:!0},containsBox:function(a){return this.min.x<=a.min.x&&a.max.x<=this.max.x&&this.min.y<=a.min.y&&a.max.y<=this.max.y&&this.min.z<=a.min.z&&a.max.z<=this.max.z?!0:!1},getParameter:function(a,c){return(c||new b.Vector3).set((a.x-this.min.x)/(this.max.x-this.min.x),(a.y-this.min.y)/(this.max.y-this.min.y),(a.z-this.min.z)/(this.max.z-this.min.z))},intersectsBox:function(a){return a.max.x<
this.min.x||a.min.x>this.max.x||a.max.y<this.min.y||a.min.y>this.max.y||a.max.z<this.min.z||a.min.z>this.max.z?!1:!0},intersectsSphere:function(){var a;return function(c){void 0===a&&(a=new b.Vector3);this.clampPoint(c.center,a);return a.distanceToSquared(c.center)<=c.radius*c.radius}}(),intersectsPlane:function(a){var b,d;0<a.normal.x?(b=a.normal.x*this.min.x,d=a.normal.x*this.max.x):(b=a.normal.x*this.max.x,d=a.normal.x*this.min.x);0<a.normal.y?(b+=a.normal.y*this.min.y,d+=a.normal.y*this.max.y):
(b+=a.normal.y*this.max.y,d+=a.normal.y*this.min.y);0<a.normal.z?(b+=a.normal.z*this.min.z,d+=a.normal.z*this.max.z):(b+=a.normal.z*this.max.z,d+=a.normal.z*this.min.z);return b<=a.constant&&d>=a.constant},clampPoint:function(a,c){return(c||new b.Vector3).copy(a).clamp(this.min,this.max)},distanceToPoint:function(){var a=new b.Vector3;return function(b){return a.copy(b).clamp(this.min,this.max).sub(b).length()}}(),getBoundingSphere:function(){var a=new b.Vector3;return function(c){c=c||new b.Sphere;
c.center=this.center();c.radius=.5*this.size(a).length();return c}}(),intersect:function(a){this.min.max(a.min);this.max.min(a.max);this.isEmpty()&&this.makeEmpty();return this},union:function(a){this.min.min(a.min);this.max.max(a.max);return this},applyMatrix4:function(){var a=[new b.Vector3,new b.Vector3,new b.Vector3,new b.Vector3,new b.Vector3,new b.Vector3,new b.Vector3,new b.Vector3];return function(b){if(this.isEmpty())return this;a[0].set(this.min.x,this.min.y,this.min.z).applyMatrix4(b);
a[1].set(this.min.x,this.min.y,this.max.z).applyMatrix4(b);a[2].set(this.min.x,this.max.y,this.min.z).applyMatrix4(b);a[3].set(this.min.x,this.max.y,this.max.z).applyMatrix4(b);a[4].set(this.max.x,this.min.y,this.min.z).applyMatrix4(b);a[5].set(this.max.x,this.min.y,this.max.z).applyMatrix4(b);a[6].set(this.max.x,this.max.y,this.min.z).applyMatrix4(b);a[7].set(this.max.x,this.max.y,this.max.z).applyMatrix4(b);this.setFromPoints(a);return this}}(),translate:function(a){this.min.add(a);this.max.add(a);
return this},equals:function(a){return a.min.equals(this.min)&&a.max.equals(this.max)}};b.Sphere=function(a,c){this.center=void 0!==a?a:new b.Vector3;this.radius=void 0!==c?c:0};b.Sphere.prototype={constructor:b.Sphere,set:function(a,b){this.center.copy(a);this.radius=b;return this},setFromPoints:function(){var a=new b.Box3;return function(b,d){var e=this.center;void 0!==d?e.copy(d):a.setFromPoints(b).center(e);for(var f=0,g=0,h=b.length;g<h;g++)f=Math.max(f,e.distanceToSquared(b[g]));this.radius=
Math.sqrt(f);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.center.copy(a.center);this.radius=a.radius;return this},empty:function(){return 0>=this.radius},containsPoint:function(a){return a.distanceToSquared(this.center)<=this.radius*this.radius},distanceToPoint:function(a){return a.distanceTo(this.center)-this.radius},intersectsSphere:function(a){var b=this.radius+a.radius;return a.center.distanceToSquared(this.center)<=b*b},intersectsBox:function(a){return a.intersectsSphere(this)},
intersectsPlane:function(a){return Math.abs(this.center.dot(a.normal)-a.constant)<=this.radius},clampPoint:function(a,c){var d=this.center.distanceToSquared(a),e=c||new b.Vector3;e.copy(a);d>this.radius*this.radius&&(e.sub(this.center).normalize(),e.multiplyScalar(this.radius).add(this.center));return e},getBoundingBox:function(a){a=a||new b.Box3;a.set(this.center,this.center);a.expandByScalar(this.radius);return a},applyMatrix4:function(a){this.center.applyMatrix4(a);this.radius*=a.getMaxScaleOnAxis();
return this},translate:function(a){this.center.add(a);return this},equals:function(a){return a.center.equals(this.center)&&a.radius===this.radius}};b.Plane=function(a,c){this.normal=void 0!==a?a:new b.Vector3(1,0,0);this.constant=void 0!==c?c:0};b.Plane.prototype={constructor:b.Plane,set:function(a,b){this.normal.copy(a);this.constant=b;return this},setComponents:function(a,b,d,e){this.normal.set(a,b,d);this.constant=e;return this},setFromNormalAndCoplanarPoint:function(a,b){this.normal.copy(a);this.constant=
-b.dot(this.normal);return this},setFromCoplanarPoints:function(){var a=new b.Vector3,c=new b.Vector3;return function(b,e,f){e=a.subVectors(f,e).cross(c.subVectors(b,e)).normalize();this.setFromNormalAndCoplanarPoint(e,b);return this}}(),clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.normal.copy(a.normal);this.constant=a.constant;return this},normalize:function(){var a=1/this.normal.length();this.normal.multiplyScalar(a);this.constant*=a;return this},negate:function(){this.constant*=
-1;this.normal.negate();return this},distanceToPoint:function(a){return this.normal.dot(a)+this.constant},distanceToSphere:function(a){return this.distanceToPoint(a.center)-a.radius},projectPoint:function(a,b){return this.orthoPoint(a,b).sub(a).negate()},orthoPoint:function(a,c){var d=this.distanceToPoint(a);return(c||new b.Vector3).copy(this.normal).multiplyScalar(d)},intersectLine:function(){var a=new b.Vector3;return function(c,d){var e=d||new b.Vector3,f=c.delta(a),g=this.normal.dot(f);if(0===
g){if(0===this.distanceToPoint(c.start))return e.copy(c.start)}else return g=-(c.start.dot(this.normal)+this.constant)/g,0>g||1<g?void 0:e.copy(f).multiplyScalar(g).add(c.start)}}(),intersectsLine:function(a){var b=this.distanceToPoint(a.start);a=this.distanceToPoint(a.end);return 0>b&&0<a||0>a&&0<b},intersectsBox:function(a){return a.intersectsPlane(this)},intersectsSphere:function(a){return a.intersectsPlane(this)},coplanarPoint:function(a){return(a||new b.Vector3).copy(this.normal).multiplyScalar(-this.constant)},
applyMatrix4:function(){var a=new b.Vector3,c=new b.Matrix3;return function(b,e){var f=this.coplanarPoint(a).applyMatrix4(b),g=e||c.getNormalMatrix(b),g=this.normal.applyMatrix3(g).normalize();this.constant=-f.dot(g);return this}}(),translate:function(a){this.constant-=a.dot(this.normal);return this},equals:function(a){return a.normal.equals(this.normal)&&a.constant===this.constant}};b.Frustum=function(a,c,d,e,f,g){this.planes=[void 0!==a?a:new b.Plane,void 0!==c?c:new b.Plane,void 0!==d?d:new b.Plane,
void 0!==e?e:new b.Plane,void 0!==f?f:new b.Plane,void 0!==g?g:new b.Plane]};b.Frustum.prototype={constructor:b.Frustum,set:function(a,b,d,e,f,g){var h=this.planes;h[0].copy(a);h[1].copy(b);h[2].copy(d);h[3].copy(e);h[4].copy(f);h[5].copy(g);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){for(var b=this.planes,d=0;6>d;d++)b[d].copy(a.planes[d]);return this},setFromMatrix:function(a){var b=this.planes,d=a.elements;a=d[0];var e=d[1],f=d[2],g=d[3],h=d[4],n=d[5],
k=d[6],r=d[7],m=d[8],x=d[9],l=d[10],p=d[11],q=d[12],s=d[13],w=d[14],d=d[15];b[0].setComponents(g-a,r-h,p-m,d-q).normalize();b[1].setComponents(g+a,r+h,p+m,d+q).normalize();b[2].setComponents(g+e,r+n,p+x,d+s).normalize();b[3].setComponents(g-e,r-n,p-x,d-s).normalize();b[4].setComponents(g-f,r-k,p-l,d-w).normalize();b[5].setComponents(g+f,r+k,p+l,d+w).normalize();return this},intersectsObject:function(){var a=new b.Sphere;return function(b){var d=b.geometry;null===d.boundingSphere&&d.computeBoundingSphere();
a.copy(d.boundingSphere);a.applyMatrix4(b.matrixWorld);return this.intersectsSphere(a)}}(),intersectsSphere:function(a){var b=this.planes,d=a.center;a=-a.radius;for(var e=0;6>e;e++)if(b[e].distanceToPoint(d)<a)return!1;return!0},intersectsBox:function(){var a=new b.Vector3,c=new b.Vector3;return function(b){for(var e=this.planes,f=0;6>f;f++){var g=e[f];a.x=0<g.normal.x?b.min.x:b.max.x;c.x=0<g.normal.x?b.max.x:b.min.x;a.y=0<g.normal.y?b.min.y:b.max.y;c.y=0<g.normal.y?b.max.y:b.min.y;a.z=0<g.normal.z?
b.min.z:b.max.z;c.z=0<g.normal.z?b.max.z:b.min.z;var h=g.distanceToPoint(a),g=g.distanceToPoint(c);if(0>h&&0>g)return!1}return!0}}(),containsPoint:function(a){for(var b=this.planes,d=0;6>d;d++)if(0>b[d].distanceToPoint(a))return!1;return!0}};b.Math={DEG2RAD:Math.PI/180,RAD2DEG:180/Math.PI,generateUUID:function(){var a="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".split(""),b=Array(36),d=0,e;return function(){for(var f=0;36>f;f++)8===f||13===f||18===f||23===f?b[f]="-":14===f?b[f]=
"4":(2>=d&&(d=33554432+16777216*Math.random()|0),e=d&15,d>>=4,b[f]=a[19===f?e&3|8:e]);return b.join("")}}(),clamp:function(a,b,d){return Math.max(b,Math.min(d,a))},euclideanModulo:function(a,b){return(a%b+b)%b},mapLinear:function(a,b,d,e,f){return e+(a-b)*(f-e)/(d-b)},smoothstep:function(a,b,d){if(a<=b)return 0;if(a>=d)return 1;a=(a-b)/(d-b);return a*a*(3-2*a)},smootherstep:function(a,b,d){if(a<=b)return 0;if(a>=d)return 1;a=(a-b)/(d-b);return a*a*a*(a*(6*a-15)+10)},random16:function(){console.warn("THREE.Math.random16() has been deprecated. Use Math.random() instead.");
return Math.random()},randInt:function(a,b){return a+Math.floor(Math.random()*(b-a+1))},randFloat:function(a,b){return a+Math.random()*(b-a)},randFloatSpread:function(a){return a*(.5-Math.random())},degToRad:function(a){return a*b.Math.DEG2RAD},radToDeg:function(a){return a*b.Math.RAD2DEG},isPowerOfTwo:function(a){return 0===(a&a-1)&&0!==a},nearestPowerOfTwo:function(a){return Math.pow(2,Math.round(Math.log(a)/Math.LN2))},nextPowerOfTwo:function(a){a--;a|=a>>1;a|=a>>2;a|=a>>4;a|=a>>8;a|=a>>16;a++;
return a}};b.Triangle=function(a,c,d){this.a=void 0!==a?a:new b.Vector3;this.b=void 0!==c?c:new b.Vector3;this.c=void 0!==d?d:new b.Vector3};b.Triangle.normal=function(){var a=new b.Vector3;return function(c,d,e,f){f=f||new b.Vector3;f.subVectors(e,d);a.subVectors(c,d);f.cross(a);c=f.lengthSq();return 0<c?f.multiplyScalar(1/Math.sqrt(c)):f.set(0,0,0)}}();b.Triangle.barycoordFromPoint=function(){var a=new b.Vector3,c=new b.Vector3,d=new b.Vector3;return function(e,f,g,h,n){a.subVectors(h,f);c.subVectors(g,
f);d.subVectors(e,f);e=a.dot(a);f=a.dot(c);g=a.dot(d);var k=c.dot(c);h=c.dot(d);var m=e*k-f*f;n=n||new b.Vector3;if(0===m)return n.set(-2,-1,-1);m=1/m;k=(k*g-f*h)*m;e=(e*h-f*g)*m;return n.set(1-k-e,e,k)}}();b.Triangle.containsPoint=function(){var a=new b.Vector3;return function(c,d,e,f){c=b.Triangle.barycoordFromPoint(c,d,e,f,a);return 0<=c.x&&0<=c.y&&1>=c.x+c.y}}();b.Triangle.prototype={constructor:b.Triangle,set:function(a,b,d){this.a.copy(a);this.b.copy(b);this.c.copy(d);return this},setFromPointsAndIndices:function(a,
b,d,e){this.a.copy(a[b]);this.b.copy(a[d]);this.c.copy(a[e]);return this},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a.copy(a.a);this.b.copy(a.b);this.c.copy(a.c);return this},area:function(){var a=new b.Vector3,c=new b.Vector3;return function(){a.subVectors(this.c,this.b);c.subVectors(this.a,this.b);return.5*a.cross(c).length()}}(),midpoint:function(a){return(a||new b.Vector3).addVectors(this.a,this.b).add(this.c).multiplyScalar(1/3)},normal:function(a){return b.Triangle.normal(this.a,
this.b,this.c,a)},plane:function(a){return(a||new b.Plane).setFromCoplanarPoints(this.a,this.b,this.c)},barycoordFromPoint:function(a,c){return b.Triangle.barycoordFromPoint(a,this.a,this.b,this.c,c)},containsPoint:function(a){return b.Triangle.containsPoint(a,this.a,this.b,this.c)},closestPointToPoint:function(){var a,c,d,e;return function(f,g){void 0===a&&(a=new b.Plane,c=[new b.Line3,new b.Line3,new b.Line3],d=new b.Vector3,e=new b.Vector3);var h=g||new b.Vector3,n=Infinity;a.setFromCoplanarPoints(this.a,
this.b,this.c);a.projectPoint(f,d);if(!0===this.containsPoint(d))h.copy(d);else{c[0].set(this.a,this.b);c[1].set(this.b,this.c);c[2].set(this.c,this.a);for(var k=0;k<c.length;k++){c[k].closestPointToPoint(d,!0,e);var m=d.distanceToSquared(e);m<n&&(n=m,h.copy(e))}}return h}}(),equals:function(a){return a.a.equals(this.a)&&a.b.equals(this.b)&&a.c.equals(this.c)}};b.EventDispatcher=function(){};b.EventDispatcher.prototype={constructor:b.EventDispatcher,apply:function(a){a.addEventListener=b.EventDispatcher.prototype.addEventListener;
a.hasEventListener=b.EventDispatcher.prototype.hasEventListener;a.removeEventListener=b.EventDispatcher.prototype.removeEventListener;a.dispatchEvent=b.EventDispatcher.prototype.dispatchEvent},addEventListener:function(a,b){void 0===this._listeners&&(this._listeners={});var d=this._listeners;void 0===d[a]&&(d[a]=[]);-1===d[a].indexOf(b)&&d[a].push(b)},hasEventListener:function(a,b){if(void 0===this._listeners)return!1;var d=this._listeners;return void 0!==d[a]&&-1!==d[a].indexOf(b)?!0:!1},removeEventListener:function(a,
b){if(void 0!==this._listeners){var d=this._listeners[a];if(void 0!==d){var e=d.indexOf(b);-1!==e&&d.splice(e,1)}}},dispatchEvent:function(a){if(void 0!==this._listeners){var b=this._listeners[a.type];if(void 0!==b){a.target=this;for(var d=[],e=b.length,f=0;f<e;f++)d[f]=b[f];for(f=0;f<e;f++)d[f].call(this,a)}}}};(function(a){function b(a,c){return a.distance-c.distance}function d(a,b,c,h){if(!1!==a.visible&&(a.raycast(b,c),!0===h)){a=a.children;h=0;for(var n=a.length;h<n;h++)d(a[h],b,c,!0)}}a.Raycaster=
function(b,c,d,h){this.ray=new a.Ray(b,c);this.near=d||0;this.far=h||Infinity;this.params={Mesh:{},Line:{},LOD:{},Points:{threshold:1},Sprite:{}};Object.defineProperties(this.params,{PointCloud:{get:function(){console.warn("THREE.Raycaster: params.PointCloud has been renamed to params.Points.");return this.Points}}})};a.Raycaster.prototype={constructor:a.Raycaster,linePrecision:1,set:function(a,b){this.ray.set(a,b)},setFromCamera:function(b,c){c instanceof a.PerspectiveCamera?(this.ray.origin.setFromMatrixPosition(c.matrixWorld),
this.ray.direction.set(b.x,b.y,.5).unproject(c).sub(this.ray.origin).normalize()):c instanceof a.OrthographicCamera?(this.ray.origin.set(b.x,b.y,-1).unproject(c),this.ray.direction.set(0,0,-1).transformDirection(c.matrixWorld)):console.error("THREE.Raycaster: Unsupported camera type.")},intersectObject:function(a,f){var g=[];d(a,this,g,f);g.sort(b);return g},intersectObjects:function(a,f){var g=[];if(!1===Array.isArray(a))return console.warn("THREE.Raycaster.intersectObjects: objects is not an Array."),
g;for(var h=0,n=a.length;h<n;h++)d(a[h],this,g,f);g.sort(b);return g}}})(b);b.Object3D=function(){Object.defineProperty(this,"id",{value:b.Object3DIdCount++});this.uuid=b.Math.generateUUID();this.name="";this.type="Object3D";this.parent=null;this.children=[];this.up=b.Object3D.DefaultUp.clone();var a=new b.Vector3,c=new b.Euler,d=new b.Quaternion,e=new b.Vector3(1,1,1);c.onChange(function(){d.setFromEuler(c,!1)});d.onChange(function(){c.setFromQuaternion(d,void 0,!1)});Object.defineProperties(this,
{position:{enumerable:!0,value:a},rotation:{enumerable:!0,value:c},quaternion:{enumerable:!0,value:d},scale:{enumerable:!0,value:e},modelViewMatrix:{value:new b.Matrix4},normalMatrix:{value:new b.Matrix3}});this.rotationAutoUpdate=!0;this.matrix=new b.Matrix4;this.matrixWorld=new b.Matrix4;this.matrixAutoUpdate=b.Object3D.DefaultMatrixAutoUpdate;this.matrixWorldNeedsUpdate=!1;this.layers=new b.Layers;this.visible=!0;this.receiveShadow=this.castShadow=!1;this.frustumCulled=!0;this.renderOrder=0;this.userData=
{}};b.Object3D.DefaultUp=new b.Vector3(0,1,0);b.Object3D.DefaultMatrixAutoUpdate=!0;b.Object3D.prototype={constructor:b.Object3D,applyMatrix:function(a){this.matrix.multiplyMatrices(a,this.matrix);this.matrix.decompose(this.position,this.quaternion,this.scale)},setRotationFromAxisAngle:function(a,b){this.quaternion.setFromAxisAngle(a,b)},setRotationFromEuler:function(a){this.quaternion.setFromEuler(a,!0)},setRotationFromMatrix:function(a){this.quaternion.setFromRotationMatrix(a)},setRotationFromQuaternion:function(a){this.quaternion.copy(a)},
rotateOnAxis:function(){var a=new b.Quaternion;return function(b,d){a.setFromAxisAngle(b,d);this.quaternion.multiply(a);return this}}(),rotateX:function(){var a=new b.Vector3(1,0,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateY:function(){var a=new b.Vector3(0,1,0);return function(b){return this.rotateOnAxis(a,b)}}(),rotateZ:function(){var a=new b.Vector3(0,0,1);return function(b){return this.rotateOnAxis(a,b)}}(),translateOnAxis:function(){var a=new b.Vector3;return function(b,d){a.copy(b).applyQuaternion(this.quaternion);
this.position.add(a.multiplyScalar(d));return this}}(),translateX:function(){var a=new b.Vector3(1,0,0);return function(b){return this.translateOnAxis(a,b)}}(),translateY:function(){var a=new b.Vector3(0,1,0);return function(b){return this.translateOnAxis(a,b)}}(),translateZ:function(){var a=new b.Vector3(0,0,1);return function(b){return this.translateOnAxis(a,b)}}(),localToWorld:function(a){return a.applyMatrix4(this.matrixWorld)},worldToLocal:function(){var a=new b.Matrix4;return function(b){return b.applyMatrix4(a.getInverse(this.matrixWorld))}}(),
lookAt:function(){var a=new b.Matrix4;return function(b){a.lookAt(b,this.position,this.up);this.quaternion.setFromRotationMatrix(a)}}(),add:function(a){if(1<arguments.length){for(var c=0;c<arguments.length;c++)this.add(arguments[c]);return this}if(a===this)return console.error("THREE.Object3D.add: object can't be added as a child of itself.",a),this;a instanceof b.Object3D?(null!==a.parent&&a.parent.remove(a),a.parent=this,a.dispatchEvent({type:"added"}),this.children.push(a)):console.error("THREE.Object3D.add: object not an instance of THREE.Object3D.",
a);return this},remove:function(a){if(1<arguments.length)for(var b=0;b<arguments.length;b++)this.remove(arguments[b]);b=this.children.indexOf(a);-1!==b&&(a.parent=null,a.dispatchEvent({type:"removed"}),this.children.splice(b,1))},getObjectById:function(a){return this.getObjectByProperty("id",a)},getObjectByName:function(a){return this.getObjectByProperty("name",a)},getObjectByProperty:function(a,b){if(this[a]===b)return this;for(var d=0,e=this.children.length;d<e;d++){var f=this.children[d].getObjectByProperty(a,
b);if(void 0!==f)return f}},getWorldPosition:function(a){a=a||new b.Vector3;this.updateMatrixWorld(!0);return a.setFromMatrixPosition(this.matrixWorld)},getWorldQuaternion:function(){var a=new b.Vector3,c=new b.Vector3;return function(d){d=d||new b.Quaternion;this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,d,c);return d}}(),getWorldRotation:function(){var a=new b.Quaternion;return function(c){c=c||new b.Euler;this.getWorldQuaternion(a);return c.setFromQuaternion(a,this.rotation.order,!1)}}(),
getWorldScale:function(){var a=new b.Vector3,c=new b.Quaternion;return function(d){d=d||new b.Vector3;this.updateMatrixWorld(!0);this.matrixWorld.decompose(a,c,d);return d}}(),getWorldDirection:function(){var a=new b.Quaternion;return function(c){c=c||new b.Vector3;this.getWorldQuaternion(a);return c.set(0,0,1).applyQuaternion(a)}}(),raycast:function(){},traverse:function(a){a(this);for(var b=this.children,d=0,e=b.length;d<e;d++)b[d].traverse(a)},traverseVisible:function(a){if(!1!==this.visible){a(this);
for(var b=this.children,d=0,e=b.length;d<e;d++)b[d].traverseVisible(a)}},traverseAncestors:function(a){var b=this.parent;null!==b&&(a(b),b.traverseAncestors(a))},updateMatrix:function(){this.matrix.compose(this.position,this.quaternion,this.scale);this.matrixWorldNeedsUpdate=!0},updateMatrixWorld:function(a){!0===this.matrixAutoUpdate&&this.updateMatrix();if(!0===this.matrixWorldNeedsUpdate||!0===a)null===this.parent?this.matrixWorld.copy(this.matrix):this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,
this.matrix),this.matrixWorldNeedsUpdate=!1,a=!0;for(var b=0,d=this.children.length;b<d;b++)this.children[b].updateMatrixWorld(a)},toJSON:function(a){function b(a){var c=[],d;for(d in a){var e=a[d];delete e.metadata;c.push(e)}return c}var d=void 0===a||""===a,e={};d&&(a={geometries:{},materials:{},textures:{},images:{}},e.metadata={version:4.4,type:"Object",generator:"Object3D.toJSON"});var f={};f.uuid=this.uuid;f.type=this.type;""!==this.name&&(f.name=this.name);"{}"!==JSON.stringify(this.userData)&&
(f.userData=this.userData);!0===this.castShadow&&(f.castShadow=!0);!0===this.receiveShadow&&(f.receiveShadow=!0);!1===this.visible&&(f.visible=!1);f.matrix=this.matrix.toArray();void 0!==this.geometry&&(void 0===a.geometries[this.geometry.uuid]&&(a.geometries[this.geometry.uuid]=this.geometry.toJSON(a)),f.geometry=this.geometry.uuid);void 0!==this.material&&(void 0===a.materials[this.material.uuid]&&(a.materials[this.material.uuid]=this.material.toJSON(a)),f.material=this.material.uuid);if(0<this.children.length){f.children=
[];for(var g=0;g<this.children.length;g++)f.children.push(this.children[g].toJSON(a).object)}if(d){var d=b(a.geometries),g=b(a.materials),h=b(a.textures);a=b(a.images);0<d.length&&(e.geometries=d);0<g.length&&(e.materials=g);0<h.length&&(e.textures=h);0<a.length&&(e.images=a)}e.object=f;return e},clone:function(a){return(new this.constructor).copy(this,a)},copy:function(a,b){void 0===b&&(b=!0);this.name=a.name;this.up.copy(a.up);this.position.copy(a.position);this.quaternion.copy(a.quaternion);this.scale.copy(a.scale);
this.rotationAutoUpdate=a.rotationAutoUpdate;this.matrix.copy(a.matrix);this.matrixWorld.copy(a.matrixWorld);this.matrixAutoUpdate=a.matrixAutoUpdate;this.matrixWorldNeedsUpdate=a.matrixWorldNeedsUpdate;this.visible=a.visible;this.castShadow=a.castShadow;this.receiveShadow=a.receiveShadow;this.frustumCulled=a.frustumCulled;this.renderOrder=a.renderOrder;this.userData=JSON.parse(JSON.stringify(a.userData));if(!0===b)for(var d=0;d<a.children.length;d++)this.add(a.children[d].clone());return this}};
b.EventDispatcher.prototype.apply(b.Object3D.prototype);b.Object3DIdCount=0;b.Face3=function(a,c,d,e,f,g){this.a=a;this.b=c;this.c=d;this.normal=e instanceof b.Vector3?e:new b.Vector3;this.vertexNormals=Array.isArray(e)?e:[];this.color=f instanceof b.Color?f:new b.Color;this.vertexColors=Array.isArray(f)?f:[];this.materialIndex=void 0!==g?g:0};b.Face3.prototype={constructor:b.Face3,clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.a=a.a;this.b=a.b;this.c=a.c;this.normal.copy(a.normal);
this.color.copy(a.color);this.materialIndex=a.materialIndex;for(var b=0,d=a.vertexNormals.length;b<d;b++)this.vertexNormals[b]=a.vertexNormals[b].clone();b=0;for(d=a.vertexColors.length;b<d;b++)this.vertexColors[b]=a.vertexColors[b].clone();return this}};b.Layers=function(){this.mask=1};b.Layers.prototype={constructor:b.Layers,set:function(a){this.mask=1<<a},enable:function(a){this.mask|=1<<a},toggle:function(a){this.mask^=1<<a},disable:function(a){this.mask&=~(1<<a)},test:function(a){return 0!==
(this.mask&a.mask)}};b.BufferAttribute=function(a,c,d){this.uuid=b.Math.generateUUID();this.array=a;this.itemSize=c;this.dynamic=!1;this.updateRange={offset:0,count:-1};this.version=0;this.normalized=!0===d};b.BufferAttribute.prototype={constructor:b.BufferAttribute,get count(){return this.array.length/this.itemSize},set needsUpdate(a){!0===a&&this.version++},setDynamic:function(a){this.dynamic=a;return this},copy:function(a){this.array=new a.array.constructor(a.array);this.itemSize=a.itemSize;this.dynamic=
a.dynamic;return this},copyAt:function(a,b,d){a*=this.itemSize;d*=b.itemSize;for(var e=0,f=this.itemSize;e<f;e++)this.array[a+e]=b.array[d+e];return this},copyArray:function(a){this.array.set(a);return this},copyColorsArray:function(a){for(var c=this.array,d=0,e=0,f=a.length;e<f;e++){var g=a[e];void 0===g&&(console.warn("THREE.BufferAttribute.copyColorsArray(): color is undefined",e),g=new b.Color);c[d++]=g.r;c[d++]=g.g;c[d++]=g.b}return this},copyIndicesArray:function(a){for(var b=this.array,d=0,
e=0,f=a.length;e<f;e++){var g=a[e];b[d++]=g.a;b[d++]=g.b;b[d++]=g.c}return this},copyVector2sArray:function(a){for(var c=this.array,d=0,e=0,f=a.length;e<f;e++){var g=a[e];void 0===g&&(console.warn("THREE.BufferAttribute.copyVector2sArray(): vector is undefined",e),g=new b.Vector2);c[d++]=g.x;c[d++]=g.y}return this},copyVector3sArray:function(a){for(var c=this.array,d=0,e=0,f=a.length;e<f;e++){var g=a[e];void 0===g&&(console.warn("THREE.BufferAttribute.copyVector3sArray(): vector is undefined",e),
g=new b.Vector3);c[d++]=g.x;c[d++]=g.y;c[d++]=g.z}return this},copyVector4sArray:function(a){for(var c=this.array,d=0,e=0,f=a.length;e<f;e++){var g=a[e];void 0===g&&(console.warn("THREE.BufferAttribute.copyVector4sArray(): vector is undefined",e),g=new b.Vector4);c[d++]=g.x;c[d++]=g.y;c[d++]=g.z;c[d++]=g.w}return this},set:function(a,b){void 0===b&&(b=0);this.array.set(a,b);return this},getX:function(a){return this.array[a*this.itemSize]},setX:function(a,b){this.array[a*this.itemSize]=b;return this},
getY:function(a){return this.array[a*this.itemSize+1]},setY:function(a,b){this.array[a*this.itemSize+1]=b;return this},getZ:function(a){return this.array[a*this.itemSize+2]},setZ:function(a,b){this.array[a*this.itemSize+2]=b;return this},getW:function(a){return this.array[a*this.itemSize+3]},setW:function(a,b){this.array[a*this.itemSize+3]=b;return this},setXY:function(a,b,d){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=d;return this},setXYZ:function(a,b,d,e){a*=this.itemSize;this.array[a+0]=
b;this.array[a+1]=d;this.array[a+2]=e;return this},setXYZW:function(a,b,d,e,f){a*=this.itemSize;this.array[a+0]=b;this.array[a+1]=d;this.array[a+2]=e;this.array[a+3]=f;return this},clone:function(){return(new this.constructor).copy(this)}};b.Int8Attribute=function(a,c){return new b.BufferAttribute(new Int8Array(a),c)};b.Uint8Attribute=function(a,c){return new b.BufferAttribute(new Uint8Array(a),c)};b.Uint8ClampedAttribute=function(a,c){return new b.BufferAttribute(new Uint8ClampedArray(a),c)};b.Int16Attribute=
function(a,c){return new b.BufferAttribute(new Int16Array(a),c)};b.Uint16Attribute=function(a,c){return new b.BufferAttribute(new Uint16Array(a),c)};b.Int32Attribute=function(a,c){return new b.BufferAttribute(new Int32Array(a),c)};b.Uint32Attribute=function(a,c){return new b.BufferAttribute(new Uint32Array(a),c)};b.Float32Attribute=function(a,c){return new b.BufferAttribute(new Float32Array(a),c)};b.Float64Attribute=function(a,c){return new b.BufferAttribute(new Float64Array(a),c)};b.DynamicBufferAttribute=
function(a,c){console.warn("THREE.DynamicBufferAttribute has been removed. Use new THREE.BufferAttribute().setDynamic( true ) instead.");return(new b.BufferAttribute(a,c)).setDynamic(!0)};b.InstancedBufferAttribute=function(a,c,d){b.BufferAttribute.call(this,a,c);this.meshPerAttribute=d||1};b.InstancedBufferAttribute.prototype=Object.create(b.BufferAttribute.prototype);b.InstancedBufferAttribute.prototype.constructor=b.InstancedBufferAttribute;b.InstancedBufferAttribute.prototype.copy=function(a){b.BufferAttribute.prototype.copy.call(this,
a);this.meshPerAttribute=a.meshPerAttribute;return this};b.Geometry=function(){Object.defineProperty(this,"id",{value:b.GeometryIdCount++});this.uuid=b.Math.generateUUID();this.name="";this.type="Geometry";this.vertices=[];this.colors=[];this.faces=[];this.faceVertexUvs=[[]];this.morphTargets=[];this.morphNormals=[];this.skinWeights=[];this.skinIndices=[];this.lineDistances=[];this.boundingSphere=this.boundingBox=null;this.groupsNeedUpdate=this.lineDistancesNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=
this.uvsNeedUpdate=this.elementsNeedUpdate=this.verticesNeedUpdate=!1};b.Geometry.prototype={constructor:b.Geometry,applyMatrix:function(a){for(var c=(new b.Matrix3).getNormalMatrix(a),d=0,e=this.vertices.length;d<e;d++)this.vertices[d].applyMatrix4(a);d=0;for(e=this.faces.length;d<e;d++){a=this.faces[d];a.normal.applyMatrix3(c).normalize();for(var f=0,g=a.vertexNormals.length;f<g;f++)a.vertexNormals[f].applyMatrix3(c).normalize()}null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&
this.computeBoundingSphere();this.normalsNeedUpdate=this.verticesNeedUpdate=!0;return this},rotateX:function(){var a;return function(c){void 0===a&&(a=new b.Matrix4);a.makeRotationX(c);this.applyMatrix(a);return this}}(),rotateY:function(){var a;return function(c){void 0===a&&(a=new b.Matrix4);a.makeRotationY(c);this.applyMatrix(a);return this}}(),rotateZ:function(){var a;return function(c){void 0===a&&(a=new b.Matrix4);a.makeRotationZ(c);this.applyMatrix(a);return this}}(),translate:function(){var a;
return function(c,d,e){void 0===a&&(a=new b.Matrix4);a.makeTranslation(c,d,e);this.applyMatrix(a);return this}}(),scale:function(){var a;return function(c,d,e){void 0===a&&(a=new b.Matrix4);a.makeScale(c,d,e);this.applyMatrix(a);return this}}(),lookAt:function(){var a;return function(c){void 0===a&&(a=new b.Object3D);a.lookAt(c);a.updateMatrix();this.applyMatrix(a.matrix)}}(),fromBufferGeometry:function(a){function c(a,c,e,f){var g=void 0!==h?[t[a].clone(),t[c].clone(),t[e].clone()]:[],p=void 0!==
n?[d.colors[a].clone(),d.colors[c].clone(),d.colors[e].clone()]:[];f=new b.Face3(a,c,e,g,p,f);d.faces.push(f);void 0!==k&&d.faceVertexUvs[0].push([x[a].clone(),x[c].clone(),x[e].clone()]);void 0!==m&&d.faceVertexUvs[1].push([l[a].clone(),l[c].clone(),l[e].clone()])}var d=this,e=null!==a.index?a.index.array:void 0,f=a.attributes,g=f.position.array,h=void 0!==f.normal?f.normal.array:void 0,n=void 0!==f.color?f.color.array:void 0,k=void 0!==f.uv?f.uv.array:void 0,m=void 0!==f.uv2?f.uv2.array:void 0;
void 0!==m&&(this.faceVertexUvs[1]=[]);for(var t=[],x=[],l=[],p=f=0;f<g.length;f+=3,p+=2)d.vertices.push(new b.Vector3(g[f],g[f+1],g[f+2])),void 0!==h&&t.push(new b.Vector3(h[f],h[f+1],h[f+2])),void 0!==n&&d.colors.push(new b.Color(n[f],n[f+1],n[f+2])),void 0!==k&&x.push(new b.Vector2(k[p],k[p+1])),void 0!==m&&l.push(new b.Vector2(m[p],m[p+1]));if(void 0!==e)if(g=a.groups,0<g.length)for(f=0;f<g.length;f++)for(var q=g[f],s=q.start,w=q.count,p=s,s=s+w;p<s;p+=3)c(e[p],e[p+1],e[p+2],q.materialIndex);
else for(f=0;f<e.length;f+=3)c(e[f],e[f+1],e[f+2]);else for(f=0;f<g.length/3;f+=3)c(f,f+1,f+2);this.computeFaceNormals();null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());return this},center:function(){this.computeBoundingBox();var a=this.boundingBox.center().negate();this.translate(a.x,a.y,a.z);return a},normalize:function(){this.computeBoundingSphere();var a=this.boundingSphere.center,c=this.boundingSphere.radius,
c=0===c?1:1/c,d=new b.Matrix4;d.set(c,0,0,-c*a.x,0,c,0,-c*a.y,0,0,c,-c*a.z,0,0,0,1);this.applyMatrix(d);return this},computeFaceNormals:function(){for(var a=new b.Vector3,c=new b.Vector3,d=0,e=this.faces.length;d<e;d++){var f=this.faces[d],g=this.vertices[f.a],h=this.vertices[f.b];a.subVectors(this.vertices[f.c],h);c.subVectors(g,h);a.cross(c);a.normalize();f.normal.copy(a)}},computeVertexNormals:function(a){void 0===a&&(a=!0);var c,d,e;e=Array(this.vertices.length);c=0;for(d=this.vertices.length;c<
d;c++)e[c]=new b.Vector3;if(a){var f,g,h,n=new b.Vector3,k=new b.Vector3;a=0;for(c=this.faces.length;a<c;a++)d=this.faces[a],f=this.vertices[d.a],g=this.vertices[d.b],h=this.vertices[d.c],n.subVectors(h,g),k.subVectors(f,g),n.cross(k),e[d.a].add(n),e[d.b].add(n),e[d.c].add(n)}else for(a=0,c=this.faces.length;a<c;a++)d=this.faces[a],e[d.a].add(d.normal),e[d.b].add(d.normal),e[d.c].add(d.normal);c=0;for(d=this.vertices.length;c<d;c++)e[c].normalize();a=0;for(c=this.faces.length;a<c;a++)d=this.faces[a],
f=d.vertexNormals,3===f.length?(f[0].copy(e[d.a]),f[1].copy(e[d.b]),f[2].copy(e[d.c])):(f[0]=e[d.a].clone(),f[1]=e[d.b].clone(),f[2]=e[d.c].clone());0<this.faces.length&&(this.normalsNeedUpdate=!0)},computeMorphNormals:function(){var a,c,d,e,f;d=0;for(e=this.faces.length;d<e;d++)for(f=this.faces[d],f.__originalFaceNormal?f.__originalFaceNormal.copy(f.normal):f.__originalFaceNormal=f.normal.clone(),f.__originalVertexNormals||(f.__originalVertexNormals=[]),a=0,c=f.vertexNormals.length;a<c;a++)f.__originalVertexNormals[a]?
f.__originalVertexNormals[a].copy(f.vertexNormals[a]):f.__originalVertexNormals[a]=f.vertexNormals[a].clone();var g=new b.Geometry;g.faces=this.faces;a=0;for(c=this.morphTargets.length;a<c;a++){if(!this.morphNormals[a]){this.morphNormals[a]={};this.morphNormals[a].faceNormals=[];this.morphNormals[a].vertexNormals=[];f=this.morphNormals[a].faceNormals;var h=this.morphNormals[a].vertexNormals,n,k;d=0;for(e=this.faces.length;d<e;d++)n=new b.Vector3,k={a:new b.Vector3,b:new b.Vector3,c:new b.Vector3},
f.push(n),h.push(k)}h=this.morphNormals[a];g.vertices=this.morphTargets[a].vertices;g.computeFaceNormals();g.computeVertexNormals();d=0;for(e=this.faces.length;d<e;d++)f=this.faces[d],n=h.faceNormals[d],k=h.vertexNormals[d],n.copy(f.normal),k.a.copy(f.vertexNormals[0]),k.b.copy(f.vertexNormals[1]),k.c.copy(f.vertexNormals[2])}d=0;for(e=this.faces.length;d<e;d++)f=this.faces[d],f.normal=f.__originalFaceNormal,f.vertexNormals=f.__originalVertexNormals},computeTangents:function(){console.warn("THREE.Geometry: .computeTangents() has been removed.")},
computeLineDistances:function(){for(var a=0,b=this.vertices,d=0,e=b.length;d<e;d++)0<d&&(a+=b[d].distanceTo(b[d-1])),this.lineDistances[d]=a},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new b.Box3);this.boundingBox.setFromPoints(this.vertices)},computeBoundingSphere:function(){null===this.boundingSphere&&(this.boundingSphere=new b.Sphere);this.boundingSphere.setFromPoints(this.vertices)},merge:function(a,c,d){if(!1===a instanceof b.Geometry)console.error("THREE.Geometry.merge(): geometry not an instance of THREE.Geometry.",
a);else{var e,f=this.vertices.length,g=this.vertices,h=a.vertices,n=this.faces,k=a.faces,m=this.faceVertexUvs[0];a=a.faceVertexUvs[0];void 0===d&&(d=0);void 0!==c&&(e=(new b.Matrix3).getNormalMatrix(c));for(var t=0,x=h.length;t<x;t++){var l=h[t].clone();void 0!==c&&l.applyMatrix4(c);g.push(l)}t=0;for(x=k.length;t<x;t++){var h=k[t],p,q=h.vertexNormals,s=h.vertexColors,l=new b.Face3(h.a+f,h.b+f,h.c+f);l.normal.copy(h.normal);void 0!==e&&l.normal.applyMatrix3(e).normalize();c=0;for(g=q.length;c<g;c++)p=
q[c].clone(),void 0!==e&&p.applyMatrix3(e).normalize(),l.vertexNormals.push(p);l.color.copy(h.color);c=0;for(g=s.length;c<g;c++)p=s[c],l.vertexColors.push(p.clone());l.materialIndex=h.materialIndex+d;n.push(l)}t=0;for(x=a.length;t<x;t++)if(d=a[t],e=[],void 0!==d){c=0;for(g=d.length;c<g;c++)e.push(d[c].clone());m.push(e)}}},mergeMesh:function(a){!1===a instanceof b.Mesh?console.error("THREE.Geometry.mergeMesh(): mesh not an instance of THREE.Mesh.",a):(a.matrixAutoUpdate&&a.updateMatrix(),this.merge(a.geometry,
a.matrix))},mergeVertices:function(){var a={},b=[],d=[],e,f=Math.pow(10,4),g,h;g=0;for(h=this.vertices.length;g<h;g++)e=this.vertices[g],e=Math.round(e.x*f)+"_"+Math.round(e.y*f)+"_"+Math.round(e.z*f),void 0===a[e]?(a[e]=g,b.push(this.vertices[g]),d[g]=b.length-1):d[g]=d[a[e]];a=[];g=0;for(h=this.faces.length;g<h;g++)for(f=this.faces[g],f.a=d[f.a],f.b=d[f.b],f.c=d[f.c],f=[f.a,f.b,f.c],e=0;3>e;e++)if(f[e]===f[(e+1)%3]){a.push(g);break}for(g=a.length-1;0<=g;g--)for(f=a[g],this.faces.splice(f,1),d=0,
h=this.faceVertexUvs.length;d<h;d++)this.faceVertexUvs[d].splice(f,1);g=this.vertices.length-b.length;this.vertices=b;return g},sortFacesByMaterialIndex:function(){for(var a=this.faces,b=a.length,d=0;d<b;d++)a[d]._id=d;a.sort(function(a,b){return a.materialIndex-b.materialIndex});var e=this.faceVertexUvs[0],f=this.faceVertexUvs[1],g,h;e&&e.length===b&&(g=[]);f&&f.length===b&&(h=[]);for(d=0;d<b;d++){var n=a[d]._id;g&&g.push(e[n]);h&&h.push(f[n])}g&&(this.faceVertexUvs[0]=g);h&&(this.faceVertexUvs[1]=
h)},toJSON:function(){function a(a,b,c){return c?a|1<<b:a&~(1<<b)}function b(a){var c=a.x.toString()+a.y.toString()+a.z.toString();if(void 0!==m[c])return m[c];m[c]=k.length/3;k.push(a.x,a.y,a.z);return m[c]}function d(a){var b=a.r.toString()+a.g.toString()+a.b.toString();if(void 0!==x[b])return x[b];x[b]=t.length;t.push(a.getHex());return x[b]}function e(a){var b=a.x.toString()+a.y.toString();if(void 0!==p[b])return p[b];p[b]=l.length/2;l.push(a.x,a.y);return p[b]}var f={metadata:{version:4.4,type:"Geometry",
generator:"Geometry.toJSON"}};f.uuid=this.uuid;f.type=this.type;""!==this.name&&(f.name=this.name);if(void 0!==this.parameters){var g=this.parameters,h;for(h in g)void 0!==g[h]&&(f[h]=g[h]);return f}g=[];for(h=0;h<this.vertices.length;h++){var n=this.vertices[h];g.push(n.x,n.y,n.z)}var n=[],k=[],m={},t=[],x={},l=[],p={};for(h=0;h<this.faces.length;h++){var q=this.faces[h],s=void 0!==this.faceVertexUvs[0][h],w=0<q.normal.length(),y=0<q.vertexNormals.length,B=1!==q.color.r||1!==q.color.g||1!==q.color.b,
z=0<q.vertexColors.length,A=0,A=a(A,0,0),A=a(A,1,!0),A=a(A,2,!1),A=a(A,3,s),A=a(A,4,w),A=a(A,5,y),A=a(A,6,B),A=a(A,7,z);n.push(A);n.push(q.a,q.b,q.c);n.push(q.materialIndex);s&&(s=this.faceVertexUvs[0][h],n.push(e(s[0]),e(s[1]),e(s[2])));w&&n.push(b(q.normal));y&&(w=q.vertexNormals,n.push(b(w[0]),b(w[1]),b(w[2])));B&&n.push(d(q.color));z&&(q=q.vertexColors,n.push(d(q[0]),d(q[1]),d(q[2])))}f.data={};f.data.vertices=g;f.data.normals=k;0<t.length&&(f.data.colors=t);0<l.length&&(f.data.uvs=[l]);f.data.faces=
n;return f},clone:function(){return(new b.Geometry).copy(this)},copy:function(a){this.vertices=[];this.faces=[];this.faceVertexUvs=[[]];for(var b=a.vertices,d=0,e=b.length;d<e;d++)this.vertices.push(b[d].clone());b=a.faces;d=0;for(e=b.length;d<e;d++)this.faces.push(b[d].clone());d=0;for(e=a.faceVertexUvs.length;d<e;d++){b=a.faceVertexUvs[d];void 0===this.faceVertexUvs[d]&&(this.faceVertexUvs[d]=[]);for(var f=0,g=b.length;f<g;f++){for(var h=b[f],n=[],k=0,m=h.length;k<m;k++)n.push(h[k].clone());this.faceVertexUvs[d].push(n)}}return this},
dispose:function(){this.dispatchEvent({type:"dispose"})}};b.EventDispatcher.prototype.apply(b.Geometry.prototype);b.GeometryIdCount=0;b.DirectGeometry=function(){Object.defineProperty(this,"id",{value:b.GeometryIdCount++});this.uuid=b.Math.generateUUID();this.name="";this.type="DirectGeometry";this.indices=[];this.vertices=[];this.normals=[];this.colors=[];this.uvs=[];this.uvs2=[];this.groups=[];this.morphTargets={};this.skinWeights=[];this.skinIndices=[];this.boundingSphere=this.boundingBox=null;
this.groupsNeedUpdate=this.uvsNeedUpdate=this.colorsNeedUpdate=this.normalsNeedUpdate=this.verticesNeedUpdate=!1};b.DirectGeometry.prototype={constructor:b.DirectGeometry,computeBoundingBox:b.Geometry.prototype.computeBoundingBox,computeBoundingSphere:b.Geometry.prototype.computeBoundingSphere,computeFaceNormals:function(){console.warn("THREE.DirectGeometry: computeFaceNormals() is not a method of this type of geometry.")},computeVertexNormals:function(){console.warn("THREE.DirectGeometry: computeVertexNormals() is not a method of this type of geometry.")},
computeGroups:function(a){var b,d=[],e;a=a.faces;for(var f=0;f<a.length;f++){var g=a[f];g.materialIndex!==e&&(e=g.materialIndex,void 0!==b&&(b.count=3*f-b.start,d.push(b)),b={start:3*f,materialIndex:e})}void 0!==b&&(b.count=3*f-b.start,d.push(b));this.groups=d},fromGeometry:function(a){var c=a.faces,d=a.vertices,e=a.faceVertexUvs,f=e[0]&&0<e[0].length,g=e[1]&&0<e[1].length,h=a.morphTargets,n=h.length,k;if(0<n){k=[];for(var m=0;m<n;m++)k[m]=[];this.morphTargets.position=k}var t=a.morphNormals,x=t.length,
l;if(0<x){l=[];for(m=0;m<x;m++)l[m]=[];this.morphTargets.normal=l}for(var p=a.skinIndices,q=a.skinWeights,s=p.length===d.length,w=q.length===d.length,m=0;m<c.length;m++){var y=c[m];this.vertices.push(d[y.a],d[y.b],d[y.c]);var B=y.vertexNormals;3===B.length?this.normals.push(B[0],B[1],B[2]):(B=y.normal,this.normals.push(B,B,B));B=y.vertexColors;3===B.length?this.colors.push(B[0],B[1],B[2]):(B=y.color,this.colors.push(B,B,B));!0===f&&(B=e[0][m],void 0!==B?this.uvs.push(B[0],B[1],B[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv ",
m),this.uvs.push(new b.Vector2,new b.Vector2,new b.Vector2)));!0===g&&(B=e[1][m],void 0!==B?this.uvs2.push(B[0],B[1],B[2]):(console.warn("THREE.DirectGeometry.fromGeometry(): Undefined vertexUv2 ",m),this.uvs2.push(new b.Vector2,new b.Vector2,new b.Vector2)));for(B=0;B<n;B++){var z=h[B].vertices;k[B].push(z[y.a],z[y.b],z[y.c])}for(B=0;B<x;B++)z=t[B].vertexNormals[m],l[B].push(z.a,z.b,z.c);s&&this.skinIndices.push(p[y.a],p[y.b],p[y.c]);w&&this.skinWeights.push(q[y.a],q[y.b],q[y.c])}this.computeGroups(a);
this.verticesNeedUpdate=a.verticesNeedUpdate;this.normalsNeedUpdate=a.normalsNeedUpdate;this.colorsNeedUpdate=a.colorsNeedUpdate;this.uvsNeedUpdate=a.uvsNeedUpdate;this.groupsNeedUpdate=a.groupsNeedUpdate;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};b.EventDispatcher.prototype.apply(b.DirectGeometry.prototype);b.BufferGeometry=function(){Object.defineProperty(this,"id",{value:b.GeometryIdCount++});this.uuid=b.Math.generateUUID();this.name="";this.type="BufferGeometry";this.index=
null;this.attributes={};this.morphAttributes={};this.groups=[];this.boundingSphere=this.boundingBox=null;this.drawRange={start:0,count:Infinity}};b.BufferGeometry.prototype={constructor:b.BufferGeometry,getIndex:function(){return this.index},setIndex:function(a){this.index=a},addAttribute:function(a,c,d){if(!1===c instanceof b.BufferAttribute&&!1===c instanceof b.InterleavedBufferAttribute)console.warn("THREE.BufferGeometry: .addAttribute() now expects ( name, attribute )."),this.addAttribute(a,new b.BufferAttribute(c,
d));else if("index"===a)console.warn("THREE.BufferGeometry.addAttribute: Use .setIndex() for index attribute."),this.setIndex(c);else return this.attributes[a]=c,this},getAttribute:function(a){return this.attributes[a]},removeAttribute:function(a){delete this.attributes[a];return this},addGroup:function(a,b,d){this.groups.push({start:a,count:b,materialIndex:void 0!==d?d:0})},clearGroups:function(){this.groups=[]},setDrawRange:function(a,b){this.drawRange.start=a;this.drawRange.count=b},applyMatrix:function(a){var c=
this.attributes.position;void 0!==c&&(a.applyToVector3Array(c.array),c.needsUpdate=!0);c=this.attributes.normal;void 0!==c&&((new b.Matrix3).getNormalMatrix(a).applyToVector3Array(c.array),c.needsUpdate=!0);null!==this.boundingBox&&this.computeBoundingBox();null!==this.boundingSphere&&this.computeBoundingSphere();return this},rotateX:function(){var a;return function(c){void 0===a&&(a=new b.Matrix4);a.makeRotationX(c);this.applyMatrix(a);return this}}(),rotateY:function(){var a;return function(c){void 0===
a&&(a=new b.Matrix4);a.makeRotationY(c);this.applyMatrix(a);return this}}(),rotateZ:function(){var a;return function(c){void 0===a&&(a=new b.Matrix4);a.makeRotationZ(c);this.applyMatrix(a);return this}}(),translate:function(){var a;return function(c,d,e){void 0===a&&(a=new b.Matrix4);a.makeTranslation(c,d,e);this.applyMatrix(a);return this}}(),scale:function(){var a;return function(c,d,e){void 0===a&&(a=new b.Matrix4);a.makeScale(c,d,e);this.applyMatrix(a);return this}}(),lookAt:function(){var a;
return function(c){void 0===a&&(a=new b.Object3D);a.lookAt(c);a.updateMatrix();this.applyMatrix(a.matrix)}}(),center:function(){this.computeBoundingBox();var a=this.boundingBox.center().negate();this.translate(a.x,a.y,a.z);return a},setFromObject:function(a){var c=a.geometry;if(a instanceof b.Points||a instanceof b.Line){a=new b.Float32Attribute(3*c.vertices.length,3);var d=new b.Float32Attribute(3*c.colors.length,3);this.addAttribute("position",a.copyVector3sArray(c.vertices));this.addAttribute("color",
d.copyColorsArray(c.colors));c.lineDistances&&c.lineDistances.length===c.vertices.length&&(a=new b.Float32Attribute(c.lineDistances.length,1),this.addAttribute("lineDistance",a.copyArray(c.lineDistances)));null!==c.boundingSphere&&(this.boundingSphere=c.boundingSphere.clone());null!==c.boundingBox&&(this.boundingBox=c.boundingBox.clone())}else a instanceof b.Mesh&&c instanceof b.Geometry&&this.fromGeometry(c);return this},updateFromObject:function(a){var c=a.geometry;if(a instanceof b.Mesh){var d=
c.__directGeometry;if(void 0===d)return this.fromGeometry(c);d.verticesNeedUpdate=c.verticesNeedUpdate;d.normalsNeedUpdate=c.normalsNeedUpdate;d.colorsNeedUpdate=c.colorsNeedUpdate;d.uvsNeedUpdate=c.uvsNeedUpdate;d.groupsNeedUpdate=c.groupsNeedUpdate;c.verticesNeedUpdate=!1;c.normalsNeedUpdate=!1;c.colorsNeedUpdate=!1;c.uvsNeedUpdate=!1;c.groupsNeedUpdate=!1;c=d}!0===c.verticesNeedUpdate&&(d=this.attributes.position,void 0!==d&&(d.copyVector3sArray(c.vertices),d.needsUpdate=!0),c.verticesNeedUpdate=
!1);!0===c.normalsNeedUpdate&&(d=this.attributes.normal,void 0!==d&&(d.copyVector3sArray(c.normals),d.needsUpdate=!0),c.normalsNeedUpdate=!1);!0===c.colorsNeedUpdate&&(d=this.attributes.color,void 0!==d&&(d.copyColorsArray(c.colors),d.needsUpdate=!0),c.colorsNeedUpdate=!1);c.uvsNeedUpdate&&(d=this.attributes.uv,void 0!==d&&(d.copyVector2sArray(c.uvs),d.needsUpdate=!0),c.uvsNeedUpdate=!1);c.lineDistancesNeedUpdate&&(d=this.attributes.lineDistance,void 0!==d&&(d.copyArray(c.lineDistances),d.needsUpdate=
!0),c.lineDistancesNeedUpdate=!1);c.groupsNeedUpdate&&(c.computeGroups(a.geometry),this.groups=c.groups,c.groupsNeedUpdate=!1);return this},fromGeometry:function(a){a.__directGeometry=(new b.DirectGeometry).fromGeometry(a);return this.fromDirectGeometry(a.__directGeometry)},fromDirectGeometry:function(a){var c=new Float32Array(3*a.vertices.length);this.addAttribute("position",(new b.BufferAttribute(c,3)).copyVector3sArray(a.vertices));0<a.normals.length&&(c=new Float32Array(3*a.normals.length),this.addAttribute("normal",
(new b.BufferAttribute(c,3)).copyVector3sArray(a.normals)));0<a.colors.length&&(c=new Float32Array(3*a.colors.length),this.addAttribute("color",(new b.BufferAttribute(c,3)).copyColorsArray(a.colors)));0<a.uvs.length&&(c=new Float32Array(2*a.uvs.length),this.addAttribute("uv",(new b.BufferAttribute(c,2)).copyVector2sArray(a.uvs)));0<a.uvs2.length&&(c=new Float32Array(2*a.uvs2.length),this.addAttribute("uv2",(new b.BufferAttribute(c,2)).copyVector2sArray(a.uvs2)));0<a.indices.length&&(c=new (65535<
a.vertices.length?Uint32Array:Uint16Array)(3*a.indices.length),this.setIndex((new b.BufferAttribute(c,1)).copyIndicesArray(a.indices)));this.groups=a.groups;for(var d in a.morphTargets){for(var c=[],e=a.morphTargets[d],f=0,g=e.length;f<g;f++){var h=e[f],n=new b.Float32Attribute(3*h.length,3);c.push(n.copyVector3sArray(h))}this.morphAttributes[d]=c}0<a.skinIndices.length&&(d=new b.Float32Attribute(4*a.skinIndices.length,4),this.addAttribute("skinIndex",d.copyVector4sArray(a.skinIndices)));0<a.skinWeights.length&&
(d=new b.Float32Attribute(4*a.skinWeights.length,4),this.addAttribute("skinWeight",d.copyVector4sArray(a.skinWeights)));null!==a.boundingSphere&&(this.boundingSphere=a.boundingSphere.clone());null!==a.boundingBox&&(this.boundingBox=a.boundingBox.clone());return this},computeBoundingBox:function(){null===this.boundingBox&&(this.boundingBox=new b.Box3);var a=this.attributes.position.array;void 0!==a?this.boundingBox.setFromArray(a):this.boundingBox.makeEmpty();(isNaN(this.boundingBox.min.x)||isNaN(this.boundingBox.min.y)||
isNaN(this.boundingBox.min.z))&&console.error('THREE.BufferGeometry.computeBoundingBox: Computed min/max have NaN values. The "position" attribute is likely to have NaN values.',this)},computeBoundingSphere:function(){var a=new b.Box3,c=new b.Vector3;return function(){null===this.boundingSphere&&(this.boundingSphere=new b.Sphere);var d=this.attributes.position.array;if(d){var e=this.boundingSphere.center;a.setFromArray(d);a.center(e);for(var f=0,g=0,h=d.length;g<h;g+=3)c.fromArray(d,g),f=Math.max(f,
e.distanceToSquared(c));this.boundingSphere.radius=Math.sqrt(f);isNaN(this.boundingSphere.radius)&&console.error('THREE.BufferGeometry.computeBoundingSphere(): Computed radius is NaN. The "position" attribute is likely to have NaN values.',this)}}}(),computeFaceNormals:function(){},computeVertexNormals:function(){var a=this.index,c=this.attributes,d=this.groups;if(c.position){var e=c.position.array;if(void 0===c.normal)this.addAttribute("normal",new b.BufferAttribute(new Float32Array(e.length),3));
else for(var f=c.normal.array,g=0,h=f.length;g<h;g++)f[g]=0;var f=c.normal.array,n,k,m,t=new b.Vector3,x=new b.Vector3,l=new b.Vector3,p=new b.Vector3,q=new b.Vector3;if(a){a=a.array;0===d.length&&this.addGroup(0,a.length);for(var s=0,w=d.length;s<w;++s)for(g=d[s],h=g.start,n=g.count,g=h,h+=n;g<h;g+=3)n=3*a[g+0],k=3*a[g+1],m=3*a[g+2],t.fromArray(e,n),x.fromArray(e,k),l.fromArray(e,m),p.subVectors(l,x),q.subVectors(t,x),p.cross(q),f[n]+=p.x,f[n+1]+=p.y,f[n+2]+=p.z,f[k]+=p.x,f[k+1]+=p.y,f[k+2]+=p.z,
f[m]+=p.x,f[m+1]+=p.y,f[m+2]+=p.z}else for(g=0,h=e.length;g<h;g+=9)t.fromArray(e,g),x.fromArray(e,g+3),l.fromArray(e,g+6),p.subVectors(l,x),q.subVectors(t,x),p.cross(q),f[g]=p.x,f[g+1]=p.y,f[g+2]=p.z,f[g+3]=p.x,f[g+4]=p.y,f[g+5]=p.z,f[g+6]=p.x,f[g+7]=p.y,f[g+8]=p.z;this.normalizeNormals();c.normal.needsUpdate=!0}},merge:function(a,c){if(!1===a instanceof b.BufferGeometry)console.error("THREE.BufferGeometry.merge(): geometry not an instance of THREE.BufferGeometry.",a);else{void 0===c&&(c=0);var d=
this.attributes,e;for(e in d)if(void 0!==a.attributes[e])for(var f=d[e].array,g=a.attributes[e],h=g.array,n=0,g=g.itemSize*c;n<h.length;n++,g++)f[g]=h[n];return this}},normalizeNormals:function(){for(var a=this.attributes.normal.array,b,d,e,f=0,g=a.length;f<g;f+=3)b=a[f],d=a[f+1],e=a[f+2],b=1/Math.sqrt(b*b+d*d+e*e),a[f]*=b,a[f+1]*=b,a[f+2]*=b},toNonIndexed:function(){if(null===this.index)return console.warn("THREE.BufferGeometry.toNonIndexed(): Geometry is already non-indexed."),this;var a=new b.BufferGeometry,
c=this.index.array,d=this.attributes,e;for(e in d){for(var f=d[e],g=f.array,f=f.itemSize,h=new g.constructor(c.length*f),n=0,k=0,m=0,t=c.length;m<t;m++)for(var n=c[m]*f,x=0;x<f;x++)h[k++]=g[n++];a.addAttribute(e,new b.BufferAttribute(h,f))}return a},toJSON:function(){var a={metadata:{version:4.4,type:"BufferGeometry",generator:"BufferGeometry.toJSON"}};a.uuid=this.uuid;a.type=this.type;""!==this.name&&(a.name=this.name);if(void 0!==this.parameters){var b=this.parameters,d;for(d in b)void 0!==b[d]&&
(a[d]=b[d]);return a}a.data={attributes:{}};var e=this.index;null!==e&&(b=Array.prototype.slice.call(e.array),a.data.index={type:e.array.constructor.name,array:b});e=this.attributes;for(d in e){var f=e[d],b=Array.prototype.slice.call(f.array);a.data.attributes[d]={itemSize:f.itemSize,type:f.array.constructor.name,array:b,normalized:f.normalized}}d=this.groups;0<d.length&&(a.data.groups=JSON.parse(JSON.stringify(d)));d=this.boundingSphere;null!==d&&(a.data.boundingSphere={center:d.center.toArray(),
radius:d.radius});return a},clone:function(){return(new b.BufferGeometry).copy(this)},copy:function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,d;for(d in b)this.addAttribute(d,b[d].clone());a=a.groups;d=0;for(b=a.length;d<b;d++){var e=a[d];this.addGroup(e.start,e.count,e.materialIndex)}return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};b.EventDispatcher.prototype.apply(b.BufferGeometry.prototype);b.BufferGeometry.MaxIndex=65535;b.InstancedBufferGeometry=
function(){b.BufferGeometry.call(this);this.type="InstancedBufferGeometry";this.maxInstancedCount=void 0};b.InstancedBufferGeometry.prototype=Object.create(b.BufferGeometry.prototype);b.InstancedBufferGeometry.prototype.constructor=b.InstancedBufferGeometry;b.InstancedBufferGeometry.prototype.addGroup=function(a,b,d){this.groups.push({start:a,count:b,instances:d})};b.InstancedBufferGeometry.prototype.copy=function(a){var b=a.index;null!==b&&this.setIndex(b.clone());var b=a.attributes,d;for(d in b)this.addAttribute(d,
b[d].clone());a=a.groups;d=0;for(b=a.length;d<b;d++){var e=a[d];this.addGroup(e.start,e.count,e.instances)}return this};b.EventDispatcher.prototype.apply(b.InstancedBufferGeometry.prototype);b.InterleavedBufferAttribute=function(a,c,d){this.uuid=b.Math.generateUUID();this.data=a;this.itemSize=c;this.offset=d};b.InterleavedBufferAttribute.prototype={constructor:b.InterleavedBufferAttribute,get length(){console.warn("THREE.BufferAttribute: .length has been deprecated. Please use .count.");return this.array.length},
get count(){return this.data.count},setX:function(a,b){this.data.array[a*this.data.stride+this.offset]=b;return this},setY:function(a,b){this.data.array[a*this.data.stride+this.offset+1]=b;return this},setZ:function(a,b){this.data.array[a*this.data.stride+this.offset+2]=b;return this},setW:function(a,b){this.data.array[a*this.data.stride+this.offset+3]=b;return this},getX:function(a){return this.data.array[a*this.data.stride+this.offset]},getY:function(a){return this.data.array[a*this.data.stride+
this.offset+1]},getZ:function(a){return this.data.array[a*this.data.stride+this.offset+2]},getW:function(a){return this.data.array[a*this.data.stride+this.offset+3]},setXY:function(a,b,d){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=d;return this},setXYZ:function(a,b,d,e){a=a*this.data.stride+this.offset;this.data.array[a+0]=b;this.data.array[a+1]=d;this.data.array[a+2]=e;return this},setXYZW:function(a,b,d,e,f){a=a*this.data.stride+this.offset;this.data.array[a+0]=
b;this.data.array[a+1]=d;this.data.array[a+2]=e;this.data.array[a+3]=f;return this}};b.Camera=function(){b.Object3D.call(this);this.type="Camera";this.matrixWorldInverse=new b.Matrix4;this.projectionMatrix=new b.Matrix4};b.Camera.prototype=Object.create(b.Object3D.prototype);b.Camera.prototype.constructor=b.Camera;b.Camera.prototype.getWorldDirection=function(){var a=new b.Quaternion;return function(c){c=c||new b.Vector3;this.getWorldQuaternion(a);return c.set(0,0,-1).applyQuaternion(a)}}();b.Camera.prototype.lookAt=
function(){var a=new b.Matrix4;return function(b){a.lookAt(this.position,b,this.up);this.quaternion.setFromRotationMatrix(a)}}();b.Camera.prototype.clone=function(){return(new this.constructor).copy(this)};b.Camera.prototype.copy=function(a){b.Object3D.prototype.copy.call(this,a);this.matrixWorldInverse.copy(a.matrixWorldInverse);this.projectionMatrix.copy(a.projectionMatrix);return this};b.PerspectiveCamera=function(a,c,d,e){b.Camera.call(this);this.type="PerspectiveCamera";this.fov=void 0!==a?a:
50;this.zoom=1;this.near=void 0!==d?d:.1;this.far=void 0!==e?e:2E3;this.focus=10;this.aspect=void 0!==c?c:1;this.view=null;this.filmGauge=35;this.filmOffset=0;this.updateProjectionMatrix()};b.PerspectiveCamera.prototype=Object.create(b.Camera.prototype);b.PerspectiveCamera.prototype.constructor=b.PerspectiveCamera;b.PerspectiveCamera.prototype.setLens=function(a,b){console.warn("THREE.PerspectiveCamera.setLens is deprecated. Use .setFocalLength and .filmGauge for a photographic setup.");void 0!==
b&&(this.filmGauge=b);this.setFocalLength(a)};b.PerspectiveCamera.prototype.setFocalLength=function(a){a=.5*this.getFilmHeight()/a;this.fov=2*b.Math.RAD2DEG*Math.atan(a);this.updateProjectionMatrix()};b.PerspectiveCamera.prototype.getFocalLength=function(){var a=Math.tan(.5*b.Math.DEG2RAD*this.fov);return.5*this.getFilmHeight()/a};b.PerspectiveCamera.prototype.getEffectiveFOV=function(){return 2*b.Math.RAD2DEG*Math.atan(Math.tan(.5*b.Math.DEG2RAD*this.fov)/this.zoom)};b.PerspectiveCamera.prototype.getFilmWidth=
function(){return this.filmGauge*Math.min(this.aspect,1)};b.PerspectiveCamera.prototype.getFilmHeight=function(){return this.filmGauge/Math.max(this.aspect,1)};b.PerspectiveCamera.prototype.setViewOffset=function(a,b,d,e,f,g){this.aspect=a/b;this.view={fullWidth:a,fullHeight:b,offsetX:d,offsetY:e,width:f,height:g};this.updateProjectionMatrix()};b.PerspectiveCamera.prototype.updateProjectionMatrix=function(){var a=this.near,c=a*Math.tan(.5*b.Math.DEG2RAD*this.fov)/this.zoom,d=2*c,e=this.aspect*d,f=
-.5*e,g=this.view;if(null!==g)var h=g.fullWidth,n=g.fullHeight,f=f+g.offsetX*e/h,c=c-g.offsetY*d/n,e=g.width/h*e,d=g.height/n*d;g=this.filmOffset;0!==g&&(f+=a*g/this.getFilmWidth());this.projectionMatrix.makeFrustum(f,f+e,c-d,c,a,this.far)};b.PerspectiveCamera.prototype.copy=function(a){b.Camera.prototype.copy.call(this,a);this.fov=a.fov;this.zoom=a.zoom;this.near=a.near;this.far=a.far;this.focus=a.focus;this.aspect=a.aspect;this.view=null===a.view?null:Object.assign({},a.view);this.filmGauge=a.filmGauge;
this.filmOffset=a.filmOffset;return this};b.PerspectiveCamera.prototype.toJSON=function(a){a=b.Object3D.prototype.toJSON.call(this,a);a.object.fov=this.fov;a.object.zoom=this.zoom;a.object.near=this.near;a.object.far=this.far;a.object.focus=this.focus;a.object.aspect=this.aspect;null!==this.view&&(a.object.view=Object.assign({},this.view));a.object.filmGauge=this.filmGauge;a.object.filmOffset=this.filmOffset;return a};b.Light=function(a,c){b.Object3D.call(this);this.type="Light";this.color=new b.Color(a);
this.intensity=void 0!==c?c:1;this.receiveShadow=void 0};b.Light.prototype=Object.create(b.Object3D.prototype);b.Light.prototype.constructor=b.Light;b.Light.prototype.copy=function(a){b.Object3D.prototype.copy.call(this,a);this.color.copy(a.color);this.intensity=a.intensity;return this};b.Light.prototype.toJSON=function(a){a=b.Object3D.prototype.toJSON.call(this,a);a.object.color=this.color.getHex();a.object.intensity=this.intensity;void 0!==this.groundColor&&(a.object.groundColor=this.groundColor.getHex());
void 0!==this.distance&&(a.object.distance=this.distance);void 0!==this.angle&&(a.object.angle=this.angle);void 0!==this.decay&&(a.object.decay=this.decay);void 0!==this.penumbra&&(a.object.penumbra=this.penumbra);return a};b.AmbientLight=function(a,c){b.Light.call(this,a,c);this.type="AmbientLight";this.castShadow=void 0};b.AmbientLight.prototype=Object.create(b.Light.prototype);b.AmbientLight.prototype.constructor=b.AmbientLight;b.PointLight=function(a,c,d,e){b.Light.call(this,a,c);this.type="PointLight";
this.distance=void 0!==d?d:0;this.decay=void 0!==e?e:1;this.shadow=new b.LightShadow(new b.PerspectiveCamera(90,1,.5,500))};b.PointLight.prototype=Object.create(b.Light.prototype);b.PointLight.prototype.constructor=b.PointLight;Object.defineProperty(b.PointLight.prototype,"power",{get:function(){return 4*this.intensity*Math.PI},set:function(a){this.intensity=a/(4*Math.PI)}});b.PointLight.prototype.copy=function(a){b.Light.prototype.copy.call(this,a);this.distance=a.distance;this.decay=a.decay;this.shadow=
a.shadow.clone();return this};b.DirectionalLight=function(a,c){b.Light.call(this,a,c);this.type="DirectionalLight";this.position.set(0,1,0);this.updateMatrix();this.target=new b.Object3D;this.shadow=new b.DirectionalLightShadow};b.DirectionalLight.prototype=Object.create(b.Light.prototype);b.DirectionalLight.prototype.constructor=b.DirectionalLight;b.DirectionalLight.prototype.copy=function(a){b.Light.prototype.copy.call(this,a);this.target=a.target.clone();this.shadow=a.shadow.clone();return this};
b.LightShadow=function(a){this.camera=a;this.bias=0;this.radius=1;this.mapSize=new b.Vector2(512,512);this.map=null;this.matrix=new b.Matrix4};b.LightShadow.prototype={constructor:b.LightShadow,copy:function(a){this.camera=a.camera.clone();this.bias=a.bias;this.radius=a.radius;this.mapSize.copy(a.mapSize);return this},clone:function(){return(new this.constructor).copy(this)}};b.SpotLight=function(a,c,d,e,f,g){b.Light.call(this,a,c);this.type="SpotLight";this.position.set(0,1,0);this.updateMatrix();
this.target=new b.Object3D;this.distance=void 0!==d?d:0;this.angle=void 0!==e?e:Math.PI/3;this.penumbra=void 0!==f?f:0;this.decay=void 0!==g?g:1;this.shadow=new b.SpotLightShadow};b.SpotLight.prototype=Object.create(b.Light.prototype);b.SpotLight.prototype.constructor=b.SpotLight;Object.defineProperty(b.SpotLight.prototype,"power",{get:function(){return this.intensity*Math.PI},set:function(a){this.intensity=a/Math.PI}});b.SpotLight.prototype.copy=function(a){b.Light.prototype.copy.call(this,a);this.distance=
a.distance;this.angle=a.angle;this.penumbra=a.penumbra;this.decay=a.decay;this.target=a.target.clone();this.shadow=a.shadow.clone();return this};b.Material=function(){Object.defineProperty(this,"id",{value:b.MaterialIdCount++});this.uuid=b.Math.generateUUID();this.name="";this.type="Material";this.side=b.FrontSide;this.opacity=1;this.transparent=!1;this.blending=b.NormalBlending;this.blendSrc=b.SrcAlphaFactor;this.blendDst=b.OneMinusSrcAlphaFactor;this.blendEquation=b.AddEquation;this.blendEquationAlpha=
this.blendDstAlpha=this.blendSrcAlpha=null;this.depthFunc=b.LessEqualDepth;this.depthWrite=this.depthTest=!0;this.clippingPlanes=null;this.clipShadows=!1;this.colorWrite=!0;this.precision=null;this.polygonOffset=!1;this.alphaTest=this.polygonOffsetUnits=this.polygonOffsetFactor=0;this.premultipliedAlpha=!1;this.overdraw=0;this._needsUpdate=this.visible=!0};b.Material.prototype={constructor:b.Material,get needsUpdate(){return this._needsUpdate},set needsUpdate(a){!0===a&&this.update();this._needsUpdate=
a},setValues:function(a){if(void 0!==a)for(var c in a){var d=a[c];if(void 0===d)console.warn("THREE.Material: '"+c+"' parameter is undefined.");else{var e=this[c];void 0===e?console.warn("THREE."+this.type+": '"+c+"' is not a property of this material."):e instanceof b.Color?e.set(d):e instanceof b.Vector3&&d instanceof b.Vector3?e.copy(d):this[c]="overdraw"===c?Number(d):d}}},toJSON:function(a){function c(a){var b=[],c;for(c in a){var d=a[c];delete d.metadata;b.push(d)}return b}var d=void 0===a;
d&&(a={textures:{},images:{}});var e={metadata:{version:4.4,type:"Material",generator:"Material.toJSON"}};e.uuid=this.uuid;e.type=this.type;""!==this.name&&(e.name=this.name);this.color instanceof b.Color&&(e.color=this.color.getHex());.5!==this.roughness&&(e.roughness=this.roughness);.5!==this.metalness&&(e.metalness=this.metalness);this.emissive instanceof b.Color&&(e.emissive=this.emissive.getHex());this.specular instanceof b.Color&&(e.specular=this.specular.getHex());void 0!==this.shininess&&
(e.shininess=this.shininess);this.map instanceof b.Texture&&(e.map=this.map.toJSON(a).uuid);this.alphaMap instanceof b.Texture&&(e.alphaMap=this.alphaMap.toJSON(a).uuid);this.lightMap instanceof b.Texture&&(e.lightMap=this.lightMap.toJSON(a).uuid);this.bumpMap instanceof b.Texture&&(e.bumpMap=this.bumpMap.toJSON(a).uuid,e.bumpScale=this.bumpScale);this.normalMap instanceof b.Texture&&(e.normalMap=this.normalMap.toJSON(a).uuid,e.normalScale=this.normalScale.toArray());this.displacementMap instanceof
b.Texture&&(e.displacementMap=this.displacementMap.toJSON(a).uuid,e.displacementScale=this.displacementScale,e.displacementBias=this.displacementBias);this.roughnessMap instanceof b.Texture&&(e.roughnessMap=this.roughnessMap.toJSON(a).uuid);this.metalnessMap instanceof b.Texture&&(e.metalnessMap=this.metalnessMap.toJSON(a).uuid);this.emissiveMap instanceof b.Texture&&(e.emissiveMap=this.emissiveMap.toJSON(a).uuid);this.specularMap instanceof b.Texture&&(e.specularMap=this.specularMap.toJSON(a).uuid);
this.envMap instanceof b.Texture&&(e.envMap=this.envMap.toJSON(a).uuid,e.reflectivity=this.reflectivity);void 0!==this.size&&(e.size=this.size);void 0!==this.sizeAttenuation&&(e.sizeAttenuation=this.sizeAttenuation);void 0!==this.vertexColors&&this.vertexColors!==b.NoColors&&(e.vertexColors=this.vertexColors);void 0!==this.shading&&this.shading!==b.SmoothShading&&(e.shading=this.shading);void 0!==this.blending&&this.blending!==b.NormalBlending&&(e.blending=this.blending);void 0!==this.side&&this.side!==
b.FrontSide&&(e.side=this.side);1>this.opacity&&(e.opacity=this.opacity);!0===this.transparent&&(e.transparent=this.transparent);0<this.alphaTest&&(e.alphaTest=this.alphaTest);!0===this.premultipliedAlpha&&(e.premultipliedAlpha=this.premultipliedAlpha);!0===this.wireframe&&(e.wireframe=this.wireframe);1<this.wireframeLinewidth&&(e.wireframeLinewidth=this.wireframeLinewidth);d&&(d=c(a.textures),a=c(a.images),0<d.length&&(e.textures=d),0<a.length&&(e.images=a));return e},clone:function(){return(new this.constructor).copy(this)},
copy:function(a){this.name=a.name;this.side=a.side;this.opacity=a.opacity;this.transparent=a.transparent;this.blending=a.blending;this.blendSrc=a.blendSrc;this.blendDst=a.blendDst;this.blendEquation=a.blendEquation;this.blendSrcAlpha=a.blendSrcAlpha;this.blendDstAlpha=a.blendDstAlpha;this.blendEquationAlpha=a.blendEquationAlpha;this.depthFunc=a.depthFunc;this.depthTest=a.depthTest;this.depthWrite=a.depthWrite;this.colorWrite=a.colorWrite;this.precision=a.precision;this.polygonOffset=a.polygonOffset;
this.polygonOffsetFactor=a.polygonOffsetFactor;this.polygonOffsetUnits=a.polygonOffsetUnits;this.alphaTest=a.alphaTest;this.premultipliedAlpha=a.premultipliedAlpha;this.overdraw=a.overdraw;this.visible=a.visible;this.clipShadows=a.clipShadows;a=a.clippingPlanes;var b=null;if(null!==a)for(var d=a.length,b=Array(d),e=0;e!==d;++e)b[e]=a[e].clone();this.clippingPlanes=b;return this},update:function(){this.dispatchEvent({type:"update"})},dispose:function(){this.dispatchEvent({type:"dispose"})}};b.EventDispatcher.prototype.apply(b.Material.prototype);
b.MaterialIdCount=0;b.LineBasicMaterial=function(a){b.Material.call(this);this.type="LineBasicMaterial";this.color=new b.Color(16777215);this.linewidth=1;this.linejoin=this.linecap="round";this.blending=b.NormalBlending;this.vertexColors=b.NoColors;this.fog=!0;this.setValues(a)};b.LineBasicMaterial.prototype=Object.create(b.Material.prototype);b.LineBasicMaterial.prototype.constructor=b.LineBasicMaterial;b.LineBasicMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,a);this.color.copy(a.color);
this.linewidth=a.linewidth;this.linecap=a.linecap;this.linejoin=a.linejoin;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};b.LineDashedMaterial=function(a){b.Material.call(this);this.type="LineDashedMaterial";this.color=new b.Color(16777215);this.scale=this.linewidth=1;this.dashSize=3;this.gapSize=1;this.blending=b.NormalBlending;this.vertexColors=b.NoColors;this.fog=!0;this.setValues(a)};b.LineDashedMaterial.prototype=Object.create(b.Material.prototype);b.LineDashedMaterial.prototype.constructor=
b.LineDashedMaterial;b.LineDashedMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.linewidth=a.linewidth;this.scale=a.scale;this.dashSize=a.dashSize;this.gapSize=a.gapSize;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};b.MeshBasicMaterial=function(a){b.Material.call(this);this.type="MeshBasicMaterial";this.color=new b.Color(16777215);this.aoMap=this.map=null;this.aoMapIntensity=1;this.envMap=this.alphaMap=this.specularMap=null;this.combine=
b.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=!0;this.shading=b.SmoothShading;this.blending=b.NormalBlending;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=b.NoColors;this.morphTargets=this.skinning=!1;this.setValues(a)};b.MeshBasicMaterial.prototype=Object.create(b.Material.prototype);b.MeshBasicMaterial.prototype.constructor=b.MeshBasicMaterial;b.MeshBasicMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,
a);this.color.copy(a.color);this.map=a.map;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=a.vertexColors;this.skinning=
a.skinning;this.morphTargets=a.morphTargets;return this};b.MeshLambertMaterial=function(a){b.Material.call(this);this.type="MeshLambertMaterial";this.color=new b.Color(16777215);this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new b.Color(0);this.emissiveIntensity=1;this.envMap=this.alphaMap=this.specularMap=this.emissiveMap=null;this.combine=b.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=!0;this.blending=b.NormalBlending;
this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=b.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};b.MeshLambertMaterial.prototype=Object.create(b.Material.prototype);b.MeshLambertMaterial.prototype.constructor=b.MeshLambertMaterial;b.MeshLambertMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=
a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=
a.wireframeLinejoin;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};b.MultiMaterial=function(a){this.uuid=b.Math.generateUUID();this.type="MultiMaterial";this.materials=a instanceof Array?a:[];this.visible=!0};b.MultiMaterial.prototype={constructor:b.MultiMaterial,toJSON:function(a){for(var b={metadata:{version:4.2,type:"material",generator:"MaterialExporter"},uuid:this.uuid,type:this.type,materials:[]},d=this.materials,
e=0,f=d.length;e<f;e++){var g=d[e].toJSON(a);delete g.metadata;b.materials.push(g)}b.visible=this.visible;return b},clone:function(){for(var a=new this.constructor,b=0;b<this.materials.length;b++)a.materials.push(this.materials[b].clone());a.visible=this.visible;return a}};b.PointsMaterial=function(a){b.Material.call(this);this.type="PointsMaterial";this.color=new b.Color(16777215);this.map=null;this.size=1;this.sizeAttenuation=!0;this.blending=b.NormalBlending;this.vertexColors=b.NoColors;this.fog=
!0;this.setValues(a)};b.PointsMaterial.prototype=Object.create(b.Material.prototype);b.PointsMaterial.prototype.constructor=b.PointsMaterial;b.PointsMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.size=a.size;this.sizeAttenuation=a.sizeAttenuation;this.vertexColors=a.vertexColors;this.fog=a.fog;return this};b.MeshPhongMaterial=function(a){b.Material.call(this);this.type="MeshPhongMaterial";this.color=new b.Color(16777215);this.specular=
new b.Color(1118481);this.shininess=30;this.lightMap=this.map=null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new b.Color(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new b.Vector2(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.specularMap=null;this.combine=b.MultiplyOperation;this.reflectivity=1;this.refractionRatio=.98;this.fog=
!0;this.shading=b.SmoothShading;this.blending=b.NormalBlending;this.wireframe=!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=b.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};b.MeshPhongMaterial.prototype=Object.create(b.Material.prototype);b.MeshPhongMaterial.prototype.constructor=b.MeshPhongMaterial;b.MeshPhongMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.specular.copy(a.specular);
this.shininess=a.shininess;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;
this.specularMap=a.specularMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.combine=a.combine;this.reflectivity=a.reflectivity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};
b.MeshDepthMaterial=function(a){b.Material.call(this);this.type="MeshDepthMaterial";this.depthPacking=b.BasicDepthPacking;this.morphTargets=this.skinning=!1;this.displacementMap=this.alphaMap=this.map=null;this.displacementScale=1;this.displacementBias=0;this.wireframe=!1;this.wireframeLinewidth=1;this.setValues(a)};b.MeshDepthMaterial.prototype=Object.create(b.Material.prototype);b.MeshDepthMaterial.prototype.constructor=b.MeshDepthMaterial;b.MeshDepthMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,
a);this.depthPacking=a.depthPacking;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.map=a.map;this.alphaMap=a.alphaMap;this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};b.MeshNormalMaterial=function(a){b.Material.call(this,a);this.type="MeshNormalMaterial";this.wireframe=!1;this.wireframeLinewidth=1;this.morphTargets=!1;this.setValues(a)};
b.MeshNormalMaterial.prototype=Object.create(b.Material.prototype);b.MeshNormalMaterial.prototype.constructor=b.MeshNormalMaterial;b.MeshNormalMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,a);this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;return this};b.MeshStandardMaterial=function(a){b.Material.call(this);this.defines={STANDARD:""};this.type="MeshStandardMaterial";this.color=new b.Color(16777215);this.metalness=this.roughness=.5;this.lightMap=this.map=
null;this.lightMapIntensity=1;this.aoMap=null;this.aoMapIntensity=1;this.emissive=new b.Color(0);this.emissiveIntensity=1;this.bumpMap=this.emissiveMap=null;this.bumpScale=1;this.normalMap=null;this.normalScale=new b.Vector2(1,1);this.displacementMap=null;this.displacementScale=1;this.displacementBias=0;this.envMap=this.alphaMap=this.metalnessMap=this.roughnessMap=null;this.envMapIntensity=1;this.refractionRatio=.98;this.fog=!0;this.shading=b.SmoothShading;this.blending=b.NormalBlending;this.wireframe=
!1;this.wireframeLinewidth=1;this.wireframeLinejoin=this.wireframeLinecap="round";this.vertexColors=b.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.setValues(a)};b.MeshStandardMaterial.prototype=Object.create(b.Material.prototype);b.MeshStandardMaterial.prototype.constructor=b.MeshStandardMaterial;b.MeshStandardMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,a);this.defines={STANDARD:""};this.color.copy(a.color);this.roughness=a.roughness;this.metalness=
a.metalness;this.map=a.map;this.lightMap=a.lightMap;this.lightMapIntensity=a.lightMapIntensity;this.aoMap=a.aoMap;this.aoMapIntensity=a.aoMapIntensity;this.emissive.copy(a.emissive);this.emissiveMap=a.emissiveMap;this.emissiveIntensity=a.emissiveIntensity;this.bumpMap=a.bumpMap;this.bumpScale=a.bumpScale;this.normalMap=a.normalMap;this.normalScale.copy(a.normalScale);this.displacementMap=a.displacementMap;this.displacementScale=a.displacementScale;this.displacementBias=a.displacementBias;this.roughnessMap=
a.roughnessMap;this.metalnessMap=a.metalnessMap;this.alphaMap=a.alphaMap;this.envMap=a.envMap;this.envMapIntensity=a.envMapIntensity;this.refractionRatio=a.refractionRatio;this.fog=a.fog;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.wireframeLinecap=a.wireframeLinecap;this.wireframeLinejoin=a.wireframeLinejoin;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;return this};
b.MeshPhysicalMaterial=function(a){b.MeshStandardMaterial.call(this);this.defines={PHYSICAL:""};this.type="MeshPhysicalMaterial";this.reflectivity=.5;this.setValues(a)};b.MeshPhysicalMaterial.prototype=Object.create(b.MeshStandardMaterial.prototype);b.MeshPhysicalMaterial.prototype.constructor=b.MeshPhysicalMaterial;b.MeshPhysicalMaterial.prototype.copy=function(a){b.MeshStandardMaterial.prototype.copy.call(this,a);this.defines={PHYSICAL:""};this.reflectivity=a.reflectivity;return this};b.SpriteMaterial=
function(a){b.Material.call(this);this.type="SpriteMaterial";this.color=new b.Color(16777215);this.map=null;this.rotation=0;this.fog=!1;this.setValues(a)};b.SpriteMaterial.prototype=Object.create(b.Material.prototype);b.SpriteMaterial.prototype.constructor=b.SpriteMaterial;b.SpriteMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,a);this.color.copy(a.color);this.map=a.map;this.rotation=a.rotation;this.fog=a.fog;return this};b.ShaderMaterial=function(a){b.Material.call(this);
this.type="ShaderMaterial";this.defines={};this.uniforms={};this.vertexShader="void main() {\n\tgl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );\n}";this.fragmentShader="void main() {\n\tgl_FragColor = vec4( 1.0, 0.0, 0.0, 1.0 );\n}";this.shading=b.SmoothShading;this.linewidth=1;this.wireframe=!1;this.wireframeLinewidth=1;this.clipping=this.lights=this.fog=!1;this.vertexColors=b.NoColors;this.morphNormals=this.morphTargets=this.skinning=!1;this.extensions={derivatives:!1,
fragDepth:!1,drawBuffers:!1,shaderTextureLOD:!1};this.defaultAttributeValues={color:[1,1,1],uv:[0,0],uv2:[0,0]};this.index0AttributeName=void 0;void 0!==a&&(void 0!==a.attributes&&console.error("THREE.ShaderMaterial: attributes should now be defined in THREE.BufferGeometry instead."),this.setValues(a))};b.ShaderMaterial.prototype=Object.create(b.Material.prototype);b.ShaderMaterial.prototype.constructor=b.ShaderMaterial;b.ShaderMaterial.prototype.copy=function(a){b.Material.prototype.copy.call(this,
a);this.fragmentShader=a.fragmentShader;this.vertexShader=a.vertexShader;this.uniforms=b.UniformsUtils.clone(a.uniforms);this.defines=a.defines;this.shading=a.shading;this.wireframe=a.wireframe;this.wireframeLinewidth=a.wireframeLinewidth;this.fog=a.fog;this.lights=a.lights;this.clipping=a.clipping;this.vertexColors=a.vertexColors;this.skinning=a.skinning;this.morphTargets=a.morphTargets;this.morphNormals=a.morphNormals;this.extensions=a.extensions;return this};b.ShaderMaterial.prototype.toJSON=function(a){a=
b.Material.prototype.toJSON.call(this,a);a.uniforms=this.uniforms;a.vertexShader=this.vertexShader;a.fragmentShader=this.fragmentShader;return a};b.RawShaderMaterial=function(a){b.ShaderMaterial.call(this,a);this.type="RawShaderMaterial"};b.RawShaderMaterial.prototype=Object.create(b.ShaderMaterial.prototype);b.RawShaderMaterial.prototype.constructor=b.RawShaderMaterial;b.Texture=function(a,c,d,e,f,g,h,n,k,m){Object.defineProperty(this,"id",{value:b.TextureIdCount++});this.uuid=b.Math.generateUUID();
this.sourceFile=this.name="";this.image=void 0!==a?a:b.Texture.DEFAULT_IMAGE;this.mipmaps=[];this.mapping=void 0!==c?c:b.Texture.DEFAULT_MAPPING;this.wrapS=void 0!==d?d:b.ClampToEdgeWrapping;this.wrapT=void 0!==e?e:b.ClampToEdgeWrapping;this.magFilter=void 0!==f?f:b.LinearFilter;this.minFilter=void 0!==g?g:b.LinearMipMapLinearFilter;this.anisotropy=void 0!==k?k:1;this.format=void 0!==h?h:b.RGBAFormat;this.type=void 0!==n?n:b.UnsignedByteType;this.offset=new b.Vector2(0,0);this.repeat=new b.Vector2(1,
1);this.generateMipmaps=!0;this.premultiplyAlpha=!1;this.flipY=!0;this.unpackAlignment=4;this.encoding=void 0!==m?m:b.LinearEncoding;this.version=0;this.onUpdate=null};b.Texture.DEFAULT_IMAGE=void 0;b.Texture.DEFAULT_MAPPING=b.UVMapping;b.Texture.prototype={constructor:b.Texture,set needsUpdate(a){!0===a&&this.version++},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.image=a.image;this.mipmaps=a.mipmaps.slice(0);this.mapping=a.mapping;this.wrapS=a.wrapS;this.wrapT=
a.wrapT;this.magFilter=a.magFilter;this.minFilter=a.minFilter;this.anisotropy=a.anisotropy;this.format=a.format;this.type=a.type;this.offset.copy(a.offset);this.repeat.copy(a.repeat);this.generateMipmaps=a.generateMipmaps;this.premultiplyAlpha=a.premultiplyAlpha;this.flipY=a.flipY;this.unpackAlignment=a.unpackAlignment;this.encoding=a.encoding;return this},toJSON:function(a){if(void 0!==a.textures[this.uuid])return a.textures[this.uuid];var c={metadata:{version:4.4,type:"Texture",generator:"Texture.toJSON"},
uuid:this.uuid,name:this.name,mapping:this.mapping,repeat:[this.repeat.x,this.repeat.y],offset:[this.offset.x,this.offset.y],wrap:[this.wrapS,this.wrapT],minFilter:this.minFilter,magFilter:this.magFilter,anisotropy:this.anisotropy};if(void 0!==this.image){var d=this.image;void 0===d.uuid&&(d.uuid=b.Math.generateUUID());if(void 0===a.images[d.uuid]){var e=a.images,f=d.uuid,g=d.uuid,h;void 0!==d.toDataURL?h=d:(h=document.createElement("canvas"),h.width=d.width,h.height=d.height,h.getContext("2d").drawImage(d,
0,0,d.width,d.height));h=2048<h.width||2048<h.height?h.toDataURL("image/jpeg",.6):h.toDataURL("image/png");e[f]={uuid:g,url:h}}c.image=d.uuid}return a.textures[this.uuid]=c},dispose:function(){this.dispatchEvent({type:"dispose"})},transformUv:function(a){if(this.mapping===b.UVMapping){a.multiply(this.repeat);a.add(this.offset);if(0>a.x||1<a.x)switch(this.wrapS){case b.RepeatWrapping:a.x-=Math.floor(a.x);break;case b.ClampToEdgeWrapping:a.x=0>a.x?0:1;break;case b.MirroredRepeatWrapping:1===Math.abs(Math.floor(a.x)%
2)?a.x=Math.ceil(a.x)-a.x:a.x-=Math.floor(a.x)}if(0>a.y||1<a.y)switch(this.wrapT){case b.RepeatWrapping:a.y-=Math.floor(a.y);break;case b.ClampToEdgeWrapping:a.y=0>a.y?0:1;break;case b.MirroredRepeatWrapping:1===Math.abs(Math.floor(a.y)%2)?a.y=Math.ceil(a.y)-a.y:a.y-=Math.floor(a.y)}this.flipY&&(a.y=1-a.y)}}};b.EventDispatcher.prototype.apply(b.Texture.prototype);b.TextureIdCount=0;b.DepthTexture=function(a,c,d,e,f,g,h,n,k){b.Texture.call(this,null,e,f,g,h,n,b.DepthFormat,d,k);this.image={width:a,
height:c};this.type=void 0!==d?d:b.UnsignedShortType;this.magFilter=void 0!==h?h:b.NearestFilter;this.minFilter=void 0!==n?n:b.NearestFilter;this.generateMipmaps=this.flipY=!1};b.DepthTexture.prototype=Object.create(b.Texture.prototype);b.DepthTexture.prototype.constructor=b.DepthTexture;b.CompressedTexture=function(a,c,d,e,f,g,h,n,k,m,t,x){b.Texture.call(this,null,g,h,n,k,m,e,f,t,x);this.image={width:c,height:d};this.mipmaps=a;this.generateMipmaps=this.flipY=!1};b.CompressedTexture.prototype=Object.create(b.Texture.prototype);
b.CompressedTexture.prototype.constructor=b.CompressedTexture;b.DataTexture=function(a,c,d,e,f,g,h,n,k,m,t,x){b.Texture.call(this,null,g,h,n,k,m,e,f,t,x);this.image={data:a,width:c,height:d};this.magFilter=void 0!==k?k:b.NearestFilter;this.minFilter=void 0!==m?m:b.NearestFilter;this.generateMipmaps=this.flipY=!1};b.DataTexture.prototype=Object.create(b.Texture.prototype);b.DataTexture.prototype.constructor=b.DataTexture;b.Line=function(a,c,d){if(1===d)return console.warn("THREE.Line: parameter THREE.LinePieces no longer supported. Created THREE.LineSegments instead."),
new b.LineSegments(a,c);b.Object3D.call(this);this.type="Line";this.geometry=void 0!==a?a:new b.Geometry;this.material=void 0!==c?c:new b.LineBasicMaterial({color:16777215*Math.random()})};b.Line.prototype=Object.create(b.Object3D.prototype);b.Line.prototype.constructor=b.Line;b.Line.prototype.raycast=function(){var a=new b.Matrix4,c=new b.Ray,d=new b.Sphere;return function(e,f){var g=e.linePrecision,g=g*g,h=this.geometry,n=this.matrixWorld;null===h.boundingSphere&&h.computeBoundingSphere();d.copy(h.boundingSphere);
d.applyMatrix4(n);if(!1!==e.ray.intersectsSphere(d)){a.getInverse(n);c.copy(e.ray).applyMatrix4(a);var k=new b.Vector3,m=new b.Vector3,n=new b.Vector3,t=new b.Vector3,x=this instanceof b.LineSegments?2:1;if(h instanceof b.BufferGeometry){var l=h.index,p=h.attributes.position.array;if(null!==l)for(var l=l.array,h=0,q=l.length-1;h<q;h+=x){var s=l[h+1];k.fromArray(p,3*l[h]);m.fromArray(p,3*s);s=c.distanceSqToSegment(k,m,t,n);s>g||(t.applyMatrix4(this.matrixWorld),s=e.ray.origin.distanceTo(t),s<e.near||
s>e.far||f.push({distance:s,point:n.clone().applyMatrix4(this.matrixWorld),index:h,face:null,faceIndex:null,object:this}))}else for(h=0,q=p.length/3-1;h<q;h+=x)k.fromArray(p,3*h),m.fromArray(p,3*h+3),s=c.distanceSqToSegment(k,m,t,n),s>g||(t.applyMatrix4(this.matrixWorld),s=e.ray.origin.distanceTo(t),s<e.near||s>e.far||f.push({distance:s,point:n.clone().applyMatrix4(this.matrixWorld),index:h,face:null,faceIndex:null,object:this}))}else if(h instanceof b.Geometry)for(k=h.vertices,m=k.length,h=0;h<m-
1;h+=x)s=c.distanceSqToSegment(k[h],k[h+1],t,n),s>g||(t.applyMatrix4(this.matrixWorld),s=e.ray.origin.distanceTo(t),s<e.near||s>e.far||f.push({distance:s,point:n.clone().applyMatrix4(this.matrixWorld),index:h,face:null,faceIndex:null,object:this}))}}}();b.Line.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};b.LineStrip=0;b.LinePieces=1;b.Points=function(a,c){b.Object3D.call(this);this.type="Points";this.geometry=void 0!==a?a:new b.Geometry;this.material=
void 0!==c?c:new b.PointsMaterial({color:16777215*Math.random()})};b.Points.prototype=Object.create(b.Object3D.prototype);b.Points.prototype.constructor=b.Points;b.Points.prototype.raycast=function(){var a=new b.Matrix4,c=new b.Ray,d=new b.Sphere;return function(e,f){function g(a,b){var d=c.distanceSqToPoint(a);if(d<t){var g=c.closestPointToPoint(a);g.applyMatrix4(k);var l=e.ray.origin.distanceTo(g);l<e.near||l>e.far||f.push({distance:l,distanceToRay:Math.sqrt(d),point:g.clone(),index:b,face:null,
object:h})}}var h=this,n=this.geometry,k=this.matrixWorld,m=e.params.Points.threshold;null===n.boundingSphere&&n.computeBoundingSphere();d.copy(n.boundingSphere);d.applyMatrix4(k);if(!1!==e.ray.intersectsSphere(d)){a.getInverse(k);c.copy(e.ray).applyMatrix4(a);var m=m/((this.scale.x+this.scale.y+this.scale.z)/3),t=m*m,m=new b.Vector3;if(n instanceof b.BufferGeometry){var x=n.index,n=n.attributes.position.array;if(null!==x)for(var l=x.array,x=0,p=l.length;x<p;x++){var q=l[x];m.fromArray(n,3*q);g(m,
q)}else for(x=0,l=n.length/3;x<l;x++)m.fromArray(n,3*x),g(m,x)}else for(m=n.vertices,x=0,l=m.length;x<l;x++)g(m[x],x)}}}();b.Points.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};b.LineSegments=function(a,c){b.Line.call(this,a,c);this.type="LineSegments"};b.LineSegments.prototype=Object.create(b.Line.prototype);b.LineSegments.prototype.constructor=b.LineSegments;b.Mesh=function(a,c){b.Object3D.call(this);this.type="Mesh";this.geometry=void 0!==a?a:
new b.Geometry;this.material=void 0!==c?c:new b.MeshBasicMaterial({color:16777215*Math.random()});this.drawMode=b.TrianglesDrawMode;this.updateMorphTargets()};b.Mesh.prototype=Object.create(b.Object3D.prototype);b.Mesh.prototype.constructor=b.Mesh;b.Mesh.prototype.setDrawMode=function(a){this.drawMode=a};b.Mesh.prototype.updateMorphTargets=function(){if(void 0!==this.geometry.morphTargets&&0<this.geometry.morphTargets.length){this.morphTargetBase=-1;this.morphTargetInfluences=[];this.morphTargetDictionary=
{};for(var a=0,b=this.geometry.morphTargets.length;a<b;a++)this.morphTargetInfluences.push(0),this.morphTargetDictionary[this.geometry.morphTargets[a].name]=a}};b.Mesh.prototype.getMorphTargetIndexByName=function(a){if(void 0!==this.morphTargetDictionary[a])return this.morphTargetDictionary[a];console.warn("THREE.Mesh.getMorphTargetIndexByName: morph target "+a+" does not exist. Returning 0.");return 0};b.Mesh.prototype.raycast=function(){function a(a,c,d,e,f,h,g){b.Triangle.barycoordFromPoint(a,
c,d,e,s);f.multiplyScalar(s.x);h.multiplyScalar(s.y);g.multiplyScalar(s.z);f.add(h).add(g);return f.clone()}function c(a,c,d,e,f,h,g){var l=a.material;if(null===(l.side===b.BackSide?d.intersectTriangle(h,f,e,!0,g):d.intersectTriangle(e,f,h,l.side!==b.DoubleSide,g)))return null;y.copy(g);y.applyMatrix4(a.matrixWorld);d=c.ray.origin.distanceTo(y);return d<c.near||d>c.far?null:{distance:d,point:y.clone(),object:a}}function d(d,e,f,g,r,t,x,s){h.fromArray(g,3*t);k.fromArray(g,3*x);m.fromArray(g,3*s);if(d=
c(d,e,f,h,k,m,w))r&&(l.fromArray(r,2*t),p.fromArray(r,2*x),q.fromArray(r,2*s),d.uv=a(w,h,k,m,l,p,q)),d.face=new b.Face3(t,x,s,b.Triangle.normal(h,k,m)),d.faceIndex=t;return d}var e=new b.Matrix4,f=new b.Ray,g=new b.Sphere,h=new b.Vector3,k=new b.Vector3,m=new b.Vector3,r=new b.Vector3,t=new b.Vector3,x=new b.Vector3,l=new b.Vector2,p=new b.Vector2,q=new b.Vector2,s=new b.Vector3,w=new b.Vector3,y=new b.Vector3;return function(s,z){var A=this.geometry,y=this.material,I=this.matrixWorld;if(void 0!==
y&&(null===A.boundingSphere&&A.computeBoundingSphere(),g.copy(A.boundingSphere),g.applyMatrix4(I),!1!==s.ray.intersectsSphere(g)&&(e.getInverse(I),f.copy(s.ray).applyMatrix4(e),null===A.boundingBox||!1!==f.intersectsBox(A.boundingBox)))){var G,E;if(A instanceof b.BufferGeometry){var R,M,y=A.index,I=A.attributes,A=I.position.array;void 0!==I.uv&&(G=I.uv.array);if(null!==y)for(var I=y.array,Q=0,L=I.length;Q<L;Q+=3){if(y=I[Q],R=I[Q+1],M=I[Q+2],E=d(this,s,f,A,G,y,R,M))E.faceIndex=Math.floor(Q/3),z.push(E)}else for(Q=
0,L=A.length;Q<L;Q+=9)if(y=Q/3,R=y+1,M=y+2,E=d(this,s,f,A,G,y,R,M))E.index=y,z.push(E)}else if(A instanceof b.Geometry){var D,P,I=y instanceof b.MultiMaterial,Q=!0===I?y.materials:null,L=A.vertices;R=A.faces;M=A.faceVertexUvs[0];0<M.length&&(G=M);for(var N=0,T=R.length;N<T;N++){var H=R[N];E=!0===I?Q[H.materialIndex]:y;if(void 0!==E){M=L[H.a];D=L[H.b];P=L[H.c];if(!0===E.morphTargets){E=A.morphTargets;var J=this.morphTargetInfluences;h.set(0,0,0);k.set(0,0,0);m.set(0,0,0);for(var O=0,Y=E.length;O<Y;O++){var V=
J[O];if(0!==V){var sa=E[O].vertices;h.addScaledVector(r.subVectors(sa[H.a],M),V);k.addScaledVector(t.subVectors(sa[H.b],D),V);m.addScaledVector(x.subVectors(sa[H.c],P),V)}}h.add(M);k.add(D);m.add(P);M=h;D=k;P=m}if(E=c(this,s,f,M,D,P,w))G&&(J=G[N],l.copy(J[0]),p.copy(J[1]),q.copy(J[2]),E.uv=a(w,M,D,P,l,p,q)),E.face=H,E.faceIndex=N,z.push(E)}}}}}}();b.Mesh.prototype.clone=function(){return(new this.constructor(this.geometry,this.material)).copy(this)};b.SkinnedMesh=function(a,c,d){b.Mesh.call(this,
a,c);this.type="SkinnedMesh";this.bindMode="attached";this.bindMatrix=new b.Matrix4;this.bindMatrixInverse=new b.Matrix4;a=[];if(this.geometry&&void 0!==this.geometry.bones){for(var e,f=0,g=this.geometry.bones.length;f<g;++f)e=this.geometry.bones[f],c=new b.Bone(this),a.push(c),c.name=e.name,c.position.fromArray(e.pos),c.quaternion.fromArray(e.rotq),void 0!==e.scl&&c.scale.fromArray(e.scl);f=0;for(g=this.geometry.bones.length;f<g;++f)e=this.geometry.bones[f],-1!==e.parent&&null!==e.parent&&void 0!==
a[e.parent]?a[e.parent].add(a[f]):this.add(a[f])}this.normalizeSkinWeights();this.updateMatrixWorld(!0);this.bind(new b.Skeleton(a,void 0,d),this.matrixWorld)};b.SkinnedMesh.prototype=Object.create(b.Mesh.prototype);b.SkinnedMesh.prototype.constructor=b.SkinnedMesh;b.SkinnedMesh.prototype.bind=function(a,b){this.skeleton=a;void 0===b&&(this.updateMatrixWorld(!0),this.skeleton.calculateInverses(),b=this.matrixWorld);this.bindMatrix.copy(b);this.bindMatrixInverse.getInverse(b)};b.SkinnedMesh.prototype.pose=
function(){this.skeleton.pose()};b.SkinnedMesh.prototype.normalizeSkinWeights=function(){if(this.geometry instanceof b.Geometry)for(var a=0;a<this.geometry.skinWeights.length;a++){var c=this.geometry.skinWeights[a],d=1/c.lengthManhattan();Infinity!==d?c.multiplyScalar(d):c.set(1,0,0,0)}else if(this.geometry instanceof b.BufferGeometry)for(var c=new b.Vector4,e=this.geometry.attributes.skinWeight,a=0;a<e.count;a++)c.x=e.getX(a),c.y=e.getY(a),c.z=e.getZ(a),c.w=e.getW(a),d=1/c.lengthManhattan(),Infinity!==
d?c.multiplyScalar(d):c.set(1,0,0,0),e.setXYZW(a,c.x,c.y,c.z,c.w)};b.SkinnedMesh.prototype.updateMatrixWorld=function(a){b.Mesh.prototype.updateMatrixWorld.call(this,!0);"attached"===this.bindMode?this.bindMatrixInverse.getInverse(this.matrixWorld):"detached"===this.bindMode?this.bindMatrixInverse.getInverse(this.bindMatrix):console.warn("THREE.SkinnedMesh unrecognized bindMode: "+this.bindMode)};b.SkinnedMesh.prototype.clone=function(){return(new this.constructor(this.geometry,this.material,this.useVertexTexture)).copy(this)};
b.Sprite=function(){var a=new Uint16Array([0,1,2,0,2,3]),c=new Float32Array([-.5,-.5,0,.5,-.5,0,.5,.5,0,-.5,.5,0]),d=new Float32Array([0,0,1,0,1,1,0,1]),e=new b.BufferGeometry;e.setIndex(new b.BufferAttribute(a,1));e.addAttribute("position",new b.BufferAttribute(c,3));e.addAttribute("uv",new b.BufferAttribute(d,2));return function(a){b.Object3D.call(this);this.type="Sprite";this.geometry=e;this.material=void 0!==a?a:new b.SpriteMaterial}}();b.Sprite.prototype=Object.create(b.Object3D.prototype);b.Sprite.prototype.constructor=
b.Sprite;b.Sprite.prototype.raycast=function(){var a=new b.Vector3;return function(b,d){a.setFromMatrixPosition(this.matrixWorld);var e=b.ray.distanceSqToPoint(a);e>this.scale.x*this.scale.y/4||d.push({distance:Math.sqrt(e),point:this.position,face:null,object:this})}}();b.Sprite.prototype.clone=function(){return(new this.constructor(this.material)).copy(this)};b.Particle=b.Sprite;b.LensFlare=function(a,c,d,e,f){b.Object3D.call(this);this.lensFlares=[];this.positionScreen=new b.Vector3;this.customUpdateCallback=
void 0;void 0!==a&&this.add(a,c,d,e,f)};b.LensFlare.prototype=Object.create(b.Object3D.prototype);b.LensFlare.prototype.constructor=b.LensFlare;b.LensFlare.prototype.add=function(a,c,d,e,f,g){void 0===c&&(c=-1);void 0===d&&(d=0);void 0===g&&(g=1);void 0===f&&(f=new b.Color(16777215));void 0===e&&(e=b.NormalBlending);d=Math.min(d,Math.max(0,d));this.lensFlares.push({texture:a,size:c,distance:d,x:0,y:0,z:0,scale:1,rotation:0,opacity:g,color:f,blending:e})};b.LensFlare.prototype.updateLensFlares=function(){var a,
b=this.lensFlares.length,d,e=2*-this.positionScreen.x,f=2*-this.positionScreen.y;for(a=0;a<b;a++)d=this.lensFlares[a],d.x=this.positionScreen.x+e*d.distance,d.y=this.positionScreen.y+f*d.distance,d.wantedRotation=d.x*Math.PI*.25,d.rotation+=.25*(d.wantedRotation-d.rotation)};b.LensFlare.prototype.copy=function(a){b.Object3D.prototype.copy.call(this,a);this.positionScreen.copy(a.positionScreen);this.customUpdateCallback=a.customUpdateCallback;for(var c=0,d=a.lensFlares.length;c<d;c++)this.lensFlares.push(a.lensFlares[c]);
return this};b.ImmediateRenderObject=function(a){b.Object3D.call(this);this.material=a;this.render=function(a){}};b.ImmediateRenderObject.prototype=Object.create(b.Object3D.prototype);b.ImmediateRenderObject.prototype.constructor=b.ImmediateRenderObject;b.Scene=function(){b.Object3D.call(this);this.type="Scene";this.overrideMaterial=this.fog=null;this.autoUpdate=!0};b.Scene.prototype=Object.create(b.Object3D.prototype);b.Scene.prototype.constructor=b.Scene;b.Scene.prototype.copy=function(a,c){b.Object3D.prototype.copy.call(this,
a,c);null!==a.fog&&(this.fog=a.fog.clone());null!==a.overrideMaterial&&(this.overrideMaterial=a.overrideMaterial.clone());this.autoUpdate=a.autoUpdate;this.matrixAutoUpdate=a.matrixAutoUpdate;return this};b.FogExp2=function(a,c){this.name="";this.color=new b.Color(a);this.density=void 0!==c?c:2.5E-4};b.FogExp2.prototype.clone=function(){return new b.FogExp2(this.color.getHex(),this.density)};b.ShaderChunk={};b.ShaderChunk.common="#define PI 3.14159265359\n#define PI2 6.28318530718\n#define RECIPROCAL_PI 0.31830988618\n#define RECIPROCAL_PI2 0.15915494\n#define LOG2 1.442695\n#define EPSILON 1e-6\n#define saturate(a) clamp( a, 0.0, 1.0 )\n#define whiteCompliment(a) ( 1.0 - saturate( a ) )\nfloat pow2( const in float x ) { return x*x; }\nfloat pow3( const in float x ) { return x*x*x; }\nfloat pow4( const in float x ) { float x2 = x*x; return x2*x2; }\nfloat average( const in vec3 color ) { return dot( color, vec3( 0.3333 ) ); }\nhighp float rand( const in vec2 uv ) {\n\tconst highp float a = 12.9898, b = 78.233, c = 43758.5453;\n\thighp float dt = dot( uv.xy, vec2( a,b ) ), sn = mod( dt, PI );\n\treturn fract(sin(sn) * c);\n}\nstruct IncidentLight {\n\tvec3 color;\n\tvec3 direction;\n\tbool visible;\n};\nstruct ReflectedLight {\n\tvec3 directDiffuse;\n\tvec3 directSpecular;\n\tvec3 indirectDiffuse;\n\tvec3 indirectSpecular;\n};\nstruct GeometricContext {\n\tvec3 position;\n\tvec3 normal;\n\tvec3 viewDir;\n};\nvec3 transformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( matrix * vec4( dir, 0.0 ) ).xyz );\n}\nvec3 inverseTransformDirection( in vec3 dir, in mat4 matrix ) {\n\treturn normalize( ( vec4( dir, 0.0 ) * matrix ).xyz );\n}\nvec3 projectOnPlane(in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\tfloat distance = dot( planeNormal, point - pointOnPlane );\n\treturn - distance * planeNormal + point;\n}\nfloat sideOfPlane( in vec3 point, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn sign( dot( point - pointOnPlane, planeNormal ) );\n}\nvec3 linePlaneIntersect( in vec3 pointOnLine, in vec3 lineDirection, in vec3 pointOnPlane, in vec3 planeNormal ) {\n\treturn lineDirection * ( dot( planeNormal, pointOnPlane - pointOnLine ) / dot( planeNormal, lineDirection ) ) + pointOnLine;\n}\n";
b.ShaderChunk.alphamap_fragment="#ifdef USE_ALPHAMAP\n\tdiffuseColor.a *= texture2D( alphaMap, vUv ).g;\n#endif\n";b.ShaderChunk.alphamap_pars_fragment="#ifdef USE_ALPHAMAP\n\tuniform sampler2D alphaMap;\n#endif\n";b.ShaderChunk.alphatest_fragment="#ifdef ALPHATEST\n\tif ( diffuseColor.a < ALPHATEST ) discard;\n#endif\n";b.ShaderChunk.aomap_pars_fragment="#ifdef USE_AOMAP\n\tuniform sampler2D aoMap;\n\tuniform float aoMapIntensity;\n#endif";b.ShaderChunk.aomap_fragment="#ifdef USE_AOMAP\n\tfloat ambientOcclusion = ( texture2D( aoMap, vUv2 ).r - 1.0 ) * aoMapIntensity + 1.0;\n\treflectedLight.indirectDiffuse *= ambientOcclusion;\n\t#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\t\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\t\treflectedLight.indirectSpecular *= computeSpecularOcclusion( dotNV, ambientOcclusion, material.specularRoughness );\n\t#endif\n#endif\n";
b.ShaderChunk.uv_pars_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n\tuniform vec4 offsetRepeat;\n#endif\n";b.ShaderChunk.uv_vertex="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvUv = uv * offsetRepeat.zw + offsetRepeat.xy;\n#endif";
b.ShaderChunk.uv_pars_fragment="#if defined( USE_MAP ) || defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( USE_SPECULARMAP ) || defined( USE_ALPHAMAP ) || defined( USE_EMISSIVEMAP ) || defined( USE_ROUGHNESSMAP ) || defined( USE_METALNESSMAP )\n\tvarying vec2 vUv;\n#endif";b.ShaderChunk.uv2_pars_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tattribute vec2 uv2;\n\tvarying vec2 vUv2;\n#endif";b.ShaderChunk.uv2_vertex="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvUv2 = uv2;\n#endif";
b.ShaderChunk.uv2_pars_fragment="#if defined( USE_LIGHTMAP ) || defined( USE_AOMAP )\n\tvarying vec2 vUv2;\n#endif";b.ShaderChunk.emissivemap_pars_fragment="#ifdef USE_EMISSIVEMAP\n\tuniform sampler2D emissiveMap;\n#endif\n";b.ShaderChunk.emissivemap_fragment="#ifdef USE_EMISSIVEMAP\n\tvec4 emissiveColor = texture2D( emissiveMap, vUv );\n\temissiveColor.rgb = emissiveMapTexelToLinear( emissiveColor ).rgb;\n\ttotalEmissiveRadiance *= emissiveColor.rgb;\n#endif\n";b.ShaderChunk.encodings_pars_fragment=
"\nvec4 LinearToLinear( in vec4 value ) {\n return value;\n}\nvec4 GammaToLinear( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( gammaFactor ) ), value.w );\n}\nvec4 LinearToGamma( in vec4 value, in float gammaFactor ) {\n return vec4( pow( value.xyz, vec3( 1.0 / gammaFactor ) ), value.w );\n}\nvec4 sRGBToLinear( in vec4 value ) {\n return vec4( mix( pow( value.rgb * 0.9478672986 + vec3( 0.0521327014 ), vec3( 2.4 ) ), value.rgb * 0.0773993808, vec3( lessThanEqual( value.rgb, vec3( 0.04045 ) ) ) ), value.w );\n}\nvec4 LinearTosRGB( in vec4 value ) {\n return vec4( mix( pow( value.rgb, vec3( 0.41666 ) ) * 1.055 - vec3( 0.055 ), value.rgb * 12.92, vec3( lessThanEqual( value.rgb, vec3( 0.0031308 ) ) ) ), value.w );\n}\nvec4 RGBEToLinear( in vec4 value ) {\n return vec4( value.rgb * exp2( value.a * 255.0 - 128.0 ), 1.0 );\n}\nvec4 LinearToRGBE( in vec4 value ) {\n float maxComponent = max( max( value.r, value.g ), value.b );\n float fExp = clamp( ceil( log2( maxComponent ) ), -128.0, 127.0 );\n return vec4( value.rgb / exp2( fExp ), ( fExp + 128.0 ) / 255.0 );\n}\nvec4 RGBMToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.xyz * value.w * maxRange, 1.0 );\n}\nvec4 LinearToRGBM( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float M = clamp( maxRGB / maxRange, 0.0, 1.0 );\n M = ceil( M * 255.0 ) / 255.0;\n return vec4( value.rgb / ( M * maxRange ), M );\n}\nvec4 RGBDToLinear( in vec4 value, in float maxRange ) {\n return vec4( value.rgb * ( ( maxRange / 255.0 ) / value.a ), 1.0 );\n}\nvec4 LinearToRGBD( in vec4 value, in float maxRange ) {\n float maxRGB = max( value.x, max( value.g, value.b ) );\n float D = max( maxRange / maxRGB, 1.0 );\n D = min( floor( D ) / 255.0, 1.0 );\n return vec4( value.rgb * ( D * ( 255.0 / maxRange ) ), D );\n}\nconst mat3 cLogLuvM = mat3( 0.2209, 0.3390, 0.4184, 0.1138, 0.6780, 0.7319, 0.0102, 0.1130, 0.2969 );\nvec4 LinearToLogLuv( in vec4 value ) {\n vec3 Xp_Y_XYZp = value.rgb * cLogLuvM;\n Xp_Y_XYZp = max(Xp_Y_XYZp, vec3(1e-6, 1e-6, 1e-6));\n vec4 vResult;\n vResult.xy = Xp_Y_XYZp.xy / Xp_Y_XYZp.z;\n float Le = 2.0 * log2(Xp_Y_XYZp.y) + 127.0;\n vResult.w = fract(Le);\n vResult.z = (Le - (floor(vResult.w*255.0))/255.0)/255.0;\n return vResult;\n}\nconst mat3 cLogLuvInverseM = mat3( 6.0014, -2.7008, -1.7996, -1.3320, 3.1029, -5.7721, 0.3008, -1.0882, 5.6268 );\nvec4 LogLuvToLinear( in vec4 value ) {\n float Le = value.z * 255.0 + value.w;\n vec3 Xp_Y_XYZp;\n Xp_Y_XYZp.y = exp2((Le - 127.0) / 2.0);\n Xp_Y_XYZp.z = Xp_Y_XYZp.y / value.y;\n Xp_Y_XYZp.x = value.x * Xp_Y_XYZp.z;\n vec3 vRGB = Xp_Y_XYZp.rgb * cLogLuvInverseM;\n return vec4( max(vRGB, 0.0), 1.0 );\n}\n";
b.ShaderChunk.encodings_fragment=" gl_FragColor = linearToOutputTexel( gl_FragColor );\n";b.ShaderChunk.envmap_pars_vertex="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvarying vec3 vWorldPosition;\n\t#else\n\t\tvarying vec3 vReflect;\n\t\tuniform float refractionRatio;\n\t#endif\n#endif\n";b.ShaderChunk.envmap_vertex="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvWorldPosition = worldPosition.xyz;\n\t#else\n\t\tvec3 cameraToVertex = normalize( worldPosition.xyz - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( transformedNormal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvReflect = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvReflect = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#endif\n#endif\n";
b.ShaderChunk.envmap_pars_fragment="#if defined( USE_ENVMAP ) || defined( PHYSICAL )\n\tuniform float reflectivity;\n\tuniform float envMapIntenstiy;\n#endif\n#ifdef USE_ENVMAP\n\t#if ! defined( PHYSICAL ) && ( defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) )\n\t\tvarying vec3 vWorldPosition;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tuniform samplerCube envMap;\n\t#else\n\t\tuniform sampler2D envMap;\n\t#endif\n\tuniform float flipEnvMap;\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG ) || defined( PHYSICAL )\n\t\tuniform float refractionRatio;\n\t#else\n\t\tvarying vec3 vReflect;\n\t#endif\n#endif\n";
b.ShaderChunk.envmap_fragment="#ifdef USE_ENVMAP\n\t#if defined( USE_BUMPMAP ) || defined( USE_NORMALMAP ) || defined( PHONG )\n\t\tvec3 cameraToVertex = normalize( vWorldPosition - cameraPosition );\n\t\tvec3 worldNormal = inverseTransformDirection( normal, viewMatrix );\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( cameraToVertex, worldNormal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( cameraToVertex, worldNormal, refractionRatio );\n\t\t#endif\n\t#else\n\t\tvec3 reflectVec = vReflect;\n\t#endif\n\t#ifdef DOUBLE_SIDED\n\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t#else\n\t\tfloat flipNormal = 1.0;\n\t#endif\n\t#ifdef ENVMAP_TYPE_CUBE\n\t\tvec4 envColor = textureCube( envMap, flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz ) );\n\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\tvec2 sampleUV;\n\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\tvec4 envColor = texture2D( envMap, sampleUV );\n\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\tvec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\tvec4 envColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5 );\n\t#endif\n\tenvColor = envMapTexelToLinear( envColor );\n\t#ifdef ENVMAP_BLENDING_MULTIPLY\n\t\toutgoingLight = mix( outgoingLight, outgoingLight * envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_MIX )\n\t\toutgoingLight = mix( outgoingLight, envColor.xyz, specularStrength * reflectivity );\n\t#elif defined( ENVMAP_BLENDING_ADD )\n\t\toutgoingLight += envColor.xyz * specularStrength * reflectivity;\n\t#endif\n#endif\n";
b.ShaderChunk.bsdfs="bool testLightInRange( const in float lightDistance, const in float cutoffDistance ) {\n\treturn any( bvec2( cutoffDistance == 0.0, lightDistance < cutoffDistance ) );\n}\nfloat punctualLightIntensityToIrradianceFactor( const in float lightDistance, const in float cutoffDistance, const in float decayExponent ) {\n\t\tif( decayExponent > 0.0 ) {\n#if defined ( PHYSICALLY_CORRECT_LIGHTS )\n\t\t\tfloat distanceFalloff = 1.0 / max( pow( lightDistance, decayExponent ), 0.01 );\n\t\t\tfloat maxDistanceCutoffFactor = pow2( saturate( 1.0 - pow4( lightDistance / cutoffDistance ) ) );\n\t\t\treturn distanceFalloff * maxDistanceCutoffFactor;\n#else\n\t\t\treturn pow( saturate( -lightDistance / cutoffDistance + 1.0 ), decayExponent );\n#endif\n\t\t}\n\t\treturn 1.0;\n}\nvec3 BRDF_Diffuse_Lambert( const in vec3 diffuseColor ) {\n\treturn RECIPROCAL_PI * diffuseColor;\n}\nvec3 F_Schlick( const in vec3 specularColor, const in float dotLH ) {\n\tfloat fresnel = exp2( ( -5.55473 * dotLH - 6.98316 ) * dotLH );\n\treturn ( 1.0 - specularColor ) * fresnel + specularColor;\n}\nfloat G_GGX_Smith( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gl = dotNL + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\tfloat gv = dotNV + sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\treturn 1.0 / ( gl * gv );\n}\nfloat G_GGX_SmithCorrelated( const in float alpha, const in float dotNL, const in float dotNV ) {\n\tfloat a2 = pow2( alpha );\n\tfloat gv = dotNL * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNV ) );\n\tfloat gl = dotNV * sqrt( a2 + ( 1.0 - a2 ) * pow2( dotNL ) );\n\treturn 0.5 / max( gv + gl, EPSILON );\n}\nfloat D_GGX( const in float alpha, const in float dotNH ) {\n\tfloat a2 = pow2( alpha );\n\tfloat denom = pow2( dotNH ) * ( a2 - 1.0 ) + 1.0;\n\treturn RECIPROCAL_PI * a2 / pow2( denom );\n}\nvec3 BRDF_Specular_GGX( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat alpha = pow2( roughness );\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNL = saturate( dot( geometry.normal, incidentLight.direction ) );\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_GGX_SmithCorrelated( alpha, dotNL, dotNV );\n\tfloat D = D_GGX( alpha, dotNH );\n\treturn F * ( G * D );\n}\nvec3 BRDF_Specular_GGX_Environment( const in GeometricContext geometry, const in vec3 specularColor, const in float roughness ) {\n\tfloat dotNV = saturate( dot( geometry.normal, geometry.viewDir ) );\n\tconst vec4 c0 = vec4( - 1, - 0.0275, - 0.572, 0.022 );\n\tconst vec4 c1 = vec4( 1, 0.0425, 1.04, - 0.04 );\n\tvec4 r = roughness * c0 + c1;\n\tfloat a004 = min( r.x * r.x, exp2( - 9.28 * dotNV ) ) * r.x + r.y;\n\tvec2 AB = vec2( -1.04, 1.04 ) * a004 + r.zw;\n\treturn specularColor * AB.x + AB.y;\n}\nfloat G_BlinnPhong_Implicit( ) {\n\treturn 0.25;\n}\nfloat D_BlinnPhong( const in float shininess, const in float dotNH ) {\n\treturn RECIPROCAL_PI * ( shininess * 0.5 + 1.0 ) * pow( dotNH, shininess );\n}\nvec3 BRDF_Specular_BlinnPhong( const in IncidentLight incidentLight, const in GeometricContext geometry, const in vec3 specularColor, const in float shininess ) {\n\tvec3 halfDir = normalize( incidentLight.direction + geometry.viewDir );\n\tfloat dotNH = saturate( dot( geometry.normal, halfDir ) );\n\tfloat dotLH = saturate( dot( incidentLight.direction, halfDir ) );\n\tvec3 F = F_Schlick( specularColor, dotLH );\n\tfloat G = G_BlinnPhong_Implicit( );\n\tfloat D = D_BlinnPhong( shininess, dotNH );\n\treturn F * ( G * D );\n}\nfloat GGXRoughnessToBlinnExponent( const in float ggxRoughness ) {\n\treturn ( 2.0 / pow2( ggxRoughness + 0.0001 ) - 2.0 );\n}\nfloat BlinnExponentToGGXRoughness( const in float blinnExponent ) {\n\treturn sqrt( 2.0 / ( blinnExponent + 2.0 ) );\n}\n";
b.ShaderChunk.color_pars_vertex="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif";b.ShaderChunk.color_vertex="#ifdef USE_COLOR\n\tvColor.xyz = color.xyz;\n#endif";b.ShaderChunk.color_pars_fragment="#ifdef USE_COLOR\n\tvarying vec3 vColor;\n#endif\n";b.ShaderChunk.color_fragment="#ifdef USE_COLOR\n\tdiffuseColor.rgb *= vColor;\n#endif";b.ShaderChunk.beginnormal_vertex="\nvec3 objectNormal = vec3( normal );\n";b.ShaderChunk.map_fragment="#ifdef USE_MAP\n\tvec4 texelColor = texture2D( map, vUv );\n\ttexelColor = mapTexelToLinear( texelColor );\n\tdiffuseColor *= texelColor;\n#endif\n";
b.ShaderChunk.map_pars_fragment="#ifdef USE_MAP\n\tuniform sampler2D map;\n#endif\n";b.ShaderChunk.morphtarget_pars_vertex="#ifdef USE_MORPHTARGETS\n\t#ifndef USE_MORPHNORMALS\n\tuniform float morphTargetInfluences[ 8 ];\n\t#else\n\tuniform float morphTargetInfluences[ 4 ];\n\t#endif\n#endif";b.ShaderChunk.morphtarget_vertex="#ifdef USE_MORPHTARGETS\n\ttransformed += ( morphTarget0 - position ) * morphTargetInfluences[ 0 ];\n\ttransformed += ( morphTarget1 - position ) * morphTargetInfluences[ 1 ];\n\ttransformed += ( morphTarget2 - position ) * morphTargetInfluences[ 2 ];\n\ttransformed += ( morphTarget3 - position ) * morphTargetInfluences[ 3 ];\n\t#ifndef USE_MORPHNORMALS\n\ttransformed += ( morphTarget4 - position ) * morphTargetInfluences[ 4 ];\n\ttransformed += ( morphTarget5 - position ) * morphTargetInfluences[ 5 ];\n\ttransformed += ( morphTarget6 - position ) * morphTargetInfluences[ 6 ];\n\ttransformed += ( morphTarget7 - position ) * morphTargetInfluences[ 7 ];\n\t#endif\n#endif\n";
b.ShaderChunk.morphnormal_vertex="#ifdef USE_MORPHNORMALS\n\tobjectNormal += ( morphNormal0 - normal ) * morphTargetInfluences[ 0 ];\n\tobjectNormal += ( morphNormal1 - normal ) * morphTargetInfluences[ 1 ];\n\tobjectNormal += ( morphNormal2 - normal ) * morphTargetInfluences[ 2 ];\n\tobjectNormal += ( morphNormal3 - normal ) * morphTargetInfluences[ 3 ];\n#endif\n";b.ShaderChunk.clipping_planes_pars_vertex="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvarying vec3 vViewPosition;\n#endif\n";
b.ShaderChunk.clipping_planes_vertex="#if NUM_CLIPPING_PLANES > 0 && ! defined( PHYSICAL ) && ! defined( PHONG )\n\tvViewPosition = - mvPosition.xyz;\n#endif\n";b.ShaderChunk.clipping_planes_fragment="#if NUM_CLIPPING_PLANES > 0\n\tfor ( int i = 0; i < NUM_CLIPPING_PLANES; ++ i ) {\n\t\tvec4 plane = clippingPlanes[ i ];\n\t\tif ( dot( vViewPosition, plane.xyz ) > plane.w ) discard;\n\t}\n#endif\n";b.ShaderChunk.clipping_planes_pars_fragment="#if NUM_CLIPPING_PLANES > 0\n\t#if ! defined( PHYSICAL ) && ! defined( PHONG )\n\t\tvarying vec3 vViewPosition;\n\t#endif\n\tuniform vec4 clippingPlanes[ NUM_CLIPPING_PLANES ];\n#endif\n";
b.ShaderChunk.displacementmap_pars_vertex="#ifdef USE_DISPLACEMENTMAP\n\tuniform sampler2D displacementMap;\n\tuniform float displacementScale;\n\tuniform float displacementBias;\n#endif\n";b.ShaderChunk.displacementmap_vertex="#ifdef USE_DISPLACEMENTMAP\n\ttransformed += normal * ( texture2D( displacementMap, uv ).x * displacementScale + displacementBias );\n#endif\n";b.ShaderChunk.fog_pars_fragment="#ifdef USE_FOG\n\tuniform vec3 fogColor;\n\t#ifdef FOG_EXP2\n\t\tuniform float fogDensity;\n\t#else\n\t\tuniform float fogNear;\n\t\tuniform float fogFar;\n\t#endif\n#endif";
b.ShaderChunk.fog_fragment="#ifdef USE_FOG\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tfloat depth = gl_FragDepthEXT / gl_FragCoord.w;\n\t#else\n\t\tfloat depth = gl_FragCoord.z / gl_FragCoord.w;\n\t#endif\n\t#ifdef FOG_EXP2\n\t\tfloat fogFactor = whiteCompliment( exp2( - fogDensity * fogDensity * depth * depth * LOG2 ) );\n\t#else\n\t\tfloat fogFactor = smoothstep( fogNear, fogFar, depth );\n\t#endif\n\tgl_FragColor.rgb = mix( gl_FragColor.rgb, fogColor, fogFactor );\n#endif\n";b.ShaderChunk.lights_lambert_vertex=
"vec3 diffuse = vec3( 1.0 );\nGeometricContext geometry;\ngeometry.position = mvPosition.xyz;\ngeometry.normal = normalize( transformedNormal );\ngeometry.viewDir = normalize( -mvPosition.xyz );\nGeometricContext backGeometry;\nbackGeometry.position = geometry.position;\nbackGeometry.normal = -geometry.normal;\nbackGeometry.viewDir = geometry.viewDir;\nvLightFront = vec3( 0.0 );\n#ifdef DOUBLE_SIDED\n\tvLightBack = vec3( 0.0 );\n#endif\nIncidentLight directLight;\nfloat dotNL;\nvec3 directLightColor_Diffuse;\n#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tgetPointDirectLightIrradiance( pointLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tgetSpotDirectLightIrradiance( spotLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tgetDirectionalDirectLightIrradiance( directionalLights[ i ], geometry, directLight );\n\t\tdotNL = dot( geometry.normal, directLight.direction );\n\t\tdirectLightColor_Diffuse = PI * directLight.color;\n\t\tvLightFront += saturate( dotNL ) * directLightColor_Diffuse;\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += saturate( -dotNL ) * directLightColor_Diffuse;\n\t\t#endif\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_HEMI_LIGHTS; i ++ ) {\n\t\tvLightFront += getHemisphereLightIrradiance( hemisphereLights[ i ], geometry );\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tvLightBack += getHemisphereLightIrradiance( hemisphereLights[ i ], backGeometry );\n\t\t#endif\n\t}\n#endif\n";
b.ShaderChunk.lightmap_pars_fragment="#ifdef USE_LIGHTMAP\n\tuniform sampler2D lightMap;\n\tuniform float lightMapIntensity;\n#endif";b.ShaderChunk.lights_pars="uniform vec3 ambientLightColor;\nvec3 getAmbientLightIrradiance( const in vec3 ambientLightColor ) {\n\tvec3 irradiance = ambientLightColor;\n\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\tirradiance *= PI;\n\t#endif\n\treturn irradiance;\n}\n#if NUM_DIR_LIGHTS > 0\n\tstruct DirectionalLight {\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform DirectionalLight directionalLights[ NUM_DIR_LIGHTS ];\n\tvoid getDirectionalDirectLightIrradiance( const in DirectionalLight directionalLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tdirectLight.color = directionalLight.color;\n\t\tdirectLight.direction = directionalLight.direction;\n\t\tdirectLight.visible = true;\n\t}\n#endif\n#if NUM_POINT_LIGHTS > 0\n\tstruct PointLight {\n\t\tvec3 position;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform PointLight pointLights[ NUM_POINT_LIGHTS ];\n\tvoid getPointDirectLightIrradiance( const in PointLight pointLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = pointLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tif ( testLightInRange( lightDistance, pointLight.distance ) ) {\n\t\t\tdirectLight.color = pointLight.color;\n\t\t\tdirectLight.color *= punctualLightIntensityToIrradianceFactor( lightDistance, pointLight.distance, pointLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_SPOT_LIGHTS > 0\n\tstruct SpotLight {\n\t\tvec3 position;\n\t\tvec3 direction;\n\t\tvec3 color;\n\t\tfloat distance;\n\t\tfloat decay;\n\t\tfloat coneCos;\n\t\tfloat penumbraCos;\n\t\tint shadow;\n\t\tfloat shadowBias;\n\t\tfloat shadowRadius;\n\t\tvec2 shadowMapSize;\n\t};\n\tuniform SpotLight spotLights[ NUM_SPOT_LIGHTS ];\n\tvoid getSpotDirectLightIrradiance( const in SpotLight spotLight, const in GeometricContext geometry, out IncidentLight directLight ) {\n\t\tvec3 lVector = spotLight.position - geometry.position;\n\t\tdirectLight.direction = normalize( lVector );\n\t\tfloat lightDistance = length( lVector );\n\t\tfloat angleCos = dot( directLight.direction, spotLight.direction );\n\t\tif ( all( bvec2( angleCos > spotLight.coneCos, testLightInRange( lightDistance, spotLight.distance ) ) ) ) {\n\t\t\tfloat spotEffect = smoothstep( spotLight.coneCos, spotLight.penumbraCos, angleCos );\n\t\t\tdirectLight.color = spotLight.color;\n\t\t\tdirectLight.color *= spotEffect * punctualLightIntensityToIrradianceFactor( lightDistance, spotLight.distance, spotLight.decay );\n\t\t\tdirectLight.visible = true;\n\t\t} else {\n\t\t\tdirectLight.color = vec3( 0.0 );\n\t\t\tdirectLight.visible = false;\n\t\t}\n\t}\n#endif\n#if NUM_HEMI_LIGHTS > 0\n\tstruct HemisphereLight {\n\t\tvec3 direction;\n\t\tvec3 skyColor;\n\t\tvec3 groundColor;\n\t};\n\tuniform HemisphereLight hemisphereLights[ NUM_HEMI_LIGHTS ];\n\tvec3 getHemisphereLightIrradiance( const in HemisphereLight hemiLight, const in GeometricContext geometry ) {\n\t\tfloat dotNL = dot( geometry.normal, hemiLight.direction );\n\t\tfloat hemiDiffuseWeight = 0.5 * dotNL + 0.5;\n\t\tvec3 irradiance = mix( hemiLight.groundColor, hemiLight.skyColor, hemiDiffuseWeight );\n\t\t#ifndef PHYSICALLY_CORRECT_LIGHTS\n\t\t\tirradiance *= PI;\n\t\t#endif\n\t\treturn irradiance;\n\t}\n#endif\n#if defined( USE_ENVMAP ) && defined( PHYSICAL )\n\tvec3 getLightProbeIndirectIrradiance( const in GeometricContext geometry, const in int maxMIPLevel ) {\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tfloat flipNormal = 1.0;\n\t\t#endif\n\t\tvec3 worldNormal = inverseTransformDirection( geometry.normal, viewMatrix );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryVec, float( maxMIPLevel ) );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryVec = flipNormal * vec3( flipEnvMap * worldNormal.x, worldNormal.yz );\n\t\t\tvec4 envMapColor = textureCubeUV( queryVec, 1.0 );\n\t\t#else\n\t\t\tvec4 envMapColor = vec4( 0.0 );\n\t\t#endif\n\t\treturn PI * envMapColor.rgb * envMapIntensity;\n\t}\n\tfloat getSpecularMIPLevel( const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\tfloat maxMIPLevelScalar = float( maxMIPLevel );\n\t\tfloat desiredMIPLevel = maxMIPLevelScalar - 0.79248 - 0.5 * log2( pow2( blinnShininessExponent ) + 1.0 );\n\t\treturn clamp( desiredMIPLevel, 0.0, maxMIPLevelScalar );\n\t}\n\tvec3 getLightProbeIndirectRadiance( const in GeometricContext geometry, const in float blinnShininessExponent, const in int maxMIPLevel ) {\n\t\t#ifdef ENVMAP_MODE_REFLECTION\n\t\t\tvec3 reflectVec = reflect( -geometry.viewDir, geometry.normal );\n\t\t#else\n\t\t\tvec3 reflectVec = refract( -geometry.viewDir, geometry.normal, refractionRatio );\n\t\t#endif\n\t\t#ifdef DOUBLE_SIDED\n\t\t\tfloat flipNormal = ( float( gl_FrontFacing ) * 2.0 - 1.0 );\n\t\t#else\n\t\t\tfloat flipNormal = 1.0;\n\t\t#endif\n\t\treflectVec = inverseTransformDirection( reflectVec, viewMatrix );\n\t\tfloat specularMIPLevel = getSpecularMIPLevel( blinnShininessExponent, maxMIPLevel );\n\t\t#ifdef ENVMAP_TYPE_CUBE\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = textureCubeLodEXT( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = textureCube( envMap, queryReflectVec, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_CUBE_UV )\n\t\t\tvec3 queryReflectVec = flipNormal * vec3( flipEnvMap * reflectVec.x, reflectVec.yz );\n\t\t\tvec4 envMapColor = textureCubeUV(queryReflectVec, BlinnExponentToGGXRoughness(blinnShininessExponent));\n\t\t#elif defined( ENVMAP_TYPE_EQUIREC )\n\t\t\tvec2 sampleUV;\n\t\t\tsampleUV.y = saturate( flipNormal * reflectVec.y * 0.5 + 0.5 );\n\t\t\tsampleUV.x = atan( flipNormal * reflectVec.z, flipNormal * reflectVec.x ) * RECIPROCAL_PI2 + 0.5;\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, sampleUV, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, sampleUV, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#elif defined( ENVMAP_TYPE_SPHERE )\n\t\t\tvec3 reflectView = flipNormal * normalize((viewMatrix * vec4( reflectVec, 0.0 )).xyz + vec3(0.0,0.0,1.0));\n\t\t\t#ifdef TEXTURE_LOD_EXT\n\t\t\t\tvec4 envMapColor = texture2DLodEXT( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#else\n\t\t\t\tvec4 envMapColor = texture2D( envMap, reflectView.xy * 0.5 + 0.5, specularMIPLevel );\n\t\t\t#endif\n\t\t\tenvMapColor.rgb = envMapTexelToLinear( envMapColor ).rgb;\n\t\t#endif\n\t\treturn envMapColor.rgb * envMapIntensity;\n\t}\n#endif\n";
b.ShaderChunk.lightmap_fragment="#ifdef USE_LIGHTMAP\n\treflectedLight.indirectDiffuse += PI * texture2D( lightMap, vUv2 ).xyz * lightMapIntensity;\n#endif\n";b.ShaderChunk.logdepthbuf_pars_vertex="#ifdef USE_LOGDEPTHBUF\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n\tuniform float logDepthBufFC;\n#endif";b.ShaderChunk.logdepthbuf_vertex="#ifdef USE_LOGDEPTHBUF\n\tgl_Position.z = log2(max( EPSILON, gl_Position.w + 1.0 )) * logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvFragDepth = 1.0 + gl_Position.w;\n\t#else\n\t\tgl_Position.z = (gl_Position.z - 1.0) * gl_Position.w;\n\t#endif\n#endif\n";
b.ShaderChunk.logdepthbuf_fragment="#if defined(USE_LOGDEPTHBUF) && defined(USE_LOGDEPTHBUF_EXT)\n\tgl_FragDepthEXT = log2(vFragDepth) * logDepthBufFC * 0.5;\n#endif";b.ShaderChunk.logdepthbuf_pars_fragment="#ifdef USE_LOGDEPTHBUF\n\tuniform float logDepthBufFC;\n\t#ifdef USE_LOGDEPTHBUF_EXT\n\t\tvarying float vFragDepth;\n\t#endif\n#endif\n";b.ShaderChunk.packing="vec3 packNormalToRGB( const in vec3 normal ) {\n return normalize( normal ) * 0.5 + 0.5;\n}\nvec3 unpackRGBToNormal( const in vec3 rgb ) {\n return 1.0 - 2.0 * rgb.xyz;\n}\nvec4 packDepthToRGBA( const in float value ) {\n\tconst vec4 bit_shift = vec4( 256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0 );\n\tconst vec4 bit_mask = vec4( 0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0 );\n\tvec4 res = mod( value * bit_shift * vec4( 255 ), vec4( 256 ) ) / vec4( 255 );\n\tres -= res.xxyz * bit_mask;\n\treturn res;\n}\nfloat unpackRGBAToDepth( const in vec4 rgba ) {\n\tconst vec4 bitSh = vec4( 1.0 / ( 256.0 * 256.0 * 256.0 ), 1.0 / ( 256.0 * 256.0 ), 1.0 / 256.0, 1.0 );\n\treturn dot( rgba, bitSh );\n}\nfloat viewZToOrthoDepth( const in float viewZ, const in float near, const in float far ) {\n return ( viewZ + near ) / ( near - far );\n}\nfloat OrthoDepthToViewZ( const in float linearClipZ, const in float near, const in float far ) {\n return linearClipZ * ( near - far ) - near;\n}\nfloat viewZToPerspectiveDepth( const in float viewZ, const in float near, const in float far ) {\n return (( near + viewZ ) * far ) / (( far - near ) * viewZ );\n}\nfloat perspectiveDepthToViewZ( const in float invClipZ, const in float near, const in float far ) {\n return ( near * far ) / ( ( far - near ) * invClipZ - far );\n}\n";
b.ShaderChunk.premultiplied_alpha_fragment="#ifdef PREMULTIPLIED_ALPHA\n\tgl_FragColor.rgb *= gl_FragColor.a;\n#endif\n";b.ShaderChunk.shadowmap_pars_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform mat4 directionalShadowMatrix[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform mat4 spotShadowMatrix[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform mat4 pointShadowMatrix[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n#endif\n";
b.ShaderChunk.shadowmap_vertex="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tvDirectionalShadowCoord[ i ] = directionalShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tvSpotShadowCoord[ i ] = spotShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tvPointShadowCoord[ i ] = pointShadowMatrix[ i ] * worldPosition;\n\t}\n\t#endif\n#endif\n";
b.ShaderChunk.shadowmap_pars_fragment="#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\t\tuniform sampler2D directionalShadowMap[ NUM_DIR_LIGHTS ];\n\t\tvarying vec4 vDirectionalShadowCoord[ NUM_DIR_LIGHTS ];\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\t\tuniform sampler2D spotShadowMap[ NUM_SPOT_LIGHTS ];\n\t\tvarying vec4 vSpotShadowCoord[ NUM_SPOT_LIGHTS ];\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\t\tuniform sampler2D pointShadowMap[ NUM_POINT_LIGHTS ];\n\t\tvarying vec4 vPointShadowCoord[ NUM_POINT_LIGHTS ];\n\t#endif\n\tfloat texture2DCompare( sampler2D depths, vec2 uv, float compare ) {\n\t\treturn step( compare, unpackRGBAToDepth( texture2D( depths, uv ) ) );\n\t}\n\tfloat texture2DShadowLerp( sampler2D depths, vec2 size, vec2 uv, float compare ) {\n\t\tconst vec2 offset = vec2( 0.0, 1.0 );\n\t\tvec2 texelSize = vec2( 1.0 ) / size;\n\t\tvec2 centroidUV = floor( uv * size + 0.5 ) / size;\n\t\tfloat lb = texture2DCompare( depths, centroidUV + texelSize * offset.xx, compare );\n\t\tfloat lt = texture2DCompare( depths, centroidUV + texelSize * offset.xy, compare );\n\t\tfloat rb = texture2DCompare( depths, centroidUV + texelSize * offset.yx, compare );\n\t\tfloat rt = texture2DCompare( depths, centroidUV + texelSize * offset.yy, compare );\n\t\tvec2 f = fract( uv * size + 0.5 );\n\t\tfloat a = mix( lb, lt, f.y );\n\t\tfloat b = mix( rb, rt, f.y );\n\t\tfloat c = mix( a, b, f.x );\n\t\treturn c;\n\t}\n\tfloat getShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tshadowCoord.xyz /= shadowCoord.w;\n\t\tshadowCoord.z += shadowBias;\n\t\tbvec4 inFrustumVec = bvec4 ( shadowCoord.x >= 0.0, shadowCoord.x <= 1.0, shadowCoord.y >= 0.0, shadowCoord.y <= 1.0 );\n\t\tbool inFrustum = all( inFrustumVec );\n\t\tbvec2 frustumTestVec = bvec2( inFrustum, shadowCoord.z <= 1.0 );\n\t\tbool frustumTest = all( frustumTestVec );\n\t\tif ( frustumTest ) {\n\t\t#if defined( SHADOWMAP_TYPE_PCF )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DCompare( shadowMap, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#elif defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 texelSize = vec2( 1.0 ) / shadowMapSize;\n\t\t\tfloat dx0 = - texelSize.x * shadowRadius;\n\t\t\tfloat dy0 = - texelSize.y * shadowRadius;\n\t\t\tfloat dx1 = + texelSize.x * shadowRadius;\n\t\t\tfloat dy1 = + texelSize.y * shadowRadius;\n\t\t\treturn (\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy, shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, 0.0 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( 0.0, dy1 ), shadowCoord.z ) +\n\t\t\t\ttexture2DShadowLerp( shadowMap, shadowMapSize, shadowCoord.xy + vec2( dx1, dy1 ), shadowCoord.z )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, shadowCoord.xy, shadowCoord.z );\n\t\t#endif\n\t\t}\n\t\treturn 1.0;\n\t}\n\tvec2 cubeToUV( vec3 v, float texelSizeY ) {\n\t\tvec3 absV = abs( v );\n\t\tfloat scaleToCube = 1.0 / max( absV.x, max( absV.y, absV.z ) );\n\t\tabsV *= scaleToCube;\n\t\tv *= scaleToCube * ( 1.0 - 2.0 * texelSizeY );\n\t\tvec2 planar = v.xy;\n\t\tfloat almostATexel = 1.5 * texelSizeY;\n\t\tfloat almostOne = 1.0 - almostATexel;\n\t\tif ( absV.z >= almostOne ) {\n\t\t\tif ( v.z > 0.0 )\n\t\t\t\tplanar.x = 4.0 - v.x;\n\t\t} else if ( absV.x >= almostOne ) {\n\t\t\tfloat signX = sign( v.x );\n\t\t\tplanar.x = v.z * signX + 2.0 * signX;\n\t\t} else if ( absV.y >= almostOne ) {\n\t\t\tfloat signY = sign( v.y );\n\t\t\tplanar.x = v.x + 2.0 * signY + 2.0;\n\t\t\tplanar.y = v.z * signY - 2.0;\n\t\t}\n\t\treturn vec2( 0.125, 0.25 ) * planar + vec2( 0.375, 0.75 );\n\t}\n\tfloat getPointShadow( sampler2D shadowMap, vec2 shadowMapSize, float shadowBias, float shadowRadius, vec4 shadowCoord ) {\n\t\tvec2 texelSize = vec2( 1.0 ) / ( shadowMapSize * vec2( 4.0, 2.0 ) );\n\t\tvec3 lightToPosition = shadowCoord.xyz;\n\t\tvec3 bd3D = normalize( lightToPosition );\n\t\tfloat dp = ( length( lightToPosition ) - shadowBias ) / 1000.0;\n\t\t#if defined( SHADOWMAP_TYPE_PCF ) || defined( SHADOWMAP_TYPE_PCF_SOFT )\n\t\t\tvec2 offset = vec2( - 1, 1 ) * shadowRadius * texelSize.y;\n\t\t\treturn (\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yyx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxy, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.xxx, texelSize.y ), dp ) +\n\t\t\t\ttexture2DCompare( shadowMap, cubeToUV( bd3D + offset.yxx, texelSize.y ), dp )\n\t\t\t) * ( 1.0 / 9.0 );\n\t\t#else\n\t\t\treturn texture2DCompare( shadowMap, cubeToUV( bd3D, texelSize.y ), dp );\n\t\t#endif\n\t}\n#endif\n";
b.ShaderChunk.shadowmask_pars_fragment="float getShadowMask() {\n\tfloat shadow = 1.0;\n\t#ifdef USE_SHADOWMAP\n\t#if NUM_DIR_LIGHTS > 0\n\tDirectionalLight directionalLight;\n\tfor ( int i = 0; i < NUM_DIR_LIGHTS; i ++ ) {\n\t\tdirectionalLight = directionalLights[ i ];\n\t\tshadow *= bool( directionalLight.shadow ) ? getShadow( directionalShadowMap[ i ], directionalLight.shadowMapSize, directionalLight.shadowBias, directionalLight.shadowRadius, vDirectionalShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_SPOT_LIGHTS > 0\n\tSpotLight spotLight;\n\tfor ( int i = 0; i < NUM_SPOT_LIGHTS; i ++ ) {\n\t\tspotLight = spotLights[ i ];\n\t\tshadow *= bool( spotLight.shadow ) ? getShadow( spotShadowMap[ i ], spotLight.shadowMapSize, spotLight.shadowBias, spotLight.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#if NUM_POINT_LIGHTS > 0\n\tPointLight pointLight;\n\tfor ( int i = 0; i < NUM_POINT_LIGHTS; i ++ ) {\n\t\tpointLight = pointLights[ i ];\n\t\tshadow *= bool( pointLight.shadow ) ? getPointShadow( pointShadowMap[ i ], pointLight.shadowMapSize, pointLight.shadowBias, pointLight.shadowRadius, vPointShadowCoord[ i ] ) : 1.0;\n\t}\n\t#endif\n\t#endif\n\treturn shadow;\n}\n";
b.ShaderChunk.skinning_pars_vertex="#ifdef USE_SKINNING\n\tuniform mat4 bindMatrix;\n\tuniform mat4 bindMatrixInverse;\n\t#ifdef BONE_TEXTURE\n\t\tuniform sampler2D boneTexture;\n\t\tuniform int boneTextureWidth;\n\t\tuniform int boneTextureHeight;\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tfloat j = i * 4.0;\n\t\t\tfloat x = mod( j, float( boneTextureWidth ) );\n\t\t\tfloat y = floor( j / float( boneTextureWidth ) );\n\t\t\tfloat dx = 1.0 / float( boneTextureWidth );\n\t\t\tfloat dy = 1.0 / float( boneTextureHeight );\n\t\t\ty = dy * ( y + 0.5 );\n\t\t\tvec4 v1 = texture2D( boneTexture, vec2( dx * ( x + 0.5 ), y ) );\n\t\t\tvec4 v2 = texture2D( boneTexture, vec2( dx * ( x + 1.5 ), y ) );\n\t\t\tvec4 v3 = texture2D( boneTexture, vec2( dx * ( x + 2.5 ), y ) );\n\t\t\tvec4 v4 = texture2D( boneTexture, vec2( dx * ( x + 3.5 ), y ) );\n\t\t\tmat4 bone = mat4( v1, v2, v3, v4 );\n\t\t\treturn bone;\n\t\t}\n\t#else\n\t\tuniform mat4 boneMatrices[ MAX_BONES ];\n\t\tmat4 getBoneMatrix( const in float i ) {\n\t\t\tmat4 bone = boneMatrices[ int(i) ];\n\t\t\treturn bone;\n\t\t}\n\t#endif\n#endif\n";
b.ShaderChunk.skinning_vertex="#ifdef USE_SKINNING\n\tvec4 skinVertex = bindMatrix * vec4( transformed, 1.0 );\n\tvec4 skinned = vec4( 0.0 );\n\tskinned += boneMatX * skinVertex * skinWeight.x;\n\tskinned += boneMatY * skinVertex * skinWeight.y;\n\tskinned += boneMatZ * skinVertex * skinWeight.z;\n\tskinned += boneMatW * skinVertex * skinWeight.w;\n\tskinned = bindMatrixInverse * skinned;\n#endif\n";b.ShaderChunk.skinbase_vertex="#ifdef USE_SKINNING\n\tmat4 boneMatX = getBoneMatrix( skinIndex.x );\n\tmat4 boneMatY = getBoneMatrix( skinIndex.y );\n\tmat4 boneMatZ = getBoneMatrix( skinIndex.z );\n\tmat4 boneMatW = getBoneMatrix( skinIndex.w );\n#endif";
b.ShaderChunk.skinnormal_vertex="#ifdef USE_SKINNING\n\tmat4 skinMatrix = mat4( 0.0 );\n\tskinMatrix += skinWeight.x * boneMatX;\n\tskinMatrix += skinWeight.y * boneMatY;\n\tskinMatrix += skinWeight.z * boneMatZ;\n\tskinMatrix += skinWeight.w * boneMatW;\n\tskinMatrix = bindMatrixInverse * skinMatrix * bindMatrix;\n\tobjectNormal = vec4( skinMatrix * vec4( objectNormal, 0.0 ) ).xyz;\n#endif\n";b.ShaderChunk.specularmap_fragment="float specularStrength;\n#ifdef USE_SPECULARMAP\n\tvec4 texelSpecular = texture2D( specularMap, vUv );\n\tspecularStrength = texelSpecular.r;\n#else\n\tspecularStrength = 1.0;\n#endif";
b.ShaderChunk.specularmap_pars_fragment="#ifdef USE_SPECULARMAP\n\tuniform sampler2D specularMap;\n#endif";b.ShaderChunk.defaultnormal_vertex="#ifdef FLIP_SIDED\n\tobjectNormal = -objectNormal;\n#endif\nvec3 transformedNormal = normalMatrix * objectNormal;\n";b.ShaderChunk.begin_vertex="\nvec3 transformed = vec3( position );\n";b.ShaderChunk.project_vertex="#ifdef USE_SKINNING\n\tvec4 mvPosition = modelViewMatrix * skinned;\n#else\n\tvec4 mvPosition = modelViewMatrix * vec4( transformed, 1.0 );\n#endif\ngl_Position = projectionMatrix * mvPosition;\n";
b.ShaderChunk.worldpos_vertex="#if defined( USE_ENVMAP ) || defined( PHONG ) || defined( PHYSICAL ) || defined( LAMBERT ) || defined ( USE_SHADOWMAP )\n\t#ifdef USE_SKINNING\n\t\tvec4 worldPosition = modelMatrix * skinned;\n\t#else\n\t\tvec4 worldPosition = modelMatrix * vec4( transformed, 1.0 );\n\t#endif\n#endif\n";b.ShaderChunk.tonemapping_fragment="#if defined( TONE_MAPPING )\n gl_FragColor.rgb = toneMapping( gl_FragColor.rgb );\n#endif\n";b.ShaderChunk.tonemapping_pars_fragment="#define saturate(a) clamp( a, 0.0, 1.0 )\nuniform float toneMappingExposure;\nuniform float toneMappingWhitePoint;\nvec3 LinearToneMapping( vec3 color ) {\n return toneMappingExposure * color;\n}\nvec3 ReinhardToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( color / ( vec3( 1.0 ) + color ) );\n}\n#define Uncharted2Helper( x ) max( ( ( x * ( 0.15 * x + 0.10 * 0.50 ) + 0.20 * 0.02 ) / ( x * ( 0.15 * x + 0.50 ) + 0.20 * 0.30 ) ) - 0.02 / 0.30, vec3( 0.0 ) )\nvec3 Uncharted2ToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n return saturate( Uncharted2Helper( color ) / Uncharted2Helper( vec3( toneMappingWhitePoint ) ) );\n}\nvec3 OptimizedCineonToneMapping( vec3 color ) {\n color *= toneMappingExposure;\n color = max( vec3( 0.0 ), color - 0.004 );\n return pow( ( color * ( 6.2 * color + 0.5 ) ) / ( color * ( 6.2 * color + 1.7 ) + 0.06 ), vec3( 2.2 ) );\n}\n";
b.UniformsUtils={merge:function(a){for(var b={},d=0;d<a.length;d++){var e=this.clone(a[d]),f;for(f in e)b[f]=e[f]}return b},clone:function(a){var c={},d;for(d in a){c[d]={};for(var e in a[d]){var f=a[d][e];f instanceof b.Color||f instanceof b.Vector2||f instanceof b.Vector3||f instanceof b.Vector4||f instanceof b.Matrix3||f instanceof b.Matrix4||f instanceof b.Texture?c[d][e]=f.clone():Array.isArray(f)?c[d][e]=f.slice():c[d][e]=f}}return c}};b.UniformsLib={common:{diffuse:{type:"c",value:new b.Color(15658734)},
opacity:{type:"1f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new b.Vector4(0,0,1,1)},specularMap:{type:"t",value:null},alphaMap:{type:"t",value:null},envMap:{type:"t",value:null},flipEnvMap:{type:"1f",value:-1},reflectivity:{type:"1f",value:1},refractionRatio:{type:"1f",value:.98}},aomap:{aoMap:{type:"t",value:null},aoMapIntensity:{type:"1f",value:1}},lightmap:{lightMap:{type:"t",value:null},lightMapIntensity:{type:"1f",value:1}},emissivemap:{emissiveMap:{type:"t",value:null}},
bumpmap:{bumpMap:{type:"t",value:null},bumpScale:{type:"1f",value:1}},normalmap:{normalMap:{type:"t",value:null},normalScale:{type:"v2",value:new b.Vector2(1,1)}},displacementmap:{displacementMap:{type:"t",value:null},displacementScale:{type:"1f",value:1},displacementBias:{type:"1f",value:0}},roughnessmap:{roughnessMap:{type:"t",value:null}},metalnessmap:{metalnessMap:{type:"t",value:null}},fog:{fogDensity:{type:"1f",value:2.5E-4},fogNear:{type:"1f",value:1},fogFar:{type:"1f",value:2E3},fogColor:{type:"c",
value:new b.Color(16777215)}},lights:{ambientLightColor:{type:"3fv",value:[]},directionalLights:{type:"sa",value:[],properties:{direction:{type:"v3"},color:{type:"c"},shadow:{type:"1i"},shadowBias:{type:"1f"},shadowRadius:{type:"1f"},shadowMapSize:{type:"v2"}}},directionalShadowMap:{type:"tv",value:[]},directionalShadowMatrix:{type:"m4v",value:[]},spotLights:{type:"sa",value:[],properties:{color:{type:"c"},position:{type:"v3"},direction:{type:"v3"},distance:{type:"1f"},coneCos:{type:"1f"},penumbraCos:{type:"1f"},
decay:{type:"1f"},shadow:{type:"1i"},shadowBias:{type:"1f"},shadowRadius:{type:"1f"},shadowMapSize:{type:"v2"}}},spotShadowMap:{type:"tv",value:[]},spotShadowMatrix:{type:"m4v",value:[]},pointLights:{type:"sa",value:[],properties:{color:{type:"c"},position:{type:"v3"},decay:{type:"1f"},distance:{type:"1f"},shadow:{type:"1i"},shadowBias:{type:"1f"},shadowRadius:{type:"1f"},shadowMapSize:{type:"v2"}}},pointShadowMap:{type:"tv",value:[]},pointShadowMatrix:{type:"m4v",value:[]},hemisphereLights:{type:"sa",
value:[],properties:{direction:{type:"v3"},skyColor:{type:"c"},groundColor:{type:"c"}}}},points:{diffuse:{type:"c",value:new b.Color(15658734)},opacity:{type:"1f",value:1},size:{type:"1f",value:1},scale:{type:"1f",value:1},map:{type:"t",value:null},offsetRepeat:{type:"v4",value:new b.Vector4(0,0,1,1)}}};b.ShaderChunk.cube_frag="uniform samplerCube tCube;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tgl_FragColor = textureCube( tCube, vec3( tFlip * vWorldPosition.x, vWorldPosition.yz ) );\n\t#include <logdepthbuf_fragment>\n}\n";
b.ShaderChunk.cube_vert="varying vec3 vWorldPosition;\n#include <common>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n";b.ShaderChunk.depth_frag="#if DEPTH_PACKING == 3200\n\tuniform float opacity;\n#endif\n#include <common>\n#include <packing>\n#include <uv_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( 1.0 );\n\t#if DEPTH_PACKING == 3200\n\t\tdiffuseColor.a = opacity;\n\t#endif\n\t#include <map_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <logdepthbuf_fragment>\n\t#if DEPTH_PACKING == 3200\n\t\tgl_FragColor = vec4( vec3( gl_FragCoord.z ), opacity );\n\t#elif DEPTH_PACKING == 3201\n\t\tgl_FragColor = packDepthToRGBA( gl_FragCoord.z );\n\t#endif\n}\n";
b.ShaderChunk.depth_vert="#include <common>\n#include <uv_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <skinbase_vertex>\n\t#include <begin_vertex>\n\t#include <displacementmap_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n";
b.ShaderChunk.distanceRGBA_frag="uniform vec3 lightPos;\nvarying vec4 vWorldPosition;\n#include <common>\n#include <packing>\n#include <clipping_planes_pars_fragment>\nvoid main () {\n\t#include <clipping_planes_fragment>\n\tgl_FragColor = packDepthToRGBA( length( vWorldPosition.xyz - lightPos.xyz ) / 1000.0 );\n}\n";b.ShaderChunk.distanceRGBA_vert="varying vec4 vWorldPosition;\n#include <common>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <skinbase_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\tvWorldPosition = worldPosition;\n}\n";
b.ShaderChunk.equirect_frag="uniform sampler2D tEquirect;\nuniform float tFlip;\nvarying vec3 vWorldPosition;\n#include <common>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 direction = normalize( vWorldPosition );\n\tvec2 sampleUV;\n\tsampleUV.y = saturate( tFlip * direction.y * -0.5 + 0.5 );\n\tsampleUV.x = atan( direction.z, direction.x ) * RECIPROCAL_PI2 + 0.5;\n\tgl_FragColor = texture2D( tEquirect, sampleUV );\n\t#include <logdepthbuf_fragment>\n}\n";
b.ShaderChunk.equirect_vert="varying vec3 vWorldPosition;\n#include <common>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvWorldPosition = transformDirection( position, modelMatrix );\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n";b.ShaderChunk.linedashed_frag="uniform vec3 diffuse;\nuniform float opacity;\nuniform float dashSize;\nuniform float totalSize;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_fragment>\n#include <fog_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tif ( mod( vLineDistance, totalSize ) > dashSize ) {\n\t\tdiscard;\n\t}\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <color_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
b.ShaderChunk.linedashed_vert="uniform float scale;\nattribute float lineDistance;\nvarying float vLineDistance;\n#include <common>\n#include <color_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\tvLineDistance = scale * lineDistance;\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n";
b.ShaderChunk.meshbasic_frag="uniform vec3 diffuse;\nuniform float opacity;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\tReflectedLight reflectedLight;\n\treflectedLight.directDiffuse = vec3( 0.0 );\n\treflectedLight.directSpecular = vec3( 0.0 );\n\treflectedLight.indirectDiffuse = diffuseColor.rgb;\n\treflectedLight.indirectSpecular = vec3( 0.0 );\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.indirectDiffuse;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
b.ShaderChunk.meshbasic_vert="#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <skinbase_vertex>\n\t#ifdef USE_ENVMAP\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#endif\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <worldpos_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <envmap_vertex>\n}\n";
b.ShaderChunk.meshlambert_frag="uniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float opacity;\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <shadowmask_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <emissivemap_fragment>\n\treflectedLight.indirectDiffuse = getAmbientLightIrradiance( ambientLightColor );\n\t#include <lightmap_fragment>\n\treflectedLight.indirectDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb );\n\t#ifdef DOUBLE_SIDED\n\t\treflectedLight.directDiffuse = ( gl_FrontFacing ) ? vLightFront : vLightBack;\n\t#else\n\t\treflectedLight.directDiffuse = vLightFront;\n\t#endif\n\treflectedLight.directDiffuse *= BRDF_Diffuse_Lambert( diffuseColor.rgb ) * getShadowMask();\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
b.ShaderChunk.meshlambert_vert="#define LAMBERT\nvarying vec3 vLightFront;\n#ifdef DOUBLE_SIDED\n\tvarying vec3 vLightBack;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <envmap_pars_vertex>\n#include <bsdfs>\n#include <lights_pars>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <lights_lambert_vertex>\n\t#include <shadowmap_vertex>\n}\n";
b.ShaderChunk.meshphong_frag="#define PHONG\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform vec3 specular;\nuniform float shininess;\nuniform float opacity;\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <lights_pars>\n#include <lights_phong_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_phong_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\t#include <envmap_fragment>\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
b.ShaderChunk.meshphong_vert="#define PHONG\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <envmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <displacementmap_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <envmap_vertex>\n\t#include <shadowmap_vertex>\n}\n";
b.ShaderChunk.meshphysical_frag="#define PHYSICAL\nuniform vec3 diffuse;\nuniform vec3 emissive;\nuniform float roughness;\nuniform float metalness;\nuniform float opacity;\nuniform float envMapIntensity;\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <packing>\n#include <color_pars_fragment>\n#include <uv_pars_fragment>\n#include <uv2_pars_fragment>\n#include <map_pars_fragment>\n#include <alphamap_pars_fragment>\n#include <aomap_pars_fragment>\n#include <lightmap_pars_fragment>\n#include <emissivemap_pars_fragment>\n#include <envmap_pars_fragment>\n#include <fog_pars_fragment>\n#include <bsdfs>\n#include <cube_uv_reflection_fragment>\n#include <lights_pars>\n#include <lights_physical_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <bumpmap_pars_fragment>\n#include <normalmap_pars_fragment>\n#include <roughnessmap_pars_fragment>\n#include <metalnessmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\tReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );\n\tvec3 totalEmissiveRadiance = emissive;\n\t#include <logdepthbuf_fragment>\n\t#include <map_fragment>\n\t#include <color_fragment>\n\t#include <alphamap_fragment>\n\t#include <alphatest_fragment>\n\t#include <specularmap_fragment>\n\t#include <roughnessmap_fragment>\n\t#include <metalnessmap_fragment>\n\t#include <normal_fragment>\n\t#include <emissivemap_fragment>\n\t#include <lights_physical_fragment>\n\t#include <lights_template>\n\t#include <aomap_fragment>\n\tvec3 outgoingLight = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse + reflectedLight.directSpecular + reflectedLight.indirectSpecular + totalEmissiveRadiance;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
b.ShaderChunk.meshphysical_vert="#define PHYSICAL\nvarying vec3 vViewPosition;\n#ifndef FLAT_SHADED\n\tvarying vec3 vNormal;\n#endif\n#include <common>\n#include <uv_pars_vertex>\n#include <uv2_pars_vertex>\n#include <displacementmap_pars_vertex>\n#include <color_pars_vertex>\n#include <morphtarget_pars_vertex>\n#include <skinning_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <specularmap_pars_fragment>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <uv_vertex>\n\t#include <uv2_vertex>\n\t#include <color_vertex>\n\t#include <beginnormal_vertex>\n\t#include <morphnormal_vertex>\n\t#include <skinbase_vertex>\n\t#include <skinnormal_vertex>\n\t#include <defaultnormal_vertex>\n#ifndef FLAT_SHADED\n\tvNormal = normalize( transformedNormal );\n#endif\n\t#include <begin_vertex>\n\t#include <displacementmap_vertex>\n\t#include <morphtarget_vertex>\n\t#include <skinning_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\tvViewPosition = - mvPosition.xyz;\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n}\n";
b.ShaderChunk.normal_frag="uniform float opacity;\nvarying vec3 vNormal;\n#include <common>\n#include <packing>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tgl_FragColor = vec4( packNormalToRGB( vNormal ), opacity );\n\t#include <logdepthbuf_fragment>\n}\n";b.ShaderChunk.normal_vert="varying vec3 vNormal;\n#include <common>\n#include <morphtarget_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\tvNormal = normalize( normalMatrix * normal );\n\t#include <begin_vertex>\n\t#include <morphtarget_vertex>\n\t#include <project_vertex>\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n}\n";
b.ShaderChunk.points_frag="uniform vec3 diffuse;\nuniform float opacity;\n#include <common>\n#include <color_pars_fragment>\n#include <map_particle_pars_fragment>\n#include <fog_pars_fragment>\n#include <shadowmap_pars_fragment>\n#include <logdepthbuf_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t#include <clipping_planes_fragment>\n\tvec3 outgoingLight = vec3( 0.0 );\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t#include <logdepthbuf_fragment>\n\t#include <map_particle_fragment>\n\t#include <color_fragment>\n\t#include <alphatest_fragment>\n\toutgoingLight = diffuseColor.rgb;\n\tgl_FragColor = vec4( outgoingLight, diffuseColor.a );\n\t#include <premultiplied_alpha_fragment>\n\t#include <tonemapping_fragment>\n\t#include <encodings_fragment>\n\t#include <fog_fragment>\n}\n";
b.ShaderChunk.points_vert="uniform float size;\nuniform float scale;\n#include <common>\n#include <color_pars_vertex>\n#include <shadowmap_pars_vertex>\n#include <logdepthbuf_pars_vertex>\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t#include <color_vertex>\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t#ifdef USE_SIZEATTENUATION\n\t\tgl_PointSize = size * ( scale / - mvPosition.z );\n\t#else\n\t\tgl_PointSize = size;\n\t#endif\n\t#include <logdepthbuf_vertex>\n\t#include <clipping_planes_vertex>\n\t#include <worldpos_vertex>\n\t#include <shadowmap_vertex>\n}\n";
b.ShaderLib={basic:{uniforms:b.UniformsUtils.merge([b.UniformsLib.common,b.UniformsLib.aomap,b.UniformsLib.fog]),vertexShader:b.ShaderChunk.meshbasic_vert,fragmentShader:b.ShaderChunk.meshbasic_frag},lambert:{uniforms:b.UniformsUtils.merge([b.UniformsLib.common,b.UniformsLib.aomap,b.UniformsLib.lightmap,b.UniformsLib.emissivemap,b.UniformsLib.fog,b.UniformsLib.lights,{emissive:{type:"c",value:new b.Color(0)}}]),vertexShader:b.ShaderChunk.meshlambert_vert,fragmentShader:b.ShaderChunk.meshlambert_frag},
phong:{uniforms:b.UniformsUtils.merge([b.UniformsLib.common,b.UniformsLib.aomap,b.UniformsLib.lightmap,b.UniformsLib.emissivemap,b.UniformsLib.bumpmap,b.UniformsLib.normalmap,b.UniformsLib.displacementmap,b.UniformsLib.fog,b.UniformsLib.lights,{emissive:{type:"c",value:new b.Color(0)},specular:{type:"c",value:new b.Color(1118481)},shininess:{type:"1f",value:30}}]),vertexShader:b.ShaderChunk.meshphong_vert,fragmentShader:b.ShaderChunk.meshphong_frag},standard:{uniforms:b.UniformsUtils.merge([b.UniformsLib.common,
b.UniformsLib.aomap,b.UniformsLib.lightmap,b.UniformsLib.emissivemap,b.UniformsLib.bumpmap,b.UniformsLib.normalmap,b.UniformsLib.displacementmap,b.UniformsLib.roughnessmap,b.UniformsLib.metalnessmap,b.UniformsLib.fog,b.UniformsLib.lights,{emissive:{type:"c",value:new b.Color(0)},roughness:{type:"1f",value:.5},metalness:{type:"1f",value:0},envMapIntensity:{type:"1f",value:1}}]),vertexShader:b.ShaderChunk.meshphysical_vert,fragmentShader:b.ShaderChunk.meshphysical_frag},points:{uniforms:b.UniformsUtils.merge([b.UniformsLib.points,
b.UniformsLib.fog]),vertexShader:b.ShaderChunk.points_vert,fragmentShader:b.ShaderChunk.points_frag},dashed:{uniforms:b.UniformsUtils.merge([b.UniformsLib.common,b.UniformsLib.fog,{scale:{type:"1f",value:1},dashSize:{type:"1f",value:1},totalSize:{type:"1f",value:2}}]),vertexShader:b.ShaderChunk.linedashed_vert,fragmentShader:b.ShaderChunk.linedashed_frag},depth:{uniforms:b.UniformsUtils.merge([b.UniformsLib.common,b.UniformsLib.displacementmap]),vertexShader:b.ShaderChunk.depth_vert,fragmentShader:b.ShaderChunk.depth_frag},
normal:{uniforms:{opacity:{type:"1f",value:1}},vertexShader:b.ShaderChunk.normal_vert,fragmentShader:b.ShaderChunk.normal_frag},cube:{uniforms:{tCube:{type:"t",value:null},tFlip:{type:"1f",value:-1}},vertexShader:b.ShaderChunk.cube_vert,fragmentShader:b.ShaderChunk.cube_frag},equirect:{uniforms:{tEquirect:{type:"t",value:null},tFlip:{type:"1f",value:-1}},vertexShader:b.ShaderChunk.equirect_vert,fragmentShader:b.ShaderChunk.equirect_frag},distanceRGBA:{uniforms:{lightPos:{type:"v3",value:new b.Vector3}},
vertexShader:b.ShaderChunk.distanceRGBA_vert,fragmentShader:b.ShaderChunk.distanceRGBA_frag}};b.ShaderLib.physical={uniforms:b.UniformsUtils.merge([b.ShaderLib.standard.uniforms,{}]),vertexShader:b.ShaderChunk.meshphysical_vert,fragmentShader:b.ShaderChunk.meshphysical_frag};b.WebGLRenderer=function(a){function c(a,b,c,d){!0===O&&(a*=d,b*=d,c*=d);U.clearColor(a,b,c,d)}function d(){U.init();U.scissor(Ka.copy(la).multiplyScalar(fa));U.viewport(W.copy(ma).multiplyScalar(fa));c(ha.r,ha.g,ha.b,$)}function e(){ya=
qa=null;xa="";oa=-1;U.reset()}function f(a){a.preventDefault();e();d();ga.clear()}function g(a){a=a.target;a.removeEventListener("dispose",g);a:{var b=ga.get(a);if(a.image&&b.__image__webglTextureCube)v.deleteTexture(b.__image__webglTextureCube);else{if(void 0===b.__webglInit)break a;v.deleteTexture(b.__webglTexture)}ga.delete(a)}Ha.textures--}function h(a){a=a.target;a.removeEventListener("dispose",h);var c=ga.get(a),d=ga.get(a.texture);if(a){void 0!==d.__webglTexture&&v.deleteTexture(d.__webglTexture);
a.depthTexture&&a.depthTexture.dispose();if(a instanceof b.WebGLRenderTargetCube)for(d=0;6>d;d++)v.deleteFramebuffer(c.__webglFramebuffer[d]),c.__webglDepthbuffer&&v.deleteRenderbuffer(c.__webglDepthbuffer[d]);else v.deleteFramebuffer(c.__webglFramebuffer),c.__webglDepthbuffer&&v.deleteRenderbuffer(c.__webglDepthbuffer);ga.delete(a.texture);ga.delete(a)}Ha.textures--}function k(a){a=a.target;a.removeEventListener("dispose",k);m(a);ga.delete(a)}function m(a){var b=ga.get(a).program;a.program=void 0;
void 0!==b&&Fa.releaseProgram(b)}function r(a,b){return Math.abs(b[0])-Math.abs(a[0])}function t(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.material.id!==b.material.id?a.material.id-b.material.id:a.z!==b.z?a.z-b.z:a.id-b.id}function x(a,b){return a.object.renderOrder!==b.object.renderOrder?a.object.renderOrder-b.object.renderOrder:a.z!==b.z?b.z-a.z:a.id-b.id}function l(a,b,c,d,e){var f;c.transparent?(d=ca,f=++ua):(d=sa,f=++Na);f=d[f];void 0!==
f?(f.id=a.id,f.object=a,f.geometry=b,f.material=c,f.z=ra.z,f.group=e):(f={id:a.id,object:a,geometry:b,material:c,z:ra.z,group:e},d.push(f))}function p(a){var b=a.geometry;null===b.boundingSphere&&b.computeBoundingSphere();var c=ab.copy(b.boundingSphere).applyMatrix4(a.matrixWorld);if(!Z.intersectsSphere(c))return!1;if(0===Aa)return!0;a=ia.clippingPlanes;var b=c.center,c=-c.radius,d=0;do if(a[d].distanceToPoint(b)<c)return!1;while(++d!==Aa);return!0}function q(a,c){if(!1!==a.visible){if(a.layers.test(c.layers))if(a instanceof
b.Light)V.push(a);else if(a instanceof b.Sprite)!1!==a.frustumCulled&&!0!==p(a)||ta.push(a);else if(a instanceof b.LensFlare)pa.push(a);else if(a instanceof b.ImmediateRenderObject)!0===ia.sortObjects&&(ra.setFromMatrixPosition(a.matrixWorld),ra.applyProjection(Ra)),l(a,null,a.material,ra.z,null);else if(a instanceof b.Mesh||a instanceof b.Line||a instanceof b.Points)if(a instanceof b.SkinnedMesh&&a.skeleton.update(),!1===a.frustumCulled||!0===p(a)){var d=a.material;if(!0===d.visible){!0===ia.sortObjects&&
(ra.setFromMatrixPosition(a.matrixWorld),ra.applyProjection(Ra));var e=Ia.update(a);if(d instanceof b.MultiMaterial)for(var f=e.groups,h=d.materials,d=0,g=f.length;d<g;d++){var k=f[d],n=h[k.materialIndex];!0===n.visible&&l(a,e,n,ra.z,k)}else l(a,e,d,ra.z,null)}}e=a.children;d=0;for(g=e.length;d<g;d++)q(e[d],c)}}function s(a,c,d,e){for(var f=0,h=a.length;f<h;f++){var g=a[f],l=g.object,k=g.geometry,n=void 0===e?g.material:e,g=g.group;l.modelViewMatrix.multiplyMatrices(c.matrixWorldInverse,l.matrixWorld);
l.normalMatrix.getNormalMatrix(l.modelViewMatrix);if(l instanceof b.ImmediateRenderObject){w(n);var m=y(c,d,n,l);xa="";l.render(function(a){ia.renderBufferImmediate(a,m,n)})}else ia.renderBufferDirect(c,d,k,n,l,g)}}function w(a){a.side!==b.DoubleSide?U.enable(v.CULL_FACE):U.disable(v.CULL_FACE);U.setFlipSided(a.side===b.BackSide);!0===a.transparent?U.setBlending(a.blending,a.blendEquation,a.blendSrc,a.blendDst,a.blendEquationAlpha,a.blendSrcAlpha,a.blendDstAlpha,a.premultipliedAlpha):U.setBlending(b.NoBlending);
U.setDepthFunc(a.depthFunc);U.setDepthTest(a.depthTest);U.setDepthWrite(a.depthWrite);U.setColorWrite(a.colorWrite);U.setPolygonOffset(a.polygonOffset,a.polygonOffsetFactor,a.polygonOffsetUnits)}function y(a,c,d,e){ba=0;var f=ga.get(d);if(Qa){if(La||a!==ya){var h=d.clippingPlanes,g=a===ya&&d.id===oa;if(!La||null===h||0===h.length||Ea&&!d.clipShadows)Ea?z(null):A();else{var l=Ea?0:va,p=4*l,r=f.clippingState||null;na.value=r;r=z(h,a,p,g);for(h=0;h!==p;++h)r[h]=Ba[h];f.clippingState=r;Aa+=l}}void 0!==
f.numClippingPlanes&&f.numClippingPlanes!==Aa&&(d.needsUpdate=!0)}void 0===f.program&&(d.needsUpdate=!0);void 0!==f.lightsHash&&f.lightsHash!==S.hash&&(d.needsUpdate=!0);if(d.needsUpdate){a:{l=ga.get(d);p=Fa.getParameters(d,S,c,Aa,e);r=Fa.getProgramCode(d,p);h=l.program;g=!0;if(void 0===h)d.addEventListener("dispose",k);else if(h.code!==r)m(d);else if(void 0!==p.shaderID)break a;else g=!1;g&&(p.shaderID?(h=b.ShaderLib[p.shaderID],l.__webglShader={name:d.type,uniforms:b.UniformsUtils.clone(h.uniforms),
vertexShader:h.vertexShader,fragmentShader:h.fragmentShader}):l.__webglShader={name:d.type,uniforms:d.uniforms,vertexShader:d.vertexShader,fragmentShader:d.fragmentShader},d.__webglShader=l.__webglShader,h=Fa.acquireProgram(d,p,r),l.program=h,d.program=h);p=h.getAttributes();if(d.morphTargets)for(r=d.numSupportedMorphTargets=0;r<ia.maxMorphTargets;r++)0<=p["morphTarget"+r]&&d.numSupportedMorphTargets++;if(d.morphNormals)for(r=d.numSupportedMorphNormals=0;r<ia.maxMorphNormals;r++)0<=p["morphNormal"+
r]&&d.numSupportedMorphNormals++;p=l.__webglShader.uniforms;(d instanceof b.ShaderMaterial||d instanceof b.RawShaderMaterial)&&!0!==d.clipping||(l.numClippingPlanes=Aa,p.clippingPlanes=na);if(d instanceof b.MeshPhongMaterial||d instanceof b.MeshLambertMaterial||d instanceof b.MeshStandardMaterial||d.lights)l.lightsHash=S.hash,p.ambientLightColor.value=S.ambient,p.directionalLights.value=S.directional,p.spotLights.value=S.spot,p.pointLights.value=S.point,p.hemisphereLights.value=S.hemi,p.directionalShadowMap.value=
S.directionalShadowMap,p.directionalShadowMatrix.value=S.directionalShadowMatrix,p.spotShadowMap.value=S.spotShadowMap,p.spotShadowMatrix.value=S.spotShadowMatrix,p.pointShadowMap.value=S.pointShadowMap,p.pointShadowMatrix.value=S.pointShadowMatrix;r=l.program.getUniforms();r=b.WebGLUniforms.seqWithValue(r.seq,p);l.uniformsList=r;l.dynamicUniforms=b.WebGLUniforms.splitDynamic(r,p)}d.needsUpdate=!1}var q=!1,g=h=!1,l=f.program,r=l.getUniforms(),p=f.__webglShader.uniforms;l.id!==qa&&(v.useProgram(l.program),
qa=l.id,g=h=q=!0);d.id!==oa&&(oa=d.id,h=!0);if(q||a!==ya){r.set(v,a,"projectionMatrix");wa.logarithmicDepthBuffer&&r.setValue(v,"logDepthBufFC",2/(Math.log(a.far+1)/Math.LN2));a!==ya&&(ya=a,g=h=!0);if(d instanceof b.ShaderMaterial||d instanceof b.MeshPhongMaterial||d instanceof b.MeshStandardMaterial||d.envMap)q=r.map.cameraPosition,void 0!==q&&q.setValue(v,ra.setFromMatrixPosition(a.matrixWorld));(d instanceof b.MeshPhongMaterial||d instanceof b.MeshLambertMaterial||d instanceof b.MeshBasicMaterial||
d instanceof b.MeshStandardMaterial||d instanceof b.ShaderMaterial||d.skinning)&&r.setValue(v,"viewMatrix",a.matrixWorldInverse);r.set(v,ia,"toneMappingExposure");r.set(v,ia,"toneMappingWhitePoint")}d.skinning&&(r.setOptional(v,e,"bindMatrix"),r.setOptional(v,e,"bindMatrixInverse"),q=e.skeleton)&&(wa.floatVertexTextures&&q.useVertexTexture?(r.set(v,q,"boneTexture"),r.set(v,q,"boneTextureWidth"),r.set(v,q,"boneTextureHeight")):r.setOptional(v,q,"boneMatrices"));if(h){if(d instanceof b.MeshPhongMaterial||
d instanceof b.MeshLambertMaterial||d instanceof b.MeshStandardMaterial||d.lights)h=g,p.ambientLightColor.needsUpdate=h,p.directionalLights.needsUpdate=h,p.pointLights.needsUpdate=h,p.spotLights.needsUpdate=h,p.hemisphereLights.needsUpdate=h;c&&d.fog&&(p.fogColor.value=c.color,c instanceof b.Fog?(p.fogNear.value=c.near,p.fogFar.value=c.far):c instanceof b.FogExp2&&(p.fogDensity.value=c.density));if(d instanceof b.MeshBasicMaterial||d instanceof b.MeshLambertMaterial||d instanceof b.MeshPhongMaterial||
d instanceof b.MeshStandardMaterial||d instanceof b.MeshDepthMaterial){p.opacity.value=d.opacity;p.diffuse.value=d.color;d.emissive&&p.emissive.value.copy(d.emissive).multiplyScalar(d.emissiveIntensity);p.map.value=d.map;p.specularMap.value=d.specularMap;p.alphaMap.value=d.alphaMap;d.aoMap&&(p.aoMap.value=d.aoMap,p.aoMapIntensity.value=d.aoMapIntensity);var t;d.map?t=d.map:d.specularMap?t=d.specularMap:d.displacementMap?t=d.displacementMap:d.normalMap?t=d.normalMap:d.bumpMap?t=d.bumpMap:d.roughnessMap?
t=d.roughnessMap:d.metalnessMap?t=d.metalnessMap:d.alphaMap?t=d.alphaMap:d.emissiveMap&&(t=d.emissiveMap);void 0!==t&&(t instanceof b.WebGLRenderTarget&&(t=t.texture),c=t.offset,t=t.repeat,p.offsetRepeat.value.set(c.x,c.y,t.x,t.y));p.envMap.value=d.envMap;p.flipEnvMap.value=d.envMap instanceof b.WebGLRenderTargetCube?1:-1;p.reflectivity.value=d.reflectivity;p.refractionRatio.value=d.refractionRatio}d instanceof b.LineBasicMaterial?(p.diffuse.value=d.color,p.opacity.value=d.opacity):d instanceof b.LineDashedMaterial?
(p.diffuse.value=d.color,p.opacity.value=d.opacity,p.dashSize.value=d.dashSize,p.totalSize.value=d.dashSize+d.gapSize,p.scale.value=d.scale):d instanceof b.PointsMaterial?(p.diffuse.value=d.color,p.opacity.value=d.opacity,p.size.value=d.size*fa,p.scale.value=.5*D.clientHeight,p.map.value=d.map,null!==d.map&&(t=d.map.offset,d=d.map.repeat,p.offsetRepeat.value.set(t.x,t.y,d.x,d.y))):d instanceof b.MeshLambertMaterial?(d.lightMap&&(p.lightMap.value=d.lightMap,p.lightMapIntensity.value=d.lightMapIntensity),
d.emissiveMap&&(p.emissiveMap.value=d.emissiveMap)):d instanceof b.MeshPhongMaterial?(p.specular.value=d.specular,p.shininess.value=Math.max(d.shininess,1E-4),d.lightMap&&(p.lightMap.value=d.lightMap,p.lightMapIntensity.value=d.lightMapIntensity),d.emissiveMap&&(p.emissiveMap.value=d.emissiveMap),d.bumpMap&&(p.bumpMap.value=d.bumpMap,p.bumpScale.value=d.bumpScale),d.normalMap&&(p.normalMap.value=d.normalMap,p.normalScale.value.copy(d.normalScale)),d.displacementMap&&(p.displacementMap.value=d.displacementMap,
p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias)):d instanceof b.MeshPhysicalMaterial?B(p,d):d instanceof b.MeshStandardMaterial?B(p,d):d instanceof b.MeshDepthMaterial?d.displacementMap&&(p.displacementMap.value=d.displacementMap,p.displacementScale.value=d.displacementScale,p.displacementBias.value=d.displacementBias):d instanceof b.MeshNormalMaterial&&(p.opacity.value=d.opacity);b.WebGLUniforms.upload(v,f.uniformsList,p,ia)}r.set(v,e,"modelViewMatrix");
r.set(v,e,"normalMatrix");r.setValue(v,"modelMatrix",e.matrixWorld);f=f.dynamicUniforms;null!==f&&(b.WebGLUniforms.evalDynamic(f,p,e,a),b.WebGLUniforms.upload(v,f,p,ia));return l}function B(a,b){a.roughness.value=b.roughness;a.metalness.value=b.metalness;b.roughnessMap&&(a.roughnessMap.value=b.roughnessMap);b.metalnessMap&&(a.metalnessMap.value=b.metalnessMap);b.lightMap&&(a.lightMap.value=b.lightMap,a.lightMapIntensity.value=b.lightMapIntensity);b.emissiveMap&&(a.emissiveMap.value=b.emissiveMap);
b.bumpMap&&(a.bumpMap.value=b.bumpMap,a.bumpScale.value=b.bumpScale);b.normalMap&&(a.normalMap.value=b.normalMap,a.normalScale.value.copy(b.normalScale));b.displacementMap&&(a.displacementMap.value=b.displacementMap,a.displacementScale.value=b.displacementScale,a.displacementBias.value=b.displacementBias);b.envMap&&(a.envMapIntensity.value=b.envMapIntensity)}function z(a,b,c,d){var e=null!==a?a.length:0,f=null;if(0!==e){f=na.value;if(!0!==d||null===f){var h=c+4*e;b=b.matrixWorldInverse;d=eb.getNormalMatrix(b);
if(null===f||f.length<h)f=new Float32Array(h);for(h=0;h!==e;++h,c+=4){var g=fb.copy(a[h]).applyMatrix4(b,d);g.normal.toArray(f,c);f[c+3]=g.constant}}na.value=f;na.needsUpdate=!0}Aa=e;return f}function A(){na.value!==Ba&&(na.value=Ba,na.needsUpdate=0<va);Aa=va}function K(a,c,d){d?(v.texParameteri(a,v.TEXTURE_WRAP_S,L(c.wrapS)),v.texParameteri(a,v.TEXTURE_WRAP_T,L(c.wrapT)),v.texParameteri(a,v.TEXTURE_MAG_FILTER,L(c.magFilter)),v.texParameteri(a,v.TEXTURE_MIN_FILTER,L(c.minFilter))):(v.texParameteri(a,
v.TEXTURE_WRAP_S,v.CLAMP_TO_EDGE),v.texParameteri(a,v.TEXTURE_WRAP_T,v.CLAMP_TO_EDGE),c.wrapS===b.ClampToEdgeWrapping&&c.wrapT===b.ClampToEdgeWrapping||console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.wrapS and Texture.wrapT should be set to THREE.ClampToEdgeWrapping.",c),v.texParameteri(a,v.TEXTURE_MAG_FILTER,Q(c.magFilter)),v.texParameteri(a,v.TEXTURE_MIN_FILTER,Q(c.minFilter)),c.minFilter!==b.NearestFilter&&c.minFilter!==b.LinearFilter&&console.warn("THREE.WebGLRenderer: Texture is not power of two. Texture.minFilter should be set to THREE.NearestFilter or THREE.LinearFilter.",
c));!(d=ja.get("EXT_texture_filter_anisotropic"))||c.type===b.FloatType&&null===ja.get("OES_texture_float_linear")||c.type===b.HalfFloatType&&null===ja.get("OES_texture_half_float_linear")||!(1<c.anisotropy||ga.get(c).__currentAnisotropy)||(v.texParameterf(a,d.TEXTURE_MAX_ANISOTROPY_EXT,Math.min(c.anisotropy,ia.getMaxAnisotropy())),ga.get(c).__currentAnisotropy=c.anisotropy)}function F(a,c){a instanceof b.WebGLRenderTarget&&(a=a.texture);var d=ga.get(a);if(0<a.version&&d.__version!==a.version){var e=
a.image;if(void 0===e)console.warn("THREE.WebGLRenderer: Texture marked for update but image is undefined",a);else if(!1===e.complete)console.warn("THREE.WebGLRenderer: Texture marked for update but image is incomplete",a);else{e=a;void 0===d.__webglInit&&(d.__webglInit=!0,e.addEventListener("dispose",g),d.__webglTexture=v.createTexture(),Ha.textures++);U.activeTexture(v.TEXTURE0+c);U.bindTexture(v.TEXTURE_2D,d.__webglTexture);v.pixelStorei(v.UNPACK_FLIP_Y_WEBGL,e.flipY);v.pixelStorei(v.UNPACK_PREMULTIPLY_ALPHA_WEBGL,
e.premultiplyAlpha);v.pixelStorei(v.UNPACK_ALIGNMENT,e.unpackAlignment);var f=G(e.image,wa.maxTextureSize);if((e.wrapS!==b.ClampToEdgeWrapping||e.wrapT!==b.ClampToEdgeWrapping||e.minFilter!==b.NearestFilter&&e.minFilter!==b.LinearFilter)&&!1===E(f)){var h=f;if(h instanceof HTMLImageElement||h instanceof HTMLCanvasElement){var l=document.createElement("canvas");l.width=b.Math.nearestPowerOfTwo(h.width);l.height=b.Math.nearestPowerOfTwo(h.height);l.getContext("2d").drawImage(h,0,0,l.width,l.height);
console.warn("THREE.WebGLRenderer: image is not power of two ("+h.width+"x"+h.height+"). Resized to "+l.width+"x"+l.height,h);f=l}else f=h}var h=E(f),l=L(e.format),k=L(e.type);K(v.TEXTURE_2D,e,h);var n=e.mipmaps;if(e instanceof b.DepthTexture){n=v.DEPTH_COMPONENT;if(e.type===b.FloatType){if(!Pa)throw Error("Float Depth Texture only supported in WebGL2.0");n=v.DEPTH_COMPONENT32F}else Pa&&(n=v.DEPTH_COMPONENT16);U.texImage2D(v.TEXTURE_2D,0,n,f.width,f.height,0,l,k,null)}else if(e instanceof b.DataTexture)if(0<
n.length&&h){for(var m=0,p=n.length;m<p;m++)f=n[m],U.texImage2D(v.TEXTURE_2D,m,l,f.width,f.height,0,l,k,f.data);e.generateMipmaps=!1}else U.texImage2D(v.TEXTURE_2D,0,l,f.width,f.height,0,l,k,f.data);else if(e instanceof b.CompressedTexture)for(m=0,p=n.length;m<p;m++)f=n[m],e.format!==b.RGBAFormat&&e.format!==b.RGBFormat?-1<U.getCompressedTextureFormats().indexOf(l)?U.compressedTexImage2D(v.TEXTURE_2D,m,l,f.width,f.height,0,f.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .uploadTexture()"):
U.texImage2D(v.TEXTURE_2D,m,l,f.width,f.height,0,l,k,f.data);else if(0<n.length&&h){m=0;for(p=n.length;m<p;m++)f=n[m],U.texImage2D(v.TEXTURE_2D,m,l,l,k,f);e.generateMipmaps=!1}else U.texImage2D(v.TEXTURE_2D,0,l,l,k,f);e.generateMipmaps&&h&&v.generateMipmap(v.TEXTURE_2D);d.__version=e.version;if(e.onUpdate)e.onUpdate(e)}}else U.activeTexture(v.TEXTURE0+c),U.bindTexture(v.TEXTURE_2D,d.__webglTexture)}function G(a,b){if(a.width>b||a.height>b){var c=b/Math.max(a.width,a.height),d=document.createElement("canvas");
d.width=Math.floor(a.width*c);d.height=Math.floor(a.height*c);d.getContext("2d").drawImage(a,0,0,a.width,a.height,0,0,d.width,d.height);console.warn("THREE.WebGLRenderer: image is too big ("+a.width+"x"+a.height+"). Resized to "+d.width+"x"+d.height,a);return d}return a}function E(a){return b.Math.isPowerOfTwo(a.width)&&b.Math.isPowerOfTwo(a.height)}function R(a,b,c,d){var e=L(b.texture.format),f=L(b.texture.type);U.texImage2D(d,0,e,b.width,b.height,0,e,f,null);v.bindFramebuffer(v.FRAMEBUFFER,a);
v.framebufferTexture2D(v.FRAMEBUFFER,c,d,ga.get(b.texture).__webglTexture,0);v.bindFramebuffer(v.FRAMEBUFFER,null)}function M(a,b){v.bindRenderbuffer(v.RENDERBUFFER,a);b.depthBuffer&&!b.stencilBuffer?(v.renderbufferStorage(v.RENDERBUFFER,v.DEPTH_COMPONENT16,b.width,b.height),v.framebufferRenderbuffer(v.FRAMEBUFFER,v.DEPTH_ATTACHMENT,v.RENDERBUFFER,a)):b.depthBuffer&&b.stencilBuffer?(v.renderbufferStorage(v.RENDERBUFFER,v.DEPTH_STENCIL,b.width,b.height),v.framebufferRenderbuffer(v.FRAMEBUFFER,v.DEPTH_STENCIL_ATTACHMENT,
v.RENDERBUFFER,a)):v.renderbufferStorage(v.RENDERBUFFER,v.RGBA4,b.width,b.height);v.bindRenderbuffer(v.RENDERBUFFER,null)}function Q(a){return a===b.NearestFilter||a===b.NearestMipMapNearestFilter||a===b.NearestMipMapLinearFilter?v.NEAREST:v.LINEAR}function L(a){var c;if(a===b.RepeatWrapping)return v.REPEAT;if(a===b.ClampToEdgeWrapping)return v.CLAMP_TO_EDGE;if(a===b.MirroredRepeatWrapping)return v.MIRRORED_REPEAT;if(a===b.NearestFilter)return v.NEAREST;if(a===b.NearestMipMapNearestFilter)return v.NEAREST_MIPMAP_NEAREST;
if(a===b.NearestMipMapLinearFilter)return v.NEAREST_MIPMAP_LINEAR;if(a===b.LinearFilter)return v.LINEAR;if(a===b.LinearMipMapNearestFilter)return v.LINEAR_MIPMAP_NEAREST;if(a===b.LinearMipMapLinearFilter)return v.LINEAR_MIPMAP_LINEAR;if(a===b.UnsignedByteType)return v.UNSIGNED_BYTE;if(a===b.UnsignedShort4444Type)return v.UNSIGNED_SHORT_4_4_4_4;if(a===b.UnsignedShort5551Type)return v.UNSIGNED_SHORT_5_5_5_1;if(a===b.UnsignedShort565Type)return v.UNSIGNED_SHORT_5_6_5;if(a===b.ByteType)return v.BYTE;
if(a===b.ShortType)return v.SHORT;if(a===b.UnsignedShortType)return v.UNSIGNED_SHORT;if(a===b.IntType)return v.INT;if(a===b.UnsignedIntType)return v.UNSIGNED_INT;if(a===b.FloatType)return v.FLOAT;c=ja.get("OES_texture_half_float");if(null!==c&&a===b.HalfFloatType)return c.HALF_FLOAT_OES;if(a===b.AlphaFormat)return v.ALPHA;if(a===b.RGBFormat)return v.RGB;if(a===b.RGBAFormat)return v.RGBA;if(a===b.LuminanceFormat)return v.LUMINANCE;if(a===b.LuminanceAlphaFormat)return v.LUMINANCE_ALPHA;if(a===b.DepthFormat)return v.DEPTH_COMPONENT;
if(a===b.AddEquation)return v.FUNC_ADD;if(a===b.SubtractEquation)return v.FUNC_SUBTRACT;if(a===b.ReverseSubtractEquation)return v.FUNC_REVERSE_SUBTRACT;if(a===b.ZeroFactor)return v.ZERO;if(a===b.OneFactor)return v.ONE;if(a===b.SrcColorFactor)return v.SRC_COLOR;if(a===b.OneMinusSrcColorFactor)return v.ONE_MINUS_SRC_COLOR;if(a===b.SrcAlphaFactor)return v.SRC_ALPHA;if(a===b.OneMinusSrcAlphaFactor)return v.ONE_MINUS_SRC_ALPHA;if(a===b.DstAlphaFactor)return v.DST_ALPHA;if(a===b.OneMinusDstAlphaFactor)return v.ONE_MINUS_DST_ALPHA;
if(a===b.DstColorFactor)return v.DST_COLOR;if(a===b.OneMinusDstColorFactor)return v.ONE_MINUS_DST_COLOR;if(a===b.SrcAlphaSaturateFactor)return v.SRC_ALPHA_SATURATE;c=ja.get("WEBGL_compressed_texture_s3tc");if(null!==c){if(a===b.RGB_S3TC_DXT1_Format)return c.COMPRESSED_RGB_S3TC_DXT1_EXT;if(a===b.RGBA_S3TC_DXT1_Format)return c.COMPRESSED_RGBA_S3TC_DXT1_EXT;if(a===b.RGBA_S3TC_DXT3_Format)return c.COMPRESSED_RGBA_S3TC_DXT3_EXT;if(a===b.RGBA_S3TC_DXT5_Format)return c.COMPRESSED_RGBA_S3TC_DXT5_EXT}c=ja.get("WEBGL_compressed_texture_pvrtc");
if(null!==c){if(a===b.RGB_PVRTC_4BPPV1_Format)return c.COMPRESSED_RGB_PVRTC_4BPPV1_IMG;if(a===b.RGB_PVRTC_2BPPV1_Format)return c.COMPRESSED_RGB_PVRTC_2BPPV1_IMG;if(a===b.RGBA_PVRTC_4BPPV1_Format)return c.COMPRESSED_RGBA_PVRTC_4BPPV1_IMG;if(a===b.RGBA_PVRTC_2BPPV1_Format)return c.COMPRESSED_RGBA_PVRTC_2BPPV1_IMG}c=ja.get("WEBGL_compressed_texture_etc1");if(null!==c&&a===b.RGB_ETC1_Format)return c.COMPRESSED_RGB_ETC1_WEBGL;c=ja.get("EXT_blend_minmax");if(null!==c){if(a===b.MinEquation)return c.MIN_EXT;
if(a===b.MaxEquation)return c.MAX_EXT}return 0}console.log("THREE.WebGLRenderer",b.REVISION);a=a||{};var D=void 0!==a.canvas?a.canvas:document.createElement("canvas"),P=void 0!==a.context?a.context:null,N=void 0!==a.alpha?a.alpha:!1,T=void 0!==a.depth?a.depth:!0,H=void 0!==a.stencil?a.stencil:!0,J=void 0!==a.antialias?a.antialias:!1,O=void 0!==a.premultipliedAlpha?a.premultipliedAlpha:!0,Y=void 0!==a.preserveDrawingBuffer?a.preserveDrawingBuffer:!1,V=[],sa=[],Na=-1,ca=[],ua=-1,X=new Float32Array(8),
ta=[],pa=[];this.domElement=D;this.context=null;this.sortObjects=this.autoClearStencil=this.autoClearDepth=this.autoClearColor=this.autoClear=!0;this.clippingPlanes=[];this.localClippingEnabled=!1;this.gammaFactor=2;this.physicallyCorrectLights=this.gammaOutput=this.gammaInput=!1;this.toneMapping=b.LinearToneMapping;this.toneMappingWhitePoint=this.toneMappingExposure=1;this.maxMorphTargets=8;this.maxMorphNormals=4;this.autoScaleCubemaps=!0;var ia=this,qa=null,Ca=null,Da=null,oa=-1,xa="",ya=null,Ka=
new b.Vector4,ka=null,W=new b.Vector4,ba=0,ha=new b.Color(0),$=0,da=D.width,ea=D.height,fa=1,la=new b.Vector4(0,0,da,ea),aa=!1,ma=new b.Vector4(0,0,da,ea),Z=new b.Frustum,Qa=!1,La=!1,Ea=!1,Aa=0,na={type:"4fv",value:null,needsUpdate:!1},Ba=null,va=0,eb=new b.Matrix3,ab=new b.Sphere,fb=new b.Plane,Ra=new b.Matrix4,ra=new b.Vector3,S={hash:"",ambient:[0,0,0],directional:[],directionalShadowMap:[],directionalShadowMatrix:[],spot:[],spotShadowMap:[],spotShadowMatrix:[],point:[],pointShadowMap:[],pointShadowMatrix:[],
hemi:[],shadows:[]},Ha={geometries:0,textures:0},Oa={calls:0,vertices:0,faces:0,points:0};this.info={render:Oa,memory:Ha,programs:null};var v;try{N={alpha:N,depth:T,stencil:H,antialias:J,premultipliedAlpha:O,preserveDrawingBuffer:Y};v=P||D.getContext("webgl",N)||D.getContext("experimental-webgl",N);if(null===v){if(null!==D.getContext("webgl"))throw"Error creating WebGL context with your selected attributes.";throw"Error creating WebGL context.";}void 0===v.getShaderPrecisionFormat&&(v.getShaderPrecisionFormat=
function(){return{rangeMin:1,rangeMax:1,precision:1}});D.addEventListener("webglcontextlost",f,!1)}catch(gb){console.error("THREE.WebGLRenderer: "+gb)}var Pa="undefined"!==typeof WebGL2RenderingContext&&v instanceof WebGL2RenderingContext,ja=new b.WebGLExtensions(v);ja.get("WEBGL_depth_texture");ja.get("OES_texture_float");ja.get("OES_texture_float_linear");ja.get("OES_texture_half_float");ja.get("OES_texture_half_float_linear");ja.get("OES_standard_derivatives");ja.get("ANGLE_instanced_arrays");
ja.get("OES_element_index_uint")&&(b.BufferGeometry.MaxIndex=4294967296);var wa=new b.WebGLCapabilities(v,ja,a),U=new b.WebGLState(v,ja,L),ga=new b.WebGLProperties,Ia=new b.WebGLObjects(v,ga,this.info),Fa=new b.WebGLPrograms(this,wa),Ua=new b.WebGLLights;this.info.programs=Fa.programs;var Va=new b.WebGLBufferRenderer(v,ja,Oa),bb=new b.WebGLIndexedBufferRenderer(v,ja,Oa);d();this.context=v;this.capabilities=wa;this.extensions=ja;this.properties=ga;this.state=U;var cb=new b.WebGLShadowMap(this,S,Ia);
this.shadowMap=cb;var Wa=new b.SpritePlugin(this,ta),Xa=new b.LensFlarePlugin(this,pa);this.getContext=function(){return v};this.getContextAttributes=function(){return v.getContextAttributes()};this.forceContextLoss=function(){ja.get("WEBGL_lose_context").loseContext()};this.getMaxAnisotropy=function(){var a;return function(){if(void 0!==a)return a;var b=ja.get("EXT_texture_filter_anisotropic");return a=null!==b?v.getParameter(b.MAX_TEXTURE_MAX_ANISOTROPY_EXT):0}}();this.getPrecision=function(){return wa.precision};
this.getPixelRatio=function(){return fa};this.setPixelRatio=function(a){void 0!==a&&(fa=a,this.setSize(ma.z,ma.w,!1))};this.getSize=function(){return{width:da,height:ea}};this.setSize=function(a,b,c){da=a;ea=b;D.width=a*fa;D.height=b*fa;!1!==c&&(D.style.width=a+"px",D.style.height=b+"px");this.setViewport(0,0,a,b)};this.setViewport=function(a,b,c,d){U.viewport(ma.set(a,b,c,d))};this.setScissor=function(a,b,c,d){U.scissor(la.set(a,b,c,d))};this.setScissorTest=function(a){U.setScissorTest(aa=a)};this.getClearColor=
function(){return ha};this.setClearColor=function(a,b){ha.set(a);$=void 0!==b?b:1;c(ha.r,ha.g,ha.b,$)};this.getClearAlpha=function(){return $};this.setClearAlpha=function(a){$=a;c(ha.r,ha.g,ha.b,$)};this.clear=function(a,b,c){var d=0;if(void 0===a||a)d|=v.COLOR_BUFFER_BIT;if(void 0===b||b)d|=v.DEPTH_BUFFER_BIT;if(void 0===c||c)d|=v.STENCIL_BUFFER_BIT;v.clear(d)};this.clearColor=function(){this.clear(!0,!1,!1)};this.clearDepth=function(){this.clear(!1,!0,!1)};this.clearStencil=function(){this.clear(!1,
!1,!0)};this.clearTarget=function(a,b,c,d){this.setRenderTarget(a);this.clear(b,c,d)};this.resetGLState=e;this.dispose=function(){D.removeEventListener("webglcontextlost",f,!1)};this.renderBufferImmediate=function(a,c,d){U.initAttributes();var e=ga.get(a);a.hasPositions&&!e.position&&(e.position=v.createBuffer());a.hasNormals&&!e.normal&&(e.normal=v.createBuffer());a.hasUvs&&!e.uv&&(e.uv=v.createBuffer());a.hasColors&&!e.color&&(e.color=v.createBuffer());c=c.getAttributes();a.hasPositions&&(v.bindBuffer(v.ARRAY_BUFFER,
e.position),v.bufferData(v.ARRAY_BUFFER,a.positionArray,v.DYNAMIC_DRAW),U.enableAttribute(c.position),v.vertexAttribPointer(c.position,3,v.FLOAT,!1,0,0));if(a.hasNormals){v.bindBuffer(v.ARRAY_BUFFER,e.normal);if("MeshPhongMaterial"!==d.type&&"MeshStandardMaterial"!==d.type&&"MeshPhysicalMaterial"!==d.type&&d.shading===b.FlatShading)for(var f=0,h=3*a.count;f<h;f+=9){var g=a.normalArray,l=(g[f+0]+g[f+3]+g[f+6])/3,k=(g[f+1]+g[f+4]+g[f+7])/3,n=(g[f+2]+g[f+5]+g[f+8])/3;g[f+0]=l;g[f+1]=k;g[f+2]=n;g[f+3]=
l;g[f+4]=k;g[f+5]=n;g[f+6]=l;g[f+7]=k;g[f+8]=n}v.bufferData(v.ARRAY_BUFFER,a.normalArray,v.DYNAMIC_DRAW);U.enableAttribute(c.normal);v.vertexAttribPointer(c.normal,3,v.FLOAT,!1,0,0)}a.hasUvs&&d.map&&(v.bindBuffer(v.ARRAY_BUFFER,e.uv),v.bufferData(v.ARRAY_BUFFER,a.uvArray,v.DYNAMIC_DRAW),U.enableAttribute(c.uv),v.vertexAttribPointer(c.uv,2,v.FLOAT,!1,0,0));a.hasColors&&d.vertexColors!==b.NoColors&&(v.bindBuffer(v.ARRAY_BUFFER,e.color),v.bufferData(v.ARRAY_BUFFER,a.colorArray,v.DYNAMIC_DRAW),U.enableAttribute(c.color),
v.vertexAttribPointer(c.color,3,v.FLOAT,!1,0,0));U.disableUnusedAttributes();v.drawArrays(v.TRIANGLES,0,a.count);a.count=0};this.renderBufferDirect=function(a,c,d,e,f,h){w(e);var g=y(a,c,e,f),l=!1;a=d.id+"_"+g.id+"_"+e.wireframe;a!==xa&&(xa=a,l=!0);c=f.morphTargetInfluences;if(void 0!==c){a=[];for(var k=0,l=c.length;k<l;k++){var n=c[k];a.push([n,k])}a.sort(r);8<a.length&&(a.length=8);for(var m=d.morphAttributes,k=0,l=a.length;k<l;k++)n=a[k],X[k]=n[0],0!==n[0]?(c=n[1],!0===e.morphTargets&&m.position&&
d.addAttribute("morphTarget"+k,m.position[c]),!0===e.morphNormals&&m.normal&&d.addAttribute("morphNormal"+k,m.normal[c])):(!0===e.morphTargets&&d.removeAttribute("morphTarget"+k),!0===e.morphNormals&&d.removeAttribute("morphNormal"+k));g.getUniforms().setValue(v,"morphTargetInfluences",X);l=!0}c=d.index;k=d.attributes.position;!0===e.wireframe&&(c=Ia.getWireframeAttribute(d));null!==c?(a=bb,a.setIndex(c)):a=Va;if(l){a:{var l=void 0,p;if(d instanceof b.InstancedBufferGeometry&&(p=ja.get("ANGLE_instanced_arrays"),
null===p)){console.error("THREE.WebGLRenderer.setupVertexAttributes: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");break a}void 0===l&&(l=0);U.initAttributes();var n=d.attributes,g=g.getAttributes(),m=e.defaultAttributeValues,q;for(q in g){var u=g[q];if(0<=u){var t=n[q];if(void 0!==t){var x=v.FLOAT,s=t.array,z=t.normalized;s instanceof Float32Array?x=v.FLOAT:s instanceof Float64Array?console.warn("Unsupported data buffer format: Float64Array"):
s instanceof Uint16Array?x=v.UNSIGNED_SHORT:s instanceof Int16Array?x=v.SHORT:s instanceof Uint32Array?x=v.UNSIGNED_INT:s instanceof Int32Array?x=v.INT:s instanceof Int8Array?x=v.BYTE:s instanceof Uint8Array&&(x=v.UNSIGNED_BYTE);var s=t.itemSize,A=Ia.getAttributeBuffer(t);if(t instanceof b.InterleavedBufferAttribute){var H=t.data,B=H.stride,t=t.offset;H instanceof b.InstancedInterleavedBuffer?(U.enableAttributeAndDivisor(u,H.meshPerAttribute,p),void 0===d.maxInstancedCount&&(d.maxInstancedCount=H.meshPerAttribute*
H.count)):U.enableAttribute(u);v.bindBuffer(v.ARRAY_BUFFER,A);v.vertexAttribPointer(u,s,x,z,B*H.array.BYTES_PER_ELEMENT,(l*B+t)*H.array.BYTES_PER_ELEMENT)}else t instanceof b.InstancedBufferAttribute?(U.enableAttributeAndDivisor(u,t.meshPerAttribute,p),void 0===d.maxInstancedCount&&(d.maxInstancedCount=t.meshPerAttribute*t.count)):U.enableAttribute(u),v.bindBuffer(v.ARRAY_BUFFER,A),v.vertexAttribPointer(u,s,x,z,0,l*s*t.array.BYTES_PER_ELEMENT)}else if(void 0!==m&&(x=m[q],void 0!==x))switch(x.length){case 2:v.vertexAttrib2fv(u,
x);break;case 3:v.vertexAttrib3fv(u,x);break;case 4:v.vertexAttrib4fv(u,x);break;default:v.vertexAttrib1fv(u,x)}}}U.disableUnusedAttributes()}null!==c&&v.bindBuffer(v.ELEMENT_ARRAY_BUFFER,Ia.getAttributeBuffer(c))}p=Infinity;null!==c?p=c.count:void 0!==k&&(p=k.count);q=d.drawRange.start;c=d.drawRange.count;k=null!==h?h.start:0;l=null!==h?h.count:Infinity;h=Math.max(0,q,k);p=Math.min(0+p,q+c,k+l)-1;p=Math.max(0,p-h+1);if(f instanceof b.Mesh)if(!0===e.wireframe)U.setLineWidth(e.wireframeLinewidth*(null===
Ca?fa:1)),a.setMode(v.LINES);else switch(f.drawMode){case b.TrianglesDrawMode:a.setMode(v.TRIANGLES);break;case b.TriangleStripDrawMode:a.setMode(v.TRIANGLE_STRIP);break;case b.TriangleFanDrawMode:a.setMode(v.TRIANGLE_FAN)}else f instanceof b.Line?(e=e.linewidth,void 0===e&&(e=1),U.setLineWidth(e*(null===Ca?fa:1)),f instanceof b.LineSegments?a.setMode(v.LINES):a.setMode(v.LINE_STRIP)):f instanceof b.Points&&a.setMode(v.POINTS);d instanceof b.InstancedBufferGeometry?0<d.maxInstancedCount&&a.renderInstances(d,
h,p):a.render(h,p)};this.render=function(a,c,d,e){if(!1===c instanceof b.Camera)console.error("THREE.WebGLRenderer.render: camera is not an instance of THREE.Camera.");else{var f=a.fog;xa="";oa=-1;ya=null;!0===a.autoUpdate&&a.updateMatrixWorld();null===c.parent&&c.updateMatrixWorld();c.matrixWorldInverse.getInverse(c.matrixWorld);Ra.multiplyMatrices(c.projectionMatrix,c.matrixWorldInverse);Z.setFromMatrix(Ra);V.length=0;ua=Na=-1;ta.length=0;pa.length=0;var h=this.clippingPlanes;Qa=0!==ia.clippingPlanes.length||
ia.localClippingEnabled||0!==va||La;La=ia.localClippingEnabled;Ba=z(h,c,0);va=null!==h?h.length:0;q(a,c);sa.length=Na+1;ca.length=ua+1;!0===ia.sortObjects&&(sa.sort(t),ca.sort(x));Qa&&(Ea=!0,z(null));for(var h=V,g=0,l=0,k=h.length;l<k;l++){var n=h[l];n.castShadow&&(S.shadows[g++]=n)}S.shadows.length=g;cb.render(a,c);for(var h=V,m=n=0,p=0,r,u,y,w=c.matrixWorldInverse,H=0,B=0,O=0,J=0,g=0,l=h.length;g<l;g++)if(k=h[g],r=k.color,u=k.intensity,y=k.distance,k instanceof b.AmbientLight)n+=r.r*u,m+=r.g*u,
p+=r.b*u;else if(k instanceof b.DirectionalLight){var X=Ua.get(k);X.color.copy(k.color).multiplyScalar(k.intensity);X.direction.setFromMatrixPosition(k.matrixWorld);ra.setFromMatrixPosition(k.target.matrixWorld);X.direction.sub(ra);X.direction.transformDirection(w);if(X.shadow=k.castShadow)X.shadowBias=k.shadow.bias,X.shadowRadius=k.shadow.radius,X.shadowMapSize=k.shadow.mapSize;S.directionalShadowMap[H]=k.shadow.map;S.directionalShadowMatrix[H]=k.shadow.matrix;S.directional[H++]=X}else if(k instanceof
b.SpotLight){X=Ua.get(k);X.position.setFromMatrixPosition(k.matrixWorld);X.position.applyMatrix4(w);X.color.copy(r).multiplyScalar(u);X.distance=y;X.direction.setFromMatrixPosition(k.matrixWorld);ra.setFromMatrixPosition(k.target.matrixWorld);X.direction.sub(ra);X.direction.transformDirection(w);X.coneCos=Math.cos(k.angle);X.penumbraCos=Math.cos(k.angle*(1-k.penumbra));X.decay=0===k.distance?0:k.decay;if(X.shadow=k.castShadow)X.shadowBias=k.shadow.bias,X.shadowRadius=k.shadow.radius,X.shadowMapSize=
k.shadow.mapSize;S.spotShadowMap[O]=k.shadow.map;S.spotShadowMatrix[O]=k.shadow.matrix;S.spot[O++]=X}else if(k instanceof b.PointLight){X=Ua.get(k);X.position.setFromMatrixPosition(k.matrixWorld);X.position.applyMatrix4(w);X.color.copy(k.color).multiplyScalar(k.intensity);X.distance=k.distance;X.decay=0===k.distance?0:k.decay;if(X.shadow=k.castShadow)X.shadowBias=k.shadow.bias,X.shadowRadius=k.shadow.radius,X.shadowMapSize=k.shadow.mapSize;S.pointShadowMap[B]=k.shadow.map;void 0===S.pointShadowMatrix[B]&&
(S.pointShadowMatrix[B]=new b.Matrix4);ra.setFromMatrixPosition(k.matrixWorld).negate();S.pointShadowMatrix[B].identity().setPosition(ra);S.point[B++]=X}else k instanceof b.HemisphereLight&&(X=Ua.get(k),X.direction.setFromMatrixPosition(k.matrixWorld),X.direction.transformDirection(w),X.direction.normalize(),X.skyColor.copy(k.color).multiplyScalar(u),X.groundColor.copy(k.groundColor).multiplyScalar(u),S.hemi[J++]=X);S.ambient[0]=n;S.ambient[1]=m;S.ambient[2]=p;S.directional.length=H;S.spot.length=
O;S.point.length=B;S.hemi.length=J;S.hash=H+","+B+","+O+","+J+","+S.shadows.length;Qa&&(Ea=!1,A());Oa.calls=0;Oa.vertices=0;Oa.faces=0;Oa.points=0;void 0===d&&(d=null);this.setRenderTarget(d);(this.autoClear||e)&&this.clear(this.autoClearColor,this.autoClearDepth,this.autoClearStencil);a.overrideMaterial?(e=a.overrideMaterial,s(sa,c,f,e),s(ca,c,f,e)):(U.setBlending(b.NoBlending),s(sa,c,f),s(ca,c,f));Wa.render(a,c);Xa.render(a,c,W);d&&(a=d.texture,a.generateMipmaps&&E(d)&&a.minFilter!==b.NearestFilter&&
a.minFilter!==b.LinearFilter&&(a=d instanceof b.WebGLRenderTargetCube?v.TEXTURE_CUBE_MAP:v.TEXTURE_2D,d=ga.get(d.texture).__webglTexture,U.bindTexture(a,d),v.generateMipmap(a),U.bindTexture(a,null)));U.setDepthTest(!0);U.setDepthWrite(!0);U.setColorWrite(!0)}};this.setFaceCulling=function(a,c){a===b.CullFaceNone?U.disable(v.CULL_FACE):(c===b.FrontFaceDirectionCW?v.frontFace(v.CW):v.frontFace(v.CCW),a===b.CullFaceBack?v.cullFace(v.BACK):a===b.CullFaceFront?v.cullFace(v.FRONT):v.cullFace(v.FRONT_AND_BACK),
U.enable(v.CULL_FACE))};var Ya=!1;this.setTexture=function(a,b){Ya||(console.warn("THREE.WebGLRenderer: .setTexture is deprecated, use setTexture2D instead."),Ya=!0);F(a,b)};this.allocTextureUnit=function(){var a=ba;a>=wa.maxTextures&&console.warn("WebGLRenderer: trying to use "+a+" texture units while this GPU supports only "+wa.maxTextures);ba+=1;return a};this.setTexture2D=F;this.setTextureCube=function(a,c){if(a instanceof b.CubeTexture||Array.isArray(a.image)&&6===a.image.length){var d=ga.get(a);
if(6===a.image.length)if(0<a.version&&d.__version!==a.version){d.__image__webglTextureCube||(a.addEventListener("dispose",g),d.__image__webglTextureCube=v.createTexture(),Ha.textures++);U.activeTexture(v.TEXTURE0+c);U.bindTexture(v.TEXTURE_CUBE_MAP,d.__image__webglTextureCube);v.pixelStorei(v.UNPACK_FLIP_Y_WEBGL,a.flipY);for(var e=a instanceof b.CompressedTexture,f=a.image[0]instanceof b.DataTexture,h=[],l=0;6>l;l++)h[l]=!ia.autoScaleCubemaps||e||f?f?a.image[l].image:a.image[l]:G(a.image[l],wa.maxCubemapSize);
var k=E(h[0]),n=L(a.format),m=L(a.type);K(v.TEXTURE_CUBE_MAP,a,k);for(l=0;6>l;l++)if(e)for(var p,r=h[l].mipmaps,q=0,u=r.length;q<u;q++)p=r[q],a.format!==b.RGBAFormat&&a.format!==b.RGBFormat?-1<U.getCompressedTextureFormats().indexOf(n)?U.compressedTexImage2D(v.TEXTURE_CUBE_MAP_POSITIVE_X+l,q,n,p.width,p.height,0,p.data):console.warn("THREE.WebGLRenderer: Attempt to load unsupported compressed texture format in .setCubeTexture()"):U.texImage2D(v.TEXTURE_CUBE_MAP_POSITIVE_X+l,q,n,p.width,p.height,0,
n,m,p.data);else f?U.texImage2D(v.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,n,h[l].width,h[l].height,0,n,m,h[l].data):U.texImage2D(v.TEXTURE_CUBE_MAP_POSITIVE_X+l,0,n,n,m,h[l]);a.generateMipmaps&&k&&v.generateMipmap(v.TEXTURE_CUBE_MAP);d.__version=a.version;if(a.onUpdate)a.onUpdate(a)}else U.activeTexture(v.TEXTURE0+c),U.bindTexture(v.TEXTURE_CUBE_MAP,d.__image__webglTextureCube)}else d=a.texture,U.activeTexture(v.TEXTURE0+c),U.bindTexture(v.TEXTURE_CUBE_MAP,ga.get(d).__webglTexture)};this.getCurrentRenderTarget=
function(){return Ca};this.setRenderTarget=function(a){if((Ca=a)&&void 0===ga.get(a).__webglFramebuffer){var c=ga.get(a),d=ga.get(a.texture);a.addEventListener("dispose",h);d.__webglTexture=v.createTexture();Ha.textures++;var e=a instanceof b.WebGLRenderTargetCube,f=b.Math.isPowerOfTwo(a.width)&&b.Math.isPowerOfTwo(a.height);if(e){c.__webglFramebuffer=[];for(var g=0;6>g;g++)c.__webglFramebuffer[g]=v.createFramebuffer()}else c.__webglFramebuffer=v.createFramebuffer();if(e){U.bindTexture(v.TEXTURE_CUBE_MAP,
d.__webglTexture);K(v.TEXTURE_CUBE_MAP,a.texture,f);for(g=0;6>g;g++)R(c.__webglFramebuffer[g],a,v.COLOR_ATTACHMENT0,v.TEXTURE_CUBE_MAP_POSITIVE_X+g);a.texture.generateMipmaps&&f&&v.generateMipmap(v.TEXTURE_CUBE_MAP);U.bindTexture(v.TEXTURE_CUBE_MAP,null)}else U.bindTexture(v.TEXTURE_2D,d.__webglTexture),K(v.TEXTURE_2D,a.texture,f),R(c.__webglFramebuffer,a,v.COLOR_ATTACHMENT0,v.TEXTURE_2D),a.texture.generateMipmaps&&f&&v.generateMipmap(v.TEXTURE_2D),U.bindTexture(v.TEXTURE_2D,null);if(a.depthBuffer){c=
ga.get(a);d=a instanceof b.WebGLRenderTargetCube;if(a.depthTexture){if(d)throw Error("target.depthTexture not supported in Cube render targets");if(a instanceof b.WebGLRenderTargetCube)throw Error("Depth Texture with cube render targets is not supported!");v.bindFramebuffer(v.FRAMEBUFFER,c.__webglFramebuffer);if(!(a.depthTexture instanceof b.DepthTexture))throw Error("renderTarget.depthTexture must be an instance of THREE.DepthTexture");ga.get(a.depthTexture).__webglTexture&&a.depthTexture.image.width===
a.width&&a.depthTexture.image.height===a.height||(a.depthTexture.image.width=a.width,a.depthTexture.image.height=a.height,a.depthTexture.needsUpdate=!0);ia.setTexture(a.depthTexture,0);c=ga.get(a.depthTexture).__webglTexture;v.framebufferTexture2D(v.FRAMEBUFFER,v.DEPTH_ATTACHMENT,v.TEXTURE_2D,c,0)}else if(d)for(c.__webglDepthbuffer=[],d=0;6>d;d++)v.bindFramebuffer(v.FRAMEBUFFER,c.__webglFramebuffer[d]),c.__webglDepthbuffer[d]=v.createRenderbuffer(),M(c.__webglDepthbuffer[d],a);else v.bindFramebuffer(v.FRAMEBUFFER,
c.__webglFramebuffer),c.__webglDepthbuffer=v.createRenderbuffer(),M(c.__webglDepthbuffer,a);v.bindFramebuffer(v.FRAMEBUFFER,null)}}c=a instanceof b.WebGLRenderTargetCube;a?(d=ga.get(a),d=c?d.__webglFramebuffer[a.activeCubeFace]:d.__webglFramebuffer,Ka.copy(a.scissor),ka=a.scissorTest,W.copy(a.viewport)):(d=null,Ka.copy(la).multiplyScalar(fa),ka=aa,W.copy(ma).multiplyScalar(fa));Da!==d&&(v.bindFramebuffer(v.FRAMEBUFFER,d),Da=d);U.scissor(Ka);U.setScissorTest(ka);U.viewport(W);c&&(c=ga.get(a.texture),
v.framebufferTexture2D(v.FRAMEBUFFER,v.COLOR_ATTACHMENT0,v.TEXTURE_CUBE_MAP_POSITIVE_X+a.activeCubeFace,c.__webglTexture,a.activeMipMapLevel))};this.readRenderTargetPixels=function(a,c,d,e,f,h){if(!1===a instanceof b.WebGLRenderTarget)console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not THREE.WebGLRenderTarget.");else{var g=ga.get(a).__webglFramebuffer;if(g){var l=!1;g!==Da&&(v.bindFramebuffer(v.FRAMEBUFFER,g),l=!0);try{var k=a.texture;k.format!==b.RGBAFormat&&L(k.format)!==
v.getParameter(v.IMPLEMENTATION_COLOR_READ_FORMAT)?console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in RGBA or implementation defined format."):k.type===b.UnsignedByteType||L(k.type)===v.getParameter(v.IMPLEMENTATION_COLOR_READ_TYPE)||k.type===b.FloatType&&ja.get("WEBGL_color_buffer_float")||k.type===b.HalfFloatType&&ja.get("EXT_color_buffer_half_float")?v.checkFramebufferStatus(v.FRAMEBUFFER)===v.FRAMEBUFFER_COMPLETE?0<c&&c<=a.width-e&&0<d&&d<=a.height-f&&v.readPixels(c,
d,e,f,L(k.format),L(k.type),h):console.error("THREE.WebGLRenderer.readRenderTargetPixels: readPixels from renderTarget failed. Framebuffer not complete."):console.error("THREE.WebGLRenderer.readRenderTargetPixels: renderTarget is not in UnsignedByteType or implementation defined type.")}finally{l&&v.bindFramebuffer(v.FRAMEBUFFER,Da)}}}}};b.WebGLRenderTarget=function(a,c,d){this.uuid=b.Math.generateUUID();this.width=a;this.height=c;this.scissor=new b.Vector4(0,0,a,c);this.scissorTest=!1;this.viewport=
new b.Vector4(0,0,a,c);d=d||{};void 0===d.minFilter&&(d.minFilter=b.LinearFilter);this.texture=new b.Texture(void 0,void 0,d.wrapS,d.wrapT,d.magFilter,d.minFilter,d.format,d.type,d.anisotropy,d.encoding);this.depthBuffer=void 0!==d.depthBuffer?d.depthBuffer:!0;this.stencilBuffer=void 0!==d.stencilBuffer?d.stencilBuffer:!0;this.depthTexture=null};b.WebGLRenderTarget.prototype={constructor:b.WebGLRenderTarget,setSize:function(a,b){if(this.width!==a||this.height!==b)this.width=a,this.height=b,this.dispose();
this.viewport.set(0,0,a,b);this.scissor.set(0,0,a,b)},clone:function(){return(new this.constructor).copy(this)},copy:function(a){this.width=a.width;this.height=a.height;this.viewport.copy(a.viewport);this.texture=a.texture.clone();this.depthBuffer=a.depthBuffer;this.stencilBuffer=a.stencilBuffer;this.depthTexture=a.depthTexture;return this},dispose:function(){this.dispatchEvent({type:"dispose"})}};b.EventDispatcher.prototype.apply(b.WebGLRenderTarget.prototype);b.WebGLRenderTargetCube=function(a,
c,d){b.WebGLRenderTarget.call(this,a,c,d);this.activeMipMapLevel=this.activeCubeFace=0};b.WebGLRenderTargetCube.prototype=Object.create(b.WebGLRenderTarget.prototype);b.WebGLRenderTargetCube.prototype.constructor=b.WebGLRenderTargetCube;b.WebGLBufferRenderer=function(a,c,d){var e;this.setMode=function(a){e=a};this.render=function(b,c){a.drawArrays(e,b,c);d.calls++;d.vertices+=c;e===a.TRIANGLES&&(d.faces+=c/3)};this.renderInstances=function(f){var g=c.get("ANGLE_instanced_arrays");if(null===g)console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays.");
else{var h=f.attributes.position,k=0,k=h instanceof b.InterleavedBufferAttribute?h.data.count:h.count;g.drawArraysInstancedANGLE(e,0,k,f.maxInstancedCount);d.calls++;d.vertices+=k*f.maxInstancedCount;e===a.TRIANGLES&&(d.faces+=f.maxInstancedCount*k/3)}}};b.WebGLIndexedBufferRenderer=function(a,b,d){var e,f,g;this.setMode=function(a){e=a};this.setIndex=function(d){d.array instanceof Uint32Array&&b.get("OES_element_index_uint")?(f=a.UNSIGNED_INT,g=4):(f=a.UNSIGNED_SHORT,g=2)};this.render=function(b,
c){a.drawElements(e,c,f,b*g);d.calls++;d.vertices+=c;e===a.TRIANGLES&&(d.faces+=c/3)};this.renderInstances=function(h,k,m){var r=b.get("ANGLE_instanced_arrays");null===r?console.error("THREE.WebGLBufferRenderer: using THREE.InstancedBufferGeometry but hardware does not support extension ANGLE_instanced_arrays."):(r.drawElementsInstancedANGLE(e,m,f,k*g,h.maxInstancedCount),d.calls++,d.vertices+=m*h.maxInstancedCount,e===a.TRIANGLES&&(d.faces+=h.maxInstancedCount*m/3))}};b.WebGLExtensions=function(a){var b=
{};this.get=function(d){if(void 0!==b[d])return b[d];var e;switch(d){case "WEBGL_depth_texture":a.getExtension("WEBGL_depth_texture")||a.getExtension("MOZ_WEBGL_depth_texture")||a.getExtension("WEBKIT_WEBGL_depth_texture");case "EXT_texture_filter_anisotropic":e=a.getExtension("EXT_texture_filter_anisotropic")||a.getExtension("MOZ_EXT_texture_filter_anisotropic")||a.getExtension("WEBKIT_EXT_texture_filter_anisotropic");break;case "WEBGL_compressed_texture_s3tc":e=a.getExtension("WEBGL_compressed_texture_s3tc")||
a.getExtension("MOZ_WEBGL_compressed_texture_s3tc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_s3tc");break;case "WEBGL_compressed_texture_pvrtc":e=a.getExtension("WEBGL_compressed_texture_pvrtc")||a.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc");break;case "WEBGL_compressed_texture_etc1":e=a.getExtension("WEBGL_compressed_texture_etc1");break;default:e=a.getExtension(d)}null===e&&console.warn("THREE.WebGLRenderer: "+d+" extension not supported.");return b[d]=e}};b.WebGLCapabilities=
function(a,b,d){function e(b){if("highp"===b){if(0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.HIGH_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.HIGH_FLOAT).precision)return"highp";b="mediump"}return"mediump"===b&&0<a.getShaderPrecisionFormat(a.VERTEX_SHADER,a.MEDIUM_FLOAT).precision&&0<a.getShaderPrecisionFormat(a.FRAGMENT_SHADER,a.MEDIUM_FLOAT).precision?"mediump":"lowp"}this.getMaxPrecision=e;this.precision=void 0!==d.precision?d.precision:"highp";this.logarithmicDepthBuffer=
void 0!==d.logarithmicDepthBuffer?d.logarithmicDepthBuffer:!1;this.maxTextures=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS);this.maxVertexTextures=a.getParameter(a.MAX_VERTEX_TEXTURE_IMAGE_UNITS);this.maxTextureSize=a.getParameter(a.MAX_TEXTURE_SIZE);this.maxCubemapSize=a.getParameter(a.MAX_CUBE_MAP_TEXTURE_SIZE);this.maxAttributes=a.getParameter(a.MAX_VERTEX_ATTRIBS);this.maxVertexUniforms=a.getParameter(a.MAX_VERTEX_UNIFORM_VECTORS);this.maxVaryings=a.getParameter(a.MAX_VARYING_VECTORS);this.maxFragmentUniforms=
a.getParameter(a.MAX_FRAGMENT_UNIFORM_VECTORS);this.vertexTextures=0<this.maxVertexTextures;this.floatFragmentTextures=!!b.get("OES_texture_float");this.floatVertexTextures=this.vertexTextures&&this.floatFragmentTextures;d=e(this.precision);d!==this.precision&&(console.warn("THREE.WebGLRenderer:",this.precision,"not supported, using",d,"instead."),this.precision=d);this.logarithmicDepthBuffer&&(this.logarithmicDepthBuffer=!!b.get("EXT_frag_depth"))};b.WebGLGeometries=function(a,c,d){function e(a){var b=
a.target;a=g[b.id];null!==a.index&&f(a.index);var k=a.attributes,m;for(m in k)f(k[m]);b.removeEventListener("dispose",e);delete g[b.id];m=c.get(b);m.wireframe&&f(m.wireframe);c.delete(b);b=c.get(a);b.wireframe&&f(b.wireframe);c.delete(a);d.memory.geometries--}function f(d){var e;e=d instanceof b.InterleavedBufferAttribute?c.get(d.data).__webglBuffer:c.get(d).__webglBuffer;void 0!==e&&(a.deleteBuffer(e),d instanceof b.InterleavedBufferAttribute?c.delete(d.data):c.delete(d))}var g={};this.get=function(a){var c=
a.geometry;if(void 0!==g[c.id])return g[c.id];c.addEventListener("dispose",e);var f;c instanceof b.BufferGeometry?f=c:c instanceof b.Geometry&&(void 0===c._bufferGeometry&&(c._bufferGeometry=(new b.BufferGeometry).setFromObject(a)),f=c._bufferGeometry);g[c.id]=f;d.memory.geometries++;return f}};b.WebGLLights=function(){var a={};this.get=function(c){if(void 0!==a[c.id])return a[c.id];var d;switch(c.type){case "DirectionalLight":d={direction:new b.Vector3,color:new b.Color,shadow:!1,shadowBias:0,shadowRadius:1,
shadowMapSize:new b.Vector2};break;case "SpotLight":d={position:new b.Vector3,direction:new b.Vector3,color:new b.Color,distance:0,coneCos:0,penumbraCos:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new b.Vector2};break;case "PointLight":d={position:new b.Vector3,color:new b.Color,distance:0,decay:0,shadow:!1,shadowBias:0,shadowRadius:1,shadowMapSize:new b.Vector2};break;case "HemisphereLight":d={direction:new b.Vector3,skyColor:new b.Color,groundColor:new b.Color}}return a[c.id]=
d}};b.WebGLObjects=function(a,c,d){function e(d,e){var f=d instanceof b.InterleavedBufferAttribute?d.data:d,g=c.get(f);void 0===g.__webglBuffer?(g.__webglBuffer=a.createBuffer(),a.bindBuffer(e,g.__webglBuffer),a.bufferData(e,f.array,f.dynamic?a.DYNAMIC_DRAW:a.STATIC_DRAW),g.version=f.version):g.version!==f.version&&(a.bindBuffer(e,g.__webglBuffer),!1===f.dynamic||-1===f.updateRange.count?a.bufferSubData(e,0,f.array):0===f.updateRange.count?console.error("THREE.WebGLObjects.updateBuffer: dynamic THREE.BufferAttribute marked as needsUpdate but updateRange.count is 0, ensure you are using set methods or updating manually."):
(a.bufferSubData(e,f.updateRange.offset*f.array.BYTES_PER_ELEMENT,f.array.subarray(f.updateRange.offset,f.updateRange.offset+f.updateRange.count)),f.updateRange.count=0),g.version=f.version)}function f(a,b,c){if(b>c){var d=b;b=c;c=d}d=a[b];return void 0===d?(a[b]=[c],!0):-1===d.indexOf(c)?(d.push(c),!0):!1}var g=new b.WebGLGeometries(a,c,d);this.getAttributeBuffer=function(a){return a instanceof b.InterleavedBufferAttribute?c.get(a.data).__webglBuffer:c.get(a).__webglBuffer};this.getWireframeAttribute=
function(d){var g=c.get(d);if(void 0!==g.wireframe)return g.wireframe;var k=[],m=d.index,t=d.attributes;d=t.position;if(null!==m)for(var t={},m=m.array,x=0,l=m.length;x<l;x+=3){var p=m[x+0],q=m[x+1],s=m[x+2];f(t,p,q)&&k.push(p,q);f(t,q,s)&&k.push(q,s);f(t,s,p)&&k.push(s,p)}else for(m=t.position.array,x=0,l=m.length/3-1;x<l;x+=3)p=x+0,q=x+1,s=x+2,k.push(p,q,q,s,s,p);k=new b.BufferAttribute(new (65535<d.count?Uint32Array:Uint16Array)(k),1);e(k,a.ELEMENT_ARRAY_BUFFER);return g.wireframe=k};this.update=
function(c){var d=g.get(c);c.geometry instanceof b.Geometry&&d.updateFromObject(c);c=d.index;var f=d.attributes;null!==c&&e(c,a.ELEMENT_ARRAY_BUFFER);for(var k in f)e(f[k],a.ARRAY_BUFFER);c=d.morphAttributes;for(k in c)for(var f=c[k],m=0,x=f.length;m<x;m++)e(f[m],a.ARRAY_BUFFER);return d}};b.WebGLProgram=function(){function a(a){switch(a){case b.LinearEncoding:return["Linear","( value )"];case b.sRGBEncoding:return["sRGB","( value )"];case b.RGBEEncoding:return["RGBE","( value )"];case b.RGBM7Encoding:return["RGBM",
"( value, 7.0 )"];case b.RGBM16Encoding:return["RGBM","( value, 16.0 )"];case b.RGBDEncoding:return["RGBD","( value, 256.0 )"];case b.GammaEncoding:return["Gamma","( value, float( GAMMA_FACTOR ) )"];default:throw Error("unsupported encoding: "+a);}}function c(b,c){var d=a(c);return"vec4 "+b+"( vec4 value ) { return "+d[0]+"ToLinear"+d[1]+"; }"}function d(b,c){var d=a(c);return"vec4 "+b+"( vec4 value ) { return LinearTo"+d[0]+d[1]+"; }"}function e(a,c){var d;switch(c){case b.LinearToneMapping:d="Linear";
break;case b.ReinhardToneMapping:d="Reinhard";break;case b.Uncharted2ToneMapping:d="Uncharted2";break;case b.CineonToneMapping:d="OptimizedCineon";break;default:throw Error("unsupported toneMapping: "+c);}return"vec3 "+a+"( vec3 color ) { return "+d+"ToneMapping( color ); }"}function f(a,b,c){a=a||{};return[a.derivatives||b.envMapCubeUV||b.bumpMap||b.normalMap||b.flatShading?"#extension GL_OES_standard_derivatives : enable":"",(a.fragDepth||b.logarithmicDepthBuffer)&&c.get("EXT_frag_depth")?"#extension GL_EXT_frag_depth : enable":
"",a.drawBuffers&&c.get("WEBGL_draw_buffers")?"#extension GL_EXT_draw_buffers : require":"",(a.shaderTextureLOD||b.envMap)&&c.get("EXT_shader_texture_lod")?"#extension GL_EXT_shader_texture_lod : enable":""].filter(h).join("\n")}function g(a){var b=[],c;for(c in a){var d=a[c];!1!==d&&b.push("#define "+c+" "+d)}return b.join("\n")}function h(a){return""!==a}function k(a,b){return a.replace(/NUM_DIR_LIGHTS/g,b.numDirLights).replace(/NUM_SPOT_LIGHTS/g,b.numSpotLights).replace(/NUM_POINT_LIGHTS/g,b.numPointLights).replace(/NUM_HEMI_LIGHTS/g,
b.numHemiLights)}function m(a){return a.replace(/#include +<([\w\d.]+)>/g,function(a,c){var d=b.ShaderChunk[c];if(void 0===d)throw Error("Can not resolve #include <"+c+">");return m(d)})}function r(a){return a.replace(/for \( int i \= (\d+)\; i < (\d+)\; i \+\+ \) \{([\s\S]+?)(?=\})\}/g,function(a,b,c,d){a="";for(b=parseInt(b);b<parseInt(c);b++)a+=d.replace(/\[ i \]/g,"[ "+b+" ]");return a})}var t=0;return function(a,l,p,q){var s=a.context,w=p.extensions,y=p.defines,B=p.__webglShader.vertexShader,
z=p.__webglShader.fragmentShader,A="SHADOWMAP_TYPE_BASIC";q.shadowMapType===b.PCFShadowMap?A="SHADOWMAP_TYPE_PCF":q.shadowMapType===b.PCFSoftShadowMap&&(A="SHADOWMAP_TYPE_PCF_SOFT");var K="ENVMAP_TYPE_CUBE",F="ENVMAP_MODE_REFLECTION",G="ENVMAP_BLENDING_MULTIPLY";if(q.envMap){switch(p.envMap.mapping){case b.CubeReflectionMapping:case b.CubeRefractionMapping:K="ENVMAP_TYPE_CUBE";break;case b.CubeUVReflectionMapping:case b.CubeUVRefractionMapping:K="ENVMAP_TYPE_CUBE_UV";break;case b.EquirectangularReflectionMapping:case b.EquirectangularRefractionMapping:K=
"ENVMAP_TYPE_EQUIREC";break;case b.SphericalReflectionMapping:K="ENVMAP_TYPE_SPHERE"}switch(p.envMap.mapping){case b.CubeRefractionMapping:case b.EquirectangularRefractionMapping:F="ENVMAP_MODE_REFRACTION"}switch(p.combine){case b.MultiplyOperation:G="ENVMAP_BLENDING_MULTIPLY";break;case b.MixOperation:G="ENVMAP_BLENDING_MIX";break;case b.AddOperation:G="ENVMAP_BLENDING_ADD"}}var E=0<a.gammaFactor?a.gammaFactor:1,w=f(w,q,a.extensions),R=g(y),M=s.createProgram();p instanceof b.RawShaderMaterial?A=
y="":(y=["precision "+q.precision+" float;","precision "+q.precision+" int;","#define SHADER_NAME "+p.__webglShader.name,R,q.supportsVertexTextures?"#define VERTEX_TEXTURES":"","#define GAMMA_FACTOR "+E,"#define MAX_BONES "+q.maxBones,q.map?"#define USE_MAP":"",q.envMap?"#define USE_ENVMAP":"",q.envMap?"#define "+F:"",q.lightMap?"#define USE_LIGHTMAP":"",q.aoMap?"#define USE_AOMAP":"",q.emissiveMap?"#define USE_EMISSIVEMAP":"",q.bumpMap?"#define USE_BUMPMAP":"",q.normalMap?"#define USE_NORMALMAP":
"",q.displacementMap&&q.supportsVertexTextures?"#define USE_DISPLACEMENTMAP":"",q.specularMap?"#define USE_SPECULARMAP":"",q.roughnessMap?"#define USE_ROUGHNESSMAP":"",q.metalnessMap?"#define USE_METALNESSMAP":"",q.alphaMap?"#define USE_ALPHAMAP":"",q.vertexColors?"#define USE_COLOR":"",q.flatShading?"#define FLAT_SHADED":"",q.skinning?"#define USE_SKINNING":"",q.useVertexTexture?"#define BONE_TEXTURE":"",q.morphTargets?"#define USE_MORPHTARGETS":"",q.morphNormals&&!1===q.flatShading?"#define USE_MORPHNORMALS":
"",q.doubleSided?"#define DOUBLE_SIDED":"",q.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+q.numClippingPlanes,q.shadowMapEnabled?"#define USE_SHADOWMAP":"",q.shadowMapEnabled?"#define "+A:"",q.sizeAttenuation?"#define USE_SIZEATTENUATION":"",q.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":"",q.logarithmicDepthBuffer&&a.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"","uniform mat4 modelMatrix;","uniform mat4 modelViewMatrix;","uniform mat4 projectionMatrix;",
"uniform mat4 viewMatrix;","uniform mat3 normalMatrix;","uniform vec3 cameraPosition;","attribute vec3 position;","attribute vec3 normal;","attribute vec2 uv;","#ifdef USE_COLOR","\tattribute vec3 color;","#endif","#ifdef USE_MORPHTARGETS","\tattribute vec3 morphTarget0;","\tattribute vec3 morphTarget1;","\tattribute vec3 morphTarget2;","\tattribute vec3 morphTarget3;","\t#ifdef USE_MORPHNORMALS","\t\tattribute vec3 morphNormal0;","\t\tattribute vec3 morphNormal1;","\t\tattribute vec3 morphNormal2;",
"\t\tattribute vec3 morphNormal3;","\t#else","\t\tattribute vec3 morphTarget4;","\t\tattribute vec3 morphTarget5;","\t\tattribute vec3 morphTarget6;","\t\tattribute vec3 morphTarget7;","\t#endif","#endif","#ifdef USE_SKINNING","\tattribute vec4 skinIndex;","\tattribute vec4 skinWeight;","#endif","\n"].filter(h).join("\n"),A=[w,"precision "+q.precision+" float;","precision "+q.precision+" int;","#define SHADER_NAME "+p.__webglShader.name,R,q.alphaTest?"#define ALPHATEST "+q.alphaTest:"","#define GAMMA_FACTOR "+
E,q.useFog&&q.fog?"#define USE_FOG":"",q.useFog&&q.fogExp?"#define FOG_EXP2":"",q.map?"#define USE_MAP":"",q.envMap?"#define USE_ENVMAP":"",q.envMap?"#define "+K:"",q.envMap?"#define "+F:"",q.envMap?"#define "+G:"",q.lightMap?"#define USE_LIGHTMAP":"",q.aoMap?"#define USE_AOMAP":"",q.emissiveMap?"#define USE_EMISSIVEMAP":"",q.bumpMap?"#define USE_BUMPMAP":"",q.normalMap?"#define USE_NORMALMAP":"",q.specularMap?"#define USE_SPECULARMAP":"",q.roughnessMap?"#define USE_ROUGHNESSMAP":"",q.metalnessMap?
"#define USE_METALNESSMAP":"",q.alphaMap?"#define USE_ALPHAMAP":"",q.vertexColors?"#define USE_COLOR":"",q.flatShading?"#define FLAT_SHADED":"",q.doubleSided?"#define DOUBLE_SIDED":"",q.flipSided?"#define FLIP_SIDED":"","#define NUM_CLIPPING_PLANES "+q.numClippingPlanes,q.shadowMapEnabled?"#define USE_SHADOWMAP":"",q.shadowMapEnabled?"#define "+A:"",q.premultipliedAlpha?"#define PREMULTIPLIED_ALPHA":"",q.physicallyCorrectLights?"#define PHYSICALLY_CORRECT_LIGHTS":"",q.logarithmicDepthBuffer?"#define USE_LOGDEPTHBUF":
"",q.logarithmicDepthBuffer&&a.extensions.get("EXT_frag_depth")?"#define USE_LOGDEPTHBUF_EXT":"",q.envMap&&a.extensions.get("EXT_shader_texture_lod")?"#define TEXTURE_LOD_EXT":"","uniform mat4 viewMatrix;","uniform vec3 cameraPosition;",q.toneMapping!==b.NoToneMapping?"#define TONE_MAPPING":"",q.toneMapping!==b.NoToneMapping?b.ShaderChunk.tonemapping_pars_fragment:"",q.toneMapping!==b.NoToneMapping?e("toneMapping",q.toneMapping):"",q.outputEncoding||q.mapEncoding||q.envMapEncoding||q.emissiveMapEncoding?
b.ShaderChunk.encodings_pars_fragment:"",q.mapEncoding?c("mapTexelToLinear",q.mapEncoding):"",q.envMapEncoding?c("envMapTexelToLinear",q.envMapEncoding):"",q.emissiveMapEncoding?c("emissiveMapTexelToLinear",q.emissiveMapEncoding):"",q.outputEncoding?d("linearToOutputTexel",q.outputEncoding):"",q.depthPacking?"#define DEPTH_PACKING "+p.depthPacking:"","\n"].filter(h).join("\n"));B=m(B,q);B=k(B,q);z=m(z,q);z=k(z,q);!1===p instanceof b.ShaderMaterial&&(B=r(B),z=r(z));z=A+z;B=b.WebGLShader(s,s.VERTEX_SHADER,
y+B);z=b.WebGLShader(s,s.FRAGMENT_SHADER,z);s.attachShader(M,B);s.attachShader(M,z);void 0!==p.index0AttributeName?s.bindAttribLocation(M,0,p.index0AttributeName):!0===q.morphTargets&&s.bindAttribLocation(M,0,"position");s.linkProgram(M);q=s.getProgramInfoLog(M);K=s.getShaderInfoLog(B);F=s.getShaderInfoLog(z);E=G=!0;if(!1===s.getProgramParameter(M,s.LINK_STATUS))G=!1,console.error("THREE.WebGLProgram: shader error: ",s.getError(),"gl.VALIDATE_STATUS",s.getProgramParameter(M,s.VALIDATE_STATUS),"gl.getProgramInfoLog",
q,K,F);else if(""!==q)console.warn("THREE.WebGLProgram: gl.getProgramInfoLog()",q);else if(""===K||""===F)E=!1;E&&(this.diagnostics={runnable:G,material:p,programLog:q,vertexShader:{log:K,prefix:y},fragmentShader:{log:F,prefix:A}});s.deleteShader(B);s.deleteShader(z);var Q;this.getUniforms=function(){void 0===Q&&(Q=new b.WebGLUniforms(s,M,a));return Q};var L;this.getAttributes=function(){if(void 0===L){for(var a={},b=s.getProgramParameter(M,s.ACTIVE_ATTRIBUTES),c=0;c<b;c++){var d=s.getActiveAttrib(M,
c).name;a[d]=s.getAttribLocation(M,d)}L=a}return L};this.destroy=function(){s.deleteProgram(M);this.program=void 0};Object.defineProperties(this,{uniforms:{get:function(){console.warn("THREE.WebGLProgram: .uniforms is now .getUniforms().");return this.getUniforms()}},attributes:{get:function(){console.warn("THREE.WebGLProgram: .attributes is now .getAttributes().");return this.getAttributes()}}});this.id=t++;this.code=l;this.usedTimes=1;this.program=M;this.vertexShader=B;this.fragmentShader=z;return this}}();
b.WebGLPrograms=function(a,c){function d(a,c){var d;a?a instanceof b.Texture?d=a.encoding:a instanceof b.WebGLRenderTarget&&(d=a.texture.encoding):d=b.LinearEncoding;d===b.LinearEncoding&&c&&(d=b.GammaEncoding);return d}var e=[],f={MeshDepthMaterial:"depth",MeshNormalMaterial:"normal",MeshBasicMaterial:"basic",MeshLambertMaterial:"lambert",MeshPhongMaterial:"phong",MeshStandardMaterial:"physical",MeshPhysicalMaterial:"physical",LineBasicMaterial:"basic",LineDashedMaterial:"dashed",PointsMaterial:"points"},
g="precision supportsVertexTextures map mapEncoding envMap envMapMode envMapEncoding lightMap aoMap emissiveMap emissiveMapEncoding bumpMap normalMap displacementMap specularMap roughnessMap metalnessMap alphaMap combine vertexColors fog useFog fogExp flatShading sizeAttenuation logarithmicDepthBuffer skinning maxBones useVertexTexture morphTargets morphNormals maxMorphTargets maxMorphNormals premultipliedAlpha numDirLights numPointLights numSpotLights numHemiLights shadowMapEnabled shadowMapType toneMapping physicallyCorrectLights alphaTest doubleSided flipSided numClippingPlanes depthPacking".split(" ");
this.getParameters=function(e,g,k,m,t){var s=f[e.type],l;c.floatVertexTextures&&t&&t.skeleton&&t.skeleton.useVertexTexture?l=1024:(l=Math.floor((c.maxVertexUniforms-20)/4),void 0!==t&&t instanceof b.SkinnedMesh&&(l=Math.min(t.skeleton.bones.length,l),l<t.skeleton.bones.length&&console.warn("WebGLRenderer: too many bones - "+t.skeleton.bones.length+", this GPU supports just "+l+" (try OpenGL instead of ANGLE)")));var p=a.getPrecision();null!==e.precision&&(p=c.getMaxPrecision(e.precision),p!==e.precision&&
console.warn("THREE.WebGLProgram.getParameters:",e.precision,"not supported, using",p,"instead."));return{shaderID:s,precision:p,supportsVertexTextures:c.vertexTextures,outputEncoding:d(a.getCurrentRenderTarget(),a.gammaOutput),map:!!e.map,mapEncoding:d(e.map,a.gammaInput),envMap:!!e.envMap,envMapMode:e.envMap&&e.envMap.mapping,envMapEncoding:d(e.envMap,a.gammaInput),envMapCubeUV:!!e.envMap&&(e.envMap.mapping===b.CubeUVReflectionMapping||e.envMap.mapping===b.CubeUVRefractionMapping),lightMap:!!e.lightMap,
aoMap:!!e.aoMap,emissiveMap:!!e.emissiveMap,emissiveMapEncoding:d(e.emissiveMap,a.gammaInput),bumpMap:!!e.bumpMap,normalMap:!!e.normalMap,displacementMap:!!e.displacementMap,roughnessMap:!!e.roughnessMap,metalnessMap:!!e.metalnessMap,specularMap:!!e.specularMap,alphaMap:!!e.alphaMap,combine:e.combine,vertexColors:e.vertexColors,fog:k,useFog:e.fog,fogExp:k instanceof b.FogExp2,flatShading:e.shading===b.FlatShading,sizeAttenuation:e.sizeAttenuation,logarithmicDepthBuffer:c.logarithmicDepthBuffer,skinning:e.skinning,
maxBones:l,useVertexTexture:c.floatVertexTextures&&t&&t.skeleton&&t.skeleton.useVertexTexture,morphTargets:e.morphTargets,morphNormals:e.morphNormals,maxMorphTargets:a.maxMorphTargets,maxMorphNormals:a.maxMorphNormals,numDirLights:g.directional.length,numPointLights:g.point.length,numSpotLights:g.spot.length,numHemiLights:g.hemi.length,numClippingPlanes:m,shadowMapEnabled:a.shadowMap.enabled&&t.receiveShadow&&0<g.shadows.length,shadowMapType:a.shadowMap.type,toneMapping:a.toneMapping,physicallyCorrectLights:a.physicallyCorrectLights,
premultipliedAlpha:e.premultipliedAlpha,alphaTest:e.alphaTest,doubleSided:e.side===b.DoubleSide,flipSided:e.side===b.BackSide,depthPacking:void 0!==e.depthPacking?e.depthPacking:!1}};this.getProgramCode=function(a,b){var c=[];b.shaderID?c.push(b.shaderID):(c.push(a.fragmentShader),c.push(a.vertexShader));if(void 0!==a.defines)for(var d in a.defines)c.push(d),c.push(a.defines[d]);for(d=0;d<g.length;d++)c.push(b[g[d]]);return c.join()};this.acquireProgram=function(c,d,f){for(var g,k=0,m=e.length;k<
m;k++){var l=e[k];if(l.code===f){g=l;++g.usedTimes;break}}void 0===g&&(g=new b.WebGLProgram(a,f,c,d),e.push(g));return g};this.releaseProgram=function(a){if(0===--a.usedTimes){var b=e.indexOf(a);e[b]=e[e.length-1];e.pop();a.destroy()}};this.programs=e};b.WebGLProperties=function(){var a={};this.get=function(b){b=b.uuid;var d=a[b];void 0===d&&(d={},a[b]=d);return d};this.delete=function(b){delete a[b.uuid]};this.clear=function(){a={}}};b.WebGLShader=function(){function a(a){a=a.split("\n");for(var b=
0;b<a.length;b++)a[b]=b+1+": "+a[b];return a.join("\n")}return function(b,d,e){var f=b.createShader(d);b.shaderSource(f,e);b.compileShader(f);!1===b.getShaderParameter(f,b.COMPILE_STATUS)&&console.error("THREE.WebGLShader: Shader couldn't compile.");""!==b.getShaderInfoLog(f)&&console.warn("THREE.WebGLShader: gl.getShaderInfoLog()",d===b.VERTEX_SHADER?"vertex":"fragment",b.getShaderInfoLog(f),a(e));return f}}();b.WebGLShadowMap=function(a,c,d){function e(c,d,e,f){var g=c.geometry,h=null,h=q,k=c.customDepthMaterial;
e&&(h=w,k=c.customDistanceMaterial);k?h=k:(c=c instanceof b.SkinnedMesh&&d.skinning,k=0,void 0!==g.morphTargets&&0<g.morphTargets.length&&d.morphTargets&&(k|=1),c&&(k|=2),h=h[k]);a.localClippingEnabled&&!0===d.clipShadows&&0!==d.clippingPlanes.length&&(k=h.uuid,g=d.uuid,c=C[k],void 0===c&&(c={},C[k]=c),k=c[g],void 0===k&&(k=h.clone(),c[g]=k),h=k);h.visible=d.visible;h.wireframe=d.wireframe;h.side=d.side;h.clipShadows=d.clipShadows;h.clippingPlanes=d.clippingPlanes;h.wireframeLinewidth=d.wireframeLinewidth;
h.linewidth=d.linewidth;e&&void 0!==h.uniforms.lightPos&&h.uniforms.lightPos.value.copy(f);return h}function f(a,c,d){if(!1!==a.visible){a.layers.test(c.layers)&&(a instanceof b.Mesh||a instanceof b.Line||a instanceof b.Points)&&a.castShadow&&(!1===a.frustumCulled||!0===k.intersectsObject(a))&&!0===a.material.visible&&(a.modelViewMatrix.multiplyMatrices(d.matrixWorldInverse,a.matrixWorld),p.push(a));a=a.children;for(var e=0,g=a.length;e<g;e++)f(a[e],c,d)}}var g=a.context,h=a.state,k=new b.Frustum,
m=new b.Matrix4,r=c.shadows,t=new b.Vector2,s=new b.Vector3,l=new b.Vector3,p=[],q=Array(4),w=Array(4),C={},y=[new b.Vector3(1,0,0),new b.Vector3(-1,0,0),new b.Vector3(0,0,1),new b.Vector3(0,0,-1),new b.Vector3(0,1,0),new b.Vector3(0,-1,0)],B=[new b.Vector3(0,1,0),new b.Vector3(0,1,0),new b.Vector3(0,1,0),new b.Vector3(0,1,0),new b.Vector3(0,0,1),new b.Vector3(0,0,-1)],z=[new b.Vector4,new b.Vector4,new b.Vector4,new b.Vector4,new b.Vector4,new b.Vector4];c=new b.MeshDepthMaterial;c.depthPacking=
b.RGBADepthPacking;c.clipping=!0;for(var A=b.ShaderLib.distanceRGBA,K=b.UniformsUtils.clone(A.uniforms),F=0;4!==F;++F){var G=0!==(F&1),E=0!==(F&2),R=c.clone();R.morphTargets=G;R.skinning=E;q[F]=R;G=new b.ShaderMaterial({defines:{USE_SHADOWMAP:""},uniforms:K,vertexShader:A.vertexShader,fragmentShader:A.fragmentShader,morphTargets:G,skinning:E,clipping:!0});w[F]=G}var M=this;this.enabled=!1;this.autoUpdate=!0;this.needsUpdate=!1;this.type=b.PCFShadowMap;this.cullFace=b.CullFaceFront;this.render=function(c,
q){if(!1!==M.enabled&&(!1!==M.autoUpdate||!1!==M.needsUpdate)&&0!==r.length){h.clearColor(1,1,1,1);h.disable(g.BLEND);h.enable(g.CULL_FACE);g.frontFace(g.CCW);g.cullFace(M.cullFace===b.CullFaceFront?g.FRONT:g.BACK);h.setDepthTest(!0);h.setScissorTest(!1);for(var A,w,I=0,G=r.length;I<G;I++){var H=r[I],J=H.shadow,O=J.camera;t.copy(J.mapSize);if(H instanceof b.PointLight){A=6;w=!0;var F=t.x,E=t.y;z[0].set(2*F,E,F,E);z[1].set(0,E,F,E);z[2].set(3*F,E,F,E);z[3].set(F,E,F,E);z[4].set(3*F,0,F,E);z[5].set(F,
0,F,E);t.x*=4;t.y*=2}else A=1,w=!1;null===J.map&&(J.map=new b.WebGLRenderTarget(t.x,t.y,{minFilter:b.NearestFilter,magFilter:b.NearestFilter,format:b.RGBAFormat}),O.updateProjectionMatrix());J instanceof b.SpotLightShadow&&J.update(H);F=J.map;J=J.matrix;l.setFromMatrixPosition(H.matrixWorld);O.position.copy(l);a.setRenderTarget(F);a.clear();for(F=0;F<A;F++){w?(s.copy(O.position),s.add(y[F]),O.up.copy(B[F]),O.lookAt(s),h.viewport(z[F])):(s.setFromMatrixPosition(H.target.matrixWorld),O.lookAt(s));O.updateMatrixWorld();
O.matrixWorldInverse.getInverse(O.matrixWorld);J.set(.5,0,0,.5,0,.5,0,.5,0,0,.5,.5,0,0,0,1);J.multiply(O.projectionMatrix);J.multiply(O.matrixWorldInverse);m.multiplyMatrices(O.projectionMatrix,O.matrixWorldInverse);k.setFromMatrix(m);p.length=0;f(c,q,O);for(var E=0,K=p.length;E<K;E++){var C=p[E],R=d.update(C),ua=C.material;if(ua instanceof b.MultiMaterial)for(var X=R.groups,ua=ua.materials,ta=0,pa=X.length;ta<pa;ta++){var ia=X[ta],qa=ua[ia.materialIndex];!0===qa.visible&&(qa=e(C,qa,w,l),a.renderBufferDirect(O,
null,R,qa,C,ia))}else qa=e(C,ua,w,l),a.renderBufferDirect(O,null,R,qa,C,null)}}}A=a.getClearColor();w=a.getClearAlpha();a.setClearColor(A,w);h.enable(g.BLEND);M.cullFace===b.CullFaceFront&&g.cullFace(g.BACK);M.needsUpdate=!1}}};b.WebGLState=function(a,c,d){var e=this,f=new b.Vector4,g=a.getParameter(a.MAX_VERTEX_ATTRIBS),h=new Uint8Array(g),k=new Uint8Array(g),m=new Uint8Array(g),r={},t=null,s=null,l=null,p=null,q=null,w=null,C=null,y=null,B=!1,z=null,A=null,K=null,F=null,G=null,E=null,R=null,M=null,
Q=null,L=null,D=null,P=null,N=null,T=null,H=null,J=a.getParameter(a.MAX_TEXTURE_IMAGE_UNITS),O=void 0,Y={},V=new b.Vector4,sa=null,Na=null,ca=new b.Vector4,ua=new b.Vector4;this.init=function(){this.clearColor(0,0,0,1);this.clearDepth(1);this.clearStencil(0);this.enable(a.DEPTH_TEST);a.depthFunc(a.LEQUAL);a.frontFace(a.CCW);a.cullFace(a.BACK);this.enable(a.CULL_FACE);this.enable(a.BLEND);a.blendEquation(a.FUNC_ADD);a.blendFunc(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA)};this.initAttributes=function(){for(var a=
0,b=h.length;a<b;a++)h[a]=0};this.enableAttribute=function(b){h[b]=1;0===k[b]&&(a.enableVertexAttribArray(b),k[b]=1);0!==m[b]&&(c.get("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(b,0),m[b]=0)};this.enableAttributeAndDivisor=function(b,c,d){h[b]=1;0===k[b]&&(a.enableVertexAttribArray(b),k[b]=1);m[b]!==c&&(d.vertexAttribDivisorANGLE(b,c),m[b]=c)};this.disableUnusedAttributes=function(){for(var b=0,c=k.length;b<c;b++)k[b]!==h[b]&&(a.disableVertexAttribArray(b),k[b]=0)};this.enable=function(b){!0!==
r[b]&&(a.enable(b),r[b]=!0)};this.disable=function(b){!1!==r[b]&&(a.disable(b),r[b]=!1)};this.getCompressedTextureFormats=function(){if(null===t&&(t=[],c.get("WEBGL_compressed_texture_pvrtc")||c.get("WEBGL_compressed_texture_s3tc")||c.get("WEBGL_compressed_texture_etc1")))for(var b=a.getParameter(a.COMPRESSED_TEXTURE_FORMATS),d=0;d<b.length;d++)t.push(b[d]);return t};this.setBlending=function(c,e,f,g,h,k,m,n){c===b.NoBlending?this.disable(a.BLEND):this.enable(a.BLEND);if(c!==s||n!==B)c===b.AdditiveBlending?
n?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ONE,a.ONE,a.ONE,a.ONE)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.SRC_ALPHA,a.ONE)):c===b.SubtractiveBlending?n?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ZERO,a.ZERO,a.ONE_MINUS_SRC_COLOR,a.ONE_MINUS_SRC_ALPHA)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.ONE_MINUS_SRC_COLOR)):c===b.MultiplyBlending?n?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ZERO,a.ZERO,a.SRC_COLOR,
a.SRC_ALPHA)):(a.blendEquation(a.FUNC_ADD),a.blendFunc(a.ZERO,a.SRC_COLOR)):n?(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.ONE,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA)):(a.blendEquationSeparate(a.FUNC_ADD,a.FUNC_ADD),a.blendFuncSeparate(a.SRC_ALPHA,a.ONE_MINUS_SRC_ALPHA,a.ONE,a.ONE_MINUS_SRC_ALPHA)),s=c,B=n;if(c===b.CustomBlending){h=h||e;k=k||f;m=m||g;if(e!==l||h!==w)a.blendEquationSeparate(d(e),d(h)),l=e,w=h;if(f!==p||g!==q||k!==C||m!==y)a.blendFuncSeparate(d(f),
d(g),d(k),d(m)),p=f,q=g,C=k,y=m}else y=C=w=q=p=l=null};this.setDepthFunc=function(c){if(z!==c){if(c)switch(c){case b.NeverDepth:a.depthFunc(a.NEVER);break;case b.AlwaysDepth:a.depthFunc(a.ALWAYS);break;case b.LessDepth:a.depthFunc(a.LESS);break;case b.LessEqualDepth:a.depthFunc(a.LEQUAL);break;case b.EqualDepth:a.depthFunc(a.EQUAL);break;case b.GreaterEqualDepth:a.depthFunc(a.GEQUAL);break;case b.GreaterDepth:a.depthFunc(a.GREATER);break;case b.NotEqualDepth:a.depthFunc(a.NOTEQUAL);break;default:a.depthFunc(a.LEQUAL)}else a.depthFunc(a.LEQUAL);
z=c}};this.setDepthTest=function(b){b?this.enable(a.DEPTH_TEST):this.disable(a.DEPTH_TEST)};this.setDepthWrite=function(b){A!==b&&(a.depthMask(b),A=b)};this.setColorWrite=function(b){K!==b&&(a.colorMask(b,b,b,b),K=b)};this.setStencilFunc=function(b,c,d){if(G!==b||E!==c||R!==d)a.stencilFunc(b,c,d),G=b,E=c,R=d};this.setStencilOp=function(b,c,d){if(M!==b||Q!==c||L!==d)a.stencilOp(b,c,d),M=b,Q=c,L=d};this.setStencilTest=function(b){b?this.enable(a.STENCIL_TEST):this.disable(a.STENCIL_TEST)};this.setStencilWrite=
function(b){F!==b&&(a.stencilMask(b),F=b)};this.setFlipSided=function(b){D!==b&&(b?a.frontFace(a.CW):a.frontFace(a.CCW),D=b)};this.setLineWidth=function(b){b!==P&&(a.lineWidth(b),P=b)};this.setPolygonOffset=function(b,c,d){b?this.enable(a.POLYGON_OFFSET_FILL):this.disable(a.POLYGON_OFFSET_FILL);!b||N===c&&T===d||(a.polygonOffset(c,d),N=c,T=d)};this.getScissorTest=function(){return H};this.setScissorTest=function(b){(H=b)?this.enable(a.SCISSOR_TEST):this.disable(a.SCISSOR_TEST)};this.activeTexture=
function(b){void 0===b&&(b=a.TEXTURE0+J-1);O!==b&&(a.activeTexture(b),O=b)};this.bindTexture=function(b,c){void 0===O&&e.activeTexture();var d=Y[O];void 0===d&&(d={type:void 0,texture:void 0},Y[O]=d);if(d.type!==b||d.texture!==c)a.bindTexture(b,c),d.type=b,d.texture=c};this.compressedTexImage2D=function(){try{a.compressedTexImage2D.apply(a,arguments)}catch(b){console.error(b)}};this.texImage2D=function(){try{a.texImage2D.apply(a,arguments)}catch(b){console.error(b)}};this.clearColor=function(b,c,
d,e){f.set(b,c,d,e);!1===V.equals(f)&&(a.clearColor(b,c,d,e),V.copy(f))};this.clearDepth=function(b){sa!==b&&(a.clearDepth(b),sa=b)};this.clearStencil=function(b){Na!==b&&(a.clearStencil(b),Na=b)};this.scissor=function(b){!1===ca.equals(b)&&(a.scissor(b.x,b.y,b.z,b.w),ca.copy(b))};this.viewport=function(b){!1===ua.equals(b)&&(a.viewport(b.x,b.y,b.z,b.w),ua.copy(b))};this.reset=function(){for(var b=0;b<k.length;b++)1===k[b]&&(a.disableVertexAttribArray(b),k[b]=0);r={};t=null;O=void 0;Y={};D=F=A=K=
s=null}};b.WebGLUniforms=function(){var a=[],b=[],d=function(b,c,d){var e=b[0];if(0>=e||0<e)return b;var f=c*d,g=a[f];void 0===g&&(g=new Float32Array(f),a[f]=g);if(0!==c)for(e.toArray(g,0),e=1,f=0;e!==c;++e)f+=d,b[e].toArray(g,f);return g},e=function(a,d){var e=b[d];void 0===e&&(e=new Int32Array(d),b[d]=e);for(var f=0;f!==d;++f)e[f]=a.allocTextureUnit();return e},f=function(a,b){a.uniform1f(this.addr,b)},g=function(a,b){a.uniform1i(this.addr,b)},h=function(a,b){void 0===b.x?a.uniform2fv(this.addr,
b):a.uniform2f(this.addr,b.x,b.y)},k=function(a,b){void 0!==b.x?a.uniform3f(this.addr,b.x,b.y,b.z):void 0!==b.r?a.uniform3f(this.addr,b.r,b.g,b.b):a.uniform3fv(this.addr,b)},m=function(a,b){void 0===b.x?a.uniform4fv(this.addr,b):a.uniform4f(this.addr,b.x,b.y,b.z,b.w)},r=function(a,b){a.uniformMatrix2fv(this.addr,!1,b.elements||b)},s=function(a,b){a.uniformMatrix3fv(this.addr,!1,b.elements||b)},x=function(a,b){a.uniformMatrix4fv(this.addr,!1,b.elements||b)},l=function(a,b,c){var d=c.allocTextureUnit();
a.uniform1i(this.addr,d);b&&c.setTexture2D(b,d)},p=function(a,b,c){var d=c.allocTextureUnit();a.uniform1i(this.addr,d);b&&c.setTextureCube(b,d)},q=function(a,b){a.uniform2iv(this.addr,b)},w=function(a,b){a.uniform3iv(this.addr,b)},C=function(a,b){a.uniform4iv(this.addr,b)},y=function(a){switch(a){case 5126:return f;case 35664:return h;case 35665:return k;case 35666:return m;case 35674:return r;case 35675:return s;case 35676:return x;case 35678:return l;case 35680:return p;case 5124:case 35670:return g;
case 35667:case 35671:return q;case 35668:case 35672:return w;case 35669:case 35673:return C}},B=function(a,b){a.uniform1fv(this.addr,b)},z=function(a,b){a.uniform1iv(this.addr,b)},A=function(a,b){a.uniform2fv(this.addr,d(b,this.size,2))},K=function(a,b){a.uniform3fv(this.addr,d(b,this.size,3))},F=function(a,b){a.uniform4fv(this.addr,d(b,this.size,4))},G=function(a,b){a.uniformMatrix2fv(this.addr,!1,d(b,this.size,4))},E=function(a,b){a.uniformMatrix3fv(this.addr,!1,d(b,this.size,9))},R=function(a,
b){a.uniformMatrix4fv(this.addr,!1,d(b,this.size,16))},M=function(a,b,c){var d=b.length,f=e(c,d);a.uniform1iv(this.addr,f);for(a=0;a!==d;++a){var g=b[a];g&&c.setTexture2D(g,f[a])}},Q=function(a,b,c){var d=b.length,f=e(c,d);a.uniform1iv(this.addr,f);for(a=0;a!==d;++a){var g=b[a];g&&c.setTextureCube(g,f[a])}},L=function(a){switch(a){case 5126:return B;case 35664:return A;case 35665:return K;case 35666:return F;case 35674:return G;case 35675:return E;case 35676:return R;case 35678:return M;case 35680:return Q;
case 5124:case 35670:return z;case 35667:case 35671:return q;case 35668:case 35672:return w;case 35669:case 35673:return C}},D=function(a,b,c){this.id=a;this.addr=c;this.setValue=y(b.type)},P=function(a,b,c){this.id=a;this.addr=c;this.size=b.size;this.setValue=L(b.type)},N=function(a){this.id=a;this.seq=[];this.map={}};N.prototype.setValue=function(a,b){for(var c=this.seq,d=0,e=c.length;d!==e;++d){var f=c[d];f.setValue(a,b[f.id])}};var T=/([\w\d_]+)(\])?(\[|\.)?/g,H=function(a,b,c){this.seq=[];this.map=
{};this.renderer=c;c=a.getProgramParameter(b,a.ACTIVE_UNIFORMS);for(var d=0;d!==c;++d){var e=a.getActiveUniform(b,d),f=a.getUniformLocation(b,e.name),g=this,h=e.name,k=h.length;for(T.lastIndex=0;;){var l=T.exec(h),m=T.lastIndex,n=l[1],p=l[3];"]"===l[2]&&(n|=0);if(void 0===p||"["===p&&m+2===k){h=g;e=void 0===p?new D(n,e,f):new P(n,e,f);h.seq.push(e);h.map[e.id]=e;break}else p=g.map[n],void 0===p&&(p=new N(n),n=g,g=p,n.seq.push(g),n.map[g.id]=g),g=p}}};H.prototype.setValue=function(a,b,c){b=this.map[b];
void 0!==b&&b.setValue(a,c,this.renderer)};H.prototype.set=function(a,b,c){var d=this.map[c];void 0!==d&&d.setValue(a,b[c],this.renderer)};H.prototype.setOptional=function(a,b,c){b=b[c];void 0!==b&&this.setValue(a,c,b)};H.upload=function(a,b,c,d){for(var e=0,f=b.length;e!==f;++e){var g=b[e],h=c[g.id];!1!==h.needsUpdate&&g.setValue(a,h.value,d)}};H.seqWithValue=function(a,b){for(var c=[],d=0,e=a.length;d!==e;++d){var f=a[d];f.id in b&&c.push(f)}return c};H.splitDynamic=function(a,b){for(var c=null,
d=a.length,e=0,f=0;f!==d;++f){var g=a[f],h=b[g.id];h&&!0===h.dynamic?(null===c&&(c=[]),c.push(g)):(e<f&&(a[e]=g),++e)}e<d&&(a.length=e);return c};H.evalDynamic=function(a,b,c,d){for(var e=0,f=a.length;e!==f;++e){var g=b[a[e].id],h=g.onUpdateCallback;void 0!==h&&h.call(g,c,d)}};return H}();b.LensFlarePlugin=function(a,c){var d,e,f,g,h,k,m,r,s,x,l=a.context,p=a.state,q,w,C,y,B,z;this.render=function(A,K,F){if(0!==c.length){A=new b.Vector3;var G=F.w/F.z,E=.5*F.z,R=.5*F.w,M=16/F.w,Q=new b.Vector2(M*G,
M),L=new b.Vector3(1,1,0),D=new b.Vector2(1,1),P=new b.Box2;P.min.set(0,0);P.max.set(F.z-16,F.w-16);if(void 0===y){var M=new Float32Array([-1,-1,0,0,1,-1,1,0,1,1,1,1,-1,1,0,1]),N=new Uint16Array([0,1,2,0,2,3]);q=l.createBuffer();w=l.createBuffer();l.bindBuffer(l.ARRAY_BUFFER,q);l.bufferData(l.ARRAY_BUFFER,M,l.STATIC_DRAW);l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,w);l.bufferData(l.ELEMENT_ARRAY_BUFFER,N,l.STATIC_DRAW);B=l.createTexture();z=l.createTexture();p.bindTexture(l.TEXTURE_2D,B);l.texImage2D(l.TEXTURE_2D,
0,l.RGB,16,16,0,l.RGB,l.UNSIGNED_BYTE,null);l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE);l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,l.CLAMP_TO_EDGE);l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST);l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST);p.bindTexture(l.TEXTURE_2D,z);l.texImage2D(l.TEXTURE_2D,0,l.RGBA,16,16,0,l.RGBA,l.UNSIGNED_BYTE,null);l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_S,l.CLAMP_TO_EDGE);l.texParameteri(l.TEXTURE_2D,l.TEXTURE_WRAP_T,
l.CLAMP_TO_EDGE);l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MAG_FILTER,l.NEAREST);l.texParameteri(l.TEXTURE_2D,l.TEXTURE_MIN_FILTER,l.NEAREST);var M=C={vertexShader:"uniform lowp int renderType;\nuniform vec3 screenPosition;\nuniform vec2 scale;\nuniform float rotation;\nuniform sampler2D occlusionMap;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nvUV = uv;\nvec2 pos = position;\nif ( renderType == 2 ) {\nvec4 visibility = texture2D( occlusionMap, vec2( 0.1, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.1 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.9, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.9 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.1, 0.5 ) );\nvisibility += texture2D( occlusionMap, vec2( 0.5, 0.5 ) );\nvVisibility = visibility.r / 9.0;\nvVisibility *= 1.0 - visibility.g / 9.0;\nvVisibility *= visibility.b / 9.0;\nvVisibility *= 1.0 - visibility.a / 9.0;\npos.x = cos( rotation ) * position.x - sin( rotation ) * position.y;\npos.y = sin( rotation ) * position.x + cos( rotation ) * position.y;\n}\ngl_Position = vec4( ( pos * scale + screenPosition.xy ).xy, screenPosition.z, 1.0 );\n}",
fragmentShader:"uniform lowp int renderType;\nuniform sampler2D map;\nuniform float opacity;\nuniform vec3 color;\nvarying vec2 vUV;\nvarying float vVisibility;\nvoid main() {\nif ( renderType == 0 ) {\ngl_FragColor = vec4( 1.0, 0.0, 1.0, 0.0 );\n} else if ( renderType == 1 ) {\ngl_FragColor = texture2D( map, vUV );\n} else {\nvec4 texture = texture2D( map, vUV );\ntexture.a *= opacity * vVisibility;\ngl_FragColor = texture;\ngl_FragColor.rgb *= color;\n}\n}"},N=l.createProgram(),T=l.createShader(l.FRAGMENT_SHADER),
H=l.createShader(l.VERTEX_SHADER),J="precision "+a.getPrecision()+" float;\n";l.shaderSource(T,J+M.fragmentShader);l.shaderSource(H,J+M.vertexShader);l.compileShader(T);l.compileShader(H);l.attachShader(N,T);l.attachShader(N,H);l.linkProgram(N);y=N;s=l.getAttribLocation(y,"position");x=l.getAttribLocation(y,"uv");d=l.getUniformLocation(y,"renderType");e=l.getUniformLocation(y,"map");f=l.getUniformLocation(y,"occlusionMap");g=l.getUniformLocation(y,"opacity");h=l.getUniformLocation(y,"color");k=l.getUniformLocation(y,
"scale");m=l.getUniformLocation(y,"rotation");r=l.getUniformLocation(y,"screenPosition")}l.useProgram(y);p.initAttributes();p.enableAttribute(s);p.enableAttribute(x);p.disableUnusedAttributes();l.uniform1i(f,0);l.uniform1i(e,1);l.bindBuffer(l.ARRAY_BUFFER,q);l.vertexAttribPointer(s,2,l.FLOAT,!1,16,0);l.vertexAttribPointer(x,2,l.FLOAT,!1,16,8);l.bindBuffer(l.ELEMENT_ARRAY_BUFFER,w);p.disable(l.CULL_FACE);p.setDepthWrite(!1);N=0;for(T=c.length;N<T;N++)if(M=16/F.w,Q.set(M*G,M),H=c[N],A.set(H.matrixWorld.elements[12],
H.matrixWorld.elements[13],H.matrixWorld.elements[14]),A.applyMatrix4(K.matrixWorldInverse),A.applyProjection(K.projectionMatrix),L.copy(A),D.x=F.x+L.x*E+E-8,D.y=F.y+L.y*R+R-8,!0===P.containsPoint(D)){p.activeTexture(l.TEXTURE0);p.bindTexture(l.TEXTURE_2D,null);p.activeTexture(l.TEXTURE1);p.bindTexture(l.TEXTURE_2D,B);l.copyTexImage2D(l.TEXTURE_2D,0,l.RGB,D.x,D.y,16,16,0);l.uniform1i(d,0);l.uniform2f(k,Q.x,Q.y);l.uniform3f(r,L.x,L.y,L.z);p.disable(l.BLEND);p.enable(l.DEPTH_TEST);l.drawElements(l.TRIANGLES,
6,l.UNSIGNED_SHORT,0);p.activeTexture(l.TEXTURE0);p.bindTexture(l.TEXTURE_2D,z);l.copyTexImage2D(l.TEXTURE_2D,0,l.RGBA,D.x,D.y,16,16,0);l.uniform1i(d,1);p.disable(l.DEPTH_TEST);p.activeTexture(l.TEXTURE1);p.bindTexture(l.TEXTURE_2D,B);l.drawElements(l.TRIANGLES,6,l.UNSIGNED_SHORT,0);H.positionScreen.copy(L);H.customUpdateCallback?H.customUpdateCallback(H):H.updateLensFlares();l.uniform1i(d,2);p.enable(l.BLEND);for(var J=0,O=H.lensFlares.length;J<O;J++){var Y=H.lensFlares[J];.001<Y.opacity&&.001<Y.scale&&
(L.x=Y.x,L.y=Y.y,L.z=Y.z,M=Y.size*Y.scale/F.w,Q.x=M*G,Q.y=M,l.uniform3f(r,L.x,L.y,L.z),l.uniform2f(k,Q.x,Q.y),l.uniform1f(m,Y.rotation),l.uniform1f(g,Y.opacity),l.uniform3f(h,Y.color.r,Y.color.g,Y.color.b),p.setBlending(Y.blending,Y.blendEquation,Y.blendSrc,Y.blendDst),a.setTexture2D(Y.texture,1),l.drawElements(l.TRIANGLES,6,l.UNSIGNED_SHORT,0))}}p.enable(l.CULL_FACE);p.enable(l.DEPTH_TEST);p.setDepthWrite(!0);a.resetGLState()}}};b.SpritePlugin=function(a,c){var d,e,f,g,h,k,m,r,s,x,l,p,q,w,C,y,B;
function z(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:b.id-a.id}var A=a.context,K=a.state,F,G,E,R,M=new b.Vector3,Q=new b.Quaternion,L=new b.Vector3;this.render=function(D,P){if(0!==c.length){if(void 0===E){var N=new Float32Array([-.5,-.5,0,0,.5,-.5,1,0,.5,.5,1,1,-.5,.5,0,1]),T=new Uint16Array([0,1,2,0,2,3]);F=A.createBuffer();G=A.createBuffer();A.bindBuffer(A.ARRAY_BUFFER,F);A.bufferData(A.ARRAY_BUFFER,N,A.STATIC_DRAW);A.bindBuffer(A.ELEMENT_ARRAY_BUFFER,
G);A.bufferData(A.ELEMENT_ARRAY_BUFFER,T,A.STATIC_DRAW);var N=A.createProgram(),T=A.createShader(A.VERTEX_SHADER),H=A.createShader(A.FRAGMENT_SHADER);A.shaderSource(T,["precision "+a.getPrecision()+" float;","uniform mat4 modelViewMatrix;\nuniform mat4 projectionMatrix;\nuniform float rotation;\nuniform vec2 scale;\nuniform vec2 uvOffset;\nuniform vec2 uvScale;\nattribute vec2 position;\nattribute vec2 uv;\nvarying vec2 vUV;\nvoid main() {\nvUV = uvOffset + uv * uvScale;\nvec2 alignedPosition = position * scale;\nvec2 rotatedPosition;\nrotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;\nrotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;\nvec4 finalPosition;\nfinalPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );\nfinalPosition.xy += rotatedPosition;\nfinalPosition = projectionMatrix * finalPosition;\ngl_Position = finalPosition;\n}"].join("\n"));
A.shaderSource(H,["precision "+a.getPrecision()+" float;","uniform vec3 color;\nuniform sampler2D map;\nuniform float opacity;\nuniform int fogType;\nuniform vec3 fogColor;\nuniform float fogDensity;\nuniform float fogNear;\nuniform float fogFar;\nuniform float alphaTest;\nvarying vec2 vUV;\nvoid main() {\nvec4 texture = texture2D( map, vUV );\nif ( texture.a < alphaTest ) discard;\ngl_FragColor = vec4( color * texture.xyz, texture.a * opacity );\nif ( fogType > 0 ) {\nfloat depth = gl_FragCoord.z / gl_FragCoord.w;\nfloat fogFactor = 0.0;\nif ( fogType == 1 ) {\nfogFactor = smoothstep( fogNear, fogFar, depth );\n} else {\nconst float LOG2 = 1.442695;\nfogFactor = exp2( - fogDensity * fogDensity * depth * depth * LOG2 );\nfogFactor = 1.0 - clamp( fogFactor, 0.0, 1.0 );\n}\ngl_FragColor = mix( gl_FragColor, vec4( fogColor, gl_FragColor.w ), fogFactor );\n}\n}"].join("\n"));
A.compileShader(T);A.compileShader(H);A.attachShader(N,T);A.attachShader(N,H);A.linkProgram(N);E=N;y=A.getAttribLocation(E,"position");B=A.getAttribLocation(E,"uv");d=A.getUniformLocation(E,"uvOffset");e=A.getUniformLocation(E,"uvScale");f=A.getUniformLocation(E,"rotation");g=A.getUniformLocation(E,"scale");h=A.getUniformLocation(E,"color");k=A.getUniformLocation(E,"map");m=A.getUniformLocation(E,"opacity");r=A.getUniformLocation(E,"modelViewMatrix");s=A.getUniformLocation(E,"projectionMatrix");x=
A.getUniformLocation(E,"fogType");l=A.getUniformLocation(E,"fogDensity");p=A.getUniformLocation(E,"fogNear");q=A.getUniformLocation(E,"fogFar");w=A.getUniformLocation(E,"fogColor");C=A.getUniformLocation(E,"alphaTest");N=document.createElement("canvas");N.width=8;N.height=8;T=N.getContext("2d");T.fillStyle="white";T.fillRect(0,0,8,8);R=new b.Texture(N);R.needsUpdate=!0}A.useProgram(E);K.initAttributes();K.enableAttribute(y);K.enableAttribute(B);K.disableUnusedAttributes();K.disable(A.CULL_FACE);K.enable(A.BLEND);
A.bindBuffer(A.ARRAY_BUFFER,F);A.vertexAttribPointer(y,2,A.FLOAT,!1,16,0);A.vertexAttribPointer(B,2,A.FLOAT,!1,16,8);A.bindBuffer(A.ELEMENT_ARRAY_BUFFER,G);A.uniformMatrix4fv(s,!1,P.projectionMatrix.elements);K.activeTexture(A.TEXTURE0);A.uniform1i(k,0);T=N=0;(H=D.fog)?(A.uniform3f(w,H.color.r,H.color.g,H.color.b),H instanceof b.Fog?(A.uniform1f(p,H.near),A.uniform1f(q,H.far),A.uniform1i(x,1),T=N=1):H instanceof b.FogExp2&&(A.uniform1f(l,H.density),A.uniform1i(x,2),T=N=2)):(A.uniform1i(x,0),T=N=0);
for(var H=0,J=c.length;H<J;H++){var O=c[H];O.modelViewMatrix.multiplyMatrices(P.matrixWorldInverse,O.matrixWorld);O.z=-O.modelViewMatrix.elements[14]}c.sort(z);for(var Y=[],H=0,J=c.length;H<J;H++){var O=c[H],V=O.material;A.uniform1f(C,V.alphaTest);A.uniformMatrix4fv(r,!1,O.modelViewMatrix.elements);O.matrixWorld.decompose(M,Q,L);Y[0]=L.x;Y[1]=L.y;O=0;D.fog&&V.fog&&(O=T);N!==O&&(A.uniform1i(x,O),N=O);null!==V.map?(A.uniform2f(d,V.map.offset.x,V.map.offset.y),A.uniform2f(e,V.map.repeat.x,V.map.repeat.y)):
(A.uniform2f(d,0,0),A.uniform2f(e,1,1));A.uniform1f(m,V.opacity);A.uniform3f(h,V.color.r,V.color.g,V.color.b);A.uniform1f(f,V.rotation);A.uniform2fv(g,Y);K.setBlending(V.blending,V.blendEquation,V.blendSrc,V.blendDst);K.setDepthTest(V.depthTest);K.setDepthWrite(V.depthWrite);V.map?a.setTexture2D(V.map,0):a.setTexture2D(R,0);A.drawElements(A.TRIANGLES,6,A.UNSIGNED_SHORT,0)}K.enable(A.CULL_FACE);a.resetGLState()}}};b.RenderableObject=function(){this.id=0;this.object=null;this.renderOrder=this.z=0};
b.RenderableFace=function(){this.id=0;this.v1=new b.RenderableVertex;this.v2=new b.RenderableVertex;this.v3=new b.RenderableVertex;this.normalModel=new b.Vector3;this.vertexNormalsModel=[new b.Vector3,new b.Vector3,new b.Vector3];this.vertexNormalsLength=0;this.color=new b.Color;this.material=null;this.uvs=[new b.Vector2,new b.Vector2,new b.Vector2];this.renderOrder=this.z=0};b.RenderableVertex=function(){this.position=new b.Vector3;this.positionWorld=new b.Vector3;this.positionScreen=new b.Vector4;
this.visible=!0};b.RenderableVertex.prototype.copy=function(a){this.positionWorld.copy(a.positionWorld);this.positionScreen.copy(a.positionScreen)};b.RenderableLine=function(){this.id=0;this.v1=new b.RenderableVertex;this.v2=new b.RenderableVertex;this.vertexColors=[new b.Color,new b.Color];this.material=null;this.renderOrder=this.z=0};b.RenderableSprite=function(){this.id=0;this.object=null;this.rotation=this.z=this.y=this.x=0;this.scale=new b.Vector2;this.material=null;this.renderOrder=0};b.Projector=
function(){function a(){if(x===p){var a=new b.RenderableVertex;l.push(a);p++;x++;return a}return l[x++]}function c(){if(w===y){var a=new b.RenderableFace;C.push(a);y++;w++;return a}return C[w++]}function d(){if(z===K){var a=new b.RenderableLine;A.push(a);K++;z++;return a}return A[z++]}function e(){if(G===R){var a=new b.RenderableSprite;E.push(a);R++;G++;return a}return E[G++]}function f(a,b){return a.renderOrder!==b.renderOrder?a.renderOrder-b.renderOrder:a.z!==b.z?b.z-a.z:a.id!==b.id?a.id-b.id:0}
function g(a,b){var c=0,d=1,e=a.z+a.w,f=b.z+b.w,g=-a.z+a.w,h=-b.z+b.w;if(0<=e&&0<=f&&0<=g&&0<=h)return!0;if(0>e&&0>f||0>g&&0>h)return!1;0>e?c=Math.max(c,e/(e-f)):0>f&&(d=Math.min(d,e/(e-f)));0>g?c=Math.max(c,g/(g-h)):0>h&&(d=Math.min(d,g/(g-h)));if(d<c)return!1;a.lerp(b,c);b.lerp(a,1-d);return!0}var h,k,m=[],r=0,s,x,l=[],p=0,q,w,C=[],y=0,B,z,A=[],K=0,F,G,E=[],R=0,M={objects:[],lights:[],elements:[]},Q=new b.Vector3,L=new b.Vector4,D=new b.Box3(new b.Vector3(-1,-1,-1),new b.Vector3(1,1,1)),P=new b.Box3,
N=Array(3),T=new b.Matrix4,H=new b.Matrix4,J,O=new b.Matrix4,Y=new b.Matrix3,V=new b.Frustum,ba=new b.Vector4,ea=new b.Vector4;this.projectVector=function(a,b){console.warn("THREE.Projector: .projectVector() is now vector.project().");a.project(b)};this.unprojectVector=function(a,b){console.warn("THREE.Projector: .unprojectVector() is now vector.unproject().");a.unproject(b)};this.pickingRay=function(a,b){console.error("THREE.Projector: .pickingRay() is now raycaster.setFromCamera().")};var ca=new function(){function e(a){var b=
a.positionWorld,c=a.positionScreen;b.copy(a.position).applyMatrix4(J);c.copy(b).applyMatrix4(H);b=1/c.w;c.x*=b;c.y*=b;c.z*=b;a.visible=-1<=c.x&&1>=c.x&&-1<=c.y&&1>=c.y&&-1<=c.z&&1>=c.z}function f(a,b,c){if(!0===a.visible||!0===b.visible||!0===c.visible)return!0;N[0]=a.positionScreen;N[1]=b.positionScreen;N[2]=c.positionScreen;return D.intersectsBox(P.setFromPoints(N))}function g(a,b,c){return 0>(c.positionScreen.x-a.positionScreen.x)*(b.positionScreen.y-a.positionScreen.y)-(c.positionScreen.y-a.positionScreen.y)*
(b.positionScreen.x-a.positionScreen.x)}var h=[],k=[],m=null,n=null,p=new b.Matrix3;return{setObject:function(a){m=a;n=m.material;p.getNormalMatrix(m.matrixWorld);h.length=0;k.length=0},projectVertex:e,checkTriangleVisibility:f,checkBackfaceCulling:g,pushVertex:function(b,c,d){s=a();s.position.set(b,c,d);e(s)},pushNormal:function(a,b,c){h.push(a,b,c)},pushUv:function(a,b){k.push(a,b)},pushLine:function(a,b){var c=l[a],e=l[b];B=d();B.id=m.id;B.v1.copy(c);B.v2.copy(e);B.z=(c.positionScreen.z+e.positionScreen.z)/
2;B.renderOrder=m.renderOrder;B.material=m.material;M.elements.push(B)},pushTriangle:function(a,d,e){var r=l[a],s=l[d],u=l[e];if(!1!==f(r,s,u)&&(n.side===b.DoubleSide||!0===g(r,s,u))){q=c();q.id=m.id;q.v1.copy(r);q.v2.copy(s);q.v3.copy(u);q.z=(r.positionScreen.z+s.positionScreen.z+u.positionScreen.z)/3;q.renderOrder=m.renderOrder;q.normalModel.fromArray(h,3*a);q.normalModel.applyMatrix3(p).normalize();for(r=0;3>r;r++)s=q.vertexNormalsModel[r],s.fromArray(h,3*arguments[r]),s.applyMatrix3(p).normalize(),
q.uvs[r].fromArray(k,2*arguments[r]);q.vertexNormalsLength=3;q.material=m.material;M.elements.push(q)}}}};this.projectScene=function(p,s,t,A){G=z=w=0;M.elements.length=0;!0===p.autoUpdate&&p.updateMatrixWorld();null===s.parent&&s.updateMatrixWorld();T.copy(s.matrixWorldInverse.getInverse(s.matrixWorld));H.multiplyMatrices(s.projectionMatrix,T);V.setFromMatrix(H);k=0;M.objects.length=0;M.lights.length=0;p.traverseVisible(function(a){if(a instanceof b.Light)M.lights.push(a);else if((a instanceof b.Mesh||
a instanceof b.Line||a instanceof b.Sprite)&&!1!==a.material.visible&&(!1===a.frustumCulled||!0===V.intersectsObject(a))){if(k===r){var c=new b.RenderableObject;m.push(c);r++;k++;h=c}else h=m[k++];h.id=a.id;h.object=a;Q.setFromMatrixPosition(a.matrixWorld);Q.applyProjection(H);h.z=Q.z;h.renderOrder=a.renderOrder;M.objects.push(h)}});!0===t&&M.objects.sort(f);p=0;for(t=M.objects.length;p<t;p++){var y=M.objects[p].object,E=y.geometry;ca.setObject(y);J=y.matrixWorld;x=0;if(y instanceof b.Mesh)if(E instanceof
b.BufferGeometry){var D=E.attributes,y=E.groups;if(void 0!==D.position){for(var K=D.position.array,C=0,R=K.length;C<R;C+=3)ca.pushVertex(K[C],K[C+1],K[C+2]);if(void 0!==D.normal)for(var N=D.normal.array,C=0,R=N.length;C<R;C+=3)ca.pushNormal(N[C],N[C+1],N[C+2]);if(void 0!==D.uv)for(D=D.uv.array,C=0,R=D.length;C<R;C+=2)ca.pushUv(D[C],D[C+1]);if(null!==E.index)if(K=E.index.array,0<y.length)for(p=0;p<y.length;p++)for(R=y[p],C=R.start,R=R.start+R.count;C<R;C+=3)ca.pushTriangle(K[C],K[C+1],K[C+2]);else for(C=
0,R=K.length;C<R;C+=3)ca.pushTriangle(K[C],K[C+1],K[C+2]);else for(C=0,R=K.length/3;C<R;C+=3)ca.pushTriangle(C,C+1,C+2)}}else{if(E instanceof b.Geometry){var P=E.vertices,C=E.faces,R=E.faceVertexUvs[0];Y.getNormalMatrix(J);for(var K=y.material,D=K instanceof b.MultiMaterial,N=!0===D?y.material:null,ka=0,W=P.length;ka<W;ka++){var Z=P[ka];Q.copy(Z);if(!0===K.morphTargets)for(var ha=E.morphTargets,$=y.morphTargetInfluences,da=0,za=ha.length;da<za;da++){var fa=$[da];if(0!==fa){var la=ha[da].vertices[ka];
Q.x+=(la.x-Z.x)*fa;Q.y+=(la.y-Z.y)*fa;Q.z+=(la.z-Z.z)*fa}}ca.pushVertex(Q.x,Q.y,Q.z)}P=0;for(ka=C.length;P<ka;P++)if(W=C[P],K=!0===D?N.materials[W.materialIndex]:y.material,void 0!==K&&($=K.side,E=l[W.a],Z=l[W.b],ha=l[W.c],!1!==ca.checkTriangleVisibility(E,Z,ha))){da=ca.checkBackfaceCulling(E,Z,ha);if($!==b.DoubleSide){if($===b.FrontSide&&!1===da)continue;if($===b.BackSide&&!0===da)continue}q=c();q.id=y.id;q.v1.copy(E);q.v2.copy(Z);q.v3.copy(ha);q.normalModel.copy(W.normal);!1!==da||$!==b.BackSide&&
$!==b.DoubleSide||q.normalModel.negate();q.normalModel.applyMatrix3(Y).normalize();za=W.vertexNormals;fa=0;for(la=Math.min(za.length,3);fa<la;fa++){var aa=q.vertexNormalsModel[fa];aa.copy(za[fa]);!1!==da||$!==b.BackSide&&$!==b.DoubleSide||aa.negate();aa.applyMatrix3(Y).normalize()}q.vertexNormalsLength=za.length;$=R[P];if(void 0!==$)for(da=0;3>da;da++)q.uvs[da].copy($[da]);q.color=W.color;q.material=K;q.z=(E.positionScreen.z+Z.positionScreen.z+ha.positionScreen.z)/3;q.renderOrder=y.renderOrder;M.elements.push(q)}}}else if(y instanceof
b.Line)if(E instanceof b.BufferGeometry){if(D=E.attributes,void 0!==D.position){K=D.position.array;C=0;for(R=K.length;C<R;C+=3)ca.pushVertex(K[C],K[C+1],K[C+2]);if(null!==E.index)for(K=E.index.array,C=0,R=K.length;C<R;C+=2)ca.pushLine(K[C],K[C+1]);else for(D=y instanceof b.LineSegments?2:1,C=0,R=K.length/3-1;C<R;C+=D)ca.pushLine(C,C+1)}}else{if(E instanceof b.Geometry&&(O.multiplyMatrices(H,J),P=y.geometry.vertices,0!==P.length))for(E=a(),E.positionScreen.copy(P[0]).applyMatrix4(O),D=y instanceof
b.LineSegments?2:1,ka=1,W=P.length;ka<W;ka++)E=a(),E.positionScreen.copy(P[ka]).applyMatrix4(O),0<(ka+1)%D||(Z=l[x-2],ba.copy(E.positionScreen),ea.copy(Z.positionScreen),!0===g(ba,ea)&&(ba.multiplyScalar(1/ba.w),ea.multiplyScalar(1/ea.w),B=d(),B.id=y.id,B.v1.positionScreen.copy(ba),B.v2.positionScreen.copy(ea),B.z=Math.max(ba.z,ea.z),B.renderOrder=y.renderOrder,B.material=y.material,y.material.vertexColors===b.VertexColors&&(B.vertexColors[0].copy(y.geometry.colors[ka]),B.vertexColors[1].copy(y.geometry.colors[ka-
1])),M.elements.push(B)))}else y instanceof b.Sprite&&(L.set(J.elements[12],J.elements[13],J.elements[14],1),L.applyMatrix4(H),C=1/L.w,L.z*=C,-1<=L.z&&1>=L.z&&(F=e(),F.id=y.id,F.x=L.x*C,F.y=L.y*C,F.z=L.z,F.renderOrder=y.renderOrder,F.object=y,F.rotation=y.rotation,F.scale.x=y.scale.x*Math.abs(F.x-(L.x+s.projectionMatrix.elements[0])/(L.w+s.projectionMatrix.elements[12])),F.scale.y=y.scale.y*Math.abs(F.y-(L.y+s.projectionMatrix.elements[5])/(L.w+s.projectionMatrix.elements[13])),F.material=y.material,
M.elements.push(F)))}!0===A&&M.elements.sort(f);return M}};b.SpriteCanvasMaterial=function(a){b.Material.call(this);this.type="SpriteCanvasMaterial";this.color=new b.Color(16777215);this.program=function(a,b){};this.setValues(a)};b.SpriteCanvasMaterial.prototype=Object.create(b.Material.prototype);b.SpriteCanvasMaterial.prototype.constructor=b.SpriteCanvasMaterial;b.SpriteCanvasMaterial.prototype.clone=function(){var a=new b.SpriteCanvasMaterial;a.copy(this);a.color.copy(this.color);a.program=this.program;
return a};b.CanvasRenderer=function(a){function c(a,b,c,d){m(b);r(c);s(d);x(a.getStyle());D.stroke();ma.expandByScalar(2*b)}function d(a){l(a.getStyle());D.fill()}function e(a){if(0===a.version||a instanceof b.CompressedTexture||a instanceof b.DataTexture)return{canvas:void 0,version:a.version};var c=a.image;if(!1===c.complete)return{canvas:void 0,version:0};var d=document.createElement("canvas");d.width=c.width;d.height=c.height;var e=d.getContext("2d");e.setTransform(1,0,0,-1,0,c.height);e.drawImage(c,
0,0);var c=a.wrapS===b.RepeatWrapping,e=a.wrapT===b.RepeatWrapping,f="no-repeat";!0===c&&!0===e?f="repeat":!0===c?f="repeat-x":!0===e&&(f="repeat-y");d=D.createPattern(d,f);if(a.onUpdate)a.onUpdate(a);return{canvas:d,version:a.version}}function f(a,b,c,d,f,g,h,k,m,n,p,r,q){var s=ka[q.id];if(void 0===s||s.version!==q.version)s=e(q),ka[q.id]=s;if(void 0!==s.canvas){l(s.canvas);var s=q.offset.x/q.repeat.x,u=q.offset.y/q.repeat.y,t=q.image.width*q.repeat.x;q=q.image.height*q.repeat.y;h=(h+s)*t;k=(k+u)*
q;c-=a;d-=b;f-=a;g-=b;m=(m+s)*t-h;n=(n+u)*q-k;p=(p+s)*t-h;r=(r+u)*q-k;q=m*r-p*n;0!==q&&(s=1/q,q=(r*c-n*f)*s,n=(r*d-n*g)*s,c=(m*f-p*c)*s,d=(m*g-p*d)*s,a=a-q*h-c*k,b=b-n*h-d*k,D.save(),D.transform(q,n,c,d,a,b),D.fill(),D.restore())}else l("rgba( 0, 0, 0, 1)"),D.fill()}function g(a,b,c){var d=b.x-a.x,e=b.y-a.y,f=d*d+e*e;0!==f&&(c/=Math.sqrt(f),d*=c,e*=c,b.x+=d,b.y+=e,a.x-=d,a.y-=e)}function h(a){T!==a&&(T=D.globalAlpha=a)}function k(a){H!==a&&(a===b.NormalBlending?D.globalCompositeOperation="source-over":
a===b.AdditiveBlending?D.globalCompositeOperation="lighter":a===b.SubtractiveBlending&&(D.globalCompositeOperation="darker"),H=a)}function m(a){Y!==a&&(Y=D.lineWidth=a)}function r(a){V!==a&&(V=D.lineCap=a)}function s(a){ba!==a&&(ba=D.lineJoin=a)}function x(a){J!==a&&(J=D.strokeStyle=a)}function l(a){O!==a&&(O=D.fillStyle=a)}function p(a){ea.length!==a.length&&(D.setLineDash(a),ea=a)}console.log("THREE.CanvasRenderer",b.REVISION);a=a||{};var q=this,w,C,y,B=new b.Projector,z=void 0!==a.canvas?a.canvas:
document.createElement("canvas"),A=z.width,K=z.height,F=Math.floor(A/2),G=Math.floor(K/2),E=0,R=0,M=A,Q=K,L=1,D=z.getContext("2d",{alpha:!0===a.alpha}),P=new b.Color(0),N=!0===a.alpha?0:1,T=1,H=0,J=null,O=null,Y=null,V=null,ba=null,ea=[],ca,Z,X;new b.RenderableVertex;new b.RenderableVertex;var ta,pa,ia,qa,Ca,Da,oa=new b.Color;new b.Color;new b.Color;new b.Color;new b.Color;var xa=new b.Color,ya=new b.Color,Ka=new b.Color,ka={},W,Ga,ha,$,da,za,fa,la=new b.Box2,aa=new b.Box2,ma=new b.Box2,pb=new b.Color,
Qa=new b.Color,La=new b.Color,Ea=new b.Vector3,Aa=new b.Vector3,na=new b.Vector3,Ba=new b.Matrix3;void 0===D.setLineDash&&(D.setLineDash=function(){});this.domElement=z;this.sortElements=this.sortObjects=this.autoClear=!0;this.info={render:{vertices:0,faces:0}};this.supportsVertexTextures=function(){};this.setFaceCulling=function(){};this.getContext=function(){return D};this.getContextAttributes=function(){return D.getContextAttributes()};this.getPixelRatio=function(){return L};this.setPixelRatio=
function(a){void 0!==a&&(L=a)};this.setSize=function(a,b,c){A=a*L;K=b*L;z.width=A;z.height=K;F=Math.floor(A/2);G=Math.floor(K/2);!1!==c&&(z.style.width=a+"px",z.style.height=b+"px");la.min.set(-F,-G);la.max.set(F,G);aa.min.set(-F,-G);aa.max.set(F,G);T=1;H=0;ba=V=Y=O=J=null;this.setViewport(0,0,a,b)};this.setViewport=function(a,b,c,d){E=a*L;R=b*L;M=c*L;Q=d*L};this.setScissor=function(){};this.setScissorTest=function(){};this.setClearColor=function(a,b){P.set(a);N=void 0!==b?b:1;aa.min.set(-F,-G);aa.max.set(F,
G)};this.setClearColorHex=function(a,b){console.warn("THREE.CanvasRenderer: .setClearColorHex() is being removed. Use .setClearColor() instead.");this.setClearColor(a,b)};this.getClearColor=function(){return P};this.getClearAlpha=function(){return N};this.getMaxAnisotropy=function(){return 0};this.clear=function(){!1===aa.isEmpty()&&(aa.intersect(la),aa.expandByScalar(2),aa.min.x+=F,aa.min.y=-aa.min.y+G,aa.max.x+=F,aa.max.y=-aa.max.y+G,1>N&&D.clearRect(aa.min.x|0,aa.max.y|0,aa.max.x-aa.min.x|0,aa.min.y-
aa.max.y|0),0<N&&(k(b.NormalBlending),h(1),l("rgba("+Math.floor(255*P.r)+","+Math.floor(255*P.g)+","+Math.floor(255*P.b)+","+N+")"),D.fillRect(aa.min.x|0,aa.max.y|0,aa.max.x-aa.min.x|0,aa.min.y-aa.max.y|0)),aa.makeEmpty())};this.clearColor=function(){};this.clearDepth=function(){};this.clearStencil=function(){};this.render=function(a,z){if(!1===z instanceof b.Camera)console.error("THREE.CanvasRenderer.render: camera is not an instance of THREE.Camera.");else{!0===this.autoClear&&this.clear();q.info.render.vertices=
0;q.info.render.faces=0;D.setTransform(M/A,0,0,-Q/K,E,K-R);D.translate(F,G);w=B.projectScene(a,z,this.sortObjects,this.sortElements);C=w.elements;y=w.lights;Ba.getNormalMatrix(z.matrixWorldInverse);pb.setRGB(0,0,0);Qa.setRGB(0,0,0);La.setRGB(0,0,0);for(var H=0,L=y.length;H<L;H++){var J=y[H],O=J.color;J instanceof b.AmbientLight?pb.add(O):J instanceof b.DirectionalLight?Qa.add(O):J instanceof b.PointLight&&La.add(O)}H=0;for(L=C.length;H<L;H++){var S=C[H],N=S.material;if(void 0!==N&&0!==N.opacity){ma.makeEmpty();
if(S instanceof b.RenderableSprite){ca=S;ca.x*=F;ca.y*=G;var J=ca,P=S,O=N;h(O.opacity);k(O.blending);var v=P.scale.x*F,P=P.scale.y*G,S=.5*Math.sqrt(v*v+P*P);ma.min.set(J.x-S,J.y-S);ma.max.set(J.x+S,J.y+S);if(O instanceof b.SpriteMaterial){var T=O.map;if(null!==T){S=ka[T.id];if(void 0===S||S.version!==T.version)S=e(T),ka[T.id]=S;if(void 0!==S.canvas){l(S.canvas);var V=T.image,S=V.width*T.offset.x,N=V.height*T.offset.y,Y=V.width*T.repeat.x,T=V.height*T.repeat.y,V=v/Y,ba=P/T;D.save();D.translate(J.x,
J.y);0!==O.rotation&&D.rotate(O.rotation);D.translate(-v/2,-P/2);D.scale(V,ba);D.translate(-S,-N);D.fillRect(S,N,Y,T);D.restore()}}else l(O.color.getStyle()),D.save(),D.translate(J.x,J.y),0!==O.rotation&&D.rotate(O.rotation),D.scale(v,-P),D.fillRect(-.5,-.5,1,1),D.restore()}else O instanceof b.SpriteCanvasMaterial&&(x(O.color.getStyle()),l(O.color.getStyle()),D.save(),D.translate(J.x,J.y),0!==O.rotation&&D.rotate(O.rotation),D.scale(v,P),O.program(D),D.restore())}else if(S instanceof b.RenderableLine){if(ca=
S.v1,Z=S.v2,ca.positionScreen.x*=F,ca.positionScreen.y*=G,Z.positionScreen.x*=F,Z.positionScreen.y*=G,ma.setFromPoints([ca.positionScreen,Z.positionScreen]),!0===la.intersectsBox(ma))if(J=ca,O=Z,v=S,P=N,h(P.opacity),k(P.blending),D.beginPath(),D.moveTo(J.positionScreen.x,J.positionScreen.y),D.lineTo(O.positionScreen.x,O.positionScreen.y),P instanceof b.LineBasicMaterial){m(P.linewidth);r(P.linecap);s(P.linejoin);if(P.vertexColors!==b.VertexColors)x(P.color.getStyle());else if(S=v.vertexColors[0].getStyle(),
v=v.vertexColors[1].getStyle(),S===v)x(S);else{try{var U=D.createLinearGradient(J.positionScreen.x,J.positionScreen.y,O.positionScreen.x,O.positionScreen.y);U.addColorStop(0,S);U.addColorStop(1,v)}catch(ea){U=S}x(U)}D.stroke();ma.expandByScalar(2*P.linewidth)}else P instanceof b.LineDashedMaterial&&(m(P.linewidth),r(P.linecap),s(P.linejoin),x(P.color.getStyle()),p([P.dashSize,P.gapSize]),D.stroke(),ma.expandByScalar(2*P.linewidth),p([]))}else if(S instanceof b.RenderableFace){ca=S.v1;Z=S.v2;X=S.v3;
if(-1>ca.positionScreen.z||1<ca.positionScreen.z)continue;if(-1>Z.positionScreen.z||1<Z.positionScreen.z)continue;if(-1>X.positionScreen.z||1<X.positionScreen.z)continue;ca.positionScreen.x*=F;ca.positionScreen.y*=G;Z.positionScreen.x*=F;Z.positionScreen.y*=G;X.positionScreen.x*=F;X.positionScreen.y*=G;0<N.overdraw&&(g(ca.positionScreen,Z.positionScreen,N.overdraw),g(Z.positionScreen,X.positionScreen,N.overdraw),g(X.positionScreen,ca.positionScreen,N.overdraw));ma.setFromPoints([ca.positionScreen,
Z.positionScreen,X.positionScreen]);if(!0===la.intersectsBox(ma)){O=ca;v=Z;P=X;J=N;q.info.render.vertices+=3;q.info.render.faces++;h(J.opacity);k(J.blending);ta=O.positionScreen.x;pa=O.positionScreen.y;ia=v.positionScreen.x;qa=v.positionScreen.y;Ca=P.positionScreen.x;Da=P.positionScreen.y;var N=ta,Y=pa,T=ia,V=qa,ba=Ca,sa=Da;D.beginPath();D.moveTo(N,Y);D.lineTo(T,V);D.lineTo(ba,sa);D.closePath();if((J instanceof b.MeshLambertMaterial||J instanceof b.MeshPhongMaterial)&&null===J.map){xa.copy(J.color);
ya.copy(J.emissive);J.vertexColors===b.FaceColors&&xa.multiply(S.color);oa.copy(pb);Aa.copy(O.positionWorld).add(v.positionWorld).add(P.positionWorld).divideScalar(3);O=Aa;v=S.normalModel;P=oa;S=0;for(N=y.length;S<N;S++)Y=y[S],Ka.copy(Y.color),Y instanceof b.DirectionalLight?(T=Ea.setFromMatrixPosition(Y.matrixWorld).normalize(),V=v.dot(T),0>=V||(V*=Y.intensity,P.add(Ka.multiplyScalar(V)))):Y instanceof b.PointLight&&(T=Ea.setFromMatrixPosition(Y.matrixWorld),V=v.dot(Ea.subVectors(T,O).normalize()),
0>=V||(V*=0==Y.distance?1:1-Math.min(O.distanceTo(T)/Y.distance,1),0!=V&&(V*=Y.intensity,P.add(Ka.multiplyScalar(V)))));oa.multiply(xa).add(ya);!0===J.wireframe?c(oa,J.wireframeLinewidth,J.wireframeLinecap,J.wireframeLinejoin):d(oa)}else J instanceof b.MeshBasicMaterial||J instanceof b.MeshLambertMaterial||J instanceof b.MeshPhongMaterial?null!==J.map?J.map.mapping===b.UVMapping&&(W=S.uvs,f(ta,pa,ia,qa,Ca,Da,W[0].x,W[0].y,W[1].x,W[1].y,W[2].x,W[2].y,J.map)):null!==J.envMap?J.envMap.mapping===b.SphericalReflectionMapping&&
(na.copy(S.vertexNormalsModel[0]).applyMatrix3(Ba),Ga=.5*na.x+.5,ha=.5*na.y+.5,na.copy(S.vertexNormalsModel[1]).applyMatrix3(Ba),$=.5*na.x+.5,da=.5*na.y+.5,na.copy(S.vertexNormalsModel[2]).applyMatrix3(Ba),za=.5*na.x+.5,fa=.5*na.y+.5,f(ta,pa,ia,qa,Ca,Da,Ga,ha,$,da,za,fa,J.envMap)):(oa.copy(J.color),J.vertexColors===b.FaceColors&&oa.multiply(S.color),!0===J.wireframe?c(oa,J.wireframeLinewidth,J.wireframeLinecap,J.wireframeLinejoin):d(oa)):(J instanceof b.MeshNormalMaterial?(na.copy(S.normalModel).applyMatrix3(Ba),
oa.setRGB(na.x,na.y,na.z).multiplyScalar(.5).addScalar(.5)):oa.setRGB(1,1,1),!0===J.wireframe?c(oa,J.wireframeLinewidth,J.wireframeLinecap,J.wireframeLinejoin):d(oa))}}aa.union(ma)}}D.setTransform(1,0,0,1,0,0)}}};b.TrackballControls=function(a,c){function d(a){!1!==l.enabled&&(window.removeEventListener("keydown",d),C=w,w===p.NONE)&&(a.keyCode!==l.keys[p.ROTATE]||l.noRotate?a.keyCode!==l.keys[p.ZOOM]||l.noZoom?a.keyCode!==l.keys[p.PAN]||l.noPan||(w=p.PAN):w=p.ZOOM:w=p.ROTATE)}function e(a){!1!==l.enabled&&
(w=C,window.addEventListener("keydown",d,!1))}function f(a){!1!==l.enabled&&(a.preventDefault(),a.stopPropagation(),w===p.NONE&&(w=a.button),w!==p.ROTATE||l.noRotate?w!==p.ZOOM||l.noZoom?w!==p.PAN||l.noPan||(M.copy(N(a.pageX,a.pageY)),Q.copy(M)):(F.copy(N(a.pageX,a.pageY)),G.copy(F)):(z.copy(T(a.pageX,a.pageY)),B.copy(z)),document.addEventListener("mousemove",g,!1),document.addEventListener("mouseup",h,!1),l.dispatchEvent(D))}function g(a){!1!==l.enabled&&(a.preventDefault(),a.stopPropagation(),w!==
p.ROTATE||l.noRotate?w!==p.ZOOM||l.noZoom?w!==p.PAN||l.noPan||Q.copy(N(a.pageX,a.pageY)):G.copy(N(a.pageX,a.pageY)):(B.copy(z),z.copy(T(a.pageX,a.pageY))))}function h(a){!1!==l.enabled&&(a.preventDefault(),a.stopPropagation(),w=p.NONE,document.removeEventListener("mousemove",g),document.removeEventListener("mouseup",h),l.dispatchEvent(P))}function k(a){if(!1!==l.enabled){a.preventDefault();a.stopPropagation();var b=0;a.wheelDelta?b=a.wheelDelta/40:a.detail&&(b=-a.detail/3);F.y+=.01*b;l.dispatchEvent(D);
l.dispatchEvent(P)}}function m(a){if(!1!==l.enabled){switch(a.touches.length){case 1:w=p.TOUCH_ROTATE;z.copy(T(a.touches[0].pageX,a.touches[0].pageY));B.copy(z);break;default:w=p.TOUCH_ZOOM_PAN;var b=a.touches[0].pageX-a.touches[1].pageX,c=a.touches[0].pageY-a.touches[1].pageY;R=E=Math.sqrt(b*b+c*c);M.copy(N((a.touches[0].pageX+a.touches[1].pageX)/2,(a.touches[0].pageY+a.touches[1].pageY)/2));Q.copy(M)}l.dispatchEvent(D)}}function r(a){if(!1!==l.enabled)switch(a.preventDefault(),a.stopPropagation(),
a.touches.length){case 1:B.copy(z);z.copy(T(a.touches[0].pageX,a.touches[0].pageY));break;default:var b=a.touches[0].pageX-a.touches[1].pageX,c=a.touches[0].pageY-a.touches[1].pageY;R=Math.sqrt(b*b+c*c);Q.copy(N((a.touches[0].pageX+a.touches[1].pageX)/2,(a.touches[0].pageY+a.touches[1].pageY)/2))}}function s(a){if(!1!==l.enabled){switch(a.touches.length){case 0:w=p.NONE;break;case 1:w=p.TOUCH_ROTATE,z.copy(T(a.touches[0].pageX,a.touches[0].pageY)),B.copy(z)}l.dispatchEvent(P)}}function x(a){a.preventDefault()}
var l=this,p={NONE:-1,ROTATE:0,ZOOM:1,PAN:2,TOUCH_ROTATE:3,TOUCH_ZOOM_PAN:4};this.object=a;this.domElement=void 0!==c?c:document;this.enabled=!0;this.screen={left:0,top:0,width:0,height:0};this.rotateSpeed=1;this.zoomSpeed=1.2;this.panSpeed=.3;this.staticMoving=this.noPan=this.noZoom=this.noRotate=!1;this.dynamicDampingFactor=.2;this.minDistance=0;this.maxDistance=Infinity;this.keys=[65,83,68];this.target=new b.Vector3;var q=new b.Vector3,w=p.NONE,C=p.NONE,y=new b.Vector3,B=new b.Vector2,z=new b.Vector2,
A=new b.Vector3,K=0,F=new b.Vector2,G=new b.Vector2,E=0,R=0,M=new b.Vector2,Q=new b.Vector2;this.target0=this.target.clone();this.position0=this.object.position.clone();this.up0=this.object.up.clone();var L={type:"change"},D={type:"start"},P={type:"end"};this.handleResize=function(){if(this.domElement===document)this.screen.left=0,this.screen.top=0,this.screen.width=window.innerWidth,this.screen.height=window.innerHeight;else{var a=this.domElement.getBoundingClientRect(),b=this.domElement.ownerDocument.documentElement;
this.screen.left=a.left+window.pageXOffset-b.clientLeft;this.screen.top=a.top+window.pageYOffset-b.clientTop;this.screen.width=a.width;this.screen.height=a.height}};this.handleEvent=function(a){if("function"==typeof this[a.type])this[a.type](a)};var N=function(){var a=new b.Vector2;return function(b,c){a.set((b-l.screen.left)/l.screen.width,(c-l.screen.top)/l.screen.height);return a}}(),T=function(){var a=new b.Vector2;return function(b,c){a.set((b-.5*l.screen.width-l.screen.left)/(.5*l.screen.width),
(l.screen.height+2*(l.screen.top-c))/l.screen.width);return a}}();this.rotateCamera=function(){var a=new b.Vector3,c=new b.Quaternion,d=new b.Vector3,e=new b.Vector3,f=new b.Vector3,g=new b.Vector3,h;return function(){g.set(z.x-B.x,z.y-B.y,0);(h=g.length())?(y.copy(l.object.position).sub(l.target),d.copy(y).normalize(),e.copy(l.object.up).normalize(),f.crossVectors(e,d).normalize(),e.setLength(z.y-B.y),f.setLength(z.x-B.x),g.copy(e.add(f)),a.crossVectors(g,y).normalize(),h*=l.rotateSpeed,c.setFromAxisAngle(a,
h),y.applyQuaternion(c),l.object.up.applyQuaternion(c),A.copy(a),K=h):!l.staticMoving&&K&&(K*=Math.sqrt(1-l.dynamicDampingFactor),y.copy(l.object.position).sub(l.target),c.setFromAxisAngle(A,K),y.applyQuaternion(c),l.object.up.applyQuaternion(c));B.copy(z)}}();this.zoomCamera=function(){var a;w===p.TOUCH_ZOOM_PAN?(a=E/R,E=R,y.multiplyScalar(a)):(a=1+(G.y-F.y)*l.zoomSpeed,1!==a&&0<a&&(y.multiplyScalar(a),l.staticMoving?F.copy(G):F.y+=(G.y-F.y)*this.dynamicDampingFactor))};this.panCamera=function(){var a=
new b.Vector2,c=new b.Vector3,d=new b.Vector3;return function(){a.copy(Q).sub(M);a.lengthSq()&&(a.multiplyScalar(y.length()*l.panSpeed),d.copy(y).cross(l.object.up).setLength(a.x),d.add(c.copy(l.object.up).setLength(a.y)),l.object.position.add(d),l.target.add(d),l.staticMoving?M.copy(Q):M.add(a.subVectors(Q,M).multiplyScalar(l.dynamicDampingFactor)))}}();this.checkDistances=function(){l.noZoom&&l.noPan||(y.lengthSq()>l.maxDistance*l.maxDistance&&(l.object.position.addVectors(l.target,y.setLength(l.maxDistance)),
F.copy(G)),y.lengthSq()<l.minDistance*l.minDistance&&(l.object.position.addVectors(l.target,y.setLength(l.minDistance)),F.copy(G)))};this.update=function(){y.subVectors(l.object.position,l.target);l.noRotate||l.rotateCamera();l.noZoom||l.zoomCamera();l.noPan||l.panCamera();l.object.position.addVectors(l.target,y);l.checkDistances();l.object.lookAt(l.target);1E-6<q.distanceToSquared(l.object.position)&&(l.dispatchEvent(L),q.copy(l.object.position))};this.reset=function(){C=w=p.NONE;l.target.copy(l.target0);
l.object.position.copy(l.position0);l.object.up.copy(l.up0);y.subVectors(l.object.position,l.target);l.object.lookAt(l.target);l.dispatchEvent(L);q.copy(l.object.position)};this.dispose=function(){this.domElement.removeEventListener("contextmenu",x,!1);this.domElement.removeEventListener("mousedown",f,!1);this.domElement.removeEventListener("mousewheel",k,!1);this.domElement.removeEventListener("MozMousePixelScroll",k,!1);this.domElement.removeEventListener("touchstart",m,!1);this.domElement.removeEventListener("touchend",
s,!1);this.domElement.removeEventListener("touchmove",r,!1);document.removeEventListener("mousemove",g,!1);document.removeEventListener("mouseup",h,!1);window.removeEventListener("keydown",d,!1);window.removeEventListener("keyup",e,!1)};this.domElement.addEventListener("contextmenu",x,!1);this.domElement.addEventListener("mousedown",f,!1);this.domElement.addEventListener("mousewheel",k,!1);this.domElement.addEventListener("MozMousePixelScroll",k,!1);this.domElement.addEventListener("touchstart",m,
!1);this.domElement.addEventListener("touchend",s,!1);this.domElement.addEventListener("touchmove",r,!1);window.addEventListener("keydown",d,!1);window.addEventListener("keyup",e,!1);this.handleResize();this.update()};b.TrackballControls.prototype=Object.create(b.EventDispatcher.prototype);b.TrackballControls.prototype.constructor=b.TrackballControls;b.SphereGeometry=function(a,c,d,e,f,g,h){b.Geometry.call(this);this.type="SphereGeometry";this.parameters={radius:a,widthSegments:c,heightSegments:d,
phiStart:e,phiLength:f,thetaStart:g,thetaLength:h};this.fromBufferGeometry(new b.SphereBufferGeometry(a,c,d,e,f,g,h))};b.SphereGeometry.prototype=Object.create(b.Geometry.prototype);b.SphereGeometry.prototype.constructor=b.SphereGeometry;b.SphereBufferGeometry=function(a,c,d,e,f,g,h){b.BufferGeometry.call(this);this.type="SphereBufferGeometry";this.parameters={radius:a,widthSegments:c,heightSegments:d,phiStart:e,phiLength:f,thetaStart:g,thetaLength:h};a=a||50;c=Math.max(3,Math.floor(c)||8);d=Math.max(2,
Math.floor(d)||6);e=void 0!==e?e:0;f=void 0!==f?f:2*Math.PI;g=void 0!==g?g:0;h=void 0!==h?h:Math.PI;for(var k=g+h,m=(c+1)*(d+1),r=new b.BufferAttribute(new Float32Array(3*m),3),s=new b.BufferAttribute(new Float32Array(3*m),3),m=new b.BufferAttribute(new Float32Array(2*m),2),w=0,l=[],p=new b.Vector3,q=0;q<=d;q++){for(var I=[],C=q/d,y=0;y<=c;y++){var B=y/c,z=-a*Math.cos(e+B*f)*Math.sin(g+C*h),A=a*Math.cos(g+C*h),K=a*Math.sin(e+B*f)*Math.sin(g+C*h);p.set(z,A,K).normalize();r.setXYZ(w,z,A,K);s.setXYZ(w,
p.x,p.y,p.z);m.setXY(w,B,1-C);I.push(w);w++}l.push(I)}e=[];for(q=0;q<d;q++)for(y=0;y<c;y++)f=l[q][y+1],h=l[q][y],w=l[q+1][y],p=l[q+1][y+1],(0!==q||0<g)&&e.push(f,h,p),(q!==d-1||k<Math.PI)&&e.push(h,w,p);this.setIndex(new (65535<r.count?b.Uint32Attribute:b.Uint16Attribute)(e,1));this.addAttribute("position",r);this.addAttribute("normal",s);this.addAttribute("uv",m);this.boundingSphere=new b.Sphere(new b.Vector3,a)};b.SphereBufferGeometry.prototype=Object.create(b.BufferGeometry.prototype);b.SphereBufferGeometry.prototype.constructor=
b.SphereBufferGeometry;b.CylinderGeometry=function(a,c,d,e,f,g,h,k){b.Geometry.call(this);this.type="CylinderGeometry";this.parameters={radiusTop:a,radiusBottom:c,height:d,radialSegments:e,heightSegments:f,openEnded:g,thetaStart:h,thetaLength:k};this.fromBufferGeometry(new b.CylinderBufferGeometry(a,c,d,e,f,g,h,k));this.mergeVertices()};b.CylinderGeometry.prototype=Object.create(b.Geometry.prototype);b.CylinderGeometry.prototype.constructor=b.CylinderGeometry;b.CylinderBufferGeometry=function(a,c,
d,e,f,g,h,k){function m(d){var f,g,s;s=new b.Vector2;var t=new b.Vector3,u=0,w=!0===d?a:c,x=!0===d?1:-1;g=C;for(f=1;f<=e;f++)p.setXYZ(C,0,z*x,0),q.setXYZ(C,0,x,0),!0===d?(s.x=f/e,s.y=0):(s.x=(f-1)/e,s.y=1),I.setXY(C,s.x,s.y),C++;s=C;for(f=0;f<=e;f++){var B=f/e;t.x=w*Math.sin(B*k+h);t.y=z*x;t.z=w*Math.cos(B*k+h);p.setXYZ(C,t.x,t.y,t.z);q.setXYZ(C,0,x,0);I.setXY(C,B,!0===d?1:0);C++}for(f=0;f<e;f++)t=g+f,w=s+f,!0===d?(l.setX(y,w),y++,l.setX(y,w+1)):(l.setX(y,w+1),y++,l.setX(y,w)),y++,l.setX(y,t),y++,
u+=3;r.addGroup(A,u,!0===d?1:2);A+=u}b.BufferGeometry.call(this);this.type="CylinderBufferGeometry";this.parameters={radiusTop:a,radiusBottom:c,height:d,radialSegments:e,heightSegments:f,openEnded:g,thetaStart:h,thetaLength:k};var r=this;a=void 0!==a?a:20;c=void 0!==c?c:20;d=void 0!==d?d:100;e=Math.floor(e)||8;f=Math.floor(f)||1;g=void 0!==g?g:!1;h=void 0!==h?h:0;k=void 0!==k?k:2*Math.PI;var s=function(){var a=(e+1)*(f+1);!1===g&&(a+=2*(e+1)+2*e);return a}(),w=function(){var a=e*f*6;!1===g&&(a+=6*
e);return a}(),l=new b.BufferAttribute(new (65535<w?Uint32Array:Uint16Array)(w),1),p=new b.BufferAttribute(new Float32Array(3*s),3),q=new b.BufferAttribute(new Float32Array(3*s),3),I=new b.BufferAttribute(new Float32Array(2*s),2),C=0,y=0,B=[],z=d/2,A=0;(function(){var g,m,s=new b.Vector3,t=new b.Vector3,u=0,w=(c-a)/d;for(m=0;m<=f;m++){var x=[],L=m/f,D=L*(c-a)+a;for(g=0;g<=e;g++){var P=g/e;t.x=D*Math.sin(P*k+h);t.y=-L*d+z;t.z=D*Math.cos(P*k+h);p.setXYZ(C,t.x,t.y,t.z);s.copy(t);if(0===a&&0===m||0===
c&&m===f)s.x=Math.sin(P*k+h),s.z=Math.cos(P*k+h);s.setY(Math.sqrt(s.x*s.x+s.z*s.z)*w).normalize();q.setXYZ(C,s.x,s.y,s.z);I.setXY(C,P,1-L);x.push(C);C++}B.push(x)}for(g=0;g<e;g++)for(m=0;m<f;m++)s=B[m+1][g],t=B[m+1][g+1],w=B[m][g+1],l.setX(y,B[m][g]),y++,l.setX(y,s),y++,l.setX(y,w),y++,l.setX(y,s),y++,l.setX(y,t),y++,l.setX(y,w),y++,u+=6;r.addGroup(A,u,0);A+=u})();!1===g&&(0<a&&m(!0),0<c&&m(!1));this.setIndex(l);this.addAttribute("position",p);this.addAttribute("normal",q);this.addAttribute("uv",
I)};b.CylinderBufferGeometry.prototype=Object.create(b.BufferGeometry.prototype);b.CylinderBufferGeometry.prototype.constructor=b.CylinderBufferGeometry;b.ArrowHelper=function(){var a=new b.Geometry;a.vertices.push(new b.Vector3(0,0,0),new b.Vector3(0,1,0));var c=new b.CylinderGeometry(0,.5,1,5,1);c.translate(0,-.5,0);return function(d,e,f,g,h,k){b.Object3D.call(this);void 0===g&&(g=16776960);void 0===f&&(f=1);void 0===h&&(h=.2*f);void 0===k&&(k=.2*h);this.position.copy(e);this.line=new b.Line(a,
new b.LineBasicMaterial({color:g}));this.line.matrixAutoUpdate=!1;this.add(this.line);this.cone=new b.Mesh(c,new b.MeshBasicMaterial({color:g}));this.cone.matrixAutoUpdate=!1;this.add(this.cone);this.setDirection(d);this.setLength(f,h,k)}}();b.ArrowHelper.prototype=Object.create(b.Object3D.prototype);b.ArrowHelper.prototype.constructor=b.ArrowHelper;b.ArrowHelper.prototype.setDirection=function(){var a=new b.Vector3,c;return function(b){.99999<b.y?this.quaternion.set(0,0,0,1):-.99999>b.y?this.quaternion.set(1,
0,0,0):(a.set(b.z,0,-b.x).normalize(),c=Math.acos(b.y),this.quaternion.setFromAxisAngle(a,c))}}();b.ArrowHelper.prototype.setLength=function(a,b,d){void 0===b&&(b=.2*a);void 0===d&&(d=.2*b);this.line.scale.set(1,Math.max(0,a-b),1);this.line.updateMatrix();this.cone.scale.set(d,b,d);this.cone.position.y=a;this.cone.updateMatrix()};b.ArrowHelper.prototype.setColor=function(a){this.line.material.color.set(a);this.cone.material.color.set(a)};m.THREE=b})}]);
</script>
</body>
</html>