soonspacejs 2.3.18 → 2.3.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +2 -2
- package/dist/index.js +2 -2
- package/package.json +2 -2
- package/types/index.d.ts +2 -2
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var e="soonspacejs",t="2.3.
|
|
1
|
+
var e="soonspacejs",t="2.3.19",n=!1;
|
|
2
2
|
/**
|
|
3
3
|
* @license
|
|
4
4
|
* Copyright 2010-2022 Three.js Authors
|
|
@@ -44,4 +44,4 @@ fflate - fast JavaScript compression/decompression
|
|
|
44
44
|
<https://101arrowz.github.io/fflate>
|
|
45
45
|
Licensed under MIT. https://github.com/101arrowz/fflate/blob/master/LICENSE
|
|
46
46
|
version 0.6.9
|
|
47
|
-
*/var gf={},vf=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},yf=function(e){return new Worker(e)};try{URL.revokeObjectURL(vf(""))}catch(df){vf=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},yf=function(e){return new Worker(e,{type:"module"})}}var xf=Uint8Array,wf=Uint16Array,bf=Uint32Array,_f=new xf([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Mf=new xf([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Sf=new xf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Tf=function(e,t){for(var n=new wf(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new bf(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},Ef=Tf(_f,2),Af=Ef[0],Cf=Ef[1];Af[28]=258,Cf[258]=28;for(var Pf=Tf(Mf,0),Rf=Pf[0],Lf=Pf[1],If=new wf(32768),Df=0;Df<32768;++Df){var Of=(43690&Df)>>>1|(21845&Df)<<1;Of=(61680&(Of=(52428&Of)>>>2|(13107&Of)<<2))>>>4|(3855&Of)<<4,If[Df]=((65280&Of)>>>8|(255&Of)<<8)>>>1}var Bf=function(e,t,n){for(var r=e.length,i=0,s=new wf(t);i<r;++i)++s[e[i]-1];var o,a=new wf(t);for(i=0;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(n){o=new wf(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var c=i<<4|e[i],h=t-e[i],u=a[e[i]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)o[If[u]>>>l]=c}else for(o=new wf(r),i=0;i<r;++i)e[i]&&(o[i]=If[a[e[i]-1]++]>>>15-e[i]);return o},Nf=new xf(288);for(Df=0;Df<144;++Df)Nf[Df]=8;for(Df=144;Df<256;++Df)Nf[Df]=9;for(Df=256;Df<280;++Df)Nf[Df]=7;for(Df=280;Df<288;++Df)Nf[Df]=8;var zf=new xf(32);for(Df=0;Df<32;++Df)zf[Df]=5;var Uf=Bf(Nf,9,0),kf=Bf(Nf,9,1),Ff=Bf(zf,5,0),Hf=Bf(zf,5,1),Gf=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},jf=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},Vf=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Wf=function(e){return(e/8|0)+(7&e&&1)},Xf=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof wf?wf:e instanceof bf?bf:xf)(n-t);return r.set(e.subarray(t,n)),r},qf=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new xf(0);var i=!t||n,s=!n||n.i;n||(n={}),t||(t=new xf(3*r));var o=function(e){var n=t.length;if(e>n){var r=new xf(Math.max(2*n,e));r.set(t),t=r}},a=n.f||0,l=n.p||0,c=n.b||0,h=n.l,u=n.d,d=n.m,p=n.n,f=8*r;do{if(!h){n.f=a=jf(e,l,1);var m=jf(e,l+1,3);if(l+=3,!m){var g=e[(A=Wf(l)+4)-4]|e[A-3]<<8,v=A+g;if(v>r){if(s)throw"unexpected EOF";break}i&&o(c+g),t.set(e.subarray(A,v),c),n.b=c+=g,n.p=l=8*v;continue}if(1==m)h=kf,u=Hf,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=jf(e,l,31)+257,x=jf(e,l+10,15)+4,w=y+jf(e,l+5,31)+1;l+=14;for(var b=new xf(w),_=new xf(19),M=0;M<x;++M)_[Sf[M]]=jf(e,l+3*M,7);l+=3*x;var S=Gf(_),T=(1<<S)-1,E=Bf(_,S,1);for(M=0;M<w;){var A,C=E[jf(e,l,T)];if(l+=15&C,(A=C>>>4)<16)b[M++]=A;else{var P=0,R=0;for(16==A?(R=3+jf(e,l,3),l+=2,P=b[M-1]):17==A?(R=3+jf(e,l,7),l+=3):18==A&&(R=11+jf(e,l,127),l+=7);R--;)b[M++]=P}}var L=b.subarray(0,y),I=b.subarray(y);d=Gf(L),p=Gf(I),h=Bf(L,d,1),u=Bf(I,p,1)}if(l>f){if(s)throw"unexpected EOF";break}}i&&o(c+131072);for(var D=(1<<d)-1,O=(1<<p)-1,B=l;;B=l){var N=(P=h[Vf(e,l)&D])>>>4;if((l+=15&P)>f){if(s)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(N<256)t[c++]=N;else{if(256==N){B=l,h=null;break}var z=N-254;if(N>264){var U=_f[M=N-257];z=jf(e,l,(1<<U)-1)+Af[M],l+=U}var k=u[Vf(e,l)&O],F=k>>>4;if(!k)throw"invalid distance";l+=15&k;I=Rf[F];if(F>3){U=Mf[F];I+=Vf(e,l)&(1<<U)-1,l+=U}if(l>f){if(s)throw"unexpected EOF";break}i&&o(c+131072);for(var H=c+z;c<H;c+=4)t[c]=t[c-I],t[c+1]=t[c+1-I],t[c+2]=t[c+2-I],t[c+3]=t[c+3-I];c=H}}n.l=h,n.p=B,n.b=c,h&&(a=1,n.m=d,n.d=u,n.n=p)}while(!a);return c==t.length?t:Xf(t,0,c)},Yf=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},Zf=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Jf=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,s=n.slice();if(!i)return[rm,0];if(1==i){var o=new xf(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],l=n[1],c=0,h=1,u=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=i-1;)a=n[n[c].f<n[u].f?c++:u++],l=n[c!=h&&n[c].f<n[u].f?c++:u++],n[h++]={s:-1,f:a.f+l.f,l:a,r:l};var d=s[0].s;for(r=1;r<i;++r)s[r].s>d&&(d=s[r].s);var p=new wf(d+1),f=Qf(n[h-1],p,0);if(f>t){r=0;var m=0,g=f-t,v=1<<g;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<i;++r){var y=s[r].s;if(!(p[y]>t))break;m+=v-(1<<f-p[y]),p[y]=t}for(m>>>=g;m>0;){var x=s[r].s;p[x]<t?m-=1<<t-p[x]++-1:++r}for(;r>=0&&m;--r){var w=s[r].s;p[w]==t&&(--p[w],++m)}f=t}return[new xf(p),f]},Qf=function(e,t,n){return-1==e.s?Math.max(Qf(e.l,t,n+1),Qf(e.r,t,n+1)):t[e.s]=n},Kf=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new wf(++t),r=0,i=e[0],s=1,o=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==i&&a!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=e[a]}return[n.subarray(0,r),t]},$f=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},em=function(e,t,n){var r=n.length,i=Wf(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var s=0;s<r;++s)e[i+s+4]=n[s];return 8*(i+4+r)},tm=function(e,t,n,r,i,s,o,a,l,c,h){Yf(t,h++,n),++i[256];for(var u=Jf(i,15),d=u[0],p=u[1],f=Jf(s,15),m=f[0],g=f[1],v=Kf(d),y=v[0],x=v[1],w=Kf(m),b=w[0],_=w[1],M=new wf(19),S=0;S<y.length;++S)M[31&y[S]]++;for(S=0;S<b.length;++S)M[31&b[S]]++;for(var T=Jf(M,7),E=T[0],A=T[1],C=19;C>4&&!E[Sf[C-1]];--C);var P,R,L,I,D=c+5<<3,O=$f(i,Nf)+$f(s,zf)+o,B=$f(i,d)+$f(s,m)+o+14+3*C+$f(M,E)+(2*M[16]+3*M[17]+7*M[18]);if(D<=O&&D<=B)return em(t,h,e.subarray(l,l+c));if(Yf(t,h,1+(B<O)),h+=2,B<O){P=Bf(d,p,0),R=d,L=Bf(m,g,0),I=m;var N=Bf(E,A,0);Yf(t,h,x-257),Yf(t,h+5,_-1),Yf(t,h+10,C-4),h+=14;for(S=0;S<C;++S)Yf(t,h+3*S,E[Sf[S]]);h+=3*C;for(var z=[y,b],U=0;U<2;++U){var k=z[U];for(S=0;S<k.length;++S){var F=31&k[S];Yf(t,h,N[F]),h+=E[F],F>15&&(Yf(t,h,k[S]>>>5&127),h+=k[S]>>>12)}}}else P=Uf,R=Nf,L=Ff,I=zf;for(S=0;S<a;++S)if(r[S]>255){F=r[S]>>>18&31;Zf(t,h,P[F+257]),h+=R[F+257],F>7&&(Yf(t,h,r[S]>>>23&31),h+=_f[F]);var H=31&r[S];Zf(t,h,L[H]),h+=I[H],H>3&&(Zf(t,h,r[S]>>>5&8191),h+=Mf[H])}else Zf(t,h,P[r[S]]),h+=R[r[S]];return Zf(t,h,P[256]),h+R[256]},nm=new bf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),rm=new xf(0),im=function(e,t,n,r,i,s){var o=e.length,a=new xf(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),c=0;if(!t||o<8)for(var h=0;h<=o;h+=65535){var u=h+65535;u<o?c=em(l,c,e.subarray(h,u)):(l[h]=s,c=em(l,c,e.subarray(h,o)))}else{for(var d=nm[t-1],p=d>>>13,f=8191&d,m=(1<<n)-1,g=new wf(32768),v=new wf(m+1),y=Math.ceil(n/3),x=2*y,w=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<x)&m},b=new bf(25e3),_=new wf(288),M=new wf(32),S=0,T=0,E=(h=0,0),A=0,C=0;h<o;++h){var P=w(h),R=32767&h,L=v[P];if(g[R]=L,v[P]=R,A<=h){var I=o-h;if((S>7e3||E>24576)&&I>423){c=tm(e,l,0,b,_,M,T,E,C,h-C,c),E=S=T=0,C=h;for(var D=0;D<286;++D)_[D]=0;for(D=0;D<30;++D)M[D]=0}var O=2,B=0,N=f,z=R-L&32767;if(I>2&&P==w(h-z))for(var U=Math.min(p,I)-1,k=Math.min(32767,h),F=Math.min(258,I);z<=k&&--N&&R!=L;){if(e[h+O]==e[h+O-z]){for(var H=0;H<F&&e[h+H]==e[h+H-z];++H);if(H>O){if(O=H,B=z,H>U)break;var G=Math.min(z,H-2),j=0;for(D=0;D<G;++D){var V=h-z+D+32768&32767,W=V-g[V]+32768&32767;W>j&&(j=W,L=V)}}}z+=(R=L)-(L=g[R])+32768&32767}if(B){b[E++]=268435456|Cf[O]<<18|Lf[B];var X=31&Cf[O],q=31&Lf[B];T+=_f[X]+Mf[q],++_[257+X],++M[q],A=h+O,++S}else b[E++]=e[h],++_[e[h]]}}c=tm(e,l,s,b,_,M,T,E,C,h-C,c),!s&&7&c&&(c=em(l,c+1,rm))}return Xf(a,0,r+Wf(c)+i)},sm=function(){for(var e=new bf(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),om=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=sm[255&n^t[r]]^n>>>8;e=n},d:function(){return~e}}},am=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,s=n.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)i+=r+=n[o];r=(65535&r)+15*(r>>16),i=(65535&i)+15*(i>>16)}e=r,t=i},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},lm=function(e,t,n,r,i){return im(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!i)},cm=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},hm=function(e,t,n){for(var r=e(),i=e.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o<r.length;++o){var a=r[o],l=s[o];if("function"==typeof a){t+=";"+l+"=";var c=a.toString();if(a.prototype)if(-1!=c.indexOf("[native code]")){var h=c.indexOf(" ",8)+1;t+=c.slice(h,c.indexOf("(",h))}else for(var u in t+=c,a.prototype)t+=";"+l+".prototype."+u+"="+a.prototype[u].toString();else t+=c}else n[l]=a}return[t,n]},um=[],dm=function(e,t,n,r){var i;if(!um[n]){for(var s="",o={},a=e.length-1,l=0;l<a;++l)s=(i=hm(e[l],s,o))[0],o=i[1];um[n]=hm(e[a],s,o)}var c=cm({},um[n][1]);return function(e,t,n,r,i){var s=yf(gf[t]||(gf[t]=vf(e)));return s.onerror=function(e){return i(e.error,null)},s.onmessage=function(e){return i(null,e.data)},s.postMessage(n,r),s}(um[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",n,c,function(e){var t=[];for(var n in e)(e[n]instanceof xf||e[n]instanceof wf||e[n]instanceof bf)&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t}(c),r)},pm=function(){return[xf,wf,bf,_f,Mf,Sf,Af,Rf,kf,Hf,If,Bf,Gf,jf,Vf,Wf,Xf,qf,Gm,xm,wm]},fm=function(){return[xf,wf,bf,_f,Mf,Sf,Cf,Lf,Uf,Nf,Ff,zf,If,nm,rm,Bf,Yf,Zf,Jf,Qf,Kf,$f,em,tm,Wf,Xf,im,lm,Um,xm]},mm=function(){return[Cm,Lm,Am,om,sm]},gm=function(){return[Pm,Rm]},vm=function(){return[Im,Am,am]},ym=function(){return[Dm]},xm=function(e){return postMessage(e,[e.buffer])},wm=function(e){return e&&e.size&&new xf(e.size)},bm=function(e,t,n,r,i,s){var o=dm(n,r,i,(function(e,t){o.terminate(),s(e,t)}));return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},_m=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}},Mm=function(e,t,n,r,i){var s,o=dm(e,r,i,(function(e,n){e?(o.terminate(),t.ondata.call(t,e)):(n[1]&&o.terminate(),t.ondata.call(t,e,n[0],n[1]))}));o.postMessage(n),t.push=function(e,n){if(s)throw"stream finished";if(!t.ondata)throw"no stream handler";o.postMessage([e,s=n],[e.buffer])},t.terminate=function(){o.terminate()}},Sm=function(e,t){return e[t]|e[t+1]<<8},Tm=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Em=function(e,t){return Tm(e,t)+4294967296*Tm(e,t+4)},Am=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Cm=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Am(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}},Pm=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(2&t)},Rm=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Lm=function(e){return 10+(e.filename&&e.filename.length+1||0)},Im=function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)},Dm=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function Om(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var Bm=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(lm(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}(),Nm=function(){return function(e,t){Mm([fm,function(){return[_m,Bm]}],this,Om.call(this,e,t),(function(e){var t=new Bm(e.data);onmessage=_m(t)}),6)}}();function zm(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[fm],(function(e){return xm(Um(e.data[0],e.data[1]))}),0,n)}function Um(e,t){return lm(e,t||{},0,0)}var km=function(){function e(e){this.s={},this.p=new xf(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new xf(t+e.length);n.set(this.p),n.set(e,t),this.p=n},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=qf(this.p,this.o,this.s);this.ondata(Xf(n,t,this.s.b),this.d),this.o=Xf(n,this.s.b-32768),this.s.b=this.o.length,this.p=Xf(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),Fm=function(){return function(e){this.ondata=e,Mm([pm,function(){return[_m,km]}],this,0,(function(){var e=new km;onmessage=_m(e)}),7)}}();function Hm(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[pm],(function(e){return xm(Gm(e.data[0],wm(e.data[1])))}),1,n)}function Gm(e,t){return qf(e,t)}var jm=function(){function e(e,t){this.c=om(),this.l=0,this.v=1,Bm.call(this,e,t)}return e.prototype.push=function(e,t){Bm.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=lm(e,this.o,this.v&&Lm(this.o),t&&8,!t);this.v&&(Cm(n,this.o),this.v=0),t&&(Am(n,n.length-8,this.c.d()),Am(n,n.length-4,this.l)),this.ondata(n,t)},e}(),Vm=function(){return function(e,t){Mm([fm,mm,function(){return[_m,Bm,jm]}],this,Om.call(this,e,t),(function(e){var t=new jm(e.data);onmessage=_m(t)}),8)}}();function Wm(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[fm,mm,function(){return[Xm]}],(function(e){return xm(Xm(e.data[0],e.data[1]))}),2,n)}function Xm(e,t){t||(t={});var n=om(),r=e.length;n.p(e);var i=lm(e,t,Lm(t),8),s=i.length;return Cm(i,t),Am(i,s-8,n.d()),Am(i,s-4,r),i}var qm=function(){function e(e){this.v=1,km.call(this,e)}return e.prototype.push=function(e,t){if(km.prototype.e.call(this,e),this.v){var n=this.p.length>3?Pm(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}km.prototype.c.call(this,t)},e}(),Ym=function(){return function(e){this.ondata=e,Mm([pm,gm,function(){return[_m,km,qm]}],this,0,(function(){var e=new qm;onmessage=_m(e)}),9)}}();function Zm(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[pm,gm,function(){return[Jm]}],(function(e){return xm(Jm(e.data[0]))}),3,n)}function Jm(e,t){return qf(e.subarray(Pm(e),-8),t||new xf(Rm(e)))}var Qm=function(){function e(e,t){this.c=am(),this.v=1,Bm.call(this,e,t)}return e.prototype.push=function(e,t){Bm.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var n=lm(e,this.o,this.v&&2,t&&4,!t);this.v&&(Im(n,this.o),this.v=0),t&&Am(n,n.length-4,this.c.d()),this.ondata(n,t)},e}(),Km=function(){return function(e,t){Mm([fm,vm,function(){return[_m,Bm,Qm]}],this,Om.call(this,e,t),(function(e){var t=new Qm(e.data);onmessage=_m(t)}),10)}}();function $m(e,t){t||(t={});var n=am();n.p(e);var r=lm(e,t,2,4);return Im(r,t),Am(r,r.length-4,n.d()),r}var eg=function(){function e(e){this.v=1,km.call(this,e)}return e.prototype.push=function(e,t){if(km.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}km.prototype.c.call(this,t)},e}(),tg=function(){return function(e){this.ondata=e,Mm([pm,ym,function(){return[_m,km,eg]}],this,0,(function(){var e=new eg;onmessage=_m(e)}),11)}}();function ng(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[pm,ym,function(){return[rg]}],(function(e){return xm(rg(e.data[0],wm(e.data[1])))}),5,n)}function rg(e,t){return qf((Dm(e),e.subarray(2,-4)),t)}var ig=function(){function e(e){this.G=qm,this.I=km,this.Z=eg,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new xf(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var r=this,i=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(i):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(i):new this.Z(i),this.s.push(this.p,t),this.p=null}}},e}(),sg=function(){function e(e){this.G=Ym,this.I=Fm,this.Z=tg,this.ondata=e}return e.prototype.push=function(e,t){ig.prototype.push.call(this,e,t)},e}();var og=function(e,t,n,r){for(var i in e){var s=e[i],o=t+i;s instanceof xf?n[o]=[s,r]:Array.isArray(s)?n[o]=[s[0],cm(r,s[1])]:og(s,o+"/",n,r)}},ag="undefined"!=typeof TextEncoder&&new TextEncoder,lg="undefined"!=typeof TextDecoder&&new TextDecoder,cg=0;try{lg.decode(rm,{stream:!0}),cg=1}catch(df){}var hg=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return[t,Xf(e,n-1)];i?3==i?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&i?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}},ug=function(){function e(e){this.ondata=e,cg?this.t=new TextDecoder:this.p=rm}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var n=new xf(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var r=hg(n),i=r[0],s=r[1];if(t){if(s.length)throw"invalid utf-8 data";this.p=null}else this.p=s;this.ondata(i,t)}},e}(),dg=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(pg(e),this.d=t||!1)},e}();function pg(e,t){if(t){for(var n=new xf(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(ag)return ag.encode(e);var i=e.length,s=new xf(e.length+(e.length>>1)),o=0,a=function(e){s[o++]=e};for(r=0;r<i;++r){if(o+5>s.length){var l=new xf(o+8+(i-r<<1));l.set(s),s=l}var c=e.charCodeAt(r);c<128||t?a(c):c<2048?(a(192|c>>6),a(128|63&c)):c>55295&&c<57344?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++r))>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|63&c)):(a(224|c>>12),a(128|c>>6&63),a(128|63&c))}return Xf(s,0,o)}function fg(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(lg)return lg.decode(e);var i=hg(e),s=i[0];if(i[1].length)throw"invalid utf-8 data";return s}var mg=function(e){return 1==e?3:e<6?2:9==e?1:0},gg=function(e,t){return t+30+Sm(e,t+26)+Sm(e,t+28)},vg=function(e,t,n){var r=Sm(e,t+28),i=fg(e.subarray(t+46,t+46+r),!(2048&Sm(e,t+8))),s=t+46+r,o=Tm(e,t+20),a=n&&4294967295==o?yg(e,s):[o,Tm(e,t+24),Tm(e,t+42)],l=a[0],c=a[1],h=a[2];return[Sm(e,t+10),l,c,i,s+Sm(e,t+30)+Sm(e,t+32),h]},yg=function(e,t){for(;1!=Sm(e,t);t+=4+Sm(e,t+2));return[Em(e,t+12),Em(e,t+4),Em(e,t+20)]},xg=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;if(r>65535)throw"extra field too long";t+=r+4}return t},wg=function(e,t,n,r,i,s,o,a){var l=r.length,c=n.extra,h=a&&a.length,u=xg(c);Am(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==s&&8),e[t++]=i&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(Am(e,t,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),t+=4,null!=s&&(Am(e,t,n.crc),Am(e,t+4,s),Am(e,t+8,n.size)),Am(e,t+12,l),Am(e,t+14,u),t+=16,null!=o&&(Am(e,t,h),Am(e,t+6,n.attrs),Am(e,t+10,o),t+=14),e.set(r,t),t+=l,u)for(var f in c){var m=c[f],g=m.length;Am(e,t,+f),Am(e,t+2,g),e.set(m,t+4),t+=4+g}return h&&(e.set(a,t),t+=h),t},bg=function(e,t,n,r,i){Am(e,t,101010256),Am(e,t+8,n),Am(e,t+10,n),Am(e,t+12,r),Am(e,t+16,i)},_g=function(){function e(e){this.filename=e,this.c=om(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}(),Mg=function(){function e(e,t){var n=this;t||(t={}),_g.call(this,e),this.d=new Bm(t,(function(e,t){n.ondata(null,e,t)})),this.compression=8,this.flag=mg(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){_g.prototype.push.call(this,e,t)},e}(),Sg=function(){function e(e,t){var n=this;t||(t={}),_g.call(this,e),this.d=new Nm(t,(function(e,t,r){n.ondata(e,t,r)})),this.compression=8,this.flag=mg(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){_g.prototype.push.call(this,e,t)},e}(),Tg=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var n=pg(e.filename),r=n.length,i=e.comment,s=i&&pg(i),o=r!=e.filename.length||s&&i.length!=s.length,a=r+xg(e.extra)+30;if(r>65535)throw"filename too long";var l=new xf(a);wg(l,0,e,n,o);var c=[l],h=function(){for(var e=0,n=c;e<n.length;e++){var r=n[e];t.ondata(null,r,!1)}c=[]},u=this.d;this.d=0;var d=this.u.length,p=cm(e,{f:n,u:o,o:s,t:function(){e.terminate&&e.terminate()},r:function(){if(h(),u){var e=t.u[d+1];e?e.r():t.d=1}u=1}}),f=0;e.ondata=function(n,r,i){if(n)t.ondata(n,r,i),t.terminate();else if(f+=r.length,c.push(r),i){var s=new xf(16);Am(s,0,134695760),Am(s,4,e.crc),Am(s,8,f),Am(s,12,e.size),c.push(s),p.c=f,p.b=a+f+16,p.crc=e.crc,p.size=e.size,u&&p.r(),u=1}else u&&h()},this.u.push(p)},e.prototype.end=function(){var e=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,n=0,r=0,i=this.u;r<i.length;r++){n+=46+(l=i[r]).f.length+xg(l.extra)+(l.o?l.o.length:0)}for(var s=new xf(n+22),o=0,a=this.u;o<a.length;o++){var l=a[o];wg(s,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+xg(l.extra)+(l.o?l.o.length:0),t+=l.b}bg(s,e,this.u.length,n,t),this.ondata(null,s,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++){t[e].t()}this.d=2},e}();var Eg=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),Ag=function(){function e(){var e=this;this.i=new km((function(t,n){e.ondata(null,t,n)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(n){this.ondata(n,e,t)}},e.compression=8,e}(),Cg=function(){function e(e,t){var n=this;t<32e4?this.i=new km((function(e,t){n.ondata(null,e,t)})):(this.i=new Fm((function(e,t,r){n.ondata(e,t,r)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=Xf(e,0)),this.i.push(e,t)},e.compression=8,e}(),Pg=function(){function e(e){this.onfile=e,this.k=[],this.o={0:Eg},this.p=rm}return e.prototype.push=function(e,t){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var r=Math.min(this.c,e.length),i=e.subarray(0,r);if(this.c-=r,this.d?this.d.push(i,!this.c):this.k[0].push(i),(e=e.subarray(r)).length)return this.push(e,t)}else{var s=0,o=0,a=void 0,l=void 0;this.p.length?e.length?((l=new xf(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var c=l.length,h=this.c,u=h&&this.d,d=function(){var e,t=Tm(l,o);if(67324752==t){s=1,a=o,p.d=null,p.c=0;var r=Sm(l,o+6),i=Sm(l,o+8),u=2048&r,d=8&r,f=Sm(l,o+26),m=Sm(l,o+28);if(c>o+30+f+m){var g=[];p.k.unshift(g),s=2;var v,y=Tm(l,o+18),x=Tm(l,o+22),w=fg(l.subarray(o+30,o+=30+f),!u);4294967295==y?(e=d?[-2]:yg(l,o),y=e[0],x=e[1]):d&&(y=-1),o+=m,p.c=y;var b={name:w,compression:i,start:function(){if(!b.ondata)throw"no callback";if(y){var e=n.o[i];if(!e)throw"unknown compression type "+i;(v=y<0?new e(w):new e(w,y,x)).ondata=function(e,t,n){b.ondata(e,t,n)};for(var t=0,r=g;t<r.length;t++){var s=r[t];v.push(s,!1)}n.k[0]==g&&n.c?n.d=v:v.push(rm,!0)}else b.ondata(null,rm,!0)},terminate:function(){v&&v.terminate&&v.terminate()}};y>=0&&(b.size=y,b.originalSize=x),p.onfile(b)}return"break"}if(h){if(134695760==t)return a=o+=12+(-2==h&&8),s=3,p.c=0,"break";if(33639248==t)return a=o-=4,s=3,p.c=0,"break"}},p=this;o<c-4;++o){if("break"===d())break}if(this.p=rm,h<0){var f=s?l.subarray(0,a-12-(-2==h&&8)-(134695760==Tm(l,a-16)&&4)):l.subarray(0,o);u?u.push(f,!!s):this.k[+(2==s)].push(f)}if(2&s)return this.push(l.subarray(o),t);this.p=l.subarray(o)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e.prototype.register=function(e){this.o[e.compression]=e},e}();var Rg=Object.freeze({__proto__:null,Deflate:Bm,AsyncDeflate:Nm,deflate:zm,deflateSync:Um,Inflate:km,AsyncInflate:Fm,inflate:Hm,inflateSync:Gm,Gzip:jm,AsyncGzip:Vm,gzip:Wm,gzipSync:Xm,Gunzip:qm,AsyncGunzip:Ym,gunzip:Zm,gunzipSync:Jm,Zlib:Qm,AsyncZlib:Km,zlib:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[fm,vm,function(){return[$m]}],(function(e){return xm($m(e.data[0],e.data[1]))}),4,n)},zlibSync:$m,Unzlib:eg,AsyncUnzlib:tg,unzlib:ng,unzlibSync:rg,compress:Wm,AsyncCompress:Vm,compressSync:Xm,Compress:jm,Decompress:ig,AsyncDecompress:sg,decompress:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?Zm(e,t,n):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Hm(e,t,n):ng(e,t,n)},decompressSync:function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?Jm(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Gm(e,t):rg(e,t)},DecodeUTF8:ug,EncodeUTF8:dg,strToU8:pg,strFromU8:fg,ZipPassThrough:_g,ZipDeflate:Mg,AsyncZipDeflate:Sg,Zip:Tg,zip:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";var r={};og(e,"",r,t);var i=Object.keys(r),s=i.length,o=0,a=0,l=s,c=new Array(s),h=[],u=function(){for(var e=0;e<h.length;++e)h[e]()},d=function(){var e=new xf(a+22),t=o,r=a-o;a=0;for(var i=0;i<l;++i){var s=c[i];try{var h=s.c.length;wg(e,a,s,s.f,s.u,h);var u=30+s.f.length+xg(s.extra),d=a+u;e.set(s.c,d),wg(e,o,s,s.f,s.u,h,a,s.m),o+=16+u+(s.m?s.m.length:0),a=d+h}catch(e){return n(e,null)}}bg(e,o,c.length,r,t),n(null,e)};s||d();for(var p=function(e){var t=i[e],l=r[t],p=l[0],f=l[1],m=om(),g=p.length;m.p(p);var v=pg(t),y=v.length,x=f.comment,w=x&&pg(x),b=w&&w.length,_=xg(f.extra),M=0==f.level?0:8,S=function(r,i){if(r)u(),n(r,null);else{var l=i.length;c[e]=cm(f,{size:g,crc:m.d(),c:i,f:v,m:w,u:y!=t.length||w&&x.length!=b,compression:M}),o+=30+y+_+l,a+=76+2*(y+_)+(b||0)+l,--s||d()}};if(y>65535&&S("filename too long",null),M)if(g<16e4)try{S(null,Um(p,f))}catch(e){S(e,null)}else h.push(zm(p,f,S));else S(null,p)},f=0;f<l;++f)p(f);return u},zipSync:function(e,t){t||(t={});var n={},r=[];og(e,"",n,t);var i=0,s=0;for(var o in n){var a=n[o],l=a[0],c=a[1],h=0==c.level?0:8,u=(M=pg(o)).length,d=c.comment,p=d&&pg(d),f=p&&p.length,m=xg(c.extra);if(u>65535)throw"filename too long";var g=h?Um(l,c):l,v=g.length,y=om();y.p(l),r.push(cm(c,{size:l.length,crc:y.d(),c:g,f:M,m:p,u:u!=o.length||p&&d.length!=f,o:i,compression:h})),i+=30+u+m+v,s+=76+2*(u+m)+(f||0)+v}for(var x=new xf(s+22),w=i,b=s-i,_=0;_<r.length;++_){var M=r[_];wg(x,M.o,M,M.f,M.u,M.c.length);var S=30+M.f.length+xg(M.extra);x.set(M.c,M.o+S),wg(x,i,M,M.f,M.u,M.c.length,M.o,M.m),i+=16+S+(M.m?M.m.length:0)}return bg(x,i,r.length,b,w),x},UnzipPassThrough:Eg,UnzipInflate:Ag,AsyncUnzipInflate:Cg,Unzip:Pg,unzip:function(e,t){if("function"!=typeof t)throw"no callback";for(var n=[],r=function(){for(var e=0;e<n.length;++e)n[e]()},i={},s=e.length-22;101010256!=Tm(e,s);--s)if(!s||e.length-s>65558)return void t("invalid zip file",null);var o=Sm(e,s+8);o||t(null,{});var a=o,l=Tm(e,s+16),c=4294967295==l;if(c){if(s=Tm(e,s-12),101075792!=Tm(e,s))return void t("invalid zip file",null);a=o=Tm(e,s+32),l=Tm(e,s+48)}for(var h=function(s){var a=vg(e,l,c),h=a[0],u=a[1],d=a[2],p=a[3],f=a[4],m=a[5],g=gg(e,m);l=f;var v=function(e,n){e?(r(),t(e,null)):(i[p]=n,--o||t(null,i))};if(h)if(8==h){var y=e.subarray(g,g+u);if(u<32e4)try{v(null,Gm(y,new xf(d)))}catch(e){v(e,null)}else n.push(Hm(y,{size:d},v))}else v("unknown compression type "+h,null);else v(null,Xf(e,g,g+u))},u=0;u<a;++u)h();return r},unzipSync:function(e){for(var t={},n=e.length-22;101010256!=Tm(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var r=Sm(e,n+8);if(!r)return{};var i=Tm(e,n+16),s=4294967295==i;if(s){if(n=Tm(e,n-12),101075792!=Tm(e,n))throw"invalid zip file";r=Tm(e,n+32),i=Tm(e,n+48)}for(var o=0;o<r;++o){var a=vg(e,i,s),l=a[0],c=a[1],h=a[2],u=a[3],d=a[4],p=a[5],f=gg(e,p);if(i=d,l){if(8!=l)throw"unknown compression type "+l;t[u]=Gm(e.subarray(f,f+c),new xf(h))}else t[u]=Xf(e,f,f+c)}return t}});function Lg(e,t,n){const r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let i=e,s=r,o=Math.floor((i+s)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?s=o:i=o,o=Math.floor((i+s)/2);return o}function Ig(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function Dg(e,t,n,r,i){return function(e){const t=e.length,n=[],r=[];for(let i=0;i<t;++i){const t=e[i];n[i]=new q(t.x,t.y,t.z),r[i]=t.w}const i=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(i[e-n].clone().multiplyScalar(Ig(e,n)*r[n]));i[e]=t.divideScalar(r[0])}return i}(function(e,t,n,r,i){const s=i<e?i:e,o=[],a=Lg(e,r,t),l=function(e,t,n,r,i){const s=[];for(let e=0;e<=n;++e)s[e]=0;const o=[];for(let e=0;e<=r;++e)o[e]=s.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=s.slice(0);a[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let r=1;r<=n;++r){l[r]=t-i[e+1-r],c[r]=i[e+r]-t;let n=0;for(let e=0;e<r;++e){const t=c[e+1],i=l[r-e];a[r][e]=t+i;const s=a[e][r-1]/a[r][e];a[e][r]=n+t*s,n=i*s}a[r][r]=n}for(let e=0;e<=n;++e)o[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,i=1;const l=[];for(let e=0;e<=n;++e)l[e]=s.slice(0);l[0][0]=1;for(let s=1;s<=r;++s){let r=0;const c=e-s,h=n-s;e>=s&&(l[i][0]=l[t][0]/a[h+1][c],r=l[i][0]*a[c][h]);const u=e-1<=h?s-1:n-e;for(let e=c>=-1?1:-c;e<=u;++e)l[i][e]=(l[t][e]-l[t][e-1])/a[h+1][c+e],r+=l[i][e]*a[c+e][h];e<=h&&(l[i][s]=-l[t][s-1]/a[h+1][e],r+=l[i][s]*a[e][h]),o[s][e]=r;const d=t;t=i,i=d}}let h=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)o[e][t]*=h;h*=n-e}return o}(a,r,e,s,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,c[e]=t}for(let t=0;t<=s;++t){const n=c[a-e].clone().multiplyScalar(l[t][0]);for(let r=1;r<=e;++r)n.add(c[a-e+r].clone().multiplyScalar(l[t][r]));o[t]=n}for(let e=s+1;e<=i+1;++e)o[e]=new k(0,0,0);return o}(e,t,n,r,i))}class Og extends io{constructor(e,t,n,r,i){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new k(t.x,t.y,t.z,t.w)}}getPoint(e,t=new q){const n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=function(e,t,n,r){const i=Lg(e,r,t),s=function(e,t,n,r){const i=[],s=[],o=[];i[0]=1;for(let a=1;a<=n;++a){s[a]=t-r[e+1-a],o[a]=r[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=o[e+1],r=s[a-e],l=i[e]/(t+r);i[e]=n+t*l,n=r*l}i[a]=n}return i}(i,r,e,t),o=new k(0,0,0,0);for(let t=0;t<=e;++t){const r=n[i-e+t],a=s[t],l=r.w*a;o.x+=r.x*l,o.y+=r.y*l,o.z+=r.z*l,o.w+=r.w*a}return o}(this.degree,this.knots,this.controlPoints,r);return 1!==i.w&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(e,t=new q){const n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=Dg(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}}let Bg,Ng,zg;class Ug extends rl{constructor(e){super(e)}load(e,t,n,r){const i=this,s=""===i.path?Rl.extractUrlBase(e):i.path,o=new sl(this.manager);o.setPath(i.path),o.setResponseType("arraybuffer"),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(n,s))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===tv(e,0,t.length)}(e))Bg=(new jg).parse(e);else{const t=tv(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(t){const r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e){if(r(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Xg(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Xg(t));Bg=(new Gg).parse(t)}const n=new cl(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new kg(n,this.manager).parse(Bg)}}class kg{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Ng=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),i=(new Fg).parse(r);return this.parseScene(r,i,n),zg}parseConnections(){const e=new Map;if("Connections"in Bg){Bg.Connections.connections.forEach((function(t){const n=t[0],r=t[1],i=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const s={ID:r,relationship:i};e.get(n).parents.push(s),e.has(r)||e.set(r,{parents:[],children:[]});const o={ID:n,relationship:i};e.get(r).children.push(o)}))}return e}parseImages(){const e={},t={};if("Video"in Bg.Objects){const n=Bg.Objects.Video;for(const r in n){const i=n[r];if(e[parseInt(r)]=i.RelativeFilename||i.Filename,"Content"in i){const e=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,s="string"==typeof i.Content&&""!==i.Content;if(e||s){const e=this.parseImage(n[r]);t[i.RelativeFilename||i.Filename]=e}}}}for(const n in e){const r=e[n];void 0!==t[r]?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(r){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof t)return"data:"+i+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:i}))}}parseTextures(e){const t=new Map;if("Texture"in Bg.Objects){const n=Bg.Objects.Texture;for(const r in n){const i=this.parseTexture(n[r],e);t.set(parseInt(r),i)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const r=e.WrapModeU,i=e.WrapModeV,s=void 0!==r?r.value:0,o=void 0!==i?i.value:0;if(n.wrapS=0===s?1e3:1001,n.wrapT=0===o?1e3:1001,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}return n}loadTexture(e,t){let n;const r=this.textureLoader.path,i=Ng.get(e.id).children;let s;void 0!==i&&i.length>0&&void 0!==t[i[0].ID]&&(n=t[i[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const o=e.FileName.slice(-3).toLowerCase();if("tga"===o){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),s=new U):(t.setPath(this.textureLoader.path),s=t.load(n))}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),s=new U):s=this.textureLoader.load(n);return this.textureLoader.setPath(r),s}parseMaterials(e){const t=new Map;if("Material"in Bg.Objects){const n=Bg.Objects.Material;for(const r in n){const i=this.parseMaterial(n[r],e);null!==i&&t.set(parseInt(r),i)}}return t}parseMaterial(e,t){const n=e.id,r=e.attrName;let i=e.ShadingModel;if("object"==typeof i&&(i=i.value),!Ng.has(n))return null;const s=this.parseParameters(e,t,n);let o;switch(i.toLowerCase()){case"phong":o=new Ia;break;case"lambert":o=new Ba;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),o=new Ia}return o.setValues(s),o.name=r,o}parseParameters(e,t,n){const r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=(new I).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(r.color=(new I).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=(new I).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(r.emissive=(new I).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(r.opacity=parseFloat(e.Opacity.value)),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=(new I).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(r.specular=(new I).fromArray(e.SpecularColor.value));const i=this;return Ng.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":r.bumpMap=i.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":r.aoMap=i.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=i.getTexture(t,e.ID),void 0!==r.map&&(r.map.encoding=3001);break;case"DisplacementColor":r.displacementMap=i.getTexture(t,e.ID);break;case"EmissiveColor":r.emissiveMap=i.getTexture(t,e.ID),void 0!==r.emissiveMap&&(r.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=i.getTexture(t,e.ID);break;case"ReflectionColor":r.envMap=i.getTexture(t,e.ID),void 0!==r.envMap&&(r.envMap.mapping=303,r.envMap.encoding=3001);break;case"SpecularColor":r.specularMap=i.getTexture(t,e.ID),void 0!==r.specularMap&&(r.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=i.getTexture(t,e.ID),r.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),r}getTexture(e,t){return"LayeredTexture"in Bg.Objects&&t in Bg.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ng.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Bg.Objects){const n=Bg.Objects.Deformer;for(const r in n){const i=n[r],s=Ng.get(parseInt(r));if("Skin"===i.attrType){const t=this.parseSkeleton(s,n);t.ID=r,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,e[r]=t}else if("BlendShape"===i.attrType){const e={id:r};e.rawTargets=this.parseMorphTargets(s,n),e.id=r,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const r=t[e.ID];if("Cluster"!==r.attrType)return;const i={ID:e.ID,indices:[],weights:[],transformLink:(new Se).fromArray(r.TransformLink.a)};"Indexes"in r&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const i=e.children[r],s=t[i.ID],o={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;o.geoID=Ng.get(parseInt(i.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(o)}return n}parseScene(e,t,n){zg=new Fi;const r=this.parseModels(e.skeletons,t,n),i=Bg.Objects.Model,s=this;r.forEach((function(e){const t=i[e.ID];s.setLookAtProperties(e,t);Ng.get(e.ID).parents.forEach((function(t){const n=r.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&zg.add(e)})),this.bindSkeleton(e.skeletons,t,r),this.createAmbientLight(),zg.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=Kg(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const o=(new Hg).parse();1===zg.children.length&&zg.children[0].isGroup&&(zg.children[0].animations=o,zg=zg.children[0]),zg.animations=o}parseModels(e,t,n){const r=new Map,i=Bg.Objects.Model;for(const s in i){const o=parseInt(s),a=i[s],l=Ng.get(o);let c=this.buildSkeleton(l,e,o,a.attrName);if(!c){switch(a.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new Ts;break;case"Null":default:c=new Fi}c.name=a.attrName?dc.sanitizeNodeName(a.attrName):"",c.ID=o}this.getTransformData(c,a),r.set(o,c)}return r}buildSkeleton(e,t,n,r){let i=null;return e.parents.forEach((function(e){for(const s in t){const o=t[s];o.rawBones.forEach((function(t,s){if(t.ID===e.ID){const e=i;i=new Ts,i.matrixWorld.copy(t.transformLink),i.name=r?dc.sanitizeNodeName(r):"",i.ID=n,o.bones[s]=i,null!==e&&i.add(e)}}))}})),i}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=Bg.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new Ze;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let r=1;void 0!==n.NearPlane&&(r=n.NearPlane.value/1e3);let i=1e3;void 0!==n.FarPlane&&(i=n.FarPlane.value/1e3);let s=window.innerWidth,o=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(s=n.AspectWidth.value,o=n.AspectHeight.value);const a=s/o;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new nn(l,a,r,i),null!==c&&t.setFocalLength(c);break;case 1:t=new En(-s/2,s/2,o/2,-o/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new Ze}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=Bg.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new Ze;else{let e;e=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=(new I).fromArray(n.Color.value));let i=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(i=0);let s=0;void 0!==n.FarAttenuationEnd&&(s=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new _l(r,i,s,o);break;case 1:t=new Sl(r,i);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=m.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=m.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new vl(r,i,s,e,a,o);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new _l(r,i)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,i=null,s=null;const o=[];return e.children.forEach((function(e){t.has(e.ID)&&(i=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))})),o.length>1?s=o:o.length>0?s=o[0]:(s=new Ia({color:13421772}),o.push(s)),"color"in i.attributes&&o.forEach((function(e){e.vertexColors=!0})),i.FBX_Deformer?(r=new Ss(i,s),r.normalizeSkinWeights()):r=new Yt(i,s),r}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),r=new Ns({color:3342591,linewidth:1});return new Gs(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?$g(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){Ng.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const n=Bg.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),zg.add(e.target)):e.lookAt((new q).fromArray(t))}}}))}}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const i in e){const s=e[i];Ng.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;Ng.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new Ps(s.bones),r[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in Bg.Objects){const t=Bg.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const r=t[n].PoseNode;Array.isArray(r)?r.forEach((function(t){e[t.Node]=(new Se).fromArray(t.Matrix.a)})):e[r.Node]=(new Se).fromArray(r.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Bg&&"AmbientColor"in Bg.GlobalSettings){const e=Bg.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(0!==t||0!==n||0!==r){const e=new I(t,n,r);zg.add(new Tl(e,1))}}}}class Fg{parse(e){const t=new Map;if("Geometry"in Bg.Objects){const n=Bg.Objects.Geometry;for(const r in n){const i=Ng.get(parseInt(r)),s=this.parseGeometry(i,n[r],e);t.set(parseInt(r),s)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,i=[],s=e.parents.map((function(e){return Bg.Objects.Model[e.ID]}));if(0===s.length)return;const o=e.children.reduce((function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&i.push(n.morphTargets[e.ID])}));const a=s[0],l={};"RotationOrder"in a&&(l.eulerOrder=$g(a.RotationOrder.value)),"InheritType"in a&&(l.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(l.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(l.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(l.scale=a.GeometricScaling.value);const c=Kg(l);return this.genGeometry(t,o,i,c)}genGeometry(e,t,n,r){const i=new Rt;e.attrName&&(i.name=e.attrName);const s=this.parseGeoNode(e,t),o=this.genBuffers(s),a=new bt(o.vertex,3);if(a.applyMatrix4(r),i.setAttribute("position",a),o.colors.length>0&&i.setAttribute("color",new bt(o.colors,3)),t&&(i.setAttribute("skinIndex",new vt(o.weightsIndices,4)),i.setAttribute("skinWeight",new bt(o.vertexWeights,4)),i.FBX_Deformer=t),o.normal.length>0){const e=(new v).getNormalMatrix(r),t=new bt(o.normal,3);t.applyNormalMatrix(e),i.setAttribute("normal",t)}if(o.uvs.forEach((function(e,t){let n="uv"+(t+1).toString();0===t&&(n="uv"),i.setAttribute(n,new bt(o.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach((function(n,r){n!==e&&(i.addGroup(t,r-t,e),e=n,t=r)})),i.groups.length>0){const t=i.groups[i.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&i.addGroup(n,o.materialIndex.length-n,e)}0===i.groups.length&&i.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(i,e,n,r),i}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(r,i){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[i]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,i=!1,s=[],o=[],a=[],l=[],c=[],h=[];const u=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(s.push(3*d,3*d+1,3*d+2),e.color){const t=Zg(p,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),v.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,r){let i=n,s=g[r];t.forEach((function(t,n,r){if(i>t){r[n]=i,i=t;const o=e[n];e[n]=s,s=o}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)c.push(v[e]),h.push(g[e])}if(e.normal){const t=Zg(p,n,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=Zg(p,n,d,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){const r=Zg(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(r[0]),l[t].push(r[1])})),r++,m&&(u.genFace(t,e,s,f,o,a,l,c,h,r),n++,r=0,s=[],o=[],a=[],l=[],c=[],h=[])})),t}genFace(e,t,n,r,i,s,o,a,l,c){for(let h=2;h<c;h++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(h-1)]]),e.vertex.push(t.vertexPositions[n[3*(h-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(h-1)+2]]),e.vertex.push(t.vertexPositions[n[3*h]]),e.vertex.push(t.vertexPositions[n[3*h+1]]),e.vertex.push(t.vertexPositions[n[3*h+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[4*(h-1)]),e.vertexWeights.push(a[4*(h-1)+1]),e.vertexWeights.push(a[4*(h-1)+2]),e.vertexWeights.push(a[4*(h-1)+3]),e.vertexWeights.push(a[4*h]),e.vertexWeights.push(a[4*h+1]),e.vertexWeights.push(a[4*h+2]),e.vertexWeights.push(a[4*h+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(h-1)]),e.weightsIndices.push(l[4*(h-1)+1]),e.weightsIndices.push(l[4*(h-1)+2]),e.weightsIndices.push(l[4*(h-1)+3]),e.weightsIndices.push(l[4*h]),e.weightsIndices.push(l[4*h+1]),e.weightsIndices.push(l[4*h+2]),e.weightsIndices.push(l[4*h+3])),t.color&&(e.colors.push(s[0]),e.colors.push(s[1]),e.colors.push(s[2]),e.colors.push(s[3*(h-1)]),e.colors.push(s[3*(h-1)+1]),e.colors.push(s[3*(h-1)+2]),e.colors.push(s[3*h]),e.colors.push(s[3*h+1]),e.colors.push(s[3*h+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[3*(h-1)]),e.normal.push(i[3*(h-1)+1]),e.normal.push(i[3*(h-1)+2]),e.normal.push(i[3*h]),e.normal.push(i[3*h+1]),e.normal.push(i[3*h+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(o[n][0]),e.uvs[n].push(o[n][1]),e.uvs[n].push(o[n][2*(h-1)]),e.uvs[n].push(o[n][2*(h-1)+1]),e.uvs[n].push(o[n][2*h]),e.uvs[n].push(o[n][2*h+1])}))}addMorphTargets(e,t,n,r){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const i=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=Bg.Objects.Geometry[n.geoID];void 0!==s&&i.genMorphGeometry(e,t,s,r,n.name)}))}))}genMorphGeometry(e,t,n,r,i){const s=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],o=void 0!==n.Vertices?n.Vertices.a:[],a=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<a.length;e++){const t=3*a[e];c[t]=o[3*e],c[t+1]=o[3*e+1],c[t+2]=o[3*e+2]}const h={vertexIndices:s,vertexPositions:c},u=this.genBuffers(h),d=new bt(u.vertex,3);d.name=i||n.attrName,d.applyMatrix4(r),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let i=[];return"IndexToDirect"===n&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let i=[];return"IndexToDirect"===n&&(i=e.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a;let i=[];return"IndexToDirect"===n&&(i=e.ColorIndex.a),{dataSize:4,buffer:r,indices:i,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,i=[];for(let e=0;e<r.length;++e)i.push(e);return{dataSize:1,buffer:r,indices:i,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(void 0===Og)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new Rt;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Rt;const n=t-1,r=e.KnotVector.a,i=[],s=e.Points.a;for(let e=0,t=s.length;e<t;e+=4)i.push((new k).fromArray(s,e));let o,a;if("Closed"===e.Form)i.push(i[0]);else if("Periodic"===e.Form){o=n,a=r.length-1-o;for(let e=0;e<n;++e)i.push(i[e])}const l=new Og(n,r,i,o,a).getPoints(12*i.length);return(new Rt).setFromPoints(l)}}class Hg{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const r=t[n],i=this.addClip(r);e.push(i)}return e}parseClips(){if(void 0===Bg.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Bg.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const e={id:r.id,attr:r.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Bg.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(qg),values:t[n].KeyValueFloat.a},i=Ng.get(r.id);if(void 0!==i){const t=i.parents[0].ID,n=i.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=r:n.match(/Y/)?e.get(t).curves.y=r:n.match(/Z/)?e.get(t).curves.z=r:n.match(/d|DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=r)}}}parseAnimationLayers(e){const t=Bg.Objects.AnimationLayer,n=new Map;for(const r in t){const t=[],i=Ng.get(parseInt(r));if(void 0!==i){i.children.forEach((function(n,r){if(e.has(n.ID)){const i=e.get(n.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===t[r]){const e=Ng.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const i=Bg.Objects.Model[e.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:i.attrName?dc.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};zg.traverse((function(e){e.ID===i.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))})),s.transform||(s.transform=new Se),"PreRotation"in i&&(s.preRotation=i.PreRotation.value),"PostRotation"in i&&(s.postRotation=i.PostRotation.value),t[r]=s}}t[r]&&(t[r][i.attr]=i)}else if(void 0!==i.curves.morph){if(void 0===t[r]){const e=Ng.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,i=Ng.get(e).parents[0].ID,s=Ng.get(i).parents[0].ID,o=Ng.get(s).parents[0].ID,a=Bg.Objects.Model[o],l={modelName:a.attrName?dc.sanitizeNodeName(a.attrName):"",morphName:Bg.Objects.Deformer[e].attrName};t[r]=l}t[r][i.attr]=i}}})),n.set(parseInt(r),t)}}return n}parseAnimStacks(e){const t=Bg.Objects.AnimationStack,n={};for(const r in t){const i=Ng.get(parseInt(r)).children;i.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(i[0].ID);n[r]={name:t[r].attrName,layer:s}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new Ka(e.name,-1,t)}generateTracks(e){const t=[];let n=new q,r=new X,i=new q;if(e.transform&&e.transform.decompose(n,r,i),n=n.toArray(),r=(new Oe).setFromQuaternion(r,e.eulerOrder).toArray(),i=i.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==r&&t.push(r)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,r){const i=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(i,t,n);return new Qa(e+"."+r,i,s)}generateRotationTrack(e,t,n,r,i,s){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(m.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(m.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(m.degToRad));const o=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(o,t,n);void 0!==r&&((r=r.map(m.degToRad)).push(s),r=(new Oe).fromArray(r),r=(new X).setFromEuler(r)),void 0!==i&&((i=i.map(m.degToRad)).push(s),i=(new Oe).fromArray(i),i=(new X).setFromEuler(i).invert());const l=new X,c=new Oe,h=[];for(let e=0;e<a.length;e+=3)c.set(a[e],a[e+1],a[e+2],s),l.setFromEuler(c),void 0!==r&&l.premultiply(r),void 0!==i&&l.multiply(i),l.toArray(h,e/3*4);return new Za(e+".quaternion",o,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),r=zg.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new qa(e.modelName+".morphTargetInfluences["+r+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){const i=t[r];i!==n&&(t[e]=i,n=i,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const r=n,i=[];let s=-1,o=-1,a=-1;return e.forEach((function(e){if(t.x&&(s=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==s){const e=t.x.values[s];i.push(e),r[0]=e}else i.push(r[0]);if(-1!==o){const e=t.y.values[o];i.push(e),r[1]=e}else i.push(r[1]);if(-1!==a){const e=t.z.values[a];i.push(e),r[2]=e}else i.push(r[2])})),i}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],r=e.values[t]-n,i=Math.abs(r);if(i>=180){const s=i/180,o=r/s;let a=n+o;const l=e.times[t-1],c=(e.times[t]-l)/s;let h=l+c;const u=[],d=[];for(;h<e.times[t];)u.push(h),h+=c,d.push(a),a+=o;e.times=nv(e.times,t,u),e.values=nv(e.values,t,d)}}}}class Gg{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Wg,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,r){const i=e.match(/^[\s\t]*;/),s=e.match(/^[\s\t]*$/);if(i||s)return;const o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,n[++r]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),i={name:n},s=this.parseNodeAttr(r),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,i):n in o?("PoseNode"===n?o.PoseNode.push(i):void 0!==o[n].id&&(o[n]={},o[n][o[n].id]=o[n]),""!==s.id&&(o[n][s.id]=i)):"number"==typeof s.id?(o[n]={},o[n][s.id]=i):"Properties70"!==n&&(o[n]="PoseNode"===n?[i]:i),"number"==typeof s.id&&(i.id=s.id),""!==s.name&&(i.attrName=s.name),""!==s.type&&(i.attrType=s.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),i=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===r){const e=i.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let o=i.split(",").slice(3);o=o.map((function(e){return e.trim().replace(/^"/,"")})),r="connections",i=[t,n],function(e,t){for(let n=0,r=e.length,i=t.length;n<i;n++,r++)e[r]=t[n]}(i,o),void 0===s[r]&&(s[r]=[])}"Node"===r&&(s.id=i),r in s&&Array.isArray(s[r])?s[r].push(i):"a"!==r?s[r]=i:s.a=i,this.setCurrentProp(s,r),"a"===r&&","!==i.slice(-1)&&(s.a=ev(i))}else this.parseNodeSpecialProperty(e,r,i)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=ev(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),i=r[0],s=r[1],o=r[2],a=r[3];let l=r[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=ev(l)}this.getPrevNode()[i]={type:s,type2:o,flag:a,value:l},this.setCurrentProp(this.getPrevNode(),i)}}class jg{parse(e){const t=new Vg(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new Wg;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),o=e.getString(s);if(0===r)return null;const a=[];for(let t=0;t<i;t++)a.push(this.parseProperty(e));const l=a.length>0?a[0]:"",c=a.length>1?a[1]:"",h=a.length>2?a[2]:"";for(n.singleProperty=1===i&&e.getOffset()===r;r>e.getOffset();){const r=this.parseNode(e,t);null!==r&&this.parseSubNode(o,n,r)}return n.propertyList=a,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==h&&(n.attrType=h),""!==o&&(n.name=o),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],s=n.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),o="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:i,flag:s,value:o}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),i=e.getUint32(),s=e.getUint32();if(0===i)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}void 0===Rg&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=rg(new Uint8Array(e.getArrayBuffer(s))),a=new Vg(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(r);case"d":return a.getFloat64Array(r);case"f":return a.getFloat32Array(r);case"i":return a.getInt32Array(r);case"l":return a.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Vg{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let n=0;n<e;n++)t[n]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Rl.decodeText(new Uint8Array(t))}}class Wg{add(e,t){this[e]=t}}function Xg(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function qg(e){return e/46186158e3}const Yg=[];function Zg(e,t,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=e;break;case"ByPolygon":i=t;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(i=r.indices[i]);const s=i*r.dataSize,o=s+r.dataSize;return function(e,t,n,r){for(let i=n,s=0;i<r;i++,s++)e[s]=t[i];return e}(Yg,r.buffer,s,o)}const Jg=new Oe,Qg=new q;function Kg(e){const t=new Se,n=new Se,r=new Se,i=new Se,s=new Se,o=new Se,a=new Se,l=new Se,c=new Se,h=new Se,u=new Se,d=new Se,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(Qg.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(m.degToRad);t.push(e.eulerOrder),n.makeRotationFromEuler(Jg.fromArray(t))}if(e.rotation){const t=e.rotation.map(m.degToRad);t.push(e.eulerOrder),r.makeRotationFromEuler(Jg.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(m.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(Jg.fromArray(t)),i.invert()}e.scale&&s.scale(Qg.fromArray(e.scale)),e.scalingOffset&&a.setPosition(Qg.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(Qg.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(Qg.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(Qg.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(u.copy(e.parentMatrix),h.copy(e.parentMatrixWorld));const f=n.clone().multiply(r).multiply(i),g=new Se;g.extractRotation(h);const v=new Se;v.copyPosition(h);const y=v.clone().invert().multiply(h),x=g.clone().invert().multiply(y),w=s,b=new Se;if(0===p)b.copy(g).multiply(f).multiply(x).multiply(w);else if(1===p)b.copy(g).multiply(x).multiply(f).multiply(w);else{const e=(new Se).scale((new q).setFromMatrixScale(u)).clone().invert(),t=x.clone().multiply(e);b.copy(g).multiply(f).multiply(t).multiply(w)}const _=c.clone().invert(),M=o.clone().invert();let S=t.clone().multiply(l).multiply(c).multiply(n).multiply(r).multiply(i).multiply(_).multiply(a).multiply(o).multiply(s).multiply(M);const T=(new Se).copyPosition(S),E=h.clone().multiply(T);return d.copyPosition(E),S=d.clone().multiply(b),S.premultiply(h.invert()),S}function $g(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function ev(e){return e.split(",").map((function(e){return parseFloat(e)}))}function tv(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),Rl.decodeText(new Uint8Array(e,t,n))}function nv(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class rv extends ll{constructor(e){super(e)}parse(e){const t=0,n=1,r=2,i=3,s=9,o=10,a=11,l=48,c=4,h=0,u=1,d=2,p=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let f=0;const m=new Uint8Array(e),g={id_length:m[f++],colormap_type:m[f++],image_type:m[f++],colormap_index:m[f++]|m[f++]<<8,colormap_length:m[f++]|m[f++]<<8,colormap_size:m[f++],origin:[m[f++]|m[f++]<<8,m[f++]|m[f++]<<8],width:m[f++]|m[f++]<<8,height:m[f++]|m[f++]<<8,pixel_size:m[f++],flags:m[f++]};!function(e){switch(e.image_type){case n:case s:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case r:case i:case o:case a:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(g),g.id_length+f>e.length&&console.error("THREE.TGALoader: No data."),f+=g.id_length;let v=!1,y=!1,x=!1;switch(g.image_type){case s:v=!0,y=!0;break;case n:y=!0;break;case o:v=!0;break;case r:break;case a:v=!0,x=!0;break;case i:x=!0}const w=new Uint8Array(g.width*g.height*4),b=function(e,t,n,r,i){let s,o;const a=n.pixel_size>>3,l=n.width*n.height*a;if(t&&(o=i.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(l);let o=0;const c=new Uint8Array(a);for(;o<l;)if(e=i[r++],t=1+(127&e),128&e){for(n=0;n<a;++n)c[n]=i[r++];for(n=0;n<t;++n)s.set(c,o+n*a);o+=a*t}else{for(t*=a,n=0;n<t;++n)s[o+n]=i[r++];o+=t}}else s=i.subarray(r,r+=t?n.width*n.height:l);return{pixel_data:s,palettes:o}}(v,y,g,f,m);return function(e,t,n,r,i){let s,o,a,f,m,v;switch((g.flags&l)>>c){default:case d:s=0,a=1,m=t,o=0,f=1,v=n;break;case h:s=0,a=1,m=t,o=n-1,f=-1,v=-1;break;case p:s=t-1,a=-1,m=-1,o=0,f=1,v=n;break;case u:s=t-1,a=-1,m=-1,o=n-1,f=-1,v=-1}if(x)switch(g.pixel_size){case 8:!function(e,t,n,r,i,s,o,a){let l,c,h,u=0;const d=g.width;for(h=t;h!==r;h+=n)for(c=i;c!==o;c+=s,u++)l=a[u],e[4*(c+d*h)+0]=l,e[4*(c+d*h)+1]=l,e[4*(c+d*h)+2]=l,e[4*(c+d*h)+3]=255}(e,o,f,v,s,a,m,r);break;case 16:!function(e,t,n,r,i,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==o;l+=s,h+=2)e[4*(l+u*c)+0]=a[h+0],e[4*(l+u*c)+1]=a[h+0],e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+3]=a[h+1]}(e,o,f,v,s,a,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(e,t,n,r,i,s,o,a,l){const c=l;let h,u,d,p=0;const f=g.width;for(d=t;d!==r;d+=n)for(u=i;u!==o;u+=s,p++)h=a[p],e[4*(u+f*d)+3]=255,e[4*(u+f*d)+2]=c[3*h+0],e[4*(u+f*d)+1]=c[3*h+1],e[4*(u+f*d)+0]=c[3*h+2]}(e,o,f,v,s,a,m,r,i);break;case 16:!function(e,t,n,r,i,s,o,a){let l,c,h,u=0;const d=g.width;for(h=t;h!==r;h+=n)for(c=i;c!==o;c+=s,u+=2)l=a[u+0]+(a[u+1]<<8),e[4*(c+d*h)+0]=(31744&l)>>7,e[4*(c+d*h)+1]=(992&l)>>2,e[4*(c+d*h)+2]=(31&l)<<3,e[4*(c+d*h)+3]=32768&l?0:255}(e,o,f,v,s,a,m,r);break;case 24:!function(e,t,n,r,i,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==o;l+=s,h+=3)e[4*(l+u*c)+3]=255,e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+1]=a[h+1],e[4*(l+u*c)+0]=a[h+2]}(e,o,f,v,s,a,m,r);break;case 32:!function(e,t,n,r,i,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==o;l+=s,h+=4)e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+1]=a[h+1],e[4*(l+u*c)+0]=a[h+2],e[4*(l+u*c)+3]=a[h+3]}(e,o,f,v,s,a,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}}(w,g.width,g.height,b.pixel_data,b.palettes),{data:w,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:1008}}}class iv extends rl{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new cv(e)})),this.register((function(e){return new mv(e)})),this.register((function(e){return new gv(e)})),this.register((function(e){return new hv(e)})),this.register((function(e){return new uv(e)})),this.register((function(e){return new dv(e)})),this.register((function(e){return new pv(e)})),this.register((function(e){return new fv(e)})),this.register((function(e){return new av(e)})),this.register((function(e){return new vv(e)}))}load(e,t,n,r){const i=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Rl.extractUrlBase(e),this.manager.itemStart(e);const o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},a=new sl(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{i.parse(n,s,(function(n){t(n),i.manager.itemEnd(e)}),o)}catch(e){o(e)}}),n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const s={},o={};if("string"==typeof e)i=e;else{if(Rl.decodeText(new Uint8Array(e,0,4))===yv){try{s[ov.KHR_BINARY_GLTF]=new bv(e)}catch(e){return void(r&&r(e))}i=s[ov.KHR_BINARY_GLTF].content}else i=Rl.decodeText(new Uint8Array(e))}const a=JSON.parse(i);if(void 0===a.asset||a.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new ey(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);o[t.name]=t,s[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){const t=a.extensionsUsed[e],n=a.extensionsRequired||[];switch(t){case ov.KHR_MATERIALS_UNLIT:s[t]=new lv;break;case ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[t]=new Tv;break;case ov.KHR_DRACO_MESH_COMPRESSION:s[t]=new _v(a,this.dracoLoader);break;case ov.KHR_TEXTURE_TRANSFORM:s[t]=new Mv;break;case ov.KHR_MESH_QUANTIZATION:s[t]=new Ev;break;default:n.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function sv(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const ov={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class av{constructor(e){this.parser=e,this.name=ov.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const i=t.json,s=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let o;const a=new I(16777215);void 0!==s.color&&a.fromArray(s.color);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new Sl(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new _l(a),o.distance=l;break;case"spot":o=new vl(a),o.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),o.decay=2,void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),r=Promise.resolve(o),t.cache.add(n,r),r}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class lv{constructor(){this.name=ov.KHR_MATERIALS_UNLIT}getMaterialType(){return ct}extendParams(e,t,n){const r=[];e.color=new I(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,3001))}return Promise.all(r)}}class cv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new g(e,e)}return Promise.all(i)}}class hv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new I(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=r.extensions[this.name];return void 0!==s.sheenColorFactor&&t.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,3001)),void 0!==s.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class uv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class dv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new I(o[0],o[1],o[2]),Promise.all(i)}}class pv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class fv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new I(o[0],o[1],o[2]),void 0!==s.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,3001)),Promise.all(i)}}class mv{constructor(e){this.parser=e,this.name=ov.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,s)}}class gv{constructor(e){this.parser=e,this.name=ov.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],o=r.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,o,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class vv{constructor(e){this.name=ov.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,i.ready]).then((function(t){const n=e.byteOffset||0,r=e.byteLength||0,s=e.count,o=e.byteStride,a=new ArrayBuffer(s*o),l=new Uint8Array(t[0],n,r);return i.decodeGltfBuffer(new Uint8Array(a),s,o,l,e.mode,e.filter),a}))}return null}}const yv="glTF",xv=1313821514,wv=5130562;class bv{constructor(e){this.name=ov.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Rl.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==yv)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let i=0;for(;i<n;){const t=r.getUint32(i,!0);i+=4;const n=r.getUint32(i,!0);if(i+=4,n===xv){const n=new Uint8Array(e,12+i,t);this.content=Rl.decodeText(n)}else if(n===wv){const n=12+i;this.body=e.slice(n,n+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class _v{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ov.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},l={};for(const e in s){const t=Hv[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const r=Hv[t]||t.toLowerCase();if(void 0!==s[t]){const i=n.accessors[e.attributes[t]],s=zv[i.componentType];l[r]=s,a[r]=!0===i.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=a[t];void 0!==r&&(n.normalized=r)}t(e)}),o,l)}))}))}}class Mv{constructor(){this.name=ov.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Sv extends Ra{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),r=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),i=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),s=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),o={specular:{value:(new I).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=o,this.onBeforeCompile=function(e){for(const t in o)e.uniforms[t]=o[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",r).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",s)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(e){o.specular.value=e}},specularMap:{get:function(){return o.specularMap.value},set:function(e){o.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(e){o.glossiness.value=e}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(e){o.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class Tv{constructor(){this.name=ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return Sv}extendParams(e,t,n){const r=t.extensions[this.name];e.color=new I(1,1,1),e.opacity=1;const i=[];if(Array.isArray(r.diffuseFactor)){const t=r.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==r.diffuseTexture&&i.push(n.assignTexture(e,"map",r.diffuseTexture,3001)),e.emissive=new I(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new I(1,1,1),Array.isArray(r.specularFactor)&&e.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const t=r.specularGlossinessTexture;i.push(n.assignTexture(e,"glossinessMap",t)),i.push(n.assignTexture(e,"specularMap",t,3001))}return Promise.all(i)}createMaterial(e){const t=new Sv(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=0,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class Ev{constructor(){this.name=ov.KHR_MESH_QUANTIZATION}}class Av extends Fa{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}}Av.prototype.beforeStart_=Av.prototype.copySampleValue_,Av.prototype.afterEnd_=Av.prototype.copySampleValue_,Av.prototype.interpolate_=function(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=r-t,h=(n-t)/c,u=h*h,d=u*h,p=e*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+h;for(let e=0;e!==o;e++){const t=s[f+e+o],n=s[f+e+a]*c,r=s[p+e+o],l=s[p+e]*c;i[e]=v*t+y*n+m*r+g*l}return i};const Cv=new X;class Pv extends Av{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return Cv.fromArray(i).normalize().toArray(i),i}}const Rv=0,Lv=1,Iv=2,Dv=3,Ov=4,Bv=5,Nv=6,zv={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Uv={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},kv={33071:1001,33648:1002,10497:1e3},Fv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Hv={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Gv={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jv={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},Vv="OPAQUE",Wv="MASK",Xv="BLEND";function qv(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new Ra({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Yv(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function Zv(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Jv(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Qv(e){const t=e.extensions&&e.extensions[ov.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+Kv(t.attributes):e.indices+":"+Kv(e.attributes)+":"+e.mode,n}function Kv(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function $v(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class ey{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new sv,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?this.textureLoader=new Nl(this.options.manager):this.textureLoader=new cl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new sl(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};Yv(i,s,r),Zv(s,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this.loadNode(t);break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this.loadAnimation(t);break;case"camera":r=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[ov.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(Rl.resolveURL(t.uri,r.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse)return Promise.resolve(null);const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],s=Fv[r.type],o=zv[r.componentType],a=o.BYTES_PER_ELEMENT,l=a*s,c=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,u=!0===r.normalized;let d,p;if(h&&h!==l){const e=Math.floor(c/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(n);l||(d=new o(i,e*h,r.count*h/a),l=new Qi(d,h/a),t.cache.add(n,l)),p=new $i(l,s,c%h/a,u)}else d=null===i?new o(r.count*s):new o(i,c,r.count*s),p=new dt(d,s,u);if(void 0!==r.sparse){const t=Fv.SCALAR,n=zv[r.sparse.indices.componentType],a=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new n(e[1],a,r.sparse.count*t),h=new o(e[2],l,r.sparse.count*s);null!==i&&(p=new dt(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,h[e*s]),s>=2&&p.setY(t,h[e*s+1]),s>=3&&p.setZ(t,h[e*s+2]),s>=4&&p.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let s=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){const r=this,i=this.json,s=i.textures[e],o=i.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,s.name&&(t.name=s.name);const n=(i.samplers||{})[s.sampler]||{};return t.magFilter=Uv[n.magFilter]||1006,t.minFilter=Uv[n.minFilter]||1008,t.wrapS=kv[n.wrapS]||1e3,t.wrapT=kv[n.wrapT]||1e3,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=l,l}loadImageSource(e,t){const n=this,r=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=r.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then((function(e){return new Promise((function(n,r){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new U(e);t.needsUpdate=!0,n(t)}),t.load(Rl.resolveURL(e,i.path),s,void 0,r)}))})).then((function(e){var t;return!0===l&&o.revokeObjectURL(a),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(s){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[ov.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[ov.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(s);s=i.extensions[ov.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.encoding=r),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new qs,lt.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Ns,lt.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(r||i||s){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),s&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Ra}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let s;const o={},a=i.extensions||{},l=[];if(a[ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=r[ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else if(a[ov.KHR_MATERIALS_UNLIT]){const e=r[ov.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else{const n=i.pbrMetallicRoughness||{};if(o.color=new I(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.fromArray(e),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,3001)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===i.doubleSided&&(o.side=2);const c=i.alphaMode||Vv;if(c===Xv?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===Wv&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&s!==ct&&(l.push(t.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new g(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;o.normalScale.set(e,e)}return void 0!==i.occlusionTexture&&s!==ct&&(l.push(t.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&s!==ct&&(o.emissive=(new I).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&s!==ct&&l.push(t.assignTexture(o,"emissiveMap",i.emissiveTexture,3001)),Promise.all(l).then((function(){let n;return n=s===Sv?r[ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new s(o),i.name&&(n.name=i.name),Zv(n,i),t.associations.set(n,{materials:e}),i.extensions&&Yv(r,n,i),n}))}createUniqueName(e){const t=dc.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[ov.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return ny(n,e,t)}))}const s=[];for(let n=0,o=e.length;n<o;n++){const o=e[n],a=Qv(o),l=r[a];if(l)s.push(l.promise);else{let e;e=o.extensions&&o.extensions[ov.KHR_DRACO_MESH_COMPRESSION]?i(o):ny(new Rt,o,t),r[a]={primitive:o,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,r=this.extensions,i=n.meshes[e],s=i.primitives,o=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?qv(this.cache):this.getDependency("material",s[e].material);o.push(t)}return o.push(t.loadGeometries(s)),Promise.all(o).then((function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],l=[];for(let n=0,c=a.length;n<c;n++){const c=a[n],h=s[n];let u;const d=o[n];if(h.mode===Ov||h.mode===Bv||h.mode===Nv||void 0===h.mode)u=!0===i.isSkinnedMesh?new Ss(c,d):new Yt(c,d),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),h.mode===Bv?u.geometry=ry(u.geometry,1):h.mode===Nv&&(u.geometry=ry(u.geometry,2));else if(h.mode===Lv)u=new Ws(c,d);else if(h.mode===Dv)u=new Gs(c,d);else if(h.mode===Iv)u=new Xs(c,d);else{if(h.mode!==Rv)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new Ks(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&Jv(u,i),u.name=t.createUniqueName(i.name||"mesh_"+e),Zv(u,i),h.extensions&&Yv(r,u,h),t.assignFinalMaterial(u),l.push(u)}for(let n=0,r=l.length;n<r;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new Fi;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new nn(m.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new En(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Zv(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return n.inverseBindMatrices=e,n}))}loadAnimation(e){const t=this.json.animations[e],n=[],r=[],i=[],s=[],o=[];for(let e=0,a=t.channels.length;e<a;e++){const a=t.channels[e],l=t.samplers[a.sampler],c=a.target,h=void 0!==c.node?c.node:c.id,u=void 0!==t.parameters?t.parameters[l.input]:l.input,d=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",h)),r.push(this.getDependency("accessor",u)),i.push(this.getDependency("accessor",d)),s.push(l),o.push(c)}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(i),Promise.all(s),Promise.all(o)]).then((function(n){const r=n[0],i=n[1],s=n[2],o=n[3],a=n[4],l=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=i[e],c=s[e],h=o[e],u=a[e];if(void 0===t)continue;let d;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,Gv[u.path]){case Gv.weights:d=qa;break;case Gv.rotation:d=Za;break;case Gv.position:case Gv.scale:default:d=Qa}const p=t.name?t.name:t.uuid,f=void 0!==h.interpolation?jv[h.interpolation]:2301,m=[];Gv[u.path]===Gv.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name?e.name:e.uuid)})):m.push(p);let g=c.array;if(c.normalized){const e=$v(g.constructor),t=new Float32Array(g.length);for(let n=0,r=g.length;n<r;n++)t[n]=g[n]*e;g=t}for(let e=0,t=m.length;e<t;e++){const t=new d(m[e]+"."+Gv[u.path],n.array,g,f);"CUBICSPLINE"===h.interpolation&&(t.createInterpolant=function(e){return new(this instanceof Za?Pv:Av)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new Ka(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,r=this,i=t.nodes[e],s=i.name?r.createUniqueName(i.name):"";return function(){const t=[],n=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==i.camera&&t.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let o;if(o=!0===i.isBone?new Ts:t.length>1?new Fi:1===t.length?t[0]:new Ze,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=s),Zv(o,i),i.extensions&&Yv(n,o,i),void 0!==i.matrix){const e=new Se;e.fromArray(i.matrix),o.applyMatrix4(e)}else void 0!==i.translation&&o.position.fromArray(i.translation),void 0!==i.rotation&&o.quaternion.fromArray(i.rotation),void 0!==i.scale&&o.scale.fromArray(i.scale);return r.associations.has(o)||r.associations.set(o,{}),r.associations.get(o).nodes=e,o}))}loadScene(e){const t=this.json,n=this.extensions,r=this.json.scenes[e],i=this,s=new Fi;r.name&&(s.name=i.createUniqueName(r.name)),Zv(s,r),r.extensions&&Yv(n,s,r);const o=r.nodes||[],a=[];for(let e=0,n=o.length;e<n;e++)a.push(ty(o[e],s,t,i));return Promise.all(a).then((function(){return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof lt||e instanceof U)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(s),s}))}}function ty(e,t,n,r){const i=n.nodes[e];return r.getDependency("node",e).then((function(e){if(void 0===i.skin)return e;let t;return r.getDependency("skin",i.skin).then((function(e){t=e;const n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(r.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const r=[],i=[];for(let e=0,s=n.length;e<s;e++){const s=n[e];if(s){r.push(s);const n=new Se;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),i.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new Ps(r,i),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const s=[];if(i.children){const t=i.children;for(let i=0,o=t.length;i<o;i++){const o=t[i];s.push(ty(o,e,n,r))}}return Promise.all(s)}))}function ny(e,t,n){const r=t.attributes,i=[];function s(t,r){return n.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const t in r){const n=Hv[t]||t.toLowerCase();n in e.attributes||i.push(s(r[t],n))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(r)}return Zv(e,t),function(e,t,n){const r=t.attributes,i=new J;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new q(t[0],t[1],t[2]),new q(s[0],s[1],s[2])),e.normalized){const t=$v(zv[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new q,t=new q;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],s=r.min,o=r.max;if(void 0!==s&&void 0!==o){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),r.normalized){const e=$v(zv[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const o=new me;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let r=!1,i=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),void 0!==n.COLOR_0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(e);const o=[],a=[],l=[];for(let c=0,h=t.length;c<h;c++){const h=t[c];if(r){const t=void 0!==h.POSITION?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(t)}if(i){const t=void 0!==h.NORMAL?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==h.COLOR_0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],o=t[1],a=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),s&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function ry(e,t){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(2===t)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(i),s}const iy=new WeakMap;class sy extends rl{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const i=new sl(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(r)}),n,r)}decodeDracoFile(e,t,n,r){const i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const n=t.attributeTypes[e];void 0!==n.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=n.name)}const n=JSON.stringify(t);if(iy.has(e)){const t=iy.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(i,s).then((n=>(r=n,new Promise(((n,s)=>{r._callbacks[i]={resolve:n,reject:s},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),iy.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Rt;e.index&&t.setIndex(new dt(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,s=r.array,o=r.itemSize;t.setAttribute(i,new dt(s,o))}return t}_loadLibrary(e,t){const n=new sl(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,r)=>{n.load(e,t,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=oy.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function oy(){let e,t;function n(e,t,n,r,i,s){const o=s.num_components(),a=n.num_points()*o,l=a*i.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),h=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,c,l,h);const u=new i(e.HEAPF32.buffer,h,a).slice();return e._free(h),{name:r,array:u,itemSize:o}}onmessage=function(r){const i=r.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=i.buffer,s=i.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(r),r.byteLength);try{const e=function(e,t,r,i){const s=i.attributeIDs,o=i.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(r,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(r,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const r in s){const l=self[o[r]];let c,u;if(i.useUniqueIDs)u=s[r],c=t.GetAttributeByUniqueId(a,u);else{if(u=t.GetAttributeId(a,e[s[r]]),-1===u)continue;c=t.GetAttribute(a,u)}h.attributes.push(n(e,t,a,r,l,c))}c===e.TRIANGULAR_MESH&&(h.index=function(e,t,n){const r=3*n.num_faces(),i=4*r,s=e._malloc(i);t.GetTrianglesUInt32Array(n,i,s);const o=new Uint32Array(e.HEAPF32.buffer,s,r).slice();return e._free(s),{array:o,itemSize:1}}(e,t,a));return e.destroy(a),h}(t,o,a,s),r=e.attributes.map((e=>e.array.buffer));e.index&&r.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},r)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(a),t.destroy(o)}}))}}}class ay extends nf{constructor(e){super("Model",e),this.viewport=e,this.gltfLoader=null,this.fbxLoader=null,this.modelMaps=new Map,this.store=of.createInstance({name:"soonspace",storeName:"modelData"}),this.dracoDecoderPath=null}setDracoDecoderPath(e){this.dracoDecoderPath=e}load(e){return this._loadItem(e)}parse(e,t,n){return new Promise(((r,i)=>{const s=new Fp(Object.assign({format:e},n)),o=new tl;o.addHandler(/\.tga$/i,new rv);const{url:a}=n,l=e.toLocaleUpperCase(),c=a.substring(0,a.lastIndexOf("/")+1);if("GLTF"===l||"GLB"===l||"SBMX"===l){if(this.gltfLoader||(this.gltfLoader=new iv(o)),this.dracoDecoderPath&&!this.gltfLoader.dracoLoader){const e=new sy;e.setDecoderPath(this.dracoDecoderPath),this.gltfLoader.setDRACOLoader(e)}this.gltfLoader.parse(t,c,(e=>{const{animations:t}=e;if(t&&t.length>0&&(s.animations=t),e.scene.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0})),s.add(e.scene),!this.modelMaps.get(a)){const e=s.sClone();this.modelMaps.set(a,e)}r(s)}),(e=>{i(e)}))}else if("FBX"===l){this.fbxLoader||(this.fbxLoader=new Ug(o));const e=this.fbxLoader.parse(t,c),{animations:n}=e;if(n&&n.length>0&&(s.animations=n),e.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0})),s.add(e),!this.modelMaps.get(a)){const e=s.sClone();this.modelMaps.set(a,e)}r(s)}else i(`In soonspacejs: 加载通用模型资源(id:${n.id}, url:${a})格式错误,当前支持 fbx、gltf、glb !`)}))}clone(e,t,n){return new Promise(((r,i)=>sd(this,void 0,void 0,(function*(){"Model"!==e.stype&&i("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:s,name:o,level:a,visible:l,position:c,rotation:h,scale:u,onClick:d,onDblClick:p,onRightClick:f,onLoad:m,userData:g}=t;function v(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)v(e.children[r],t.children[r],n)}const y=yield function(e){const t=new Map,n=new Map;let r;return r=e instanceof Iu||e instanceof Lu?e.sClone():e.clone(),v(e,r,(function(e,r){t.set(r,e),n.set(e,r)})),r.traverse((function(e){if(e instanceof Ss){const r=e,i=t.get(e),s=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=s.map((function(e){return n.get(e)})),r.bind(r.skeleton,r.bindMatrix)}})),r}(e);y.animations=yield y.animations.map((e=>e.clone())),yield this._copyMaterial(y),s&&(y.sid=s),o&&(y.name=o),a&&(y.level=a),!1===l&&y.hide(),c&&y.position.set(c.x,c.y,c.z),h&&y.rotation.set(h.x,h.y,h.z),u&&y.scale.set(u.x,u.y,u.z),y.onClick=d?d.bind(y):null,y.onDblClick=p?p.bind(y):null,y.onRightClick=f?f.bind(y):null,y.onLoad=m?m.bind(y):null,y.onLoad&&y.onLoad(y),g&&(y.userData=g),null!==n&&this.viewport.scener.addObject(y,n||e.parent||this.scene),r(y)}))))}loadToGroup(e,t){return sd(this,void 0,void 0,(function*(){const n=new Ou(e);for(let e=0;e<t.length;e++)try{const r=yield this._loadItem(t[e],null);n.add(r)}catch(e){console.error(e)}return this.viewport.scener.addObject(n,this.scene),n}))}addForGroup(e,t){return sd(this,void 0,void 0,(function*(){const n=this.getGroupById(e);if(n)for(let e=0;e<t.length;e++)try{const r=yield this._loadItem(t[e],null);this.viewport.scener.addObject(r,n)}catch(e){console.error(e)}return n}))}clearIdb(){return this.store.clear()}_loadItem(e,t=this.scene){var n;return sd(this,void 0,void 0,(function*(){const{url:r}=e,{useIndexedDB:i}=this.viewport.options,s=r.slice(r.lastIndexOf(".")+1),o=this.modelMaps.get(r);let a=null;if(o)return this.clone(o,e,t);i&&(a=yield this.store.getItem(r)),a||(a=yield this._fetchBuffer(e));const l=yield this.parse(s,a,e);return null===(n=l.onLoad)||void 0===n||n.call(l,l),null!==t&&this.viewport.scener.addObject(l,t||this.scene),l}))}_fetchBuffer(e){const{url:t}=e,{useIndexedDB:n}=this.viewport.options;return fetch(t).then((e=>e.arrayBuffer())).then((e=>(n&&(nu(t)&&(e=ru(e)),this.store.setItem(t,e)),e)))}_copyMaterial(e){e.traverse((e=>{e instanceof Yt&&(lu(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof lt&&(e.material=e.material.clone()))}))}}class ly extends nf{constructor(e){super("Poi",e),this.materials=new Map}create(e){const t=this._createMaterial(e.url),n=new jp(t,e);return this.viewport.scener.addObject(n,this.scene),n}clone(e,t,n){"Poi"!==e.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:r,name:i,level:s,visible:o,position:a,rotation:l,scale:c,onClick:h,onDblClick:u,onRightClick:d,userData:p}=t,f=e.sClone();return this._copyMaterial(f),r&&(f.sid=r),i&&(f.name=i),s&&(f.level=s),ou(o)&&(f.visible=o),a&&f.position.set(a.x,a.y,a.z),l&&f.rotation.set(l.x,l.y,l.z),c&&f.scale.set(c.x,c.y,c.z),f.onClick=h?h.bind(f):null,f.onDblClick=u?u.bind(f):null,f.onRightClick=d?d.bind(f):null,p&&(f.userData=p),null!==n&&this.viewport.scener.addObject(f,n||this.scene||e.parent),f}createToGroup(e,t){const n=new Ou(e);return t.forEach((e=>{const t=this._createMaterial(e.url),r=new jp(t,e);n.add(r)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getGroupById(e);return n&&(t.forEach((e=>{const t=this._createMaterial(e.url),r=new jp(t,e);n.add(r)})),this.viewport.scener.addObject(n,this.scene)),n}_createMaterial(e){const t=this.materials.get(e);if(!t){const t=(new cl).load(e);t.flipY=!0;const n=new es({map:t,color:16777215});return this.materials.set(e,n),n}return t}_copyMaterial(e){e.traverse((e=>{(e instanceof Yt||e instanceof fs)&&(lu(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof lt&&(e.material=e.material.clone()))}))}}class cy extends nf{constructor(e){super("PoiNode",e)}create(e){this._openEnableRenderCss(e);const t=new id(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=new Ou(e);return t.forEach((e=>{this._openEnableRenderCss(e);const t=new id(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getGroupById(e);return n&&(t.forEach((e=>{const t=new id(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene)),n}_openEnableRenderCss(e){switch(e.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class hy extends nf{constructor(e){super("Canvas3D",e)}create(e){const t=new $p(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=new Ou(e);return t.forEach((e=>{const t=new $p(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getGroupById(e);return n&&(t.forEach((e=>{const t=new $p(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene)),n}}class uy{constructor(){this.graph=[],this.queue=null,this.distance=[],this.previous=[]}setGraph(e){if(!lu(e))return console.error("In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph isn't an array )");if(!(e.length<1))for(let t=0;t<e.length;t++){const n=e[t];if(2!==n.length)return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph item must be an array and contain 2 values [name, vertices], Failed at index: ${t} )`);const r=n[0],i=n[1];this.graph[r]=[];for(let e=0;e<i.length;e++){const t=i[e],n=t[0],s=t[1];this.graph[r][n]=s}}}getPath(e,t){if(void 0===this.graph[e])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method source ${e} doesn't exist )`),[];if(void 0===this.graph[t])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method target ${t} doesn't exist )`),[];if(e===t)return[];let n;for(this.queue=new eu,this.queue.add(e,0),this.previous[e]=null;n=this.queue.shift();){if(n===t){const e=[];for(;au(n)&&null!==this.previous[n];)e.unshift(n),n=this.previous[n];return e}const e=this.queue.getDistance(n);if(e===1/0)return[];for(const t in this.graph[n]){const r=this.queue.getDistance(Number(t)),i=e+this.graph[n][t];i<r&&(this.queue.update(Number(t),i),this.previous[t]=n)}}return[]}}class dy extends nf{constructor(e){super("Topology",e),this.dijkstra=new uy}createFromGml(e){const{url:t,linkWidth:n=20,linkColor:r=65280,renderNode:i=!0,nodeColor:s=255}=e;return pf(t).then((t=>{if(!t||!t.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const o=[],a=new Map;let l=[],c=[];const h=t.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;lu(h)?h.forEach((e=>{l=[...l,...e.state],c=[...c,...e.transition]})):(l=[...l,...h.state],c=[...c,...h.transition]),l.forEach(((e,t)=>{const n=e.State._attributes["gml:id"],r=e.State.topoNode["gml:Node"].node_name;o.push({id:su(n)?n:"",name:su(r)?r:"",position:{x:Number(e.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(e.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(e.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),a.set(n,t)})),c.forEach((e=>{const t=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],r=e.Transition.topoEdge["gml:Edge"].length["#text"],i=e.Transition.topoEdge["gml:Edge"].restrict["#text"],s=e.Transition.topoEdge["gml:Edge"].passable["#text"],l=a.get(t),c=a.get(n),h=e.Transition._attributes["gml:id"],u=e.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==l&&void 0!==c&&("2"!==s&&"3"!==s&&o[l].graphs.push({targetNodeId:n,linkInfo:{id:h,name:u},enable:!0,length:parseInt(r),restrict:parseInt(i),passable:parseInt(s)}),"1"!==s&&"3"!==s&&o[c].graphs.push({targetNodeId:t,linkInfo:{id:h,name:u},enable:!0,length:parseInt(r),restrict:parseInt(i),passable:parseInt(s)}))})),this.setDijkstraGraph(o);const u=new Yp(Object.assign(Object.assign({},e),{type:"network",nodes:o,linkWidth:n,renderLink:!0,linkColor:r,renderNode:i,nodeColor:s}));return this.viewport.scener.addObject(u,this.scene),Promise.resolve(u)}))}create(e){const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const n=new Yp(t);return this.viewport.scener.addObject(n,this.scene),n}resetNodes(e,t){const n=this.generateLineTopologyInfoNodeGraphs(Object.assign(Object.assign({},e.info),{nodes:t}));return e.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),e}createToGroup(e,t){const n=new Ou(e);return t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const r=new Yp(t);n.add(r)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getGroupById(e);return n&&t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const r=new Yp(t);n.add(r)})),n}getShortestPath(e,t){const{nodes:n}=e.info,r=Xh(t.start),i=Xh(t.end);let s=null,o=1/0,a=null,l=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Xh(e.position),n=t.distanceTo(r),c=t.distanceTo(i);n<o&&(o=n,s=Number(e.id)),c<l&&(l=c,a=Number(e.id))}})),s&&a){const o=this.dijkstra.getPath(s,a);if(o.length>0){const s=[{id:"startPoint",position:r,graphs:[]}];o.forEach((e=>{const t=n.find((t=>t.id==e));t&&s.push(t)})),s.push({id:"endPoint",position:i,graphs:[]});for(let e=0;e<s.length;e++)s[e].position.y+=1;const a=Object.assign(Object.assign(Object.assign({},t),{type:"line",nodes:s}),e.getSpaceAttribute(!0));this.generateLineTopologyInfoNodeGraphs(a);const l=new Yp(a);return this.viewport.scener.addObject(l,this.scene),l}}return null}getShortestPathByMultipleStartPoints(e,t){const{nodes:n}=e.info,r=[];t.start.forEach((e=>{const i=Xh(e),s=Xh(t.end);let o=null,a=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Xh(e.position),n=t.distanceTo(i),r=t.distanceTo(s);n<a&&(a=n,o=Number(e.id)),r<c&&(c=r,l=Number(e.id))}})),o&&l){let e=0;const t=this.dijkstra.getPath(o,l);if(t.length>0){const o=[{id:"startPoint",position:i,graphs:[]}];t.forEach(((t,r)=>{const s=n.find((e=>e.id==t));s&&(e+=0===r?Xh(s.position).distanceTo(i):Xh(s.position).distanceTo(Xh(o[o.length-1].position)),o.push(s))})),o.push({id:"endPoint",position:s,graphs:[]}),e+=s.distanceTo(Xh(o[o.length-1].position)),r.push({nodeInfo:o,pathLength:e})}}}));let i=[],s=1/0;if(r.forEach((({nodeInfo:e,pathLength:t})=>{t<s&&(s=t,i=e)})),i.length){for(let e=0;e<i.length;e++)i[e].position.y+=1;const n=Object.assign(Object.assign({},t),{type:"line",nodes:i,position:e.getWorldPosition(new q),rotation:(new Oe).setFromQuaternion(e.getWorldQuaternion(new X)),scale:e.getWorldScale(new q)});this.generateLineTopologyInfoNodeGraphs(n);const r=new Yp(n);return this.viewport.scener.addObject(r,this.scene),r}return null}getShortestPathByMultipleEndPoints(e,t){const{nodes:n}=e.info,r=[];t.end.forEach((e=>{const i=Xh(t.start),s=Xh(e);let o=null,a=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Xh(e.position),n=t.distanceTo(i),r=t.distanceTo(s);n<a&&(a=n,o=Number(e.id)),r<c&&(c=r,l=Number(e.id))}})),o&&l){let e=0;const t=this.dijkstra.getPath(o,l);if(t.length>0){const o=[{id:"startPoint",position:i,graphs:[]}];t.forEach(((t,r)=>{const s=n.find((e=>e.id==t));s&&(e+=0===r?Xh(s.position).distanceTo(i):Xh(s.position).distanceTo(Xh(o[o.length-1].position)),o.push(s))})),o.push({id:"endPoint",position:s,graphs:[]}),e+=s.distanceTo(Xh(o[o.length-1].position)),r.push({nodeInfo:o,pathLength:e})}}}));let i=[],s=1/0;if(r.forEach((({nodeInfo:e,pathLength:t})=>{t<s&&(s=t,i=e)})),i.length){for(let e=0;e<i.length;e++)i[e].position.y+=1;const n=Object.assign(Object.assign({},t),{type:"line",nodes:i,position:e.getWorldPosition(new q),rotation:(new Oe).setFromQuaternion(e.getWorldQuaternion(new X)),scale:e.getWorldScale(new q)});this.generateLineTopologyInfoNodeGraphs(n);const r=new Yp(n);return this.viewport.scener.addObject(r,this.scene),r}return null}setDijkstraGraph(e){const t=[];e.forEach((n=>{if(n.graphs&&n.graphs.length>0){const r=[];n.graphs.forEach((t=>{const i=e.find((e=>e.id===t.targetNodeId));i&&r.push([Number(t.targetNodeId),t.length||Xh(n.position).distanceTo(Xh(i.position))])})),t.push([Number(n.id),r])}})),t.length>0&&this.dijkstra.setGraph(t)}generateLineTopologyInfoNodeGraphs(e){if("line"===e.type)for(let t=0;t<e.nodes.length;t++)if(t===e.nodes.length-1)e.nodes[t].graphs=[];else{const n=e.nodes[t],r=e.nodes[t+1];e.nodes[t].graphs=[{targetNodeId:r.id.toString(),linkInfo:{id:`${n.id}_to_${r.id}`,name:`${n.name||n.id}_to_${r.name||r.id}`},enable:!0,length:Xh(e.nodes[t].position).distanceTo(Xh(r.position)),restrict:0,passable:0}]}return e}}class py extends Gs{constructor(e,t){const n=new Rt;n.setAttribute("position",new bt([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere();super(n,new Ns({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=new Rt;r.setAttribute("position",new bt([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Yt(r,new ct({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class fy extends nf{constructor(e){super("Helper",e)}addGridHelper(e){const{id:t,size:n=1e3,divisions:r=20,color:i="#fff",position:s={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:a={x:1,y:1,z:1}}=e,l=new kc(n,r,i,i);return l.position.set(s.x,s.y,s.z),l.rotation.set(o.x,o.y,o.z),l.scale.set(a.x,a.y,a.z),l.userData.sid=t,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(e){const{id:t,axesLength:n=1e3}=e,r=new $c(n);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addBoxHelper(e){const{id:t,box:n,color:r="#00ff00"}=e,i=new Zc(n,new I(r));return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addPlaneHelper(e){const{id:t,width:n=500,height:r=500,color:i="#00ff00",opacity:s=.2,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=e,c=new Lu(new gn(n,r),new ct({color:i,opacity:s,transparent:s<1,side:2}),{id:t,position:o,rotation:a,scale:l});return c.userData.sid=t,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(e){const{imgUrl:t,id:n,width:r=500,height:i=500,opacity:s=1,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=e,h=(new cl).load(t),u=new gn(r,i);u.computeBoundingBox();const d=new Ra({side:2,map:h,transparent:s<1,opacity:s,roughness:.8});d.map&&(d.map.repeat.set(c.x,c.x),d.map.wrapS=1e3,d.map.wrapT=1e3,d.map.version++),a.x-=Math.PI/2,d.version++;const p=new ef(u,d,{id:n,position:o,rotation:a,scale:l});return p.userData.sid=n,p.userData.stype="Helper",this.viewport.scener.addObject(p,this.scene),p}addDirectionalLightHelper(e){const{id:t,light:n,color:r,size:i=50}=e,s=new jc(n,i,r);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addHemisphereLightHelper(e){const{id:t,light:n,color:r,size:i=20}=e,s=new Uc(n,i,r);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addSpotLightHelper(e){const{id:t,light:n,color:r}=e,i=new Cc(n,r);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addPointLightHelper(e){const{id:t,light:n,color:r,size:i=20}=e,s=new Oc(n,i,r);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addRectAreaLightHelper(e){const{id:t,light:n,color:r}=e,i=new py(n,r);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}}class my extends nf{constructor(e){super("PluginObject",e)}createObject(e,t){const n=new Bu(e);return t&&n.add(t),this.viewport.scener.addObject(n,this.scene),n}addToObject(e,t){const n=this.getById(e);return n?(this.viewport.scener.addObject(t,n),n):null}}class gy{constructor(e){this.viewport=e,this.needUpdate=!1,this.store={LightManager:new rf(e),sbmManager:new mf(e),modelManager:new ay(e),poiManager:new ly(e),poiNodeManager:new cy(e),canvas3DManager:new hy(e),topologyManager:new dy(e),helperManager:new fy(e),pluginObjectManager:new my(e)},this.postUpdate=new Map;for(const e in this.store)this.postUpdate.set(e,this.store[e].update.bind(this.store[e]));e.postUpdate.set("ManagerRender",this.update.bind(this))}update(){const e=performance.now();this.postUpdate.forEach((e=>e())),this.viewport.signals.loadRendered.dispatch(performance.now()-e)}clearObject(){this.store.sbmManager.clear(),this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.LightManager.clear()}}self.THREE=hh;class vy{constructor(e){this.THREE=hh,this.version=t,this.animation=Ru,this.library=tf,this.utils=pu,this.plugins={};const{el:n,options:r={},events:i={}}=e;if(this.domElement=document.querySelector(n),this.options=Object.assign(Object.assign({},{showInfo:!1,showStats:!1,showGrid:!1,background:{color:11459572,alpha:!1},fog:!1,controls:{},hoverEnabled:!1,closeInfoLog:!1,closeWarnLog:!0,useIndexedDB:!0,logarithmicDepthBuffer:!0}),r),this.viewport=new Np(this.options),this.signals=this.viewport.signals,this.manager=new gy(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(i),this._initDefaultLight()}_init(){const{showGrid:t,background:n,fog:r,controls:i,closeInfoLog:s,closeWarnLog:o,useIndexedDB:a}=this.options;if(!s){Wh(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),Wh(e,{color:"#3eaf7c","font-size":"24px"}),Wh(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),Wh("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),Wh("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),Wh("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}t&&this.addGridHelper(!0===t?{id:"defaultGridHelper"}:t),(null==n?void 0:n.skyBox)?su(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):cu(null==n?void 0:n.skyBox)&&this.setSkyBackground(n.skyBox.dirPath,n.skyBox.fileNames):(null==n?void 0:n.img)?this.setBackgroundImage(n.img):(null==n?void 0:n.color)&&this.setBackgroundColor(n.color),r&&this.openSceneFog(!0===r?void 0:r),i&&this.setControlsOptions(i),o&&(window.console.warn=function(){}),a&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(e){const{modelHover:t,modelUnHover:n,modelClick:r,modelRightClick:i,modelDblClick:s,poiHover:o,poiUnHover:a,poiClick:l,poiRightClick:c,poiDblClick:h,selectPosition:u,sceneClick:d,resize:p}=e;t&&this.signals.modelHover.add(t),n&&this.signals.modelUnHover.add(n),r&&this.signals.modelClick.add(r),i&&this.signals.modelRightClick.add(i),s&&this.signals.modelDblClick.add(s),o&&this.signals.poiHover.add(o),a&&this.signals.poiUnHover.add(a),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),h&&this.signals.poiDblClick.add(h),u&&this.signals.selectPosition.add(u),d&&this.signals.sceneClick.add(d),p&&this.signals.windowResize.add(p),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultLight(){this.createAmbientLight({id:"defaultAmbientLight",name:"defaultAmbientLight"}),this.createDirectionalLight({id:"defaultDirectionalLight",name:"defaultDirectionalLight"}),this.createHemisphereLight({id:"defaultHemisphereLight",name:"defaulHemisphereLight",intensity:.1})}registerPlugin(e,t){const n=new e(this);return this.plugins[t]=n,n}getPlugin(e){return this.plugins[e]?this.plugins[e]:null}createPluginObject(e,t){return this.manager.store.pluginObjectManager.createObject(e,t)}addToPluginObject(e,t){return this.manager.store.pluginObjectManager.addToObject(e,t)}getPluginObjectById(e){return this.manager.store.pluginObjectManager.getById(e)}getPluginObjectByName(e){return this.manager.store.pluginObjectManager.getByName(e)}removePluginObjectById(e){return this.manager.store.pluginObjectManager.removeById(e)}setSobel(e){this.viewport.setSobel(e)}setBloom(e){this.viewport.setBloom(e)}setColorSpace(e){this.viewport.setColorSpace(e)}setHoverEnabled(e){this.viewport.setHoverEnabled(e)}setBackgroundColor(e){this.viewport.setBackgroundColor(e)}setBackgroundImage(e){this.viewport.setBackgroundImage(e)}setSphereSkyBackground(e){this.viewport.setSphereSkyBackground(e)}setSkyBackground(e,t){this.viewport.setSkyBackground(e,t)}setEnvironment(){return this.viewport.setEnvironment()}playModelAnimation(e,t){return this.viewport.playModelAnimation(e,t)}stopModelAnimation(e,t){this.viewport.stopModelAnimation(e,t)}getOffsetByPosition(e){return this.viewport.getOffsetByPosition(e)}getPositionByOffset(e,t){return this.viewport.getPositionByOffset(e,t)}render(e){return this.viewport.render(e)}clearSignals(){this.viewport.clearSignals()}dispose(){return this.clear(),this.clearSignals(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(e){this.viewport.cameraManager.setCameraViewpoint(e)}flyTo(e,t="frontTop",n){return this.viewport.cameraManager.flyTo(e,t,n)}flyToBoundingBox(e,t="frontTop",n){return this.viewport.cameraManager.flyToBoundingBox(e,t,n)}flyToObj(e,t="frontTop",n){return this.viewport.cameraManager.flyToObj(e,t,n)}flyMainViewpoint(e="frontTop",t){return this.flyToObj(this.viewport.scene,e,t)}surroundOnTarget(e,t){return this.viewport.cameraManager.surroundOnTarget(e,t)}surroundOnObject(e,t){return this.viewport.cameraManager.surroundOnObject(e,t)}getObjectLabelPos(e,t="frontTop",n){return this.viewport.cameraManager.getObjectLabelPos(e,t,n)}setControlsOptions(e){return this.viewport.controls.setOptions(e)}addObject(e,t){this.viewport.scener.addObject(e,t)}removeObject(e){this.viewport.scener.removeObject(e)}openSceneFog(e){this.viewport.scener.openSceneFog(e)}closeSceneFog(){this.viewport.scener.closeSceneFog()}setSky(e){return this.viewport.setSky(e)}edgeShow(e,t){return this.viewport.scener.edgeShow(e,t)}unEdgeShow(e){return this.viewport.scener.unEdgeShow(e)}strokeShow(e,t){return this.viewport.scener.strokeShow(e,t)}unStrokeShow(e){return this.viewport.scener.unStrokeShow(e)}opacityShow(e,t){return this.viewport.scener.opacityShow(e,t)}unOpacityShow(e){return this.viewport.scener.unOpacityShow(e)}highlightShow(e,t){return this.viewport.scener.highlightShow(e,t)}unHighlightShow(e){return this.viewport.scener.unHighlightShow(e)}emissiveShow(e,t){return this.viewport.scener.emissiveShow(e,t)}unEmissiveShow(e){return this.viewport.scener.unEmissiveShow(e)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(e){return this.manager.store.LightManager.createAmbientLight(e)}setAmbientLight(e){return this.manager.store.LightManager.setAmbientLight(e)}createDirectionalLight(e){return this.manager.store.LightManager.createDirectionalLight(e)}setDirectionalLight(e){return this.manager.store.LightManager.setDirectionalLight(e)}createHemisphereLight(e){return this.manager.store.LightManager.createHemisphereLight(e)}setHemisphereLight(e){return this.manager.store.LightManager.setHemisphereLight(e)}createSpotLight(e){return this.manager.store.LightManager.createSpotLight(e)}setSpotLight(e){return this.manager.store.LightManager.setSpotLight(e)}createPointLight(e){return this.manager.store.LightManager.createPointLight(e)}setPointLight(e){return this.manager.store.LightManager.setPointLight(e)}createRectAreaLight(e){return this.manager.store.LightManager.createRectAreaLight(e)}setRectAreaLight(e){return this.manager.store.LightManager.setRectAreaLight(e)}getLightById(e){return this.manager.store.LightManager.getById(e)}removeLightById(e){return this.manager.store.LightManager.removeById(e)}getAllLight(){return this.manager.store.LightManager.getAll()}clearLight(){return this.manager.store.LightManager.clear()}showAllLight(){return this.manager.store.LightManager.showAll()}hideAllLight(){return this.manager.store.LightManager.hideAll()}updateAllShadow(){return this.manager.store.LightManager.updateAllShadow()}loadSbm(e,t){return this.manager.store.sbmManager.load(e,t)}parseSbm(e,t,n){return this.manager.store.sbmManager.parse(e,t,n)}cloneSbm(e,t,n){return this.manager.store.sbmManager.clone(e,t,n)}getSbmById(e){return this.manager.store.sbmManager.getById(e)}getSbmByName(e){return this.manager.store.sbmManager.getByName(e)}getSbmByUserDataProperty(e,t){return this.manager.store.sbmManager.getByUserDataProperty(e,t)}removeSbmById(e){return this.manager.store.sbmManager.removeById(e)}createGroupForSbm(e){return this.manager.store.sbmManager.createGroup(e)}loadSbmToGroup(e,t,n){return this.manager.store.sbmManager.loadToGroup(e,t,n)}addSbmForGroup(e,t,n){return this.manager.store.sbmManager.addForGroup(e,t,n)}createSbmGroupFromXml(e,t){return this.manager.store.sbmManager.createGroupFromXml(e,t)}getSbmGroupById(e){return this.manager.store.sbmManager.getGroupById(e)}getSbmGroupByName(e){return this.manager.store.sbmManager.getGroupByName(e)}getAllSbmGroup(){return this.manager.store.sbmManager.getAllGroup()}removeSbmGroupById(e){return this.manager.store.sbmManager.removeGroupById(e)}clearSbm(){return this.manager.store.sbmManager.clear()}getAllSbm(){return this.manager.store.sbmManager.getAll()}showAllSbm(){return this.manager.store.sbmManager.showAll()}hideAllSbm(){return this.manager.store.sbmManager.hideAll()}getSbmModelMaps(){return this.manager.store.sbmManager.modelMaps}setSbmModelMaps(e){this.manager.store.sbmManager.modelMaps=e}clearIdb(){return Promise.all([this.manager.store.sbmManager.clearIdb(),this.manager.store.modelManager.clearIdb()])}setModelDracoDecoderPath(e){return this.manager.store.modelManager.setDracoDecoderPath(e)}loadModel(e){return this.manager.store.modelManager.load(e)}cloneModel(e,t,n){return this.manager.store.modelManager.clone(e,t,n)}getModelById(e){return this.manager.store.modelManager.getById(e)}getModelByName(e){return this.manager.store.modelManager.getByName(e)}getModelByUserDataProperty(e,t){return this.manager.store.modelManager.getByUserDataProperty(e,t)}removeModelById(e){return this.manager.store.modelManager.removeById(e)}createGroupForModel(e){return this.manager.store.modelManager.createGroup(e)}loadModelToGroup(e,t){return this.manager.store.modelManager.loadToGroup(e,t)}addModelForGroup(e,t){return this.manager.store.modelManager.addForGroup(e,t)}getModelGroupById(e){return this.manager.store.modelManager.getGroupById(e)}getModelGroupByName(e){return this.manager.store.modelManager.getGroupByName(e)}getAllModelGroup(){return this.manager.store.modelManager.getAllGroup()}removeModelGroupById(e){return this.manager.store.modelManager.removeGroupById(e)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}createPoi(e){return this.manager.store.poiManager.create(e)}clonePoi(e,t,n){return this.manager.store.poiManager.clone(e,t,n)}getPoiById(e){return this.manager.store.poiManager.getById(e)}getPoiByName(e){return this.manager.store.poiManager.getByName(e)}getPoiByUserDataProperty(e,t){return this.manager.store.poiManager.getByUserDataProperty(e,t)}removePoiById(e){return this.manager.store.poiManager.removeById(e)}createGroupForPoi(e){return this.manager.store.poiManager.createGroup(e)}createPoiToGroup(e,t){return this.manager.store.poiManager.createToGroup(e,t)}addPoiForGroup(e,t){return this.manager.store.poiManager.addForGroup(e,t)}getPoiGroupById(e){return this.manager.store.poiManager.getGroupById(e)}getPoiGroupByName(e){return this.manager.store.poiManager.getGroupByName(e)}getAllPoiGroup(){return this.manager.store.poiManager.getAllGroup()}removePoiGroupById(e){return this.manager.store.poiManager.removeGroupById(e)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(e){return this.manager.store.poiNodeManager.create(e)}getPoiNodeById(e){return this.manager.store.poiNodeManager.getById(e)}getPoiNodeByName(e){return this.manager.store.poiNodeManager.getByName(e)}getPoiNodeByUserDataProperty(e,t){return this.manager.store.poiNodeManager.getByUserDataProperty(e,t)}removePoiNodeById(e){return this.manager.store.poiNodeManager.removeById(e)}createGroupForPoiNode(e){return this.manager.store.poiNodeManager.createGroup(e)}createPoiNodeToGroup(e,t){return this.manager.store.poiNodeManager.createToGroup(e,t)}addPoiNodeForGroup(e,t){return this.manager.store.poiNodeManager.addForGroup(e,t)}getPoiNodeGroupById(e){return this.manager.store.poiNodeManager.getGroupById(e)}getPoiNodeGroupByName(e){return this.manager.store.poiNodeManager.getGroupByName(e)}getAllPoiNodeGroup(){return this.manager.store.poiNodeManager.getAllGroup()}removePoiNodeGroupById(e){return this.manager.store.poiNodeManager.removeGroupById(e)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createCanvas3D(e){return this.manager.store.canvas3DManager.create(e)}getCanvas3DById(e){return this.manager.store.canvas3DManager.getById(e)}getCanvas3DByName(e){return this.manager.store.canvas3DManager.getByName(e)}getCanvas3DByUserDataProperty(e,t){return this.manager.store.canvas3DManager.getByUserDataProperty(e,t)}removeCanvas3DById(e){return this.manager.store.canvas3DManager.removeById(e)}createGroupForCanvas3D(e){return this.manager.store.canvas3DManager.createGroup(e)}createCanvas3DToGroup(e,t){return this.manager.store.canvas3DManager.createToGroup(e,t)}addCanvas3DForGroup(e,t){return this.manager.store.canvas3DManager.addForGroup(e,t)}getCanvas3DGroupById(e){return this.manager.store.canvas3DManager.getGroupById(e)}getCanvas3DGroupByName(e){return this.manager.store.canvas3DManager.getGroupByName(e)}getAllCanvas3DGroup(){return this.manager.store.canvas3DManager.getAllGroup()}removeCanvas3DGroupById(e){return this.manager.store.canvas3DManager.removeGroupById(e)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(e,t){return this.manager.store.topologyManager.getShortestPath(e,t)}getShortestPathByMultipleStartPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(e,t)}getShortestPathByMultipleEndPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(e,t)}createTopologyFromGml(e){return this.manager.store.topologyManager.createFromGml(e)}createTopology(e){return this.manager.store.topologyManager.create(e)}resetTopologyNodes(e,t){return this.manager.store.topologyManager.resetNodes(e,t)}getTopologyById(e){return this.manager.store.topologyManager.getById(e)}getTopologyByName(e){return this.manager.store.topologyManager.getByName(e)}getTopologyByUserDataProperty(e,t){return this.manager.store.topologyManager.getByUserDataProperty(e,t)}removeTopologyById(e){return this.manager.store.topologyManager.removeById(e)}createGroupForTopology(e){return this.manager.store.topologyManager.createGroup(e)}createTopologyToGroup(e,t){return this.manager.store.topologyManager.createToGroup(e,t)}addTopologyForGroup(e,t){return this.manager.store.topologyManager.addForGroup(e,t)}getTopologyGroupById(e){return this.manager.store.topologyManager.getGroupById(e)}getTopologyGroupByName(e){return this.manager.store.topologyManager.getGroupByName(e)}getAllTopologyGroup(){return this.manager.store.topologyManager.getAllGroup()}removeTopologyGroupById(e){return this.manager.store.topologyManager.removeGroupById(e)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(e){return this.manager.store.helperManager.addGridHelper(e)}addAxesHelper(e){return this.manager.store.helperManager.addAxesHelper(e)}addBoxHelper(e){return this.manager.store.helperManager.addBoxHelper(e)}addPlaneHelper(e){return this.manager.store.helperManager.addPlaneHelper(e)}createGround(e){return console.warn("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(e)}addGroundHelper(e){return this.manager.store.helperManager.addGroundHelper(e)}addDirectionalLightHelper(e){return this.manager.store.helperManager.addDirectionalLightHelper(e)}addHemisphereLightHelper(e){return this.manager.store.helperManager.addHemisphereLightHelper(e)}addSpotLightHelper(e){return this.manager.store.helperManager.addSpotLightHelper(e)}addPointLightHelper(e){return this.manager.store.helperManager.addPointLightHelper(e)}addRectAreaLightHelper(e){return this.manager.store.helperManager.addRectAreaLightHelper(e)}getHelperById(e){return this.manager.store.helperManager.getById(e)}removeHelperById(e){return this.manager.store.helperManager.removeById(e)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}}vy.THREE=hh,vy.THREE_PLUGINS={TransformControls:wh,Lensflare:{Lensflare:jh,LensflareElement:Vh}};export default vy;
|
|
47
|
+
*/var gf={},vf=function(e){return URL.createObjectURL(new Blob([e],{type:"text/javascript"}))},yf=function(e){return new Worker(e)};try{URL.revokeObjectURL(vf(""))}catch(df){vf=function(e){return"data:application/javascript;charset=UTF-8,"+encodeURI(e)},yf=function(e){return new Worker(e,{type:"module"})}}var xf=Uint8Array,wf=Uint16Array,bf=Uint32Array,_f=new xf([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Mf=new xf([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Sf=new xf([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Tf=function(e,t){for(var n=new wf(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var i=new bf(n[30]);for(r=1;r<30;++r)for(var s=n[r];s<n[r+1];++s)i[s]=s-n[r]<<5|r;return[n,i]},Ef=Tf(_f,2),Af=Ef[0],Cf=Ef[1];Af[28]=258,Cf[258]=28;for(var Pf=Tf(Mf,0),Rf=Pf[0],Lf=Pf[1],If=new wf(32768),Df=0;Df<32768;++Df){var Of=(43690&Df)>>>1|(21845&Df)<<1;Of=(61680&(Of=(52428&Of)>>>2|(13107&Of)<<2))>>>4|(3855&Of)<<4,If[Df]=((65280&Of)>>>8|(255&Of)<<8)>>>1}var Bf=function(e,t,n){for(var r=e.length,i=0,s=new wf(t);i<r;++i)++s[e[i]-1];var o,a=new wf(t);for(i=0;i<t;++i)a[i]=a[i-1]+s[i-1]<<1;if(n){o=new wf(1<<t);var l=15-t;for(i=0;i<r;++i)if(e[i])for(var c=i<<4|e[i],h=t-e[i],u=a[e[i]-1]++<<h,d=u|(1<<h)-1;u<=d;++u)o[If[u]>>>l]=c}else for(o=new wf(r),i=0;i<r;++i)e[i]&&(o[i]=If[a[e[i]-1]++]>>>15-e[i]);return o},Nf=new xf(288);for(Df=0;Df<144;++Df)Nf[Df]=8;for(Df=144;Df<256;++Df)Nf[Df]=9;for(Df=256;Df<280;++Df)Nf[Df]=7;for(Df=280;Df<288;++Df)Nf[Df]=8;var zf=new xf(32);for(Df=0;Df<32;++Df)zf[Df]=5;var Uf=Bf(Nf,9,0),kf=Bf(Nf,9,1),Ff=Bf(zf,5,0),Hf=Bf(zf,5,1),Gf=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},jf=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},Vf=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Wf=function(e){return(e/8|0)+(7&e&&1)},Xf=function(e,t,n){(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length);var r=new(e instanceof wf?wf:e instanceof bf?bf:xf)(n-t);return r.set(e.subarray(t,n)),r},qf=function(e,t,n){var r=e.length;if(!r||n&&!n.l&&r<5)return t||new xf(0);var i=!t||n,s=!n||n.i;n||(n={}),t||(t=new xf(3*r));var o=function(e){var n=t.length;if(e>n){var r=new xf(Math.max(2*n,e));r.set(t),t=r}},a=n.f||0,l=n.p||0,c=n.b||0,h=n.l,u=n.d,d=n.m,p=n.n,f=8*r;do{if(!h){n.f=a=jf(e,l,1);var m=jf(e,l+1,3);if(l+=3,!m){var g=e[(A=Wf(l)+4)-4]|e[A-3]<<8,v=A+g;if(v>r){if(s)throw"unexpected EOF";break}i&&o(c+g),t.set(e.subarray(A,v),c),n.b=c+=g,n.p=l=8*v;continue}if(1==m)h=kf,u=Hf,d=9,p=5;else{if(2!=m)throw"invalid block type";var y=jf(e,l,31)+257,x=jf(e,l+10,15)+4,w=y+jf(e,l+5,31)+1;l+=14;for(var b=new xf(w),_=new xf(19),M=0;M<x;++M)_[Sf[M]]=jf(e,l+3*M,7);l+=3*x;var S=Gf(_),T=(1<<S)-1,E=Bf(_,S,1);for(M=0;M<w;){var A,C=E[jf(e,l,T)];if(l+=15&C,(A=C>>>4)<16)b[M++]=A;else{var P=0,R=0;for(16==A?(R=3+jf(e,l,3),l+=2,P=b[M-1]):17==A?(R=3+jf(e,l,7),l+=3):18==A&&(R=11+jf(e,l,127),l+=7);R--;)b[M++]=P}}var L=b.subarray(0,y),I=b.subarray(y);d=Gf(L),p=Gf(I),h=Bf(L,d,1),u=Bf(I,p,1)}if(l>f){if(s)throw"unexpected EOF";break}}i&&o(c+131072);for(var D=(1<<d)-1,O=(1<<p)-1,B=l;;B=l){var N=(P=h[Vf(e,l)&D])>>>4;if((l+=15&P)>f){if(s)throw"unexpected EOF";break}if(!P)throw"invalid length/literal";if(N<256)t[c++]=N;else{if(256==N){B=l,h=null;break}var z=N-254;if(N>264){var U=_f[M=N-257];z=jf(e,l,(1<<U)-1)+Af[M],l+=U}var k=u[Vf(e,l)&O],F=k>>>4;if(!k)throw"invalid distance";l+=15&k;I=Rf[F];if(F>3){U=Mf[F];I+=Vf(e,l)&(1<<U)-1,l+=U}if(l>f){if(s)throw"unexpected EOF";break}i&&o(c+131072);for(var H=c+z;c<H;c+=4)t[c]=t[c-I],t[c+1]=t[c+1-I],t[c+2]=t[c+2-I],t[c+3]=t[c+3-I];c=H}}n.l=h,n.p=B,n.b=c,h&&(a=1,n.m=d,n.d=u,n.n=p)}while(!a);return c==t.length?t:Xf(t,0,c)},Yf=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8},Zf=function(e,t,n){n<<=7&t;var r=t/8|0;e[r]|=n,e[r+1]|=n>>>8,e[r+2]|=n>>>16},Jf=function(e,t){for(var n=[],r=0;r<e.length;++r)e[r]&&n.push({s:r,f:e[r]});var i=n.length,s=n.slice();if(!i)return[rm,0];if(1==i){var o=new xf(n[0].s+1);return o[n[0].s]=1,[o,1]}n.sort((function(e,t){return e.f-t.f})),n.push({s:-1,f:25001});var a=n[0],l=n[1],c=0,h=1,u=2;for(n[0]={s:-1,f:a.f+l.f,l:a,r:l};h!=i-1;)a=n[n[c].f<n[u].f?c++:u++],l=n[c!=h&&n[c].f<n[u].f?c++:u++],n[h++]={s:-1,f:a.f+l.f,l:a,r:l};var d=s[0].s;for(r=1;r<i;++r)s[r].s>d&&(d=s[r].s);var p=new wf(d+1),f=Qf(n[h-1],p,0);if(f>t){r=0;var m=0,g=f-t,v=1<<g;for(s.sort((function(e,t){return p[t.s]-p[e.s]||e.f-t.f}));r<i;++r){var y=s[r].s;if(!(p[y]>t))break;m+=v-(1<<f-p[y]),p[y]=t}for(m>>>=g;m>0;){var x=s[r].s;p[x]<t?m-=1<<t-p[x]++-1:++r}for(;r>=0&&m;--r){var w=s[r].s;p[w]==t&&(--p[w],++m)}f=t}return[new xf(p),f]},Qf=function(e,t,n){return-1==e.s?Math.max(Qf(e.l,t,n+1),Qf(e.r,t,n+1)):t[e.s]=n},Kf=function(e){for(var t=e.length;t&&!e[--t];);for(var n=new wf(++t),r=0,i=e[0],s=1,o=function(e){n[r++]=e},a=1;a<=t;++a)if(e[a]==i&&a!=t)++s;else{if(!i&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(i),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(i);s=1,i=e[a]}return[n.subarray(0,r),t]},$f=function(e,t){for(var n=0,r=0;r<t.length;++r)n+=e[r]*t[r];return n},em=function(e,t,n){var r=n.length,i=Wf(t+2);e[i]=255&r,e[i+1]=r>>>8,e[i+2]=255^e[i],e[i+3]=255^e[i+1];for(var s=0;s<r;++s)e[i+s+4]=n[s];return 8*(i+4+r)},tm=function(e,t,n,r,i,s,o,a,l,c,h){Yf(t,h++,n),++i[256];for(var u=Jf(i,15),d=u[0],p=u[1],f=Jf(s,15),m=f[0],g=f[1],v=Kf(d),y=v[0],x=v[1],w=Kf(m),b=w[0],_=w[1],M=new wf(19),S=0;S<y.length;++S)M[31&y[S]]++;for(S=0;S<b.length;++S)M[31&b[S]]++;for(var T=Jf(M,7),E=T[0],A=T[1],C=19;C>4&&!E[Sf[C-1]];--C);var P,R,L,I,D=c+5<<3,O=$f(i,Nf)+$f(s,zf)+o,B=$f(i,d)+$f(s,m)+o+14+3*C+$f(M,E)+(2*M[16]+3*M[17]+7*M[18]);if(D<=O&&D<=B)return em(t,h,e.subarray(l,l+c));if(Yf(t,h,1+(B<O)),h+=2,B<O){P=Bf(d,p,0),R=d,L=Bf(m,g,0),I=m;var N=Bf(E,A,0);Yf(t,h,x-257),Yf(t,h+5,_-1),Yf(t,h+10,C-4),h+=14;for(S=0;S<C;++S)Yf(t,h+3*S,E[Sf[S]]);h+=3*C;for(var z=[y,b],U=0;U<2;++U){var k=z[U];for(S=0;S<k.length;++S){var F=31&k[S];Yf(t,h,N[F]),h+=E[F],F>15&&(Yf(t,h,k[S]>>>5&127),h+=k[S]>>>12)}}}else P=Uf,R=Nf,L=Ff,I=zf;for(S=0;S<a;++S)if(r[S]>255){F=r[S]>>>18&31;Zf(t,h,P[F+257]),h+=R[F+257],F>7&&(Yf(t,h,r[S]>>>23&31),h+=_f[F]);var H=31&r[S];Zf(t,h,L[H]),h+=I[H],H>3&&(Zf(t,h,r[S]>>>5&8191),h+=Mf[H])}else Zf(t,h,P[r[S]]),h+=R[r[S]];return Zf(t,h,P[256]),h+R[256]},nm=new bf([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),rm=new xf(0),im=function(e,t,n,r,i,s){var o=e.length,a=new xf(r+o+5*(1+Math.ceil(o/7e3))+i),l=a.subarray(r,a.length-i),c=0;if(!t||o<8)for(var h=0;h<=o;h+=65535){var u=h+65535;u<o?c=em(l,c,e.subarray(h,u)):(l[h]=s,c=em(l,c,e.subarray(h,o)))}else{for(var d=nm[t-1],p=d>>>13,f=8191&d,m=(1<<n)-1,g=new wf(32768),v=new wf(m+1),y=Math.ceil(n/3),x=2*y,w=function(t){return(e[t]^e[t+1]<<y^e[t+2]<<x)&m},b=new bf(25e3),_=new wf(288),M=new wf(32),S=0,T=0,E=(h=0,0),A=0,C=0;h<o;++h){var P=w(h),R=32767&h,L=v[P];if(g[R]=L,v[P]=R,A<=h){var I=o-h;if((S>7e3||E>24576)&&I>423){c=tm(e,l,0,b,_,M,T,E,C,h-C,c),E=S=T=0,C=h;for(var D=0;D<286;++D)_[D]=0;for(D=0;D<30;++D)M[D]=0}var O=2,B=0,N=f,z=R-L&32767;if(I>2&&P==w(h-z))for(var U=Math.min(p,I)-1,k=Math.min(32767,h),F=Math.min(258,I);z<=k&&--N&&R!=L;){if(e[h+O]==e[h+O-z]){for(var H=0;H<F&&e[h+H]==e[h+H-z];++H);if(H>O){if(O=H,B=z,H>U)break;var G=Math.min(z,H-2),j=0;for(D=0;D<G;++D){var V=h-z+D+32768&32767,W=V-g[V]+32768&32767;W>j&&(j=W,L=V)}}}z+=(R=L)-(L=g[R])+32768&32767}if(B){b[E++]=268435456|Cf[O]<<18|Lf[B];var X=31&Cf[O],q=31&Lf[B];T+=_f[X]+Mf[q],++_[257+X],++M[q],A=h+O,++S}else b[E++]=e[h],++_[e[h]]}}c=tm(e,l,s,b,_,M,T,E,C,h-C,c),!s&&7&c&&(c=em(l,c+1,rm))}return Xf(a,0,r+Wf(c)+i)},sm=function(){for(var e=new bf(256),t=0;t<256;++t){for(var n=t,r=9;--r;)n=(1&n&&3988292384)^n>>>1;e[t]=n}return e}(),om=function(){var e=-1;return{p:function(t){for(var n=e,r=0;r<t.length;++r)n=sm[255&n^t[r]]^n>>>8;e=n},d:function(){return~e}}},am=function(){var e=1,t=0;return{p:function(n){for(var r=e,i=t,s=n.length,o=0;o!=s;){for(var a=Math.min(o+2655,s);o<a;++o)i+=r+=n[o];r=(65535&r)+15*(r>>16),i=(65535&i)+15*(i>>16)}e=r,t=i},d:function(){return(255&(e%=65521))<<24|e>>>8<<16|(255&(t%=65521))<<8|t>>>8}}},lm=function(e,t,n,r,i){return im(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,n,r,!i)},cm=function(e,t){var n={};for(var r in e)n[r]=e[r];for(var r in t)n[r]=t[r];return n},hm=function(e,t,n){for(var r=e(),i=e.toString(),s=i.slice(i.indexOf("[")+1,i.lastIndexOf("]")).replace(/ /g,"").split(","),o=0;o<r.length;++o){var a=r[o],l=s[o];if("function"==typeof a){t+=";"+l+"=";var c=a.toString();if(a.prototype)if(-1!=c.indexOf("[native code]")){var h=c.indexOf(" ",8)+1;t+=c.slice(h,c.indexOf("(",h))}else for(var u in t+=c,a.prototype)t+=";"+l+".prototype."+u+"="+a.prototype[u].toString();else t+=c}else n[l]=a}return[t,n]},um=[],dm=function(e,t,n,r){var i;if(!um[n]){for(var s="",o={},a=e.length-1,l=0;l<a;++l)s=(i=hm(e[l],s,o))[0],o=i[1];um[n]=hm(e[a],s,o)}var c=cm({},um[n][1]);return function(e,t,n,r,i){var s=yf(gf[t]||(gf[t]=vf(e)));return s.onerror=function(e){return i(e.error,null)},s.onmessage=function(e){return i(null,e.data)},s.postMessage(n,r),s}(um[n][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",n,c,function(e){var t=[];for(var n in e)(e[n]instanceof xf||e[n]instanceof wf||e[n]instanceof bf)&&t.push((e[n]=new e[n].constructor(e[n])).buffer);return t}(c),r)},pm=function(){return[xf,wf,bf,_f,Mf,Sf,Af,Rf,kf,Hf,If,Bf,Gf,jf,Vf,Wf,Xf,qf,Gm,xm,wm]},fm=function(){return[xf,wf,bf,_f,Mf,Sf,Cf,Lf,Uf,Nf,Ff,zf,If,nm,rm,Bf,Yf,Zf,Jf,Qf,Kf,$f,em,tm,Wf,Xf,im,lm,Um,xm]},mm=function(){return[Cm,Lm,Am,om,sm]},gm=function(){return[Pm,Rm]},vm=function(){return[Im,Am,am]},ym=function(){return[Dm]},xm=function(e){return postMessage(e,[e.buffer])},wm=function(e){return e&&e.size&&new xf(e.size)},bm=function(e,t,n,r,i,s){var o=dm(n,r,i,(function(e,t){o.terminate(),s(e,t)}));return o.postMessage([e,t],t.consume?[e.buffer]:[]),function(){o.terminate()}},_m=function(e){return e.ondata=function(e,t){return postMessage([e,t],[e.buffer])},function(t){return e.push(t.data[0],t.data[1])}},Mm=function(e,t,n,r,i){var s,o=dm(e,r,i,(function(e,n){e?(o.terminate(),t.ondata.call(t,e)):(n[1]&&o.terminate(),t.ondata.call(t,e,n[0],n[1]))}));o.postMessage(n),t.push=function(e,n){if(s)throw"stream finished";if(!t.ondata)throw"no stream handler";o.postMessage([e,s=n],[e.buffer])},t.terminate=function(){o.terminate()}},Sm=function(e,t){return e[t]|e[t+1]<<8},Tm=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Em=function(e,t){return Tm(e,t)+4294967296*Tm(e,t+4)},Am=function(e,t,n){for(;n;++t)e[t]=n,n>>>=8},Cm=function(e,t){var n=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&Am(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),n){e[3]=8;for(var r=0;r<=n.length;++r)e[r+10]=n.charCodeAt(r)}},Pm=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],n=10;4&t&&(n+=e[10]|2+(e[11]<<8));for(var r=(t>>3&1)+(t>>4&1);r>0;r-=!e[n++]);return n+(2&t)},Rm=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},Lm=function(e){return 10+(e.filename&&e.filename.length+1||0)},Im=function(e,t){var n=t.level,r=0==n?0:n<6?1:9==n?3:2;e[0]=120,e[1]=r<<6|(r?32-2*r:1)},Dm=function(e){if(8!=(15&e[0])||e[0]>>>4>7||(e[0]<<8|e[1])%31)throw"invalid zlib data";if(32&e[1])throw"invalid zlib data: preset dictionaries not supported"};function Om(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var Bm=function(){function e(e,t){t||"function"!=typeof e||(t=e,e={}),this.ondata=t,this.o=e||{}}return e.prototype.p=function(e,t){this.ondata(lm(e,this.o,0,0,!t),t)},e.prototype.push=function(e,t){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";this.d=t,this.p(e,t||!1)},e}(),Nm=function(){return function(e,t){Mm([fm,function(){return[_m,Bm]}],this,Om.call(this,e,t),(function(e){var t=new Bm(e.data);onmessage=_m(t)}),6)}}();function zm(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[fm],(function(e){return xm(Um(e.data[0],e.data[1]))}),0,n)}function Um(e,t){return lm(e,t||{},0,0)}var km=function(){function e(e){this.s={},this.p=new xf(0),this.ondata=e}return e.prototype.e=function(e){if(this.d)throw"stream finished";if(!this.ondata)throw"no stream handler";var t=this.p.length,n=new xf(t+e.length);n.set(this.p),n.set(e,t),this.p=n},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,n=qf(this.p,this.o,this.s);this.ondata(Xf(n,t,this.s.b),this.d),this.o=Xf(n,this.s.b-32768),this.s.b=this.o.length,this.p=Xf(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),Fm=function(){return function(e){this.ondata=e,Mm([pm,function(){return[_m,km]}],this,0,(function(){var e=new km;onmessage=_m(e)}),7)}}();function Hm(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[pm],(function(e){return xm(Gm(e.data[0],wm(e.data[1])))}),1,n)}function Gm(e,t){return qf(e,t)}var jm=function(){function e(e,t){this.c=om(),this.l=0,this.v=1,Bm.call(this,e,t)}return e.prototype.push=function(e,t){Bm.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var n=lm(e,this.o,this.v&&Lm(this.o),t&&8,!t);this.v&&(Cm(n,this.o),this.v=0),t&&(Am(n,n.length-8,this.c.d()),Am(n,n.length-4,this.l)),this.ondata(n,t)},e}(),Vm=function(){return function(e,t){Mm([fm,mm,function(){return[_m,Bm,jm]}],this,Om.call(this,e,t),(function(e){var t=new jm(e.data);onmessage=_m(t)}),8)}}();function Wm(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[fm,mm,function(){return[Xm]}],(function(e){return xm(Xm(e.data[0],e.data[1]))}),2,n)}function Xm(e,t){t||(t={});var n=om(),r=e.length;n.p(e);var i=lm(e,t,Lm(t),8),s=i.length;return Cm(i,t),Am(i,s-8,n.d()),Am(i,s-4,r),i}var qm=function(){function e(e){this.v=1,km.call(this,e)}return e.prototype.push=function(e,t){if(km.prototype.e.call(this,e),this.v){var n=this.p.length>3?Pm(this.p):4;if(n>=this.p.length&&!t)return;this.p=this.p.subarray(n),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}km.prototype.c.call(this,t)},e}(),Ym=function(){return function(e){this.ondata=e,Mm([pm,gm,function(){return[_m,km,qm]}],this,0,(function(){var e=new qm;onmessage=_m(e)}),9)}}();function Zm(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[pm,gm,function(){return[Jm]}],(function(e){return xm(Jm(e.data[0]))}),3,n)}function Jm(e,t){return qf(e.subarray(Pm(e),-8),t||new xf(Rm(e)))}var Qm=function(){function e(e,t){this.c=am(),this.v=1,Bm.call(this,e,t)}return e.prototype.push=function(e,t){Bm.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var n=lm(e,this.o,this.v&&2,t&&4,!t);this.v&&(Im(n,this.o),this.v=0),t&&Am(n,n.length-4,this.c.d()),this.ondata(n,t)},e}(),Km=function(){return function(e,t){Mm([fm,vm,function(){return[_m,Bm,Qm]}],this,Om.call(this,e,t),(function(e){var t=new Qm(e.data);onmessage=_m(t)}),10)}}();function $m(e,t){t||(t={});var n=am();n.p(e);var r=lm(e,t,2,4);return Im(r,t),Am(r,r.length-4,n.d()),r}var eg=function(){function e(e){this.v=1,km.call(this,e)}return e.prototype.push=function(e,t){if(km.prototype.e.call(this,e),this.v){if(this.p.length<2&&!t)return;this.p=this.p.subarray(2),this.v=0}if(t){if(this.p.length<4)throw"invalid zlib stream";this.p=this.p.subarray(0,-4)}km.prototype.c.call(this,t)},e}(),tg=function(){return function(e){this.ondata=e,Mm([pm,ym,function(){return[_m,km,eg]}],this,0,(function(){var e=new eg;onmessage=_m(e)}),11)}}();function ng(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[pm,ym,function(){return[rg]}],(function(e){return xm(rg(e.data[0],wm(e.data[1])))}),5,n)}function rg(e,t){return qf((Dm(e),e.subarray(2,-4)),t)}var ig=function(){function e(e){this.G=qm,this.I=km,this.Z=eg,this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no stream handler";if(this.s)this.s.push(e,t);else{if(this.p&&this.p.length){var n=new xf(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var r=this,i=function(){r.ondata.apply(r,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(i):8!=(15&this.p[0])||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(i):new this.Z(i),this.s.push(this.p,t),this.p=null}}},e}(),sg=function(){function e(e){this.G=Ym,this.I=Fm,this.Z=tg,this.ondata=e}return e.prototype.push=function(e,t){ig.prototype.push.call(this,e,t)},e}();var og=function(e,t,n,r){for(var i in e){var s=e[i],o=t+i;s instanceof xf?n[o]=[s,r]:Array.isArray(s)?n[o]=[s[0],cm(r,s[1])]:og(s,o+"/",n,r)}},ag="undefined"!=typeof TextEncoder&&new TextEncoder,lg="undefined"!=typeof TextDecoder&&new TextDecoder,cg=0;try{lg.decode(rm,{stream:!0}),cg=1}catch(df){}var hg=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return[t,Xf(e,n-1)];i?3==i?(r=((15&r)<<18|(63&e[n++])<<12|(63&e[n++])<<6|63&e[n++])-65536,t+=String.fromCharCode(55296|r>>10,56320|1023&r)):t+=1&i?String.fromCharCode((31&r)<<6|63&e[n++]):String.fromCharCode((15&r)<<12|(63&e[n++])<<6|63&e[n++]):t+=String.fromCharCode(r)}},ug=function(){function e(e){this.ondata=e,cg?this.t=new TextDecoder:this.p=rm}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(t=!!t,this.t){if(this.ondata(this.t.decode(e,{stream:!0}),t),t){if(this.t.decode().length)throw"invalid utf-8 data";this.t=null}}else{if(!this.p)throw"stream finished";var n=new xf(this.p.length+e.length);n.set(this.p),n.set(e,this.p.length);var r=hg(n),i=r[0],s=r[1];if(t){if(s.length)throw"invalid utf-8 data";this.p=null}else this.p=s;this.ondata(i,t)}},e}(),dg=function(){function e(e){this.ondata=e}return e.prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(pg(e),this.d=t||!1)},e}();function pg(e,t){if(t){for(var n=new xf(e.length),r=0;r<e.length;++r)n[r]=e.charCodeAt(r);return n}if(ag)return ag.encode(e);var i=e.length,s=new xf(e.length+(e.length>>1)),o=0,a=function(e){s[o++]=e};for(r=0;r<i;++r){if(o+5>s.length){var l=new xf(o+8+(i-r<<1));l.set(s),s=l}var c=e.charCodeAt(r);c<128||t?a(c):c<2048?(a(192|c>>6),a(128|63&c)):c>55295&&c<57344?(a(240|(c=65536+(1047552&c)|1023&e.charCodeAt(++r))>>18),a(128|c>>12&63),a(128|c>>6&63),a(128|63&c)):(a(224|c>>12),a(128|c>>6&63),a(128|63&c))}return Xf(s,0,o)}function fg(e,t){if(t){for(var n="",r=0;r<e.length;r+=16384)n+=String.fromCharCode.apply(null,e.subarray(r,r+16384));return n}if(lg)return lg.decode(e);var i=hg(e),s=i[0];if(i[1].length)throw"invalid utf-8 data";return s}var mg=function(e){return 1==e?3:e<6?2:9==e?1:0},gg=function(e,t){return t+30+Sm(e,t+26)+Sm(e,t+28)},vg=function(e,t,n){var r=Sm(e,t+28),i=fg(e.subarray(t+46,t+46+r),!(2048&Sm(e,t+8))),s=t+46+r,o=Tm(e,t+20),a=n&&4294967295==o?yg(e,s):[o,Tm(e,t+24),Tm(e,t+42)],l=a[0],c=a[1],h=a[2];return[Sm(e,t+10),l,c,i,s+Sm(e,t+30)+Sm(e,t+32),h]},yg=function(e,t){for(;1!=Sm(e,t);t+=4+Sm(e,t+2));return[Em(e,t+12),Em(e,t+4),Em(e,t+20)]},xg=function(e){var t=0;if(e)for(var n in e){var r=e[n].length;if(r>65535)throw"extra field too long";t+=r+4}return t},wg=function(e,t,n,r,i,s,o,a){var l=r.length,c=n.extra,h=a&&a.length,u=xg(c);Am(e,t,null!=o?33639248:67324752),t+=4,null!=o&&(e[t++]=20,e[t++]=n.os),e[t]=20,t+=2,e[t++]=n.flag<<1|(null==s&&8),e[t++]=i&&8,e[t++]=255&n.compression,e[t++]=n.compression>>8;var d=new Date(null==n.mtime?Date.now():n.mtime),p=d.getFullYear()-1980;if(p<0||p>119)throw"date not in range 1980-2099";if(Am(e,t,p<<25|d.getMonth()+1<<21|d.getDate()<<16|d.getHours()<<11|d.getMinutes()<<5|d.getSeconds()>>>1),t+=4,null!=s&&(Am(e,t,n.crc),Am(e,t+4,s),Am(e,t+8,n.size)),Am(e,t+12,l),Am(e,t+14,u),t+=16,null!=o&&(Am(e,t,h),Am(e,t+6,n.attrs),Am(e,t+10,o),t+=14),e.set(r,t),t+=l,u)for(var f in c){var m=c[f],g=m.length;Am(e,t,+f),Am(e,t+2,g),e.set(m,t+4),t+=4+g}return h&&(e.set(a,t),t+=h),t},bg=function(e,t,n,r,i){Am(e,t,101010256),Am(e,t+8,n),Am(e,t+10,n),Am(e,t+12,r),Am(e,t+16,i)},_g=function(){function e(e){this.filename=e,this.c=om(),this.size=0,this.compression=0}return e.prototype.process=function(e,t){this.ondata(null,e,t)},e.prototype.push=function(e,t){if(!this.ondata)throw"no callback - add to ZIP archive before pushing";this.c.p(e),this.size+=e.length,t&&(this.crc=this.c.d()),this.process(e,t||!1)},e}(),Mg=function(){function e(e,t){var n=this;t||(t={}),_g.call(this,e),this.d=new Bm(t,(function(e,t){n.ondata(null,e,t)})),this.compression=8,this.flag=mg(t.level)}return e.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e.prototype.push=function(e,t){_g.prototype.push.call(this,e,t)},e}(),Sg=function(){function e(e,t){var n=this;t||(t={}),_g.call(this,e),this.d=new Nm(t,(function(e,t,r){n.ondata(e,t,r)})),this.compression=8,this.flag=mg(t.level),this.terminate=this.d.terminate}return e.prototype.process=function(e,t){this.d.push(e,t)},e.prototype.push=function(e,t){_g.prototype.push.call(this,e,t)},e}(),Tg=function(){function e(e){this.ondata=e,this.u=[],this.d=1}return e.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var n=pg(e.filename),r=n.length,i=e.comment,s=i&&pg(i),o=r!=e.filename.length||s&&i.length!=s.length,a=r+xg(e.extra)+30;if(r>65535)throw"filename too long";var l=new xf(a);wg(l,0,e,n,o);var c=[l],h=function(){for(var e=0,n=c;e<n.length;e++){var r=n[e];t.ondata(null,r,!1)}c=[]},u=this.d;this.d=0;var d=this.u.length,p=cm(e,{f:n,u:o,o:s,t:function(){e.terminate&&e.terminate()},r:function(){if(h(),u){var e=t.u[d+1];e?e.r():t.d=1}u=1}}),f=0;e.ondata=function(n,r,i){if(n)t.ondata(n,r,i),t.terminate();else if(f+=r.length,c.push(r),i){var s=new xf(16);Am(s,0,134695760),Am(s,4,e.crc),Am(s,8,f),Am(s,12,e.size),c.push(s),p.c=f,p.b=a+f+16,p.crc=e.crc,p.size=e.size,u&&p.r(),u=1}else u&&h()},this.u.push(p)},e.prototype.end=function(){var e=this;if(2&this.d){if(1&this.d)throw"stream finishing";throw"stream finished"}this.d?this.e():this.u.push({r:function(){1&e.d&&(e.u.splice(-1,1),e.e())},t:function(){}}),this.d=3},e.prototype.e=function(){for(var e=0,t=0,n=0,r=0,i=this.u;r<i.length;r++){n+=46+(l=i[r]).f.length+xg(l.extra)+(l.o?l.o.length:0)}for(var s=new xf(n+22),o=0,a=this.u;o<a.length;o++){var l=a[o];wg(s,e,l,l.f,l.u,l.c,t,l.o),e+=46+l.f.length+xg(l.extra)+(l.o?l.o.length:0),t+=l.b}bg(s,e,this.u.length,n,t),this.ondata(null,s,!0),this.d=2},e.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++){t[e].t()}this.d=2},e}();var Eg=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}(),Ag=function(){function e(){var e=this;this.i=new km((function(t,n){e.ondata(null,t,n)}))}return e.prototype.push=function(e,t){try{this.i.push(e,t)}catch(n){this.ondata(n,e,t)}},e.compression=8,e}(),Cg=function(){function e(e,t){var n=this;t<32e4?this.i=new km((function(e,t){n.ondata(null,e,t)})):(this.i=new Fm((function(e,t,r){n.ondata(e,t,r)})),this.terminate=this.i.terminate)}return e.prototype.push=function(e,t){this.i.terminate&&(e=Xf(e,0)),this.i.push(e,t)},e.compression=8,e}(),Pg=function(){function e(e){this.onfile=e,this.k=[],this.o={0:Eg},this.p=rm}return e.prototype.push=function(e,t){var n=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var r=Math.min(this.c,e.length),i=e.subarray(0,r);if(this.c-=r,this.d?this.d.push(i,!this.c):this.k[0].push(i),(e=e.subarray(r)).length)return this.push(e,t)}else{var s=0,o=0,a=void 0,l=void 0;this.p.length?e.length?((l=new xf(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var c=l.length,h=this.c,u=h&&this.d,d=function(){var e,t=Tm(l,o);if(67324752==t){s=1,a=o,p.d=null,p.c=0;var r=Sm(l,o+6),i=Sm(l,o+8),u=2048&r,d=8&r,f=Sm(l,o+26),m=Sm(l,o+28);if(c>o+30+f+m){var g=[];p.k.unshift(g),s=2;var v,y=Tm(l,o+18),x=Tm(l,o+22),w=fg(l.subarray(o+30,o+=30+f),!u);4294967295==y?(e=d?[-2]:yg(l,o),y=e[0],x=e[1]):d&&(y=-1),o+=m,p.c=y;var b={name:w,compression:i,start:function(){if(!b.ondata)throw"no callback";if(y){var e=n.o[i];if(!e)throw"unknown compression type "+i;(v=y<0?new e(w):new e(w,y,x)).ondata=function(e,t,n){b.ondata(e,t,n)};for(var t=0,r=g;t<r.length;t++){var s=r[t];v.push(s,!1)}n.k[0]==g&&n.c?n.d=v:v.push(rm,!0)}else b.ondata(null,rm,!0)},terminate:function(){v&&v.terminate&&v.terminate()}};y>=0&&(b.size=y,b.originalSize=x),p.onfile(b)}return"break"}if(h){if(134695760==t)return a=o+=12+(-2==h&&8),s=3,p.c=0,"break";if(33639248==t)return a=o-=4,s=3,p.c=0,"break"}},p=this;o<c-4;++o){if("break"===d())break}if(this.p=rm,h<0){var f=s?l.subarray(0,a-12-(-2==h&&8)-(134695760==Tm(l,a-16)&&4)):l.subarray(0,o);u?u.push(f,!!s):this.k[+(2==s)].push(f)}if(2&s)return this.push(l.subarray(o),t);this.p=l.subarray(o)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e.prototype.register=function(e){this.o[e.compression]=e},e}();var Rg=Object.freeze({__proto__:null,Deflate:Bm,AsyncDeflate:Nm,deflate:zm,deflateSync:Um,Inflate:km,AsyncInflate:Fm,inflate:Hm,inflateSync:Gm,Gzip:jm,AsyncGzip:Vm,gzip:Wm,gzipSync:Xm,Gunzip:qm,AsyncGunzip:Ym,gunzip:Zm,gunzipSync:Jm,Zlib:Qm,AsyncZlib:Km,zlib:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return bm(e,t,[fm,vm,function(){return[$m]}],(function(e){return xm($m(e.data[0],e.data[1]))}),4,n)},zlibSync:$m,Unzlib:eg,AsyncUnzlib:tg,unzlib:ng,unzlibSync:rg,compress:Wm,AsyncCompress:Vm,compressSync:Xm,Compress:jm,Decompress:ig,AsyncDecompress:sg,decompress:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";return 31==e[0]&&139==e[1]&&8==e[2]?Zm(e,t,n):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Hm(e,t,n):ng(e,t,n)},decompressSync:function(e,t){return 31==e[0]&&139==e[1]&&8==e[2]?Jm(e,t):8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31?Gm(e,t):rg(e,t)},DecodeUTF8:ug,EncodeUTF8:dg,strToU8:pg,strFromU8:fg,ZipPassThrough:_g,ZipDeflate:Mg,AsyncZipDeflate:Sg,Zip:Tg,zip:function(e,t,n){if(n||(n=t,t={}),"function"!=typeof n)throw"no callback";var r={};og(e,"",r,t);var i=Object.keys(r),s=i.length,o=0,a=0,l=s,c=new Array(s),h=[],u=function(){for(var e=0;e<h.length;++e)h[e]()},d=function(){var e=new xf(a+22),t=o,r=a-o;a=0;for(var i=0;i<l;++i){var s=c[i];try{var h=s.c.length;wg(e,a,s,s.f,s.u,h);var u=30+s.f.length+xg(s.extra),d=a+u;e.set(s.c,d),wg(e,o,s,s.f,s.u,h,a,s.m),o+=16+u+(s.m?s.m.length:0),a=d+h}catch(e){return n(e,null)}}bg(e,o,c.length,r,t),n(null,e)};s||d();for(var p=function(e){var t=i[e],l=r[t],p=l[0],f=l[1],m=om(),g=p.length;m.p(p);var v=pg(t),y=v.length,x=f.comment,w=x&&pg(x),b=w&&w.length,_=xg(f.extra),M=0==f.level?0:8,S=function(r,i){if(r)u(),n(r,null);else{var l=i.length;c[e]=cm(f,{size:g,crc:m.d(),c:i,f:v,m:w,u:y!=t.length||w&&x.length!=b,compression:M}),o+=30+y+_+l,a+=76+2*(y+_)+(b||0)+l,--s||d()}};if(y>65535&&S("filename too long",null),M)if(g<16e4)try{S(null,Um(p,f))}catch(e){S(e,null)}else h.push(zm(p,f,S));else S(null,p)},f=0;f<l;++f)p(f);return u},zipSync:function(e,t){t||(t={});var n={},r=[];og(e,"",n,t);var i=0,s=0;for(var o in n){var a=n[o],l=a[0],c=a[1],h=0==c.level?0:8,u=(M=pg(o)).length,d=c.comment,p=d&&pg(d),f=p&&p.length,m=xg(c.extra);if(u>65535)throw"filename too long";var g=h?Um(l,c):l,v=g.length,y=om();y.p(l),r.push(cm(c,{size:l.length,crc:y.d(),c:g,f:M,m:p,u:u!=o.length||p&&d.length!=f,o:i,compression:h})),i+=30+u+m+v,s+=76+2*(u+m)+(f||0)+v}for(var x=new xf(s+22),w=i,b=s-i,_=0;_<r.length;++_){var M=r[_];wg(x,M.o,M,M.f,M.u,M.c.length);var S=30+M.f.length+xg(M.extra);x.set(M.c,M.o+S),wg(x,i,M,M.f,M.u,M.c.length,M.o,M.m),i+=16+S+(M.m?M.m.length:0)}return bg(x,i,r.length,b,w),x},UnzipPassThrough:Eg,UnzipInflate:Ag,AsyncUnzipInflate:Cg,Unzip:Pg,unzip:function(e,t){if("function"!=typeof t)throw"no callback";for(var n=[],r=function(){for(var e=0;e<n.length;++e)n[e]()},i={},s=e.length-22;101010256!=Tm(e,s);--s)if(!s||e.length-s>65558)return void t("invalid zip file",null);var o=Sm(e,s+8);o||t(null,{});var a=o,l=Tm(e,s+16),c=4294967295==l;if(c){if(s=Tm(e,s-12),101075792!=Tm(e,s))return void t("invalid zip file",null);a=o=Tm(e,s+32),l=Tm(e,s+48)}for(var h=function(s){var a=vg(e,l,c),h=a[0],u=a[1],d=a[2],p=a[3],f=a[4],m=a[5],g=gg(e,m);l=f;var v=function(e,n){e?(r(),t(e,null)):(i[p]=n,--o||t(null,i))};if(h)if(8==h){var y=e.subarray(g,g+u);if(u<32e4)try{v(null,Gm(y,new xf(d)))}catch(e){v(e,null)}else n.push(Hm(y,{size:d},v))}else v("unknown compression type "+h,null);else v(null,Xf(e,g,g+u))},u=0;u<a;++u)h();return r},unzipSync:function(e){for(var t={},n=e.length-22;101010256!=Tm(e,n);--n)if(!n||e.length-n>65558)throw"invalid zip file";var r=Sm(e,n+8);if(!r)return{};var i=Tm(e,n+16),s=4294967295==i;if(s){if(n=Tm(e,n-12),101075792!=Tm(e,n))throw"invalid zip file";r=Tm(e,n+32),i=Tm(e,n+48)}for(var o=0;o<r;++o){var a=vg(e,i,s),l=a[0],c=a[1],h=a[2],u=a[3],d=a[4],p=a[5],f=gg(e,p);if(i=d,l){if(8!=l)throw"unknown compression type "+l;t[u]=Gm(e.subarray(f,f+c),new xf(h))}else t[u]=Xf(e,f,f+c)}return t}});function Lg(e,t,n){const r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let i=e,s=r,o=Math.floor((i+s)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?s=o:i=o,o=Math.floor((i+s)/2);return o}function Ig(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function Dg(e,t,n,r,i){return function(e){const t=e.length,n=[],r=[];for(let i=0;i<t;++i){const t=e[i];n[i]=new q(t.x,t.y,t.z),r[i]=t.w}const i=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(i[e-n].clone().multiplyScalar(Ig(e,n)*r[n]));i[e]=t.divideScalar(r[0])}return i}(function(e,t,n,r,i){const s=i<e?i:e,o=[],a=Lg(e,r,t),l=function(e,t,n,r,i){const s=[];for(let e=0;e<=n;++e)s[e]=0;const o=[];for(let e=0;e<=r;++e)o[e]=s.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=s.slice(0);a[0][0]=1;const l=s.slice(0),c=s.slice(0);for(let r=1;r<=n;++r){l[r]=t-i[e+1-r],c[r]=i[e+r]-t;let n=0;for(let e=0;e<r;++e){const t=c[e+1],i=l[r-e];a[r][e]=t+i;const s=a[e][r-1]/a[r][e];a[e][r]=n+t*s,n=i*s}a[r][r]=n}for(let e=0;e<=n;++e)o[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,i=1;const l=[];for(let e=0;e<=n;++e)l[e]=s.slice(0);l[0][0]=1;for(let s=1;s<=r;++s){let r=0;const c=e-s,h=n-s;e>=s&&(l[i][0]=l[t][0]/a[h+1][c],r=l[i][0]*a[c][h]);const u=e-1<=h?s-1:n-e;for(let e=c>=-1?1:-c;e<=u;++e)l[i][e]=(l[t][e]-l[t][e-1])/a[h+1][c+e],r+=l[i][e]*a[c+e][h];e<=h&&(l[i][s]=-l[t][s-1]/a[h+1][e],r+=l[i][s]*a[e][h]),o[s][e]=r;const d=t;t=i,i=d}}let h=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)o[e][t]*=h;h*=n-e}return o}(a,r,e,s,t),c=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,c[e]=t}for(let t=0;t<=s;++t){const n=c[a-e].clone().multiplyScalar(l[t][0]);for(let r=1;r<=e;++r)n.add(c[a-e+r].clone().multiplyScalar(l[t][r]));o[t]=n}for(let e=s+1;e<=i+1;++e)o[e]=new k(0,0,0);return o}(e,t,n,r,i))}class Og extends io{constructor(e,t,n,r,i){super(),this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=i||this.knots.length-1;for(let e=0;e<n.length;++e){const t=n[e];this.controlPoints[e]=new k(t.x,t.y,t.z,t.w)}}getPoint(e,t=new q){const n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),i=function(e,t,n,r){const i=Lg(e,r,t),s=function(e,t,n,r){const i=[],s=[],o=[];i[0]=1;for(let a=1;a<=n;++a){s[a]=t-r[e+1-a],o[a]=r[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=o[e+1],r=s[a-e],l=i[e]/(t+r);i[e]=n+t*l,n=r*l}i[a]=n}return i}(i,r,e,t),o=new k(0,0,0,0);for(let t=0;t<=e;++t){const r=n[i-e+t],a=s[t],l=r.w*a;o.x+=r.x*l,o.y+=r.y*l,o.z+=r.z*l,o.w+=r.w*a}return o}(this.degree,this.knots,this.controlPoints,r);return 1!==i.w&&i.divideScalar(i.w),n.set(i.x,i.y,i.z)}getTangent(e,t=new q){const n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),i=Dg(this.degree,this.knots,this.controlPoints,r,1);return n.copy(i[1]).normalize(),n}}let Bg,Ng,zg;class Ug extends rl{constructor(e){super(e)}load(e,t,n,r){const i=this,s=""===i.path?Rl.extractUrlBase(e):i.path,o=new sl(this.manager);o.setPath(i.path),o.setResponseType("arraybuffer"),o.setRequestHeader(i.requestHeader),o.setWithCredentials(i.withCredentials),o.load(e,(function(n){try{t(i.parse(n,s))}catch(t){r?r(t):console.error(t),i.manager.itemError(e)}}),n,r)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===tv(e,0,t.length)}(e))Bg=(new jg).parse(e);else{const t=tv(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(t){const r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e){if(r(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Xg(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Xg(t));Bg=(new Gg).parse(t)}const n=new cl(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new kg(n,this.manager).parse(Bg)}}class kg{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){Ng=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),i=(new Fg).parse(r);return this.parseScene(r,i,n),zg}parseConnections(){const e=new Map;if("Connections"in Bg){Bg.Connections.connections.forEach((function(t){const n=t[0],r=t[1],i=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const s={ID:r,relationship:i};e.get(n).parents.push(s),e.has(r)||e.set(r,{parents:[],children:[]});const o={ID:n,relationship:i};e.get(r).children.push(o)}))}return e}parseImages(){const e={},t={};if("Video"in Bg.Objects){const n=Bg.Objects.Video;for(const r in n){const i=n[r];if(e[parseInt(r)]=i.RelativeFilename||i.Filename,"Content"in i){const e=i.Content instanceof ArrayBuffer&&i.Content.byteLength>0,s="string"==typeof i.Content&&""!==i.Content;if(e||s){const e=this.parseImage(n[r]);t[i.RelativeFilename||i.Filename]=e}}}}for(const n in e){const r=e[n];void 0!==t[r]?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename,r=n.slice(n.lastIndexOf(".")+1).toLowerCase();let i;switch(r){case"bmp":i="image/bmp";break;case"jpg":case"jpeg":i="image/jpeg";break;case"png":i="image/png";break;case"tif":i="image/tiff";break;case"tga":null===this.manager.getHandler(".tga")&&console.warn("FBXLoader: TGA loader not found, skipping ",n),i="image/tga";break;default:return void console.warn('FBXLoader: Image type "'+r+'" is not supported.')}if("string"==typeof t)return"data:"+i+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:i}))}}parseTextures(e){const t=new Map;if("Texture"in Bg.Objects){const n=Bg.Objects.Texture;for(const r in n){const i=this.parseTexture(n[r],e);t.set(parseInt(r),i)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const r=e.WrapModeU,i=e.WrapModeV,s=void 0!==r?r.value:0,o=void 0!==i?i.value:0;if(n.wrapS=0===s?1e3:1001,n.wrapT=0===o?1e3:1001,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}return n}loadTexture(e,t){let n;const r=this.textureLoader.path,i=Ng.get(e.id).children;let s;void 0!==i&&i.length>0&&void 0!==t[i[0].ID]&&(n=t[i[0].ID],0!==n.indexOf("blob:")&&0!==n.indexOf("data:")||this.textureLoader.setPath(void 0));const o=e.FileName.slice(-3).toLowerCase();if("tga"===o){const t=this.manager.getHandler(".tga");null===t?(console.warn("FBXLoader: TGA loader not found, creating placeholder texture for",e.RelativeFilename),s=new U):(t.setPath(this.textureLoader.path),s=t.load(n))}else"psd"===o?(console.warn("FBXLoader: PSD textures are not supported, creating placeholder texture for",e.RelativeFilename),s=new U):s=this.textureLoader.load(n);return this.textureLoader.setPath(r),s}parseMaterials(e){const t=new Map;if("Material"in Bg.Objects){const n=Bg.Objects.Material;for(const r in n){const i=this.parseMaterial(n[r],e);null!==i&&t.set(parseInt(r),i)}}return t}parseMaterial(e,t){const n=e.id,r=e.attrName;let i=e.ShadingModel;if("object"==typeof i&&(i=i.value),!Ng.has(n))return null;const s=this.parseParameters(e,t,n);let o;switch(i.toLowerCase()){case"phong":o=new Ia;break;case"lambert":o=new Ba;break;default:console.warn('THREE.FBXLoader: unknown material type "%s". Defaulting to MeshPhongMaterial.',i),o=new Ia}return o.setValues(s),o.name=r,o}parseParameters(e,t,n){const r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=(new I).fromArray(e.Diffuse.value):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(r.color=(new I).fromArray(e.DiffuseColor.value)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=(new I).fromArray(e.Emissive.value):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(r.emissive=(new I).fromArray(e.EmissiveColor.value)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),e.Opacity&&(r.opacity=parseFloat(e.Opacity.value)),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=(new I).fromArray(e.Specular.value):e.SpecularColor&&"Color"===e.SpecularColor.type&&(r.specular=(new I).fromArray(e.SpecularColor.value));const i=this;return Ng.get(n).children.forEach((function(e){const n=e.relationship;switch(n){case"Bump":r.bumpMap=i.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":r.aoMap=i.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=i.getTexture(t,e.ID),void 0!==r.map&&(r.map.encoding=3001);break;case"DisplacementColor":r.displacementMap=i.getTexture(t,e.ID);break;case"EmissiveColor":r.emissiveMap=i.getTexture(t,e.ID),void 0!==r.emissiveMap&&(r.emissiveMap.encoding=3001);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=i.getTexture(t,e.ID);break;case"ReflectionColor":r.envMap=i.getTexture(t,e.ID),void 0!==r.envMap&&(r.envMap.mapping=303,r.envMap.encoding=3001);break;case"SpecularColor":r.specularMap=i.getTexture(t,e.ID),void 0!==r.specularMap&&(r.specularMap.encoding=3001);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=i.getTexture(t,e.ID),r.transparent=!0;break;case"AmbientColor":case"ShininessExponent":case"SpecularFactor":case"VectorDisplacementColor":default:console.warn("THREE.FBXLoader: %s map is not supported in three.js, skipping texture.",n)}})),r}getTexture(e,t){return"LayeredTexture"in Bg.Objects&&t in Bg.Objects.LayeredTexture&&(console.warn("THREE.FBXLoader: layered textures are not supported in three.js. Discarding all but first layer."),t=Ng.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Bg.Objects){const n=Bg.Objects.Deformer;for(const r in n){const i=n[r],s=Ng.get(parseInt(r));if("Skin"===i.attrType){const t=this.parseSkeleton(s,n);t.ID=r,s.parents.length>1&&console.warn("THREE.FBXLoader: skeleton attached to more than one geometry is not supported."),t.geometryID=s.parents[0].ID,e[r]=t}else if("BlendShape"===i.attrType){const e={id:r};e.rawTargets=this.parseMorphTargets(s,n),e.id=r,s.parents.length>1&&console.warn("THREE.FBXLoader: morph target attached to more than one geometry is not supported."),t[r]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach((function(e){const r=t[e.ID];if("Cluster"!==r.attrType)return;const i={ID:e.ID,indices:[],weights:[],transformLink:(new Se).fromArray(r.TransformLink.a)};"Indexes"in r&&(i.indices=r.Indexes.a,i.weights=r.Weights.a),n.push(i)})),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const i=e.children[r],s=t[i.ID],o={name:s.attrName,initialWeight:s.DeformPercent,id:s.id,fullWeights:s.FullWeights.a};if("BlendShapeChannel"!==s.attrType)return;o.geoID=Ng.get(parseInt(i.ID)).children.filter((function(e){return void 0===e.relationship}))[0].ID,n.push(o)}return n}parseScene(e,t,n){zg=new Fi;const r=this.parseModels(e.skeletons,t,n),i=Bg.Objects.Model,s=this;r.forEach((function(e){const t=i[e.ID];s.setLookAtProperties(e,t);Ng.get(e.ID).parents.forEach((function(t){const n=r.get(t.ID);void 0!==n&&n.add(e)})),null===e.parent&&zg.add(e)})),this.bindSkeleton(e.skeletons,t,r),this.createAmbientLight(),zg.traverse((function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=Kg(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}}));const o=(new Hg).parse();1===zg.children.length&&zg.children[0].isGroup&&(zg.children[0].animations=o,zg=zg.children[0]),zg.animations=o}parseModels(e,t,n){const r=new Map,i=Bg.Objects.Model;for(const s in i){const o=parseInt(s),a=i[s],l=Ng.get(o);let c=this.buildSkeleton(l,e,o,a.attrName);if(!c){switch(a.attrType){case"Camera":c=this.createCamera(l);break;case"Light":c=this.createLight(l);break;case"Mesh":c=this.createMesh(l,t,n);break;case"NurbsCurve":c=this.createCurve(l,t);break;case"LimbNode":case"Root":c=new Ts;break;case"Null":default:c=new Fi}c.name=a.attrName?dc.sanitizeNodeName(a.attrName):"",c.ID=o}this.getTransformData(c,a),r.set(o,c)}return r}buildSkeleton(e,t,n,r){let i=null;return e.parents.forEach((function(e){for(const s in t){const o=t[s];o.rawBones.forEach((function(t,s){if(t.ID===e.ID){const e=i;i=new Ts,i.matrixWorld.copy(t.transformLink),i.name=r?dc.sanitizeNodeName(r):"",i.ID=n,o.bones[s]=i,null!==e&&i.add(e)}}))}})),i}createCamera(e){let t,n;if(e.children.forEach((function(e){const t=Bg.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new Ze;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let r=1;void 0!==n.NearPlane&&(r=n.NearPlane.value/1e3);let i=1e3;void 0!==n.FarPlane&&(i=n.FarPlane.value/1e3);let s=window.innerWidth,o=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(s=n.AspectWidth.value,o=n.AspectHeight.value);const a=s/o;let l=45;void 0!==n.FieldOfView&&(l=n.FieldOfView.value);const c=n.FocalLength?n.FocalLength.value:null;switch(e){case 0:t=new nn(l,a,r,i),null!==c&&t.setFocalLength(c);break;case 1:t=new En(-s/2,s/2,o/2,-o/2,r,i);break;default:console.warn("THREE.FBXLoader: Unknown camera type "+e+"."),t=new Ze}}return t}createLight(e){let t,n;if(e.children.forEach((function(e){const t=Bg.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)})),void 0===n)t=new Ze;else{let e;e=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=(new I).fromArray(n.Color.value));let i=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(i=0);let s=0;void 0!==n.FarAttenuationEnd&&(s=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new _l(r,i,s,o);break;case 1:t=new Sl(r,i);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=m.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=m.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new vl(r,i,s,e,a,o);break;default:console.warn("THREE.FBXLoader: Unknown light type "+n.LightType.value+", defaulting to a PointLight."),t=new _l(r,i)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,i=null,s=null;const o=[];return e.children.forEach((function(e){t.has(e.ID)&&(i=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))})),o.length>1?s=o:o.length>0?s=o[0]:(s=new Ia({color:13421772}),o.push(s)),"color"in i.attributes&&o.forEach((function(e){e.vertexColors=!0})),i.FBX_Deformer?(r=new Ss(i,s),r.normalizeSkinWeights()):r=new Yt(i,s),r}createCurve(e,t){const n=e.children.reduce((function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e}),null),r=new Ns({color:3342591,linewidth:1});return new Gs(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder="RotationOrder"in t?$g(t.RotationOrder.value):"ZYX","Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){Ng.get(e.ID).children.forEach((function(t){if("LookAtProperty"===t.relationship){const n=Bg.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),zg.add(e.target)):e.lookAt((new q).fromArray(t))}}}))}}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const i in e){const s=e[i];Ng.get(parseInt(s.ID)).parents.forEach((function(e){if(t.has(e.ID)){const t=e.ID;Ng.get(t).parents.forEach((function(e){if(n.has(e.ID)){n.get(e.ID).bind(new Ps(s.bones),r[e.ID])}}))}}))}}parsePoseNodes(){const e={};if("Pose"in Bg.Objects){const t=Bg.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const r=t[n].PoseNode;Array.isArray(r)?r.forEach((function(t){e[t.Node]=(new Se).fromArray(t.Matrix.a)})):e[r.Node]=(new Se).fromArray(r.Matrix.a)}}return e}createAmbientLight(){if("GlobalSettings"in Bg&&"AmbientColor"in Bg.GlobalSettings){const e=Bg.GlobalSettings.AmbientColor.value,t=e[0],n=e[1],r=e[2];if(0!==t||0!==n||0!==r){const e=new I(t,n,r);zg.add(new Tl(e,1))}}}}class Fg{parse(e){const t=new Map;if("Geometry"in Bg.Objects){const n=Bg.Objects.Geometry;for(const r in n){const i=Ng.get(parseInt(r)),s=this.parseGeometry(i,n[r],e);t.set(parseInt(r),s)}}return t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,i=[],s=e.parents.map((function(e){return Bg.Objects.Model[e.ID]}));if(0===s.length)return;const o=e.children.reduce((function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e}),null);e.children.forEach((function(e){void 0!==n.morphTargets[e.ID]&&i.push(n.morphTargets[e.ID])}));const a=s[0],l={};"RotationOrder"in a&&(l.eulerOrder=$g(a.RotationOrder.value)),"InheritType"in a&&(l.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(l.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(l.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(l.scale=a.GeometricScaling.value);const c=Kg(l);return this.genGeometry(t,o,i,c)}genGeometry(e,t,n,r){const i=new Rt;e.attrName&&(i.name=e.attrName);const s=this.parseGeoNode(e,t),o=this.genBuffers(s),a=new bt(o.vertex,3);if(a.applyMatrix4(r),i.setAttribute("position",a),o.colors.length>0&&i.setAttribute("color",new bt(o.colors,3)),t&&(i.setAttribute("skinIndex",new vt(o.weightsIndices,4)),i.setAttribute("skinWeight",new bt(o.vertexWeights,4)),i.FBX_Deformer=t),o.normal.length>0){const e=(new v).getNormalMatrix(r),t=new bt(o.normal,3);t.applyNormalMatrix(e),i.setAttribute("normal",t)}if(o.uvs.forEach((function(e,t){let n="uv"+(t+1).toString();0===t&&(n="uv"),i.setAttribute(n,new bt(o.uvs[t],2))})),s.material&&"AllSame"!==s.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach((function(n,r){n!==e&&(i.addGroup(t,r-t,e),e=n,t=r)})),i.groups.length>0){const t=i.groups[i.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&i.addGroup(n,o.materialIndex.length-n,e)}0===i.groups.length&&i.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(i,e,n,r),i}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach((function(e,t){e.indices.forEach((function(r,i){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[i]})}))}))),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,i=!1,s=[],o=[],a=[],l=[],c=[],h=[];const u=this;return e.vertexIndices.forEach((function(d,p){let f,m=!1;d<0&&(d^=-1,m=!0);let g=[],v=[];if(s.push(3*d,3*d+1,3*d+2),e.color){const t=Zg(p,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach((function(e){v.push(e.weight),g.push(e.id)})),v.length>4){i||(console.warn("THREE.FBXLoader: Vertex has more than 4 skinning weights assigned to vertex. Deleting additional weights."),i=!0);const e=[0,0,0,0],t=[0,0,0,0];v.forEach((function(n,r){let i=n,s=g[r];t.forEach((function(t,n,r){if(i>t){r[n]=i,i=t;const o=e[n];e[n]=s,s=o}}))})),g=e,v=t}for(;v.length<4;)v.push(0),g.push(0);for(let e=0;e<4;++e)c.push(v[e]),h.push(g[e])}if(e.normal){const t=Zg(p,n,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(f=Zg(p,n,d,e.material)[0]),e.uv&&e.uv.forEach((function(e,t){const r=Zg(p,n,d,e);void 0===l[t]&&(l[t]=[]),l[t].push(r[0]),l[t].push(r[1])})),r++,m&&(u.genFace(t,e,s,f,o,a,l,c,h,r),n++,r=0,s=[],o=[],a=[],l=[],c=[],h=[])})),t}genFace(e,t,n,r,i,s,o,a,l,c){for(let h=2;h<c;h++)e.vertex.push(t.vertexPositions[n[0]]),e.vertex.push(t.vertexPositions[n[1]]),e.vertex.push(t.vertexPositions[n[2]]),e.vertex.push(t.vertexPositions[n[3*(h-1)]]),e.vertex.push(t.vertexPositions[n[3*(h-1)+1]]),e.vertex.push(t.vertexPositions[n[3*(h-1)+2]]),e.vertex.push(t.vertexPositions[n[3*h]]),e.vertex.push(t.vertexPositions[n[3*h+1]]),e.vertex.push(t.vertexPositions[n[3*h+2]]),t.skeleton&&(e.vertexWeights.push(a[0]),e.vertexWeights.push(a[1]),e.vertexWeights.push(a[2]),e.vertexWeights.push(a[3]),e.vertexWeights.push(a[4*(h-1)]),e.vertexWeights.push(a[4*(h-1)+1]),e.vertexWeights.push(a[4*(h-1)+2]),e.vertexWeights.push(a[4*(h-1)+3]),e.vertexWeights.push(a[4*h]),e.vertexWeights.push(a[4*h+1]),e.vertexWeights.push(a[4*h+2]),e.vertexWeights.push(a[4*h+3]),e.weightsIndices.push(l[0]),e.weightsIndices.push(l[1]),e.weightsIndices.push(l[2]),e.weightsIndices.push(l[3]),e.weightsIndices.push(l[4*(h-1)]),e.weightsIndices.push(l[4*(h-1)+1]),e.weightsIndices.push(l[4*(h-1)+2]),e.weightsIndices.push(l[4*(h-1)+3]),e.weightsIndices.push(l[4*h]),e.weightsIndices.push(l[4*h+1]),e.weightsIndices.push(l[4*h+2]),e.weightsIndices.push(l[4*h+3])),t.color&&(e.colors.push(s[0]),e.colors.push(s[1]),e.colors.push(s[2]),e.colors.push(s[3*(h-1)]),e.colors.push(s[3*(h-1)+1]),e.colors.push(s[3*(h-1)+2]),e.colors.push(s[3*h]),e.colors.push(s[3*h+1]),e.colors.push(s[3*h+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(i[0]),e.normal.push(i[1]),e.normal.push(i[2]),e.normal.push(i[3*(h-1)]),e.normal.push(i[3*(h-1)+1]),e.normal.push(i[3*(h-1)+2]),e.normal.push(i[3*h]),e.normal.push(i[3*h+1]),e.normal.push(i[3*h+2])),t.uv&&t.uv.forEach((function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(o[n][0]),e.uvs[n].push(o[n][1]),e.uvs[n].push(o[n][2*(h-1)]),e.uvs[n].push(o[n][2*(h-1)+1]),e.uvs[n].push(o[n][2*h]),e.uvs[n].push(o[n][2*h+1])}))}addMorphTargets(e,t,n,r){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const i=this;n.forEach((function(n){n.rawTargets.forEach((function(n){const s=Bg.Objects.Geometry[n.geoID];void 0!==s&&i.genMorphGeometry(e,t,s,r,n.name)}))}))}genMorphGeometry(e,t,n,r,i){const s=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],o=void 0!==n.Vertices?n.Vertices.a:[],a=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,c=new Float32Array(l);for(let e=0;e<a.length;e++){const t=3*a[e];c[t]=o[3*e],c[t+1]=o[3*e+1],c[t+2]=o[3*e+2]}const h={vertexIndices:s,vertexPositions:c},u=this.genBuffers(h),d=new bt(u.vertex,3);d.name=i||n.attrName,d.applyMatrix4(r),e.morphAttributes.position.push(d)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let i=[];return"IndexToDirect"===n&&("NormalIndex"in e?i=e.NormalIndex.a:"NormalsIndex"in e&&(i=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:i,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let i=[];return"IndexToDirect"===n&&(i=e.UVIndex.a),{dataSize:2,buffer:r,indices:i,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a;let i=[];return"IndexToDirect"===n&&(i=e.ColorIndex.a),{dataSize:4,buffer:r,indices:i,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,i=[];for(let e=0;e<r.length;++e)i.push(e);return{dataSize:1,buffer:r,indices:i,mappingType:t,referenceType:n}}parseNurbsGeometry(e){if(void 0===Og)return console.error("THREE.FBXLoader: The loader relies on NURBSCurve for any nurbs present in the model. Nurbs will show up as empty geometry."),new Rt;const t=parseInt(e.Order);if(isNaN(t))return console.error("THREE.FBXLoader: Invalid Order %s given for geometry ID: %s",e.Order,e.id),new Rt;const n=t-1,r=e.KnotVector.a,i=[],s=e.Points.a;for(let e=0,t=s.length;e<t;e+=4)i.push((new k).fromArray(s,e));let o,a;if("Closed"===e.Form)i.push(i[0]);else if("Periodic"===e.Form){o=n,a=r.length-1-o;for(let e=0;e<n;++e)i.push(i[e])}const l=new Og(n,r,i,o,a).getPoints(12*i.length);return(new Rt).setFromPoints(l)}}class Hg{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const r=t[n],i=this.addClip(r);e.push(i)}return e}parseClips(){if(void 0===Bg.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Bg.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const e={id:r.id,attr:r.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Bg.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(qg),values:t[n].KeyValueFloat.a},i=Ng.get(r.id);if(void 0!==i){const t=i.parents[0].ID,n=i.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=r:n.match(/Y/)?e.get(t).curves.y=r:n.match(/Z/)?e.get(t).curves.z=r:n.match(/d|DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=r)}}}parseAnimationLayers(e){const t=Bg.Objects.AnimationLayer,n=new Map;for(const r in t){const t=[],i=Ng.get(parseInt(r));if(void 0!==i){i.children.forEach((function(n,r){if(e.has(n.ID)){const i=e.get(n.ID);if(void 0!==i.curves.x||void 0!==i.curves.y||void 0!==i.curves.z){if(void 0===t[r]){const e=Ng.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID;if(void 0!==e){const i=Bg.Objects.Model[e.toString()];if(void 0===i)return void console.warn("THREE.FBXLoader: Encountered a unused curve.",n);const s={modelName:i.attrName?dc.sanitizeNodeName(i.attrName):"",ID:i.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};zg.traverse((function(e){e.ID===i.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))})),s.transform||(s.transform=new Se),"PreRotation"in i&&(s.preRotation=i.PreRotation.value),"PostRotation"in i&&(s.postRotation=i.PostRotation.value),t[r]=s}}t[r]&&(t[r][i.attr]=i)}else if(void 0!==i.curves.morph){if(void 0===t[r]){const e=Ng.get(n.ID).parents.filter((function(e){return void 0!==e.relationship}))[0].ID,i=Ng.get(e).parents[0].ID,s=Ng.get(i).parents[0].ID,o=Ng.get(s).parents[0].ID,a=Bg.Objects.Model[o],l={modelName:a.attrName?dc.sanitizeNodeName(a.attrName):"",morphName:Bg.Objects.Deformer[e].attrName};t[r]=l}t[r][i.attr]=i}}})),n.set(parseInt(r),t)}}return n}parseAnimStacks(e){const t=Bg.Objects.AnimationStack,n={};for(const r in t){const i=Ng.get(parseInt(r)).children;i.length>1&&console.warn("THREE.FBXLoader: Encountered an animation stack with multiple layers, this is currently not supported. Ignoring subsequent layers.");const s=e.get(i[0].ID);n[r]={name:t[r].attrName,layer:s}}return n}addClip(e){let t=[];const n=this;return e.layer.forEach((function(e){t=t.concat(n.generateTracks(e))})),new Ka(e.name,-1,t)}generateTracks(e){const t=[];let n=new q,r=new X,i=new q;if(e.transform&&e.transform.decompose(n,r,i),n=n.toArray(),r=(new Oe).setFromQuaternion(r,e.eulerOrder).toArray(),i=i.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==r&&t.push(r)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,r,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,i,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,r){const i=this.getTimesForAllAxes(t),s=this.getKeyframeTrackValues(i,t,n);return new Qa(e+"."+r,i,s)}generateRotationTrack(e,t,n,r,i,s){void 0!==t.x&&(this.interpolateRotations(t.x),t.x.values=t.x.values.map(m.degToRad)),void 0!==t.y&&(this.interpolateRotations(t.y),t.y.values=t.y.values.map(m.degToRad)),void 0!==t.z&&(this.interpolateRotations(t.z),t.z.values=t.z.values.map(m.degToRad));const o=this.getTimesForAllAxes(t),a=this.getKeyframeTrackValues(o,t,n);void 0!==r&&((r=r.map(m.degToRad)).push(s),r=(new Oe).fromArray(r),r=(new X).setFromEuler(r)),void 0!==i&&((i=i.map(m.degToRad)).push(s),i=(new Oe).fromArray(i),i=(new X).setFromEuler(i).invert());const l=new X,c=new Oe,h=[];for(let e=0;e<a.length;e+=3)c.set(a[e],a[e+1],a[e+2],s),l.setFromEuler(c),void 0!==r&&l.premultiply(r),void 0!==i&&l.multiply(i),l.toArray(h,e/3*4);return new Za(e+".quaternion",o,h)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map((function(e){return e/100})),r=zg.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new qa(e.modelName+".morphTargetInfluences["+r+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort((function(e,t){return e-t})),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){const i=t[r];i!==n&&(t[e]=i,n=i,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const r=n,i=[];let s=-1,o=-1,a=-1;return e.forEach((function(e){if(t.x&&(s=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==s){const e=t.x.values[s];i.push(e),r[0]=e}else i.push(r[0]);if(-1!==o){const e=t.y.values[o];i.push(e),r[1]=e}else i.push(r[1]);if(-1!==a){const e=t.z.values[a];i.push(e),r[2]=e}else i.push(r[2])})),i}interpolateRotations(e){for(let t=1;t<e.values.length;t++){const n=e.values[t-1],r=e.values[t]-n,i=Math.abs(r);if(i>=180){const s=i/180,o=r/s;let a=n+o;const l=e.times[t-1],c=(e.times[t]-l)/s;let h=l+c;const u=[],d=[];for(;h<e.times[t];)u.push(h),h+=c,d.push(a),a+=o;e.times=nv(e.times,t,u),e.values=nv(e.values,t,d)}}}}class Gg{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Wg,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach((function(e,r){const i=e.match(/^[\s\t]*;/),s=e.match(/^[\s\t]*$/);if(i||s)return;const o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),l=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,n[++r]):l?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)})),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map((function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")})),i={name:n},s=this.parseNodeAttr(r),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,i):n in o?("PoseNode"===n?o.PoseNode.push(i):void 0!==o[n].id&&(o[n]={},o[n][o[n].id]=o[n]),""!==s.id&&(o[n][s.id]=i)):"number"==typeof s.id?(o[n]={},o[n][s.id]=i):"Properties70"!==n&&(o[n]="PoseNode"===n?[i]:i),"number"==typeof s.id&&(i.id=s.id),""!==s.name&&(i.attrName=s.name),""!==s.type&&(i.attrType=s.type),this.pushStack(i)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),i=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===i&&(i=n.replace(/"/g,"").replace(/,$/,"").trim());const s=this.getCurrentNode();if("Properties70"!==s.name){if("C"===r){const e=i.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let o=i.split(",").slice(3);o=o.map((function(e){return e.trim().replace(/^"/,"")})),r="connections",i=[t,n],function(e,t){for(let n=0,r=e.length,i=t.length;n<i;n++,r++)e[r]=t[n]}(i,o),void 0===s[r]&&(s[r]=[])}"Node"===r&&(s.id=i),r in s&&Array.isArray(s[r])?s[r].push(i):"a"!==r?s[r]=i:s.a=i,this.setCurrentProp(s,r),"a"===r&&","!==i.slice(-1)&&(s.a=ev(i))}else this.parseNodeSpecialProperty(e,r,i)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=ev(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map((function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")})),i=r[0],s=r[1],o=r[2],a=r[3];let l=r[4];switch(s){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":l=parseFloat(l);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":l=ev(l)}this.getPrevNode()[i]={type:s,type2:o,flag:a,value:l},this.setCurrentProp(this.getPrevNode(),i)}}class jg{parse(e){const t=new Vg(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new Wg;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),i=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const s=e.getUint8(),o=e.getString(s);if(0===r)return null;const a=[];for(let t=0;t<i;t++)a.push(this.parseProperty(e));const l=a.length>0?a[0]:"",c=a.length>1?a[1]:"",h=a.length>2?a[2]:"";for(n.singleProperty=1===i&&e.getOffset()===r;r>e.getOffset();){const r=this.parseNode(e,t);null!==r&&this.parseSubNode(o,n,r)}return n.propertyList=a,"number"==typeof l&&(n.id=l),""!==c&&(n.attrName=c),""!==h&&(n.attrType=h),""!==o&&(n.name=o),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach((function(t,n){0!==n&&e.push(t)})),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach((function(e){t[e]=n[e]}))}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],r=n.propertyList[1];const i=n.propertyList[2],s=n.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),o="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:i,flag:s,value:o}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),i=e.getUint32(),s=e.getUint32();if(0===i)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}void 0===Rg&&console.error("THREE.FBXLoader: External library fflate.min.js required.");const o=rg(new Uint8Array(e.getArrayBuffer(s))),a=new Vg(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(r);case"d":return a.getFloat64Array(r);case"f":return a.getFloat32Array(r);case"i":return a.getInt32Array(r);case"l":return a.getInt64Array(r)}default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Vg{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return 1==(1&this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){let t=[];for(let n=0;n<e;n++)t[n]=this.getUint8();const n=t.indexOf(0);return n>=0&&(t=t.slice(0,n)),Rl.decodeText(new Uint8Array(t))}}class Wg{add(e,t){this[e]=t}}function Xg(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function qg(e){return e/46186158e3}const Yg=[];function Zg(e,t,n,r){let i;switch(r.mappingType){case"ByPolygonVertex":i=e;break;case"ByPolygon":i=t;break;case"ByVertice":i=n;break;case"AllSame":i=r.indices[0];break;default:console.warn("THREE.FBXLoader: unknown attribute mapping type "+r.mappingType)}"IndexToDirect"===r.referenceType&&(i=r.indices[i]);const s=i*r.dataSize,o=s+r.dataSize;return function(e,t,n,r){for(let i=n,s=0;i<r;i++,s++)e[s]=t[i];return e}(Yg,r.buffer,s,o)}const Jg=new Oe,Qg=new q;function Kg(e){const t=new Se,n=new Se,r=new Se,i=new Se,s=new Se,o=new Se,a=new Se,l=new Se,c=new Se,h=new Se,u=new Se,d=new Se,p=e.inheritType?e.inheritType:0;if(e.translation&&t.setPosition(Qg.fromArray(e.translation)),e.preRotation){const t=e.preRotation.map(m.degToRad);t.push(e.eulerOrder),n.makeRotationFromEuler(Jg.fromArray(t))}if(e.rotation){const t=e.rotation.map(m.degToRad);t.push(e.eulerOrder),r.makeRotationFromEuler(Jg.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(m.degToRad);t.push(e.eulerOrder),i.makeRotationFromEuler(Jg.fromArray(t)),i.invert()}e.scale&&s.scale(Qg.fromArray(e.scale)),e.scalingOffset&&a.setPosition(Qg.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(Qg.fromArray(e.scalingPivot)),e.rotationOffset&&l.setPosition(Qg.fromArray(e.rotationOffset)),e.rotationPivot&&c.setPosition(Qg.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(u.copy(e.parentMatrix),h.copy(e.parentMatrixWorld));const f=n.clone().multiply(r).multiply(i),g=new Se;g.extractRotation(h);const v=new Se;v.copyPosition(h);const y=v.clone().invert().multiply(h),x=g.clone().invert().multiply(y),w=s,b=new Se;if(0===p)b.copy(g).multiply(f).multiply(x).multiply(w);else if(1===p)b.copy(g).multiply(x).multiply(f).multiply(w);else{const e=(new Se).scale((new q).setFromMatrixScale(u)).clone().invert(),t=x.clone().multiply(e);b.copy(g).multiply(f).multiply(t).multiply(w)}const _=c.clone().invert(),M=o.clone().invert();let S=t.clone().multiply(l).multiply(c).multiply(n).multiply(r).multiply(i).multiply(_).multiply(a).multiply(o).multiply(s).multiply(M);const T=(new Se).copyPosition(S),E=h.clone().multiply(T);return d.copyPosition(E),S=d.clone().multiply(b),S.premultiply(h.invert()),S}function $g(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?(console.warn("THREE.FBXLoader: unsupported Euler Order: Spherical XYZ. Animations and rotations may be incorrect."),t[0]):t[e]}function ev(e){return e.split(",").map((function(e){return parseFloat(e)}))}function tv(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),Rl.decodeText(new Uint8Array(e,t,n))}function nv(e,t,n){return e.slice(0,t).concat(n).concat(e.slice(t))}class rv extends ll{constructor(e){super(e)}parse(e){const t=0,n=1,r=2,i=3,s=9,o=10,a=11,l=48,c=4,h=0,u=1,d=2,p=3;e.length<19&&console.error("THREE.TGALoader: Not enough data to contain header.");let f=0;const m=new Uint8Array(e),g={id_length:m[f++],colormap_type:m[f++],image_type:m[f++],colormap_index:m[f++]|m[f++]<<8,colormap_length:m[f++]|m[f++]<<8,colormap_size:m[f++],origin:[m[f++]|m[f++]<<8,m[f++]|m[f++]<<8],width:m[f++]|m[f++]<<8,height:m[f++]|m[f++]<<8,pixel_size:m[f++],flags:m[f++]};!function(e){switch(e.image_type){case n:case s:(e.colormap_length>256||24!==e.colormap_size||1!==e.colormap_type)&&console.error("THREE.TGALoader: Invalid type colormap data for indexed type.");break;case r:case i:case o:case a:e.colormap_type&&console.error("THREE.TGALoader: Invalid type colormap data for colormap type.");break;case t:console.error("THREE.TGALoader: No data.");default:console.error('THREE.TGALoader: Invalid type "%s".',e.image_type)}(e.width<=0||e.height<=0)&&console.error("THREE.TGALoader: Invalid image size."),8!==e.pixel_size&&16!==e.pixel_size&&24!==e.pixel_size&&32!==e.pixel_size&&console.error('THREE.TGALoader: Invalid pixel size "%s".',e.pixel_size)}(g),g.id_length+f>e.length&&console.error("THREE.TGALoader: No data."),f+=g.id_length;let v=!1,y=!1,x=!1;switch(g.image_type){case s:v=!0,y=!0;break;case n:y=!0;break;case o:v=!0;break;case r:break;case a:v=!0,x=!0;break;case i:x=!0}const w=new Uint8Array(g.width*g.height*4),b=function(e,t,n,r,i){let s,o;const a=n.pixel_size>>3,l=n.width*n.height*a;if(t&&(o=i.subarray(r,r+=n.colormap_length*(n.colormap_size>>3))),e){let e,t,n;s=new Uint8Array(l);let o=0;const c=new Uint8Array(a);for(;o<l;)if(e=i[r++],t=1+(127&e),128&e){for(n=0;n<a;++n)c[n]=i[r++];for(n=0;n<t;++n)s.set(c,o+n*a);o+=a*t}else{for(t*=a,n=0;n<t;++n)s[o+n]=i[r++];o+=t}}else s=i.subarray(r,r+=t?n.width*n.height:l);return{pixel_data:s,palettes:o}}(v,y,g,f,m);return function(e,t,n,r,i){let s,o,a,f,m,v;switch((g.flags&l)>>c){default:case d:s=0,a=1,m=t,o=0,f=1,v=n;break;case h:s=0,a=1,m=t,o=n-1,f=-1,v=-1;break;case p:s=t-1,a=-1,m=-1,o=0,f=1,v=n;break;case u:s=t-1,a=-1,m=-1,o=n-1,f=-1,v=-1}if(x)switch(g.pixel_size){case 8:!function(e,t,n,r,i,s,o,a){let l,c,h,u=0;const d=g.width;for(h=t;h!==r;h+=n)for(c=i;c!==o;c+=s,u++)l=a[u],e[4*(c+d*h)+0]=l,e[4*(c+d*h)+1]=l,e[4*(c+d*h)+2]=l,e[4*(c+d*h)+3]=255}(e,o,f,v,s,a,m,r);break;case 16:!function(e,t,n,r,i,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==o;l+=s,h+=2)e[4*(l+u*c)+0]=a[h+0],e[4*(l+u*c)+1]=a[h+0],e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+3]=a[h+1]}(e,o,f,v,s,a,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}else switch(g.pixel_size){case 8:!function(e,t,n,r,i,s,o,a,l){const c=l;let h,u,d,p=0;const f=g.width;for(d=t;d!==r;d+=n)for(u=i;u!==o;u+=s,p++)h=a[p],e[4*(u+f*d)+3]=255,e[4*(u+f*d)+2]=c[3*h+0],e[4*(u+f*d)+1]=c[3*h+1],e[4*(u+f*d)+0]=c[3*h+2]}(e,o,f,v,s,a,m,r,i);break;case 16:!function(e,t,n,r,i,s,o,a){let l,c,h,u=0;const d=g.width;for(h=t;h!==r;h+=n)for(c=i;c!==o;c+=s,u+=2)l=a[u+0]+(a[u+1]<<8),e[4*(c+d*h)+0]=(31744&l)>>7,e[4*(c+d*h)+1]=(992&l)>>2,e[4*(c+d*h)+2]=(31&l)<<3,e[4*(c+d*h)+3]=32768&l?0:255}(e,o,f,v,s,a,m,r);break;case 24:!function(e,t,n,r,i,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==o;l+=s,h+=3)e[4*(l+u*c)+3]=255,e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+1]=a[h+1],e[4*(l+u*c)+0]=a[h+2]}(e,o,f,v,s,a,m,r);break;case 32:!function(e,t,n,r,i,s,o,a){let l,c,h=0;const u=g.width;for(c=t;c!==r;c+=n)for(l=i;l!==o;l+=s,h+=4)e[4*(l+u*c)+2]=a[h+0],e[4*(l+u*c)+1]=a[h+1],e[4*(l+u*c)+0]=a[h+2],e[4*(l+u*c)+3]=a[h+3]}(e,o,f,v,s,a,m,r);break;default:console.error("THREE.TGALoader: Format not supported.")}}(w,g.width,g.height,b.pixel_data,b.palettes),{data:w,width:g.width,height:g.height,flipY:!0,generateMipmaps:!0,minFilter:1008}}}class iv extends rl{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register((function(e){return new cv(e)})),this.register((function(e){return new mv(e)})),this.register((function(e){return new gv(e)})),this.register((function(e){return new hv(e)})),this.register((function(e){return new uv(e)})),this.register((function(e){return new dv(e)})),this.register((function(e){return new pv(e)})),this.register((function(e){return new fv(e)})),this.register((function(e){return new av(e)})),this.register((function(e){return new vv(e)}))}load(e,t,n,r){const i=this;let s;s=""!==this.resourcePath?this.resourcePath:""!==this.path?this.path:Rl.extractUrlBase(e),this.manager.itemStart(e);const o=function(t){r?r(t):console.error(t),i.manager.itemError(e),i.manager.itemEnd(e)},a=new sl(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,(function(n){try{i.parse(n,s,(function(n){t(n),i.manager.itemEnd(e)}),o)}catch(e){o(e)}}),n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw new Error('THREE.GLTFLoader: "MSFT_texture_dds" no longer supported. Please update to "KHR_texture_basisu".')}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let i;const s={},o={};if("string"==typeof e)i=e;else{if(Rl.decodeText(new Uint8Array(e,0,4))===yv){try{s[ov.KHR_BINARY_GLTF]=new bv(e)}catch(e){return void(r&&r(e))}i=s[ov.KHR_BINARY_GLTF].content}else i=Rl.decodeText(new Uint8Array(e))}const a=JSON.parse(i);if(void 0===a.asset||a.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const l=new ey(a,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});l.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](l);o[t.name]=t,s[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){const t=a.extensionsUsed[e],n=a.extensionsRequired||[];switch(t){case ov.KHR_MATERIALS_UNLIT:s[t]=new lv;break;case ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:s[t]=new Tv;break;case ov.KHR_DRACO_MESH_COMPRESSION:s[t]=new _v(a,this.dracoLoader);break;case ov.KHR_TEXTURE_TRANSFORM:s[t]=new Mv;break;case ov.KHR_MESH_QUANTIZATION:s[t]=new Ev;break;default:n.indexOf(t)>=0&&void 0===o[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(s),l.setPlugins(o),l.parse(n,r)}parseAsync(e,t){const n=this;return new Promise((function(r,i){n.parse(e,t,r,i)}))}}function sv(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const ov={KHR_BINARY_GLTF:"KHR_binary_glTF",KHR_DRACO_MESH_COMPRESSION:"KHR_draco_mesh_compression",KHR_LIGHTS_PUNCTUAL:"KHR_lights_punctual",KHR_MATERIALS_CLEARCOAT:"KHR_materials_clearcoat",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS:"KHR_materials_pbrSpecularGlossiness",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_UNLIT:"KHR_materials_unlit",KHR_MATERIALS_VOLUME:"KHR_materials_volume",KHR_TEXTURE_BASISU:"KHR_texture_basisu",KHR_TEXTURE_TRANSFORM:"KHR_texture_transform",KHR_MESH_QUANTIZATION:"KHR_mesh_quantization",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression"};class av{constructor(e){this.parser=e,this.name=ov.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const i=t.json,s=((i.extensions&&i.extensions[this.name]||{}).lights||[])[e];let o;const a=new I(16777215);void 0!==s.color&&a.fromArray(s.color);const l=void 0!==s.range?s.range:0;switch(s.type){case"directional":o=new Sl(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new _l(a),o.distance=l;break;case"spot":o=new vl(a),o.distance=l,s.spot=s.spot||{},s.spot.innerConeAngle=void 0!==s.spot.innerConeAngle?s.spot.innerConeAngle:0,s.spot.outerConeAngle=void 0!==s.spot.outerConeAngle?s.spot.outerConeAngle:Math.PI/4,o.angle=s.spot.outerConeAngle,o.penumbra=1-s.spot.innerConeAngle/s.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+s.type)}return o.position.set(0,0,0),o.decay=2,void 0!==s.intensity&&(o.intensity=s.intensity),o.name=t.createUniqueName(s.name||"light_"+e),r=Promise.resolve(o),t.cache.add(n,r),r}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],i=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===i?null:this._loadLight(i).then((function(e){return n._getNodeRef(t.cache,i,e)}))}}class lv{constructor(){this.name=ov.KHR_MATERIALS_UNLIT}getMaterialType(){return ct}extendParams(e,t,n){const r=[];e.color=new I(1,1,1),e.opacity=1;const i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){const t=i.baseColorFactor;e.color.fromArray(t),e.opacity=t[3]}void 0!==i.baseColorTexture&&r.push(n.assignTexture(e,"map",i.baseColorTexture,3001))}return Promise.all(r)}}class cv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&i.push(n.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&i.push(n.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(i.push(n.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){const e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new g(e,e)}return Promise.all(i)}}class hv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[];t.sheenColor=new I(0,0,0),t.sheenRoughness=0,t.sheen=1;const s=r.extensions[this.name];return void 0!==s.sheenColorFactor&&t.sheenColor.fromArray(s.sheenColorFactor),void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(n.assignTexture(t,"sheenColorMap",s.sheenColorTexture,3001)),void 0!==s.sheenRoughnessTexture&&i.push(n.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class uv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];return void 0!==s.transmissionFactor&&(t.transmission=s.transmissionFactor),void 0!==s.transmissionTexture&&i.push(n.assignTexture(t,"transmissionMap",s.transmissionTexture)),Promise.all(i)}}class dv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(n.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||0;const o=s.attenuationColor||[1,1,1];return t.attenuationColor=new I(o[0],o[1],o[2]),Promise.all(i)}}class pv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class fv{constructor(e){this.parser=e,this.name=ov.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?La:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const i=[],s=r.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(n.assignTexture(t,"specularIntensityMap",s.specularTexture));const o=s.specularColorFactor||[1,1,1];return t.specularColor=new I(o[0],o[1],o[2]),void 0!==s.specularColorTexture&&i.push(n.assignTexture(t,"specularColorMap",s.specularColorTexture,3001)),Promise.all(i)}}class mv{constructor(e){this.parser=e,this.name=ov.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const i=r.extensions[this.name],s=t.options.ktx2Loader;if(!s){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,i.source,s)}}class gv{constructor(e){this.parser=e,this.name=ov.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){const t=this.name,n=this.parser,r=n.json,i=r.textures[e];if(!i.extensions||!i.extensions[t])return null;const s=i.extensions[t],o=r.images[s.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return this.detectSupport().then((function(i){if(i)return n.loadTextureImage(e,o,a);if(r.extensionsRequired&&r.extensionsRequired.indexOf(t)>=0)throw new Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return n.loadTexture(e)}))}detectSupport(){return this.isSupported||(this.isSupported=new Promise((function(e){const t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}}))),this.isSupported}}class vv{constructor(e){this.name=ov.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),i=this.parser.options.meshoptDecoder;if(!i||!i.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return Promise.all([r,i.ready]).then((function(t){const n=e.byteOffset||0,r=e.byteLength||0,s=e.count,o=e.byteStride,a=new ArrayBuffer(s*o),l=new Uint8Array(t[0],n,r);return i.decodeGltfBuffer(new Uint8Array(a),s,o,l,e.mode,e.filter),a}))}return null}}const yv="glTF",xv=1313821514,wv=5130562;class bv{constructor(e){this.name=ov.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:Rl.decodeText(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==yv)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,r=new DataView(e,12);let i=0;for(;i<n;){const t=r.getUint32(i,!0);i+=4;const n=r.getUint32(i,!0);if(i+=4,n===xv){const n=new Uint8Array(e,12+i,t);this.content=Rl.decodeText(n)}else if(n===wv){const n=12+i;this.body=e.slice(n,n+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class _v{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=ov.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,i=e.extensions[this.name].bufferView,s=e.extensions[this.name].attributes,o={},a={},l={};for(const e in s){const t=Hv[e]||e.toLowerCase();o[t]=s[e]}for(const t in e.attributes){const r=Hv[t]||t.toLowerCase();if(void 0!==s[t]){const i=n.accessors[e.attributes[t]],s=zv[i.componentType];l[r]=s,a[r]=!0===i.normalized}}return t.getDependency("bufferView",i).then((function(e){return new Promise((function(t){r.decodeDracoFile(e,(function(e){for(const t in e.attributes){const n=e.attributes[t],r=a[t];void 0!==r&&(n.normalized=r)}t(e)}),o,l)}))}))}}class Mv{constructor(){this.name=ov.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return void 0!==t.texCoord&&console.warn('THREE.GLTFLoader: Custom UV sets in "'+this.name+'" extension not yet supported.'),void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.offset&&e.offset.fromArray(t.offset),void 0!==t.rotation&&(e.rotation=t.rotation),void 0!==t.scale&&e.repeat.fromArray(t.scale),e.needsUpdate=!0),e}}class Sv extends Ra{constructor(e){super(),this.isGLTFSpecularGlossinessMaterial=!0;const t=["#ifdef USE_SPECULARMAP","\tuniform sampler2D specularMap;","#endif"].join("\n"),n=["#ifdef USE_GLOSSINESSMAP","\tuniform sampler2D glossinessMap;","#endif"].join("\n"),r=["vec3 specularFactor = specular;","#ifdef USE_SPECULARMAP","\tvec4 texelSpecular = texture2D( specularMap, vUv );","\t// reads channel RGB, compatible with a glTF Specular-Glossiness (RGBA) texture","\tspecularFactor *= texelSpecular.rgb;","#endif"].join("\n"),i=["float glossinessFactor = glossiness;","#ifdef USE_GLOSSINESSMAP","\tvec4 texelGlossiness = texture2D( glossinessMap, vUv );","\t// reads channel A, compatible with a glTF Specular-Glossiness (RGBA) texture","\tglossinessFactor *= texelGlossiness.a;","#endif"].join("\n"),s=["PhysicalMaterial material;","material.diffuseColor = diffuseColor.rgb * ( 1. - max( specularFactor.r, max( specularFactor.g, specularFactor.b ) ) );","vec3 dxy = max( abs( dFdx( geometryNormal ) ), abs( dFdy( geometryNormal ) ) );","float geometryRoughness = max( max( dxy.x, dxy.y ), dxy.z );","material.roughness = max( 1.0 - glossinessFactor, 0.0525 ); // 0.0525 corresponds to the base mip of a 256 cubemap.","material.roughness += geometryRoughness;","material.roughness = min( material.roughness, 1.0 );","material.specularColor = specularFactor;"].join("\n"),o={specular:{value:(new I).setHex(16777215)},glossiness:{value:1},specularMap:{value:null},glossinessMap:{value:null}};this._extraUniforms=o,this.onBeforeCompile=function(e){for(const t in o)e.uniforms[t]=o[t];e.fragmentShader=e.fragmentShader.replace("uniform float roughness;","uniform vec3 specular;").replace("uniform float metalness;","uniform float glossiness;").replace("#include <roughnessmap_pars_fragment>",t).replace("#include <metalnessmap_pars_fragment>",n).replace("#include <roughnessmap_fragment>",r).replace("#include <metalnessmap_fragment>",i).replace("#include <lights_physical_fragment>",s)},Object.defineProperties(this,{specular:{get:function(){return o.specular.value},set:function(e){o.specular.value=e}},specularMap:{get:function(){return o.specularMap.value},set:function(e){o.specularMap.value=e,e?this.defines.USE_SPECULARMAP="":delete this.defines.USE_SPECULARMAP}},glossiness:{get:function(){return o.glossiness.value},set:function(e){o.glossiness.value=e}},glossinessMap:{get:function(){return o.glossinessMap.value},set:function(e){o.glossinessMap.value=e,e?(this.defines.USE_GLOSSINESSMAP="",this.defines.USE_UV=""):(delete this.defines.USE_GLOSSINESSMAP,delete this.defines.USE_UV)}}}),delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this.setValues(e)}copy(e){return super.copy(e),this.specularMap=e.specularMap,this.specular.copy(e.specular),this.glossinessMap=e.glossinessMap,this.glossiness=e.glossiness,delete this.metalness,delete this.roughness,delete this.metalnessMap,delete this.roughnessMap,this}}class Tv{constructor(){this.name=ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS,this.specularGlossinessParams=["color","map","lightMap","lightMapIntensity","aoMap","aoMapIntensity","emissive","emissiveIntensity","emissiveMap","bumpMap","bumpScale","normalMap","normalMapType","displacementMap","displacementScale","displacementBias","specularMap","specular","glossinessMap","glossiness","alphaMap","envMap","envMapIntensity"]}getMaterialType(){return Sv}extendParams(e,t,n){const r=t.extensions[this.name];e.color=new I(1,1,1),e.opacity=1;const i=[];if(Array.isArray(r.diffuseFactor)){const t=r.diffuseFactor;e.color.fromArray(t),e.opacity=t[3]}if(void 0!==r.diffuseTexture&&i.push(n.assignTexture(e,"map",r.diffuseTexture,3001)),e.emissive=new I(0,0,0),e.glossiness=void 0!==r.glossinessFactor?r.glossinessFactor:1,e.specular=new I(1,1,1),Array.isArray(r.specularFactor)&&e.specular.fromArray(r.specularFactor),void 0!==r.specularGlossinessTexture){const t=r.specularGlossinessTexture;i.push(n.assignTexture(e,"glossinessMap",t)),i.push(n.assignTexture(e,"specularMap",t,3001))}return Promise.all(i)}createMaterial(e){const t=new Sv(e);return t.fog=!0,t.color=e.color,t.map=void 0===e.map?null:e.map,t.lightMap=null,t.lightMapIntensity=1,t.aoMap=void 0===e.aoMap?null:e.aoMap,t.aoMapIntensity=1,t.emissive=e.emissive,t.emissiveIntensity=1,t.emissiveMap=void 0===e.emissiveMap?null:e.emissiveMap,t.bumpMap=void 0===e.bumpMap?null:e.bumpMap,t.bumpScale=1,t.normalMap=void 0===e.normalMap?null:e.normalMap,t.normalMapType=0,e.normalScale&&(t.normalScale=e.normalScale),t.displacementMap=null,t.displacementScale=1,t.displacementBias=0,t.specularMap=void 0===e.specularMap?null:e.specularMap,t.specular=e.specular,t.glossinessMap=void 0===e.glossinessMap?null:e.glossinessMap,t.glossiness=e.glossiness,t.alphaMap=null,t.envMap=void 0===e.envMap?null:e.envMap,t.envMapIntensity=1,t}}class Ev{constructor(){this.name=ov.KHR_MESH_QUANTIZATION}}class Av extends Fa{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,i=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[i+e];return t}}Av.prototype.beforeStart_=Av.prototype.copySampleValue_,Av.prototype.afterEnd_=Av.prototype.copySampleValue_,Av.prototype.interpolate_=function(e,t,n,r){const i=this.resultBuffer,s=this.sampleValues,o=this.valueSize,a=2*o,l=3*o,c=r-t,h=(n-t)/c,u=h*h,d=u*h,p=e*l,f=p-l,m=-2*d+3*u,g=d-u,v=1-m,y=g-u+h;for(let e=0;e!==o;e++){const t=s[f+e+o],n=s[f+e+a]*c,r=s[p+e+o],l=s[p+e]*c;i[e]=v*t+y*n+m*r+g*l}return i};const Cv=new X;class Pv extends Av{interpolate_(e,t,n,r){const i=super.interpolate_(e,t,n,r);return Cv.fromArray(i).normalize().toArray(i),i}}const Rv=0,Lv=1,Iv=2,Dv=3,Ov=4,Bv=5,Nv=6,zv={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Uv={9728:1003,9729:1006,9984:1004,9985:1007,9986:1005,9987:1008},kv={33071:1001,33648:1002,10497:1e3},Fv={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Hv={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv2",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Gv={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},jv={CUBICSPLINE:void 0,LINEAR:2301,STEP:2300},Vv="OPAQUE",Wv="MASK",Xv="BLEND";function qv(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new Ra({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:0})),e.DefaultMaterial}function Yv(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function Zv(e,t){void 0!==t.extras&&("object"==typeof t.extras?Object.assign(e.userData,t.extras):console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, "+t.extras))}function Jv(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}function Qv(e){const t=e.extensions&&e.extensions[ov.KHR_DRACO_MESH_COMPRESSION];let n;return n=t?"draco:"+t.bufferView+":"+t.indices+":"+Kv(t.attributes):e.indices+":"+Kv(e.attributes)+":"+e.mode,n}function Kv(e){let t="";const n=Object.keys(e).sort();for(let r=0,i=n.length;r<i;r++)t+=n[r]+":"+e[n[r]]+";";return t}function $v(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}class ey{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new sv,this.associations=new Map,this.primitiveCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={},"undefined"!=typeof createImageBitmap&&!1===/^((?!chrome|android).)*safari/i.test(navigator.userAgent)?this.textureLoader=new Nl(this.options.manager):this.textureLoader=new cl(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new sl(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,i=this.extensions;this.cache.removeAll(),this._invokeAll((function(e){return e._markDefs&&e._markDefs()})),Promise.all(this._invokeAll((function(e){return e.beforeRoot&&e.beforeRoot()}))).then((function(){return Promise.all([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])})).then((function(t){const s={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};Yv(i,s,r),Zv(s,r),Promise.all(n._invokeAll((function(e){return e.afterRoot&&e.afterRoot(s)}))).then((function(){e(s)}))})).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),i=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())i(r,t.children[n])};return i(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const i=e(t[r]);i&&n.push(i)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this.loadNode(t);break;case"mesh":r=this._invokeOne((function(e){return e.loadMesh&&e.loadMesh(t)}));break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne((function(e){return e.loadBufferView&&e.loadBufferView(t)}));break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne((function(e){return e.loadMaterial&&e.loadMaterial(t)}));break;case"texture":r=this._invokeOne((function(e){return e.loadTexture&&e.loadTexture(t)}));break;case"skin":r=this.loadSkin(t);break;case"animation":r=this.loadAnimation(t);break;case"camera":r=this.loadCamera(t);break;default:throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map((function(t,r){return n.getDependency(e,r)}))),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[ov.KHR_BINARY_GLTF].body);const r=this.options;return new Promise((function(e,i){n.load(Rl.resolveURL(t.uri,r.path),e,void 0,(function(){i(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))}))}))}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then((function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)}))}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse)return Promise.resolve(null);const i=[];return void 0!==r.bufferView?i.push(this.getDependency("bufferView",r.bufferView)):i.push(null),void 0!==r.sparse&&(i.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(i).then((function(e){const i=e[0],s=Fv[r.type],o=zv[r.componentType],a=o.BYTES_PER_ELEMENT,l=a*s,c=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,u=!0===r.normalized;let d,p;if(h&&h!==l){const e=Math.floor(c/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let l=t.cache.get(n);l||(d=new o(i,e*h,r.count*h/a),l=new Qi(d,h/a),t.cache.add(n,l)),p=new $i(l,s,c%h/a,u)}else d=null===i?new o(r.count*s):new o(i,c,r.count*s),p=new dt(d,s,u);if(void 0!==r.sparse){const t=Fv.SCALAR,n=zv[r.sparse.indices.componentType],a=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,c=new n(e[1],a,r.sparse.count*t),h=new o(e[2],l,r.sparse.count*s);null!==i&&(p=new dt(p.array.slice(),p.itemSize,p.normalized));for(let e=0,t=c.length;e<t;e++){const t=c[e];if(p.setX(t,h[e*s]),s>=2&&p.setY(t,h[e*s+1]),s>=3&&p.setZ(t,h[e*s+2]),s>=4&&p.setW(t,h[e*s+3]),s>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return p}))}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,i=t.images[r];let s=this.textureLoader;if(i.uri){const e=n.manager.getHandler(i.uri);null!==e&&(s=e)}return this.loadTextureImage(e,r,s)}loadTextureImage(e,t,n){const r=this,i=this.json,s=i.textures[e],o=i.images[t],a=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[a])return this.textureCache[a];const l=this.loadImageSource(t,n).then((function(t){t.flipY=!1,s.name&&(t.name=s.name);const n=(i.samplers||{})[s.sampler]||{};return t.magFilter=Uv[n.magFilter]||1006,t.minFilter=Uv[n.minFilter]||1008,t.wrapS=kv[n.wrapS]||1e3,t.wrapT=kv[n.wrapT]||1e3,r.associations.set(t,{textures:e}),t})).catch((function(){return null}));return this.textureCache[a]=l,l}loadImageSource(e,t){const n=this,r=this.json,i=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then((e=>e.clone()));const s=r.images[e],o=self.URL||self.webkitURL;let a=s.uri||"",l=!1;if(void 0!==s.bufferView)a=n.getDependency("bufferView",s.bufferView).then((function(e){l=!0;const t=new Blob([e],{type:s.mimeType});return a=o.createObjectURL(t),a}));else if(void 0===s.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const c=Promise.resolve(a).then((function(e){return new Promise((function(n,r){let s=n;!0===t.isImageBitmapLoader&&(s=function(e){const t=new U(e);t.needsUpdate=!0,n(t)}),t.load(Rl.resolveURL(e,i.path),s,void 0,r)}))})).then((function(e){var t;return!0===l&&o.revokeObjectURL(a),e.userData.mimeType=s.mimeType||((t=s.uri).search(/\.jpe?g($|\?)/i)>0||0===t.search(/^data\:image\/jpeg/)?"image/jpeg":t.search(/\.webp($|\?)/i)>0||0===t.search(/^data\:image\/webp/)?"image/webp":"image/png"),e})).catch((function(e){throw console.error("THREE.GLTFLoader: Couldn't load texture",a),e}));return this.sourceCache[e]=c,c}assignTexture(e,t,n,r){const i=this;return this.getDependency("texture",n.index).then((function(s){if(void 0===n.texCoord||0==n.texCoord||"aoMap"===t&&1==n.texCoord||console.warn("THREE.GLTFLoader: Custom UV set "+n.texCoord+" for texture "+t+" not yet supported."),i.extensions[ov.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[ov.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=i.associations.get(s);s=i.extensions[ov.KHR_TEXTURE_TRANSFORM].extendTexture(s,e),i.associations.set(s,t)}}return void 0!==r&&(s.encoding=r),e[t]=s,s}))}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new qs,lt.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new Ns,lt.prototype.copy.call(t,n),t.color.copy(n.color),this.cache.add(e,t)),n=t}if(r||i||s){let e="ClonedMaterial:"+n.uuid+":";n.isGLTFSpecularGlossinessMaterial&&(e+="specular-glossiness:"),r&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),i&&(t.vertexColors=!0),s&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}n.aoMap&&void 0===t.attributes.uv2&&void 0!==t.attributes.uv&&t.setAttribute("uv2",t.attributes.uv),e.material=n}getMaterialType(){return Ra}loadMaterial(e){const t=this,n=this.json,r=this.extensions,i=n.materials[e];let s;const o={},a=i.extensions||{},l=[];if(a[ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS]){const e=r[ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS];s=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else if(a[ov.KHR_MATERIALS_UNLIT]){const e=r[ov.KHR_MATERIALS_UNLIT];s=e.getMaterialType(),l.push(e.extendParams(o,i,t))}else{const n=i.pbrMetallicRoughness||{};if(o.color=new I(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.fromArray(e),o.opacity=e[3]}void 0!==n.baseColorTexture&&l.push(t.assignTexture(o,"map",n.baseColorTexture,3001)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(l.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),l.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),s=this._invokeOne((function(t){return t.getMaterialType&&t.getMaterialType(e)})),l.push(Promise.all(this._invokeAll((function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)}))))}!0===i.doubleSided&&(o.side=2);const c=i.alphaMode||Vv;if(c===Xv?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===Wv&&(o.alphaTest=void 0!==i.alphaCutoff?i.alphaCutoff:.5)),void 0!==i.normalTexture&&s!==ct&&(l.push(t.assignTexture(o,"normalMap",i.normalTexture)),o.normalScale=new g(1,1),void 0!==i.normalTexture.scale)){const e=i.normalTexture.scale;o.normalScale.set(e,e)}return void 0!==i.occlusionTexture&&s!==ct&&(l.push(t.assignTexture(o,"aoMap",i.occlusionTexture)),void 0!==i.occlusionTexture.strength&&(o.aoMapIntensity=i.occlusionTexture.strength)),void 0!==i.emissiveFactor&&s!==ct&&(o.emissive=(new I).fromArray(i.emissiveFactor)),void 0!==i.emissiveTexture&&s!==ct&&l.push(t.assignTexture(o,"emissiveMap",i.emissiveTexture,3001)),Promise.all(l).then((function(){let n;return n=s===Sv?r[ov.KHR_MATERIALS_PBR_SPECULAR_GLOSSINESS].createMaterial(o):new s(o),i.name&&(n.name=i.name),Zv(n,i),t.associations.set(n,{materials:e}),i.extensions&&Yv(r,n,i),n}))}createUniqueName(e){const t=dc.sanitizeNodeName(e||"");let n=t;for(let e=1;this.nodeNamesUsed[n];++e)n=t+"_"+e;return this.nodeNamesUsed[n]=!0,n}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function i(e){return n[ov.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then((function(n){return ny(n,e,t)}))}const s=[];for(let n=0,o=e.length;n<o;n++){const o=e[n],a=Qv(o),l=r[a];if(l)s.push(l.promise);else{let e;e=o.extensions&&o.extensions[ov.KHR_DRACO_MESH_COMPRESSION]?i(o):ny(new Rt,o,t),r[a]={primitive:o,promise:e},s.push(e)}}return Promise.all(s)}loadMesh(e){const t=this,n=this.json,r=this.extensions,i=n.meshes[e],s=i.primitives,o=[];for(let e=0,t=s.length;e<t;e++){const t=void 0===s[e].material?qv(this.cache):this.getDependency("material",s[e].material);o.push(t)}return o.push(t.loadGeometries(s)),Promise.all(o).then((function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],l=[];for(let n=0,c=a.length;n<c;n++){const c=a[n],h=s[n];let u;const d=o[n];if(h.mode===Ov||h.mode===Bv||h.mode===Nv||void 0===h.mode)u=!0===i.isSkinnedMesh?new Ss(c,d):new Yt(c,d),!0!==u.isSkinnedMesh||u.geometry.attributes.skinWeight.normalized||u.normalizeSkinWeights(),h.mode===Bv?u.geometry=ry(u.geometry,1):h.mode===Nv&&(u.geometry=ry(u.geometry,2));else if(h.mode===Lv)u=new Ws(c,d);else if(h.mode===Dv)u=new Gs(c,d);else if(h.mode===Iv)u=new Xs(c,d);else{if(h.mode!==Rv)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+h.mode);u=new Ks(c,d)}Object.keys(u.geometry.morphAttributes).length>0&&Jv(u,i),u.name=t.createUniqueName(i.name||"mesh_"+e),Zv(u,i),h.extensions&&Yv(r,u,h),t.assignFinalMaterial(u),l.push(u)}for(let n=0,r=l.length;n<r;n++)t.associations.set(l[n],{meshes:e,primitives:n});if(1===l.length)return l[0];const c=new Fi;t.associations.set(c,{meshes:e});for(let e=0,t=l.length;e<t;e++)c.add(l[e]);return c}))}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new nn(m.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new En(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),Zv(t,n),Promise.resolve(t);console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){const t=this.json.skins[e],n={joints:t.joints};return void 0===t.inverseBindMatrices?Promise.resolve(n):this.getDependency("accessor",t.inverseBindMatrices).then((function(e){return n.inverseBindMatrices=e,n}))}loadAnimation(e){const t=this.json.animations[e],n=[],r=[],i=[],s=[],o=[];for(let e=0,a=t.channels.length;e<a;e++){const a=t.channels[e],l=t.samplers[a.sampler],c=a.target,h=void 0!==c.node?c.node:c.id,u=void 0!==t.parameters?t.parameters[l.input]:l.input,d=void 0!==t.parameters?t.parameters[l.output]:l.output;n.push(this.getDependency("node",h)),r.push(this.getDependency("accessor",u)),i.push(this.getDependency("accessor",d)),s.push(l),o.push(c)}return Promise.all([Promise.all(n),Promise.all(r),Promise.all(i),Promise.all(s),Promise.all(o)]).then((function(n){const r=n[0],i=n[1],s=n[2],o=n[3],a=n[4],l=[];for(let e=0,t=r.length;e<t;e++){const t=r[e],n=i[e],c=s[e],h=o[e],u=a[e];if(void 0===t)continue;let d;switch(t.updateMatrix(),t.matrixAutoUpdate=!0,Gv[u.path]){case Gv.weights:d=qa;break;case Gv.rotation:d=Za;break;case Gv.position:case Gv.scale:default:d=Qa}const p=t.name?t.name:t.uuid,f=void 0!==h.interpolation?jv[h.interpolation]:2301,m=[];Gv[u.path]===Gv.weights?t.traverse((function(e){e.morphTargetInfluences&&m.push(e.name?e.name:e.uuid)})):m.push(p);let g=c.array;if(c.normalized){const e=$v(g.constructor),t=new Float32Array(g.length);for(let n=0,r=g.length;n<r;n++)t[n]=g[n]*e;g=t}for(let e=0,t=m.length;e<t;e++){const t=new d(m[e]+"."+Gv[u.path],n.array,g,f);"CUBICSPLINE"===h.interpolation&&(t.createInterpolant=function(e){return new(this instanceof Za?Pv:Av)(this.times,this.values,this.getValueSize()/3,e)},t.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0),l.push(t)}}const c=t.name?t.name:"animation_"+e;return new Ka(c,void 0,l)}))}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then((function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse((function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]})),t}))}loadNode(e){const t=this.json,n=this.extensions,r=this,i=t.nodes[e],s=i.name?r.createUniqueName(i.name):"";return function(){const t=[],n=r._invokeOne((function(t){return t.createNodeMesh&&t.createNodeMesh(e)}));return n&&t.push(n),void 0!==i.camera&&t.push(r.getDependency("camera",i.camera).then((function(e){return r._getNodeRef(r.cameraCache,i.camera,e)}))),r._invokeAll((function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)})).forEach((function(e){t.push(e)})),Promise.all(t)}().then((function(t){let o;if(o=!0===i.isBone?new Ts:t.length>1?new Fi:1===t.length?t[0]:new Ze,o!==t[0])for(let e=0,n=t.length;e<n;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=s),Zv(o,i),i.extensions&&Yv(n,o,i),void 0!==i.matrix){const e=new Se;e.fromArray(i.matrix),o.applyMatrix4(e)}else void 0!==i.translation&&o.position.fromArray(i.translation),void 0!==i.rotation&&o.quaternion.fromArray(i.rotation),void 0!==i.scale&&o.scale.fromArray(i.scale);return r.associations.has(o)||r.associations.set(o,{}),r.associations.get(o).nodes=e,o}))}loadScene(e){const t=this.json,n=this.extensions,r=this.json.scenes[e],i=this,s=new Fi;r.name&&(s.name=i.createUniqueName(r.name)),Zv(s,r),r.extensions&&Yv(n,s,r);const o=r.nodes||[],a=[];for(let e=0,n=o.length;e<n;e++)a.push(ty(o[e],s,t,i));return Promise.all(a).then((function(){return i.associations=(e=>{const t=new Map;for(const[e,n]of i.associations)(e instanceof lt||e instanceof U)&&t.set(e,n);return e.traverse((e=>{const n=i.associations.get(e);null!=n&&t.set(e,n)})),t})(s),s}))}}function ty(e,t,n,r){const i=n.nodes[e];return r.getDependency("node",e).then((function(e){if(void 0===i.skin)return e;let t;return r.getDependency("skin",i.skin).then((function(e){t=e;const n=[];for(let e=0,i=t.joints.length;e<i;e++)n.push(r.getDependency("node",t.joints[e]));return Promise.all(n)})).then((function(n){return e.traverse((function(e){if(!e.isMesh)return;const r=[],i=[];for(let e=0,s=n.length;e<s;e++){const s=n[e];if(s){r.push(s);const n=new Se;void 0!==t.inverseBindMatrices&&n.fromArray(t.inverseBindMatrices.array,16*e),i.push(n)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[e])}e.bind(new Ps(r,i),e.matrixWorld)})),e}))})).then((function(e){t.add(e);const s=[];if(i.children){const t=i.children;for(let i=0,o=t.length;i<o;i++){const o=t[i];s.push(ty(o,e,n,r))}}return Promise.all(s)}))}function ny(e,t,n){const r=t.attributes,i=[];function s(t,r){return n.getDependency("accessor",t).then((function(t){e.setAttribute(r,t)}))}for(const t in r){const n=Hv[t]||t.toLowerCase();n in e.attributes||i.push(s(r[t],n))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then((function(t){e.setIndex(t)}));i.push(r)}return Zv(e,t),function(e,t,n){const r=t.attributes,i=new J;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return void console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new q(t[0],t[1],t[2]),new q(s[0],s[1],s[2])),e.normalized){const t=$v(zv[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}const s=t.targets;if(void 0!==s){const e=new q,t=new q;for(let r=0,i=s.length;r<i;r++){const i=s[r];if(void 0!==i.POSITION){const r=n.json.accessors[i.POSITION],s=r.min,o=r.max;if(void 0!==s&&void 0!==o){if(t.setX(Math.max(Math.abs(s[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(s[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(s[2]),Math.abs(o[2]))),r.normalized){const e=$v(zv[r.componentType]);t.multiplyScalar(e)}e.max(t)}else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.")}}i.expandByVector(e)}e.boundingBox=i;const o=new me;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(i).then((function(){return void 0!==t.targets?function(e,t,n){let r=!1,i=!1,s=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(i=!0),void 0!==n.COLOR_0&&(s=!0),r&&i&&s)break}if(!r&&!i&&!s)return Promise.resolve(e);const o=[],a=[],l=[];for(let c=0,h=t.length;c<h;c++){const h=t[c];if(r){const t=void 0!==h.POSITION?n.getDependency("accessor",h.POSITION):e.attributes.position;o.push(t)}if(i){const t=void 0!==h.NORMAL?n.getDependency("accessor",h.NORMAL):e.attributes.normal;a.push(t)}if(s){const t=void 0!==h.COLOR_0?n.getDependency("accessor",h.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(l)]).then((function(t){const n=t[0],o=t[1],a=t[2];return r&&(e.morphAttributes.position=n),i&&(e.morphAttributes.normal=o),s&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e}))}(e,t.targets,n):e}))}function ry(e,t){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."),e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,i=[];if(2===t)for(let e=1;e<=r;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(i.push(n.getX(e)),i.push(n.getX(e+1)),i.push(n.getX(e+2))):(i.push(n.getX(e+2)),i.push(n.getX(e+1)),i.push(n.getX(e)));i.length/3!==r&&console.error("THREE.GLTFLoader.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");const s=e.clone();return s.setIndex(i),s}const iy=new WeakMap;class sy extends rl{constructor(e){super(e),this.decoderPath="",this.decoderConfig={},this.decoderBinary=null,this.decoderPending=null,this.workerLimit=4,this.workerPool=[],this.workerNextTaskID=1,this.workerSourceURL="",this.defaultAttributeIDs={position:"POSITION",normal:"NORMAL",color:"COLOR",uv:"TEX_COORD"},this.defaultAttributeTypes={position:"Float32Array",normal:"Float32Array",color:"Float32Array",uv:"Float32Array"}}setDecoderPath(e){return this.decoderPath=e,this}setDecoderConfig(e){return this.decoderConfig=e,this}setWorkerLimit(e){return this.workerLimit=e,this}load(e,t,n,r){const i=new sl(this.manager);i.setPath(this.path),i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setWithCredentials(this.withCredentials),i.load(e,(e=>{const n={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,n).then(t).catch(r)}),n,r)}decodeDracoFile(e,t,n,r){const i={attributeIDs:n||this.defaultAttributeIDs,attributeTypes:r||this.defaultAttributeTypes,useUniqueIDs:!!n};this.decodeGeometry(e,i).then(t)}decodeGeometry(e,t){for(const e in t.attributeTypes){const n=t.attributeTypes[e];void 0!==n.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=n.name)}const n=JSON.stringify(t);if(iy.has(e)){const t=iy.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw new Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let r;const i=this.workerNextTaskID++,s=e.byteLength,o=this._getWorker(i,s).then((n=>(r=n,new Promise(((n,s)=>{r._callbacks[i]={resolve:n,reject:s},r.postMessage({type:"decode",id:i,taskConfig:t,buffer:e},[e])}))))).then((e=>this._createGeometry(e.geometry)));return o.catch((()=>!0)).then((()=>{r&&i&&this._releaseTask(r,i)})),iy.set(e,{key:n,promise:o}),o}_createGeometry(e){const t=new Rt;e.index&&t.setIndex(new dt(e.index.array,1));for(let n=0;n<e.attributes.length;n++){const r=e.attributes[n],i=r.name,s=r.array,o=r.itemSize;t.setAttribute(i,new dt(s,o))}return t}_loadLibrary(e,t){const n=new sl(this.manager);return n.setPath(this.decoderPath),n.setResponseType(t),n.setWithCredentials(this.withCredentials),new Promise(((t,r)=>{n.load(e,t,void 0,r)}))}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;const e="object"!=typeof WebAssembly||"js"===this.decoderConfig.type,t=[];return e?t.push(this._loadLibrary("draco_decoder.js","text")):(t.push(this._loadLibrary("draco_wasm_wrapper.js","text")),t.push(this._loadLibrary("draco_decoder.wasm","arraybuffer"))),this.decoderPending=Promise.all(t).then((t=>{const n=t[0];e||(this.decoderConfig.wasmBinary=t[1]);const r=oy.toString(),i=["/* draco decoder */",n,"","/* worker */",r.substring(r.indexOf("{")+1,r.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([i]))})),this.decoderPending}_getWorker(e,t){return this._initDecoder().then((()=>{if(this.workerPool.length<this.workerLimit){const e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){const n=t.data;switch(n.type){case"decode":e._callbacks[n.id].resolve(n);break;case"error":e._callbacks[n.id].reject(n);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+n.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort((function(e,t){return e._taskLoad>t._taskLoad?-1:1}));const n=this.workerPool[this.workerPool.length-1];return n._taskCosts[e]=t,n._taskLoad+=t,n}))}_releaseTask(e,t){e._taskLoad-=e._taskCosts[t],delete e._callbacks[t],delete e._taskCosts[t]}debug(){console.log("Task load: ",this.workerPool.map((e=>e._taskLoad)))}dispose(){for(let e=0;e<this.workerPool.length;++e)this.workerPool[e].terminate();return this.workerPool.length=0,this}}function oy(){let e,t;function n(e,t,n,r,i,s){const o=s.num_components(),a=n.num_points()*o,l=a*i.BYTES_PER_ELEMENT,c=function(e,t){switch(t){case Float32Array:return e.DT_FLOAT32;case Int8Array:return e.DT_INT8;case Int16Array:return e.DT_INT16;case Int32Array:return e.DT_INT32;case Uint8Array:return e.DT_UINT8;case Uint16Array:return e.DT_UINT16;case Uint32Array:return e.DT_UINT32}}(e,i),h=e._malloc(l);t.GetAttributeDataArrayForAllPoints(n,s,c,l,h);const u=new i(e.HEAPF32.buffer,h,a).slice();return e._free(h),{name:r,array:u,itemSize:o}}onmessage=function(r){const i=r.data;switch(i.type){case"init":e=i.decoderConfig,t=new Promise((function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)}));break;case"decode":const r=i.buffer,s=i.taskConfig;t.then((e=>{const t=e.draco,o=new t.Decoder,a=new t.DecoderBuffer;a.Init(new Int8Array(r),r.byteLength);try{const e=function(e,t,r,i){const s=i.attributeIDs,o=i.attributeTypes;let a,l;const c=t.GetEncodedGeometryType(r);if(c===e.TRIANGULAR_MESH)a=new e.Mesh,l=t.DecodeBufferToMesh(r,a);else{if(c!==e.POINT_CLOUD)throw new Error("THREE.DRACOLoader: Unexpected geometry type.");a=new e.PointCloud,l=t.DecodeBufferToPointCloud(r,a)}if(!l.ok()||0===a.ptr)throw new Error("THREE.DRACOLoader: Decoding failed: "+l.error_msg());const h={index:null,attributes:[]};for(const r in s){const l=self[o[r]];let c,u;if(i.useUniqueIDs)u=s[r],c=t.GetAttributeByUniqueId(a,u);else{if(u=t.GetAttributeId(a,e[s[r]]),-1===u)continue;c=t.GetAttribute(a,u)}h.attributes.push(n(e,t,a,r,l,c))}c===e.TRIANGULAR_MESH&&(h.index=function(e,t,n){const r=3*n.num_faces(),i=4*r,s=e._malloc(i);t.GetTrianglesUInt32Array(n,i,s);const o=new Uint32Array(e.HEAPF32.buffer,s,r).slice();return e._free(s),{array:o,itemSize:1}}(e,t,a));return e.destroy(a),h}(t,o,a,s),r=e.attributes.map((e=>e.array.buffer));e.index&&r.push(e.index.array.buffer),self.postMessage({type:"decode",id:i.id,geometry:e},r)}catch(e){console.error(e),self.postMessage({type:"error",id:i.id,error:e.message})}finally{t.destroy(a),t.destroy(o)}}))}}}class ay extends nf{constructor(e){super("Model",e),this.viewport=e,this.gltfLoader=null,this.fbxLoader=null,this.modelMaps=new Map,this.store=of.createInstance({name:"soonspace",storeName:"modelData"}),this.dracoDecoderPath=null}setDracoDecoderPath(e){this.dracoDecoderPath=e}load(e){return this._loadItem(e)}parse(e,t,n){return new Promise(((r,i)=>{const s=new Fp(Object.assign({format:e},n)),o=new tl;o.addHandler(/\.tga$/i,new rv);const{url:a}=n,l=e.toLocaleUpperCase(),c=a.substring(0,a.lastIndexOf("/")+1);if("GLTF"===l||"GLB"===l||"SBMX"===l){if(this.gltfLoader||(this.gltfLoader=new iv(o)),this.dracoDecoderPath&&!this.gltfLoader.dracoLoader){const e=new sy;e.setDecoderPath(this.dracoDecoderPath),this.gltfLoader.setDRACOLoader(e)}this.gltfLoader.parse(t,c,(e=>{const{animations:t}=e;if(t&&t.length>0&&(s.animations=t),e.scene.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0})),s.add(e.scene),!this.modelMaps.get(a)){const e=s.sClone();this.modelMaps.set(a,e)}r(s)}),(e=>{i(e)}))}else if("FBX"===l){this.fbxLoader||(this.fbxLoader=new Ug(o));const e=this.fbxLoader.parse(t,c),{animations:n}=e;if(n&&n.length>0&&(s.animations=n),e.traverse((e=>{"AmbientLight"!==e.type&&"DirectionalLight"!==e.type||(e.visible=!1),e.castShadow=!0,e.receiveShadow=!0})),s.add(e),!this.modelMaps.get(a)){const e=s.sClone();this.modelMaps.set(a,e)}r(s)}else i(`In soonspacejs: 加载通用模型资源(id:${n.id}, url:${a})格式错误,当前支持 fbx、gltf、glb !`)}))}clone(e,t,n){return new Promise(((r,i)=>sd(this,void 0,void 0,(function*(){"Model"!==e.stype&&i("In soonspacejs: 方法 cloneModel 参入对象类型错误!");const{id:s,name:o,level:a,visible:l,position:c,rotation:h,scale:u,onClick:d,onDblClick:p,onRightClick:f,onLoad:m,userData:g}=t;function v(e,t,n){n(e,t);for(let r=0;r<e.children.length;r++)v(e.children[r],t.children[r],n)}const y=yield function(e){const t=new Map,n=new Map;let r;return r=e instanceof Iu||e instanceof Lu?e.sClone():e.clone(),v(e,r,(function(e,r){t.set(r,e),n.set(e,r)})),r.traverse((function(e){if(e instanceof Ss){const r=e,i=t.get(e),s=i.skeleton.bones;r.skeleton=i.skeleton.clone(),r.bindMatrix.copy(i.bindMatrix),r.skeleton.bones=s.map((function(e){return n.get(e)})),r.bind(r.skeleton,r.bindMatrix)}})),r}(e);y.animations=yield y.animations.map((e=>e.clone())),yield this._copyMaterial(y),s&&(y.sid=s),o&&(y.name=o),a&&(y.level=a),!1===l&&y.hide(),c&&y.position.set(c.x,c.y,c.z),h&&y.rotation.set(h.x,h.y,h.z),u&&y.scale.set(u.x,u.y,u.z),y.onClick=d?d.bind(y):null,y.onDblClick=p?p.bind(y):null,y.onRightClick=f?f.bind(y):null,y.onLoad=m?m.bind(y):null,y.onLoad&&y.onLoad(y),g&&(y.userData=g),null!==n&&this.viewport.scener.addObject(y,n||e.parent||this.scene),r(y)}))))}loadToGroup(e,t){return sd(this,void 0,void 0,(function*(){const n=new Ou(e);for(let e=0;e<t.length;e++)try{const r=yield this._loadItem(t[e],null);n.add(r)}catch(e){console.error(e)}return this.viewport.scener.addObject(n,this.scene),n}))}addForGroup(e,t){return sd(this,void 0,void 0,(function*(){const n=this.getGroupById(e);if(n)for(let e=0;e<t.length;e++)try{const r=yield this._loadItem(t[e],null);this.viewport.scener.addObject(r,n)}catch(e){console.error(e)}return n}))}clearIdb(){return this.store.clear()}_loadItem(e,t=this.scene){var n;return sd(this,void 0,void 0,(function*(){const{url:r}=e,{useIndexedDB:i}=this.viewport.options,s=r.slice(r.lastIndexOf(".")+1),o=this.modelMaps.get(r);let a=null;if(o)return this.clone(o,e,t);i&&(a=yield this.store.getItem(r)),a||(a=yield this._fetchBuffer(e));const l=yield this.parse(s,a,e);return null===(n=l.onLoad)||void 0===n||n.call(l,l),null!==t&&this.viewport.scener.addObject(l,t||this.scene),l}))}_fetchBuffer(e){const{url:t}=e,{useIndexedDB:n}=this.viewport.options;return fetch(t).then((e=>e.arrayBuffer())).then((e=>(n&&(nu(t)&&(e=ru(e)),this.store.setItem(t,e)),e)))}_copyMaterial(e){e.traverse((e=>{e instanceof Yt&&(lu(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof lt&&(e.material=e.material.clone()))}))}}class ly extends nf{constructor(e){super("Poi",e),this.materials=new Map}create(e){const t=this._createMaterial(e.url),n=new jp(t,e);return this.viewport.scener.addObject(n,this.scene),n}clone(e,t,n){"Poi"!==e.stype&&console.error("In soonspacejs: 方法 clonePoi 参入对象类型错误!");const{id:r,name:i,level:s,visible:o,position:a,rotation:l,scale:c,onClick:h,onDblClick:u,onRightClick:d,userData:p}=t,f=e.sClone();return this._copyMaterial(f),r&&(f.sid=r),i&&(f.name=i),s&&(f.level=s),ou(o)&&(f.visible=o),a&&f.position.set(a.x,a.y,a.z),l&&f.rotation.set(l.x,l.y,l.z),c&&f.scale.set(c.x,c.y,c.z),f.onClick=h?h.bind(f):null,f.onDblClick=u?u.bind(f):null,f.onRightClick=d?d.bind(f):null,p&&(f.userData=p),null!==n&&this.viewport.scener.addObject(f,n||this.scene||e.parent),f}createToGroup(e,t){const n=new Ou(e);return t.forEach((e=>{const t=this._createMaterial(e.url),r=new jp(t,e);n.add(r)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getGroupById(e);return n&&(t.forEach((e=>{const t=this._createMaterial(e.url),r=new jp(t,e);n.add(r)})),this.viewport.scener.addObject(n,this.scene)),n}_createMaterial(e){const t=this.materials.get(e);if(!t){const t=(new cl).load(e);t.flipY=!0;const n=new es({map:t,color:16777215});return this.materials.set(e,n),n}return t}_copyMaterial(e){e.traverse((e=>{(e instanceof Yt||e instanceof fs)&&(lu(e.material)?e.material=e.material.map((e=>e.clone())):e.material instanceof lt&&(e.material=e.material.clone()))}))}}class cy extends nf{constructor(e){super("PoiNode",e)}create(e){this._openEnableRenderCss(e);const t=new id(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=new Ou(e);return t.forEach((e=>{this._openEnableRenderCss(e);const t=new id(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getGroupById(e);return n&&(t.forEach((e=>{const t=new id(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene)),n}_openEnableRenderCss(e){switch(e.type){case"2d":case"2D":this.viewport.rendererManager.setInternalState("enableRenderCss2D",!0);break;case"2.5d":case"2.5D":this.viewport.rendererManager.setInternalState("enableRenderCss2DHalf",!0);break;case"3d":case"3D":this.viewport.rendererManager.setInternalState("enableRenderCss3D",!0)}}}class hy extends nf{constructor(e){super("Canvas3D",e)}create(e){const t=new $p(e);return this.viewport.scener.addObject(t,this.scene),t}createToGroup(e,t){const n=new Ou(e);return t.forEach((e=>{const t=new $p(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getGroupById(e);return n&&(t.forEach((e=>{const t=new $p(e);n.add(t)})),this.viewport.scener.addObject(n,this.scene)),n}}class uy{constructor(){this.graph=[],this.queue=null,this.distance=[],this.previous=[]}setGraph(e){if(!lu(e))return console.error("In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph isn't an array )");if(!(e.length<1))for(let t=0;t<e.length;t++){const n=e[t];if(2!==n.length)return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra setGraph method graph item must be an array and contain 2 values [name, vertices], Failed at index: ${t} )`);const r=n[0],i=n[1];this.graph[r]=[];for(let e=0;e<i.length;e++){const t=i[e],n=t[0],s=t[1];this.graph[r][n]=s}}}getPath(e,t){if(void 0===this.graph[e])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method source ${e} doesn't exist )`),[];if(void 0===this.graph[t])return console.error(`In soonspacejs: 内容错误 - 路径计算! ( dijkstra getPath method target ${t} doesn't exist )`),[];if(e===t)return[];let n;for(this.queue=new eu,this.queue.add(e,0),this.previous[e]=null;n=this.queue.shift();){if(n===t){const e=[];for(;au(n)&&null!==this.previous[n];)e.unshift(n),n=this.previous[n];return e}const e=this.queue.getDistance(n);if(e===1/0)return[];for(const t in this.graph[n]){const r=this.queue.getDistance(Number(t)),i=e+this.graph[n][t];i<r&&(this.queue.update(Number(t),i),this.previous[t]=n)}}return[]}}class dy extends nf{constructor(e){super("Topology",e),this.dijkstra=new uy}createFromGml(e){const{url:t,linkWidth:n=20,linkColor:r=65280,renderNode:i=!0,nodeColor:s=255}=e;return pf(t).then((t=>{if(!t||!t.MultiLayeredGraph)return Promise.reject('In soonspace: createTopologyFromGml "url" path error!');const o=[],a=new Map;let l=[],c=[];const h=t.MultiLayeredGraph.SpaceLayerMember.SpaceLayer.X_floor;lu(h)?h.forEach((e=>{l=[...l,...e.state],c=[...c,...e.transition]})):(l=[...l,...h.state],c=[...c,...h.transition]),l.forEach(((e,t)=>{const n=e.State._attributes["gml:id"],r=e.State.topoNode["gml:Node"].node_name;o.push({id:su(n)?n:"",name:su(r)?r:"",position:{x:Number(e.State.topoNode["gml:Node"].xcoord["#text"]),y:Number(e.State.topoNode["gml:Node"].zcoord["#text"]),z:-1*Number(e.State.topoNode["gml:Node"].ycoord["#text"])},graphs:[]}),a.set(n,t)})),c.forEach((e=>{const t=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][0]._attributes["xlink:href"],n=e.Transition.topoEdge["gml:Edge"]["gml:directedNode"][1]._attributes["xlink:href"],r=e.Transition.topoEdge["gml:Edge"].length["#text"],i=e.Transition.topoEdge["gml:Edge"].restrict["#text"],s=e.Transition.topoEdge["gml:Edge"].passable["#text"],l=a.get(t),c=a.get(n),h=e.Transition._attributes["gml:id"],u=e.Transition.topoEdge["gml:Edge"].link_name["#text"];void 0!==l&&void 0!==c&&("2"!==s&&"3"!==s&&o[l].graphs.push({targetNodeId:n,linkInfo:{id:h,name:u},enable:!0,length:parseInt(r),restrict:parseInt(i),passable:parseInt(s)}),"1"!==s&&"3"!==s&&o[c].graphs.push({targetNodeId:t,linkInfo:{id:h,name:u},enable:!0,length:parseInt(r),restrict:parseInt(i),passable:parseInt(s)}))})),this.setDijkstraGraph(o);const u=new Yp(Object.assign(Object.assign({},e),{type:"network",nodes:o,linkWidth:n,renderLink:!0,linkColor:r,renderNode:i,nodeColor:s}));return this.viewport.scener.addObject(u,this.scene),Promise.resolve(u)}))}create(e){const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const n=new Yp(t);return this.viewport.scener.addObject(n,this.scene),n}resetNodes(e,t){const n=this.generateLineTopologyInfoNodeGraphs(Object.assign(Object.assign({},e.info),{nodes:t}));return e.resetNodes(n.nodes),this.viewport.signals.objectChanged.dispatch(),e}createToGroup(e,t){const n=new Ou(e);return t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const r=new Yp(t);n.add(r)})),this.viewport.scener.addObject(n,this.scene),n}addForGroup(e,t){const n=this.getGroupById(e);return n&&t.forEach((e=>{const t=this.generateLineTopologyInfoNodeGraphs(e);this.setDijkstraGraph(t.nodes);const r=new Yp(t);n.add(r)})),n}getShortestPath(e,t){const{nodes:n}=e.info,r=Xh(t.start),i=Xh(t.end);let s=null,o=1/0,a=null,l=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Xh(e.position),n=t.distanceTo(r),c=t.distanceTo(i);n<o&&(o=n,s=Number(e.id)),c<l&&(l=c,a=Number(e.id))}})),s&&a){const o=this.dijkstra.getPath(s,a);if(o.length>0){const s=[{id:"startPoint",position:r,graphs:[]}];o.forEach((e=>{const t=n.find((t=>t.id==e));t&&s.push(t)})),s.push({id:"endPoint",position:i,graphs:[]});for(let e=0;e<s.length;e++)s[e].position.y+=1;const a=Object.assign(Object.assign(Object.assign({},t),{type:"line",nodes:s}),e.getSpaceAttribute(!0));this.generateLineTopologyInfoNodeGraphs(a);const l=new Yp(a);return this.viewport.scener.addObject(l,this.scene),l}}return null}getShortestPathByMultipleStartPoints(e,t){const{nodes:n}=e.info,r=[];t.start.forEach((e=>{const i=Xh(e),s=Xh(t.end);let o=null,a=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Xh(e.position),n=t.distanceTo(i),r=t.distanceTo(s);n<a&&(a=n,o=Number(e.id)),r<c&&(c=r,l=Number(e.id))}})),o&&l){let e=0;const t=this.dijkstra.getPath(o,l);if(t.length>0){const o=[{id:"startPoint",position:i,graphs:[]}];t.forEach(((t,r)=>{const s=n.find((e=>e.id==t));s&&(e+=0===r?Xh(s.position).distanceTo(i):Xh(s.position).distanceTo(Xh(o[o.length-1].position)),o.push(s))})),o.push({id:"endPoint",position:s,graphs:[]}),e+=s.distanceTo(Xh(o[o.length-1].position)),r.push({nodeInfo:o,pathLength:e})}}}));let i=[],s=1/0;if(r.forEach((({nodeInfo:e,pathLength:t})=>{t<s&&(s=t,i=e)})),i.length){for(let e=0;e<i.length;e++)i[e].position.y+=1;const n=Object.assign(Object.assign({},t),{type:"line",nodes:i,position:e.getWorldPosition(new q),rotation:(new Oe).setFromQuaternion(e.getWorldQuaternion(new X)),scale:e.getWorldScale(new q)});this.generateLineTopologyInfoNodeGraphs(n);const r=new Yp(n);return this.viewport.scener.addObject(r,this.scene),r}return null}getShortestPathByMultipleEndPoints(e,t){const{nodes:n}=e.info,r=[];t.end.forEach((e=>{const i=Xh(t.start),s=Xh(e);let o=null,a=1/0,l=null,c=1/0;if(n.forEach((e=>{if(e.graphs.length>0){const t=Xh(e.position),n=t.distanceTo(i),r=t.distanceTo(s);n<a&&(a=n,o=Number(e.id)),r<c&&(c=r,l=Number(e.id))}})),o&&l){let e=0;const t=this.dijkstra.getPath(o,l);if(t.length>0){const o=[{id:"startPoint",position:i,graphs:[]}];t.forEach(((t,r)=>{const s=n.find((e=>e.id==t));s&&(e+=0===r?Xh(s.position).distanceTo(i):Xh(s.position).distanceTo(Xh(o[o.length-1].position)),o.push(s))})),o.push({id:"endPoint",position:s,graphs:[]}),e+=s.distanceTo(Xh(o[o.length-1].position)),r.push({nodeInfo:o,pathLength:e})}}}));let i=[],s=1/0;if(r.forEach((({nodeInfo:e,pathLength:t})=>{t<s&&(s=t,i=e)})),i.length){for(let e=0;e<i.length;e++)i[e].position.y+=1;const n=Object.assign(Object.assign({},t),{type:"line",nodes:i,position:e.getWorldPosition(new q),rotation:(new Oe).setFromQuaternion(e.getWorldQuaternion(new X)),scale:e.getWorldScale(new q)});this.generateLineTopologyInfoNodeGraphs(n);const r=new Yp(n);return this.viewport.scener.addObject(r,this.scene),r}return null}setDijkstraGraph(e){const t=[];e.forEach((n=>{if(n.graphs&&n.graphs.length>0){const r=[];n.graphs.forEach((t=>{const i=e.find((e=>e.id===t.targetNodeId));i&&r.push([Number(t.targetNodeId),t.length||Xh(n.position).distanceTo(Xh(i.position))])})),t.push([Number(n.id),r])}})),t.length>0&&this.dijkstra.setGraph(t)}generateLineTopologyInfoNodeGraphs(e){if("line"===e.type)for(let t=0;t<e.nodes.length;t++)if(t===e.nodes.length-1)e.nodes[t].graphs=[];else{const n=e.nodes[t],r=e.nodes[t+1];e.nodes[t].graphs=[{targetNodeId:r.id.toString(),linkInfo:{id:`${n.id}_to_${r.id}`,name:`${n.name||n.id}_to_${r.name||r.id}`},enable:!0,length:Xh(e.nodes[t].position).distanceTo(Xh(r.position)),restrict:0,passable:0}]}return e}}class py extends Gs{constructor(e,t){const n=new Rt;n.setAttribute("position",new bt([1,1,0,-1,1,0,-1,-1,0,1,-1,0,1,1,0],3)),n.computeBoundingSphere();super(n,new Ns({fog:!1})),this.light=e,this.color=t,this.type="RectAreaLightHelper";const r=new Rt;r.setAttribute("position",new bt([1,1,0,-1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,-1,0],3)),r.computeBoundingSphere(),this.add(new Yt(r,new ct({side:1,fog:!1})))}updateMatrixWorld(){if(this.scale.set(.5*this.light.width,.5*this.light.height,1),void 0!==this.color)this.material.color.set(this.color),this.children[0].material.color.set(this.color);else{this.material.color.copy(this.light.color).multiplyScalar(this.light.intensity);const e=this.material.color,t=Math.max(e.r,e.g,e.b);t>1&&e.multiplyScalar(1/t),this.children[0].material.color.copy(this.material.color)}this.matrixWorld.extractRotation(this.light.matrixWorld).scale(this.scale).copyPosition(this.light.matrixWorld),this.children[0].matrixWorld.copy(this.matrixWorld)}dispose(){this.geometry.dispose(),this.material.dispose(),this.children[0].geometry.dispose(),this.children[0].material.dispose()}}class fy extends nf{constructor(e){super("Helper",e)}addGridHelper(e){const{id:t,size:n=1e3,divisions:r=20,color:i="#fff",position:s={x:0,y:0,z:0},rotation:o={x:0,y:0,z:0},scale:a={x:1,y:1,z:1}}=e,l=new kc(n,r,i,i);return l.position.set(s.x,s.y,s.z),l.rotation.set(o.x,o.y,o.z),l.scale.set(a.x,a.y,a.z),l.userData.sid=t,l.userData.stype="Helper",this.viewport.scener.addObject(l,this.scene),l}addAxesHelper(e){const{id:t,axesLength:n=1e3}=e,r=new $c(n);return r.userData.sid=t,r.userData.stype="Helper",this.viewport.scener.addObject(r,this.scene),r}addBoxHelper(e){const{id:t,box:n,color:r="#00ff00"}=e,i=new Zc(n,new I(r));return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addPlaneHelper(e){const{id:t,width:n=500,height:r=500,color:i="#00ff00",opacity:s=.2,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1}}=e,c=new Lu(new gn(n,r),new ct({color:i,opacity:s,transparent:s<1,side:2}),{id:t,position:o,rotation:a,scale:l});return c.userData.sid=t,c.userData.stype="Helper",this.viewport.scener.addObject(c,this.scene),c}addGroundHelper(e){const{imgUrl:t,id:n,width:r=500,height:i=500,opacity:s=1,position:o={x:0,y:0,z:0},rotation:a={x:0,y:0,z:0},scale:l={x:1,y:1,z:1},repeat:c={x:10,y:10}}=e,h=(new cl).load(t),u=new gn(r,i);u.computeBoundingBox();const d=new Ra({side:2,map:h,transparent:s<1,opacity:s,roughness:.8});d.map&&(d.map.repeat.set(c.x,c.x),d.map.wrapS=1e3,d.map.wrapT=1e3,d.map.version++),a.x-=Math.PI/2,d.version++;const p=new ef(u,d,{id:n,position:o,rotation:a,scale:l});return p.userData.sid=n,p.userData.stype="Helper",this.viewport.scener.addObject(p,this.scene),p}addDirectionalLightHelper(e){const{id:t,light:n,color:r,size:i=50}=e,s=new jc(n,i,r);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addHemisphereLightHelper(e){const{id:t,light:n,color:r,size:i=20}=e,s=new Uc(n,i,r);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addSpotLightHelper(e){const{id:t,light:n,color:r}=e,i=new Cc(n,r);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}addPointLightHelper(e){const{id:t,light:n,color:r,size:i=20}=e,s=new Oc(n,i,r);return s.userData.sid=t,s.userData.stype="Helper",this.viewport.scener.addObject(s,this.scene),s}addRectAreaLightHelper(e){const{id:t,light:n,color:r}=e,i=new py(n,r);return i.userData.sid=t,i.userData.stype="Helper",this.viewport.scener.addObject(i,this.scene),i}}class my extends nf{constructor(e){super("PluginObject",e)}createObject(e,t){const n=new Bu(e);return t&&n.add(t),this.viewport.scener.addObject(n,this.scene),n}addToObject(e,t){const n=this.getById(e);return n?(this.viewport.scener.addObject(t,n),n):null}}class gy{constructor(e){this.viewport=e,this.needUpdate=!1,this.store={LightManager:new rf(e),sbmManager:new mf(e),modelManager:new ay(e),poiManager:new ly(e),poiNodeManager:new cy(e),canvas3DManager:new hy(e),topologyManager:new dy(e),helperManager:new fy(e),pluginObjectManager:new my(e)},this.postUpdate=new Map;for(const e in this.store)this.postUpdate.set(e,this.store[e].update.bind(this.store[e]));e.postUpdate.set("ManagerRender",this.update.bind(this))}update(){const e=performance.now();this.postUpdate.forEach((e=>e())),this.viewport.signals.loadRendered.dispatch(performance.now()-e)}clearObject(){this.store.sbmManager.clear(),this.store.modelManager.clear(),this.store.poiManager.clear(),this.store.poiNodeManager.clear(),this.store.canvas3DManager.clear(),this.store.topologyManager.clear(),this.store.helperManager.clear(),this.store.pluginObjectManager.clear()}clear(){this.clearObject(),this.store.LightManager.clear()}}self.THREE=hh;class vy{constructor(e){this.THREE=hh,this.THREE_PLUGINS={TransformControls:wh,Lensflare:{Lensflare:jh,LensflareElement:Vh}},this.version=t,this.animation=Ru,this.library=tf,this.utils=pu,this.plugins={};const{el:n,options:r={},events:i={}}=e;if(this.domElement=document.querySelector(n),this.options=Object.assign(Object.assign({},{showInfo:!1,showStats:!1,showGrid:!1,background:{color:11459572,alpha:!1},fog:!1,controls:{},hoverEnabled:!1,closeInfoLog:!1,closeWarnLog:!0,useIndexedDB:!0,logarithmicDepthBuffer:!0}),r),this.viewport=new Np(this.options),this.signals=this.viewport.signals,this.manager=new gy(this.viewport),!this.domElement)throw new Error(`In SoonSpace: Can't find element by "${n}"!`);this.domElement.appendChild(this.viewport.container),this._init(),this._initEvents(i),this._initDefaultLight()}_init(){const{showGrid:t,background:n,fog:r,controls:i,closeInfoLog:s,closeWarnLog:o,useIndexedDB:a}=this.options;if(!s){Wh(" ____ ____ _ \n / ___| ___ ___ _ __ / ___| _ __ __ _ ___ ___ (_)___ \n \\___ \\ / _ \\ / _ \\| '_ \\\\___ \\| '_ \\ / _` |/ __/ _ \\ | / __| \n ___) | (_) | (_) | | | |___) | |_) | (_| | (_| __/_ | \\__ \\ \n |____/ \\___/ \\___/|_| |_|____/| .__/ \\__,_|\\___\\___(_)/ |___/ \n |_| |__/ \n",{color:"#3eaf7c"}),Wh(e,{color:"#3eaf7c","font-size":"24px"}),Wh(`当前版本: ${this.version}`,{color:"#3eaf7c","font-size":"12px"}),Wh("文档: http://www.xwbuilders.com:8800",{color:"#3eaf7c","font-size":"12px"}),Wh("样例: http://www.xwbuilders.com:8800/examples",{color:"#3eaf7c","font-size":"12px"}),Wh("GitHub: https://github.com/soonspacejs",{color:"#3eaf7c","font-size":"12px"})}t&&this.addGridHelper(!0===t?{id:"defaultGridHelper"}:t),(null==n?void 0:n.skyBox)?su(null==n?void 0:n.skyBox)?this.setSphereSkyBackground(null==n?void 0:n.skyBox):cu(null==n?void 0:n.skyBox)&&this.setSkyBackground(n.skyBox.dirPath,n.skyBox.fileNames):(null==n?void 0:n.img)?this.setBackgroundImage(n.img):(null==n?void 0:n.color)&&this.setBackgroundColor(n.color),r&&this.openSceneFog(!0===r?void 0:r),i&&this.setControlsOptions(i),o&&(window.console.warn=function(){}),a&&!window.indexedDB&&(this.options.useIndexedDB=!1,window.console.warn("Your browser doesn't support a stable version of IndexedDB. Such and such feature will not be available."))}_initEvents(e){const{modelHover:t,modelUnHover:n,modelClick:r,modelRightClick:i,modelDblClick:s,poiHover:o,poiUnHover:a,poiClick:l,poiRightClick:c,poiDblClick:h,selectPosition:u,sceneClick:d,resize:p}=e;t&&this.signals.modelHover.add(t),n&&this.signals.modelUnHover.add(n),r&&this.signals.modelClick.add(r),i&&this.signals.modelRightClick.add(i),s&&this.signals.modelDblClick.add(s),o&&this.signals.poiHover.add(o),a&&this.signals.poiUnHover.add(a),l&&this.signals.poiClick.add(l),c&&this.signals.poiRightClick.add(c),h&&this.signals.poiDblClick.add(h),u&&this.signals.selectPosition.add(u),d&&this.signals.sceneClick.add(d),p&&this.signals.windowResize.add(p),this.signals.windowResize.dispatch(),window.addEventListener("resize",(()=>this.signals.windowResize.dispatch()),!1)}_initDefaultLight(){this.createAmbientLight({id:"defaultAmbientLight",name:"defaultAmbientLight"}),this.createDirectionalLight({id:"defaultDirectionalLight",name:"defaultDirectionalLight"}),this.createHemisphereLight({id:"defaultHemisphereLight",name:"defaulHemisphereLight",intensity:.1})}registerPlugin(e,t){const n=new e(this);return this.plugins[t]=n,n}getPlugin(e){return this.plugins[e]?this.plugins[e]:null}createPluginObject(e,t){return this.manager.store.pluginObjectManager.createObject(e,t)}addToPluginObject(e,t){return this.manager.store.pluginObjectManager.addToObject(e,t)}getPluginObjectById(e){return this.manager.store.pluginObjectManager.getById(e)}getPluginObjectByName(e){return this.manager.store.pluginObjectManager.getByName(e)}removePluginObjectById(e){return this.manager.store.pluginObjectManager.removeById(e)}setSobel(e){this.viewport.setSobel(e)}setBloom(e){this.viewport.setBloom(e)}setColorSpace(e){this.viewport.setColorSpace(e)}setHoverEnabled(e){this.viewport.setHoverEnabled(e)}setBackgroundColor(e){this.viewport.setBackgroundColor(e)}setBackgroundImage(e){this.viewport.setBackgroundImage(e)}setSphereSkyBackground(e){this.viewport.setSphereSkyBackground(e)}setSkyBackground(e,t){this.viewport.setSkyBackground(e,t)}setEnvironment(){return this.viewport.setEnvironment()}playModelAnimation(e,t){return this.viewport.playModelAnimation(e,t)}stopModelAnimation(e,t){this.viewport.stopModelAnimation(e,t)}getOffsetByPosition(e){return this.viewport.getOffsetByPosition(e)}getPositionByOffset(e,t){return this.viewport.getPositionByOffset(e,t)}render(e){return this.viewport.render(e)}clearSignals(){this.viewport.clearSignals()}dispose(){return this.clear(),this.clearSignals(),this.viewport.dispose()}getCameraViewpoint(){return this.viewport.cameraManager.getCameraViewpoint()}setCameraViewpoint(e){this.viewport.cameraManager.setCameraViewpoint(e)}flyTo(e,t="frontTop",n){return this.viewport.cameraManager.flyTo(e,t,n)}flyToBoundingBox(e,t="frontTop",n){return this.viewport.cameraManager.flyToBoundingBox(e,t,n)}flyToObj(e,t="frontTop",n){return this.viewport.cameraManager.flyToObj(e,t,n)}flyMainViewpoint(e="frontTop",t){return this.flyToObj(this.viewport.scene,e,t)}surroundOnTarget(e,t){return this.viewport.cameraManager.surroundOnTarget(e,t)}surroundOnObject(e,t){return this.viewport.cameraManager.surroundOnObject(e,t)}getObjectLabelPos(e,t="frontTop",n){return this.viewport.cameraManager.getObjectLabelPos(e,t,n)}setControlsOptions(e){return this.viewport.controls.setOptions(e)}addObject(e,t){this.viewport.scener.addObject(e,t)}removeObject(e){this.viewport.scener.removeObject(e)}openSceneFog(e){this.viewport.scener.openSceneFog(e)}closeSceneFog(){this.viewport.scener.closeSceneFog()}setSky(e){return this.viewport.setSky(e)}edgeShow(e,t){return this.viewport.scener.edgeShow(e,t)}unEdgeShow(e){return this.viewport.scener.unEdgeShow(e)}strokeShow(e,t){return this.viewport.scener.strokeShow(e,t)}unStrokeShow(e){return this.viewport.scener.unStrokeShow(e)}opacityShow(e,t){return this.viewport.scener.opacityShow(e,t)}unOpacityShow(e){return this.viewport.scener.unOpacityShow(e)}highlightShow(e,t){return this.viewport.scener.highlightShow(e,t)}unHighlightShow(e){return this.viewport.scener.unHighlightShow(e)}emissiveShow(e,t){return this.viewport.scener.emissiveShow(e,t)}unEmissiveShow(e){return this.viewport.scener.unEmissiveShow(e)}clearObject(){this.manager.clearObject()}clear(){this.manager.clear()}createAmbientLight(e){return this.manager.store.LightManager.createAmbientLight(e)}setAmbientLight(e){return this.manager.store.LightManager.setAmbientLight(e)}createDirectionalLight(e){return this.manager.store.LightManager.createDirectionalLight(e)}setDirectionalLight(e){return this.manager.store.LightManager.setDirectionalLight(e)}createHemisphereLight(e){return this.manager.store.LightManager.createHemisphereLight(e)}setHemisphereLight(e){return this.manager.store.LightManager.setHemisphereLight(e)}createSpotLight(e){return this.manager.store.LightManager.createSpotLight(e)}setSpotLight(e){return this.manager.store.LightManager.setSpotLight(e)}createPointLight(e){return this.manager.store.LightManager.createPointLight(e)}setPointLight(e){return this.manager.store.LightManager.setPointLight(e)}createRectAreaLight(e){return this.manager.store.LightManager.createRectAreaLight(e)}setRectAreaLight(e){return this.manager.store.LightManager.setRectAreaLight(e)}getLightById(e){return this.manager.store.LightManager.getById(e)}removeLightById(e){return this.manager.store.LightManager.removeById(e)}getAllLight(){return this.manager.store.LightManager.getAll()}clearLight(){return this.manager.store.LightManager.clear()}showAllLight(){return this.manager.store.LightManager.showAll()}hideAllLight(){return this.manager.store.LightManager.hideAll()}updateAllShadow(){return this.manager.store.LightManager.updateAllShadow()}loadSbm(e,t){return this.manager.store.sbmManager.load(e,t)}parseSbm(e,t,n){return this.manager.store.sbmManager.parse(e,t,n)}cloneSbm(e,t,n){return this.manager.store.sbmManager.clone(e,t,n)}getSbmById(e){return this.manager.store.sbmManager.getById(e)}getSbmByName(e){return this.manager.store.sbmManager.getByName(e)}getSbmByUserDataProperty(e,t){return this.manager.store.sbmManager.getByUserDataProperty(e,t)}removeSbmById(e){return this.manager.store.sbmManager.removeById(e)}createGroupForSbm(e){return this.manager.store.sbmManager.createGroup(e)}loadSbmToGroup(e,t,n){return this.manager.store.sbmManager.loadToGroup(e,t,n)}addSbmForGroup(e,t,n){return this.manager.store.sbmManager.addForGroup(e,t,n)}createSbmGroupFromXml(e,t){return this.manager.store.sbmManager.createGroupFromXml(e,t)}getSbmGroupById(e){return this.manager.store.sbmManager.getGroupById(e)}getSbmGroupByName(e){return this.manager.store.sbmManager.getGroupByName(e)}getAllSbmGroup(){return this.manager.store.sbmManager.getAllGroup()}removeSbmGroupById(e){return this.manager.store.sbmManager.removeGroupById(e)}clearSbm(){return this.manager.store.sbmManager.clear()}getAllSbm(){return this.manager.store.sbmManager.getAll()}showAllSbm(){return this.manager.store.sbmManager.showAll()}hideAllSbm(){return this.manager.store.sbmManager.hideAll()}getSbmModelMaps(){return this.manager.store.sbmManager.modelMaps}setSbmModelMaps(e){this.manager.store.sbmManager.modelMaps=e}clearIdb(){return Promise.all([this.manager.store.sbmManager.clearIdb(),this.manager.store.modelManager.clearIdb()])}setModelDracoDecoderPath(e){return this.manager.store.modelManager.setDracoDecoderPath(e)}loadModel(e){return this.manager.store.modelManager.load(e)}cloneModel(e,t,n){return this.manager.store.modelManager.clone(e,t,n)}getModelById(e){return this.manager.store.modelManager.getById(e)}getModelByName(e){return this.manager.store.modelManager.getByName(e)}getModelByUserDataProperty(e,t){return this.manager.store.modelManager.getByUserDataProperty(e,t)}removeModelById(e){return this.manager.store.modelManager.removeById(e)}createGroupForModel(e){return this.manager.store.modelManager.createGroup(e)}loadModelToGroup(e,t){return this.manager.store.modelManager.loadToGroup(e,t)}addModelForGroup(e,t){return this.manager.store.modelManager.addForGroup(e,t)}getModelGroupById(e){return this.manager.store.modelManager.getGroupById(e)}getModelGroupByName(e){return this.manager.store.modelManager.getGroupByName(e)}getAllModelGroup(){return this.manager.store.modelManager.getAllGroup()}removeModelGroupById(e){return this.manager.store.modelManager.removeGroupById(e)}clearModel(){return this.manager.store.modelManager.clear()}getAllModel(){return this.manager.store.modelManager.getAll()}showAllModel(){return this.manager.store.modelManager.showAll()}hideAllModel(){return this.manager.store.modelManager.hideAll()}createPoi(e){return this.manager.store.poiManager.create(e)}clonePoi(e,t,n){return this.manager.store.poiManager.clone(e,t,n)}getPoiById(e){return this.manager.store.poiManager.getById(e)}getPoiByName(e){return this.manager.store.poiManager.getByName(e)}getPoiByUserDataProperty(e,t){return this.manager.store.poiManager.getByUserDataProperty(e,t)}removePoiById(e){return this.manager.store.poiManager.removeById(e)}createGroupForPoi(e){return this.manager.store.poiManager.createGroup(e)}createPoiToGroup(e,t){return this.manager.store.poiManager.createToGroup(e,t)}addPoiForGroup(e,t){return this.manager.store.poiManager.addForGroup(e,t)}getPoiGroupById(e){return this.manager.store.poiManager.getGroupById(e)}getPoiGroupByName(e){return this.manager.store.poiManager.getGroupByName(e)}getAllPoiGroup(){return this.manager.store.poiManager.getAllGroup()}removePoiGroupById(e){return this.manager.store.poiManager.removeGroupById(e)}clearPoi(){return this.manager.store.poiManager.clear()}getAllPoi(){return this.manager.store.poiManager.getAll()}showAllPoi(){return this.manager.store.poiManager.showAll()}hideAllPoi(){return this.manager.store.poiManager.hideAll()}createPoiNode(e){return this.manager.store.poiNodeManager.create(e)}getPoiNodeById(e){return this.manager.store.poiNodeManager.getById(e)}getPoiNodeByName(e){return this.manager.store.poiNodeManager.getByName(e)}getPoiNodeByUserDataProperty(e,t){return this.manager.store.poiNodeManager.getByUserDataProperty(e,t)}removePoiNodeById(e){return this.manager.store.poiNodeManager.removeById(e)}createGroupForPoiNode(e){return this.manager.store.poiNodeManager.createGroup(e)}createPoiNodeToGroup(e,t){return this.manager.store.poiNodeManager.createToGroup(e,t)}addPoiNodeForGroup(e,t){return this.manager.store.poiNodeManager.addForGroup(e,t)}getPoiNodeGroupById(e){return this.manager.store.poiNodeManager.getGroupById(e)}getPoiNodeGroupByName(e){return this.manager.store.poiNodeManager.getGroupByName(e)}getAllPoiNodeGroup(){return this.manager.store.poiNodeManager.getAllGroup()}removePoiNodeGroupById(e){return this.manager.store.poiNodeManager.removeGroupById(e)}clearPoiNode(){return this.manager.store.poiNodeManager.clear()}getAllPoiNode(){return this.manager.store.poiNodeManager.getAll()}showAllPoiNode(){return this.manager.store.poiNodeManager.showAll()}hideAllPoiNode(){return this.manager.store.poiNodeManager.hideAll()}createCanvas3D(e){return this.manager.store.canvas3DManager.create(e)}getCanvas3DById(e){return this.manager.store.canvas3DManager.getById(e)}getCanvas3DByName(e){return this.manager.store.canvas3DManager.getByName(e)}getCanvas3DByUserDataProperty(e,t){return this.manager.store.canvas3DManager.getByUserDataProperty(e,t)}removeCanvas3DById(e){return this.manager.store.canvas3DManager.removeById(e)}createGroupForCanvas3D(e){return this.manager.store.canvas3DManager.createGroup(e)}createCanvas3DToGroup(e,t){return this.manager.store.canvas3DManager.createToGroup(e,t)}addCanvas3DForGroup(e,t){return this.manager.store.canvas3DManager.addForGroup(e,t)}getCanvas3DGroupById(e){return this.manager.store.canvas3DManager.getGroupById(e)}getCanvas3DGroupByName(e){return this.manager.store.canvas3DManager.getGroupByName(e)}getAllCanvas3DGroup(){return this.manager.store.canvas3DManager.getAllGroup()}removeCanvas3DGroupById(e){return this.manager.store.canvas3DManager.removeGroupById(e)}clearCanvas3D(){return this.manager.store.canvas3DManager.clear()}getAllCanvas3D(){return this.manager.store.canvas3DManager.getAll()}showAllCanvas3D(){return this.manager.store.canvas3DManager.showAll()}hideAllCanvas3D(){return this.manager.store.canvas3DManager.hideAll()}getShortestPath(e,t){return this.manager.store.topologyManager.getShortestPath(e,t)}getShortestPathByMultipleStartPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleStartPoints(e,t)}getShortestPathByMultipleEndPoints(e,t){return this.manager.store.topologyManager.getShortestPathByMultipleEndPoints(e,t)}createTopologyFromGml(e){return this.manager.store.topologyManager.createFromGml(e)}createTopology(e){return this.manager.store.topologyManager.create(e)}resetTopologyNodes(e,t){return this.manager.store.topologyManager.resetNodes(e,t)}getTopologyById(e){return this.manager.store.topologyManager.getById(e)}getTopologyByName(e){return this.manager.store.topologyManager.getByName(e)}getTopologyByUserDataProperty(e,t){return this.manager.store.topologyManager.getByUserDataProperty(e,t)}removeTopologyById(e){return this.manager.store.topologyManager.removeById(e)}createGroupForTopology(e){return this.manager.store.topologyManager.createGroup(e)}createTopologyToGroup(e,t){return this.manager.store.topologyManager.createToGroup(e,t)}addTopologyForGroup(e,t){return this.manager.store.topologyManager.addForGroup(e,t)}getTopologyGroupById(e){return this.manager.store.topologyManager.getGroupById(e)}getTopologyGroupByName(e){return this.manager.store.topologyManager.getGroupByName(e)}getAllTopologyGroup(){return this.manager.store.topologyManager.getAllGroup()}removeTopologyGroupById(e){return this.manager.store.topologyManager.removeGroupById(e)}clearTopology(){return this.manager.store.topologyManager.clear()}getAllTopology(){return this.manager.store.topologyManager.getAll()}showAllTopology(){return this.manager.store.topologyManager.showAll()}hideAllTopology(){return this.manager.store.topologyManager.hideAll()}addGridHelper(e){return this.manager.store.helperManager.addGridHelper(e)}addAxesHelper(e){return this.manager.store.helperManager.addAxesHelper(e)}addBoxHelper(e){return this.manager.store.helperManager.addBoxHelper(e)}addPlaneHelper(e){return this.manager.store.helperManager.addPlaneHelper(e)}createGround(e){return console.warn("In soonspacejs: 'createGround' 已弃用,请使用 'addGroundHelper'!"),this.addGroundHelper(e)}addGroundHelper(e){return this.manager.store.helperManager.addGroundHelper(e)}addDirectionalLightHelper(e){return this.manager.store.helperManager.addDirectionalLightHelper(e)}addHemisphereLightHelper(e){return this.manager.store.helperManager.addHemisphereLightHelper(e)}addSpotLightHelper(e){return this.manager.store.helperManager.addSpotLightHelper(e)}addPointLightHelper(e){return this.manager.store.helperManager.addPointLightHelper(e)}addRectAreaLightHelper(e){return this.manager.store.helperManager.addRectAreaLightHelper(e)}getHelperById(e){return this.manager.store.helperManager.getById(e)}removeHelperById(e){return this.manager.store.helperManager.removeById(e)}clearHelper(){return this.manager.store.helperManager.clear()}showAllHelper(){return this.manager.store.helperManager.showAll()}hideAllHelper(){return this.manager.store.helperManager.hideAll()}}vy.THREE=hh;export default vy;
|