(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,31497,e=>{"use strict";let t=parseInt(e.i(90072).REVISION.replace(/\D+/g,""));e.s(["version",0,t])},43257,e=>{"use strict";let t;var r=e.i(31067),n=e.i(71645),a=e.i(28600),i=e.i(25234),s=e.i(44208),o=e.i(24205),l=e.i(67335),A=e.i(90072),u=A,c=e.i(31497);class h extends u.Mesh{constructor(e,t){var r,n;const a=(e=>e&&e.isCubeTexture)(e),i=Math.floor(Math.log2((null!=(n=a?null==(r=e.image[0])?void 0:r.width:e.image.width)?n:1024)/4)),s=Math.pow(2,i),o=3*Math.max(s,112),l=`
        varying vec3 vWorldPosition;
        void main() 
        {
            vec4 worldPosition = ( modelMatrix * vec4( position, 1.0 ) );
            vWorldPosition = worldPosition.xyz;
            
            gl_Position = projectionMatrix * modelViewMatrix * vec4( position, 1.0 );
        }
        `,A=[a?"#define ENVMAP_TYPE_CUBE":"",`#define CUBEUV_TEXEL_WIDTH ${1/o}`,`#define CUBEUV_TEXEL_HEIGHT ${1/(4*s)}`,`#define CUBEUV_MAX_MIP ${i}.0`].join("\n")+`
        #define ENVMAP_TYPE_CUBE_UV
        varying vec3 vWorldPosition;
        uniform float radius;
        uniform float height;
        uniform float angle;
        #ifdef ENVMAP_TYPE_CUBE
            uniform samplerCube map;
        #else
            uniform sampler2D map;
        #endif
        // From: https://www.shadertoy.com/view/4tsBD7
        float diskIntersectWithBackFaceCulling( vec3 ro, vec3 rd, vec3 c, vec3 n, float r ) 
        {
            float d = dot ( rd, n );
            
            if( d > 0.0 ) { return 1e6; }
            
            vec3  o = ro - c;
            float t = - dot( n, o ) / d;
            vec3  q = o + rd * t;
            
            return ( dot( q, q ) < r * r ) ? t : 1e6;
        }
        // From: https://www.iquilezles.org/www/articles/intersectors/intersectors.htm
        float sphereIntersect( vec3 ro, vec3 rd, vec3 ce, float ra ) 
        {
            vec3 oc = ro - ce;
            float b = dot( oc, rd );
            float c = dot( oc, oc ) - ra * ra;
            float h = b * b - c;
            
            if( h < 0.0 ) { return -1.0; }
            
            h = sqrt( h );
            
            return - b + h;
        }
        vec3 project() 
        {
            vec3 p = normalize( vWorldPosition );
            vec3 camPos = cameraPosition;
            camPos.y -= height;
            float intersection = sphereIntersect( camPos, p, vec3( 0.0 ), radius );
            if( intersection > 0.0 ) {
                
                vec3 h = vec3( 0.0, - height, 0.0 );
                float intersection2 = diskIntersectWithBackFaceCulling( camPos, p, h, vec3( 0.0, 1.0, 0.0 ), radius );
                p = ( camPos + min( intersection, intersection2 ) * p ) / radius;
            } else {
                p = vec3( 0.0, 1.0, 0.0 );
            }
            return p;
        }
        #include <common>
        #include <cube_uv_reflection_fragment>
        void main() 
        {
            vec3 projectedWorldPosition = project();
            
            #ifdef ENVMAP_TYPE_CUBE
                vec3 outcolor = textureCube( map, projectedWorldPosition ).rgb;
            #else
                vec3 direction = normalize( projectedWorldPosition );
                vec2 uv = equirectUv( direction );
                vec3 outcolor = texture2D( map, uv ).rgb;
            #endif
            gl_FragColor = vec4( outcolor, 1.0 );
            #include <tonemapping_fragment>
            #include <${c.version>=154?"colorspace_fragment":"encodings_fragment"}>
        }
        `,h={map:{value:e},height:{value:(null==t?void 0:t.height)||15},radius:{value:(null==t?void 0:t.radius)||100}};super(new u.IcosahedronGeometry(1,16),new u.ShaderMaterial({uniforms:h,fragmentShader:A,vertexShader:l,side:u.DoubleSide}))}set radius(e){this.material.uniforms.radius.value=e}get radius(){return this.material.uniforms.radius.value}set height(e){this.material.uniforms.height.value=e}get height(){return this.material.uniforms.height.value}}var d=e.i(60602),f=A;class B extends f.DataTextureLoader{constructor(e){super(e),this.type=f.HalfFloatType}parse(e){let t,r,n,a=function(e,t){switch(e){case 1:throw Error("THREE.RGBELoader: Read Error: "+(t||""));case 2:throw Error("THREE.RGBELoader: Write Error: "+(t||""));case 3:throw Error("THREE.RGBELoader: Bad File Format: "+(t||""));default:throw Error("THREE.RGBELoader: Memory Error: "+(t||""))}},i=function(e,t,r){t=t||1024;let n=e.pos,a=-1,i=0,s="",o=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));for(;0>(a=o.indexOf("\n"))&&i<t&&n<e.byteLength;)s+=o,i+=o.length,n+=128,o+=String.fromCharCode.apply(null,new Uint16Array(e.subarray(n,n+128)));return -1<a&&(!1!==r&&(e.pos+=i+a+1),s+o.slice(0,a))},s=new Uint8Array(e);s.pos=0;let o=function(e){let t,r,n=/^\s*GAMMA\s*=\s*(\d+(\.\d+)?)\s*$/,s=/^\s*EXPOSURE\s*=\s*(\d+(\.\d+)?)\s*$/,o=/^\s*FORMAT=(\S+)\s*$/,l=/^\s*\-Y\s+(\d+)\s+\+X\s+(\d+)\s*$/,A={valid:0,string:"",comments:"",programtype:"RGBE",format:"",gamma:1,exposure:1,width:0,height:0};for(!(e.pos>=e.byteLength)&&(t=i(e))||a(1,"no header found"),(r=t.match(/^#\?(\S+)/))||a(3,"bad initial token"),A.valid|=1,A.programtype=r[1],A.string+=t+"\n";!1!==(t=i(e));){if(A.string+=t+"\n","#"===t.charAt(0)){A.comments+=t+"\n";continue}if((r=t.match(n))&&(A.gamma=parseFloat(r[1])),(r=t.match(s))&&(A.exposure=parseFloat(r[1])),(r=t.match(o))&&(A.valid|=2,A.format=r[1]),(r=t.match(l))&&(A.valid|=4,A.height=parseInt(r[1],10),A.width=parseInt(r[2],10)),2&A.valid&&4&A.valid)break}return 2&A.valid||a(3,"missing format specifier"),4&A.valid||a(3,"missing image size specifier"),A}(s),l=o.width,A=o.height,u=function(e,t,r){if(t<8||t>32767||2!==e[0]||2!==e[1]||128&e[2])return new Uint8Array(e);t!==(e[2]<<8|e[3])&&a(3,"wrong scanline width");let n=new Uint8Array(4*t*r);n.length||a(4,"unable to allocate buffer space");let i=0,s=0,o=4*t,l=new Uint8Array(4),A=new Uint8Array(o),u=r;for(;u>0&&s<e.byteLength;){s+4>e.byteLength&&a(1),l[0]=e[s++],l[1]=e[s++],l[2]=e[s++],l[3]=e[s++],(2!=l[0]||2!=l[1]||(l[2]<<8|l[3])!=t)&&a(3,"bad rgbe scanline format");let r=0,c;for(;r<o&&s<e.byteLength;){let t=(c=e[s++])>128;if(t&&(c-=128),(0===c||r+c>o)&&a(3,"bad scanline data"),t){let t=e[s++];for(let e=0;e<c;e++)A[r++]=t}else A.set(e.subarray(s,s+c),r),r+=c,s+=c}for(let e=0;e<t;e++){let r=0;n[i]=A[e+r],r+=t,n[i+1]=A[e+r],r+=t,n[i+2]=A[e+r],r+=t,n[i+3]=A[e+r],i+=4}u--}return n}(s.subarray(s.pos),l,A);switch(this.type){case f.FloatType:let c=new Float32Array(4*(n=u.length/4));for(let e=0;e<n;e++)!function(e,t,r,n){let a=Math.pow(2,e[t+3]-128)/255;r[n+0]=e[t+0]*a,r[n+1]=e[t+1]*a,r[n+2]=e[t+2]*a,r[n+3]=1}(u,4*e,c,4*e);t=c,r=f.FloatType;break;case f.HalfFloatType:let h=new Uint16Array(4*(n=u.length/4));for(let e=0;e<n;e++)!function(e,t,r,n){let a=Math.pow(2,e[t+3]-128)/255;r[n+0]=f.DataUtils.toHalfFloat(Math.min(e[t+0]*a,65504)),r[n+1]=f.DataUtils.toHalfFloat(Math.min(e[t+1]*a,65504)),r[n+2]=f.DataUtils.toHalfFloat(Math.min(e[t+2]*a,65504)),r[n+3]=f.DataUtils.toHalfFloat(1)}(u,4*e,h,4*e);t=h,r=f.HalfFloatType;break;default:throw Error("THREE.RGBELoader: Unsupported type: "+this.type)}return{width:l,height:A,data:t,header:o.string,gamma:o.gamma,exposure:o.exposure,type:r}}setDataType(e){return this.type=e,this}load(e,t,r,n){return super.load(e,function(e,r){switch(e.type){case f.FloatType:case f.HalfFloatType:"colorSpace"in e?e.colorSpace="srgb-linear":e.encoding=3e3,e.minFilter=f.LinearFilter,e.magFilter=f.LinearFilter,e.generateMipmaps=!1,e.flipY=!0}t&&t(e,r)},r,n)}}var p=A,C={},m=function(e,t,r,n,a){var i=new Worker(C[t]||(C[t]=URL.createObjectURL(new Blob([e],{type:"text/javascript"}))));return i.onerror=function(e){return a(e.error,null)},i.onmessage=function(e){return a(null,e.data)},i.postMessage(r,n),i},g=Uint8Array,M=Uint16Array,v=Uint32Array,F=new g([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]),E=new g([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]),y=new g([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),I=function(e,t){for(var r=new M(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];for(var a=new v(r[30]),n=1;n<30;++n)for(var i=r[n];i<r[n+1];++i)a[i]=i-r[n]<<5|n;return[r,a]},G=I(F,2),R=G[0],b=G[1];R[28]=258,b[258]=28;for(var D=I(E,0),T=D[0],w=D[1],H=new M(32768),x=0;x<32768;++x){var J=(43690&x)>>>1|(21845&x)<<1;J=(61680&(J=(52428&J)>>>2|(13107&J)<<2))>>>4|(3855&J)<<4,H[x]=((65280&J)>>>8|(255&J)<<8)>>>1}for(var L=function(e,t,r){for(var n,a=e.length,i=0,s=new M(t);i<a;++i)++s[e[i]-1];var o=new M(t);for(i=0;i<t;++i)o[i]=o[i-1]+s[i-1]<<1;if(r){n=new M(1<<t);var l=15-t;for(i=0;i<a;++i)if(e[i])for(var A=i<<4|e[i],u=t-e[i],c=o[e[i]-1]++<<u,h=c|(1<<u)-1;c<=h;++c)n[H[c]>>>l]=A}else for(i=0,n=new M(a);i<a;++i)e[i]&&(n[i]=H[o[e[i]-1]++]>>>15-e[i]);return n},S=new g(288),x=0;x<144;++x)S[x]=8;for(var x=144;x<256;++x)S[x]=9;for(var x=256;x<280;++x)S[x]=7;for(var x=280;x<288;++x)S[x]=8;for(var U=new g(32),x=0;x<32;++x)U[x]=5;var O=L(S,9,0),P=L(S,9,1),_=L(U,5,0),K=L(U,5,1),k=function(e){for(var t=e[0],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},N=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},Q=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},X=function(e){return(e/8|0)+(7&e&&1)},j=function(e,t,r){(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length);var n=new(e instanceof M?M:e instanceof v?v:g)(r-t);return n.set(e.subarray(t,r)),n},Y=function(e,t,r){var n=e.length;if(!n||r&&!r.l&&n<5)return t||new g(0);var a=!t||r,i=!r||r.i;r||(r={}),t||(t=new g(3*n));var s=function(e){var r=t.length;if(e>r){var n=new g(Math.max(2*r,e));n.set(t),t=n}},o=r.f||0,l=r.p||0,A=r.b||0,u=r.l,c=r.d,h=r.m,d=r.n,f=8*n;do{if(!u){r.f=o=N(e,l,1);var B=N(e,l+1,3);if(l+=3,B)if(1==B)u=P,c=K,h=9,d=5;else if(2==B){var p=N(e,l,31)+257,C=N(e,l+10,15)+4,m=p+N(e,l+5,31)+1;l+=14;for(var M=new g(m),v=new g(19),I=0;I<C;++I)v[y[I]]=N(e,l+3*I,7);l+=3*C;for(var G=k(v),b=(1<<G)-1,D=L(v,G,1),I=0;I<m;){var w=D[N(e,l,b)];l+=15&w;var H=w>>>4;if(H<16)M[I++]=H;else{var x=0,J=0;for(16==H?(J=3+N(e,l,3),l+=2,x=M[I-1]):17==H?(J=3+N(e,l,7),l+=3):18==H&&(J=11+N(e,l,127),l+=7);J--;)M[I++]=x}}var S=M.subarray(0,p),U=M.subarray(p);h=k(S),d=k(U),u=L(S,h,1),c=L(U,d,1)}else throw"invalid block type";else{var H=X(l)+4,O=e[H-4]|e[H-3]<<8,_=H+O;if(_>n){if(i)throw"unexpected EOF";break}a&&s(A+O),t.set(e.subarray(H,_),A),r.b=A+=O,r.p=l=8*_;continue}if(l>f){if(i)throw"unexpected EOF";break}}a&&s(A+131072);for(var Y=(1<<h)-1,W=(1<<d)-1,Z=l;;Z=l){var x=u[Q(e,l)&Y],V=x>>>4;if((l+=15&x)>f){if(i)throw"unexpected EOF";break}if(!x)throw"invalid length/literal";if(V<256)t[A++]=V;else if(256==V){Z=l,u=null;break}else{var z=V-254;if(V>264){var I=V-257,q=F[I];z=N(e,l,(1<<q)-1)+R[I],l+=q}var $=c[Q(e,l)&W],ee=$>>>4;if(!$)throw"invalid distance";l+=15&$;var U=T[ee];if(ee>3){var q=E[ee];U+=Q(e,l)&(1<<q)-1,l+=q}if(l>f){if(i)throw"unexpected EOF";break}a&&s(A+131072);for(var et=A+z;A<et;A+=4)t[A]=t[A-U],t[A+1]=t[A+1-U],t[A+2]=t[A+2-U],t[A+3]=t[A+3-U];A=et}}r.l=u,r.p=Z,r.b=A,u&&(o=1,r.m=h,r.d=c,r.n=d)}while(!o)return A==t.length?t:j(t,0,A)},W=function(e,t,r){r<<=7&t;var n=t/8|0;e[n]|=r,e[n+1]|=r>>>8},Z=function(e,t,r){r<<=7&t;var n=t/8|0;e[n]|=r,e[n+1]|=r>>>8,e[n+2]|=r>>>16},V=function(e,t){for(var r=[],n=0;n<e.length;++n)e[n]&&r.push({s:n,f:e[n]});var a=r.length,i=r.slice();if(!a)return[en,0];if(1==a){var s=new g(r[0].s+1);return s[r[0].s]=1,[s,1]}r.sort(function(e,t){return e.f-t.f}),r.push({s:-1,f:25001});var o=r[0],l=r[1],A=0,u=1,c=2;for(r[0]={s:-1,f:o.f+l.f,l:o,r:l};u!=a-1;)o=r[r[A].f<r[c].f?A++:c++],l=r[A!=u&&r[A].f<r[c].f?A++:c++],r[u++]={s:-1,f:o.f+l.f,l:o,r:l};for(var h=i[0].s,n=1;n<a;++n)i[n].s>h&&(h=i[n].s);var d=new M(h+1),f=z(r[u-1],d,0);if(f>t){var n=0,B=0,p=f-t,C=1<<p;for(i.sort(function(e,t){return d[t.s]-d[e.s]||e.f-t.f});n<a;++n){var m=i[n].s;if(d[m]>t)B+=C-(1<<f-d[m]),d[m]=t;else break}for(B>>>=p;B>0;){var v=i[n].s;d[v]<t?B-=1<<t-d[v]++-1:++n}for(;n>=0&&B;--n){var F=i[n].s;d[F]==t&&(--d[F],++B)}f=t}return[new g(d),f]},z=function(e,t,r){return -1==e.s?Math.max(z(e.l,t,r+1),z(e.r,t,r+1)):t[e.s]=r},q=function(e){for(var t=e.length;t&&!e[--t];);for(var r=new M(++t),n=0,a=e[0],i=1,s=function(e){r[n++]=e},o=1;o<=t;++o)if(e[o]==a&&o!=t)++i;else{if(!a&&i>2){for(;i>138;i-=138)s(32754);i>2&&(s(i>10?i-11<<5|28690:i-3<<5|12305),i=0)}else if(i>3){for(s(a),--i;i>6;i-=6)s(8304);i>2&&(s(i-3<<5|8208),i=0)}for(;i--;)s(a);i=1,a=e[o]}return[r.subarray(0,n),t]},$=function(e,t){for(var r=0,n=0;n<t.length;++n)r+=e[n]*t[n];return r},ee=function(e,t,r){var n=r.length,a=X(t+2);e[a]=255&n,e[a+1]=n>>>8,e[a+2]=255^e[a],e[a+3]=255^e[a+1];for(var i=0;i<n;++i)e[a+i+4]=r[i];return(a+4+n)*8},et=function(e,t,r,n,a,i,s,o,l,A,u){W(t,u++,r),++a[256];for(var c,h,d,f,B=V(a,15),p=B[0],C=B[1],m=V(i,15),g=m[0],v=m[1],I=q(p),G=I[0],R=I[1],b=q(g),D=b[0],T=b[1],w=new M(19),H=0;H<G.length;++H)w[31&G[H]]++;for(var H=0;H<D.length;++H)w[31&D[H]]++;for(var x=V(w,7),J=x[0],P=x[1],K=19;K>4&&!J[y[K-1]];--K);var k=A+5<<3,N=$(a,S)+$(i,U)+s,Q=$(a,p)+$(i,g)+s+14+3*K+$(w,J)+(2*w[16]+3*w[17]+7*w[18]);if(k<=N&&k<=Q)return ee(t,u,e.subarray(l,l+A));if(W(t,u,1+(Q<N)),u+=2,Q<N){c=L(p,C,0),h=p,d=L(g,v,0),f=g;var X=L(J,P,0);W(t,u,R-257),W(t,u+5,T-1),W(t,u+10,K-4),u+=14;for(var H=0;H<K;++H)W(t,u+3*H,J[y[H]]);u+=3*K;for(var j=[G,D],Y=0;Y<2;++Y)for(var z=j[Y],H=0;H<z.length;++H){var et=31&z[H];W(t,u,X[et]),u+=J[et],et>15&&(W(t,u,z[H]>>>5&127),u+=z[H]>>>12)}}else c=O,h=S,d=_,f=U;for(var H=0;H<o;++H)if(n[H]>255){var et=n[H]>>>18&31;Z(t,u,c[et+257]),u+=h[et+257],et>7&&(W(t,u,n[H]>>>23&31),u+=F[et]);var er=31&n[H];Z(t,u,d[er]),u+=f[er],er>3&&(Z(t,u,n[H]>>>5&8191),u+=E[er])}else Z(t,u,c[n[H]]),u+=h[n[H]];return Z(t,u,c[256]),u+h[256]},er=new v([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),en=new g(0),ea=function(e,t,r,n,a,i){var s=e.length,o=new g(n+s+5*(1+Math.ceil(s/7e3))+a),l=o.subarray(n,o.length-a),A=0;if(!t||s<8)for(var u=0;u<=s;u+=65535){var c=u+65535;c<s?A=ee(l,A,e.subarray(u,c)):(l[u]=i,A=ee(l,A,e.subarray(u,s)))}else{for(var h=er[t-1],d=h>>>13,f=8191&h,B=(1<<r)-1,p=new M(32768),C=new M(B+1),m=Math.ceil(r/3),y=2*m,I=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<y)&B},G=new v(25e3),R=new M(288),D=new M(32),T=0,H=0,u=0,x=0,J=0,L=0;u<s;++u){var S=I(u),U=32767&u,O=C[S];if(p[U]=O,C[S]=U,J<=u){var P=s-u;if((T>7e3||x>24576)&&P>423){A=et(e,l,0,G,R,D,H,x,L,u-L,A),x=T=H=0,L=u;for(var _=0;_<286;++_)R[_]=0;for(var _=0;_<30;++_)D[_]=0}var K=2,k=0,N=f,Q=U-O&32767;if(P>2&&S==I(u-Q))for(var Y=Math.min(d,P)-1,W=Math.min(32767,u),Z=Math.min(258,P);Q<=W&&--N&&U!=O;){if(e[u+K]==e[u+K-Q]){for(var V=0;V<Z&&e[u+V]==e[u+V-Q];++V);if(V>K){if(K=V,k=Q,V>Y)break;for(var z=Math.min(Q,V-2),q=0,_=0;_<z;++_){var $=u-Q+_+32768&32767,ea=p[$],ei=$-ea+32768&32767;ei>q&&(q=ei,O=$)}}}O=p[U=O],Q+=U-O+32768&32767}if(k){G[x++]=0x10000000|b[K]<<18|w[k];var es=31&b[K],eo=31&w[k];H+=F[es]+E[eo],++R[257+es],++D[eo],J=u+K,++T}else G[x++]=e[u],++R[e[u]]}}A=et(e,l,i,G,R,D,H,x,L,u-L,A),!i&&7&A&&(A=ee(l,A+1,en))}return j(o,0,n+X(A)+a)},ei=function(){for(var e=new Int32Array(256),t=0;t<256;++t){for(var r=t,n=9;--n;)r=(1&r&&-0x12477ce0)^r>>>1;e[t]=r}return e}(),es=function(){var e=-1;return{p:function(t){for(var r=e,n=0;n<t.length;++n)r=ei[255&r^t[n]]^r>>>8;e=r},d:function(){return~e}}},eo=function(){var e=1,t=0;return{p:function(r){for(var n=e,a=t,i=r.length,s=0;s!=i;){for(var o=Math.min(s+2655,i);s<o;++s)a+=n+=r[s];n=(65535&n)+15*(n>>16),a=(65535&a)+15*(a>>16)}e=n,t=a},d:function(){return e%=65521,t%=65521,(255&e)<<24|e>>>8<<16|(255&t)<<8|t>>>8}}},el=function(e,t,r,n,a){return ea(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,r,n,!a)},eA=function(e,t){var r={};for(var n in e)r[n]=e[n];for(var n in t)r[n]=t[n];return r},eu=function(e,t,r){for(var n=e(),a=e.toString(),i=a.slice(a.indexOf("[")+1,a.lastIndexOf("]")).replace(/ /g,"").split(","),s=0;s<n.length;++s){var o=n[s],l=i[s];if("function"==typeof o){t+=";"+l+"=";var A=o.toString();if(o.prototype)if(-1!=A.indexOf("[native code]")){var u=A.indexOf(" ",8)+1;t+=A.slice(u,A.indexOf("(",u))}else for(var c in t+=A,o.prototype)t+=";"+l+".prototype."+c+"="+o.prototype[c].toString();else t+=A}else r[l]=o}return[t,r]},ec=[],eh=function(e){var t=[];for(var r in e)(e[r]instanceof g||e[r]instanceof M||e[r]instanceof v)&&t.push((e[r]=new e[r].constructor(e[r])).buffer);return t},ed=function(e,t,r,n){if(!ec[r]){for(var a,i="",s={},o=e.length-1,l=0;l<o;++l)i=(a=eu(e[l],i,s))[0],s=a[1];ec[r]=eu(e[o],i,s)}var A=eA({},ec[r][1]);return m(ec[r][0]+";onmessage=function(e){for(var k in e.data)self[k]=e.data[k];onmessage="+t.toString()+"}",r,A,eh(A),n)},ef=function(){return[g,M,v,F,E,y,R,T,P,K,H,L,k,N,Q,X,j,Y,eO,em,eg]},eB=function(){return[g,M,v,F,E,y,b,w,O,S,_,U,H,er,en,L,W,Z,V,z,q,$,ee,et,X,j,ea,el,eL,em]},ep=function(){return[eR,eb]},eC=function(){return[ew]},em=function(e){return postMessage(e,[e.buffer])},eg=function(e){return e&&e.size&&new g(e.size)},eM=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])}},ev=function(e,t,r,n,a){var i,s=ed(e,n,a,function(e,r){e?(s.terminate(),t.ondata.call(t,e)):(r[1]&&s.terminate(),t.ondata.call(t,e,r[0],r[1]))});s.postMessage(r),t.push=function(e,r){if(i)throw"stream finished";if(!t.ondata)throw"no stream handler";s.postMessage([e,i=r],[e.buffer])},t.terminate=function(){s.terminate()}},eF=function(e,t){return e[t]|e[t+1]<<8},eE=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},ey=function(e,t){return eE(e,t)+0x100000000*eE(e,t+4)},eI=function(e,t,r){for(;r;++t)e[t]=r,r>>>=8},eG=function(e,t){var r=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:2*(9==t.level),e[9]=3,0!=t.mtime&&eI(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),r){e[3]=8;for(var n=0;n<=r.length;++n)e[n+10]=r.charCodeAt(n)}},eR=function(e){if(31!=e[0]||139!=e[1]||8!=e[2])throw"invalid gzip data";var t=e[3],r=10;4&t&&(r+=e[10]|(e[11]<<8)+2);for(var n=(t>>3&1)+(t>>4&1);n>0;n-=!e[r++]);return r+(2&t)},eb=function(e){var t=e.length;return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0},eD=function(e){return 10+(e.filename&&e.filename.length+1||0)},eT=function(e,t){var r=t.level,n=0==r?0:r<6?1:9==r?3:2;e[0]=120,e[1]=n<<6|(n?32-2*n:1)},ew=function(e){if((15&e[0])!=8||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 eH(e,t){return t||"function"!=typeof e||(t=e,e={}),this.ondata=t,e}var ex=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(el(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}(),eJ=function(e,t){ev([eB,function(){return[eM,ex]}],this,eH.call(this,e,t),function(e){onmessage=eM(new ex(e.data))},6)};function eL(e,t){return el(e,t||{},0,0)}var eS=function(){function e(e){this.s={},this.p=new g(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,r=new g(t+e.length);r.set(this.p),r.set(e,t),this.p=r},e.prototype.c=function(e){this.d=this.s.i=e||!1;var t=this.s.b,r=Y(this.p,this.o,this.s);this.ondata(j(r,t,this.s.b),this.d),this.o=j(r,this.s.b-32768),this.s.b=this.o.length,this.p=j(this.p,this.s.p/8|0),this.s.p&=7},e.prototype.push=function(e,t){this.e(e),this.c(t)},e}(),eU=function(e){this.ondata=e,ev([ef,function(){return[eM,eS]}],this,0,function(){onmessage=eM(new eS)},7)};function eO(e,t){return Y(e,t)}(function(){function e(e,t){this.c=es(),this.l=0,this.v=1,ex.call(this,e,t)}e.prototype.push=function(e,t){ex.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e),this.l+=e.length;var r=el(e,this.o,this.v&&eD(this.o),t&&8,!t);this.v&&(eG(r,this.o),this.v=0),t&&(eI(r,r.length-8,this.c.d()),eI(r,r.length-4,this.l)),this.ondata(r,t)}})();var eP=function(){function e(e){this.v=1,eS.call(this,e)}return e.prototype.push=function(e,t){if(eS.prototype.e.call(this,e),this.v){var r=this.p.length>3?eR(this.p):4;if(r>=this.p.length&&!t)return;this.p=this.p.subarray(r),this.v=0}if(t){if(this.p.length<8)throw"invalid gzip stream";this.p=this.p.subarray(0,-8)}eS.prototype.c.call(this,t)},e}(),e_=function(e){this.ondata=e,ev([ef,ep,function(){return[eM,eS,eP]}],this,0,function(){onmessage=eM(new eP)},9)},eK=(function(){function e(e,t){this.c=eo(),this.v=1,ex.call(this,e,t)}e.prototype.push=function(e,t){ex.prototype.push.call(this,e,t)},e.prototype.p=function(e,t){this.c.p(e);var r=el(e,this.o,this.v&&2,t&&4,!t);this.v&&(eT(r,this.o),this.v=0),t&&eI(r,r.length-4,this.c.d()),this.ondata(r,t)}}(),function(){function e(e){this.v=1,eS.call(this,e)}return e.prototype.push=function(e,t){if(eS.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)}eS.prototype.c.call(this,t)},e}()),ek=function(e){this.ondata=e,ev([ef,eC,function(){return[eM,eS,eK]}],this,0,function(){onmessage=eM(new eK)},11)};function eN(e,t){return Y((ew(e),e.subarray(2,-4)),t)}var eQ=function(){function e(e){this.G=eP,this.I=eS,this.Z=eK,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 r=new g(this.p.length+e.length);r.set(this.p),r.set(e,this.p.length)}else this.p=e;if(this.p.length>2){var n=this,a=function(){n.ondata.apply(n,arguments)};this.s=31==this.p[0]&&139==this.p[1]&&8==this.p[2]?new this.G(a):(15&this.p[0])!=8||this.p[0]>>4>7||(this.p[0]<<8|this.p[1])%31?new this.I(a):new this.Z(a),this.s.push(this.p,t),this.p=null}}},e}();(function(e){this.G=e_,this.I=eU,this.Z=ek,this.ondata=e}).prototype.push=function(e,t){eQ.prototype.push.call(this,e,t)};var eX="u">typeof TextEncoder&&new TextEncoder,ej="u">typeof TextDecoder&&new TextDecoder,eY=0;try{ej.decode(en,{stream:!0}),eY=1}catch(e){}var eW=function(e){for(var t="",r=0;;){var n=e[r++],a=(n>127)+(n>223)+(n>239);if(r+a>e.length)return[t,j(e,r-1)];a?3==a?t+=String.fromCharCode(55296|(n=((15&n)<<18|(63&e[r++])<<12|(63&e[r++])<<6|63&e[r++])-65536)>>10,56320|1023&n):1&a?t+=String.fromCharCode((31&n)<<6|63&e[r++]):t+=String.fromCharCode((15&n)<<12|(63&e[r++])<<6|63&e[r++]):t+=String.fromCharCode(n)}};function eZ(e,t){if(t){for(var r=new g(e.length),n=0;n<e.length;++n)r[n]=e.charCodeAt(n);return r}if(eX)return eX.encode(e);for(var a=e.length,i=new g(e.length+(e.length>>1)),s=0,o=function(e){i[s++]=e},n=0;n<a;++n){if(s+5>i.length){var l=new g(s+8+(a-n<<1));l.set(i),i=l}var A=e.charCodeAt(n);A<128||t?o(A):(A<2048?o(192|A>>6):(A>55295&&A<57344?(o(240|(A=65536+(1047552&A)|1023&e.charCodeAt(++n))>>18),o(128|A>>12&63)):o(224|A>>12),o(128|A>>6&63)),o(128|63&A))}return j(i,0,s)}(function(e){this.ondata=e,eY?this.t=new TextDecoder:this.p=en}).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}return}if(!this.p)throw"stream finished";var r=new g(this.p.length+e.length);r.set(this.p),r.set(e,this.p.length);var n=eW(r),a=n[0],i=n[1];if(t){if(i.length)throw"invalid utf-8 data";this.p=null}else this.p=i;this.ondata(a,t)},(function(e){this.ondata=e}).prototype.push=function(e,t){if(!this.ondata)throw"no callback";if(this.d)throw"stream finished";this.ondata(eZ(e),this.d=t||!1)};var eV=function(e){return 1==e?3:e<6?2:+(9==e)},ez=function(e,t){for(;1!=eF(e,t);t+=4+eF(e,t+2));return[ey(e,t+12),ey(e,t+4),ey(e,t+20)]},eq=function(e){var t=0;if(e)for(var r in e){var n=e[r].length;if(n>65535)throw"extra field too long";t+=n+4}return t},e$=function(e,t,r,n,a,i,s,o){var l=n.length,A=r.extra,u=o&&o.length,c=eq(A);eI(e,t,null!=s?0x2014b50:0x4034b50),t+=4,null!=s&&(e[t++]=20,e[t++]=r.os),e[t]=20,t+=2,e[t++]=r.flag<<1|(null==i&&8),e[t++]=a&&8,e[t++]=255&r.compression,e[t++]=r.compression>>8;var h=new Date(null==r.mtime?Date.now():r.mtime),d=h.getFullYear()-1980;if(d<0||d>119)throw"date not in range 1980-2099";if(eI(e,t,d<<25|h.getMonth()+1<<21|h.getDate()<<16|h.getHours()<<11|h.getMinutes()<<5|h.getSeconds()>>>1),t+=4,null!=i&&(eI(e,t,r.crc),eI(e,t+4,i),eI(e,t+8,r.size)),eI(e,t+12,l),eI(e,t+14,c),t+=16,null!=s&&(eI(e,t,u),eI(e,t+6,r.attrs),eI(e,t+10,s),t+=14),e.set(n,t),t+=l,c)for(var f in A){var B=A[f],p=B.length;eI(e,t,+f),eI(e,t+2,p),e.set(B,t+4),t+=4+p}return u&&(e.set(o,t),t+=u),t},e0=function(e,t,r,n,a){eI(e,t,0x6054b50),eI(e,t+8,r),eI(e,t+10,r),eI(e,t+12,n),eI(e,t+16,a)},e1=function(){function e(e){this.filename=e,this.c=es(),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}();function e9(e,t){var r=this;t||(t={}),e1.call(this,e),this.d=new ex(t,function(e,t){r.ondata(null,e,t)}),this.compression=8,this.flag=eV(t.level)}function e2(e,t){var r=this;t||(t={}),e1.call(this,e),this.d=new eJ(t,function(e,t,n){r.ondata(e,t,n)}),this.compression=8,this.flag=eV(t.level),this.terminate=this.d.terminate}function e8(e){this.ondata=e,this.u=[],this.d=1}e9.prototype.process=function(e,t){try{this.d.push(e,t)}catch(e){this.ondata(e,null,t)}},e9.prototype.push=function(e,t){e1.prototype.push.call(this,e,t)},e2.prototype.process=function(e,t){this.d.push(e,t)},e2.prototype.push=function(e,t){e1.prototype.push.call(this,e,t)},e8.prototype.add=function(e){var t=this;if(2&this.d)throw"stream finished";var r=eZ(e.filename),n=r.length,a=e.comment,i=a&&eZ(a),s=n!=e.filename.length||i&&a.length!=i.length,o=n+eq(e.extra)+30;if(n>65535)throw"filename too long";var l=new g(o);e$(l,0,e,r,s);var A=[l],u=function(){for(var e=0,r=A;e<r.length;e++){var n=r[e];t.ondata(null,n,!1)}A=[]},c=this.d;this.d=0;var h=this.u.length,d=eA(e,{f:r,u:s,o:i,t:function(){e.terminate&&e.terminate()},r:function(){if(u(),c){var e=t.u[h+1];e?e.r():t.d=1}c=1}}),f=0;e.ondata=function(r,n,a){if(r)t.ondata(r,n,a),t.terminate();else if(f+=n.length,A.push(n),a){var i=new g(16);eI(i,0,0x8074b50),eI(i,4,e.crc),eI(i,8,f),eI(i,12,e.size),A.push(i),d.c=f,d.b=o+f+16,d.crc=e.crc,d.size=e.size,c&&d.r(),c=1}else c&&u()},this.u.push(d)},e8.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},e8.prototype.e=function(){for(var e=0,t=0,r=0,n=0,a=this.u;n<a.length;n++){var i=a[n];r+=46+i.f.length+eq(i.extra)+(i.o?i.o.length:0)}for(var s=new g(r+22),o=0,l=this.u;o<l.length;o++){var i=l[o];e$(s,e,i,i.f,i.u,i.c,t,i.o),e+=46+i.f.length+eq(i.extra)+(i.o?i.o.length:0),t+=i.b}e0(s,e,this.u.length,r,t),this.ondata(null,s,!0),this.d=2},e8.prototype.terminate=function(){for(var e=0,t=this.u;e<t.length;e++)t[e].t();this.d=2};var e3=function(){function e(){}return e.prototype.push=function(e,t){this.ondata(null,e,t)},e.compression=0,e}();function e6(){var e=this;this.i=new eS(function(t,r){e.ondata(null,t,r)})}function e4(e,t){var r=this;t<32e4?this.i=new eS(function(e,t){r.ondata(null,e,t)}):(this.i=new eU(function(e,t,n){r.ondata(e,t,n)}),this.terminate=this.i.terminate)}function e5(e){this.onfile=e,this.k=[],this.o={0:e3},this.p=en}e6.prototype.push=function(e,t){try{this.i.push(e,t)}catch(r){this.ondata(r,e,t)}},e6.compression=8,e4.prototype.push=function(e,t){this.i.terminate&&(e=j(e,0)),this.i.push(e,t)},e4.compression=8,e5.prototype.push=function(e,t){var r=this;if(!this.onfile)throw"no callback";if(!this.p)throw"stream finished";if(this.c>0){var n=Math.min(this.c,e.length),a=e.subarray(0,n);if(this.c-=n,this.d?this.d.push(a,!this.c):this.k[0].push(a),(e=e.subarray(n)).length)return this.push(e,t)}else{var i=0,s=0,o=void 0,l=void 0;this.p.length?e.length?((l=new g(this.p.length+e.length)).set(this.p),l.set(e,this.p.length)):l=this.p:l=e;for(var A=l.length,u=this.c,c=u&&this.d,h=this;s<A-4&&"break"!==function(){var e=eE(l,s);if(0x4034b50==e){i=1,o=s,h.d=null,h.c=0;var t=eF(l,s+6),n=eF(l,s+8),a=8&t,c=eF(l,s+26),d=eF(l,s+28);if(A>s+30+c+d){var f,B,p=[];h.k.unshift(p),i=2;var C=eE(l,s+18),m=eE(l,s+22),g=function(e,t){if(t){for(var r="",n=0;n<e.length;n+=16384)r+=String.fromCharCode.apply(null,e.subarray(n,n+16384));return r}if(ej)return ej.decode(e);var a=eW(e),i=a[0];if(a[1].length)throw"invalid utf-8 data";return i}(l.subarray(s+30,s+=30+c),!(2048&t));0xffffffff==C?(C=(f=a?[-2]:ez(l,s))[0],m=f[1]):a&&(C=-1),s+=d,h.c=C;var M={name:g,compression:n,start:function(){if(!M.ondata)throw"no callback";if(C){var e=r.o[n];if(!e)throw"unknown compression type "+n;(B=C<0?new e(g):new e(g,C,m)).ondata=function(e,t,r){M.ondata(e,t,r)};for(var t=0;t<p.length;t++){var a=p[t];B.push(a,!1)}r.k[0]==p&&r.c?r.d=B:B.push(en,!0)}else M.ondata(null,en,!0)},terminate:function(){B&&B.terminate&&B.terminate()}};C>=0&&(M.size=C,M.originalSize=m),h.onfile(M)}return"break"}if(u){if(0x8074b50==e)return o=s+=12+(-2==u&&8),i=3,h.c=0,"break";else if(0x2014b50==e)return o=s-=4,i=3,h.c=0,"break"}}();++s);if(this.p=en,u<0){var d=i?l.subarray(0,o-12-(-2==u&&8)-(0x8074b50==eE(l,o-16)&&4)):l.subarray(0,s);c?c.push(d,!!i):this.k[+(2==i)].push(d)}if(2&i)return this.push(l.subarray(s),t);this.p=l.subarray(s)}if(t){if(this.c)throw"invalid zip file";this.p=null}},e5.prototype.register=function(e){this.o[e.compression]=e};let e7=c.version>=152;class te extends p.DataTextureLoader{constructor(e){super(e),this.type=p.HalfFloatType}parse(e){let t={l:0,c:0,lc:0};function r(e,r,n,a,i){for(;n<e;)r=r<<8|G(a,i),n+=8;t.l=r>>(n-=e)&(1<<e)-1,t.c=r,t.lc=n}let n=Array(59),a={c:0,lc:0};function i(e,t,r,n){e=e<<8|G(r,n),t+=8,a.c=e,a.lc=t}let s={c:0,lc:0};function o(e,t,r,n,o,l,A,u,c,h){if(e==t){n<8&&(i(r,n,o,A),r=a.c,n=a.lc);var d=r>>(n-=8),d=new Uint8Array([d])[0];if(c.value+d>h)return!1;for(var f=u[c.value-1];d-- >0;)u[c.value++]=f}else{if(!(c.value<h))return!1;u[c.value++]=e}s.c=r,s.lc=n}function l(e){var t=65535&e;return t>32767?t-65536:t}let A={a:0,b:0};function u(e,t){var r=l(e),n=l(t),a=r+(1&n)+(n>>1),i=a-n;A.a=a,A.b=i}function c(e,t){var r=65535&t,n=(65535&e)-(r>>1)&65535;A.a=r+n-32768&65535,A.b=n}function h(e,l,A,u,c,h){var d=A.value,f=I(l,A),B=I(l,A);A.value+=4;var p=I(l,A);if(A.value+=4,f<0||f>=65537||B<0||B>=65537)throw"Something wrong with HUF_ENCSIZE";for(var C=Array(65537),m=Array(16384),g=0;g<16384;g++)m[g]={},m[g].len=0,m[g].lit=0,m[g].p=null;var M=u-(A.value-d);if(!function(e,a,i,s,o,l){for(var A=0,u=0;s<=o;s++){if(a.value-a.value>i)return!1;r(6,A,u,e,a);var c=t.l;if(A=t.c,u=t.lc,l[s]=c,63==c){if(a.value-a.value>i)throw"Something wrong with hufUnpackEncTable";r(8,A,u,e,a);var h=t.l+6;if(A=t.c,u=t.lc,s+h>o+1)throw"Something wrong with hufUnpackEncTable";for(;h--;)l[s++]=0;s--}else if(c>=59){var h=c-59+2;if(s+h>o+1)throw"Something wrong with hufUnpackEncTable";for(;h--;)l[s++]=0;s--}}!function(e){for(var t=0;t<=58;++t)n[t]=0;for(var t=0;t<65537;++t)n[e[t]]+=1;for(var r=0,t=58;t>0;--t){var a=r+n[t]>>1;n[t]=r,r=a}for(var t=0;t<65537;++t){var i=e[t];i>0&&(e[t]=i|n[i]++<<6)}}(l)}(e,A,M,f,B,C),p>8*(u-(A.value-d)))throw"Something wrong with hufUncompress";!function(e,t,r,n){for(;t<=r;t++){var a=e[t]>>6,i=63&e[t];if(a>>i)throw"Invalid table entry";if(i>14){var s=n[a>>i-14];if(s.len)throw"Invalid table entry";if(s.lit++,s.p){var o=s.p;s.p=Array(s.lit);for(var l=0;l<s.lit-1;++l)s.p[l]=o[l]}else s.p=[,];s.p[s.lit-1]=t}else if(i)for(var A=0,l=1<<14-i;l>0;l--){var s=n[(a<<14-i)+A];if(s.len||s.p)throw"Invalid table entry";s.len=i,s.lit=t,A++}}}(C,f,B,m),function(e,t,r,n,l,A,u,c,h,d){for(var f=0,B=0,p=Math.trunc(l.value+(A+7)/8);l.value<p;)for(i(f,B,r,l),f=a.c,B=a.lc;B>=14;){var C=t[f>>B-14&16383];if(C.len)B-=C.len,o(C.lit,u,f,B,r,n,l,h,d,c),f=s.c,B=s.lc;else{if(!C.p)throw"hufDecode issues";for(m=0;m<C.lit;m++){for(var m,g=63&e[C.p[m]];B<g&&l.value<p;)i(f,B,r,l),f=a.c,B=a.lc;if(B>=g&&e[C.p[m]]>>6==(f>>B-g&(1<<g)-1)){B-=g,o(C.p[m],u,f,B,r,n,l,h,d,c),f=s.c,B=s.lc;break}}if(m==C.lit)throw"hufDecode issues"}}var M=8-A&7;for(f>>=M,B-=M;B>0;){var C=t[f<<14-B&16383];if(C.len)B-=C.len,o(C.lit,u,f,B,r,n,l,h,d,c),f=s.c,B=s.lc;else throw"hufDecode issues"}}(C,m,e,l,A,p,B,h,c,{value:0})}function d(e){for(var t=1;t<e.length;t++){var r=e[t-1]+e[t]-128;e[t]=r}}function f(e,t){for(var r=0,n=Math.floor((e.length+1)/2),a=0,i=e.length-1;!(a>i)&&(t[a++]=e[r++],!(a>i));){;t[a++]=e[n++]}}function B(e){for(var t=e.byteLength,r=[],n=0,a=new DataView(e);t>0;){var i=a.getInt8(n++);if(i<0){var s=-i;t-=s+1;for(var o=0;o<s;o++)r.push(a.getUint8(n++))}else{var s=i;t-=2;for(var l=a.getUint8(n++),o=0;o<s+1;o++)r.push(l)}}return r}function C(e){return new DataView(e.array.buffer,e.offset.value,e.size)}function m(e){var t=new Uint8Array(B(e.viewer.buffer.slice(e.offset.value,e.offset.value+e.size))),r=new Uint8Array(t.length);return d(t),f(t,r),new DataView(r.buffer)}function g(e){var t=eN(e.array.slice(e.offset.value,e.offset.value+e.size)),r=new Uint8Array(t.length);return d(t),f(t,r),new DataView(r.buffer)}function M(e){for(var t=e.viewer,r={value:e.offset.value},n=new Uint16Array(e.width*e.scanlineBlockSize*(e.channels*e.type)),a=new Uint8Array(8192),i=0,s=Array(e.channels),o=0;o<e.channels;o++)s[o]={},s[o].start=i,s[o].end=s[o].start,s[o].nx=e.width,s[o].ny=e.lines,s[o].size=e.type,i+=s[o].nx*s[o].ny*s[o].size;var l=H(t,r),d=H(t,r);if(d>=8192)throw"Something is wrong with PIZ_COMPRESSION BITMAP_SIZE";if(l<=d)for(var o=0;o<d-l+1;o++)a[o+l]=R(t,r);var f=new Uint16Array(65536),B=function(e,t){for(var r=0,n=0;n<65536;++n)(0==n||e[n>>3]&1<<(7&n))&&(t[r++]=n);for(var a=r-1;r<65536;)t[r++]=0;return a}(a,f),p=I(t,r);h(e.array,t,r,p,n,i);for(var o=0;o<e.channels;++o)for(var C=s[o],m=0;m<s[o].size;++m)!function(e,t,r,n,a,i,s){for(var o=s<16384,l=r>a?a:r,h=1;h<=l;)h<<=1;for(h>>=1,d=h,h>>=1;h>=1;){for(var d,f,B,p,C,m=0,g=0+i*(a-d),M=i*h,v=i*d,F=n*h,E=n*d;m<=g;m+=v){for(var y=m,I=m+n*(r-d);y<=I;y+=E){var G=y+F,R=y+M,b=R+F;o?(u(e[y+t],e[R+t]),f=A.a,p=A.b,u(e[G+t],e[b+t]),B=A.a,C=A.b,u(f,B),e[y+t]=A.a,e[G+t]=A.b,u(p,C)):(c(e[y+t],e[R+t]),f=A.a,p=A.b,c(e[G+t],e[b+t]),B=A.a,C=A.b,c(f,B),e[y+t]=A.a,e[G+t]=A.b,c(p,C)),e[R+t]=A.a,e[b+t]=A.b}if(r&h){var R=y+M;o?u(e[y+t],e[R+t]):c(e[y+t],e[R+t]),f=A.a,e[R+t]=A.b,e[y+t]=f}}if(a&h)for(var y=m,I=m+n*(r-d);y<=I;y+=E){var G=y+F;o?u(e[y+t],e[G+t]):c(e[y+t],e[G+t]),f=A.a,e[G+t]=A.b,e[y+t]=f}d=h,h>>=1}}(n,C.start+m,C.nx,C.size,C.ny,C.nx*C.size,B);for(var g=i,M=0;M<g;++M)n[M]=f[n[M]];for(var v=0,F=new Uint8Array(n.buffer.byteLength),E=0;E<e.lines;E++)for(var y=0;y<e.channels;y++){var C=s[y],G=C.nx*C.size,b=new Uint8Array(n.buffer,2*C.end,2*G);F.set(b,v),v+=2*G,C.end+=G}return new DataView(F.buffer)}function v(e){var t=eN(e.array.slice(e.offset.value,e.offset.value+e.size));let r=e.lines*e.channels*e.width,n=1==e.type?new Uint16Array(r):new Uint32Array(r),a=0,i=0,s=[,,,,];for(let r=0;r<e.lines;r++)for(let r=0;r<e.channels;r++){let r=0;switch(e.type){case 1:s[0]=a,s[1]=s[0]+e.width,a=s[1]+e.width;for(let a=0;a<e.width;++a)r+=t[s[0]++]<<8|t[s[1]++],n[i]=r,i++;break;case 2:s[0]=a,s[1]=s[0]+e.width,s[2]=s[1]+e.width,a=s[2]+e.width;for(let a=0;a<e.width;++a)r+=t[s[0]++]<<24|t[s[1]++]<<16|t[s[2]++]<<8,n[i]=r,i++}}return new DataView(n.buffer)}function F(e){var t=e.viewer,r={value:e.offset.value},n=new Uint8Array(e.width*e.lines*(e.channels*e.type*2)),a={version:b(t,r),unknownUncompressedSize:b(t,r),unknownCompressedSize:b(t,r),acCompressedSize:b(t,r),dcCompressedSize:b(t,r),rleCompressedSize:b(t,r),rleUncompressedSize:b(t,r),rleRawSize:b(t,r),totalAcUncompressedCount:b(t,r),totalDcUncompressedCount:b(t,r),acCompression:b(t,r)};if(a.version<2)throw"EXRLoader.parse: "+U.compression+" version "+a.version+" is unsupported";for(var i=[],s=H(t,r)-2;s>0;){var o=E(t.buffer,r),l=R(t,r),A=l>>2&3,u=new Int8Array([(l>>4)-1])[0],c=R(t,r);i.push({name:o,index:u,type:c,compression:A}),s-=o.length+3}for(var d=U.channels,f=Array(e.channels),C=0;C<e.channels;++C){var m=f[C]={},M=d[C];m.name=M.name,m.compression=0,m.decoded=!1,m.type=M.pixelType,m.pLinear=M.pLinear,m.width=e.width,m.height=e.lines}for(var v={idx:[,,,]},F=0;F<e.channels;++F)for(var m=f[F],C=0;C<i.length;++C){var y=i[C];m.name==y.name&&(m.compression=y.compression,y.index>=0&&(v.idx[y.index]=F),m.offset=F)}if(a.acCompressedSize>0)switch(a.acCompression){case 0:var I=new Uint16Array(a.totalAcUncompressedCount);h(e.array,t,r,a.acCompressedSize,I,a.totalAcUncompressedCount);break;case 1:var G=e.array.slice(r.value,r.value+a.totalAcUncompressedCount),D=eN(G),I=new Uint16Array(D.buffer);r.value+=a.totalAcUncompressedCount}if(a.dcCompressedSize>0){var T=new Uint16Array(g({array:e.array,offset:r,size:a.dcCompressedSize}).buffer);r.value+=a.dcCompressedSize}if(a.rleRawSize>0){var G=e.array.slice(r.value,r.value+a.rleCompressedSize),D=eN(G),x=B(D.buffer);r.value+=a.rleCompressedSize}for(var J=0,L=Array(f.length),C=0;C<L.length;++C)L[C]=[];for(var S=0;S<e.lines;++S)for(var O=0;O<f.length;++O)L[O].push(J),J+=f[O].width*e.type*2;!function(e,t,r,n,a,i){var s=new DataView(i.buffer),o=r[e.idx[0]].width,l=r[e.idx[0]].height,A=Math.floor(o/8),u=Math.ceil(o/8),c=Math.ceil(l/8),h=o-(u-1)*8,d=l-(c-1)*8,f={value:0},B=[,,,],C=[,,,],m=[,,,],g=[,,,],M=[,,,];for(let r=0;r<3;++r)M[r]=t[e.idx[r]],B[r]=r<1?0:B[r-1]+u*c,C[r]=new Float32Array(64),m[r]=new Uint16Array(64),g[r]=new Uint16Array(64*u);for(let t=0;t<c;++t){var v,F,E=8;t==c-1&&(E=d);var y=8;for(let e=0;e<u;++e){e==u-1&&(y=h);for(let e=0;e<3;++e){m[e].fill(0),m[e][0]=a[B[e]++],function(e,t,r){for(var n,a=1;a<64;)65280==(n=t[e.value])?a=64:n>>8==255?a+=255&n:(r[a]=n,a++),e.value++}(f,n,m[e]),v=m[e],(F=C[e])[0]=w(v[0]),F[1]=w(v[1]),F[2]=w(v[5]),F[3]=w(v[6]),F[4]=w(v[14]),F[5]=w(v[15]),F[6]=w(v[27]),F[7]=w(v[28]),F[8]=w(v[2]),F[9]=w(v[4]),F[10]=w(v[7]),F[11]=w(v[13]),F[12]=w(v[16]),F[13]=w(v[26]),F[14]=w(v[29]),F[15]=w(v[42]),F[16]=w(v[3]),F[17]=w(v[8]),F[18]=w(v[12]),F[19]=w(v[17]),F[20]=w(v[25]),F[21]=w(v[30]),F[22]=w(v[41]),F[23]=w(v[43]),F[24]=w(v[9]),F[25]=w(v[11]),F[26]=w(v[18]),F[27]=w(v[24]),F[28]=w(v[31]),F[29]=w(v[40]),F[30]=w(v[44]),F[31]=w(v[53]),F[32]=w(v[10]),F[33]=w(v[19]),F[34]=w(v[23]),F[35]=w(v[32]),F[36]=w(v[39]),F[37]=w(v[45]),F[38]=w(v[52]),F[39]=w(v[54]),F[40]=w(v[20]),F[41]=w(v[22]),F[42]=w(v[33]),F[43]=w(v[38]),F[44]=w(v[46]),F[45]=w(v[51]),F[46]=w(v[55]),F[47]=w(v[60]),F[48]=w(v[21]),F[49]=w(v[34]),F[50]=w(v[37]),F[51]=w(v[47]),F[52]=w(v[50]),F[53]=w(v[56]),F[54]=w(v[59]),F[55]=w(v[61]),F[56]=w(v[35]),F[57]=w(v[36]),F[58]=w(v[48]),F[59]=w(v[49]),F[60]=w(v[57]),F[61]=w(v[58]),F[62]=w(v[62]),F[63]=w(v[63]),function(e){let t=.5*Math.cos(3.14159/16),r=.5*Math.cos(3.14159/8),n=.5*Math.cos(3*3.14159/16),a=.5*Math.cos(3*3.14159/8);for(var i=[,,,,],s=[,,,,],o=[,,,,],l=[,,,,],A=0;A<8;++A){var u=8*A;i[0]=r*e[u+2],i[1]=a*e[u+2],i[2]=r*e[u+6],i[3]=a*e[u+6],s[0]=t*e[u+1]+n*e[u+3]+.2777854612564676*e[u+5]+.09754573032714427*e[u+7],s[1]=n*e[u+1]-.09754573032714427*e[u+3]-t*e[u+5]-.2777854612564676*e[u+7],s[2]=.2777854612564676*e[u+1]-t*e[u+3]+.09754573032714427*e[u+5]+n*e[u+7],s[3]=.09754573032714427*e[u+1]-.2777854612564676*e[u+3]+n*e[u+5]-t*e[u+7],o[0]=.35355362513961314*(e[u+0]+e[u+4]),o[3]=.35355362513961314*(e[u+0]-e[u+4]),o[1]=i[0]+i[3],o[2]=i[1]-i[2],l[0]=o[0]+o[1],l[1]=o[3]+o[2],l[2]=o[3]-o[2],l[3]=o[0]-o[1],e[u+0]=l[0]+s[0],e[u+1]=l[1]+s[1],e[u+2]=l[2]+s[2],e[u+3]=l[3]+s[3],e[u+4]=l[3]-s[3],e[u+5]=l[2]-s[2],e[u+6]=l[1]-s[1],e[u+7]=l[0]-s[0]}for(var c=0;c<8;++c)i[0]=r*e[16+c],i[1]=a*e[16+c],i[2]=r*e[48+c],i[3]=a*e[48+c],s[0]=t*e[8+c]+n*e[24+c]+.2777854612564676*e[40+c]+.09754573032714427*e[56+c],s[1]=n*e[8+c]-.09754573032714427*e[24+c]-t*e[40+c]-.2777854612564676*e[56+c],s[2]=.2777854612564676*e[8+c]-t*e[24+c]+.09754573032714427*e[40+c]+n*e[56+c],s[3]=.09754573032714427*e[8+c]-.2777854612564676*e[24+c]+n*e[40+c]-t*e[56+c],o[0]=.35355362513961314*(e[c]+e[32+c]),o[3]=.35355362513961314*(e[c]-e[32+c]),o[1]=i[0]+i[3],o[2]=i[1]-i[2],l[0]=o[0]+o[1],l[1]=o[3]+o[2],l[2]=o[3]-o[2],l[3]=o[0]-o[1],e[0+c]=l[0]+s[0],e[8+c]=l[1]+s[1],e[16+c]=l[2]+s[2],e[24+c]=l[3]+s[3],e[32+c]=l[3]-s[3],e[40+c]=l[2]-s[2],e[48+c]=l[1]-s[1],e[56+c]=l[0]-s[0]}(C[e])}for(var I=C,G=0;G<64;++G){var R=I[0][G],b=I[1][G],D=I[2][G];I[0][G]=R+1.5747*D,I[1][G]=R-.1873*b-.4682*D,I[2][G]=R+1.8556*b}for(let t=0;t<3;++t)!function(e,t,r){for(var n,a=0;a<64;++a){t[r+a]=p.DataUtils.toHalfFloat((n=e[a])<=1?Math.sign(n)*Math.pow(Math.abs(n),2.2):Math.sign(n)*Math.pow(9.025013291561939,Math.abs(n)-1))}}(C[t],g[t],64*e)}let i=0;for(let n=0;n<3;++n){let a=r[e.idx[n]].type;for(let e=8*t;e<8*t+E;++e){i=M[n][e];for(let t=0;t<A;++t){let r=64*t+(7&e)*8;s.setUint16(i+0*a,g[n][r+0],!0),s.setUint16(i+2*a,g[n][r+1],!0),s.setUint16(i+4*a,g[n][r+2],!0),s.setUint16(i+6*a,g[n][r+3],!0),s.setUint16(i+8*a,g[n][r+4],!0),s.setUint16(i+10*a,g[n][r+5],!0),s.setUint16(i+12*a,g[n][r+6],!0),s.setUint16(i+14*a,g[n][r+7],!0),i+=16*a}}if(A!=u)for(let e=8*t;e<8*t+E;++e){let t=M[n][e]+8*A*2*a,r=64*A+(7&e)*8;for(let e=0;e<y;++e)s.setUint16(t+2*e*a,g[n][r+e],!0)}}}for(var T=new Uint16Array(o),s=new DataView(i.buffer),H=0;H<3;++H){r[e.idx[H]].decoded=!0;var x=r[e.idx[H]].type;if(2==r[H].type)for(var J=0;J<l;++J){let e=M[H][J];for(var L=0;L<o;++L)T[L]=s.getUint16(e+2*L*x,!0);for(var L=0;L<o;++L)s.setFloat32(e+2*L*x,w(T[L]),!0)}}}(v,L,f,I,T,n);for(var C=0;C<f.length;++C){var m=f[C];if(!m.decoded)if(2===m.compression)for(var P=0,_=0,S=0;S<e.lines;++S){for(var K=L[C][P],k=0;k<m.width;++k){for(var N=0;N<2*m.type;++N)n[K++]=x[_+N*m.width*m.height];_++}P++}else throw"EXRLoader.parse: unsupported channel compression"}return new DataView(n.buffer)}function E(e,t){for(var r=new Uint8Array(e),n=0;0!=r[t.value+n];)n+=1;var a=new TextDecoder().decode(r.slice(t.value,t.value+n));return t.value=t.value+n+1,a}function y(e,t){var r=e.getInt32(t.value,!0);return t.value=t.value+4,r}function I(e,t){var r=e.getUint32(t.value,!0);return t.value=t.value+4,r}function G(e,t){var r=e[t.value];return t.value=t.value+1,r}function R(e,t){var r=e.getUint8(t.value);return t.value=t.value+1,r}let b=function(e,t){let r;return r="getBigInt64"in DataView.prototype?Number(e.getBigInt64(t.value,!0)):e.getUint32(t.value+4,!0)+Number(e.getUint32(t.value,!0)<<32),t.value+=8,r};function D(e,t){var r=e.getFloat32(t.value,!0);return t.value+=4,r}function T(e,t){return p.DataUtils.toHalfFloat(D(e,t))}function w(e){var t=(31744&e)>>10,r=1023&e;return(e>>15?-1:1)*(t?31===t?r?NaN:1/0:Math.pow(2,t-15)*(1+r/1024):r/1024*6103515625e-14)}function H(e,t){var r=e.getUint16(t.value,!0);return t.value+=2,r}function x(e,t){return w(H(e,t))}let J=new DataView(e),L=new Uint8Array(e),S={value:0},U=function(e,t,r){let n={};if(0x1312f76!=e.getUint32(0,!0))throw"THREE.EXRLoader: provided file doesn't appear to be in OpenEXR format.";n.version=e.getUint8(4);let a=e.getUint8(5);n.spec={singleTile:!!(2&a),longName:!!(4&a),deepFormat:!!(8&a),multiPart:!!(16&a)},r.value=8;for(var i=!0;i;){var s=E(t,r);if(0==s)i=!1;else{var o=E(t,r),l=I(e,r),A=function(e,t,r,n,a){var i,s,o,l,A,u,c;if("string"===n||"stringvector"===n||"iccProfile"===n)return i=new TextDecoder().decode(new Uint8Array(t).slice(r.value,r.value+a)),r.value=r.value+a,i;if("chlist"===n)return function(e,t,r,n){for(var a=r.value,i=[];r.value<a+n-1;){var s=E(t,r),o=y(e,r),l=R(e,r);r.value+=3;var A=y(e,r),u=y(e,r);i.push({name:s,pixelType:o,pLinear:l,xSampling:A,ySampling:u})}return r.value+=1,i}(e,t,r,a);if("chromaticities"===n)return s=D(e,r),o=D(e,r),l=D(e,r),A=D(e,r),u=D(e,r),{redX:s,redY:o,greenX:l,greenY:A,blueX:u,blueY:D(e,r),whiteX:D(e,r),whiteY:D(e,r)};if("compression"===n)return["NO_COMPRESSION","RLE_COMPRESSION","ZIPS_COMPRESSION","ZIP_COMPRESSION","PIZ_COMPRESSION","PXR24_COMPRESSION","B44_COMPRESSION","B44A_COMPRESSION","DWAA_COMPRESSION","DWAB_COMPRESSION"][R(e,r)];if("box2i"===n)return c=I(e,r),{xMin:c,yMin:I(e,r),xMax:I(e,r),yMax:I(e,r)};else if("lineOrder"===n)return["INCREASING_Y"][R(e,r)];else if("float"===n)return D(e,r);else if("v2f"===n)return[D(e,r),D(e,r)];else if("v3f"===n)return[D(e,r),D(e,r),D(e,r)];else if("int"===n)return y(e,r);else if("rational"===n)return[y(e,r),I(e,r)];else if("timecode"===n)return[I(e,r),I(e,r)];else return"preview"===n?(r.value+=a,"skipped"):(r.value+=a,void 0)}(e,t,r,o,l);void 0===A?console.warn(`EXRLoader.parse: skipped unknown header attribute type '${o}'.`):n[s]=A}}if((-5&a)!=0)throw console.error("EXRHeader:",n),"THREE.EXRLoader: provided file is currently unsupported.";return n}(J,e,S),O=function(e,t,r,n,a){let i={size:0,viewer:t,array:r,offset:n,width:e.dataWindow.xMax-e.dataWindow.xMin+1,height:e.dataWindow.yMax-e.dataWindow.yMin+1,channels:e.channels.length,bytesPerLine:null,lines:null,inputSize:null,type:e.channels[0].pixelType,uncompress:null,getter:null,format:null,[e7?"colorSpace":"encoding"]:null};switch(e.compression){case"NO_COMPRESSION":i.lines=1,i.uncompress=C;break;case"RLE_COMPRESSION":i.lines=1,i.uncompress=m;break;case"ZIPS_COMPRESSION":i.lines=1,i.uncompress=g;break;case"ZIP_COMPRESSION":i.lines=16,i.uncompress=g;break;case"PIZ_COMPRESSION":i.lines=32,i.uncompress=M;break;case"PXR24_COMPRESSION":i.lines=16,i.uncompress=v;break;case"DWAA_COMPRESSION":i.lines=32,i.uncompress=F;break;case"DWAB_COMPRESSION":i.lines=256,i.uncompress=F;break;default:throw"EXRLoader.parse: "+e.compression+" is unsupported"}if(i.scanlineBlockSize=i.lines,1==i.type)switch(a){case p.FloatType:i.getter=x,i.inputSize=2;break;case p.HalfFloatType:i.getter=H,i.inputSize=2}else if(2==i.type)switch(a){case p.FloatType:i.getter=D,i.inputSize=4;break;case p.HalfFloatType:i.getter=T,i.inputSize=4}else throw"EXRLoader.parse: unsupported pixelType "+i.type+" for "+e.compression+".";i.blockCount=(e.dataWindow.yMax+1)/i.scanlineBlockSize;for(var s=0;s<i.blockCount;s++)b(t,n);i.outputChannels=3==i.channels?4:i.channels;let o=i.width*i.height*i.outputChannels;switch(a){case p.FloatType:i.byteArray=new Float32Array(o),i.channels<i.outputChannels&&i.byteArray.fill(1,0,o);break;case p.HalfFloatType:i.byteArray=new Uint16Array(o),i.channels<i.outputChannels&&i.byteArray.fill(15360,0,o);break;default:console.error("THREE.EXRLoader: unsupported type: ",a)}return i.bytesPerLine=i.width*i.inputSize*i.channels,4==i.outputChannels?i.format=p.RGBAFormat:i.format=p.RedFormat,e7?i.colorSpace="srgb-linear":i.encoding=3e3,i}(U,J,L,S,this.type),P={value:0},_={R:0,G:1,B:2,A:3,Y:0};for(let e=0;e<O.height/O.scanlineBlockSize;e++){let t=I(J,S);O.size=I(J,S),O.lines=t+O.scanlineBlockSize>O.height?O.height-t:O.scanlineBlockSize;let r=O.size<O.lines*O.bytesPerLine?O.uncompress(O):C(O);S.value+=O.size;for(let t=0;t<O.scanlineBlockSize;t++){let n=t+e*O.scanlineBlockSize;if(n>=O.height)break;for(let e=0;e<O.channels;e++){let a=_[U.channels[e].name];for(let i=0;i<O.width;i++){P.value=(t*(O.channels*O.width)+e*O.width+i)*O.inputSize;let s=(O.height-1-n)*(O.width*O.outputChannels)+i*O.outputChannels+a;O.byteArray[s]=O.getter(r,P)}}}}return{header:U,width:O.width,height:O.height,data:O.byteArray,format:O.format,[e7?"colorSpace":"encoding"]:O[e7?"colorSpace":"encoding"],type:this.type}}setDataType(e){return this.type=e,this}load(e,t,r,n){return super.load(e,function(e,r){e7?e.colorSpace=r.colorSpace:e.encoding=r.encoding,e.minFilter=p.LinearFilter,e.magFilter=p.LinearFilter,e.generateMipmaps=!1,e.flipY=!1,t&&t(e,r)},r,n)}}var tt=e.i(8560);let tr=(e,t,r)=>{let n;switch(e){case A.UnsignedByteType:n=new Uint8ClampedArray(t*r*4);break;case A.HalfFloatType:n=new Uint16Array(t*r*4);break;case A.UnsignedIntType:n=new Uint32Array(t*r*4);break;case A.ByteType:n=new Int8Array(t*r*4);break;case A.ShortType:n=new Int16Array(t*r*4);break;case A.IntType:n=new Int32Array(t*r*4);break;case A.FloatType:n=new Float32Array(t*r*4);break;default:throw Error("Unsupported data type")}return n};class tn{_renderer;_rendererIsDisposable=!1;_material;_scene;_camera;_quad;_renderTarget;_width;_height;_type;_colorSpace;_supportsReadPixels=!0;constructor(e){this._width=e.width,this._height=e.height,this._type=e.type,this._colorSpace=e.colorSpace;const r={format:A.RGBAFormat,depthBuffer:!1,stencilBuffer:!1,type:this._type,colorSpace:this._colorSpace,anisotropy:e.renderTargetOptions?.anisotropy!==void 0?e.renderTargetOptions?.anisotropy:1,generateMipmaps:e.renderTargetOptions?.generateMipmaps!==void 0&&e.renderTargetOptions?.generateMipmaps,magFilter:e.renderTargetOptions?.magFilter!==void 0?e.renderTargetOptions?.magFilter:A.LinearFilter,minFilter:e.renderTargetOptions?.minFilter!==void 0?e.renderTargetOptions?.minFilter:A.LinearFilter,samples:e.renderTargetOptions?.samples!==void 0?e.renderTargetOptions?.samples:void 0,wrapS:e.renderTargetOptions?.wrapS!==void 0?e.renderTargetOptions?.wrapS:A.ClampToEdgeWrapping,wrapT:e.renderTargetOptions?.wrapT!==void 0?e.renderTargetOptions?.wrapT:A.ClampToEdgeWrapping};if(this._material=e.material,e.renderer?this._renderer=e.renderer:(this._renderer=tn.instantiateRenderer(),this._rendererIsDisposable=!0),this._scene=new A.Scene,this._camera=new A.OrthographicCamera,this._camera.position.set(0,0,10),this._camera.left=-.5,this._camera.right=.5,this._camera.top=.5,this._camera.bottom=-.5,this._camera.updateProjectionMatrix(),!((e,r,n,a)=>{if(void 0!==t)return t;let i=new A.WebGLRenderTarget(1,1,a);r.setRenderTarget(i);let s=new A.Mesh(new A.PlaneGeometry,new A.MeshBasicMaterial({color:0xffffff}));r.render(s,n),r.setRenderTarget(null);let o=tr(e,i.width,i.height);return r.readRenderTargetPixels(i,0,0,i.width,i.height,o),i.dispose(),s.geometry.dispose(),s.material.dispose(),t=0!==o[0]})(this._type,this._renderer,this._camera,r)){let e;this._type===A.HalfFloatType&&(e=this._renderer.extensions.has("EXT_color_buffer_float")?A.FloatType:void 0),void 0!==e?(console.warn(`This browser does not support reading pixels from ${this._type} RenderTargets, switching to ${A.FloatType}`),this._type=e):(this._supportsReadPixels=!1,console.warn("This browser dos not support toArray or toDataTexture, calls to those methods will result in an error thrown"))}this._quad=new A.Mesh(new A.PlaneGeometry,this._material),this._quad.geometry.computeBoundingBox(),this._scene.add(this._quad),this._renderTarget=new A.WebGLRenderTarget(this.width,this.height,r),this._renderTarget.texture.mapping=e.renderTargetOptions?.mapping!==void 0?e.renderTargetOptions?.mapping:A.UVMapping}static instantiateRenderer(){let e=new tt.WebGLRenderer;return e.setSize(128,128),e}render=()=>{this._renderer.setRenderTarget(this._renderTarget);try{this._renderer.render(this._scene,this._camera)}catch(e){throw this._renderer.setRenderTarget(null),e}this._renderer.setRenderTarget(null)};toArray(){if(!this._supportsReadPixels)throw Error("Can't read pixels in this browser");let e=tr(this._type,this._width,this._height);return this._renderer.readRenderTargetPixels(this._renderTarget,0,0,this._width,this._height,e),e}toDataTexture(e){let t=new A.DataTexture(this.toArray(),this.width,this.height,A.RGBAFormat,this._type,e?.mapping||A.UVMapping,e?.wrapS||A.ClampToEdgeWrapping,e?.wrapT||A.ClampToEdgeWrapping,e?.magFilter||A.LinearFilter,e?.minFilter||A.LinearFilter,e?.anisotropy||1,A.LinearSRGBColorSpace);return t.generateMipmaps=e?.generateMipmaps!==void 0&&e?.generateMipmaps,t}disposeOnDemandRenderer(){this._renderer.setRenderTarget(null),this._rendererIsDisposable&&(this._renderer.dispose(),this._renderer.forceContextLoss())}dispose(e){this.disposeOnDemandRenderer(),e&&this.renderTarget.dispose(),this.material instanceof A.ShaderMaterial&&Object.values(this.material.uniforms).forEach(e=>{e.value instanceof A.Texture&&e.value.dispose()}),Object.values(this.material).forEach(e=>{e instanceof A.Texture&&e.dispose()}),this.material.dispose(),this._quad.geometry.dispose()}get width(){return this._width}set width(e){this._width=e,this._renderTarget.setSize(this._width,this._height)}get height(){return this._height}set height(e){this._height=e,this._renderTarget.setSize(this._width,this._height)}get renderer(){return this._renderer}get renderTarget(){return this._renderTarget}set renderTarget(e){this._renderTarget=e,this._width=e.width,this._height=e.height}get material(){return this._material}get type(){return this._type}get colorSpace(){return this._colorSpace}}var ta=A;class ti extends Error{}class ts extends Error{}let to=(e,t,r)=>{let n=RegExp(`${t}="([^"]*)"`,"i").exec(e);if(n)return n[1];let a=RegExp(`<${t}[^>]*>([\\s\\S]*?)</${t}>`,"i").exec(e);if(a){let e=a[1].match(/<rdf:li>([^<]*)<\/rdf:li>/g);return e&&3===e.length?e.map(e=>e.replace(/<\/?rdf:li>/g,"")):a[1].trim()}if(void 0!==r)return r;throw Error(`Can't find ${t} in gainmap metadata`)};class tl{options;constructor(e){this.options={debug:!!e&&void 0!==e.debug&&e.debug,extractFII:!e||void 0===e.extractFII||e.extractFII,extractNonFII:!e||void 0===e.extractNonFII||e.extractNonFII}}extract(e){return new Promise((t,r)=>{let n,a=this.options.debug,i=new DataView(e.buffer);if(65496!==i.getUint16(0))return void r(Error("Not a valid jpeg"));let s=i.byteLength,o=2,l=0;for(;o<s;){if(++l>250)return void r(Error(`Found no marker after ${l} loops 😵`));if(255!==i.getUint8(o))return void r(Error(`Not a valid marker at offset 0x${o.toString(16)}, found: 0x${i.getUint8(o).toString(16)}`));if(n=i.getUint8(o+1),a&&console.log(`Marker: ${n.toString(16)}`),226===n){a&&console.log("Found APP2 marker (0xffe2)");let e=o+4;if(0x4d504600===i.getUint32(e)){let n,a=e+4;if(18761===i.getUint16(a))n=!1;else{if(19789!==i.getUint16(a))return void r(Error("No valid endianness marker found in TIFF header"));n=!0}if(42!==i.getUint16(a+2,!n))return void r(Error("Not valid TIFF data! (no 0x002A marker)"));let s=i.getUint32(a+4,!n);if(s<8)return void r(Error("Not valid TIFF data! (First offset less than 8)"));let o=a+s,l=i.getUint16(o,!n),A=o+2,u=0;for(let e=A;e<A+12*l;e+=12)45057===i.getUint16(e,!n)&&(u=i.getUint32(e+8,!n));let c=o+2+12*l+4,h=[];for(let e=c;e<c+16*u;e+=16){let t={MPType:i.getUint32(e,!n),size:i.getUint32(e+4,!n),dataOffset:i.getUint32(e+8,!n),dependantImages:i.getUint32(e+12,!n),start:-1,end:-1,isFII:!1};t.dataOffset?(t.start=a+t.dataOffset,t.isFII=!1):(t.start=0,t.isFII=!0),t.end=t.start+t.size,h.push(t)}if(this.options.extractNonFII&&h.length){let e=new Blob([i]),r=[];for(let t of h){if(t.isFII&&!this.options.extractFII)continue;let n=e.slice(t.start,t.end+1,"image/jpeg");r.push(n)}t(r)}}}o+=2+i.getUint16(o+2)}})}}let tA=async e=>{let t=(e=>{let t,r=(t="u">typeof TextDecoder?new TextDecoder().decode(e):e.toString()).indexOf("<x:xmpmeta");for(;-1!==r;){let e=t.indexOf("x:xmpmeta>",r),n=t.slice(r,e+10);try{let e=to(n,"hdrgm:GainMapMin","0"),t=to(n,"hdrgm:GainMapMax"),r=to(n,"hdrgm:Gamma","1"),a=to(n,"hdrgm:OffsetSDR","0.015625"),i=to(n,"hdrgm:OffsetHDR","0.015625"),s=/hdrgm:HDRCapacityMin="([^"]*)"/.exec(n),o=s?s[1]:"0",l=/hdrgm:HDRCapacityMax="([^"]*)"/.exec(n);if(!l)throw Error("Incomplete gainmap metadata");let A=l[1];return{gainMapMin:Array.isArray(e)?e.map(e=>parseFloat(e)):[parseFloat(e),parseFloat(e),parseFloat(e)],gainMapMax:Array.isArray(t)?t.map(e=>parseFloat(e)):[parseFloat(t),parseFloat(t),parseFloat(t)],gamma:Array.isArray(r)?r.map(e=>parseFloat(e)):[parseFloat(r),parseFloat(r),parseFloat(r)],offsetSdr:Array.isArray(a)?a.map(e=>parseFloat(e)):[parseFloat(a),parseFloat(a),parseFloat(a)],offsetHdr:Array.isArray(i)?i.map(e=>parseFloat(e)):[parseFloat(i),parseFloat(i),parseFloat(i)],hdrCapacityMin:parseFloat(o),hdrCapacityMax:parseFloat(A)}}catch(e){}r=t.indexOf("<x:xmpmeta",e)}})(e);if(!t)throw new ts("Gain map XMP metadata not found");let r=new tl({extractFII:!0,extractNonFII:!0}),n=await r.extract(e);if(2!==n.length)throw new ti("Gain map recovery image not found");return{sdr:new Uint8Array(await n[0].arrayBuffer()),gainMap:new Uint8Array(await n[1].arrayBuffer()),metadata:t}},tu=e=>new Promise((t,r)=>{let n=document.createElement("img");n.onload=()=>{t(n)},n.onerror=e=>{r(e)},n.src=URL.createObjectURL(e)});class tc extends ta.Loader{_renderer;_renderTargetOptions;_internalLoadingManager;_config;constructor(e,t){super(t),this._config=e,e.renderer&&(this._renderer=e.renderer),this._internalLoadingManager=new ta.LoadingManager}setRenderer(e){return this._renderer=e,this}setRenderTargetOptions(e){return this._renderTargetOptions=e,this}prepareQuadRenderer(){this._renderer||console.warn("WARNING: A Renderer was not passed to this Loader constructor or in setRenderer, the result of this Loader will need to be converted to a Data Texture with toDataTexture() before you can use it in your renderer.");let e=this._config.createMaterial({gainMapMax:[1,1,1],gainMapMin:[0,0,0],gamma:[1,1,1],offsetHdr:[1,1,1],offsetSdr:[1,1,1],hdrCapacityMax:1,hdrCapacityMin:0,maxDisplayBoost:1,gainMap:new ta.Texture,sdr:new ta.Texture});return this._config.createQuadRenderer({width:16,height:16,type:ta.HalfFloatType,colorSpace:ta.LinearSRGBColorSpace,material:e,renderer:this._renderer,renderTargetOptions:this._renderTargetOptions})}async processImages(e,t,r){let n,a,i=t?new Blob([t],{type:"image/jpeg"}):void 0,s=new Blob([e],{type:"image/jpeg"}),o=!1;if("u"<typeof createImageBitmap){let e=await Promise.all([i?tu(i):Promise.resolve(void 0),tu(s)]);a=e[0],n=e[1],o="flipY"===r}else{let e=await Promise.all([i?createImageBitmap(i,{imageOrientation:r||"flipY"}):Promise.resolve(void 0),createImageBitmap(s,{imageOrientation:r||"flipY"})]);a=e[0],n=e[1]}return{sdrImage:n,gainMapImage:a,needsFlip:o}}createTextures(e,t,r){let n=new ta.Texture(t||new ImageData(2,2),ta.UVMapping,ta.ClampToEdgeWrapping,ta.ClampToEdgeWrapping,ta.LinearFilter,ta.LinearMipMapLinearFilter,ta.RGBAFormat,ta.UnsignedByteType,1,ta.LinearSRGBColorSpace);n.flipY=r,n.needsUpdate=!0;let a=new ta.Texture(e,ta.UVMapping,ta.ClampToEdgeWrapping,ta.ClampToEdgeWrapping,ta.LinearFilter,ta.LinearMipMapLinearFilter,ta.RGBAFormat,ta.UnsignedByteType,1,ta.SRGBColorSpace);return a.flipY=r,a.needsUpdate=!0,{gainMap:n,sdr:a}}updateQuadRenderer(e,t,r,n,a){e.width=t.width,e.height=t.height,e.material.gainMap=r,e.material.sdr=n,e.material.gainMapMin=a.gainMapMin,e.material.gainMapMax=a.gainMapMax,e.material.offsetHdr=a.offsetHdr,e.material.offsetSdr=a.offsetSdr,e.material.gamma=a.gamma,e.material.hdrCapacityMin=a.hdrCapacityMin,e.material.hdrCapacityMax=a.hdrCapacityMax,e.material.maxDisplayBoost=Math.pow(2,a.hdrCapacityMax),e.material.needsUpdate=!0}}var th=A;let td=`
varying vec2 vUv;

void main() {
  vUv = uv;
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
}
`,tf=`
// min half float value
#define HALF_FLOAT_MIN vec3( -65504, -65504, -65504 )
// max half float value
#define HALF_FLOAT_MAX vec3( 65504, 65504, 65504 )

uniform sampler2D sdr;
uniform sampler2D gainMap;
uniform vec3 gamma;
uniform vec3 offsetHdr;
uniform vec3 offsetSdr;
uniform vec3 gainMapMin;
uniform vec3 gainMapMax;
uniform float weightFactor;

varying vec2 vUv;

void main() {
  vec3 rgb = texture2D( sdr, vUv ).rgb;
  vec3 recovery = texture2D( gainMap, vUv ).rgb;
  vec3 logRecovery = pow( recovery, gamma );
  vec3 logBoost = gainMapMin * ( 1.0 - logRecovery ) + gainMapMax * logRecovery;
  vec3 hdrColor = (rgb + offsetSdr) * exp2( logBoost * weightFactor ) - offsetHdr;
  vec3 clampedHdrColor = max( HALF_FLOAT_MIN, min( HALF_FLOAT_MAX, hdrColor ));
  gl_FragColor = vec4( clampedHdrColor , 1.0 );
}
`;class tB extends th.ShaderMaterial{_maxDisplayBoost;_hdrCapacityMin;_hdrCapacityMax;constructor({gamma:e,offsetHdr:t,offsetSdr:r,gainMapMin:n,gainMapMax:a,maxDisplayBoost:i,hdrCapacityMin:s,hdrCapacityMax:o,sdr:l,gainMap:A}){super({name:"GainMapDecoderMaterial",vertexShader:td,fragmentShader:tf,uniforms:{sdr:{value:l},gainMap:{value:A},gamma:{value:new th.Vector3(1/e[0],1/e[1],1/e[2])},offsetHdr:{value:new th.Vector3().fromArray(t)},offsetSdr:{value:new th.Vector3().fromArray(r)},gainMapMin:{value:new th.Vector3().fromArray(n)},gainMapMax:{value:new th.Vector3().fromArray(a)},weightFactor:{value:(Math.log2(i)-s)/(o-s)}},blending:th.NoBlending,depthTest:!1,depthWrite:!1}),this._maxDisplayBoost=i,this._hdrCapacityMin=s,this._hdrCapacityMax=o,this.needsUpdate=!0,this.uniformsNeedUpdate=!0}get sdr(){return this.uniforms.sdr.value}set sdr(e){this.uniforms.sdr.value=e}get gainMap(){return this.uniforms.gainMap.value}set gainMap(e){this.uniforms.gainMap.value=e}get offsetHdr(){return this.uniforms.offsetHdr.value.toArray()}set offsetHdr(e){this.uniforms.offsetHdr.value.fromArray(e)}get offsetSdr(){return this.uniforms.offsetSdr.value.toArray()}set offsetSdr(e){this.uniforms.offsetSdr.value.fromArray(e)}get gainMapMin(){return this.uniforms.gainMapMin.value.toArray()}set gainMapMin(e){this.uniforms.gainMapMin.value.fromArray(e)}get gainMapMax(){return this.uniforms.gainMapMax.value.toArray()}set gainMapMax(e){this.uniforms.gainMapMax.value.fromArray(e)}get gamma(){let e=this.uniforms.gamma.value;return[1/e.x,1/e.y,1/e.z]}set gamma(e){let t=this.uniforms.gamma.value;t.x=1/e[0],t.y=1/e[1],t.z=1/e[2]}get hdrCapacityMin(){return this._hdrCapacityMin}set hdrCapacityMin(e){this._hdrCapacityMin=e,this.calculateWeight()}get hdrCapacityMax(){return this._hdrCapacityMax}set hdrCapacityMax(e){this._hdrCapacityMax=e,this.calculateWeight()}get maxDisplayBoost(){return this._maxDisplayBoost}set maxDisplayBoost(e){this._maxDisplayBoost=Math.max(1,Math.min(65504,e)),this.calculateWeight()}calculateWeight(){let e=(Math.log2(this._maxDisplayBoost)-this._hdrCapacityMin)/(this._hdrCapacityMax-this._hdrCapacityMin);this.uniforms.weightFactor.value=Math.max(0,Math.min(1,e))}}tt.WebGLRenderer;class tp extends tc{constructor(e,t){super({renderer:e,createMaterial:e=>new tB(e),createQuadRenderer:e=>new tn(e)},t)}async render(e,t,r,n){let{sdrImage:a,gainMapImage:i,needsFlip:s}=await this.processImages(r,n,"flipY"),{gainMap:o,sdr:l}=this.createTextures(a,i,s);this.updateQuadRenderer(e,a,o,l,t),e.render()}}class tC extends tp{load([e,t,r],n,a,i){let s,o,l,A=this.prepareQuadRenderer(),u=async()=>{if(s&&o&&l){try{await this.render(A,l,s,o)}catch(n){this.manager.itemError(e),this.manager.itemError(t),this.manager.itemError(r),"function"==typeof i&&i(n),A.disposeOnDemandRenderer();return}"function"==typeof n&&n(A),this.manager.itemEnd(e),this.manager.itemEnd(t),this.manager.itemEnd(r),A.disposeOnDemandRenderer()}},c=!0,h=0,d=0,f=!0,B=0,p=0,C=!0,m=0,g=0,M=()=>{"function"==typeof a&&a(new ProgressEvent("progress",{lengthComputable:c&&f&&C,loaded:d+p+g,total:h+B+m}))};this.manager.itemStart(e),this.manager.itemStart(t),this.manager.itemStart(r);let v=new th.FileLoader(this._internalLoadingManager);v.setResponseType("arraybuffer"),v.setRequestHeader(this.requestHeader),v.setPath(this.path),v.setWithCredentials(this.withCredentials),v.load(e,async e=>{if("string"==typeof e)throw Error("Invalid sdr buffer");s=e,await u()},e=>{c=e.lengthComputable,d=e.loaded,h=e.total,M()},t=>{this.manager.itemError(e),"function"==typeof i&&i(t)});let F=new th.FileLoader(this._internalLoadingManager);F.setResponseType("arraybuffer"),F.setRequestHeader(this.requestHeader),F.setPath(this.path),F.setWithCredentials(this.withCredentials),F.load(t,async e=>{if("string"==typeof e)throw Error("Invalid gainmap buffer");o=e,await u()},e=>{f=e.lengthComputable,p=e.loaded,B=e.total,M()},e=>{this.manager.itemError(t),"function"==typeof i&&i(e)});let E=new th.FileLoader(this._internalLoadingManager);return E.setRequestHeader(this.requestHeader),E.setPath(this.path),E.setWithCredentials(this.withCredentials),E.load(r,async e=>{if("string"!=typeof e)throw Error("Invalid metadata string");l=JSON.parse(e),await u()},e=>{C=e.lengthComputable,g=e.loaded,m=e.total,M()},e=>{this.manager.itemError(r),"function"==typeof i&&i(e)}),A}}class tm extends tp{load(e,t,r,n){let a=this.prepareQuadRenderer(),i=new th.FileLoader(this._internalLoadingManager);return i.setResponseType("arraybuffer"),i.setRequestHeader(this.requestHeader),i.setPath(this.path),i.setWithCredentials(this.withCredentials),this.manager.itemStart(e),i.load(e,async r=>{let i,s,o;if("string"==typeof r)throw Error("Invalid buffer, received [string], was expecting [ArrayBuffer]");let l=new Uint8Array(r);try{let e=await tA(l);i=e.sdr,s=e.gainMap,o=e.metadata}catch(t){if(t instanceof ts||t instanceof ti)console.warn(`Failure to reconstruct an HDR image from ${e}: Gain map metadata not found in the file, HDRJPGLoader will render the SDR jpeg`),o={gainMapMin:[0,0,0],gainMapMax:[1,1,1],gamma:[1,1,1],hdrCapacityMin:0,hdrCapacityMax:1,offsetHdr:[0,0,0],offsetSdr:[0,0,0]},i=l;else throw t}try{await this.render(a,o,i.buffer,s?.buffer)}catch(t){this.manager.itemError(e),"function"==typeof n&&n(t),a.disposeOnDemandRenderer();return}"function"==typeof t&&t(a),this.manager.itemEnd(e),a.disposeOnDemandRenderer()},r,t=>{this.manager.itemError(e),"function"==typeof n&&n(t)}),a}}let tg={apartment:"lebombo_1k.hdr",city:"potsdamer_platz_1k.hdr",dawn:"kiara_1_dawn_1k.hdr",forest:"forest_slope_1k.hdr",lobby:"st_fagans_interior_1k.hdr",night:"dikhololo_night_1k.hdr",park:"rooitou_park_1k.hdr",studio:"studio_small_03_1k.hdr",sunset:"venice_sunset_1k.hdr",warehouse:"empty_warehouse_01_1k.hdr"},tM="https://raw.githack.com/pmndrs/drei-assets/456060a26bbeb8fdf79326f224b6d99b8bcce736/hdri/",tv=["/px.png","/nx.png","/py.png","/ny.png","/pz.png","/nz.png"];function tF({files:e=tv,path:t="",preset:r,colorSpace:i,extensions:s}={}){r&&(tI(r),e=tg[r],t=tM);let o=Array.isArray(e),{extension:l,isCubemap:u}=tG(e),c=tR(l);if(!c)throw Error("useEnvironment: Unrecognized file extension: "+e);let h=(0,a.useThree)(e=>e.gl);(0,n.useLayoutEffect)(()=>{("webp"===l||"jpg"===l||"jpeg"===l)&&h.domElement.addEventListener("webglcontextlost",function(){d.useLoader.clear(c,o?[e]:e)},{once:!0})},[e,h.domElement]);let f=(0,d.useLoader)(c,o?[e]:e,e=>{("webp"===l||"jpg"===l||"jpeg"===l)&&e.setRenderer(h),null==e.setPath||e.setPath(t),s&&s(e)}),B=o?f[0]:f;if("jpg"===l||"jpeg"===l||"webp"===l){var p;B=null==(p=B.renderTarget)?void 0:p.texture}return B.mapping=u?A.CubeReflectionMapping:A.EquirectangularReflectionMapping,B.colorSpace=null!=i?i:u?"srgb":"srgb-linear",B}let tE={files:tv,path:"",preset:void 0,extensions:void 0};tF.preload=e=>{let t={...tE,...e},{files:r,path:n=""}=t,{preset:a,extensions:i}=t;a&&(tI(a),r=tg[a],n=tM);let{extension:s}=tG(r);if("webp"===s||"jpg"===s||"jpeg"===s)throw Error("useEnvironment: Preloading gainmaps is not supported");let o=tR(s);if(!o)throw Error("useEnvironment: Unrecognized file extension: "+r);d.useLoader.preload(o,Array.isArray(r)?[r]:r,e=>{null==e.setPath||e.setPath(n),i&&i(e)})};let ty={files:tv,preset:void 0};function tI(e){if(!(e in tg))throw Error("Preset must be one of: "+Object.keys(tg).join(", "))}function tG(e){var t;let r=Array.isArray(e)&&6===e.length,n=Array.isArray(e)&&3===e.length&&e.some(e=>e.endsWith("json")),a=Array.isArray(e)?e[0]:e;return{extension:r?"cube":n?"webp":a.startsWith("data:application/exr")?"exr":a.startsWith("data:application/hdr")?"hdr":a.startsWith("data:image/jpeg")?"jpg":null==(t=a.split(".").pop())||null==(t=t.split("?"))||null==(t=t.shift())?void 0:t.toLowerCase(),isCubemap:r,isGainmap:n}}function tR(e){return"cube"===e?A.CubeTextureLoader:"hdr"===e?B:"exr"===e?te:"jpg"===e||"jpeg"===e?tm:"webp"===e?tC:null}function tb(e,t,r,n,a={}){var i,s,l,A,u;let c;a={backgroundBlurriness:0,backgroundIntensity:1,backgroundRotation:[0,0,0],environmentIntensity:1,environmentRotation:[0,0,0],...a};let h=(c=u=t||r).current&&c.current.isScene?u.current:u,d=h.background,f=h.environment,B={backgroundBlurriness:h.backgroundBlurriness,backgroundIntensity:h.backgroundIntensity,backgroundRotation:null!=(i=null==(s=h.backgroundRotation)||null==s.clone?void 0:s.clone())?i:[0,0,0],environmentIntensity:h.environmentIntensity,environmentRotation:null!=(l=null==(A=h.environmentRotation)||null==A.clone?void 0:A.clone())?l:[0,0,0]};return"only"!==e&&(h.environment=n),e&&(h.background=n),(0,o.applyProps)(h,a),()=>{"only"!==e&&(h.environment=f),e&&(h.background=d),(0,o.applyProps)(h,B)}}function tD({scene:e,background:t=!1,map:r,...i}){let s=(0,a.useThree)(e=>e.scene);return n.useLayoutEffect(()=>{if(r)return tb(t,e,s,r,i)}),null}function tT({background:e=!1,scene:t,blur:r,backgroundBlurriness:i,backgroundIntensity:s,backgroundRotation:o,environmentIntensity:l,environmentRotation:A,...u}){let c=tF(u),h=(0,a.useThree)(e=>e.scene);return n.useLayoutEffect(()=>tb(e,t,h,c,{backgroundBlurriness:null!=r?r:i,backgroundIntensity:s,backgroundRotation:o,environmentIntensity:l,environmentRotation:A})),n.useEffect(()=>()=>{c.dispose()},[c]),null}function tw({children:e,near:t=.1,far:r=1e3,resolution:o=256,frames:l=1,map:u,background:c=!1,blur:h,backgroundBlurriness:d,backgroundIntensity:f,backgroundRotation:B,environmentIntensity:p,environmentRotation:C,scene:m,files:g,path:M,preset:v,extensions:F}){let E=(0,a.useThree)(e=>e.gl),y=(0,a.useThree)(e=>e.scene),I=n.useRef(null),[G]=n.useState(()=>new A.Scene),R=n.useMemo(()=>{let e=new A.WebGLCubeRenderTarget(o);return e.texture.type=A.HalfFloatType,e},[o]);n.useEffect(()=>()=>{R.dispose()},[R]),n.useLayoutEffect(()=>{if(1===l){let e=E.autoClear;E.autoClear=!0,I.current.update(E,G),E.autoClear=e}return tb(c,m,y,R.texture,{backgroundBlurriness:null!=h?h:d,backgroundIntensity:f,backgroundRotation:B,environmentIntensity:p,environmentRotation:C})},[e,G,R.texture,m,y,c,l,E]);let b=1;return(0,i.useFrame)(()=>{if(l===1/0||b<l){let e=E.autoClear;E.autoClear=!0,I.current.update(E,G),E.autoClear=e,b++}}),n.createElement(n.Fragment,null,(0,s.createPortal)(n.createElement(n.Fragment,null,e,n.createElement("cubeCamera",{ref:I,args:[t,r,R]}),g||v?n.createElement(tT,{background:!0,files:g,preset:v,path:M,extensions:F}):u?n.createElement(tD,{background:!0,map:u,extensions:F}):null),G))}function tH(e){var t,a,i,s;let o=tF(e),A=e.map||o;n.useMemo(()=>(0,l.extend)({GroundProjectedEnvImpl:h}),[]),n.useEffect(()=>()=>{o.dispose()},[o]);let u=n.useMemo(()=>[A],[A]),c=null==(t=e.ground)?void 0:t.height,d=null==(a=e.ground)?void 0:a.radius,f=null!=(i=null==(s=e.ground)?void 0:s.scale)?i:1e3;return n.createElement(n.Fragment,null,n.createElement(tD,(0,r.default)({},e,{map:A})),n.createElement("groundProjectedEnvImpl",{args:u,scale:f,height:c,radius:d}))}tF.clear=e=>{let t={...ty,...e},{files:r}=t,{preset:n}=t;n&&(tI(n),r=tg[n]);let{extension:a}=tG(r),i=tR(a);if(!i)throw Error("useEnvironment: Unrecognized file extension: "+r);d.useLoader.clear(i,Array.isArray(r)?[r]:r)},e.s(["Environment",0,function(e){return e.ground?n.createElement(tH,e):e.map?n.createElement(tD,e):e.children?n.createElement(tw,e):n.createElement(tT,e)}],43257)},68911,e=>{"use strict";var t=e.i(90072);e.s(["toCreasedNormals",0,function(e,r=Math.PI/3){let n=Math.cos(r),a=(1+1e-10)*100,i=[new t.Vector3,new t.Vector3,new t.Vector3],s=new t.Vector3,o=new t.Vector3,l=new t.Vector3,A=new t.Vector3;function u(e){let t=~~(e.x*a),r=~~(e.y*a),n=~~(e.z*a);return`${t},${r},${n}`}let c=e.index?e.toNonIndexed():e,h=c.attributes.position,d={};for(let e=0,r=h.count/3;e<r;e++){let r=3*e,n=i[0].fromBufferAttribute(h,r+0),a=i[1].fromBufferAttribute(h,r+1),l=i[2].fromBufferAttribute(h,r+2);s.subVectors(l,a),o.subVectors(n,a);let A=new t.Vector3().crossVectors(s,o).normalize();for(let e=0;e<3;e++){let t=u(i[e]);t in d||(d[t]=[]),d[t].push(A)}}let f=new Float32Array(3*h.count),B=new t.BufferAttribute(f,3,!1);for(let e=0,t=h.count/3;e<t;e++){let t=3*e,r=i[0].fromBufferAttribute(h,t+0),a=i[1].fromBufferAttribute(h,t+1),c=i[2].fromBufferAttribute(h,t+2);s.subVectors(c,a),o.subVectors(r,a),l.crossVectors(s,o).normalize();for(let e=0;e<3;e++){let r=d[u(i[e])];A.set(0,0,0);for(let e=0,t=r.length;e<t;e++){let t=r[e];l.dot(t)>n&&A.add(t)}A.normalize(),B.setXYZ(t+e,A.x,A.y,A.z)}}return c.setAttribute("normal",B),c},"toTrianglesDrawMode",0,function(e,r){if(r===t.TrianglesDrawMode)return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."),e;if(r!==t.TriangleFanDrawMode&&r!==t.TriangleStripDrawMode)return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:",r),e;{let n=e.getIndex();if(null===n){let t=[],r=e.getAttribute("position");if(void 0===r)return console.error("THREE.BufferGeometryUtils.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()}let a=n.count-2,i=[];if(n)if(r===t.TriangleFanDrawMode)for(let e=1;e<=a;e++)i.push(n.getX(0)),i.push(n.getX(e)),i.push(n.getX(e+1));else for(let e=0;e<a;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!==a&&console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");let s=e.clone();return s.setIndex(i),s.clearGroups(),s}}],68911)},78140,68834,e=>{"use strict";let t;var r=e.i(31067),n=e.i(71645),a=e.i(90072),i=e.i(68911),s=e.i(31497);function o(e){if("u">typeof TextDecoder)return new TextDecoder().decode(e);let t="";for(let r=0,n=e.length;r<n;r++)t+=String.fromCharCode(e[r]);try{return decodeURIComponent(escape(t))}catch(e){return t}}let l="srgb",A="srgb-linear";class u extends a.Loader{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new p(e)}),this.register(function(e){return new C(e)}),this.register(function(e){return new G(e)}),this.register(function(e){return new R(e)}),this.register(function(e){return new b(e)}),this.register(function(e){return new g(e)}),this.register(function(e){return new M(e)}),this.register(function(e){return new v(e)}),this.register(function(e){return new F(e)}),this.register(function(e){return new B(e)}),this.register(function(e){return new E(e)}),this.register(function(e){return new m(e)}),this.register(function(e){return new I(e)}),this.register(function(e){return new y(e)}),this.register(function(e){return new d(e)}),this.register(function(e){return new D(e)}),this.register(function(e){return new T(e)})}load(e,t,r,n){let i,s=this;if(""!==this.resourcePath)i=this.resourcePath;else if(""!==this.path){let t=a.LoaderUtils.extractUrlBase(e);i=a.LoaderUtils.resolveURL(t,this.path)}else i=a.LoaderUtils.extractUrlBase(e);this.manager.itemStart(e);let o=function(t){n?n(t):console.error(t),s.manager.itemError(e),s.manager.itemEnd(e)},l=new a.FileLoader(this.manager);l.setPath(this.path),l.setResponseType("arraybuffer"),l.setRequestHeader(this.requestHeader),l.setWithCredentials(this.withCredentials),l.load(e,function(r){try{s.parse(r,i,function(r){t(r),s.manager.itemEnd(e)},o)}catch(e){o(e)}},r,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setDDSLoader(){throw 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,r,n){let a,i={},s={};if("string"==typeof e)a=JSON.parse(e);else if(e instanceof ArrayBuffer)if(o(new Uint8Array(e.slice(0,4)))===w){try{i[h.KHR_BINARY_GLTF]=new H(e)}catch(e){n&&n(e);return}a=JSON.parse(i[h.KHR_BINARY_GLTF].content)}else a=JSON.parse(o(new Uint8Array(e)));else a=e;if(void 0===a.asset||a.asset.version[0]<2){n&&n(Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));return}let l=new q(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++){let t=this.pluginCallbacks[e](l);t.name||console.error("THREE.GLTFLoader: Invalid plugin found: missing name"),s[t.name]=t,i[t.name]=!0}if(a.extensionsUsed)for(let e=0;e<a.extensionsUsed.length;++e){let t=a.extensionsUsed[e],r=a.extensionsRequired||[];switch(t){case h.KHR_MATERIALS_UNLIT:i[t]=new f;break;case h.KHR_DRACO_MESH_COMPRESSION:i[t]=new x(a,this.dracoLoader);break;case h.KHR_TEXTURE_TRANSFORM:i[t]=new J;break;case h.KHR_MESH_QUANTIZATION:i[t]=new L;break;default:r.indexOf(t)>=0&&void 0===s[t]&&console.warn('THREE.GLTFLoader: Unknown extension "'+t+'".')}}l.setExtensions(i),l.setPlugins(s),l.parse(r,n)}parseAsync(e,t){let r=this;return new Promise(function(n,a){r.parse(e,t,n,a)})}}function c(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}let h={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_DISPERSION:"KHR_materials_dispersion",KHR_MATERIALS_IOR:"KHR_materials_ior",KHR_MATERIALS_SHEEN:"KHR_materials_sheen",KHR_MATERIALS_SPECULAR:"KHR_materials_specular",KHR_MATERIALS_TRANSMISSION:"KHR_materials_transmission",KHR_MATERIALS_IRIDESCENCE:"KHR_materials_iridescence",KHR_MATERIALS_ANISOTROPY:"KHR_materials_anisotropy",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",KHR_MATERIALS_EMISSIVE_STRENGTH:"KHR_materials_emissive_strength",EXT_MATERIALS_BUMP:"EXT_materials_bump",EXT_TEXTURE_WEBP:"EXT_texture_webp",EXT_TEXTURE_AVIF:"EXT_texture_avif",EXT_MESHOPT_COMPRESSION:"EXT_meshopt_compression",EXT_MESH_GPU_INSTANCING:"EXT_mesh_gpu_instancing"};class d{constructor(e){this.parser=e,this.name=h.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){let e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r<n;r++){let n=t[r];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){let t,r=this.parser,n="light:"+e,i=r.cache.get(n);if(i)return i;let s=r.json,o=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e],l=new a.Color(0xffffff);void 0!==o.color&&l.setRGB(o.color[0],o.color[1],o.color[2],A);let u=void 0!==o.range?o.range:0;switch(o.type){case"directional":(t=new a.DirectionalLight(l)).target.position.set(0,0,-1),t.add(t.target);break;case"point":(t=new a.PointLight(l)).distance=u;break;case"spot":(t=new a.SpotLight(l)).distance=u,o.spot=o.spot||{},o.spot.innerConeAngle=void 0!==o.spot.innerConeAngle?o.spot.innerConeAngle:0,o.spot.outerConeAngle=void 0!==o.spot.outerConeAngle?o.spot.outerConeAngle:Math.PI/4,t.angle=o.spot.outerConeAngle,t.penumbra=1-o.spot.innerConeAngle/o.spot.outerConeAngle,t.target.position.set(0,0,-1),t.add(t.target);break;default:throw Error("THREE.GLTFLoader: Unexpected light type: "+o.type)}return t.position.set(0,0,0),t.decay=2,W(t,o),void 0!==o.intensity&&(t.intensity=o.intensity),t.name=r.createUniqueName(o.name||"light_"+e),i=Promise.resolve(t),r.cache.add(n,i),i}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){let t=this,r=this.parser,n=r.json.nodes[e],a=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===a?null:this._loadLight(a).then(function(e){return r._getNodeRef(t.cache,a,e)})}}class f{constructor(){this.name=h.KHR_MATERIALS_UNLIT}getMaterialType(){return a.MeshBasicMaterial}extendParams(e,t,r){let n=[];e.color=new a.Color(1,1,1),e.opacity=1;let i=t.pbrMetallicRoughness;if(i){if(Array.isArray(i.baseColorFactor)){let t=i.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],A),e.opacity=t[3]}void 0!==i.baseColorTexture&&n.push(r.assignTexture(e,"map",i.baseColorTexture,l))}return Promise.all(n)}}class B{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let n=r.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class p{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let i=[],s=n.extensions[this.name];if(void 0!==s.clearcoatFactor&&(t.clearcoat=s.clearcoatFactor),void 0!==s.clearcoatTexture&&i.push(r.assignTexture(t,"clearcoatMap",s.clearcoatTexture)),void 0!==s.clearcoatRoughnessFactor&&(t.clearcoatRoughness=s.clearcoatRoughnessFactor),void 0!==s.clearcoatRoughnessTexture&&i.push(r.assignTexture(t,"clearcoatRoughnessMap",s.clearcoatRoughnessTexture)),void 0!==s.clearcoatNormalTexture&&(i.push(r.assignTexture(t,"clearcoatNormalMap",s.clearcoatNormalTexture)),void 0!==s.clearcoatNormalTexture.scale)){let e=s.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new a.Vector2(e,e)}return Promise.all(i)}}class C{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_DISPERSION}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let n=r.extensions[this.name];return t.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class m{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let a=[],i=n.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&a.push(r.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&a.push(r.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(a)}}class g{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_SHEEN}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let i=[];t.sheenColor=new a.Color(0,0,0),t.sheenRoughness=0,t.sheen=1;let s=n.extensions[this.name];if(void 0!==s.sheenColorFactor){let e=s.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],A)}return void 0!==s.sheenRoughnessFactor&&(t.sheenRoughness=s.sheenRoughnessFactor),void 0!==s.sheenColorTexture&&i.push(r.assignTexture(t,"sheenColorMap",s.sheenColorTexture,l)),void 0!==s.sheenRoughnessTexture&&i.push(r.assignTexture(t,"sheenRoughnessMap",s.sheenRoughnessTexture)),Promise.all(i)}}class M{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let a=[],i=n.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&a.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(a)}}class v{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_VOLUME}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let i=[],s=n.extensions[this.name];t.thickness=void 0!==s.thicknessFactor?s.thicknessFactor:0,void 0!==s.thicknessTexture&&i.push(r.assignTexture(t,"thicknessMap",s.thicknessTexture)),t.attenuationDistance=s.attenuationDistance||1/0;let o=s.attenuationColor||[1,1,1];return t.attenuationColor=new a.Color().setRGB(o[0],o[1],o[2],A),Promise.all(i)}}class F{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_IOR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();let n=r.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class E{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_SPECULAR}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let i=[],s=n.extensions[this.name];t.specularIntensity=void 0!==s.specularFactor?s.specularFactor:1,void 0!==s.specularTexture&&i.push(r.assignTexture(t,"specularIntensityMap",s.specularTexture));let o=s.specularColorFactor||[1,1,1];return t.specularColor=new a.Color().setRGB(o[0],o[1],o[2],A),void 0!==s.specularColorTexture&&i.push(r.assignTexture(t,"specularColorMap",s.specularColorTexture,l)),Promise.all(i)}}class y{constructor(e){this.parser=e,this.name=h.EXT_MATERIALS_BUMP}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let a=[],i=n.extensions[this.name];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&a.push(r.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(a)}}class I{constructor(e){this.parser=e,this.name=h.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){let t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?a.MeshPhysicalMaterial:null}extendMaterialParams(e,t){let r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();let a=[],i=n.extensions[this.name];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&a.push(r.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(a)}}class G{constructor(e){this.parser=e,this.name=h.KHR_TEXTURE_BASISU}loadTexture(e){let t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;let a=n.extensions[this.name],i=t.options.ktx2Loader;if(!i)if(!(r.extensionsRequired&&r.extensionsRequired.indexOf(this.name)>=0))return null;else throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return t.loadTextureImage(e,a.source,i)}}class R{constructor(e){this.parser=e,this.name=h.EXT_TEXTURE_WEBP,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,n=r.json,a=n.textures[e];if(!a.extensions||!a.extensions[t])return null;let i=a.extensions[t],s=n.images[i.source],o=r.textureLoader;if(s.uri){let e=r.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then(function(a){if(a)return r.loadTextureImage(e,i.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: WebP required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/webp;base64,UklGRiIAAABXRUJQVlA4IBYAAAAwAQCdASoBAAEADsD+JaQAA3AAAAAA",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class b{constructor(e){this.parser=e,this.name=h.EXT_TEXTURE_AVIF,this.isSupported=null}loadTexture(e){let t=this.name,r=this.parser,n=r.json,a=n.textures[e];if(!a.extensions||!a.extensions[t])return null;let i=a.extensions[t],s=n.images[i.source],o=r.textureLoader;if(s.uri){let e=r.options.manager.getHandler(s.uri);null!==e&&(o=e)}return this.detectSupport().then(function(a){if(a)return r.loadTextureImage(e,i.source,o);if(n.extensionsRequired&&n.extensionsRequired.indexOf(t)>=0)throw Error("THREE.GLTFLoader: AVIF required by asset but unsupported.");return r.loadTexture(e)})}detectSupport(){return this.isSupported||(this.isSupported=new Promise(function(e){let t=new Image;t.src="data:image/avif;base64,AAAAIGZ0eXBhdmlmAAAAAGF2aWZtaWYxbWlhZk1BMUIAAADybWV0YQAAAAAAAAAoaGRscgAAAAAAAAAAcGljdAAAAAAAAAAAAAAAAGxpYmF2aWYAAAAADnBpdG0AAAAAAAEAAAAeaWxvYwAAAABEAAABAAEAAAABAAABGgAAABcAAAAoaWluZgAAAAAAAQAAABppbmZlAgAAAAABAABhdjAxQ29sb3IAAAAAamlwcnAAAABLaXBjbwAAABRpc3BlAAAAAAAAAAEAAAABAAAAEHBpeGkAAAAAAwgICAAAAAxhdjFDgQAMAAAAABNjb2xybmNseAACAAIABoAAAAAXaXBtYQAAAAAAAAABAAEEAQKDBAAAAB9tZGF0EgAKCBgABogQEDQgMgkQAAAAB8dSLfI=",t.onload=t.onerror=function(){e(1===t.height)}})),this.isSupported}}class D{constructor(e){this.name=h.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){let t=this.parser.json,r=t.bufferViews[e];if(!r.extensions||!r.extensions[this.name])return null;{let e=r.extensions[this.name],n=this.parser.getDependency("buffer",e.buffer),a=this.parser.options.meshoptDecoder;if(!a||!a.supported)if(!(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0))return null;else throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return n.then(function(t){let r=e.byteOffset||0,n=e.byteLength||0,i=e.count,s=e.byteStride,o=new Uint8Array(t,r,n);return a.decodeGltfBufferAsync?a.decodeGltfBufferAsync(i,s,o,e.mode,e.filter).then(function(e){return e.buffer}):a.ready.then(function(){let t=new ArrayBuffer(i*s);return a.decodeGltfBuffer(new Uint8Array(t),i,s,o,e.mode,e.filter),t})})}}}class T{constructor(e){this.name=h.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){let t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;for(let e of t.meshes[r.mesh].primitives)if(e.mode!==P.TRIANGLES&&e.mode!==P.TRIANGLE_STRIP&&e.mode!==P.TRIANGLE_FAN&&void 0!==e.mode)return null;let n=r.extensions[this.name].attributes,i=[],s={};for(let e in n)i.push(this.parser.getDependency("accessor",n[e]).then(t=>(s[e]=t,s[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{let t=e.pop(),r=t.isGroup?t.children:[t],n=e[0].count,i=[];for(let e of r){let t=new a.Matrix4,r=new a.Vector3,o=new a.Quaternion,l=new a.Vector3(1,1,1),A=new a.InstancedMesh(e.geometry,e.material,n);for(let e=0;e<n;e++)s.TRANSLATION&&r.fromBufferAttribute(s.TRANSLATION,e),s.ROTATION&&o.fromBufferAttribute(s.ROTATION,e),s.SCALE&&l.fromBufferAttribute(s.SCALE,e),A.setMatrixAt(e,t.compose(r,o,l));for(let t in s)if("_COLOR_0"===t){let e=s[t];A.instanceColor=new a.InstancedBufferAttribute(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,s[t]);a.Object3D.prototype.copy.call(A,e),this.parser.assignFinalMaterial(A),i.push(A)}return t.isGroup?(t.clear(),t.add(...i),t):i[0]}))}}let w="glTF";class H{constructor(e){this.name=h.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12);if(this.header={magic:o(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==w)throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,n=new DataView(e,12);let a=0;for(;a<r;){const t=n.getUint32(a,!0);a+=4;const r=n.getUint32(a,!0);if(a+=4,0x4e4f534a===r){const r=new Uint8Array(e,12+a,t);this.content=o(r)}else if(5130562===r){const r=12+a;this.body=e.slice(r,r+t)}a+=t}if(null===this.content)throw Error("THREE.GLTFLoader: JSON content not found.")}}class x{constructor(e,t){if(!t)throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=h.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){let r=this.json,n=this.dracoLoader,a=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,s={},o={},l={};for(let e in i)s[Q[e]||e.toLowerCase()]=i[e];for(let t in e.attributes){let n=Q[t]||t.toLowerCase();if(void 0!==i[t]){let a=r.accessors[e.attributes[t]],i=_[a.componentType];l[n]=i.name,o[n]=!0===a.normalized}}return t.getDependency("bufferView",a).then(function(e){return new Promise(function(t,r){n.decodeDracoFile(e,function(e){for(let t in e.attributes){let r=e.attributes[t],n=o[t];void 0!==n&&(r.normalized=n)}t(e)},s,l,A,r)})})}}class J{constructor(){this.name=h.KHR_TEXTURE_TRANSFORM}extendTexture(e,t){return(void 0===t.texCoord||t.texCoord===e.channel)&&void 0===t.offset&&void 0===t.rotation&&void 0===t.scale||(e=e.clone(),void 0!==t.texCoord&&(e.channel=t.texCoord),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 L{constructor(){this.name=h.KHR_MESH_QUANTIZATION}}class S extends a.Interpolant{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){let t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,a=e*n*3+n;for(let e=0;e!==n;e++)t[e]=r[a+e];return t}interpolate_(e,t,r,n){let a=this.resultBuffer,i=this.sampleValues,s=this.valueSize,o=2*s,l=3*s,A=n-t,u=(r-t)/A,c=u*u,h=c*u,d=e*l,f=d-l,B=-2*h+3*c,p=h-c,C=1-B,m=p-c+u;for(let e=0;e!==s;e++){let t=i[f+e+s],r=i[f+e+o]*A,n=i[d+e+s],l=i[d+e]*A;a[e]=C*t+m*r+B*n+p*l}return a}}let U=new a.Quaternion;class O extends S{interpolate_(e,t,r,n){let a=super.interpolate_(e,t,r,n);return U.fromArray(a).normalize().toArray(a),a}}let P={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6},_={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},K={9728:a.NearestFilter,9729:a.LinearFilter,9984:a.NearestMipmapNearestFilter,9985:a.LinearMipmapNearestFilter,9986:a.NearestMipmapLinearFilter,9987:a.LinearMipmapLinearFilter},k={33071:a.ClampToEdgeWrapping,33648:a.MirroredRepeatWrapping,10497:a.RepeatWrapping},N={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Q={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",...s.version>=152?{TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3"}:{TEXCOORD_0:"uv",TEXCOORD_1:"uv2"},COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},X={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},j={CUBICSPLINE:void 0,LINEAR:a.InterpolateLinear,STEP:a.InterpolateDiscrete};function Y(e,t,r){for(let n in r.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=r.extensions[n])}function W(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 Z(e){let t="",r=Object.keys(e).sort();for(let n=0,a=r.length;n<a;n++)t+=r[n]+":"+e[r[n]]+";";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 Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}let z=new a.Matrix4;class q{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new c,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,n=!1,i=-1;"u">typeof navigator&&void 0!==navigator.userAgent&&(r=!0===/^((?!chrome|android).)*safari/i.test(navigator.userAgent),i=(n=navigator.userAgent.indexOf("Firefox")>-1)?navigator.userAgent.match(/Firefox\/([0-9]+)\./)[1]:-1),"u"<typeof createImageBitmap||r||n&&i<98?this.textureLoader=new a.TextureLoader(this.options.manager):this.textureLoader=new a.ImageBitmapLoader(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new a.FileLoader(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){let r=this,n=this.json,a=this.extensions;this.cache.removeAll(),this.nodeCache={},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([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(t){let i={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:r,userData:{}};return Y(a,i,n),W(i,n),Promise.all(r._invokeAll(function(e){return e.afterRoot&&e.afterRoot(i)})).then(function(){for(let e of i.scenes)e.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){let e=this.json.nodes||[],t=this.json.skins||[],r=this.json.meshes||[];for(let r=0,n=t.length;r<n;r++){let n=t[r].joints;for(let t=0,r=n.length;t<r;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){let n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(r[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.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,r){if(e.refs[t]<=1)return r;let n=r.clone(),a=(e,t)=>{let r=this.associations.get(e);for(let[n,i]of(null!=r&&this.associations.set(t,r),e.children.entries()))a(i,t.children[n])};return a(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){let t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){let n=e(t[r]);if(n)return n}return null}_invokeAll(e){let t=Object.values(this.plugins);t.unshift(this);let r=[];for(let n=0;n<t.length;n++){let a=e(t[n]);a&&r.push(a)}return r}getDependency(e,t){let r=e+":"+t,n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":n=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(!(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)})))throw Error("Unknown type: "+e)}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){let r=this;t=Promise.all((this.json[e+("mesh"===e?"es":"s")]||[]).map(function(t,n){return r.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){let t=this.json.buffers[e],r=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[h.KHR_BINARY_GLTF].body);let n=this.options;return new Promise(function(e,i){r.load(a.LoaderUtils.resolveURL(t.uri,n.path),e,void 0,function(){i(Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){let t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){let r=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+r)})}loadAccessor(e){let t=this,r=this.json,n=this.json.accessors[e];if(void 0===n.bufferView&&void 0===n.sparse){let e=N[n.type],t=_[n.componentType],r=!0===n.normalized,i=new t(n.count*e);return Promise.resolve(new a.BufferAttribute(i,e,r))}let i=[];return void 0!==n.bufferView?i.push(this.getDependency("bufferView",n.bufferView)):i.push(null),void 0!==n.sparse&&(i.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),i.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(i).then(function(e){let i,s,o=e[0],l=N[n.type],A=_[n.componentType],u=A.BYTES_PER_ELEMENT,c=u*l,h=n.byteOffset||0,d=void 0!==n.bufferView?r.bufferViews[n.bufferView].byteStride:void 0,f=!0===n.normalized;if(d&&d!==c){let e=Math.floor(h/d),r="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+e+":"+n.count,c=t.cache.get(r);c||(i=new A(o,e*d,n.count*d/u),c=new a.InterleavedBuffer(i,d/u),t.cache.add(r,c)),s=new a.InterleavedBufferAttribute(c,l,h%d/u,f)}else i=null===o?new A(n.count*l):new A(o,h,n.count*l),s=new a.BufferAttribute(i,l,f);if(void 0!==n.sparse){let t=N.SCALAR,r=_[n.sparse.indices.componentType],i=n.sparse.indices.byteOffset||0,u=n.sparse.values.byteOffset||0,c=new r(e[1],i,n.sparse.count*t),h=new A(e[2],u,n.sparse.count*l);null!==o&&(s=new a.BufferAttribute(s.array.slice(),s.itemSize,s.normalized));for(let e=0,t=c.length;e<t;e++){let t=c[e];if(s.setX(t,h[e*l]),l>=2&&s.setY(t,h[e*l+1]),l>=3&&s.setZ(t,h[e*l+2]),l>=4&&s.setW(t,h[e*l+3]),l>=5)throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}}return s})}loadTexture(e){let t=this.json,r=this.options,n=t.textures[e].source,a=t.images[n],i=this.textureLoader;if(a.uri){let e=r.manager.getHandler(a.uri);null!==e&&(i=e)}return this.loadTextureImage(e,n,i)}loadTextureImage(e,t,r){let n=this,i=this.json,s=i.textures[e],o=i.images[t],l=(o.uri||o.bufferView)+":"+s.sampler;if(this.textureCache[l])return this.textureCache[l];let A=this.loadImageSource(t,r).then(function(t){t.flipY=!1,t.name=s.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);let r=(i.samplers||{})[s.sampler]||{};return t.magFilter=K[r.magFilter]||a.LinearFilter,t.minFilter=K[r.minFilter]||a.LinearMipmapLinearFilter,t.wrapS=k[r.wrapS]||a.RepeatWrapping,t.wrapT=k[r.wrapT]||a.RepeatWrapping,n.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[l]=A,A}loadImageSource(e,t){let r=this.json,n=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());let i=r.images[e],s=self.URL||self.webkitURL,o=i.uri||"",l=!1;if(void 0!==i.bufferView)o=this.getDependency("bufferView",i.bufferView).then(function(e){l=!0;let t=new Blob([e],{type:i.mimeType});return o=s.createObjectURL(t)});else if(void 0===i.uri)throw Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");let A=Promise.resolve(o).then(function(e){return new Promise(function(r,i){let s=r;!0===t.isImageBitmapLoader&&(s=function(e){let t=new a.Texture(e);t.needsUpdate=!0,r(t)}),t.load(a.LoaderUtils.resolveURL(e,n.path),s,void 0,i)})}).then(function(e){var t;return!0===l&&s.revokeObjectURL(o),W(e,i),e.userData.mimeType=i.mimeType||((t=i.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",o),e});return this.sourceCache[e]=A,A}assignTexture(e,t,r,n){let a=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(void 0!==r.texCoord&&r.texCoord>0&&((i=i.clone()).channel=r.texCoord),a.extensions[h.KHR_TEXTURE_TRANSFORM]){let e=void 0!==r.extensions?r.extensions[h.KHR_TEXTURE_TRANSFORM]:void 0;if(e){let t=a.associations.get(i);i=a.extensions[h.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),a.associations.set(i,t)}}return void 0!==n&&("number"==typeof n&&(n=3001===n?l:A),"colorSpace"in i?i.colorSpace=n:i.encoding=n===l?3001:3e3),e[t]=i,i})}assignFinalMaterial(e){let t=e.geometry,r=e.material,n=void 0===t.attributes.tangent,i=void 0!==t.attributes.color,s=void 0===t.attributes.normal;if(e.isPoints){let e="PointsMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new a.PointsMaterial,a.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){let e="LineBasicMaterial:"+r.uuid,t=this.cache.get(e);t||(t=new a.LineBasicMaterial,a.Material.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,this.cache.add(e,t)),r=t}if(n||i||s){let e="ClonedMaterial:"+r.uuid+":";n&&(e+="derivative-tangents:"),i&&(e+="vertex-colors:"),s&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),i&&(t.vertexColors=!0),s&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}e.material=r}getMaterialType(){return a.MeshStandardMaterial}loadMaterial(e){let t,r=this,n=this.json,i=this.extensions,s=n.materials[e],o={},u=s.extensions||{},c=[];if(u[h.KHR_MATERIALS_UNLIT]){let e=i[h.KHR_MATERIALS_UNLIT];t=e.getMaterialType(),c.push(e.extendParams(o,s,r))}else{let n=s.pbrMetallicRoughness||{};if(o.color=new a.Color(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){let e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],A),o.opacity=e[3]}void 0!==n.baseColorTexture&&c.push(r.assignTexture(o,"map",n.baseColorTexture,l)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(c.push(r.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),c.push(r.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),t=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),c.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}!0===s.doubleSided&&(o.side=a.DoubleSide);let d=s.alphaMode||"OPAQUE";if("BLEND"===d?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,"MASK"===d&&(o.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&t!==a.MeshBasicMaterial&&(c.push(r.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new a.Vector2(1,1),void 0!==s.normalTexture.scale)){let e=s.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==s.occlusionTexture&&t!==a.MeshBasicMaterial&&(c.push(r.assignTexture(o,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(o.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&t!==a.MeshBasicMaterial){let e=s.emissiveFactor;o.emissive=new a.Color().setRGB(e[0],e[1],e[2],A)}return void 0!==s.emissiveTexture&&t!==a.MeshBasicMaterial&&c.push(r.assignTexture(o,"emissiveMap",s.emissiveTexture,l)),Promise.all(c).then(function(){let n=new t(o);return s.name&&(n.name=s.name),W(n,s),r.associations.set(n,{materials:e}),s.extensions&&Y(i,n,s),n})}createUniqueName(e){let t=a.PropertyBinding.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){let t=this,r=this.extensions,n=this.primitiveCache,i=[];for(let s=0,o=e.length;s<o;s++){let o=e[s],l=function(e){let t,r=e.extensions&&e.extensions[h.KHR_DRACO_MESH_COMPRESSION];if(t=r?"draco:"+r.bufferView+":"+r.indices+":"+Z(r.attributes):e.indices+":"+Z(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,n=e.targets.length;r<n;r++)t+=":"+Z(e.targets[r]);return t}(o),A=n[l];if(A)i.push(A.promise);else{let e;e=o.extensions&&o.extensions[h.KHR_DRACO_MESH_COMPRESSION]?function(e){return r[h.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(r){return $(r,e,t)})}(o):$(new a.BufferGeometry,o,t),n[l]={primitive:o,promise:e},i.push(e)}}return Promise.all(i)}loadMesh(e){let t=this,r=this.json,n=this.extensions,s=r.meshes[e],o=s.primitives,l=[];for(let e=0,t=o.length;e<t;e++){var A;let t=void 0===o[e].material?(void 0===(A=this.cache).DefaultMaterial&&(A.DefaultMaterial=new a.MeshStandardMaterial({color:0xffffff,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:a.FrontSide})),A.DefaultMaterial):this.getDependency("material",o[e].material);l.push(t)}return l.push(t.loadGeometries(o)),Promise.all(l).then(function(r){let l=r.slice(0,r.length-1),A=r[r.length-1],u=[];for(let r=0,c=A.length;r<c;r++){let c,h=A[r],d=o[r],f=l[r];if(d.mode===P.TRIANGLES||d.mode===P.TRIANGLE_STRIP||d.mode===P.TRIANGLE_FAN||void 0===d.mode)!0===(c=!0===s.isSkinnedMesh?new a.SkinnedMesh(h,f):new a.Mesh(h,f)).isSkinnedMesh&&c.normalizeSkinWeights(),d.mode===P.TRIANGLE_STRIP?c.geometry=(0,i.toTrianglesDrawMode)(c.geometry,a.TriangleStripDrawMode):d.mode===P.TRIANGLE_FAN&&(c.geometry=(0,i.toTrianglesDrawMode)(c.geometry,a.TriangleFanDrawMode));else if(d.mode===P.LINES)c=new a.LineSegments(h,f);else if(d.mode===P.LINE_STRIP)c=new a.Line(h,f);else if(d.mode===P.LINE_LOOP)c=new a.LineLoop(h,f);else if(d.mode===P.POINTS)c=new a.Points(h,f);else throw Error("THREE.GLTFLoader: Primitive mode unsupported: "+d.mode);Object.keys(c.geometry.morphAttributes).length>0&&function(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,n=t.weights.length;r<n;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){let r=t.extras.targetNames;if(e.morphTargetInfluences.length===r.length){e.morphTargetDictionary={};for(let t=0,n=r.length;t<n;t++)e.morphTargetDictionary[r[t]]=t}else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.")}}(c,s),c.name=t.createUniqueName(s.name||"mesh_"+e),W(c,s),d.extensions&&Y(n,c,d),t.assignFinalMaterial(c),u.push(c)}for(let r=0,n=u.length;r<n;r++)t.associations.set(u[r],{meshes:e,primitives:r});if(1===u.length)return s.extensions&&Y(n,u[0],s),u[0];let c=new a.Group;s.extensions&&Y(n,c,s),t.associations.set(c,{meshes:e});for(let e=0,t=u.length;e<t;e++)c.add(u[e]);return c})}loadCamera(e){let t,r=this.json.cameras[e],n=r[r.type];return n?("perspective"===r.type?t=new a.PerspectiveCamera(a.MathUtils.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===r.type&&(t=new a.OrthographicCamera(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),W(t,r),Promise.resolve(t)):void console.warn("THREE.GLTFLoader: Missing camera parameters.")}loadSkin(e){let t=this.json.skins[e],r=[];for(let e=0,n=t.joints.length;e<n;e++)r.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(e){let r=e.pop(),n=[],i=[];for(let s=0,o=e.length;s<o;s++){let o=e[s];if(o){n.push(o);let e=new a.Matrix4;null!==r&&e.fromArray(r.array,16*s),i.push(e)}else console.warn('THREE.GLTFLoader: Joint "%s" could not be found.',t.joints[s])}return new a.Skeleton(n,i)})}loadAnimation(e){let t=this.json,r=this,n=t.animations[e],i=n.name?n.name:"animation_"+e,s=[],o=[],l=[],A=[],u=[];for(let e=0,t=n.channels.length;e<t;e++){let t=n.channels[e],r=n.samplers[t.sampler],a=t.target,i=a.node,c=void 0!==n.parameters?n.parameters[r.input]:r.input,h=void 0!==n.parameters?n.parameters[r.output]:r.output;void 0!==a.node&&(s.push(this.getDependency("node",i)),o.push(this.getDependency("accessor",c)),l.push(this.getDependency("accessor",h)),A.push(r),u.push(a))}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(l),Promise.all(A),Promise.all(u)]).then(function(e){let t=e[0],n=e[1],s=e[2],o=e[3],l=e[4],A=[];for(let e=0,a=t.length;e<a;e++){let a=t[e],i=n[e],u=s[e],c=o[e],h=l[e];if(void 0===a)continue;a.updateMatrix&&a.updateMatrix();let d=r._createAnimationTracks(a,i,u,c,h);if(d)for(let e=0;e<d.length;e++)A.push(d[e])}return new a.AnimationClip(i,void 0,A)})}createNodeMesh(e){let t=this.json,r=this,n=t.nodes[e];return void 0===n.mesh?null:r.getDependency("mesh",n.mesh).then(function(e){let t=r._getNodeRef(r.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,r=n.weights.length;t<r;t++)e.morphTargetInfluences[t]=n.weights[t]}),t})}loadNode(e){let t=this.json.nodes[e],r=this._loadNodeShallow(e),n=[],a=t.children||[];for(let e=0,t=a.length;e<t;e++)n.push(this.getDependency("node",a[e]));let i=void 0===t.skin?Promise.resolve(null):this.getDependency("skin",t.skin);return Promise.all([r,Promise.all(n),i]).then(function(e){let t=e[0],r=e[1],n=e[2];null!==n&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(n,z)});for(let e=0,n=r.length;e<n;e++)t.add(r[e]);return t})}_loadNodeShallow(e){let t=this.json,r=this.extensions,n=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];let i=t.nodes[e],s=i.name?n.createUniqueName(i.name):"",o=[],l=n._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return l&&o.push(l),void 0!==i.camera&&o.push(n.getDependency("camera",i.camera).then(function(e){return n._getNodeRef(n.cameraCache,i.camera,e)})),n._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){o.push(e)}),this.nodeCache[e]=Promise.all(o).then(function(t){let o;if((o=!0===i.isBone?new a.Bone:t.length>1?new a.Group:1===t.length?t[0]:new a.Object3D)!==t[0])for(let e=0,r=t.length;e<r;e++)o.add(t[e]);if(i.name&&(o.userData.name=i.name,o.name=s),W(o,i),i.extensions&&Y(r,o,i),void 0!==i.matrix){let e=new a.Matrix4;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 n.associations.has(o)||n.associations.set(o,{}),n.associations.get(o).nodes=e,o}),this.nodeCache[e]}loadScene(e){let t=this.extensions,r=this.json.scenes[e],n=this,i=new a.Group;r.name&&(i.name=n.createUniqueName(r.name)),W(i,r),r.extensions&&Y(t,i,r);let s=r.nodes||[],o=[];for(let e=0,t=s.length;e<t;e++)o.push(n.getDependency("node",s[e]));return Promise.all(o).then(function(e){for(let t=0,r=e.length;t<r;t++)i.add(e[t]);return n.associations=(e=>{let t=new Map;for(let[e,r]of n.associations)(e instanceof a.Material||e instanceof a.Texture)&&t.set(e,r);return e.traverse(e=>{let r=n.associations.get(e);null!=r&&t.set(e,r)}),t})(i),i})}_createAnimationTracks(e,t,r,n,i){let s,o=[],l=e.name?e.name:e.uuid,A=[];switch(X[i.path]===X.weights?e.traverse(function(e){e.morphTargetInfluences&&A.push(e.name?e.name:e.uuid)}):A.push(l),X[i.path]){case X.weights:s=a.NumberKeyframeTrack;break;case X.rotation:s=a.QuaternionKeyframeTrack;break;case X.position:case X.scale:s=a.VectorKeyframeTrack;break;default:s=1===r.itemSize?a.NumberKeyframeTrack:a.VectorKeyframeTrack}let u=void 0!==n.interpolation?j[n.interpolation]:a.InterpolateLinear,c=this._getArrayFromAccessor(r);for(let e=0,r=A.length;e<r;e++){let r=new s(A[e]+"."+X[i.path],t.array,c,u);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(r),o.push(r)}return o}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){let e=V(t.constructor),r=new Float32Array(t.length);for(let n=0,a=t.length;n<a;n++)r[n]=t[n]*e;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof a.QuaternionKeyframeTrack?O:S)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function $(e,t,r){let n=t.attributes,i=[];for(let t in n){let a=Q[t]||t.toLowerCase();a in e.attributes||i.push(function(t,n){return r.getDependency("accessor",t).then(function(t){e.setAttribute(n,t)})}(n[t],a))}if(void 0!==t.indices&&!e.index){let n=r.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});i.push(n)}return W(e,t),!function(e,t,r){let n=t.attributes,i=new a.Box3;if(void 0===n.POSITION)return;{let e=r.json.accessors[n.POSITION],t=e.min,s=e.max;if(void 0===t||void 0===s)return console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");if(i.set(new a.Vector3(t[0],t[1],t[2]),new a.Vector3(s[0],s[1],s[2])),e.normalized){let t=V(_[e.componentType]);i.min.multiplyScalar(t),i.max.multiplyScalar(t)}}let s=t.targets;if(void 0!==s){let e=new a.Vector3,t=new a.Vector3;for(let n=0,a=s.length;n<a;n++){let a=s[n];if(void 0!==a.POSITION){let n=r.json.accessors[a.POSITION],i=n.min,s=n.max;if(void 0!==i&&void 0!==s){if(t.setX(Math.max(Math.abs(i[0]),Math.abs(s[0]))),t.setY(Math.max(Math.abs(i[1]),Math.abs(s[1]))),t.setZ(Math.max(Math.abs(i[2]),Math.abs(s[2]))),n.normalized){let e=V(_[n.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;let o=new a.Sphere;i.getCenter(o.center),o.radius=i.min.distanceTo(i.max)/2,e.boundingSphere=o}(e,t,r),Promise.all(i).then(function(){return void 0!==t.targets?function(e,t,r){let n=!1,a=!1,i=!1;for(let e=0,r=t.length;e<r;e++){let r=t[e];if(void 0!==r.POSITION&&(n=!0),void 0!==r.NORMAL&&(a=!0),void 0!==r.COLOR_0&&(i=!0),n&&a&&i)break}if(!n&&!a&&!i)return Promise.resolve(e);let s=[],o=[],l=[];for(let A=0,u=t.length;A<u;A++){let u=t[A];if(n){let t=void 0!==u.POSITION?r.getDependency("accessor",u.POSITION):e.attributes.position;s.push(t)}if(a){let t=void 0!==u.NORMAL?r.getDependency("accessor",u.NORMAL):e.attributes.normal;o.push(t)}if(i){let t=void 0!==u.COLOR_0?r.getDependency("accessor",u.COLOR_0):e.attributes.color;l.push(t)}}return Promise.all([Promise.all(s),Promise.all(o),Promise.all(l)]).then(function(t){let r=t[0],s=t[1],o=t[2];return n&&(e.morphAttributes.position=r),a&&(e.morphAttributes.normal=s),i&&(e.morphAttributes.color=o),e.morphTargetsRelative=!0,e})}(e,t.targets,r):e})}var ee=a;let et=new WeakMap;class er extends ee.Loader{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,r,n){let a=new ee.FileLoader(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,e=>{let r={attributeIDs:this.defaultAttributeIDs,attributeTypes:this.defaultAttributeTypes,useUniqueIDs:!1};this.decodeGeometry(e,r).then(t).catch(n)},r,n)}decodeDracoFile(e,t,r,n){let a={attributeIDs:r||this.defaultAttributeIDs,attributeTypes:n||this.defaultAttributeTypes,useUniqueIDs:!!r};this.decodeGeometry(e,a).then(t)}decodeGeometry(e,t){let r;for(let e in t.attributeTypes){let r=t.attributeTypes[e];void 0!==r.BYTES_PER_ELEMENT&&(t.attributeTypes[e]=r.name)}let n=JSON.stringify(t);if(et.has(e)){let t=et.get(e);if(t.key===n)return t.promise;if(0===e.byteLength)throw Error("THREE.DRACOLoader: Unable to re-decode a buffer with different settings. Buffer has already been transferred.")}let a=this.workerNextTaskID++,i=e.byteLength,s=this._getWorker(a,i).then(n=>(r=n,new Promise((n,i)=>{r._callbacks[a]={resolve:n,reject:i},r.postMessage({type:"decode",id:a,taskConfig:t,buffer:e},[e])}))).then(e=>this._createGeometry(e.geometry));return s.catch(()=>!0).then(()=>{r&&a&&this._releaseTask(r,a)}),et.set(e,{key:n,promise:s}),s}_createGeometry(e){let t=new ee.BufferGeometry;e.index&&t.setIndex(new ee.BufferAttribute(e.index.array,1));for(let r=0;r<e.attributes.length;r++){let n=e.attributes[r],a=n.name,i=n.array,s=n.itemSize;t.setAttribute(a,new ee.BufferAttribute(i,s))}return t}_loadLibrary(e,t){let r=new ee.FileLoader(this.manager);return r.setPath(this.decoderPath),r.setResponseType(t),r.setWithCredentials(this.withCredentials),new Promise((t,n)=>{r.load(e,t,void 0,n)})}preload(){return this._initDecoder(),this}_initDecoder(){if(this.decoderPending)return this.decoderPending;let 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=>{let r=t[0];e||(this.decoderConfig.wasmBinary=t[1]);let n=en.toString(),a=["/* draco decoder */",r,"\n/* worker */",n.substring(n.indexOf("{")+1,n.lastIndexOf("}"))].join("\n");this.workerSourceURL=URL.createObjectURL(new Blob([a]))}),this.decoderPending}_getWorker(e,t){return this._initDecoder().then(()=>{if(this.workerPool.length<this.workerLimit){let e=new Worker(this.workerSourceURL);e._callbacks={},e._taskCosts={},e._taskLoad=0,e.postMessage({type:"init",decoderConfig:this.decoderConfig}),e.onmessage=function(t){let r=t.data;switch(r.type){case"decode":e._callbacks[r.id].resolve(r);break;case"error":e._callbacks[r.id].reject(r);break;default:console.error('THREE.DRACOLoader: Unexpected message, "'+r.type+'"')}},this.workerPool.push(e)}else this.workerPool.sort(function(e,t){return e._taskLoad>t._taskLoad?-1:1});let r=this.workerPool[this.workerPool.length-1];return r._taskCosts[e]=t,r._taskLoad+=t,r})}_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 en(){let e,t;onmessage=function(r){let n=r.data;switch(n.type){case"init":e=n.decoderConfig,t=new Promise(function(t){e.onModuleLoaded=function(e){t({draco:e})},DracoDecoderModule(e)});break;case"decode":let a=n.buffer,i=n.taskConfig;t.then(e=>{let t=e.draco,r=new t.Decoder,s=new t.DecoderBuffer;s.Init(new Int8Array(a),a.byteLength);try{let e=function(e,t,r,n){var a,i,s;let o,l,A,u,c,h,d=n.attributeIDs,f=n.attributeTypes,B=t.GetEncodedGeometryType(r);if(B===e.TRIANGULAR_MESH)c=new e.Mesh,h=t.DecodeBufferToMesh(r,c);else if(B===e.POINT_CLOUD)c=new e.PointCloud,h=t.DecodeBufferToPointCloud(r,c);else throw Error("THREE.DRACOLoader: Unexpected geometry type.");if(!h.ok()||0===c.ptr)throw Error("THREE.DRACOLoader: Decoding failed: "+h.error_msg());let p={index:null,attributes:[]};for(let r in d){let a,i,s=self[f[r]];if(n.useUniqueIDs)i=d[r],a=t.GetAttributeByUniqueId(c,i);else{if(-1===(i=t.GetAttributeId(c,e[d[r]])))continue;a=t.GetAttribute(c,i)}p.attributes.push(function(e,t,r,n,a,i){let s=i.num_components(),o=r.num_points()*s,l=o*a.BYTES_PER_ELEMENT,A=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,a),u=e._malloc(l);t.GetAttributeDataArrayForAllPoints(r,i,A,l,u);let c=new a(e.HEAPF32.buffer,u,o).slice();return e._free(u),{name:n,array:c,itemSize:s}}(e,t,c,r,s,a))}return B===e.TRIANGULAR_MESH&&(a=e,i=t,s=c,o=3*s.num_faces(),l=4*o,A=a._malloc(l),i.GetTrianglesUInt32Array(s,l,A),u=new Uint32Array(a.HEAPF32.buffer,A,o).slice(),a._free(A),p.index={array:u,itemSize:1}),e.destroy(c),p}(t,r,s,i),a=e.attributes.map(e=>e.array.buffer);e.index&&a.push(e.index.array.buffer),self.postMessage({type:"decode",id:n.id,geometry:e},a)}catch(e){console.error(e),self.postMessage({type:"error",id:n.id,error:e.message})}finally{t.destroy(s),t.destroy(r)}})}}}var ea=e.i(60602);let ei=function(e){let t=new Map,r=new Map,n=e.clone();return function e(t,r,n){n(t,r);for(let a=0;a<t.children.length;a++)e(t.children[a],r.children[a],n)}(e,n,function(e,n){t.set(n,e),r.set(e,n)}),n.traverse(function(e){if(!e.isSkinnedMesh)return;let n=t.get(e),a=n.skeleton.bones;e.skeleton=n.skeleton.clone(),e.bindMatrix.copy(n.bindMatrix),e.skeleton.bones=a.map(function(e){return r.get(e)}),e.bind(e.skeleton,e.bindMatrix)}),n},es=n.forwardRef(({isChild:e=!1,object:t,children:i,deep:s,castShadow:o,receiveShadow:l,inject:A,keys:u,...c},h)=>{let d={keys:u,deep:s,inject:A,castShadow:o,receiveShadow:l};if(Array.isArray(t=n.useMemo(()=>{if(!1===e&&!Array.isArray(t)){let e=!1;if(t.traverse(t=>{t.isSkinnedMesh&&(e=!0)}),e)return ei(t)}return t},[t,e])))return n.createElement("group",(0,r.default)({},c,{ref:h}),t.map(e=>n.createElement(es,(0,r.default)({key:e.uuid,object:e},d))),i);let{children:f,...B}=function(e,{keys:t=["near","far","color","distance","decay","penumbra","angle","intensity","skeleton","visible","castShadow","receiveShadow","morphTargetDictionary","morphTargetInfluences","name","geometry","material","position","rotation","scale","up","userData","bindMode","bindMatrix","bindMatrixInverse","skeleton"],deep:r,inject:i,castShadow:s,receiveShadow:o}){let l={};for(let r of t)l[r]=e[r];return r&&(l.geometry&&"materialsOnly"!==r&&(l.geometry=l.geometry.clone()),l.material&&"geometriesOnly"!==r&&(l.material=l.material.clone())),i&&(l="function"==typeof i?{...l,children:i(e)}:n.isValidElement(i)?{...l,children:i}:{...l,...i}),e instanceof a.Mesh&&(s&&(l.castShadow=!0),o&&(l.receiveShadow=!0)),l}(t,d),p=t.type[0].toLowerCase()+t.type.slice(1);return n.createElement(p,(0,r.default)({},B,c,{ref:h}),t.children.map(e=>"Bone"===e.type?n.createElement("primitive",(0,r.default)({key:e.uuid,object:e},d)):n.createElement(es,(0,r.default)({key:e.uuid,object:e},d,{isChild:!0}))),i,f)}),eo=null,el="https://www.gstatic.com/draco/versioned/decoders/1.5.5/";function eA(e=!0,r=!0,n){return a=>{n&&n(a),e&&(eo||(eo=new er),eo.setDecoderPath("string"==typeof e?e:el),a.setDRACOLoader(eo)),r&&a.setMeshoptDecoder((()=>{let e;if(t)return t;let r=new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,3,2,0,0,5,3,1,0,1,12,1,0,10,22,2,12,0,65,0,65,0,65,0,252,10,0,0,11,7,0,65,0,253,15,26,11]),n=new Uint8Array([32,0,65,253,3,1,2,34,4,106,6,5,11,8,7,20,13,33,12,16,128,9,116,64,19,113,127,15,10,21,22,14,255,66,24,54,136,107,18,23,192,26,114,118,132,17,77,101,130,144,27,87,131,44,45,74,156,154,70,167]);if("object"!=typeof WebAssembly)return{supported:!1};let a=" ";WebAssembly.validate(r)&&(a=" ");let i=WebAssembly.instantiate(function(e){let t=new Uint8Array(e.length);for(let r=0;r<e.length;++r){let n=e.charCodeAt(r);t[r]=n>96?n-71:n>64?n-65:n>47?n+4:n>46?63:62}let r=0;for(let a=0;a<e.length;++a)t[r++]=t[a]<60?n[t[a]]:(t[a]-60)*64+t[++a];return t.buffer.slice(0,r)}(a),{}).then(t=>{(e=t.instance).exports.__wasm_call_ctors()});function s(t,r,n,a,i,s){let o=e.exports.sbrk,l=n+3&-4,A=o(l*a),u=o(i.length),c=new Uint8Array(e.exports.memory.buffer);c.set(i,u);let h=t(A,n,a,u,i.length);if(0===h&&s&&s(A,l,a),r.set(c.subarray(A,A+n*a)),o(A-o(0)),0!==h)throw Error(`Malformed buffer data: ${h}`)}let o={0:"",1:"meshopt_decodeFilterOct",2:"meshopt_decodeFilterQuat",3:"meshopt_decodeFilterExp",NONE:"",OCTAHEDRAL:"meshopt_decodeFilterOct",QUATERNION:"meshopt_decodeFilterQuat",EXPONENTIAL:"meshopt_decodeFilterExp"},l={0:"meshopt_decodeVertexBuffer",1:"meshopt_decodeIndexBuffer",2:"meshopt_decodeIndexSequence",ATTRIBUTES:"meshopt_decodeVertexBuffer",TRIANGLES:"meshopt_decodeIndexBuffer",INDICES:"meshopt_decodeIndexSequence"};return t={ready:i,supported:!0,decodeVertexBuffer(t,r,n,a,i){s(e.exports.meshopt_decodeVertexBuffer,t,r,n,a,e.exports[o[i]])},decodeIndexBuffer(t,r,n,a){s(e.exports.meshopt_decodeIndexBuffer,t,r,n,a)},decodeIndexSequence(t,r,n,a){s(e.exports.meshopt_decodeIndexSequence,t,r,n,a)},decodeGltfBuffer(t,r,n,a,i,A){s(e.exports[l[i]],t,r,n,a,e.exports[o[A]])}}})())}}let eu=(e,t,r,n)=>(0,ea.useLoader)(u,e,eA(t,r,n));eu.preload=(e,t,r,n)=>ea.useLoader.preload(u,e,eA(t,r,n)),eu.clear=e=>ea.useLoader.clear(u,e),eu.setDecoderPath=e=>{el=e},e.s(["useGLTF",0,eu],78140);var ec=e.i(8155);let eh=e=>{let t=(0,ec.createStore)(e),r=e=>(function(e,t=e=>e){let r=n.default.useSyncExternalStore(e.subscribe,n.default.useCallback(()=>t(e.getState()),[e,t]),n.default.useCallback(()=>t(e.getInitialState()),[e,t]));return n.default.useDebugValue(r),r})(t,e);return Object.assign(r,t),r};e.s(["create",0,e=>e?eh(e):eh],68834)}]);