@newkrok/three-particles 2.2.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -0
- package/dist/bundle-report.json +1 -1
- package/dist/js/effects/three-particles/three-particles-curves.d.ts +71 -0
- package/dist/js/effects/three-particles/three-particles-curves.d.ts.map +1 -1
- package/dist/js/effects/three-particles/three-particles-curves.js +25 -0
- package/dist/js/effects/three-particles/three-particles-enums.d.ts +90 -0
- package/dist/js/effects/three-particles/three-particles-enums.d.ts.map +1 -1
- package/dist/js/effects/three-particles/three-particles-modifiers.d.ts +62 -0
- package/dist/js/effects/three-particles/three-particles-modifiers.d.ts.map +1 -1
- package/dist/js/effects/three-particles/three-particles-modifiers.js +76 -0
- package/dist/js/effects/three-particles/three-particles-utils.d.ts +123 -0
- package/dist/js/effects/three-particles/three-particles-utils.d.ts.map +1 -1
- package/dist/js/effects/three-particles/three-particles-utils.js +123 -0
- package/dist/js/effects/three-particles/three-particles.d.ts +166 -0
- package/dist/js/effects/three-particles/three-particles.d.ts.map +1 -1
- package/dist/js/effects/three-particles/three-particles.js +202 -8
- package/dist/js/effects/three-particles/types.d.ts +119 -0
- package/dist/js/effects/three-particles/types.d.ts.map +1 -1
- package/dist/three-particles.min.js +1 -1
- package/package.json +20 -20
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see three-particles.min.js.LICENSE.txt */
|
|
2
|
-
import{AdditiveBlending as e,AmbientLight as t,AnimationClip as n,Audio as r,AudioListener as s,AudioLoader as i,Bone as o,Box3 as a,BufferAttribute as c,BufferGeometry as l,CanvasTexture as u,ClampToEdgeWrapping as h,Color as d,ColorManagement as p,Curve as m,DirectionalLight as f,DoubleSide as g,EquirectangularReflectionMapping as y,Euler as v,FileLoader as x,Float32BufferAttribute as T,FrontSide as w,Group as I,ImageBitmapLoader as b,InstancedBufferAttribute as A,InstancedMesh as M,InterleavedBuffer as R,InterleavedBufferAttribute as S,Interpolant as E,InterpolateDiscrete as _,InterpolateLinear as L,Line as O,LineBasicMaterial as P,LineLoop as N,LineSegments as C,LinearFilter as k,LinearMipmapLinearFilter as D,LinearMipmapNearestFilter as F,LinearSRGBColorSpace as U,Loader as z,LoaderUtils as B,Material as V,MathUtils as H,Matrix3 as j,Matrix4 as G,Mesh as K,MeshBasicMaterial as W,MeshLambertMaterial as X,MeshPhongMaterial as Q,MeshPhysicalMaterial as q,MeshStandardMaterial as Y,MirroredRepeatWrapping as $,MultiplyBlending as Z,NearestFilter as J,NearestMipmapLinearFilter as ee,NearestMipmapNearestFilter as te,NoBlending as ne,NormalBlending as re,NumberKeyframeTrack as se,Object3D as ie,OrthographicCamera as oe,PerspectiveCamera as ae,PointLight as ce,Points as le,PointsMaterial as ue,PositionalAudio as he,PropertyBinding as de,Quaternion as pe,QuaternionKeyframeTrack as me,RepeatWrapping as fe,SRGBColorSpace as ge,ShaderMaterial as ye,ShapeUtils as ve,Skeleton as xe,SkinnedMesh as Te,Sphere as we,SphereGeometry as Ie,SpotLight as be,SubtractiveBlending as Ae,Texture as Me,TextureLoader as Re,TriangleFanDrawMode as Se,TriangleStripDrawMode as Ee,TrianglesDrawMode as _e,Uint16BufferAttribute as Le,Vector2 as Oe,Vector3 as Pe,Vector4 as Ne,VectorKeyframeTrack as Ce}from"THREE";var ke={300:e=>{const t=e=>e,n={In:e=>e*e,Out:e=>e*(2-e),InOut(e){let t=2*e;return t<1?.5*t*t:(t-=1,-.5*(t*(t-2)-1))}},r={In:e=>e*e*e,Out:e=>--e*e*e+1,InOut(e){let t=2*e;return t<1?.5*t*t*t:(t-=2,.5*(t*t*t+2))}},s={In:e=>e*e*e*e,Out:e=>1- --e*e*e*e,InOut(e){let t=2*e;return t<1?.5*t*t*t*t:(t-=2,-.5*(t*t*t*t-2))}},i={In:e=>e*e*e*e*e,Out:e=>--e*e*e*e*e+1,InOut(e){let t=2*e;return t<1?.5*t*t*t*t*t:(t-=2,.5*(t*t*t*t*t+2))}},o={In:e=>1-Math.cos(e*Math.PI/2),Out:e=>Math.sin(e*Math.PI/2),InOut:e=>.5*(1-Math.cos(Math.PI*e))},a={In:e=>0===e?0:1024**(e-1),Out:e=>1===e?1:1-2**(-10*e),InOut(e){if(0===e)return 0;if(1===e)return 1;const t=2*e;return t<1?.5*1024**(t-1):.5*(2-2**(-10*(t-1)))}},c={In:e=>1-Math.sqrt(1-e*e),Out:e=>Math.sqrt(1- --e*e),InOut(e){let t=2*e;return t<1?-.5*(Math.sqrt(1-t*t)-1):(t-=2,.5*(Math.sqrt(1-t*t)+1))}},l={In(e){let t=.1;let n;return 0===e?0:1===e?1:(t<1?(t=1,n=.1):n=.4*Math.asin(1/t)/(2*Math.PI),-t*2**(10*(e-=1))*Math.sin((e-n)*(2*Math.PI)/.4))},Out(e){let t=.1;let n;return 0===e?0:1===e?1:(t<1?(t=1,n=.1):n=.4*Math.asin(1/t)/(2*Math.PI),t*2**(-10*e)*Math.sin((e-n)*(2*Math.PI)/.4)+1)},InOut(e){let t=.1;const n=.4;let r;if(0===e)return 0;if(1===e)return 1;t<1?(t=1,r=.1):r=n*Math.asin(1/t)/(2*Math.PI);const s=2*e;if(s<1){const e=s-1;return t*2**(10*e)*Math.sin((e-r)*(2*Math.PI)/n)*-.5}const i=s-1;return t*2**(-10*i)*Math.sin((i-r)*(2*Math.PI)/n)*.5+1}},u={In(e){const t=1.70158;return e*e*((t+1)*e-t)},Out(e){const t=1.70158;return--e*e*((t+1)*e+t)+1},InOut(e){const t=2.5949095;let n=2*e;return n<1?n*n*((t+1)*n-t)*.5:(n-=2,.5*(n*n*((t+1)*n+t)+2))}},h={In:e=>1-h.Out(1-e),Out(e){if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const t=e-1.5/2.75;return 7.5625*t*t+.75}if(e<2.5/2.75){const t=e-2.25/2.75;return 7.5625*t*t+.9375}const t=e-2.625/2.75;return 7.5625*t*t+.984375},InOut:e=>e<.5?.5*h.In(2*e):.5*h.Out(2*e-1)+.5},d={Quadratic:n,Cubic:r,Quartic:s,Quintic:i,Sinusoidal:o,Exponential:a,Circular:c,Elastic:l,Back:u,Bounce:h},p=(e,t,n)=>Object.defineProperty(e,t,{value:n});for(const e of Object.keys(d)){const t=d[e],n=e.toLowerCase();p(d,n,t);for(const r of Object.keys(t)){const s=t[r],i=r.toLowerCase();p(d,`${e}.${r}`,s),p(d,`${n}.${i}`,s),p(t,i,s)}}d.Linear=t,p(d,"linear",t),e.exports=d,"undefined"!=typeof window&&(window.Easing=d)}},De={};function Fe(e){var t=De[e];if(void 0!==t)return t.exports;var n=De[e]={exports:{}};return ke[e](n,n.exports,Fe),n.exports}Fe.d=(e,t)=>{for(var n in t)Fe.o(t,n)&&!Fe.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},Fe.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const Ue=[],ze=(e,t)=>{let n=1;for(let r=1;r<=t;r++)n*=(e+1-r)/r;return n},Be=(e,t)=>{const n=Ue.find(e=>e.bezierPoints===t);if(n)return n.referencedBy.includes(e)||n.referencedBy.push(e),n.curveFunction;const r={referencedBy:[e],bezierPoints:t,curveFunction:e=>{if(e<0)return t[0].y;if(e>1)return t[t.length-1].y;let n=0,r=t.length-1;t.find((t,s)=>{const i=e<(t.percentage??0);return i?r=s:void 0!==t.percentage&&(n=s),i});const s=r-n,i=(e-(t[n].percentage??0))/((t[r].percentage??1)-(t[n].percentage??0));let o=0;for(let e=0;e<=s;e++){const r=t[n+e];o+=ze(s,e)*Math.pow(1-i,s-e)*Math.pow(i,e)*r.y}return o}};return Ue.push(r),r.curveFunction},Ve=e=>{for(;;){const t=Ue.findIndex(t=>t.referencedBy.includes(e));if(-1===t)break;const n=Ue[t];n.referencedBy=n.referencedBy.filter(t=>t!==e),0===n.referencedBy.length&&Ue.splice(t,1)}},He=()=>Ue.length;var je=Fe(300);const Ge={LINEAR:je.Linear.None,QUADRATIC_IN:je.Quadratic.In,QUADRATIC_OUT:je.Quadratic.Out,QUADRATIC_IN_OUT:je.Quadratic.InOut,CUBIC_IN:je.Cubic.In,CUBIC_OUT:je.Cubic.Out,CUBIC_IN_OUT:je.Cubic.InOut,QUARTIC_IN:je.Quartic.In,QUARTIC_OUT:je.Quartic.Out,QUARTIC_IN_OUT:je.Quartic.InOut,QUINTIC_IN:je.Quintic.In,QUINTIC_OUT:je.Quintic.Out,QUINTIC_IN_OUT:je.Quintic.InOut,SINUSOIDAL_IN:je.Sinusoidal.In,SINUSOIDAL_OUT:je.Sinusoidal.Out,SINUSOIDAL_IN_OUT:je.Sinusoidal.InOut,EXPONENTIAL_IN:je.Exponential.In,EXPONENTIAL_OUT:je.Exponential.Out,EXPONENTIAL_IN_OUT:je.Exponential.InOut,CIRCULAR_IN:je.Circular.In,CIRCULAR_OUT:je.Circular.Out,CIRCULAR_IN_OUT:je.Circular.InOut,ELASTIC_IN:je.Elastic.In,ELASTIC_OUT:je.Elastic.Out,ELASTIC_IN_OUT:je.Elastic.InOut,BACK_IN:je.Back.In,BACK_OUT:je.Back.Out,BACK_IN_OUT:je.Back.InOut,BOUNCE_IN:je.Bounce.In,BOUNCE_OUT:je.Bounce.Out,BOUNCE_IN_OUT:je.Bounce.InOut},Ke=e=>"function"==typeof e?e:Ge[e],We=(e,t,n,r,{radius:s,radiusThickness:i,arc:o})=>{const a=Math.random()*(o/360),c=Math.random(),l=Math.random(),u=2*Math.PI*a,h=Math.acos(2*c-1),d=Math.sin(h),p=d*Math.cos(u),m=d*Math.sin(u),f=Math.cos(h),g=1-i;e.x=s*g*p+s*i*l*p,e.y=s*g*m+s*i*l*m,e.z=s*g*f+s*i*l*f,e.applyQuaternion(t);const y=1/e.length();n.set(e.x*y*r,e.y*y*r,e.z*y*r),n.applyQuaternion(t)},Xe=(e,t,n,r,{radius:s,radiusThickness:i,arc:o,angle:a=90})=>{const c=2*Math.PI*Math.random()*(o/360),l=Math.random(),u=Math.cos(c),h=Math.sin(c),d=1-i;e.x=s*d*u+s*i*l*u,e.y=s*d*h+s*i*l*h,e.z=0,e.applyQuaternion(t);const p=e.length(),m=Math.abs(p/s*H.degToRad(a)),f=Math.sin(m),g=1/p;n.set(e.x*f*g*r,e.y*f*g*r,Math.cos(m)*r),n.applyQuaternion(t)},Qe=(e,t,n,r,{scale:s,emitFrom:i})=>{const o=s;switch(i){case"VOLUME":e.x=Math.random()*o.x-o.x/2,e.y=Math.random()*o.y-o.y/2,e.z=Math.random()*o.z-o.z/2;break;case"SHELL":const t=Math.floor(6*Math.random()),n=t%3,r=[];r[n]=t>2?1:0,r[(n+1)%3]=Math.random(),r[(n+2)%3]=Math.random(),e.x=r[0]*o.x-o.x/2,e.y=r[1]*o.y-o.y/2,e.z=r[2]*o.z-o.z/2;break;case"EDGE":const s=Math.floor(6*Math.random()),i=s%3,a=Math.floor(4*Math.random()),c=[];c[i]=s>2?1:0,c[(i+1)%3]=a<2?Math.random():a-2,c[(i+2)%3]=a<2?a:Math.random(),e.x=c[0]*o.x-o.x/2,e.y=c[1]*o.y-o.y/2,e.z=c[2]*o.z-o.z/2}e.applyQuaternion(t),n.set(0,0,r),n.applyQuaternion(t)},qe=(e,t,n,r,{radius:s,radiusThickness:i,arc:o})=>{const a=2*Math.PI*Math.random()*(o/360),c=Math.random(),l=Math.cos(a),u=Math.sin(a),h=1-i;e.x=s*h*l+s*i*c*l,e.y=s*h*u+s*i*c*u,e.z=0,e.applyQuaternion(t);const d=1/e.length();n.set(e.x*d*r,e.y*d*r,0),n.applyQuaternion(t)},Ye=(e,t,n,r,{rotation:s,scale:i})=>{const o=i,a=s,c=Math.random()*o.x-o.x/2,l=Math.random()*o.y-o.y/2,u=H.degToRad(a.x),h=H.degToRad(a.y);e.x=c*Math.cos(h),e.y=l*Math.cos(u),e.z=c*Math.sin(h)-l*Math.sin(u),e.applyQuaternion(t),n.set(0,0,r),n.applyQuaternion(t)},$e=()=>{try{const e=document.createElement("canvas"),t=64;e.width=t,e.height=t;const n=e.getContext("2d");if(n){const r=t/2,s=t/2,i=t/2-2;n.beginPath(),n.arc(r,s,i,0,2*Math.PI,!1),n.fillStyle="white",n.fill();const o=new u(e);return o.needsUpdate=!0,o}return null}catch(e){return null}},Ze=e=>"number"!=typeof e&&"type"in e,Je=(e,t)=>{if("BEZIER"===t.type)return Be(e,t.bezierPoints);if("EASING"===t.type)return t.curveFunction;throw new Error(`Unsupported value type: ${t}`)},et=(e,t,n=0)=>{if("number"==typeof t)return t;if("min"in t&&"max"in t)return t.min===t.max?t.min??0:H.randFloat(t.min??0,t.max??1);const r=t;return Je(e,r)(n)*(r.scale??1)},tt=new Pe(0,0,0),nt=new v,rt=({delta:e,generalData:t,normalizedConfig:n,attributes:r,particleLifetimePercentage:s,particleIndex:i})=>{const{particleSystemId:o,startValues:a,lifetimeValues:c,linearVelocityData:l,orbitalVelocityData:u,noise:h}=t,d=3*i,p=r.position.array;if(l){const{speed:t,valueModifiers:n}=l[i],o=n.x?n.x(s):t.x,a=n.y?n.y(s):t.y,c=n.z?n.z(s):t.z;p[d]+=o*e,p[d+1]+=a*e,p[d+2]+=c*e,r.position.needsUpdate=!0}if(u){const{speed:t,positionOffset:n,valueModifiers:o}=u[i];p[d]-=n.x,p[d+1]-=n.y,p[d+2]-=n.z;const a=o.x?o.x(s):t.x,c=o.y?o.y(s):t.y,l=o.z?o.z(s):t.z;nt.set(a*e,l*e,c*e),n.applyEuler(nt),p[d]+=n.x,p[d+1]+=n.y,p[d+2]+=n.z,r.position.needsUpdate=!0}if(n.sizeOverLifetime.isActive){const e=et(o,n.sizeOverLifetime.lifetimeCurve,s);r.size.array[i]=a.startSize[i]*e,r.size.needsUpdate=!0}if(n.opacityOverLifetime.isActive){const e=et(o,n.opacityOverLifetime.lifetimeCurve,s);r.colorA.array[i]=a.startOpacity[i]*e,r.colorA.needsUpdate=!0}if(c.rotationOverLifetime&&(r.rotation.array[i]+=c.rotationOverLifetime[i]*e*.02,r.rotation.needsUpdate=!0),h.isActive){const{sampler:e,strength:t,offsets:n,positionAmount:o,rotationAmount:a,sizeAmount:c}=h;let l;const u=10*(s+(n?n[i]:0))*t,m=.15*t;tt.set(u,0,0),l=e.get3(tt),p[d]+=l*m*o,0!==a&&(r.rotation.array[i]+=l*m*a,r.rotation.needsUpdate=!0),0!==c&&(r.size.array[i]+=l*m*c,r.size.needsUpdate=!0),tt.set(u,u,0),l=e.get3(tt),p[d+1]+=l*m*o,tt.set(u,u,u),l=e.get3(tt),p[d+2]+=l*m*o,r.position.needsUpdate=!0}};const st=(e,t,n={skippedProperties:[],applyToFirstObject:!1})=>{const r={};return Array.from(new Set([...Object.keys(e||{}),...Object.keys(t||{})])).forEach(s=>{n.skippedProperties&&n.skippedProperties.includes(s)||("object"==typeof e?.[s]&&e?.[s]&&t?.[s]&&!Array.isArray(e[s])?r[s]=st(e[s],t[s],n):(r[s]=0===t?.[s]?0:!1!==t?.[s]&&(t?.[s]||e?.[s]),n.applyToFirstObject&&(e[s]=r[s])))}),r};var it=Uint8Array,ot=Uint16Array,at=Int32Array,ct=new it([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]),lt=new it([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]),ut=new it([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ht=function(e,t){for(var n=new ot(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new at(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return{b:n,r:s}},dt=ht(ct,2),pt=dt.b,mt=dt.r;pt[28]=258,mt[258]=28;for(var ft=ht(lt,0),gt=ft.b,yt=(ft.r,new ot(32768)),vt=0;vt<32768;++vt){var xt=(43690&vt)>>1|(21845&vt)<<1;xt=(61680&(xt=(52428&xt)>>2|(13107&xt)<<2))>>4|(3855&xt)<<4,yt[vt]=((65280&xt)>>8|(255&xt)<<8)>>1}var Tt=function(e,t,n){for(var r=e.length,s=0,i=new ot(t);s<r;++s)e[s]&&++i[e[s]-1];var o,a=new ot(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;if(n){o=new ot(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],u=t-e[s],h=a[e[s]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)o[yt[h]>>c]=l}else for(o=new ot(r),s=0;s<r;++s)e[s]&&(o[s]=yt[a[e[s]-1]++]>>15-e[s]);return o},wt=new it(288);for(vt=0;vt<144;++vt)wt[vt]=8;for(vt=144;vt<256;++vt)wt[vt]=9;for(vt=256;vt<280;++vt)wt[vt]=7;for(vt=280;vt<288;++vt)wt[vt]=8;var It=new it(32);for(vt=0;vt<32;++vt)It[vt]=5;var bt=Tt(wt,9,1),At=Tt(It,5,1),Mt=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Rt=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},St=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Et=function(e){return(e+7)/8|0},_t=function(e,t,n){return(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length),new it(e.subarray(t,n))},Lt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ot=function(e,t,n){var r=new Error(t||Lt[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Ot),!n)throw r;return r},Pt=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new it(0);var o=!n,a=o||2!=t.i,c=t.i;o&&(n=new it(3*s));var l=function(e){var t=n.length;if(e>t){var r=new it(Math.max(2*t,e));r.set(n),n=r}},u=t.f||0,h=t.p||0,d=t.b||0,p=t.l,m=t.d,f=t.m,g=t.n,y=8*s;do{if(!p){u=Rt(e,h,1);var v=Rt(e,h+1,3);if(h+=3,!v){var x=e[(L=Et(h)+4)-4]|e[L-3]<<8,T=L+x;if(T>s){c&&Ot(0);break}a&&l(d+x),n.set(e.subarray(L,T),d),t.b=d+=x,t.p=h=8*T,t.f=u;continue}if(1==v)p=bt,m=At,f=9,g=5;else if(2==v){var w=Rt(e,h,31)+257,I=Rt(e,h+10,15)+4,b=w+Rt(e,h+5,31)+1;h+=14;for(var A=new it(b),M=new it(19),R=0;R<I;++R)M[ut[R]]=Rt(e,h+3*R,7);h+=3*I;var S=Mt(M),E=(1<<S)-1,_=Tt(M,S,1);for(R=0;R<b;){var L,O=_[Rt(e,h,E)];if(h+=15&O,(L=O>>4)<16)A[R++]=L;else{var P=0,N=0;for(16==L?(N=3+Rt(e,h,3),h+=2,P=A[R-1]):17==L?(N=3+Rt(e,h,7),h+=3):18==L&&(N=11+Rt(e,h,127),h+=7);N--;)A[R++]=P}}var C=A.subarray(0,w),k=A.subarray(w);f=Mt(C),g=Mt(k),p=Tt(C,f,1),m=Tt(k,g,1)}else Ot(1);if(h>y){c&&Ot(0);break}}a&&l(d+131072);for(var D=(1<<f)-1,F=(1<<g)-1,U=h;;U=h){var z=(P=p[St(e,h)&D])>>4;if((h+=15&P)>y){c&&Ot(0);break}if(P||Ot(2),z<256)n[d++]=z;else{if(256==z){U=h,p=null;break}var B=z-254;if(z>264){var V=ct[R=z-257];B=Rt(e,h,(1<<V)-1)+pt[R],h+=V}var H=m[St(e,h)&F],j=H>>4;H||Ot(3),h+=15&H;k=gt[j];if(j>3){V=lt[j];k+=St(e,h)&(1<<V)-1,h+=V}if(h>y){c&&Ot(0);break}a&&l(d+131072);var G=d+B;if(d<k){var K=i-k,W=Math.min(k,G);for(K+d<0&&Ot(3);d<W;++d)n[d]=r[K+d]}for(;d<G;++d)n[d]=n[d-k]}}t.l=p,t.p=U,t.b=d,t.f=u,p&&(u=1,t.m=f,t.d=m,t.n=g)}while(!u);return d!=n.length&&o?_t(n,0,d):n.subarray(0,d)},Nt=new it(0),Ct=function(e,t){return(8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Ot(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&Ot(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),2+(e[1]>>3&4)};function kt(e,t){return Pt(e.subarray(Ct(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var Dt="undefined"!=typeof TextDecoder&&new TextDecoder;try{Dt.decode(Nt,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;function Ft(e,t,n){const r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let s=e,i=r,o=Math.floor((s+i)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?i=o:s=o,o=Math.floor((s+i)/2);return o}function Ut(e,t,n,r){const s=[],i=[],o=[];s[0]=1;for(let a=1;a<=n;++a){i[a]=t-r[e+1-a],o[a]=r[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=o[e+1],r=i[a-e],c=s[e]/(t+r);s[e]=n+t*c,n=r*c}s[a]=n}return s}function zt(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function Bt(e,t,n,r,s){const i=function(e,t,n,r,s){const i=s<e?s:e,o=[],a=Ft(e,r,t),c=function(e,t,n,r,s){const i=[];for(let e=0;e<=n;++e)i[e]=0;const o=[];for(let e=0;e<=r;++e)o[e]=i.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=i.slice(0);a[0][0]=1;const c=i.slice(0),l=i.slice(0);for(let r=1;r<=n;++r){c[r]=t-s[e+1-r],l[r]=s[e+r]-t;let n=0;for(let e=0;e<r;++e){const t=l[e+1],s=c[r-e];a[r][e]=t+s;const i=a[e][r-1]/a[r][e];a[e][r]=n+t*i,n=s*i}a[r][r]=n}for(let e=0;e<=n;++e)o[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,s=1;const c=[];for(let e=0;e<=n;++e)c[e]=i.slice(0);c[0][0]=1;for(let i=1;i<=r;++i){let r=0;const l=e-i,u=n-i;e>=i&&(c[s][0]=c[t][0]/a[u+1][l],r=c[s][0]*a[l][u]);const h=e-1<=u?i-1:n-e;for(let e=l>=-1?1:-l;e<=h;++e)c[s][e]=(c[t][e]-c[t][e-1])/a[u+1][l+e],r+=c[s][e]*a[l+e][u];e<=u&&(c[s][i]=-c[t][i-1]/a[u+1][e],r+=c[s][i]*a[e][u]),o[i][e]=r;const d=t;t=s,s=d}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)o[e][t]*=u;u*=n-e}return o}(a,r,e,i,t),l=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,l[e]=t}for(let t=0;t<=i;++t){const n=l[a-e].clone().multiplyScalar(c[t][0]);for(let r=1;r<=e;++r)n.add(l[a-e+r].clone().multiplyScalar(c[t][r]));o[t]=n}for(let e=i+1;e<=s+1;++e)o[e]=new Ne(0,0,0);return o}(e,t,n,r,s);return function(e){const t=e.length,n=[],r=[];for(let s=0;s<t;++s){const t=e[s];n[s]=new Pe(t.x,t.y,t.z),r[s]=t.w}const s=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(s[e-n].clone().multiplyScalar(zt(e,n)*r[n]));s[e]=t.divideScalar(r[0])}return s}(i)}class Vt extends m{constructor(e,t,n,r,s){super();const i=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=s||i;for(let e=0;e<o;++e){const t=n[e];this.controlPoints[e]=new Ne(t.x,t.y,t.z,t.w)}}getPoint(e,t=new Pe){const n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=function(e,t,n,r){const s=Ft(e,r,t),i=Ut(s,r,e,t),o=new Ne(0,0,0,0);for(let t=0;t<=e;++t){const r=n[s-e+t],a=i[t],c=r.w*a;o.x+=r.x*c,o.y+=r.y*c,o.z+=r.z*c,o.w+=r.w*a}return o}(this.degree,this.knots,this.controlPoints,r);return 1!==s.w&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t=new Pe){const n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=Bt(this.degree,this.knots,this.controlPoints,r,1);return n.copy(s[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(e=>e.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(e=>new Ne(e[0],e[1],e[2],e[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}let Ht,jt,Gt;class Kt extends z{constructor(e){super(e)}load(e,t,n,r){const s=this,i=""===s.path?B.extractUrlBase(e):s.path,o=new x(this.manager);o.setPath(s.path),o.setResponseType("arraybuffer"),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(n){try{t(s.parse(n,i))}catch(t){r&&r(t),s.manager.itemError(e)}},n,r)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===ln(e,0,t.length)}(e))Ht=(new Yt).parse(e);else{const t=ln(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(t){const r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e){if(r(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Jt(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Jt(t));Ht=(new qt).parse(t)}const n=new Re(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Wt(n,this.manager).parse(Ht)}}class Wt{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){jt=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),s=(new Xt).parse(r);return this.parseScene(r,s,n),Gt}parseConnections(){const e=new Map;if("Connections"in Ht){Ht.Connections.connections.forEach(function(t){const n=t[0],r=t[1],s=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const i={ID:r,relationship:s};e.get(n).parents.push(i),e.has(r)||e.set(r,{parents:[],children:[]});const o={ID:n,relationship:s};e.get(r).children.push(o)})}return e}parseImages(){const e={},t={};if("Video"in Ht.Objects){const n=Ht.Objects.Video;for(const r in n){const s=n[r];if(e[parseInt(r)]=s.RelativeFilename||s.Filename,"Content"in s){const e=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,i="string"==typeof s.Content&&""!==s.Content;if(e||i){const e=this.parseImage(n[r]);t[s.RelativeFilename||s.Filename]=e}}}}for(const n in e){const r=e[n];void 0!==t[r]?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename;let r;switch(n.slice(n.lastIndexOf(".")+1).toLowerCase()){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":this.manager.getHandler(".tga"),r="image/tga";break;case"webp":r="image/webp";break;default:return}if("string"==typeof t)return"data:"+r+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in Ht.Objects){const n=Ht.Objects.Texture;for(const r in n){const s=this.parseTexture(n[r],e);t.set(parseInt(r),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const r=e.WrapModeU,s=e.WrapModeV,i=void 0!==r?r.value:0,o=void 0!==s?s.value:0;if(n.wrapS=0===i?fe:h,n.wrapT=0===o?fe:h,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){const n=e.FileName.split(".").pop().toLowerCase();let r=this.manager.getHandler(`.${n}`);null===r&&(r=this.textureLoader);const s=r.path;s||r.setPath(this.textureLoader.path);const i=jt.get(e.id).children;let o;if(void 0!==i&&i.length>0&&void 0!==t[i[0].ID]&&(o=t[i[0].ID],0!==o.indexOf("blob:")&&0!==o.indexOf("data:")||r.setPath(void 0)),void 0===o)return new Me;const a=r.load(o);return r.setPath(s),a}parseMaterials(e){const t=new Map;if("Material"in Ht.Objects){const n=Ht.Objects.Material;for(const r in n){const s=this.parseMaterial(n[r],e);null!==s&&t.set(parseInt(r),s)}}return t}parseMaterial(e,t){const n=e.id,r=e.attrName;let s=e.ShadingModel;if("object"==typeof s&&(s=s.value),!jt.has(n))return null;const i=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":default:o=new Q;break;case"lambert":o=new X}return o.setValues(i),o.name=r,o}parseParameters(e,t,n){const r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=p.colorSpaceToWorking((new d).fromArray(e.Diffuse.value),ge):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(r.color=p.colorSpaceToWorking((new d).fromArray(e.DiffuseColor.value),ge)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=p.colorSpaceToWorking((new d).fromArray(e.Emissive.value),ge):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(r.emissive=p.colorSpaceToWorking((new d).fromArray(e.EmissiveColor.value),ge)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),r.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),1!==r.opacity&&0!==r.opacity||(r.opacity=e.Opacity?parseFloat(e.Opacity.value):null,null===r.opacity&&(r.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=p.colorSpaceToWorking((new d).fromArray(e.Specular.value),ge):e.SpecularColor&&"Color"===e.SpecularColor.type&&(r.specular=p.colorSpaceToWorking((new d).fromArray(e.SpecularColor.value),ge));const s=this;return jt.get(n).children.forEach(function(e){switch(e.relationship){case"Bump":r.bumpMap=s.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":r.aoMap=s.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=s.getTexture(t,e.ID),void 0!==r.map&&(r.map.colorSpace=ge);break;case"DisplacementColor":r.displacementMap=s.getTexture(t,e.ID);break;case"EmissiveColor":r.emissiveMap=s.getTexture(t,e.ID),void 0!==r.emissiveMap&&(r.emissiveMap.colorSpace=ge);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=s.getTexture(t,e.ID);break;case"ReflectionColor":r.envMap=s.getTexture(t,e.ID),void 0!==r.envMap&&(r.envMap.mapping=y,r.envMap.colorSpace=ge);break;case"SpecularColor":r.specularMap=s.getTexture(t,e.ID),void 0!==r.specularMap&&(r.specularMap.colorSpace=ge);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=s.getTexture(t,e.ID),r.transparent=!0}}),r}getTexture(e,t){return"LayeredTexture"in Ht.Objects&&t in Ht.Objects.LayeredTexture&&(t=jt.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Ht.Objects){const n=Ht.Objects.Deformer;for(const r in n){const s=n[r],i=jt.get(parseInt(r));if("Skin"===s.attrType){const t=this.parseSkeleton(i,n);t.ID=r,i.parents.length,t.geometryID=i.parents[0].ID,e[r]=t}else if("BlendShape"===s.attrType){const e={id:r};e.rawTargets=this.parseMorphTargets(i,n),e.id=r,i.parents.length,t[r]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(e){const r=t[e.ID];if("Cluster"!==r.attrType)return;const s={ID:e.ID,indices:[],weights:[],transformLink:(new G).fromArray(r.TransformLink.a)};"Indexes"in r&&(s.indices=r.Indexes.a,s.weights=r.Weights.a),n.push(s)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const s=e.children[r],i=t[s.ID],o={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if("BlendShapeChannel"!==i.attrType)return;o.geoID=jt.get(parseInt(s.ID)).children.filter(function(e){return void 0===e.relationship})[0].ID,n.push(o)}return n}parseScene(e,t,n){Gt=new I;const r=this.parseModels(e.skeletons,t,n),s=Ht.Objects.Model,i=this;r.forEach(function(e){const t=s[e.ID];i.setLookAtProperties(e,t);jt.get(e.ID).parents.forEach(function(t){const n=r.get(t.ID);void 0!==n&&n.add(e)}),null===e.parent&&Gt.add(e)}),this.bindSkeleton(e.skeletons,t,r),this.addGlobalSceneSettings(),Gt.traverse(function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=on(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}});const o=(new Qt).parse();1===Gt.children.length&&Gt.children[0].isGroup&&(Gt.children[0].animations=o,Gt=Gt.children[0]),Gt.animations=o}parseModels(e,t,n){const r=new Map,s=Ht.Objects.Model;for(const i in s){const a=parseInt(i),c=s[i],l=jt.get(a);let u=this.buildSkeleton(l,e,a,c.attrName);if(!u){switch(c.attrType){case"Camera":u=this.createCamera(l);break;case"Light":u=this.createLight(l);break;case"Mesh":u=this.createMesh(l,t,n);break;case"NurbsCurve":u=this.createCurve(l,t);break;case"LimbNode":case"Root":u=new o;break;default:u=new I}u.name=c.attrName?de.sanitizeNodeName(c.attrName):"",u.userData.originalName=c.attrName,u.ID=a}this.getTransformData(u,c),r.set(a,u)}return r}buildSkeleton(e,t,n,r){let s=null;return e.parents.forEach(function(e){for(const i in t){const a=t[i];a.rawBones.forEach(function(t,i){if(t.ID===e.ID){const e=s;s=new o,s.matrixWorld.copy(t.transformLink),s.name=r?de.sanitizeNodeName(r):"",s.userData.originalName=r,s.ID=n,a.bones[i]=s,null!==e&&s.add(e)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(e){const t=Ht.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)}),void 0===n)t=new ie;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let r=1;void 0!==n.NearPlane&&(r=n.NearPlane.value/1e3);let s=1e3;void 0!==n.FarPlane&&(s=n.FarPlane.value/1e3);let i=window.innerWidth,o=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(i=n.AspectWidth.value,o=n.AspectHeight.value);const a=i/o;let c=45;void 0!==n.FieldOfView&&(c=n.FieldOfView.value);const l=n.FocalLength?n.FocalLength.value:null;if(0===e)t=new ae(c,a,r,s),null!==l&&t.setFocalLength(l);else t=new ie}return t}createLight(e){let t,n;if(e.children.forEach(function(e){const t=Ht.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)}),void 0===n)t=new ie;else{let e;e=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=p.colorSpaceToWorking((new d).fromArray(n.Color.value),ge));let s=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(s=0);let i=0;void 0!==n.FarAttenuationEnd&&(i=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new ce(r,s,i,o);break;case 1:t=new f(r,s);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=H.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=H.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new be(r,s,i,e,a,o);break;default:t=new ce(r,s)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,s=null,i=null;const o=[];if(e.children.forEach(function(e){t.has(e.ID)&&(s=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))}),o.length>1?i=o:o.length>0?i=o[0]:(i=new Q({name:z.DEFAULT_MATERIAL_NAME,color:13421772}),o.push(i)),"color"in s.attributes&&o.forEach(function(e){e.vertexColors=!0}),s.groups.length>0){let e=!1;for(let t=0,n=s.groups.length;t<n;t++){const n=s.groups[t];(n.materialIndex<0||n.materialIndex>=o.length)&&(n.materialIndex=o.length,e=!0)}if(e){const e=new Q;o.push(e)}}return s.FBX_Deformer?(r=new Te(s,i),r.normalizeSkinWeights()):r=new K(s,i),r}createCurve(e,t){const n=e.children.reduce(function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e},null),r=new P({name:z.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new O(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder=an("RotationOrder"in t?t.RotationOrder.value:0),"Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){jt.get(e.ID).children.forEach(function(t){if("LookAtProperty"===t.relationship){const n=Ht.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),Gt.add(e.target)):e.lookAt((new Pe).fromArray(t))}}})}}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const s in e){const i=e[s];jt.get(parseInt(i.ID)).parents.forEach(function(e){if(t.has(e.ID)){const t=e.ID;jt.get(t).parents.forEach(function(e){if(n.has(e.ID)){n.get(e.ID).bind(new xe(i.bones),r[e.ID])}})}})}}parsePoseNodes(){const e={};if("Pose"in Ht.Objects){const t=Ht.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const r=t[n].PoseNode;Array.isArray(r)?r.forEach(function(t){e[t.Node]=(new G).fromArray(t.Matrix.a)}):e[r.Node]=(new G).fromArray(r.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in Ht){if("AmbientColor"in Ht.GlobalSettings){const e=Ht.GlobalSettings.AmbientColor.value,n=e[0],r=e[1],s=e[2];if(0!==n||0!==r||0!==s){const e=(new d).setRGB(n,r,s,ge);Gt.add(new t(e,1))}}"UnitScaleFactor"in Ht.GlobalSettings&&(Gt.userData.unitScaleFactor=Ht.GlobalSettings.UnitScaleFactor.value)}}}class Xt{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in Ht.Objects){const n=Ht.Objects.Geometry;for(const r in n){const s=jt.get(parseInt(r)),i=this.parseGeometry(s,n[r],e);t.set(parseInt(r),i)}}return this.negativeMaterialIndices,t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,s=[],i=e.parents.map(function(e){return Ht.Objects.Model[e.ID]});if(0===i.length)return;const o=e.children.reduce(function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e},null);e.children.forEach(function(e){void 0!==n.morphTargets[e.ID]&&s.push(n.morphTargets[e.ID])});const a=i[0],c={};"RotationOrder"in a&&(c.eulerOrder=an(a.RotationOrder.value)),"InheritType"in a&&(c.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(c.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(c.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(c.scale=a.GeometricScaling.value);const l=on(c);return this.genGeometry(t,o,s,l)}genGeometry(e,t,n,r){const s=new l;e.attrName&&(s.name=e.attrName);const i=this.parseGeoNode(e,t),o=this.genBuffers(i),a=new T(o.vertex,3);if(a.applyMatrix4(r),s.setAttribute("position",a),o.colors.length>0&&s.setAttribute("color",new T(o.colors,3)),t&&(s.setAttribute("skinIndex",new Le(o.weightsIndices,4)),s.setAttribute("skinWeight",new T(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const e=(new j).getNormalMatrix(r),t=new T(o.normal,3);t.applyNormalMatrix(e),s.setAttribute("normal",t)}if(o.uvs.forEach(function(e,t){const n=0===t?"uv":`uv${t}`;s.setAttribute(n,new T(o.uvs[t],2))}),i.material&&"AllSame"!==i.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach(function(n,r){n!==e&&(s.addGroup(t,r-t,e),e=n,t=r)}),s.groups.length>0){const t=s.groups[s.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&s.addGroup(n,o.materialIndex.length-n,e)}0===s.groups.length&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,n,r),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&e.LayerElementColor[0].Colors&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,s){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[s]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,s=!1,i=[],o=[],a=[],c=[],l=[],u=[];const h=this;return e.vertexIndices.forEach(function(d,p){let m,f=!1;d<0&&(d^=-1,f=!0);let g=[],y=[];if(i.push(3*d,3*d+1,3*d+2),e.color){const t=nn(p,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach(function(e){y.push(e.weight),g.push(e.id)}),y.length>4){s||(s=!0);const e=[0,0,0,0],t=[0,0,0,0];y.forEach(function(n,r){let s=n,i=g[r];t.forEach(function(t,n,r){if(s>t){r[n]=s,s=t;const o=e[n];e[n]=i,i=o}})}),g=e,y=t}for(;y.length<4;)y.push(0),g.push(0);for(let e=0;e<4;++e)l.push(y[e]),u.push(g[e])}if(e.normal){const t=nn(p,n,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(m=nn(p,n,d,e.material)[0],m<0&&(h.negativeMaterialIndices=!0,m=0)),e.uv&&e.uv.forEach(function(e,t){const r=nn(p,n,d,e);void 0===c[t]&&(c[t]=[]),c[t].push(r[0]),c[t].push(r[1])}),r++,f&&(h.genFace(t,e,i,m,o,a,c,l,u,r),n++,r=0,i=[],o=[],a=[],c=[],l=[],u=[])}),t}getNormalNewell(e){const t=new Pe(0,0,0);for(let n=0;n<e.length;n++){const r=e[n],s=e[(n+1)%e.length];t.x+=(r.y-s.y)*(r.z+s.z),t.y+=(r.z-s.z)*(r.x+s.x),t.z+=(r.x-s.x)*(r.y+s.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){const t=this.getNormalNewell(e),n=(Math.abs(t.z)>.5?new Pe(0,1,0):new Pe(0,0,1)).cross(t).normalize(),r=t.clone().cross(n).normalize();return{normal:t,tangent:n,bitangent:r}}flattenVertex(e,t,n){return new Oe(e.dot(t),e.dot(n))}genFace(e,t,n,r,s,i,o,a,c,l){let u;if(l>3){const e=[],r=t.baseVertexPositions||t.vertexPositions;for(let t=0;t<n.length;t+=3)e.push(new Pe(r[n[t]],r[n[t+1]],r[n[t+2]]));const{tangent:s,bitangent:i}=this.getNormalTangentAndBitangent(e),o=[];for(const t of e)o.push(this.flattenVertex(t,s,i));u=ve.triangulateShape(o,[])}else u=[[0,1,2]];for(const[l,h,d]of u)e.vertex.push(t.vertexPositions[n[3*l]]),e.vertex.push(t.vertexPositions[n[3*l+1]]),e.vertex.push(t.vertexPositions[n[3*l+2]]),e.vertex.push(t.vertexPositions[n[3*h]]),e.vertex.push(t.vertexPositions[n[3*h+1]]),e.vertex.push(t.vertexPositions[n[3*h+2]]),e.vertex.push(t.vertexPositions[n[3*d]]),e.vertex.push(t.vertexPositions[n[3*d+1]]),e.vertex.push(t.vertexPositions[n[3*d+2]]),t.skeleton&&(e.vertexWeights.push(a[4*l]),e.vertexWeights.push(a[4*l+1]),e.vertexWeights.push(a[4*l+2]),e.vertexWeights.push(a[4*l+3]),e.vertexWeights.push(a[4*h]),e.vertexWeights.push(a[4*h+1]),e.vertexWeights.push(a[4*h+2]),e.vertexWeights.push(a[4*h+3]),e.vertexWeights.push(a[4*d]),e.vertexWeights.push(a[4*d+1]),e.vertexWeights.push(a[4*d+2]),e.vertexWeights.push(a[4*d+3]),e.weightsIndices.push(c[4*l]),e.weightsIndices.push(c[4*l+1]),e.weightsIndices.push(c[4*l+2]),e.weightsIndices.push(c[4*l+3]),e.weightsIndices.push(c[4*h]),e.weightsIndices.push(c[4*h+1]),e.weightsIndices.push(c[4*h+2]),e.weightsIndices.push(c[4*h+3]),e.weightsIndices.push(c[4*d]),e.weightsIndices.push(c[4*d+1]),e.weightsIndices.push(c[4*d+2]),e.weightsIndices.push(c[4*d+3])),t.color&&(e.colors.push(i[3*l]),e.colors.push(i[3*l+1]),e.colors.push(i[3*l+2]),e.colors.push(i[3*h]),e.colors.push(i[3*h+1]),e.colors.push(i[3*h+2]),e.colors.push(i[3*d]),e.colors.push(i[3*d+1]),e.colors.push(i[3*d+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(s[3*l]),e.normal.push(s[3*l+1]),e.normal.push(s[3*l+2]),e.normal.push(s[3*h]),e.normal.push(s[3*h+1]),e.normal.push(s[3*h+2]),e.normal.push(s[3*d]),e.normal.push(s[3*d+1]),e.normal.push(s[3*d+2])),t.uv&&t.uv.forEach(function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(o[n][2*l]),e.uvs[n].push(o[n][2*l+1]),e.uvs[n].push(o[n][2*h]),e.uvs[n].push(o[n][2*h+1]),e.uvs[n].push(o[n][2*d]),e.uvs[n].push(o[n][2*d+1])})}addMorphTargets(e,t,n,r){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;n.forEach(function(n){n.rawTargets.forEach(function(n){const i=Ht.Objects.Geometry[n.geoID];void 0!==i&&s.genMorphGeometry(e,t,i,r,n.name)})})}genMorphGeometry(e,t,n,r,s){const i=void 0!==t.Vertices?t.Vertices.a:[],o=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],a=void 0!==n.Vertices?n.Vertices.a:[],c=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,u=new Float32Array(l);for(let e=0;e<c.length;e++){const t=3*c[e];u[t]=a[3*e],u[t+1]=a[3*e+1],u[t+2]=a[3*e+2]}const h={vertexIndices:o,vertexPositions:u,baseVertexPositions:i},d=this.genBuffers(h),p=new T(d.vertex,3);p.name=s||n.attrName,p.applyMatrix4(r),e.morphAttributes.position.push(p)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let s=[];return"IndexToDirect"===n&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:s,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let s=[];return"IndexToDirect"===n&&(s=e.UVIndex.a),{dataSize:2,buffer:r,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a;let s=[];"IndexToDirect"===n&&(s=e.ColorIndex.a);for(let e=0,t=new d;e<r.length;e+=4)t.fromArray(r,e),p.colorSpaceToWorking(t,ge),t.toArray(r,e);return{dataSize:4,buffer:r,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,s=[];for(let e=0;e<r.length;++e)s.push(e);return{dataSize:1,buffer:r,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return new l;const n=t-1,r=e.KnotVector.a,s=[],i=e.Points.a;for(let e=0,t=i.length;e<t;e+=4)s.push((new Ne).fromArray(i,e));let o,a;if("Closed"===e.Form)s.push(s[0]);else if("Periodic"===e.Form){o=n,a=r.length-1-o;for(let e=0;e<n;++e)s.push(s[e])}const c=new Vt(n,r,s,o,a).getPoints(12*s.length);return(new l).setFromPoints(c)}}class Qt{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const r=t[n],s=this.addClip(r);e.push(s)}return e}parseClips(){if(void 0===Ht.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Ht.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const e={id:r.id,attr:r.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Ht.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(en),values:t[n].KeyValueFloat.a},s=jt.get(r.id);if(void 0!==s){const t=s.parents[0].ID,n=s.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=r:n.match(/Y/)?e.get(t).curves.y=r:n.match(/Z/)?e.get(t).curves.z=r:n.match(/DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=r)}}}parseAnimationLayers(e){const t=Ht.Objects.AnimationLayer,n=new Map;for(const r in t){const t=[],s=jt.get(parseInt(r));if(void 0!==s){s.children.forEach(function(n,r){if(e.has(n.ID)){const s=e.get(n.ID);if(void 0!==s.curves.x||void 0!==s.curves.y||void 0!==s.curves.z){if(void 0===t[r]){const e=jt.get(n.ID).parents.filter(function(e){return void 0!==e.relationship})[0].ID;if(void 0!==e){const n=Ht.Objects.Model[e.toString()];if(void 0===n)return;const s={modelName:n.attrName?de.sanitizeNodeName(n.attrName):"",ID:n.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Gt.traverse(function(e){e.ID===n.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))}),s.transform||(s.transform=new G),"PreRotation"in n&&(s.preRotation=n.PreRotation.value),"PostRotation"in n&&(s.postRotation=n.PostRotation.value),t[r]=s}}t[r]&&(t[r][s.attr]=s)}else if(void 0!==s.curves.morph){if(void 0===t[r]){const e=jt.get(n.ID).parents.filter(function(e){return void 0!==e.relationship})[0].ID,s=jt.get(e).parents[0].ID,i=jt.get(s).parents[0].ID,o=jt.get(i).parents[0].ID,a=Ht.Objects.Model[o],c={modelName:a.attrName?de.sanitizeNodeName(a.attrName):"",morphName:Ht.Objects.Deformer[e].attrName};t[r]=c}t[r][s.attr]=s}}}),n.set(parseInt(r),t)}}return n}parseAnimStacks(e){const t=Ht.Objects.AnimationStack,n={};for(const r in t){const s=jt.get(parseInt(r)).children;s.length;const i=e.get(s[0].ID);n[r]={name:t[r].attrName,layer:i}}return n}addClip(e){let t=[];const r=this;return e.layer.forEach(function(e){t=t.concat(r.generateTracks(e))}),new n(e.name,-1,t)}generateTracks(e){const t=[];let n=new Pe,r=new Pe;if(e.transform&&e.transform.decompose(n,new pe,r),n=n.toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==r&&t.push(r)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,r){const s=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(s,t,n);return new Ce(e+"."+r,s,i)}generateRotationTrack(e,t,n,r,s){let i,o;if(void 0!==t.x&&void 0!==t.y&&void 0!==t.z){const e=this.interpolateRotations(t.x,t.y,t.z,s);i=e[0],o=e[1]}const a=an(0);void 0!==n&&((n=n.map(H.degToRad)).push(a),n=(new v).fromArray(n),n=(new pe).setFromEuler(n)),void 0!==r&&((r=r.map(H.degToRad)).push(a),r=(new v).fromArray(r),r=(new pe).setFromEuler(r).invert());const c=new pe,l=new v,u=[];if(!o||!i)return new me(e+".quaternion",[0],[0]);for(let e=0;e<o.length;e+=3){if(l.set(o[e],o[e+1],o[e+2],s),c.setFromEuler(l),void 0!==n&&c.premultiply(n),void 0!==r&&c.multiply(r),e>2){(new pe).fromArray(u,(e-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w)}c.toArray(u,e/3*4)}return new me(e+".quaternion",i,u)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(e){return e/100}),r=Gt.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new se(e.modelName+".morphTargetInfluences["+r+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){const s=t[r];s!==n&&(t[e]=s,n=s,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const r=n,s=[];let i=-1,o=-1,a=-1;return e.forEach(function(e){if(t.x&&(i=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==i){const e=t.x.values[i];s.push(e),r[0]=e}else s.push(r[0]);if(-1!==o){const e=t.y.values[o];s.push(e),r[1]=e}else s.push(r[1]);if(-1!==a){const e=t.z.values[a];s.push(e),r[2]=e}else s.push(r[2])}),s}interpolateRotations(e,t,n,r){const s=[],i=[];s.push(e.times[0]),i.push(H.degToRad(e.values[0])),i.push(H.degToRad(t.values[0])),i.push(H.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){const a=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(a[0])||isNaN(a[1])||isNaN(a[2]))continue;const c=a.map(H.degToRad),l=[e.values[o],t.values[o],n.values[o]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;const u=l.map(H.degToRad),h=[l[0]-a[0],l[1]-a[1],l[2]-a[2]],d=[Math.abs(h[0]),Math.abs(h[1]),Math.abs(h[2])];if(d[0]>=180||d[1]>=180||d[2]>=180){const t=Math.max(...d)/180,n=new v(...c,r),a=new v(...u,r),l=(new pe).setFromEuler(n),h=(new pe).setFromEuler(a);l.dot(h)&&h.set(-h.x,-h.y,-h.z,-h.w);const p=e.times[o-1],m=e.times[o]-p,f=new pe,g=new v;for(let e=0;e<1;e+=1/t)f.copy(l.clone().slerp(h.clone(),e)),s.push(p+e*m),g.setFromQuaternion(f,r),i.push(g.x),i.push(g.y),i.push(g.z)}else s.push(e.times[o]),i.push(H.degToRad(e.values[o])),i.push(H.degToRad(t.values[o])),i.push(H.degToRad(n.values[o]))}return[s,i]}}class qt{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new Zt,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,r){const s=e.match(/^[\s\t]*;/),i=e.match(/^[\s\t]*$/);if(s||i)return;const o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),c=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,n[++r]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},i=this.parseNodeAttr(r),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,s):n in o?("PoseNode"===n?o.PoseNode.push(s):void 0!==o[n].id&&(o[n]={},o[n][o[n].id]=o[n]),""!==i.id&&(o[n][i.id]=s)):"number"==typeof i.id?(o[n]={},o[n][i.id]=s):"Properties70"!==n&&(o[n]="PoseNode"===n?[s]:s),"number"==typeof i.id&&(s.id=i.id),""!==i.name&&(s.attrName=i.name),""!==i.type&&(s.attrType=i.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===s&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if("Properties70"!==i.name){if("C"===r){const e=s.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let o=s.split(",").slice(3);o=o.map(function(e){return e.trim().replace(/^"/,"")}),r="connections",s=[t,n],function(e,t){for(let n=0,r=e.length,s=t.length;n<s;n++,r++)e[r]=t[n]}(s,o),void 0===i[r]&&(i[r]=[])}"Node"===r&&(i.id=s),r in i&&Array.isArray(i[r])?i[r].push(s):"a"!==r?i[r]=s:i.a=s,this.setCurrentProp(i,r),"a"===r&&","!==s.slice(-1)&&(i.a=cn(s))}else this.parseNodeSpecialProperty(e,r,s)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=cn(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=r[0],i=r[1],o=r[2],a=r[3];let c=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=cn(c)}this.getPrevNode()[s]={type:i,type2:o,flag:a,value:c},this.setCurrentProp(this.getPrevNode(),s)}}class Yt{parse(e){const t=new $t(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new Zt;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),o=e.getString(i);if(0===r)return null;const a=[];for(let t=0;t<s;t++)a.push(this.parseProperty(e));const c=a.length>0?a[0]:"",l=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(n.singleProperty=1===s&&e.getOffset()===r;r>e.getOffset();){const r=this.parseNode(e,t);null!==r&&this.parseSubNode(o,n,r)}return n.propertyList=a,"number"==typeof c&&(n.id=c),""!==l&&(n.attrName=l),""!==u&&(n.attrType=u),""!==o&&(n.name=o),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach(function(t,n){0!==n&&e.push(t)}),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach(function(e){t[e]=n[e]})}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],r=n.propertyList[1];const s=n.propertyList[2],i=n.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),o="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:s,flag:i,value:o}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),s=e.getUint32(),i=e.getUint32();if(0===s)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}const o=kt(new Uint8Array(e.getArrayBuffer(i))),a=new $t(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(r);case"d":return a.getFloat64Array(r);case"f":return a.getFloat32Array(r);case"i":return a.getInt32Array(r);case"l":return a.getInt64Array(r)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class $t{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return!(1&~this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}}class Zt{add(e,t){this[e]=t}}function Jt(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function en(e){return e/46186158e3}const tn=[];function nn(e,t,n,r){let s;switch(r.mappingType){case"ByPolygonVertex":s=e;break;case"ByPolygon":s=t;break;case"ByVertice":s=n;break;case"AllSame":s=r.indices[0]}"IndexToDirect"===r.referenceType&&(s=r.indices[s]);const i=s*r.dataSize,o=i+r.dataSize;return function(e,t,n,r){for(let s=n,i=0;s<r;s++,i++)e[i]=t[s];return e}(tn,r.buffer,i,o)}const rn=new v,sn=new Pe;function on(e){const t=new G,n=new G,r=new G,s=new G,i=new G,o=new G,a=new G,c=new G,l=new G,u=new G,h=new G,d=new G,p=e.inheritType?e.inheritType:0;e.translation&&t.setPosition(sn.fromArray(e.translation));const m=an(0);if(e.preRotation){const t=e.preRotation.map(H.degToRad);t.push(m),n.makeRotationFromEuler(rn.fromArray(t))}if(e.rotation){const t=e.rotation.map(H.degToRad);t.push(e.eulerOrder||m),r.makeRotationFromEuler(rn.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(H.degToRad);t.push(m),s.makeRotationFromEuler(rn.fromArray(t)),s.invert()}e.scale&&i.scale(sn.fromArray(e.scale)),e.scalingOffset&&a.setPosition(sn.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(sn.fromArray(e.scalingPivot)),e.rotationOffset&&c.setPosition(sn.fromArray(e.rotationOffset)),e.rotationPivot&&l.setPosition(sn.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(h.copy(e.parentMatrix),u.copy(e.parentMatrixWorld));const f=n.clone().multiply(r).multiply(s),g=new G;g.extractRotation(u);const y=new G;y.copyPosition(u);const v=y.clone().invert().multiply(u),x=g.clone().invert().multiply(v),T=i,w=new G;if(0===p)w.copy(g).multiply(f).multiply(x).multiply(T);else if(1===p)w.copy(g).multiply(x).multiply(f).multiply(T);else{const e=(new G).scale((new Pe).setFromMatrixScale(h)).clone().invert(),t=x.clone().multiply(e);w.copy(g).multiply(f).multiply(t).multiply(T)}const I=l.clone().invert(),b=o.clone().invert();let A=t.clone().multiply(c).multiply(l).multiply(n).multiply(r).multiply(s).multiply(I).multiply(a).multiply(o).multiply(i).multiply(b);const M=(new G).copyPosition(A),R=u.clone().multiply(M);return d.copyPosition(R),A=d.clone().multiply(w),A.premultiply(u.invert()),A}function an(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?t[0]:t[e]}function cn(e){return e.split(",").map(function(e){return parseFloat(e)})}function ln(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,n))}function un(e,t){if(t===_e)return e;if(t===Se||t===Ee){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,s=[];if(t===Se)for(let e=1;e<=r;e++)s.push(n.getX(0)),s.push(n.getX(e)),s.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(s.push(n.getX(e)),s.push(n.getX(e+1)),s.push(n.getX(e+2))):(s.push(n.getX(e+2)),s.push(n.getX(e+1)),s.push(n.getX(e)));s.length;const i=e.clone();return i.setIndex(s),i.clearGroups(),i}return e}function hn(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const dn={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 pn{constructor(e){this.parser=e,this.name=dn.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const s=t.json,i=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let o;const a=new d(16777215);void 0!==i.color&&a.setRGB(i.color[0],i.color[1],i.color[2],U);const c=void 0!==i.range?i.range:0;switch(i.type){case"directional":o=new f(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new ce(a),o.distance=c;break;case"spot":o=new be(a),o.distance=c,i.spot=i.spot||{},i.spot.innerConeAngle=void 0!==i.spot.innerConeAngle?i.spot.innerConeAngle:0,i.spot.outerConeAngle=void 0!==i.spot.outerConeAngle?i.spot.outerConeAngle:Math.PI/4,o.angle=i.spot.outerConeAngle,o.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return o.position.set(0,0,0),er(o,i),void 0!==i.intensity&&(o.intensity=i.intensity),o.name=t.createUniqueName(i.name||"light_"+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],s=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===s?null:this._loadLight(s).then(function(e){return n._getNodeRef(t.cache,s,e)})}}class mn{constructor(){this.name=dn.KHR_MATERIALS_UNLIT}getMaterialType(){return W}extendParams(e,t,n){const r=[];e.color=new d(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],U),e.opacity=t[3]}void 0!==s.baseColorTexture&&r.push(n.assignTexture(e,"map",s.baseColorTexture,ge))}return Promise.all(r)}}class fn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class gn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&s.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(s.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Oe(e,e)}return Promise.all(s)}}class yn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.dispersion=void 0!==r.dispersion?r.dispersion:0,Promise.resolve()}}class vn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&s.push(n.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&&s.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}}class xn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new d(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=r.extensions[this.name];if(void 0!==i.sheenColorFactor){const e=i.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],U)}return void 0!==i.sheenRoughnessFactor&&(t.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&s.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,ge)),void 0!==i.sheenRoughnessTexture&&s.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class Tn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&s.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}}class wn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&s.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const o=i.attenuationColor||[1,1,1];return t.attenuationColor=(new d).setRGB(o[0],o[1],o[2],U),Promise.all(s)}}class In{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class bn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&s.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const o=i.specularColorFactor||[1,1,1];return t.specularColor=(new d).setRGB(o[0],o[1],o[2],U),void 0!==i.specularColorTexture&&s.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,ge)),Promise.all(s)}}class An{constructor(e){this.parser=e,this.name=dn.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&s.push(n.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}}class Mn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&s.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}}class Rn{constructor(e){this.parser=e,this.name=dn.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const s=r.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,i)}}class Sn{constructor(e){this.parser=e,this.name=dn.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],o=r.images[i.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return n.loadTextureImage(e,i.source,a)}}class En{constructor(e){this.parser=e,this.name=dn.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],o=r.images[i.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return n.loadTextureImage(e,i.source,a)}}class _n{constructor(e){this.name=dn.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(t){const n=e.byteOffset||0,r=e.byteLength||0,i=e.count,o=e.byteStride,a=new Uint8Array(t,n,r);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(i,o,a,e.mode,e.filter).then(function(e){return e.buffer}):s.ready.then(function(){const t=new ArrayBuffer(i*o);return s.decodeGltfBuffer(new Uint8Array(t),i,o,a,e.mode,e.filter),t})})}return null}}class Ln{constructor(e){this.name=dn.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=t.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==Vn.TRIANGLES&&e.mode!==Vn.TRIANGLE_STRIP&&e.mode!==Vn.TRIANGLE_FAN&&void 0!==e.mode)return null;const s=n.extensions[this.name].attributes,i=[],o={};for(const e in s)i.push(this.parser.getDependency("accessor",s[e]).then(t=>(o[e]=t,o[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,s=[];for(const e of n){const t=new G,n=new Pe,i=new pe,a=new Pe(1,1,1),c=new M(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&i.fromBufferAttribute(o.ROTATION,e),o.SCALE&&a.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,i,a));for(const t in o)if("_COLOR_0"===t){const e=o[t];c.instanceColor=new A(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);ie.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),s.push(c)}return t.isGroup?(t.clear(),t.add(...s),t):s[0]}))}}const On="glTF",Pn=1313821514,Nn=5130562;class Cn{constructor(e){this.name=dn.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==On)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,s=new DataView(e,12);let i=0;for(;i<r;){const t=s.getUint32(i,!0);i+=4;const r=s.getUint32(i,!0);if(i+=4,r===Pn){const r=new Uint8Array(e,12+i,t);this.content=n.decode(r)}else if(r===Nn){const n=12+i;this.body=e.slice(n,n+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class kn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=dn.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},a={},c={};for(const e in i){const t=Wn[e]||e.toLowerCase();o[t]=i[e]}for(const t in e.attributes){const r=Wn[t]||t.toLowerCase();if(void 0!==i[t]){const s=n.accessors[e.attributes[t]],i=Hn[s.componentType];c[r]=i.name,a[r]=!0===s.normalized}}return t.getDependency("bufferView",s).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(const t in e.attributes){const n=e.attributes[t],r=a[t];void 0!==r&&(n.normalized=r)}t(e)},o,c,U,n)})})}}class Dn{constructor(){this.name=dn.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):e}}class Fn{constructor(){this.name=dn.KHR_MESH_QUANTIZATION}}class Un extends E{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[s+e];return t}interpolate_(e,t,n,r){const s=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,l=r-t,u=(n-t)/l,h=u*u,d=h*u,p=e*c,m=p-c,f=-2*d+3*h,g=d-h,y=1-f,v=g-h+u;for(let e=0;e!==o;e++){const t=i[m+e+o],n=i[m+e+a]*l,r=i[p+e+o],c=i[p+e]*l;s[e]=y*t+v*n+f*r+g*c}return s}}const zn=new pe;class Bn extends Un{interpolate_(e,t,n,r){const s=super.interpolate_(e,t,n,r);return zn.fromArray(s).normalize().toArray(s),s}}const Vn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Hn={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},jn={9728:J,9729:k,9984:te,9985:F,9986:ee,9987:D},Gn={33071:h,33648:$,10497:fe},Kn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wn={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Qn={CUBICSPLINE:void 0,LINEAR:L,STEP:_},qn="OPAQUE",Yn="MASK",$n="BLEND";function Zn(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new Y({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:w})),e.DefaultMaterial}function Jn(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function er(e,t){void 0!==t.extras&&"object"==typeof t.extras&&Object.assign(e.userData,t.extras)}function tr(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}}}function nr(e){let t;const n=e.extensions&&e.extensions[dn.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+rr(n.attributes):e.indices+":"+rr(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,r=e.targets.length;n<r;n++)t+=":"+rr(e.targets[n]);return t}function rr(e){let t="";const n=Object.keys(e).sort();for(let r=0,s=n.length;r<s;r++)t+=n[r]+":"+e[n[r]]+";";return t}function sr(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const ir=new G;class or{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hn,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 n=!1,r=-1,s=!1,i=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,s=e.indexOf("Firefox")>-1,i=s?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&r<17||s&&i<98?this.textureLoader=new Re(this.options.manager):this.textureLoader=new b(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new x(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,s=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){const i={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return Jn(s,i,r),er(i,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(i)})).then(function(){for(const e of i.scenes)e.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),s=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())s(r,t.children[n])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const s=e(t[r]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[dn.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(e,s){n.load(B.resolveURL(t.uri,r.path),e,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=Kn[r.type],t=Hn[r.componentType],n=!0===r.normalized,s=new t(r.count*e);return Promise.resolve(new c(s,e,n))}const s=[];return void 0!==r.bufferView?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),void 0!==r.sparse&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(e){const s=e[0],i=Kn[r.type],o=Hn[r.componentType],a=o.BYTES_PER_ELEMENT,l=a*i,u=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let p,m;if(h&&h!==l){const e=Math.floor(u/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let c=t.cache.get(n);c||(p=new o(s,e*h,r.count*h/a),c=new R(p,h/a),t.cache.add(n,c)),m=new S(c,i,u%h/a,d)}else p=null===s?new o(r.count*i):new o(s,u,r.count*i),m=new c(p,i,d);if(void 0!==r.sparse){const t=Kn.SCALAR,n=Hn[r.sparse.indices.componentType],a=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,u=new n(e[1],a,r.sparse.count*t),h=new o(e[2],l,r.sparse.count*i);null!==s&&(m=new c(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let e=0,t=u.length;e<t;e++){const t=u[e];if(m.setX(t,h[e*i]),i>=2&&m.setY(t,h[e*i+1]),i>=3&&m.setZ(t,h[e*i+2]),i>=4&&m.setW(t,h[e*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=d}return m})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r];let i=this.textureLoader;if(s.uri){const e=n.manager.getHandler(s.uri);null!==e&&(i=e)}return this.loadTextureImage(e,r,i)}loadTextureImage(e,t,n){const r=this,s=this.json,i=s.textures[e],o=s.images[t],a=(o.uri||o.bufferView)+":"+i.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=i.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);const n=(s.samplers||{})[i.sampler]||{};return t.magFilter=jn[n.magFilter]||k,t.minFilter=jn[n.minFilter]||D,t.wrapS=Gn[n.wrapS]||fe,t.wrapT=Gn[n.wrapT]||fe,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==J&&t.minFilter!==k,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const n=this,r=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const i=r.images[e],o=self.URL||self.webkitURL;let a=i.uri||"",c=!1;if(void 0!==i.bufferView)a=n.getDependency("bufferView",i.bufferView).then(function(e){c=!0;const t=new Blob([e],{type:i.mimeType});return a=o.createObjectURL(t),a});else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then(function(e){return new Promise(function(n,r){let i=n;!0===t.isImageBitmapLoader&&(i=function(e){const t=new Me(e);t.needsUpdate=!0,n(t)}),t.load(B.resolveURL(e,s.path),i,void 0,r)})}).then(function(e){var t;return!0===c&&o.revokeObjectURL(a),er(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":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){const s=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((i=i.clone()).channel=n.texCoord),s.extensions[dn.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[dn.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=s.associations.get(i);i=s.extensions[dn.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),s.associations.set(i,t)}}return void 0!==r&&(i.colorSpace=r),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,i=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ue,V.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new P,V.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||s||i){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),i&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),i&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Y}loadMaterial(e){const t=this,n=this.json,r=this.extensions,s=n.materials[e];let i;const o={},a=[];if((s.extensions||{})[dn.KHR_MATERIALS_UNLIT]){const e=r[dn.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),a.push(e.extendParams(o,s,t))}else{const n=s.pbrMetallicRoughness||{};if(o.color=new d(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],U),o.opacity=e[3]}void 0!==n.baseColorTexture&&a.push(t.assignTexture(o,"map",n.baseColorTexture,ge)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(a.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),a.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),i=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),a.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}!0===s.doubleSided&&(o.side=g);const c=s.alphaMode||qn;if(c===$n?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===Yn&&(o.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&i!==W&&(a.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new Oe(1,1),void 0!==s.normalTexture.scale)){const e=s.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==s.occlusionTexture&&i!==W&&(a.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(o.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&i!==W){const e=s.emissiveFactor;o.emissive=(new d).setRGB(e[0],e[1],e[2],U)}return void 0!==s.emissiveTexture&&i!==W&&a.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,ge)),Promise.all(a).then(function(){const n=new i(o);return s.name&&(n.name=s.name),er(n,s),t.associations.set(n,{materials:e}),s.extensions&&Jn(r,n,s),n})}createUniqueName(e){const t=de.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function s(e){return n[dn.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return ar(n,e,t)})}const i=[];for(let n=0,o=e.length;n<o;n++){const o=e[n],a=nr(o),c=r[a];if(c)i.push(c.promise);else{let e;e=o.extensions&&o.extensions[dn.KHR_DRACO_MESH_COMPRESSION]?s(o):ar(new l,o,t),r[a]={primitive:o,promise:e},i.push(e)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,r=this.extensions,s=n.meshes[e],i=s.primitives,o=[];for(let e=0,t=i.length;e<t;e++){const t=void 0===i[e].material?Zn(this.cache):this.getDependency("material",i[e].material);o.push(t)}return o.push(t.loadGeometries(i)),Promise.all(o).then(function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],c=[];for(let n=0,l=a.length;n<l;n++){const l=a[n],u=i[n];let h;const d=o[n];if(u.mode===Vn.TRIANGLES||u.mode===Vn.TRIANGLE_STRIP||u.mode===Vn.TRIANGLE_FAN||void 0===u.mode)h=!0===s.isSkinnedMesh?new Te(l,d):new K(l,d),!0===h.isSkinnedMesh&&h.normalizeSkinWeights(),u.mode===Vn.TRIANGLE_STRIP?h.geometry=un(h.geometry,Ee):u.mode===Vn.TRIANGLE_FAN&&(h.geometry=un(h.geometry,Se));else if(u.mode===Vn.LINES)h=new C(l,d);else if(u.mode===Vn.LINE_STRIP)h=new O(l,d);else if(u.mode===Vn.LINE_LOOP)h=new N(l,d);else{if(u.mode!==Vn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new le(l,d)}Object.keys(h.geometry.morphAttributes).length>0&&tr(h,s),h.name=t.createUniqueName(s.name||"mesh_"+e),er(h,s),u.extensions&&Jn(r,h,u),t.assignFinalMaterial(h),c.push(h)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(1===c.length)return s.extensions&&Jn(r,c[0],s),c[0];const l=new I;s.extensions&&Jn(r,l,s),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new ae(H.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new oe(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),er(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(e){const t=e.pop(),n=e,r=[],s=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];if(i){r.push(i);const n=new G;null!==t&&n.fromArray(t.array,16*e),s.push(n)}}return new xe(r,s)})}loadAnimation(e){const t=this.json,r=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,o=[],a=[],c=[],l=[],u=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],n=s.samplers[t.sampler],r=t.target,i=r.node,h=void 0!==s.parameters?s.parameters[n.input]:n.input,d=void 0!==s.parameters?s.parameters[n.output]:n.output;void 0!==r.node&&(o.push(this.getDependency("node",i)),a.push(this.getDependency("accessor",h)),c.push(this.getDependency("accessor",d)),l.push(n),u.push(r))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(e){const t=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=[];for(let e=0,n=t.length;e<n;e++){const n=t[e],s=o[e],i=a[e],h=c[e],d=l[e];if(void 0===n)continue;n.updateMatrix&&n.updateMatrix();const p=r._createAnimationTracks(n,s,i,h,d);if(p)for(let e=0;e<p.length;e++)u.push(p[e])}const h=new n(i,void 0,u);return er(h,s),h})}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then(function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){const t=this,n=this.json.nodes[e],r=t._loadNodeShallow(e),s=[],i=n.children||[];for(let e=0,n=i.length;e<n;e++)s.push(t.getDependency("node",i[e]));const o=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([r,Promise.all(s),o]).then(function(e){const t=e[0],n=e[1],r=e[2];null!==r&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,ir)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);return t})}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const s=t.nodes[e],i=s.name?r.createUniqueName(s.name):"",a=[],c=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return c&&a.push(c),void 0!==s.camera&&a.push(r.getDependency("camera",s.camera).then(function(e){return r._getNodeRef(r.cameraCache,s.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){a.push(e)}),this.nodeCache[e]=Promise.all(a).then(function(t){let a;if(a=!0===s.isBone?new o:t.length>1?new I:1===t.length?t[0]:new ie,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(s.name&&(a.userData.name=s.name,a.name=i),er(a,s),s.extensions&&Jn(n,a,s),void 0!==s.matrix){const e=new G;e.fromArray(s.matrix),a.applyMatrix4(e)}else void 0!==s.translation&&a.position.fromArray(s.translation),void 0!==s.rotation&&a.quaternion.fromArray(s.rotation),void 0!==s.scale&&a.scale.fromArray(s.scale);if(r.associations.has(a)){if(void 0!==s.mesh&&r.meshCache.refs[s.mesh]>1){const e=r.associations.get(a);r.associations.set(a,{...e})}}else r.associations.set(a,{});return r.associations.get(a).nodes=e,a}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,s=new I;n.name&&(s.name=r.createUniqueName(n.name)),er(s,n),n.extensions&&Jn(t,s,n);const i=n.nodes||[],o=[];for(let e=0,t=i.length;e<t;e++)o.push(r.getDependency("node",i[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++)s.add(e[t]);return r.associations=(e=>{const t=new Map;for(const[e,n]of r.associations)(e instanceof V||e instanceof Me)&&t.set(e,n);return e.traverse(e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(s),s})}_createAnimationTracks(e,t,n,r,s){const i=[],o=e.name?e.name:e.uuid,a=[];let c;switch(Xn[s.path]===Xn.weights?e.traverse(function(e){e.morphTargetInfluences&&a.push(e.name?e.name:e.uuid)}):a.push(o),Xn[s.path]){case Xn.weights:c=se;break;case Xn.rotation:c=me;break;case Xn.translation:case Xn.scale:c=Ce;break;default:if(1===n.itemSize)c=se;else c=Ce}const l=void 0!==r.interpolation?Qn[r.interpolation]:L,u=this._getArrayFromAccessor(n);for(let e=0,n=a.length;e<n;e++){const n=new c(a[e]+"."+Xn[s.path],t.array,u,l);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(n),i.push(n)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=sr(t.constructor),n=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof me?Bn:Un)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ar(e,t,n){const r=t.attributes,s=[];function i(t,r){return n.getDependency("accessor",t).then(function(t){e.setAttribute(r,t)})}for(const t in r){const n=Wn[t]||t.toLowerCase();n in e.attributes||s.push(i(r[t],n))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});s.push(r)}return p.workingColorSpace,er(e,t),function(e,t,n){const r=t.attributes,s=new a;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,i=e.max;if(void 0===t||void 0===i)return;if(s.set(new Pe(t[0],t[1],t[2]),new Pe(i[0],i[1],i[2])),e.normalized){const t=sr(Hn[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}const i=t.targets;if(void 0!==i){const e=new Pe,t=new Pe;for(let r=0,s=i.length;r<s;r++){const s=i[r];if(void 0!==s.POSITION){const r=n.json.accessors[s.POSITION],i=r.min,o=r.max;if(void 0!==i&&void 0!==o){if(t.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),r.normalized){const e=sr(Hn[r.componentType]);t.multiplyScalar(e)}e.max(t)}}}s.expandByVector(e)}e.boundingBox=s;const o=new we;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(s).then(function(){return void 0!==t.targets?function(e,t,n){let r=!1,s=!1,i=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(s=!0),void 0!==n.COLOR_0&&(i=!0),r&&s&&i)break}if(!r&&!s&&!i)return Promise.resolve(e);const o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){const u=t[l];if(r){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(s){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(t){const n=t[0],o=t[1],a=t[2];return r&&(e.morphAttributes.position=n),s&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(e,t.targets,n):e})}new class extends z{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new gn(e)}),this.register(function(e){return new yn(e)}),this.register(function(e){return new Rn(e)}),this.register(function(e){return new Sn(e)}),this.register(function(e){return new En(e)}),this.register(function(e){return new xn(e)}),this.register(function(e){return new Tn(e)}),this.register(function(e){return new wn(e)}),this.register(function(e){return new In(e)}),this.register(function(e){return new fn(e)}),this.register(function(e){return new bn(e)}),this.register(function(e){return new vn(e)}),this.register(function(e){return new Mn(e)}),this.register(function(e){return new An(e)}),this.register(function(e){return new pn(e)}),this.register(function(e){return new _n(e)}),this.register(function(e){return new Ln(e)})}load(e,t,n,r){const s=this;let i;if(""!==this.resourcePath)i=this.resourcePath;else if(""!==this.path){const t=B.extractUrlBase(e);i=B.resolveURL(t,this.path)}else i=B.extractUrlBase(e);this.manager.itemStart(e);const o=function(t){r&&r(t),s.manager.itemError(e),s.manager.itemEnd(e)},a=new x(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{s.parse(n,i,function(n){t(n),s.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let s;const i={},o={},a=new TextDecoder;if("string"==typeof e)s=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===On){try{i[dn.KHR_BINARY_GLTF]=new Cn(e)}catch(e){return void(r&&r(e))}s=JSON.parse(i[dn.KHR_BINARY_GLTF].content)}else s=JSON.parse(a.decode(e))}else s=e;if(void 0===s.asset||s.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new or(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](c);t.name,o[t.name]=t,i[t.name]=!0}if(s.extensionsUsed)for(let e=0;e<s.extensionsUsed.length;++e){const t=s.extensionsUsed[e],n=s.extensionsRequired||[];switch(t){case dn.KHR_MATERIALS_UNLIT:i[t]=new mn;break;case dn.KHR_DRACO_MESH_COMPRESSION:i[t]=new kn(s,this.dracoLoader);break;case dn.KHR_TEXTURE_TRANSFORM:i[t]=new Dn;break;case dn.KHR_MESH_QUANTIZATION:i[t]=new Fn;break;default:n.indexOf(t)>=0&&o[t]}}c.setExtensions(i),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}},Array.from({length:3},()=>({loader:new Kt,isUsed:!1}));Array.from({length:3},()=>({loader:new Re,isUsed:!1}));Array.from({length:3},()=>({loader:new i,isUsed:!1}));const cr=new Pe,lr=new pe,ur=new Pe,hr=new Pe,dr=new pe,pr=new Pe;class mr extends ie{constructor(){super()}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null!==this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(hr,dr,pr),this.matrix.decompose(cr,lr,ur),this.matrixWorld.compose(hr,lr,pr)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let t=0,n=this.children.length;t<n;t++)this.children[t].updateMatrixWorld(e)}}var fr=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];class gr{constructor(e){const t=[new Pe(1,1,0),new Pe(-1,1,0),new Pe(1,-1,0),new Pe(-1,-1,0),new Pe(1,0,1),new Pe(-1,0,1),new Pe(1,0,-1),new Pe(-1,0,-1),new Pe(0,1,1),new Pe(0,-1,1),new Pe(0,1,-1),new Pe(0,-1,-1)];var n=new Array(512),r=new Array(512);e||(e=1),e*=65536,(e=Math.floor(e))<256&&(e|=e<<8);for(var s=0;s<256;s++){var i;i=1&s?fr[s]^255&e:fr[s]^e>>8&255,n[s]=n[s+256]=i,r[s]=r[s+256]=t[i%12]}this._seed=e,this._offsetMatrix=[new Pe(0,0,0),new Pe(0,0,1),new Pe(0,1,0),new Pe(0,1,1),new Pe(1,0,0),new Pe(1,0,1),new Pe(1,1,0),new Pe(1,1,1)],this.shaderChunk={defines:"",header:'#define GLSLIFY 1\n// From https://github.com/hughsk/glsl-noise/blob/master/periodic/2d.glsl\n\n//\n// GLSL textureless classic 2D noise "cnoise",\n// with an RSL-style periodic variant "pnoise".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\n\nvec4 permute(vec4 x) { return mod289(((x * 34.0) + 1.0) * x); }\n\nvec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }\n\nvec2 fade(vec2 t) { return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); }\n\nfloat map(float value, float min1, float max1, float min2, float max2) {\n return min2 + (value - min1) * (max2 - min2) / (max1 - min1);\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin(vec2 P) {\n\n vec2 rep = vec2(255.0, 255.0);\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod(Pi, rep.xyxy); // To create noise with explicit period\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n vec4 gy = abs(gx) - 0.5;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x, gy.x);\n vec2 g10 = vec2(gx.y, gy.y);\n vec2 g01 = vec2(gx.z, gy.z);\n vec2 g11 = vec2(gx.w, gy.w);\n\n vec4 norm = taylorInvSqrt(\n vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return map(2.3 * n_xy, -1.0, 1.0, 0.0, 1.0);\n}\n\nfloat fbm(vec2 pos, vec4 props) {\n float persistance = props.x;\n float lacunarity = props.y;\n float redistribution = props.z;\n int octaves = int(props.w);\n\n float result = 0.0;\n float amplitude = 1.0;\n float frequency = 1.0;\n float maximum = amplitude;\n\n for (int i = 0; i < 2; i++) {\n\n vec2 p = pos.xy * frequency;\n\n float noiseVal = perlin(p);\n result += noiseVal * amplitude;\n\n frequency *= lacunarity;\n amplitude *= persistance;\n maximum += amplitude;\n }\n\n float redistributed = pow(result, redistribution);\n return redistributed / maximum;\n}\n',main:"",uniforms:[{three_noise_seed:this._seed}]},this.perm=n,this.gradP=r}_fade(e){return e*e*e*(e*(6*e-15)+10)}_lerp(e,t,n){return(1-n)*e+n*t}_gradient(e){return e instanceof Pe?e.x+this.perm[e.y+this.perm[e.z]]:e.x+this.perm[e.y]}static map(e,t,n,r,s){return(e-t)*(s-r)/(n-t)+r}get2(e){void 0!==e.z&&(e=new Oe(e.x,e.y));const t=new Oe(Math.floor(e.x),Math.floor(e.y));e.sub(t),t.x&=255,t.y&=255;const n=[];for(let r=0;r<4;r++){const s=this._offsetMatrix[2*r],i=new Oe(s.x,s.y),o=this.gradP[this._gradient((new Oe).addVectors(t,i))],a=new Oe(o.x,o.y),c=(new Oe).subVectors(e,i);n.push(a.dot(c))}const r=this._fade(e.x),s=this._fade(e.y);return this._lerp(this._lerp(n[0],n[2],r),this._lerp(n[1],n[3],r),s)}get3(e){if(void 0===e.z)throw"Input to Perlin::get3() must be of type THREE.Vector3";const t=new Pe(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z));e.sub(t),t.x&=255,t.y&=255,t.z&=255;const n=[];for(let r=0;r<8;r++){const s=this._offsetMatrix[r],i=this.gradP[this._gradient((new Pe).addVectors(t,s))],o=(new Pe).subVectors(e,s);n.push(i.dot(o))}const r=this._fade(e.x),s=this._fade(e.y),i=this._fade(e.z);return this._lerp(this._lerp(this._lerp(n[0],n[4],r),this._lerp(n[1],n[5],r),i),this._lerp(this._lerp(n[2],n[6],r),this._lerp(n[3],n[7],r),i),s)}}class yr{constructor(e){const{seed:t,scale:n,persistance:r,lacunarity:s,octaves:i,redistribution:o}=e;this._noise=new gr(t),this._scale=n||1,this._persistance=r||.5,this._lacunarity=s||2,this._octaves=i||6,this._redistribution=o||1}get2(e){let t=0,n=1,r=1,s=n,i=this._noise.get2.bind(this._noise);for(let o=0;o<this._octaves;o++){t+=i(new Oe(e.x*this._scale*r,e.y*this._scale*r))*n,r*=this._lacunarity,n*=this._persistance,s+=n}return Math.pow(t,this._redistribution)/s}get3(e){let t=0,n=1,r=1,s=n,i=this._noise.get3.bind(this._noise);for(let o=0;o<this._octaves;o++){t+=i(new Pe(e.x*this._scale*r,e.y*this._scale*r,e.z*this._scale*r))*n,r*=this._lacunarity,n*=this._persistance,s+=n}return Math.pow(t,this._redistribution)/s}}let vr=0,xr=[];const Tr={"THREE.NoBlending":ne,"THREE.NormalBlending":re,"THREE.AdditiveBlending":e,"THREE.SubtractiveBlending":Ae,"THREE.MultiplyBlending":Z},wr=()=>JSON.parse(JSON.stringify(Ir)),Ir={transform:{position:new Pe,rotation:new Pe,scale:new Pe(1,1,1)},duration:5,looping:!0,startDelay:0,startLifetime:5,startSpeed:1,startSize:1,startOpacity:1,startRotation:0,startColor:{min:{r:1,g:1,b:1},max:{r:1,g:1,b:1}},gravity:0,simulationSpace:"LOCAL",maxParticles:100,emission:{rateOverTime:10,rateOverDistance:0},shape:{shape:"SPHERE",sphere:{radius:1,radiusThickness:1,arc:360},cone:{angle:25,radius:1,radiusThickness:1,arc:360},circle:{radius:1,radiusThickness:1,arc:360},rectangle:{rotation:{x:0,y:0},scale:{x:1,y:1}},box:{scale:{x:1,y:1,z:1},emitFrom:"VOLUME"}},map:void 0,renderer:{blending:re,discardBackgroundColor:!1,backgroundColorTolerance:1,backgroundColor:{r:1,g:1,b:1},transparent:!0,depthTest:!0,depthWrite:!1},velocityOverLifetime:{isActive:!1,linear:{x:0,y:0,z:0},orbital:{x:0,y:0,z:0}},sizeOverLifetime:{isActive:!1,lifetimeCurve:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:0,percentage:0},{x:1,y:1,percentage:1}]}},opacityOverLifetime:{isActive:!1,lifetimeCurve:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:0,percentage:0},{x:1,y:1,percentage:1}]}},rotationOverLifetime:{isActive:!1,min:0,max:0},noise:{isActive:!1,useRandomOffset:!1,strength:1,frequency:.5,octaves:1,positionAmount:1,rotationAmount:0,sizeAmount:0},textureSheetAnimation:{tiles:new Oe(1,1),timeMode:"LIFETIME",fps:30,startFrame:0}},br=(e,{shape:t,sphere:n,cone:r,circle:s,rectangle:i,box:o},a,c,l)=>{const u=et(e.particleSystemId,a,e.normalizedLifetimePercentage);switch(t){case"SPHERE":We(c,e.wrapperQuaternion,l,u,n);break;case"CONE":Xe(c,e.wrapperQuaternion,l,u,r);break;case"CIRCLE":qe(c,e.wrapperQuaternion,l,u,s);break;case"RECTANGLE":Ye(c,e.wrapperQuaternion,l,u,i);break;case"BOX":Qe(c,e.wrapperQuaternion,l,u,o)}},Ar=(e=Ir,t)=>{const n=t||Date.now(),r={particleSystemId:vr++,normalizedLifetimePercentage:0,distanceFromLastEmitByDistance:0,lastWorldPosition:new Pe(-99999),currentWorldPosition:new Pe(-99999),worldPositionChange:new Pe,worldQuaternion:new pe,wrapperQuaternion:new pe,lastWorldQuaternion:new pe(-99999),worldEuler:new v,gravityVelocity:new Pe(0,0,0),startValues:{},linearVelocityData:void 0,orbitalVelocityData:void 0,lifetimeValues:{},creationTimes:[],noise:{isActive:!1,strength:0,positionAmount:0,rotationAmount:0,sizeAmount:0},isEnabled:!0},s=st(Ir,e,{applyToFirstObject:!1,skippedProperties:[]});let i=s.map||$e();const{transform:o,duration:a,looping:u,startDelay:h,startLifetime:d,startSpeed:p,startSize:m,startRotation:f,startColor:g,startOpacity:y,gravity:x,simulationSpace:T,maxParticles:w,emission:I,shape:b,renderer:A,noise:M,velocityOverLifetime:R,onUpdate:S,onComplete:E,textureSheetAnimation:_}=s;"string"==typeof A?.blending&&(A.blending=Tr[A.blending]);const L=Array.from({length:w},()=>new Pe),O=Array.from({length:w},()=>new Pe);r.creationTimes=Array.from({length:w},()=>0),R.isActive&&(r.linearVelocityData=Array.from({length:w},()=>({speed:new Pe(R.linear.x?et(r.particleSystemId,R.linear.x,0):0,R.linear.y?et(r.particleSystemId,R.linear.y,0):0,R.linear.z?et(r.particleSystemId,R.linear.z,0):0),valueModifiers:{x:Ze(R.linear.x||0)?Je(r.particleSystemId,R.linear.x):void 0,y:Ze(R.linear.y||0)?Je(r.particleSystemId,R.linear.y):void 0,z:Ze(R.linear.z||0)?Je(r.particleSystemId,R.linear.z):void 0}})),r.orbitalVelocityData=Array.from({length:w},()=>({speed:new Pe(R.orbital.x?et(r.particleSystemId,R.orbital.x,0):0,R.orbital.y?et(r.particleSystemId,R.orbital.y,0):0,R.orbital.z?et(r.particleSystemId,R.orbital.z,0):0),valueModifiers:{x:Ze(R.orbital.x||0)?Je(r.particleSystemId,R.orbital.x):void 0,y:Ze(R.orbital.y||0)?Je(r.particleSystemId,R.orbital.y):void 0,z:Ze(R.orbital.z||0)?Je(r.particleSystemId,R.orbital.z):void 0},positionOffset:new Pe})));["startSize","startOpacity"].forEach(e=>{r.startValues[e]=Array.from({length:w},()=>et(r.particleSystemId,s[e],0))});["rotationOverLifetime"].forEach(e=>{const t=s[e];t.isActive&&(r.lifetimeValues[e]=Array.from({length:w},()=>H.randFloat(t.min,t.max)))}),r.noise={isActive:M.isActive,strength:M.strength,positionAmount:M.positionAmount,rotationAmount:M.rotationAmount,sizeAmount:M.sizeAmount,sampler:M.isActive?new yr({seed:Math.random(),scale:M.frequency,octaves:M.octaves}):void 0,offsets:M.useRandomOffset?Array.from({length:w},()=>100*Math.random()):void 0};const P=new ye({uniforms:{elapsed:{value:0},map:{value:i},tiles:{value:_.tiles},fps:{value:_.fps},useFPSForFrameIndex:{value:"FPS"===_.timeMode},backgroundColor:{value:A.backgroundColor},discardBackgroundColor:{value:A.discardBackgroundColor},backgroundColorTolerance:{value:A.backgroundColorTolerance}},vertexShader:"\n attribute float size;\n attribute float colorR;\n attribute float colorG;\n attribute float colorB;\n attribute float colorA;\n attribute float lifetime;\n attribute float startLifetime;\n attribute float rotation;\n attribute float startFrame;\n\n varying mat4 vPosition;\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main()\n {\n vColor = vec4(colorR, colorG, colorB, colorA);\n vLifetime = lifetime;\n vStartLifetime = startLifetime;\n vRotation = rotation;\n vStartFrame = startFrame;\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_PointSize = size * (100.0 / length(mvPosition.xyz));\n gl_Position = projectionMatrix * mvPosition;\n\n #include <logdepthbuf_vertex>\n }\n",fragmentShader:"\n uniform sampler2D map;\n uniform float elapsed;\n uniform float fps;\n uniform bool useFPSForFrameIndex;\n uniform vec2 tiles;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n void main()\n {\n gl_FragColor = vColor;\n float mid = 0.5;\n\n float frameIndex = round(vStartFrame) + (\n useFPSForFrameIndex == true\n ? fps == 0.0\n ? 0.0\n : max((vLifetime / 1000.0) * fps, 0.0)\n : max(min(floor(min(vLifetime / vStartLifetime, 1.0) * (tiles.x * tiles.y)), tiles.x * tiles.y - 1.0), 0.0)\n );\n \n float spriteXIndex = floor(mod(frameIndex, tiles.x));\n float spriteYIndex = floor(mod(frameIndex / tiles.x, tiles.y));\n\n vec2 frameUV = vec2(\n gl_PointCoord.x / tiles.x + spriteXIndex / tiles.x,\n gl_PointCoord.y / tiles.y + spriteYIndex / tiles.y);\n\n vec2 center = vec2(0.5, 0.5);\n vec2 centeredPoint = gl_PointCoord - center;\n\n mat2 rotation = mat2(\n cos(vRotation), sin(vRotation),\n -sin(vRotation), cos(vRotation)\n );\n\n centeredPoint = rotation * centeredPoint;\n vec2 centeredMiddlePoint = vec2(\n centeredPoint.x + center.x,\n centeredPoint.y + center.y\n );\n\n float dist = distance(centeredMiddlePoint, center);\n if (dist > 0.5) discard;\n\n vec2 uvPoint = vec2(\n centeredMiddlePoint.x / tiles.x + spriteXIndex / tiles.x,\n centeredMiddlePoint.y / tiles.y + spriteYIndex / tiles.y\n );\n\n vec4 rotatedTexture = texture2D(map, uvPoint);\n\n gl_FragColor = gl_FragColor * rotatedTexture;\n\n if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n \n #include <logdepthbuf_fragment>\n }\n",transparent:A.transparent,blending:A.blending,depthTest:A.depthTest,depthWrite:A.depthWrite}),N=new l;for(let e=0;e<w;e++)br(r,b,p,L[e],O[e]);N.setFromPoints(Array.from({length:w},(e,t)=>L[t].clone()));const C=(e,t)=>{(({geometry:e,propertyName:t,maxParticles:n,factory:r})=>{e.setAttribute(t,new c(new Float32Array(Array.from({length:n},"function"==typeof r?r:()=>r)),1))})({geometry:N,propertyName:e,maxParticles:w,factory:t})};C("isActive",0),C("lifetime",0),C("startLifetime",()=>1e3*et(r.particleSystemId,d,0)),C("startFrame",()=>_.startFrame?et(r.particleSystemId,_.startFrame,0):0),C("opacity",()=>et(r.particleSystemId,y,0)),C("rotation",()=>et(r.particleSystemId,f,0)),C("size",(e,t)=>r.startValues.startSize[t]),C("rotation",0);const k=Math.random();C("colorR",()=>g.min.r+k*(g.max.r-g.min.r)),C("colorG",()=>g.min.g+k*(g.max.g-g.min.g)),C("colorB",()=>g.min.b+k*(g.max.b-g.min.b)),C("colorA",0);let D=new le(N,P);D.position.copy(o.position),D.rotation.x=H.degToRad(o.rotation.x),D.rotation.y=H.degToRad(o.rotation.y),D.rotation.z=H.degToRad(o.rotation.z),D.scale.copy(o.scale);const F=n+1e3*et(r.particleSystemId,h);let U;"WORLD"===s.simulationSpace&&(U=new mr,U.add(D)),xr.push({particleSystem:D,wrapper:U,generalData:r,onUpdate:S,onComplete:E,creationTime:F,lastEmissionTime:F,duration:a,looping:u,simulationSpace:T,gravity:x,emission:I,normalizedConfig:s,iterationCount:0,velocities:O,deactivateParticle:e=>{N.attributes.isActive.array[e]=0,N.attributes.colorA.array[e]=0,N.attributes.colorA.needsUpdate=!0},activateParticle:({particleIndex:e,activationTime:t,position:n})=>{N.attributes.isActive.array[e]=1,r.creationTimes[e]=t,r.noise.offsets&&(r.noise.offsets[e]=100*Math.random());const i=Math.random();N.attributes.colorR.array[e]=g.min.r+i*(g.max.r-g.min.r),N.attributes.colorR.needsUpdate=!0,N.attributes.colorG.array[e]=g.min.g+i*(g.max.g-g.min.g),N.attributes.colorG.needsUpdate=!0,N.attributes.colorB.array[e]=g.min.b+i*(g.max.b-g.min.b),N.attributes.colorB.needsUpdate=!0,N.attributes.startFrame.array[e]=_.startFrame?et(r.particleSystemId,_.startFrame,0):0,N.attributes.startFrame.needsUpdate=!0,N.attributes.startLifetime.array[e]=1e3*et(r.particleSystemId,d,r.normalizedLifetimePercentage),N.attributes.startLifetime.needsUpdate=!0,r.startValues.startSize[e]=et(r.particleSystemId,m,r.normalizedLifetimePercentage),N.attributes.size.array[e]=r.startValues.startSize[e],N.attributes.size.needsUpdate=!0,r.startValues.startOpacity[e]=et(r.particleSystemId,y,r.normalizedLifetimePercentage),N.attributes.colorA.array[e]=r.startValues.startOpacity[e],N.attributes.colorA.needsUpdate=!0,N.attributes.rotation.array[e]=et(r.particleSystemId,f,r.normalizedLifetimePercentage),N.attributes.rotation.needsUpdate=!0,s.rotationOverLifetime.isActive&&(r.lifetimeValues.rotationOverLifetime[e]=H.randFloat(s.rotationOverLifetime.min,s.rotationOverLifetime.max)),br(r,b,p,L[e],O[e]);const o=Math.floor(3*e);N.attributes.position.array[o]=n.x+L[e].x,N.attributes.position.array[o+1]=n.y+L[e].y,N.attributes.position.array[o+2]=n.z+L[e].z,N.attributes.position.needsUpdate=!0,r.linearVelocityData&&r.linearVelocityData[e].speed.set(s.velocityOverLifetime.linear.x?et(r.particleSystemId,s.velocityOverLifetime.linear.x,0):0,s.velocityOverLifetime.linear.y?et(r.particleSystemId,s.velocityOverLifetime.linear.y,0):0,s.velocityOverLifetime.linear.z?et(r.particleSystemId,s.velocityOverLifetime.linear.z,0):0),r.orbitalVelocityData&&(r.orbitalVelocityData[e].speed.set(s.velocityOverLifetime.orbital.x?et(r.particleSystemId,s.velocityOverLifetime.orbital.x,0):0,s.velocityOverLifetime.orbital.y?et(r.particleSystemId,s.velocityOverLifetime.orbital.y,0):0,s.velocityOverLifetime.orbital.z?et(r.particleSystemId,s.velocityOverLifetime.orbital.z,0):0),r.orbitalVelocityData[e].positionOffset.set(L[e].x,L[e].y,L[e].z)),N.attributes.lifetime.array[e]=0,N.attributes.lifetime.needsUpdate=!0,rt({delta:0,generalData:r,normalizedConfig:s,attributes:D.geometry.attributes,particleLifetimePercentage:0,particleIndex:e})}});return{instance:U||D,resumeEmitter:()=>r.isEnabled=!0,pauseEmitter:()=>r.isEnabled=!1,dispose:()=>(e=>{xr=xr.filter(({particleSystem:t,wrapper:n,generalData:{particleSystemId:r}})=>t!==e&&n!==e||(Ve(r),t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach(e=>e.dispose()):t.material.dispose(),t.parent&&t.parent.remove(t),!1))})(D)}},Mr=({now:e,delta:t,elapsed:n})=>{xr.forEach(r=>{const{onUpdate:s,generalData:i,onComplete:o,particleSystem:a,wrapper:c,creationTime:l,lastEmissionTime:u,duration:h,looping:d,emission:p,normalizedConfig:m,iterationCount:f,velocities:g,deactivateParticle:y,activateParticle:v,simulationSpace:x,gravity:T}=r,w=e-l,I=w%(1e3*h);i.normalizedLifetimePercentage=Math.max(Math.min(I/(1e3*h),1),0);const{lastWorldPosition:b,currentWorldPosition:A,worldPositionChange:M,lastWorldQuaternion:R,worldQuaternion:S,worldEuler:E,gravityVelocity:_,isEnabled:L}=i;c?.parent&&i.wrapperQuaternion.copy(c.parent.quaternion);const O={...b};if(Array.isArray(a.material)?a.material.forEach(e=>{e instanceof ye&&(e.uniforms.elapsed.value=n)}):a.material instanceof ye&&(a.material.uniforms.elapsed.value=n),a.getWorldPosition(A),-99999!==b.x&&M.set(A.x-b.x,A.y-b.y,A.z-b.z),i.distanceFromLastEmitByDistance+=M.length(),a.getWorldPosition(b),a.getWorldQuaternion(S),-99999!==R.x&&R.x===S.x&&R.y===S.y&&R.z===S.z||(E.setFromQuaternion(S),R.copy(S),_.set(b.x,b.y+T,b.z),a.worldToLocal(_)),i.creationTimes.forEach((n,r)=>{if(a.geometry.attributes.isActive.array[r]){const s=e-n;if(s>a.geometry.attributes.startLifetime.array[r])y(r);else{const e=g[r];if(e.x-=_.x*t,e.y-=_.y*t,e.z-=_.z*t,0!==T||0!==e.x||0!==e.y||0!==e.z||0!==M.x||0!==M.y||0!==M.z){const n=3*r,s=a.geometry.attributes.position.array;"WORLD"===x&&(s[n]-=M.x,s[n+1]-=M.y,s[n+2]-=M.z),s[n]+=e.x*t,s[n+1]+=e.y*t,s[n+2]+=e.z*t,a.geometry.attributes.position.needsUpdate=!0}a.geometry.attributes.lifetime.array[r]=s,a.geometry.attributes.lifetime.needsUpdate=!0;const n=s/a.geometry.attributes.startLifetime.array[r];rt({delta:t,generalData:i,normalizedConfig:m,attributes:a.geometry.attributes,particleLifetimePercentage:n,particleIndex:r})}}}),L&&(d||w<1e3*h)){const o=e-u,c=p.rateOverTime?Math.floor(et(i.particleSystemId,p.rateOverTime,i.normalizedLifetimePercentage)*(o/1e3)):0,l=p.rateOverDistance?et(i.particleSystemId,p.rateOverDistance,i.normalizedLifetimePercentage):0,h=l>0&&i.distanceFromLastEmitByDistance>0?Math.floor(i.distanceFromLastEmitByDistance/(1/l)):0,d=h>0?{x:(A.x-O.x)/h,y:(A.y-O.y)/h,z:(A.z-O.z)/h}:null,m=c+h;if(l>0&&h>=1&&(i.distanceFromLastEmitByDistance=0),m>0){let t=0;for(let n=0;n<m;n++){let n=-1;if(a.geometry.attributes.isActive.array.find((e,t)=>!e&&(n=t,!0)),-1!==n&&n<a.geometry.attributes.isActive.array.length){let s={x:0,y:0,z:0};d&&t<h&&(s={x:d.x*t,y:d.y*t,z:d.z*t},t++),v({particleIndex:n,activationTime:e,position:s}),r.lastEmissionTime=e}}}s&&s({particleSystem:a,delta:t,elapsed:n,lifetime:w,normalizedLifetime:I,iterationCount:f+1})}else o&&o({particleSystem:a})})};export{rt as applyModifiers,Tr as blendingMap,Qe as calculateRandomPositionAndVelocityOnBox,qe as calculateRandomPositionAndVelocityOnCircle,Xe as calculateRandomPositionAndVelocityOnCone,Ye as calculateRandomPositionAndVelocityOnRectangle,We as calculateRandomPositionAndVelocityOnSphere,et as calculateValue,Be as createBezierCurveFunction,$e as createDefaultParticleTexture,Ar as createParticleSystem,He as getBezierCacheSize,Ke as getCurveFunction,Je as getCurveFunctionFromConfig,wr as getDefaultParticleSystemConfig,Ze as isLifeTimeCurve,Ve as removeBezierCurveFunction,Mr as updateParticleSystems};
|
|
2
|
+
import{AdditiveBlending as e,AmbientLight as t,AnimationClip as n,Audio as r,AudioListener as s,AudioLoader as i,Bone as o,Box3 as a,BufferAttribute as c,BufferGeometry as l,CanvasTexture as u,ClampToEdgeWrapping as h,Color as d,ColorManagement as p,Curve as m,DirectionalLight as f,DoubleSide as g,EquirectangularReflectionMapping as y,Euler as v,FileLoader as x,Float32BufferAttribute as T,FrontSide as w,Group as I,ImageBitmapLoader as b,InstancedBufferAttribute as A,InstancedMesh as R,InterleavedBuffer as M,InterleavedBufferAttribute as S,Interpolant as E,InterpolateDiscrete as _,InterpolateLinear as L,Line as O,LineBasicMaterial as P,LineLoop as C,LineSegments as N,LinearFilter as k,LinearMipmapLinearFilter as D,LinearMipmapNearestFilter as F,LinearSRGBColorSpace as U,Loader as z,LoaderUtils as B,Material as V,MathUtils as H,Matrix3 as j,Matrix4 as G,Mesh as K,MeshBasicMaterial as W,MeshLambertMaterial as X,MeshPhongMaterial as Q,MeshPhysicalMaterial as q,MeshStandardMaterial as Y,MirroredRepeatWrapping as Z,MultiplyBlending as $,NearestFilter as J,NearestMipmapLinearFilter as ee,NearestMipmapNearestFilter as te,NoBlending as ne,NormalBlending as re,NumberKeyframeTrack as se,Object3D as ie,OrthographicCamera as oe,PerspectiveCamera as ae,PointLight as ce,Points as le,PointsMaterial as ue,PositionalAudio as he,PropertyBinding as de,Quaternion as pe,QuaternionKeyframeTrack as me,RepeatWrapping as fe,SRGBColorSpace as ge,ShaderMaterial as ye,ShapeUtils as ve,Skeleton as xe,SkinnedMesh as Te,Sphere as we,SphereGeometry as Ie,SpotLight as be,SubtractiveBlending as Ae,Texture as Re,TextureLoader as Me,TriangleFanDrawMode as Se,TriangleStripDrawMode as Ee,TrianglesDrawMode as _e,Uint16BufferAttribute as Le,Vector2 as Oe,Vector3 as Pe,Vector4 as Ce,VectorKeyframeTrack as Ne}from"THREE";var ke={300(e){const t=e=>e,n={In:e=>e*e,Out:e=>e*(2-e),InOut(e){let t=2*e;return t<1?.5*t*t:(t-=1,-.5*(t*(t-2)-1))}},r={In:e=>e*e*e,Out:e=>--e*e*e+1,InOut(e){let t=2*e;return t<1?.5*t*t*t:(t-=2,.5*(t*t*t+2))}},s={In:e=>e*e*e*e,Out:e=>1- --e*e*e*e,InOut(e){let t=2*e;return t<1?.5*t*t*t*t:(t-=2,-.5*(t*t*t*t-2))}},i={In:e=>e*e*e*e*e,Out:e=>--e*e*e*e*e+1,InOut(e){let t=2*e;return t<1?.5*t*t*t*t*t:(t-=2,.5*(t*t*t*t*t+2))}},o={In:e=>1-Math.cos(e*Math.PI/2),Out:e=>Math.sin(e*Math.PI/2),InOut:e=>.5*(1-Math.cos(Math.PI*e))},a={In:e=>0===e?0:1024**(e-1),Out:e=>1===e?1:1-2**(-10*e),InOut(e){if(0===e)return 0;if(1===e)return 1;const t=2*e;return t<1?.5*1024**(t-1):.5*(2-2**(-10*(t-1)))}},c={In:e=>1-Math.sqrt(1-e*e),Out:e=>Math.sqrt(1- --e*e),InOut(e){let t=2*e;return t<1?-.5*(Math.sqrt(1-t*t)-1):(t-=2,.5*(Math.sqrt(1-t*t)+1))}},l={In(e){let t=.1;let n;return 0===e?0:1===e?1:(t<1?(t=1,n=.1):n=.4*Math.asin(1/t)/(2*Math.PI),-t*2**(10*(e-=1))*Math.sin((e-n)*(2*Math.PI)/.4))},Out(e){let t=.1;let n;return 0===e?0:1===e?1:(t<1?(t=1,n=.1):n=.4*Math.asin(1/t)/(2*Math.PI),t*2**(-10*e)*Math.sin((e-n)*(2*Math.PI)/.4)+1)},InOut(e){let t=.1;const n=.4;let r;if(0===e)return 0;if(1===e)return 1;t<1?(t=1,r=.1):r=n*Math.asin(1/t)/(2*Math.PI);const s=2*e;if(s<1){const e=s-1;return t*2**(10*e)*Math.sin((e-r)*(2*Math.PI)/n)*-.5}const i=s-1;return t*2**(-10*i)*Math.sin((i-r)*(2*Math.PI)/n)*.5+1}},u={In(e){const t=1.70158;return e*e*((t+1)*e-t)},Out(e){const t=1.70158;return--e*e*((t+1)*e+t)+1},InOut(e){const t=2.5949095;let n=2*e;return n<1?n*n*((t+1)*n-t)*.5:(n-=2,.5*(n*n*((t+1)*n+t)+2))}},h={In:e=>1-h.Out(1-e),Out(e){if(e<1/2.75)return 7.5625*e*e;if(e<2/2.75){const t=e-1.5/2.75;return 7.5625*t*t+.75}if(e<2.5/2.75){const t=e-2.25/2.75;return 7.5625*t*t+.9375}const t=e-2.625/2.75;return 7.5625*t*t+.984375},InOut:e=>e<.5?.5*h.In(2*e):.5*h.Out(2*e-1)+.5},d={Quadratic:n,Cubic:r,Quartic:s,Quintic:i,Sinusoidal:o,Exponential:a,Circular:c,Elastic:l,Back:u,Bounce:h},p=(e,t,n)=>Object.defineProperty(e,t,{value:n});for(const e of Object.keys(d)){const t=d[e],n=e.toLowerCase();p(d,n,t);for(const r of Object.keys(t)){const s=t[r],i=r.toLowerCase();p(d,`${e}.${r}`,s),p(d,`${n}.${i}`,s),p(t,i,s)}}d.Linear=t,p(d,"linear",t),e.exports=d,"undefined"!=typeof window&&(window.Easing=d)}},De={};function Fe(e){var t=De[e];if(void 0!==t)return t.exports;var n=De[e]={exports:{}};return ke[e](n,n.exports,Fe),n.exports}Fe.d=(e,t)=>{for(var n in t)Fe.o(t,n)&&!Fe.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},Fe.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const Ue=[],ze=(e,t)=>{let n=1;for(let r=1;r<=t;r++)n*=(e+1-r)/r;return n},Be=(e,t)=>{const n=Ue.find(e=>e.bezierPoints===t);if(n)return n.referencedBy.includes(e)||n.referencedBy.push(e),n.curveFunction;const r={referencedBy:[e],bezierPoints:t,curveFunction:e=>{if(e<0)return t[0].y;if(e>1)return t[t.length-1].y;let n=0,r=t.length-1;t.find((t,s)=>{const i=e<(t.percentage??0);return i?r=s:void 0!==t.percentage&&(n=s),i});const s=r-n,i=(e-(t[n].percentage??0))/((t[r].percentage??1)-(t[n].percentage??0));let o=0;for(let e=0;e<=s;e++){const r=t[n+e];o+=ze(s,e)*Math.pow(1-i,s-e)*Math.pow(i,e)*r.y}return o}};return Ue.push(r),r.curveFunction},Ve=e=>{for(;;){const t=Ue.findIndex(t=>t.referencedBy.includes(e));if(-1===t)break;const n=Ue[t];n.referencedBy=n.referencedBy.filter(t=>t!==e),0===n.referencedBy.length&&Ue.splice(t,1)}},He=()=>Ue.length;var je=Fe(300);const Ge={LINEAR:je.Linear.None,QUADRATIC_IN:je.Quadratic.In,QUADRATIC_OUT:je.Quadratic.Out,QUADRATIC_IN_OUT:je.Quadratic.InOut,CUBIC_IN:je.Cubic.In,CUBIC_OUT:je.Cubic.Out,CUBIC_IN_OUT:je.Cubic.InOut,QUARTIC_IN:je.Quartic.In,QUARTIC_OUT:je.Quartic.Out,QUARTIC_IN_OUT:je.Quartic.InOut,QUINTIC_IN:je.Quintic.In,QUINTIC_OUT:je.Quintic.Out,QUINTIC_IN_OUT:je.Quintic.InOut,SINUSOIDAL_IN:je.Sinusoidal.In,SINUSOIDAL_OUT:je.Sinusoidal.Out,SINUSOIDAL_IN_OUT:je.Sinusoidal.InOut,EXPONENTIAL_IN:je.Exponential.In,EXPONENTIAL_OUT:je.Exponential.Out,EXPONENTIAL_IN_OUT:je.Exponential.InOut,CIRCULAR_IN:je.Circular.In,CIRCULAR_OUT:je.Circular.Out,CIRCULAR_IN_OUT:je.Circular.InOut,ELASTIC_IN:je.Elastic.In,ELASTIC_OUT:je.Elastic.Out,ELASTIC_IN_OUT:je.Elastic.InOut,BACK_IN:je.Back.In,BACK_OUT:je.Back.Out,BACK_IN_OUT:je.Back.InOut,BOUNCE_IN:je.Bounce.In,BOUNCE_OUT:je.Bounce.Out,BOUNCE_IN_OUT:je.Bounce.InOut},Ke=e=>"function"==typeof e?e:Ge[e],We=(e,t,n,r,{radius:s,radiusThickness:i,arc:o})=>{const a=Math.random()*(o/360),c=Math.random(),l=Math.random(),u=2*Math.PI*a,h=Math.acos(2*c-1),d=Math.sin(h),p=d*Math.cos(u),m=d*Math.sin(u),f=Math.cos(h),g=1-i;e.x=s*g*p+s*i*l*p,e.y=s*g*m+s*i*l*m,e.z=s*g*f+s*i*l*f,e.applyQuaternion(t);const y=1/e.length();n.set(e.x*y*r,e.y*y*r,e.z*y*r),n.applyQuaternion(t)},Xe=(e,t,n,r,{radius:s,radiusThickness:i,arc:o,angle:a=90})=>{const c=2*Math.PI*Math.random()*(o/360),l=Math.random(),u=Math.cos(c),h=Math.sin(c),d=1-i;e.x=s*d*u+s*i*l*u,e.y=s*d*h+s*i*l*h,e.z=0,e.applyQuaternion(t);const p=e.length(),m=Math.abs(p/s*H.degToRad(a)),f=Math.sin(m),g=1/p;n.set(e.x*f*g*r,e.y*f*g*r,Math.cos(m)*r),n.applyQuaternion(t)},Qe=(e,t,n,r,{scale:s,emitFrom:i})=>{const o=s;switch(i){case"VOLUME":e.x=Math.random()*o.x-o.x/2,e.y=Math.random()*o.y-o.y/2,e.z=Math.random()*o.z-o.z/2;break;case"SHELL":const t=Math.floor(6*Math.random()),n=t%3,r=[];r[n]=t>2?1:0,r[(n+1)%3]=Math.random(),r[(n+2)%3]=Math.random(),e.x=r[0]*o.x-o.x/2,e.y=r[1]*o.y-o.y/2,e.z=r[2]*o.z-o.z/2;break;case"EDGE":const s=Math.floor(6*Math.random()),i=s%3,a=Math.floor(4*Math.random()),c=[];c[i]=s>2?1:0,c[(i+1)%3]=a<2?Math.random():a-2,c[(i+2)%3]=a<2?a:Math.random(),e.x=c[0]*o.x-o.x/2,e.y=c[1]*o.y-o.y/2,e.z=c[2]*o.z-o.z/2}e.applyQuaternion(t),n.set(0,0,r),n.applyQuaternion(t)},qe=(e,t,n,r,{radius:s,radiusThickness:i,arc:o})=>{const a=2*Math.PI*Math.random()*(o/360),c=Math.random(),l=Math.cos(a),u=Math.sin(a),h=1-i;e.x=s*h*l+s*i*c*l,e.y=s*h*u+s*i*c*u,e.z=0,e.applyQuaternion(t);const d=1/e.length();n.set(e.x*d*r,e.y*d*r,0),n.applyQuaternion(t)},Ye=(e,t,n,r,{rotation:s,scale:i})=>{const o=i,a=s,c=Math.random()*o.x-o.x/2,l=Math.random()*o.y-o.y/2,u=H.degToRad(a.x),h=H.degToRad(a.y);e.x=c*Math.cos(h),e.y=l*Math.cos(u),e.z=c*Math.sin(h)-l*Math.sin(u),e.applyQuaternion(t),n.set(0,0,r),n.applyQuaternion(t)},Ze=()=>{try{const e=document.createElement("canvas"),t=64;e.width=t,e.height=t;const n=e.getContext("2d");if(n){const r=t/2,s=t/2,i=t/2-2;n.beginPath(),n.arc(r,s,i,0,2*Math.PI,!1),n.fillStyle="white",n.fill();const o=new u(e);return o.needsUpdate=!0,o}return null}catch(e){return null}},$e=e=>"number"!=typeof e&&"type"in e,Je=(e,t)=>{if("BEZIER"===t.type)return Be(e,t.bezierPoints);if("EASING"===t.type)return t.curveFunction;throw new Error(`Unsupported value type: ${t}`)},et=(e,t,n=0)=>{if("number"==typeof t)return t;if("min"in t&&"max"in t)return t.min===t.max?t.min??0:H.randFloat(t.min??0,t.max??1);const r=t;return Je(e,r)(n)*(r.scale??1)},tt=new Pe(0,0,0),nt=new v,rt=({delta:e,generalData:t,normalizedConfig:n,attributes:r,particleLifetimePercentage:s,particleIndex:i})=>{const{particleSystemId:o,startValues:a,lifetimeValues:c,linearVelocityData:l,orbitalVelocityData:u,noise:h}=t,d=3*i,p=r.position.array;if(l){const{speed:t,valueModifiers:n}=l[i],o=n.x?n.x(s):t.x,a=n.y?n.y(s):t.y,c=n.z?n.z(s):t.z;p[d]+=o*e,p[d+1]+=a*e,p[d+2]+=c*e,r.position.needsUpdate=!0}if(u){const{speed:t,positionOffset:n,valueModifiers:o}=u[i];p[d]-=n.x,p[d+1]-=n.y,p[d+2]-=n.z;const a=o.x?o.x(s):t.x,c=o.y?o.y(s):t.y,l=o.z?o.z(s):t.z;nt.set(a*e,l*e,c*e),n.applyEuler(nt),p[d]+=n.x,p[d+1]+=n.y,p[d+2]+=n.z,r.position.needsUpdate=!0}if(n.sizeOverLifetime.isActive){const e=et(o,n.sizeOverLifetime.lifetimeCurve,s);r.size.array[i]=a.startSize[i]*e,r.size.needsUpdate=!0}if(n.opacityOverLifetime.isActive){const e=et(o,n.opacityOverLifetime.lifetimeCurve,s);r.colorA.array[i]=a.startOpacity[i]*e,r.colorA.needsUpdate=!0}if(n.colorOverLifetime.isActive){const e=et(o,n.colorOverLifetime.r,s),t=et(o,n.colorOverLifetime.g,s),c=et(o,n.colorOverLifetime.b,s);r.colorR.array[i]=a.startColorR[i]*e,r.colorG.array[i]=a.startColorG[i]*t,r.colorB.array[i]=a.startColorB[i]*c,r.colorR.needsUpdate=!0,r.colorG.needsUpdate=!0,r.colorB.needsUpdate=!0}if(c.rotationOverLifetime&&(r.rotation.array[i]+=c.rotationOverLifetime[i]*e*.02,r.rotation.needsUpdate=!0),h.isActive){const{sampler:e,strength:t,offsets:n,positionAmount:o,rotationAmount:a,sizeAmount:c}=h;let l;const u=10*(s+(n?n[i]:0))*t,m=.15*t;tt.set(u,0,0),l=e.get3(tt),p[d]+=l*m*o,0!==a&&(r.rotation.array[i]+=l*m*a,r.rotation.needsUpdate=!0),0!==c&&(r.size.array[i]+=l*m*c,r.size.needsUpdate=!0),tt.set(u,u,0),l=e.get3(tt),p[d+1]+=l*m*o,tt.set(u,u,u),l=e.get3(tt),p[d+2]+=l*m*o,r.position.needsUpdate=!0}};const st=(e,t,n={skippedProperties:[],applyToFirstObject:!1})=>{const r={};return Array.from(new Set([...Object.keys(e||{}),...Object.keys(t||{})])).forEach(s=>{n.skippedProperties&&n.skippedProperties.includes(s)||("object"==typeof e?.[s]&&e?.[s]&&t?.[s]&&!Array.isArray(e[s])?r[s]=st(e[s],t[s],n):(r[s]=0===t?.[s]?0:!1!==t?.[s]&&(t?.[s]||e?.[s]),n.applyToFirstObject&&(e[s]=r[s])))}),r};var it=Uint8Array,ot=Uint16Array,at=Int32Array,ct=new it([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]),lt=new it([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]),ut=new it([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ht=function(e,t){for(var n=new ot(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];var s=new at(n[30]);for(r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return{b:n,r:s}},dt=ht(ct,2),pt=dt.b,mt=dt.r;pt[28]=258,mt[258]=28;for(var ft=ht(lt,0),gt=ft.b,yt=(ft.r,new ot(32768)),vt=0;vt<32768;++vt){var xt=(43690&vt)>>1|(21845&vt)<<1;xt=(61680&(xt=(52428&xt)>>2|(13107&xt)<<2))>>4|(3855&xt)<<4,yt[vt]=((65280&xt)>>8|(255&xt)<<8)>>1}var Tt=function(e,t,n){for(var r=e.length,s=0,i=new ot(t);s<r;++s)e[s]&&++i[e[s]-1];var o,a=new ot(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;if(n){o=new ot(1<<t);var c=15-t;for(s=0;s<r;++s)if(e[s])for(var l=s<<4|e[s],u=t-e[s],h=a[e[s]-1]++<<u,d=h|(1<<u)-1;h<=d;++h)o[yt[h]>>c]=l}else for(o=new ot(r),s=0;s<r;++s)e[s]&&(o[s]=yt[a[e[s]-1]++]>>15-e[s]);return o},wt=new it(288);for(vt=0;vt<144;++vt)wt[vt]=8;for(vt=144;vt<256;++vt)wt[vt]=9;for(vt=256;vt<280;++vt)wt[vt]=7;for(vt=280;vt<288;++vt)wt[vt]=8;var It=new it(32);for(vt=0;vt<32;++vt)It[vt]=5;var bt=Tt(wt,9,1),At=Tt(It,5,1),Rt=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Mt=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(7&t)&n},St=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(7&t)},Et=function(e){return(e+7)/8|0},_t=function(e,t,n){return(null==t||t<0)&&(t=0),(null==n||n>e.length)&&(n=e.length),new it(e.subarray(t,n))},Lt=["unexpected EOF","invalid block type","invalid length/literal","invalid distance","stream finished","no stream handler",,"no callback","invalid UTF-8 data","extra field too long","date not in range 1980-2099","filename too long","stream finishing","invalid zip data"],Ot=function(e,t,n){var r=new Error(t||Lt[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Ot),!n)throw r;return r},Pt=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new it(0);var o=!n,a=o||2!=t.i,c=t.i;o&&(n=new it(3*s));var l=function(e){var t=n.length;if(e>t){var r=new it(Math.max(2*t,e));r.set(n),n=r}},u=t.f||0,h=t.p||0,d=t.b||0,p=t.l,m=t.d,f=t.m,g=t.n,y=8*s;do{if(!p){u=Mt(e,h,1);var v=Mt(e,h+1,3);if(h+=3,!v){var x=e[(L=Et(h)+4)-4]|e[L-3]<<8,T=L+x;if(T>s){c&&Ot(0);break}a&&l(d+x),n.set(e.subarray(L,T),d),t.b=d+=x,t.p=h=8*T,t.f=u;continue}if(1==v)p=bt,m=At,f=9,g=5;else if(2==v){var w=Mt(e,h,31)+257,I=Mt(e,h+10,15)+4,b=w+Mt(e,h+5,31)+1;h+=14;for(var A=new it(b),R=new it(19),M=0;M<I;++M)R[ut[M]]=Mt(e,h+3*M,7);h+=3*I;var S=Rt(R),E=(1<<S)-1,_=Tt(R,S,1);for(M=0;M<b;){var L,O=_[Mt(e,h,E)];if(h+=15&O,(L=O>>4)<16)A[M++]=L;else{var P=0,C=0;for(16==L?(C=3+Mt(e,h,3),h+=2,P=A[M-1]):17==L?(C=3+Mt(e,h,7),h+=3):18==L&&(C=11+Mt(e,h,127),h+=7);C--;)A[M++]=P}}var N=A.subarray(0,w),k=A.subarray(w);f=Rt(N),g=Rt(k),p=Tt(N,f,1),m=Tt(k,g,1)}else Ot(1);if(h>y){c&&Ot(0);break}}a&&l(d+131072);for(var D=(1<<f)-1,F=(1<<g)-1,U=h;;U=h){var z=(P=p[St(e,h)&D])>>4;if((h+=15&P)>y){c&&Ot(0);break}if(P||Ot(2),z<256)n[d++]=z;else{if(256==z){U=h,p=null;break}var B=z-254;if(z>264){var V=ct[M=z-257];B=Mt(e,h,(1<<V)-1)+pt[M],h+=V}var H=m[St(e,h)&F],j=H>>4;H||Ot(3),h+=15&H;k=gt[j];if(j>3){V=lt[j];k+=St(e,h)&(1<<V)-1,h+=V}if(h>y){c&&Ot(0);break}a&&l(d+131072);var G=d+B;if(d<k){var K=i-k,W=Math.min(k,G);for(K+d<0&&Ot(3);d<W;++d)n[d]=r[K+d]}for(;d<G;++d)n[d]=n[d-k]}}t.l=p,t.p=U,t.b=d,t.f=u,p&&(u=1,t.m=f,t.d=m,t.n=g)}while(!u);return d!=n.length&&o?_t(n,0,d):n.subarray(0,d)},Ct=new it(0),Nt=function(e,t){return(8!=(15&e[0])||e[0]>>4>7||(e[0]<<8|e[1])%31)&&Ot(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&Ot(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),2+(e[1]>>3&4)};function kt(e,t){return Pt(e.subarray(Nt(e,t&&t.dictionary),-4),{i:2},t&&t.out,t&&t.dictionary)}var Dt="undefined"!=typeof TextDecoder&&new TextDecoder;try{Dt.decode(Ct,{stream:!0})}catch(e){}"function"==typeof queueMicrotask?queueMicrotask:"function"==typeof setTimeout&&setTimeout;function Ft(e,t,n){const r=n.length-e-1;if(t>=n[r])return r-1;if(t<=n[e])return e;let s=e,i=r,o=Math.floor((s+i)/2);for(;t<n[o]||t>=n[o+1];)t<n[o]?i=o:s=o,o=Math.floor((s+i)/2);return o}function Ut(e,t,n,r){const s=[],i=[],o=[];s[0]=1;for(let a=1;a<=n;++a){i[a]=t-r[e+1-a],o[a]=r[e+a]-t;let n=0;for(let e=0;e<a;++e){const t=o[e+1],r=i[a-e],c=s[e]/(t+r);s[e]=n+t*c,n=r*c}s[a]=n}return s}function zt(e,t){let n=1;for(let t=2;t<=e;++t)n*=t;let r=1;for(let e=2;e<=t;++e)r*=e;for(let n=2;n<=e-t;++n)r*=n;return n/r}function Bt(e,t,n,r,s){const i=function(e,t,n,r,s){const i=s<e?s:e,o=[],a=Ft(e,r,t),c=function(e,t,n,r,s){const i=[];for(let e=0;e<=n;++e)i[e]=0;const o=[];for(let e=0;e<=r;++e)o[e]=i.slice(0);const a=[];for(let e=0;e<=n;++e)a[e]=i.slice(0);a[0][0]=1;const c=i.slice(0),l=i.slice(0);for(let r=1;r<=n;++r){c[r]=t-s[e+1-r],l[r]=s[e+r]-t;let n=0;for(let e=0;e<r;++e){const t=l[e+1],s=c[r-e];a[r][e]=t+s;const i=a[e][r-1]/a[r][e];a[e][r]=n+t*i,n=s*i}a[r][r]=n}for(let e=0;e<=n;++e)o[0][e]=a[e][n];for(let e=0;e<=n;++e){let t=0,s=1;const c=[];for(let e=0;e<=n;++e)c[e]=i.slice(0);c[0][0]=1;for(let i=1;i<=r;++i){let r=0;const l=e-i,u=n-i;e>=i&&(c[s][0]=c[t][0]/a[u+1][l],r=c[s][0]*a[l][u]);const h=e-1<=u?i-1:n-e;for(let e=l>=-1?1:-l;e<=h;++e)c[s][e]=(c[t][e]-c[t][e-1])/a[u+1][l+e],r+=c[s][e]*a[l+e][u];e<=u&&(c[s][i]=-c[t][i-1]/a[u+1][e],r+=c[s][i]*a[e][u]),o[i][e]=r;const d=t;t=s,s=d}}let u=n;for(let e=1;e<=r;++e){for(let t=0;t<=n;++t)o[e][t]*=u;u*=n-e}return o}(a,r,e,i,t),l=[];for(let e=0;e<n.length;++e){const t=n[e].clone(),r=t.w;t.x*=r,t.y*=r,t.z*=r,l[e]=t}for(let t=0;t<=i;++t){const n=l[a-e].clone().multiplyScalar(c[t][0]);for(let r=1;r<=e;++r)n.add(l[a-e+r].clone().multiplyScalar(c[t][r]));o[t]=n}for(let e=i+1;e<=s+1;++e)o[e]=new Ce(0,0,0);return o}(e,t,n,r,s);return function(e){const t=e.length,n=[],r=[];for(let s=0;s<t;++s){const t=e[s];n[s]=new Pe(t.x,t.y,t.z),r[s]=t.w}const s=[];for(let e=0;e<t;++e){const t=n[e].clone();for(let n=1;n<=e;++n)t.sub(s[e-n].clone().multiplyScalar(zt(e,n)*r[n]));s[e]=t.divideScalar(r[0])}return s}(i)}class Vt extends m{constructor(e,t,n,r,s){super();const i=t?t.length-1:0,o=n?n.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=r||0,this.endKnot=s||i;for(let e=0;e<o;++e){const t=n[e];this.controlPoints[e]=new Ce(t.x,t.y,t.z,t.w)}}getPoint(e,t=new Pe){const n=t,r=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=function(e,t,n,r){const s=Ft(e,r,t),i=Ut(s,r,e,t),o=new Ce(0,0,0,0);for(let t=0;t<=e;++t){const r=n[s-e+t],a=i[t],c=r.w*a;o.x+=r.x*c,o.y+=r.y*c,o.z+=r.z*c,o.w+=r.w*a}return o}(this.degree,this.knots,this.controlPoints,r);return 1!==s.w&&s.divideScalar(s.w),n.set(s.x,s.y,s.z)}getTangent(e,t=new Pe){const n=t,r=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=Bt(this.degree,this.knots,this.controlPoints,r,1);return n.copy(s[1]).normalize(),n}toJSON(){const e=super.toJSON();return e.degree=this.degree,e.knots=[...this.knots],e.controlPoints=this.controlPoints.map(e=>e.toArray()),e.startKnot=this.startKnot,e.endKnot=this.endKnot,e}fromJSON(e){return super.fromJSON(e),this.degree=e.degree,this.knots=[...e.knots],this.controlPoints=e.controlPoints.map(e=>new Ce(e[0],e[1],e[2],e[3])),this.startKnot=e.startKnot,this.endKnot=e.endKnot,this}}let Ht,jt,Gt;class Kt extends z{constructor(e){super(e)}load(e,t,n,r){const s=this,i=""===s.path?B.extractUrlBase(e):s.path,o=new x(this.manager);o.setPath(s.path),o.setResponseType("arraybuffer"),o.setRequestHeader(s.requestHeader),o.setWithCredentials(s.withCredentials),o.load(e,function(n){try{t(s.parse(n,i))}catch(t){r&&r(t),s.manager.itemError(e)}},n,r)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===ln(e,0,t.length)}(e))Ht=(new Yt).parse(e);else{const t=ln(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let n=0;function r(t){const r=e[t-1];return e=e.slice(n+t),n++,r}for(let e=0;e<t.length;++e){if(r(1)===t[e])return!1}return!0}(t))throw new Error("THREE.FBXLoader: Unknown format.");if(Jt(t)<7e3)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+Jt(t));Ht=(new qt).parse(t)}const n=new Me(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Wt(n,this.manager).parse(Ht)}}class Wt{constructor(e,t){this.textureLoader=e,this.manager=t}parse(){jt=this.parseConnections();const e=this.parseImages(),t=this.parseTextures(e),n=this.parseMaterials(t),r=this.parseDeformers(),s=(new Xt).parse(r);return this.parseScene(r,s,n),Gt}parseConnections(){const e=new Map;if("Connections"in Ht){Ht.Connections.connections.forEach(function(t){const n=t[0],r=t[1],s=t[2];e.has(n)||e.set(n,{parents:[],children:[]});const i={ID:r,relationship:s};e.get(n).parents.push(i),e.has(r)||e.set(r,{parents:[],children:[]});const o={ID:n,relationship:s};e.get(r).children.push(o)})}return e}parseImages(){const e={},t={};if("Video"in Ht.Objects){const n=Ht.Objects.Video;for(const r in n){const s=n[r];if(e[parseInt(r)]=s.RelativeFilename||s.Filename,"Content"in s){const e=s.Content instanceof ArrayBuffer&&s.Content.byteLength>0,i="string"==typeof s.Content&&""!==s.Content;if(e||i){const e=this.parseImage(n[r]);t[s.RelativeFilename||s.Filename]=e}}}}for(const n in e){const r=e[n];void 0!==t[r]?e[n]=t[r]:e[n]=e[n].split("\\").pop()}return e}parseImage(e){const t=e.Content,n=e.RelativeFilename||e.Filename;let r;switch(n.slice(n.lastIndexOf(".")+1).toLowerCase()){case"bmp":r="image/bmp";break;case"jpg":case"jpeg":r="image/jpeg";break;case"png":r="image/png";break;case"tif":r="image/tiff";break;case"tga":this.manager.getHandler(".tga"),r="image/tga";break;case"webp":r="image/webp";break;default:return}if("string"==typeof t)return"data:"+r+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:r}))}}parseTextures(e){const t=new Map;if("Texture"in Ht.Objects){const n=Ht.Objects.Texture;for(const r in n){const s=this.parseTexture(n[r],e);t.set(parseInt(r),s)}}return t}parseTexture(e,t){const n=this.loadTexture(e,t);n.ID=e.id,n.name=e.attrName;const r=e.WrapModeU,s=e.WrapModeV,i=void 0!==r?r.value:0,o=void 0!==s?s.value:0;if(n.wrapS=0===i?fe:h,n.wrapT=0===o?fe:h,"Scaling"in e){const t=e.Scaling.value;n.repeat.x=t[0],n.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;n.offset.x=t[0],n.offset.y=t[1]}return n}loadTexture(e,t){const n=e.FileName.split(".").pop().toLowerCase();let r=this.manager.getHandler(`.${n}`);null===r&&(r=this.textureLoader);const s=r.path;s||r.setPath(this.textureLoader.path);const i=jt.get(e.id).children;let o;if(void 0!==i&&i.length>0&&void 0!==t[i[0].ID]&&(o=t[i[0].ID],0!==o.indexOf("blob:")&&0!==o.indexOf("data:")||r.setPath(void 0)),void 0===o)return new Re;const a=r.load(o);return r.setPath(s),a}parseMaterials(e){const t=new Map;if("Material"in Ht.Objects){const n=Ht.Objects.Material;for(const r in n){const s=this.parseMaterial(n[r],e);null!==s&&t.set(parseInt(r),s)}}return t}parseMaterial(e,t){const n=e.id,r=e.attrName;let s=e.ShadingModel;if("object"==typeof s&&(s=s.value),!jt.has(n))return null;const i=this.parseParameters(e,t,n);let o;switch(s.toLowerCase()){case"phong":default:o=new Q;break;case"lambert":o=new X}return o.setValues(i),o.name=r,o}parseParameters(e,t,n){const r={};e.BumpFactor&&(r.bumpScale=e.BumpFactor.value),e.Diffuse?r.color=p.colorSpaceToWorking((new d).fromArray(e.Diffuse.value),ge):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(r.color=p.colorSpaceToWorking((new d).fromArray(e.DiffuseColor.value),ge)),e.DisplacementFactor&&(r.displacementScale=e.DisplacementFactor.value),e.Emissive?r.emissive=p.colorSpaceToWorking((new d).fromArray(e.Emissive.value),ge):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(r.emissive=p.colorSpaceToWorking((new d).fromArray(e.EmissiveColor.value),ge)),e.EmissiveFactor&&(r.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),r.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),1!==r.opacity&&0!==r.opacity||(r.opacity=e.Opacity?parseFloat(e.Opacity.value):null,null===r.opacity&&(r.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),r.opacity<1&&(r.transparent=!0),e.ReflectionFactor&&(r.reflectivity=e.ReflectionFactor.value),e.Shininess&&(r.shininess=e.Shininess.value),e.Specular?r.specular=p.colorSpaceToWorking((new d).fromArray(e.Specular.value),ge):e.SpecularColor&&"Color"===e.SpecularColor.type&&(r.specular=p.colorSpaceToWorking((new d).fromArray(e.SpecularColor.value),ge));const s=this;return jt.get(n).children.forEach(function(e){switch(e.relationship){case"Bump":r.bumpMap=s.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":r.aoMap=s.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":r.map=s.getTexture(t,e.ID),void 0!==r.map&&(r.map.colorSpace=ge);break;case"DisplacementColor":r.displacementMap=s.getTexture(t,e.ID);break;case"EmissiveColor":r.emissiveMap=s.getTexture(t,e.ID),void 0!==r.emissiveMap&&(r.emissiveMap.colorSpace=ge);break;case"NormalMap":case"Maya|TEX_normal_map":r.normalMap=s.getTexture(t,e.ID);break;case"ReflectionColor":r.envMap=s.getTexture(t,e.ID),void 0!==r.envMap&&(r.envMap.mapping=y,r.envMap.colorSpace=ge);break;case"SpecularColor":r.specularMap=s.getTexture(t,e.ID),void 0!==r.specularMap&&(r.specularMap.colorSpace=ge);break;case"TransparentColor":case"TransparencyFactor":r.alphaMap=s.getTexture(t,e.ID),r.transparent=!0}}),r}getTexture(e,t){return"LayeredTexture"in Ht.Objects&&t in Ht.Objects.LayeredTexture&&(t=jt.get(t).children[0].ID),e.get(t)}parseDeformers(){const e={},t={};if("Deformer"in Ht.Objects){const n=Ht.Objects.Deformer;for(const r in n){const s=n[r],i=jt.get(parseInt(r));if("Skin"===s.attrType){const t=this.parseSkeleton(i,n);t.ID=r,i.parents.length,t.geometryID=i.parents[0].ID,e[r]=t}else if("BlendShape"===s.attrType){const e={id:r};e.rawTargets=this.parseMorphTargets(i,n),e.id=r,i.parents.length,t[r]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const n=[];return e.children.forEach(function(e){const r=t[e.ID];if("Cluster"!==r.attrType)return;const s={ID:e.ID,indices:[],weights:[],transformLink:(new G).fromArray(r.TransformLink.a)};"Indexes"in r&&(s.indices=r.Indexes.a,s.weights=r.Weights.a),n.push(s)}),{rawBones:n,bones:[]}}parseMorphTargets(e,t){const n=[];for(let r=0;r<e.children.length;r++){const s=e.children[r],i=t[s.ID],o={name:i.attrName,initialWeight:i.DeformPercent,id:i.id,fullWeights:i.FullWeights.a};if("BlendShapeChannel"!==i.attrType)return;o.geoID=jt.get(parseInt(s.ID)).children.filter(function(e){return void 0===e.relationship})[0].ID,n.push(o)}return n}parseScene(e,t,n){Gt=new I;const r=this.parseModels(e.skeletons,t,n),s=Ht.Objects.Model,i=this;r.forEach(function(e){const t=s[e.ID];i.setLookAtProperties(e,t);jt.get(e.ID).parents.forEach(function(t){const n=r.get(t.ID);void 0!==n&&n.add(e)}),null===e.parent&&Gt.add(e)}),this.bindSkeleton(e.skeletons,t,r),this.addGlobalSceneSettings(),Gt.traverse(function(e){if(e.userData.transformData){e.parent&&(e.userData.transformData.parentMatrix=e.parent.matrix,e.userData.transformData.parentMatrixWorld=e.parent.matrixWorld);const t=on(e.userData.transformData);e.applyMatrix4(t),e.updateWorldMatrix()}});const o=(new Qt).parse();1===Gt.children.length&&Gt.children[0].isGroup&&(Gt.children[0].animations=o,Gt=Gt.children[0]),Gt.animations=o}parseModels(e,t,n){const r=new Map,s=Ht.Objects.Model;for(const i in s){const a=parseInt(i),c=s[i],l=jt.get(a);let u=this.buildSkeleton(l,e,a,c.attrName);if(!u){switch(c.attrType){case"Camera":u=this.createCamera(l);break;case"Light":u=this.createLight(l);break;case"Mesh":u=this.createMesh(l,t,n);break;case"NurbsCurve":u=this.createCurve(l,t);break;case"LimbNode":case"Root":u=new o;break;default:u=new I}u.name=c.attrName?de.sanitizeNodeName(c.attrName):"",u.userData.originalName=c.attrName,u.ID=a}this.getTransformData(u,c),r.set(a,u)}return r}buildSkeleton(e,t,n,r){let s=null;return e.parents.forEach(function(e){for(const i in t){const a=t[i];a.rawBones.forEach(function(t,i){if(t.ID===e.ID){const e=s;s=new o,s.matrixWorld.copy(t.transformLink),s.name=r?de.sanitizeNodeName(r):"",s.userData.originalName=r,s.ID=n,a.bones[i]=s,null!==e&&s.add(e)}})}}),s}createCamera(e){let t,n;if(e.children.forEach(function(e){const t=Ht.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)}),void 0===n)t=new ie;else{let e=0;void 0!==n.CameraProjectionType&&1===n.CameraProjectionType.value&&(e=1);let r=1;void 0!==n.NearPlane&&(r=n.NearPlane.value/1e3);let s=1e3;void 0!==n.FarPlane&&(s=n.FarPlane.value/1e3);let i=window.innerWidth,o=window.innerHeight;void 0!==n.AspectWidth&&void 0!==n.AspectHeight&&(i=n.AspectWidth.value,o=n.AspectHeight.value);const a=i/o;let c=45;void 0!==n.FieldOfView&&(c=n.FieldOfView.value);const l=n.FocalLength?n.FocalLength.value:null;if(0===e)t=new ae(c,a,r,s),null!==l&&t.setFocalLength(l);else t=new ie}return t}createLight(e){let t,n;if(e.children.forEach(function(e){const t=Ht.Objects.NodeAttribute[e.ID];void 0!==t&&(n=t)}),void 0===n)t=new ie;else{let e;e=void 0===n.LightType?0:n.LightType.value;let r=16777215;void 0!==n.Color&&(r=p.colorSpaceToWorking((new d).fromArray(n.Color.value),ge));let s=void 0===n.Intensity?1:n.Intensity.value/100;void 0!==n.CastLightOnObject&&0===n.CastLightOnObject.value&&(s=0);let i=0;void 0!==n.FarAttenuationEnd&&(i=void 0!==n.EnableFarAttenuation&&0===n.EnableFarAttenuation.value?0:n.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new ce(r,s,i,o);break;case 1:t=new f(r,s);break;case 2:let e=Math.PI/3;void 0!==n.InnerAngle&&(e=H.degToRad(n.InnerAngle.value));let a=0;void 0!==n.OuterAngle&&(a=H.degToRad(n.OuterAngle.value),a=Math.max(a,1)),t=new be(r,s,i,e,a,o);break;default:t=new ce(r,s)}void 0!==n.CastShadows&&1===n.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,n){let r,s=null,i=null;const o=[];if(e.children.forEach(function(e){t.has(e.ID)&&(s=t.get(e.ID)),n.has(e.ID)&&o.push(n.get(e.ID))}),o.length>1?i=o:o.length>0?i=o[0]:(i=new Q({name:z.DEFAULT_MATERIAL_NAME,color:13421772}),o.push(i)),"color"in s.attributes&&o.forEach(function(e){e.vertexColors=!0}),s.groups.length>0){let e=!1;for(let t=0,n=s.groups.length;t<n;t++){const n=s.groups[t];(n.materialIndex<0||n.materialIndex>=o.length)&&(n.materialIndex=o.length,e=!0)}if(e){const e=new Q;o.push(e)}}return s.FBX_Deformer?(r=new Te(s,i),r.normalizeSkinWeights()):r=new K(s,i),r}createCurve(e,t){const n=e.children.reduce(function(e,n){return t.has(n.ID)&&(e=t.get(n.ID)),e},null),r=new P({name:z.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new O(n,r)}getTransformData(e,t){const n={};"InheritType"in t&&(n.inheritType=parseInt(t.InheritType.value)),n.eulerOrder=an("RotationOrder"in t?t.RotationOrder.value:0),"Lcl_Translation"in t&&(n.translation=t.Lcl_Translation.value),"PreRotation"in t&&(n.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(n.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(n.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(n.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(n.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(n.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(n.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(n.rotationPivot=t.RotationPivot.value),e.userData.transformData=n}setLookAtProperties(e,t){if("LookAtProperty"in t){jt.get(e.ID).children.forEach(function(t){if("LookAtProperty"===t.relationship){const n=Ht.Objects.Model[t.ID];if("Lcl_Translation"in n){const t=n.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),Gt.add(e.target)):e.lookAt((new Pe).fromArray(t))}}})}}bindSkeleton(e,t,n){const r=this.parsePoseNodes();for(const s in e){const i=e[s];jt.get(parseInt(i.ID)).parents.forEach(function(e){if(t.has(e.ID)){const t=e.ID;jt.get(t).parents.forEach(function(e){if(n.has(e.ID)){n.get(e.ID).bind(new xe(i.bones),r[e.ID])}})}})}}parsePoseNodes(){const e={};if("Pose"in Ht.Objects){const t=Ht.Objects.Pose;for(const n in t)if("BindPose"===t[n].attrType&&t[n].NbPoseNodes>0){const r=t[n].PoseNode;Array.isArray(r)?r.forEach(function(t){e[t.Node]=(new G).fromArray(t.Matrix.a)}):e[r.Node]=(new G).fromArray(r.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in Ht){if("AmbientColor"in Ht.GlobalSettings){const e=Ht.GlobalSettings.AmbientColor.value,n=e[0],r=e[1],s=e[2];if(0!==n||0!==r||0!==s){const e=(new d).setRGB(n,r,s,ge);Gt.add(new t(e,1))}}"UnitScaleFactor"in Ht.GlobalSettings&&(Gt.userData.unitScaleFactor=Ht.GlobalSettings.UnitScaleFactor.value)}}}class Xt{constructor(){this.negativeMaterialIndices=!1}parse(e){const t=new Map;if("Geometry"in Ht.Objects){const n=Ht.Objects.Geometry;for(const r in n){const s=jt.get(parseInt(r)),i=this.parseGeometry(s,n[r],e);t.set(parseInt(r),i)}}return this.negativeMaterialIndices,t}parseGeometry(e,t,n){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,n);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,n){const r=n.skeletons,s=[],i=e.parents.map(function(e){return Ht.Objects.Model[e.ID]});if(0===i.length)return;const o=e.children.reduce(function(e,t){return void 0!==r[t.ID]&&(e=r[t.ID]),e},null);e.children.forEach(function(e){void 0!==n.morphTargets[e.ID]&&s.push(n.morphTargets[e.ID])});const a=i[0],c={};"RotationOrder"in a&&(c.eulerOrder=an(a.RotationOrder.value)),"InheritType"in a&&(c.inheritType=parseInt(a.InheritType.value)),"GeometricTranslation"in a&&(c.translation=a.GeometricTranslation.value),"GeometricRotation"in a&&(c.rotation=a.GeometricRotation.value),"GeometricScaling"in a&&(c.scale=a.GeometricScaling.value);const l=on(c);return this.genGeometry(t,o,s,l)}genGeometry(e,t,n,r){const s=new l;e.attrName&&(s.name=e.attrName);const i=this.parseGeoNode(e,t),o=this.genBuffers(i),a=new T(o.vertex,3);if(a.applyMatrix4(r),s.setAttribute("position",a),o.colors.length>0&&s.setAttribute("color",new T(o.colors,3)),t&&(s.setAttribute("skinIndex",new Le(o.weightsIndices,4)),s.setAttribute("skinWeight",new T(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const e=(new j).getNormalMatrix(r),t=new T(o.normal,3);t.applyNormalMatrix(e),s.setAttribute("normal",t)}if(o.uvs.forEach(function(e,t){const n=0===t?"uv":`uv${t}`;s.setAttribute(n,new T(o.uvs[t],2))}),i.material&&"AllSame"!==i.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach(function(n,r){n!==e&&(s.addGroup(t,r-t,e),e=n,t=r)}),s.groups.length>0){const t=s.groups[s.groups.length-1],n=t.start+t.count;n!==o.materialIndex.length&&s.addGroup(n,o.materialIndex.length-n,e)}0===s.groups.length&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,n,r),s}parseGeoNode(e,t){const n={};if(n.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],n.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&e.LayerElementColor[0].Colors&&(n.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(n.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(n.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){n.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&n.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return n.weightTable={},null!==t&&(n.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(r,s){void 0===n.weightTable[r]&&(n.weightTable[r]=[]),n.weightTable[r].push({id:t,weight:e.weights[s]})})})),n}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let n=0,r=0,s=!1,i=[],o=[],a=[],c=[],l=[],u=[];const h=this;return e.vertexIndices.forEach(function(d,p){let m,f=!1;d<0&&(d^=-1,f=!0);let g=[],y=[];if(i.push(3*d,3*d+1,3*d+2),e.color){const t=nn(p,n,d,e.color);a.push(t[0],t[1],t[2])}if(e.skeleton){if(void 0!==e.weightTable[d]&&e.weightTable[d].forEach(function(e){y.push(e.weight),g.push(e.id)}),y.length>4){s||(s=!0);const e=[0,0,0,0],t=[0,0,0,0];y.forEach(function(n,r){let s=n,i=g[r];t.forEach(function(t,n,r){if(s>t){r[n]=s,s=t;const o=e[n];e[n]=i,i=o}})}),g=e,y=t}for(;y.length<4;)y.push(0),g.push(0);for(let e=0;e<4;++e)l.push(y[e]),u.push(g[e])}if(e.normal){const t=nn(p,n,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(m=nn(p,n,d,e.material)[0],m<0&&(h.negativeMaterialIndices=!0,m=0)),e.uv&&e.uv.forEach(function(e,t){const r=nn(p,n,d,e);void 0===c[t]&&(c[t]=[]),c[t].push(r[0]),c[t].push(r[1])}),r++,f&&(h.genFace(t,e,i,m,o,a,c,l,u,r),n++,r=0,i=[],o=[],a=[],c=[],l=[],u=[])}),t}getNormalNewell(e){const t=new Pe(0,0,0);for(let n=0;n<e.length;n++){const r=e[n],s=e[(n+1)%e.length];t.x+=(r.y-s.y)*(r.z+s.z),t.y+=(r.z-s.z)*(r.x+s.x),t.z+=(r.x-s.x)*(r.y+s.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){const t=this.getNormalNewell(e),n=(Math.abs(t.z)>.5?new Pe(0,1,0):new Pe(0,0,1)).cross(t).normalize(),r=t.clone().cross(n).normalize();return{normal:t,tangent:n,bitangent:r}}flattenVertex(e,t,n){return new Oe(e.dot(t),e.dot(n))}genFace(e,t,n,r,s,i,o,a,c,l){let u;if(l>3){const e=[],r=t.baseVertexPositions||t.vertexPositions;for(let t=0;t<n.length;t+=3)e.push(new Pe(r[n[t]],r[n[t+1]],r[n[t+2]]));const{tangent:s,bitangent:i}=this.getNormalTangentAndBitangent(e),o=[];for(const t of e)o.push(this.flattenVertex(t,s,i));u=ve.triangulateShape(o,[])}else u=[[0,1,2]];for(const[l,h,d]of u)e.vertex.push(t.vertexPositions[n[3*l]]),e.vertex.push(t.vertexPositions[n[3*l+1]]),e.vertex.push(t.vertexPositions[n[3*l+2]]),e.vertex.push(t.vertexPositions[n[3*h]]),e.vertex.push(t.vertexPositions[n[3*h+1]]),e.vertex.push(t.vertexPositions[n[3*h+2]]),e.vertex.push(t.vertexPositions[n[3*d]]),e.vertex.push(t.vertexPositions[n[3*d+1]]),e.vertex.push(t.vertexPositions[n[3*d+2]]),t.skeleton&&(e.vertexWeights.push(a[4*l]),e.vertexWeights.push(a[4*l+1]),e.vertexWeights.push(a[4*l+2]),e.vertexWeights.push(a[4*l+3]),e.vertexWeights.push(a[4*h]),e.vertexWeights.push(a[4*h+1]),e.vertexWeights.push(a[4*h+2]),e.vertexWeights.push(a[4*h+3]),e.vertexWeights.push(a[4*d]),e.vertexWeights.push(a[4*d+1]),e.vertexWeights.push(a[4*d+2]),e.vertexWeights.push(a[4*d+3]),e.weightsIndices.push(c[4*l]),e.weightsIndices.push(c[4*l+1]),e.weightsIndices.push(c[4*l+2]),e.weightsIndices.push(c[4*l+3]),e.weightsIndices.push(c[4*h]),e.weightsIndices.push(c[4*h+1]),e.weightsIndices.push(c[4*h+2]),e.weightsIndices.push(c[4*h+3]),e.weightsIndices.push(c[4*d]),e.weightsIndices.push(c[4*d+1]),e.weightsIndices.push(c[4*d+2]),e.weightsIndices.push(c[4*d+3])),t.color&&(e.colors.push(i[3*l]),e.colors.push(i[3*l+1]),e.colors.push(i[3*l+2]),e.colors.push(i[3*h]),e.colors.push(i[3*h+1]),e.colors.push(i[3*h+2]),e.colors.push(i[3*d]),e.colors.push(i[3*d+1]),e.colors.push(i[3*d+2])),t.material&&"AllSame"!==t.material.mappingType&&(e.materialIndex.push(r),e.materialIndex.push(r),e.materialIndex.push(r)),t.normal&&(e.normal.push(s[3*l]),e.normal.push(s[3*l+1]),e.normal.push(s[3*l+2]),e.normal.push(s[3*h]),e.normal.push(s[3*h+1]),e.normal.push(s[3*h+2]),e.normal.push(s[3*d]),e.normal.push(s[3*d+1]),e.normal.push(s[3*d+2])),t.uv&&t.uv.forEach(function(t,n){void 0===e.uvs[n]&&(e.uvs[n]=[]),e.uvs[n].push(o[n][2*l]),e.uvs[n].push(o[n][2*l+1]),e.uvs[n].push(o[n][2*h]),e.uvs[n].push(o[n][2*h+1]),e.uvs[n].push(o[n][2*d]),e.uvs[n].push(o[n][2*d+1])})}addMorphTargets(e,t,n,r){if(0===n.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;n.forEach(function(n){n.rawTargets.forEach(function(n){const i=Ht.Objects.Geometry[n.geoID];void 0!==i&&s.genMorphGeometry(e,t,i,r,n.name)})})}genMorphGeometry(e,t,n,r,s){const i=void 0!==t.Vertices?t.Vertices.a:[],o=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],a=void 0!==n.Vertices?n.Vertices.a:[],c=void 0!==n.Indexes?n.Indexes.a:[],l=3*e.attributes.position.count,u=new Float32Array(l);for(let e=0;e<c.length;e++){const t=3*c[e];u[t]=a[3*e],u[t+1]=a[3*e+1],u[t+2]=a[3*e+2]}const h={vertexIndices:o,vertexPositions:u,baseVertexPositions:i},d=this.genBuffers(h),p=new T(d.vertex,3);p.name=s||n.attrName,p.applyMatrix4(r),e.morphAttributes.position.push(p)}parseNormals(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Normals.a;let s=[];return"IndexToDirect"===n&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:r,indices:s,mappingType:t,referenceType:n}}parseUVs(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.UV.a;let s=[];return"IndexToDirect"===n&&(s=e.UVIndex.a),{dataSize:2,buffer:r,indices:s,mappingType:t,referenceType:n}}parseVertexColors(e){const t=e.MappingInformationType,n=e.ReferenceInformationType,r=e.Colors.a;let s=[];"IndexToDirect"===n&&(s=e.ColorIndex.a);for(let e=0,t=new d;e<r.length;e+=4)t.fromArray(r,e),p.colorSpaceToWorking(t,ge),t.toArray(r,e);return{dataSize:4,buffer:r,indices:s,mappingType:t,referenceType:n}}parseMaterialIndices(e){const t=e.MappingInformationType,n=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:n};const r=e.Materials.a,s=[];for(let e=0;e<r.length;++e)s.push(e);return{dataSize:1,buffer:r,indices:s,mappingType:t,referenceType:n}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return new l;const n=t-1,r=e.KnotVector.a,s=[],i=e.Points.a;for(let e=0,t=i.length;e<t;e+=4)s.push((new Ce).fromArray(i,e));let o,a;if("Closed"===e.Form)s.push(s[0]);else if("Periodic"===e.Form){o=n,a=r.length-1-o;for(let e=0;e<n;++e)s.push(s[e])}const c=new Vt(n,r,s,o,a).getPoints(12*s.length);return(new l).setFromPoints(c)}}class Qt{parse(){const e=[],t=this.parseClips();if(void 0!==t)for(const n in t){const r=t[n],s=this.addClip(r);e.push(s)}return e}parseClips(){if(void 0===Ht.Objects.AnimationCurve)return;const e=this.parseAnimationCurveNodes();this.parseAnimationCurves(e);const t=this.parseAnimationLayers(e);return this.parseAnimStacks(t)}parseAnimationCurveNodes(){const e=Ht.Objects.AnimationCurveNode,t=new Map;for(const n in e){const r=e[n];if(null!==r.attrName.match(/S|R|T|DeformPercent/)){const e={id:r.id,attr:r.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Ht.Objects.AnimationCurve;for(const n in t){const r={id:t[n].id,times:t[n].KeyTime.a.map(en),values:t[n].KeyValueFloat.a},s=jt.get(r.id);if(void 0!==s){const t=s.parents[0].ID,n=s.parents[0].relationship;n.match(/X/)?e.get(t).curves.x=r:n.match(/Y/)?e.get(t).curves.y=r:n.match(/Z/)?e.get(t).curves.z=r:n.match(/DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=r)}}}parseAnimationLayers(e){const t=Ht.Objects.AnimationLayer,n=new Map;for(const r in t){const t=[],s=jt.get(parseInt(r));if(void 0!==s){s.children.forEach(function(n,r){if(e.has(n.ID)){const s=e.get(n.ID);if(void 0!==s.curves.x||void 0!==s.curves.y||void 0!==s.curves.z){if(void 0===t[r]){const e=jt.get(n.ID).parents.filter(function(e){return void 0!==e.relationship})[0].ID;if(void 0!==e){const n=Ht.Objects.Model[e.toString()];if(void 0===n)return;const s={modelName:n.attrName?de.sanitizeNodeName(n.attrName):"",ID:n.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Gt.traverse(function(e){e.ID===n.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))}),s.transform||(s.transform=new G),"PreRotation"in n&&(s.preRotation=n.PreRotation.value),"PostRotation"in n&&(s.postRotation=n.PostRotation.value),t[r]=s}}t[r]&&(t[r][s.attr]=s)}else if(void 0!==s.curves.morph){if(void 0===t[r]){const e=jt.get(n.ID).parents.filter(function(e){return void 0!==e.relationship})[0].ID,s=jt.get(e).parents[0].ID,i=jt.get(s).parents[0].ID,o=jt.get(i).parents[0].ID,a=Ht.Objects.Model[o],c={modelName:a.attrName?de.sanitizeNodeName(a.attrName):"",morphName:Ht.Objects.Deformer[e].attrName};t[r]=c}t[r][s.attr]=s}}}),n.set(parseInt(r),t)}}return n}parseAnimStacks(e){const t=Ht.Objects.AnimationStack,n={};for(const r in t){const s=jt.get(parseInt(r)).children;s.length;const i=e.get(s[0].ID);n[r]={name:t[r].attrName,layer:i}}return n}addClip(e){let t=[];const r=this;return e.layer.forEach(function(e){t=t.concat(r.generateTracks(e))}),new n(e.name,-1,t)}generateTracks(e){const t=[];let n=new Pe,r=new Pe;if(e.transform&&e.transform.decompose(n,new pe,r),n=n.toArray(),r=r.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.T.curves,n,"position");void 0!==r&&t.push(r)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const n=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);void 0!==n&&t.push(n)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.S.curves,r,"scale");void 0!==n&&t.push(n)}if(void 0!==e.DeformPercent){const n=this.generateMorphTrack(e);void 0!==n&&t.push(n)}return t}generateVectorTrack(e,t,n,r){const s=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(s,t,n);return new Ne(e+"."+r,s,i)}generateRotationTrack(e,t,n,r,s){let i,o;if(void 0!==t.x&&void 0!==t.y&&void 0!==t.z){const e=this.interpolateRotations(t.x,t.y,t.z,s);i=e[0],o=e[1]}const a=an(0);void 0!==n&&((n=n.map(H.degToRad)).push(a),n=(new v).fromArray(n),n=(new pe).setFromEuler(n)),void 0!==r&&((r=r.map(H.degToRad)).push(a),r=(new v).fromArray(r),r=(new pe).setFromEuler(r).invert());const c=new pe,l=new v,u=[];if(!o||!i)return new me(e+".quaternion",[0],[0]);for(let e=0;e<o.length;e+=3){if(l.set(o[e],o[e+1],o[e+2],s),c.setFromEuler(l),void 0!==n&&c.premultiply(n),void 0!==r&&c.multiply(r),e>2){(new pe).fromArray(u,(e-3)/3*4).dot(c)<0&&c.set(-c.x,-c.y,-c.z,-c.w)}c.toArray(u,e/3*4)}return new me(e+".quaternion",i,u)}generateMorphTrack(e){const t=e.DeformPercent.curves.morph,n=t.values.map(function(e){return e/100}),r=Gt.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new se(e.modelName+".morphTargetInfluences["+r+"]",t.times,n)}getTimesForAllAxes(e){let t=[];if(void 0!==e.x&&(t=t.concat(e.x.times)),void 0!==e.y&&(t=t.concat(e.y.times)),void 0!==e.z&&(t=t.concat(e.z.times)),t=t.sort(function(e,t){return e-t}),t.length>1){let e=1,n=t[0];for(let r=1;r<t.length;r++){const s=t[r];s!==n&&(t[e]=s,n=s,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,n){const r=n,s=[];let i=-1,o=-1,a=-1;return e.forEach(function(e){if(t.x&&(i=t.x.times.indexOf(e)),t.y&&(o=t.y.times.indexOf(e)),t.z&&(a=t.z.times.indexOf(e)),-1!==i){const e=t.x.values[i];s.push(e),r[0]=e}else s.push(r[0]);if(-1!==o){const e=t.y.values[o];s.push(e),r[1]=e}else s.push(r[1]);if(-1!==a){const e=t.z.values[a];s.push(e),r[2]=e}else s.push(r[2])}),s}interpolateRotations(e,t,n,r){const s=[],i=[];s.push(e.times[0]),i.push(H.degToRad(e.values[0])),i.push(H.degToRad(t.values[0])),i.push(H.degToRad(n.values[0]));for(let o=1;o<e.values.length;o++){const a=[e.values[o-1],t.values[o-1],n.values[o-1]];if(isNaN(a[0])||isNaN(a[1])||isNaN(a[2]))continue;const c=a.map(H.degToRad),l=[e.values[o],t.values[o],n.values[o]];if(isNaN(l[0])||isNaN(l[1])||isNaN(l[2]))continue;const u=l.map(H.degToRad),h=[l[0]-a[0],l[1]-a[1],l[2]-a[2]],d=[Math.abs(h[0]),Math.abs(h[1]),Math.abs(h[2])];if(d[0]>=180||d[1]>=180||d[2]>=180){const t=Math.max(...d)/180,n=new v(...c,r),a=new v(...u,r),l=(new pe).setFromEuler(n),h=(new pe).setFromEuler(a);l.dot(h)&&h.set(-h.x,-h.y,-h.z,-h.w);const p=e.times[o-1],m=e.times[o]-p,f=new pe,g=new v;for(let e=0;e<1;e+=1/t)f.copy(l.clone().slerp(h.clone(),e)),s.push(p+e*m),g.setFromQuaternion(f,r),i.push(g.x),i.push(g.y),i.push(g.z)}else s.push(e.times[o]),i.push(H.degToRad(e.values[o])),i.push(H.degToRad(t.values[o])),i.push(H.degToRad(n.values[o]))}return[s,i]}}class qt{getPrevNode(){return this.nodeStack[this.currentIndent-2]}getCurrentNode(){return this.nodeStack[this.currentIndent-1]}getCurrentProp(){return this.currentProp}pushStack(e){this.nodeStack.push(e),this.currentIndent+=1}popStack(){this.nodeStack.pop(),this.currentIndent-=1}setCurrentProp(e,t){this.currentProp=e,this.currentPropName=t}parse(e){this.currentIndent=0,this.allNodes=new $t,this.nodeStack=[],this.currentProp=[],this.currentPropName="";const t=this,n=e.split(/[\r\n]+/);return n.forEach(function(e,r){const s=e.match(/^[\s\t]*;/),i=e.match(/^[\s\t]*$/);if(s||i)return;const o=e.match("^\\t{"+t.currentIndent+"}(\\w+):(.*){",""),a=e.match("^\\t{"+t.currentIndent+"}(\\w+):[\\s\\t\\r\\n](.*)"),c=e.match("^\\t{"+(t.currentIndent-1)+"}}");o?t.parseNodeBegin(e,o):a?t.parseNodeProperty(e,a,n[++r]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){const n=t[1].trim().replace(/^"/,"").replace(/"$/,""),r=t[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:n},i=this.parseNodeAttr(r),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(n,s):n in o?("PoseNode"===n?o.PoseNode.push(s):void 0!==o[n].id&&(o[n]={},o[n][o[n].id]=o[n]),""!==i.id&&(o[n][i.id]=s)):"number"==typeof i.id?(o[n]={},o[n][i.id]=s):"Properties70"!==n&&(o[n]="PoseNode"===n?[s]:s),"number"==typeof i.id&&(s.id=i.id),""!==i.name&&(s.attrName=i.name),""!==i.type&&(s.attrType=i.type),this.pushStack(s)}parseNodeAttr(e){let t=e[0];""!==e[0]&&(t=parseInt(e[0]),isNaN(t)&&(t=e[0]));let n="",r="";return e.length>1&&(n=e[1].replace(/^(\w+)::/,""),r=e[2]),{id:t,name:n,type:r}}parseNodeProperty(e,t,n){let r=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===r&&","===s&&(s=n.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if("Properties70"!==i.name){if("C"===r){const e=s.split(",").slice(1),t=parseInt(e[0]),n=parseInt(e[1]);let o=s.split(",").slice(3);o=o.map(function(e){return e.trim().replace(/^"/,"")}),r="connections",s=[t,n],function(e,t){for(let n=0,r=e.length,s=t.length;n<s;n++,r++)e[r]=t[n]}(s,o),void 0===i[r]&&(i[r]=[])}"Node"===r&&(i.id=s),r in i&&Array.isArray(i[r])?i[r].push(s):"a"!==r?i[r]=s:i.a=s,this.setCurrentProp(i,r),"a"===r&&","!==s.slice(-1)&&(i.a=cn(s))}else this.parseNodeSpecialProperty(e,r,s)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=cn(t.a))}parseNodeSpecialProperty(e,t,n){const r=n.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=r[0],i=r[1],o=r[2],a=r[3];let c=r[4];switch(i){case"int":case"enum":case"bool":case"ULongLong":case"double":case"Number":case"FieldOfView":c=parseFloat(c);break;case"Color":case"ColorRGB":case"Vector3D":case"Lcl_Translation":case"Lcl_Rotation":case"Lcl_Scaling":c=cn(c)}this.getPrevNode()[s]={type:i,type2:o,flag:a,value:c},this.setCurrentProp(this.getPrevNode(),s)}}class Yt{parse(e){const t=new Zt(e);t.skip(23);const n=t.getUint32();if(n<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+n);const r=new $t;for(;!this.endOfContent(t);){const e=this.parseNode(t,n);null!==e&&r.add(e.name,e)}return r}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const n={},r=t>=7500?e.getUint64():e.getUint32(),s=t>=7500?e.getUint64():e.getUint32();t>=7500?e.getUint64():e.getUint32();const i=e.getUint8(),o=e.getString(i);if(0===r)return null;const a=[];for(let t=0;t<s;t++)a.push(this.parseProperty(e));const c=a.length>0?a[0]:"",l=a.length>1?a[1]:"",u=a.length>2?a[2]:"";for(n.singleProperty=1===s&&e.getOffset()===r;r>e.getOffset();){const r=this.parseNode(e,t);null!==r&&this.parseSubNode(o,n,r)}return n.propertyList=a,"number"==typeof c&&(n.id=c),""!==l&&(n.attrName=l),""!==u&&(n.attrType=u),""!==o&&(n.name=o),n}parseSubNode(e,t,n){if(!0===n.singleProperty){const e=n.propertyList[0];Array.isArray(e)?(t[n.name]=n,n.a=e):t[n.name]=e}else if("Connections"===e&&"C"===n.name){const e=[];n.propertyList.forEach(function(t,n){0!==n&&e.push(t)}),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===n.name){Object.keys(n).forEach(function(e){t[e]=n[e]})}else if("Properties70"===e&&"P"===n.name){let e=n.propertyList[0],r=n.propertyList[1];const s=n.propertyList[2],i=n.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===r.indexOf("Lcl ")&&(r=r.replace("Lcl ","Lcl_")),o="Color"===r||"ColorRGB"===r||"Vector"===r||"Vector3D"===r||0===r.indexOf("Lcl_")?[n.propertyList[4],n.propertyList[5],n.propertyList[6]]:n.propertyList[4],t[e]={type:r,type2:s,flag:i,value:o}}else void 0===t[n.name]?"number"==typeof n.id?(t[n.name]={},t[n.name][n.id]=n):t[n.name]=n:"PoseNode"===n.name?(Array.isArray(t[n.name])||(t[n.name]=[t[n.name]]),t[n.name].push(n)):void 0===t[n.name][n.id]&&(t[n.name][n.id]=n)}parseProperty(e){const t=e.getString(1);let n;switch(t){case"C":return e.getBoolean();case"D":return e.getFloat64();case"F":return e.getFloat32();case"I":return e.getInt32();case"L":return e.getInt64();case"R":return n=e.getUint32(),e.getArrayBuffer(n);case"S":return n=e.getUint32(),e.getString(n);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const r=e.getUint32(),s=e.getUint32(),i=e.getUint32();if(0===s)switch(t){case"b":case"c":return e.getBooleanArray(r);case"d":return e.getFloat64Array(r);case"f":return e.getFloat32Array(r);case"i":return e.getInt32Array(r);case"l":return e.getInt64Array(r)}const o=kt(new Uint8Array(e.getArrayBuffer(i))),a=new Zt(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(r);case"d":return a.getFloat64Array(r);case"f":return a.getFloat32Array(r);case"i":return a.getInt32Array(r);case"l":return a.getInt64Array(r)}break;default:throw new Error("THREE.FBXLoader: Unknown property type "+t)}}}class Zt{constructor(e,t){this.dv=new DataView(e),this.offset=0,this.littleEndian=void 0===t||t,this._textDecoder=new TextDecoder}getOffset(){return this.offset}size(){return this.dv.buffer.byteLength}skip(e){this.offset+=e}getBoolean(){return!(1&~this.getUint8())}getBooleanArray(e){const t=[];for(let n=0;n<e;n++)t.push(this.getBoolean());return t}getUint8(){const e=this.dv.getUint8(this.offset);return this.offset+=1,e}getInt16(){const e=this.dv.getInt16(this.offset,this.littleEndian);return this.offset+=2,e}getInt32(){const e=this.dv.getInt32(this.offset,this.littleEndian);return this.offset+=4,e}getInt32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt32());return t}getUint32(){const e=this.dv.getUint32(this.offset,this.littleEndian);return this.offset+=4,e}getInt64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),2147483648&t?(t=4294967295&~t,e=4294967295&~e,4294967295===e&&(t=t+1&4294967295),e=e+1&4294967295,-(4294967296*t+e)):4294967296*t+e}getInt64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getInt64());return t}getUint64(){let e,t;return this.littleEndian?(e=this.getUint32(),t=this.getUint32()):(t=this.getUint32(),e=this.getUint32()),4294967296*t+e}getFloat32(){const e=this.dv.getFloat32(this.offset,this.littleEndian);return this.offset+=4,e}getFloat32Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat32());return t}getFloat64(){const e=this.dv.getFloat64(this.offset,this.littleEndian);return this.offset+=8,e}getFloat64Array(e){const t=[];for(let n=0;n<e;n++)t.push(this.getFloat64());return t}getArrayBuffer(e){const t=this.dv.buffer.slice(this.offset,this.offset+e);return this.offset+=e,t}getString(e){const t=this.offset;let n=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const r=n.indexOf(0);return r>=0&&(n=new Uint8Array(this.dv.buffer,t,r)),this._textDecoder.decode(n)}}class $t{add(e,t){this[e]=t}}function Jt(e){const t=e.match(/FBXVersion: (\d+)/);if(t){return parseInt(t[1])}throw new Error("THREE.FBXLoader: Cannot find the version number for the file given.")}function en(e){return e/46186158e3}const tn=[];function nn(e,t,n,r){let s;switch(r.mappingType){case"ByPolygonVertex":s=e;break;case"ByPolygon":s=t;break;case"ByVertice":s=n;break;case"AllSame":s=r.indices[0]}"IndexToDirect"===r.referenceType&&(s=r.indices[s]);const i=s*r.dataSize,o=i+r.dataSize;return function(e,t,n,r){for(let s=n,i=0;s<r;s++,i++)e[i]=t[s];return e}(tn,r.buffer,i,o)}const rn=new v,sn=new Pe;function on(e){const t=new G,n=new G,r=new G,s=new G,i=new G,o=new G,a=new G,c=new G,l=new G,u=new G,h=new G,d=new G,p=e.inheritType?e.inheritType:0;e.translation&&t.setPosition(sn.fromArray(e.translation));const m=an(0);if(e.preRotation){const t=e.preRotation.map(H.degToRad);t.push(m),n.makeRotationFromEuler(rn.fromArray(t))}if(e.rotation){const t=e.rotation.map(H.degToRad);t.push(e.eulerOrder||m),r.makeRotationFromEuler(rn.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(H.degToRad);t.push(m),s.makeRotationFromEuler(rn.fromArray(t)),s.invert()}e.scale&&i.scale(sn.fromArray(e.scale)),e.scalingOffset&&a.setPosition(sn.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(sn.fromArray(e.scalingPivot)),e.rotationOffset&&c.setPosition(sn.fromArray(e.rotationOffset)),e.rotationPivot&&l.setPosition(sn.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(h.copy(e.parentMatrix),u.copy(e.parentMatrixWorld));const f=n.clone().multiply(r).multiply(s),g=new G;g.extractRotation(u);const y=new G;y.copyPosition(u);const v=y.clone().invert().multiply(u),x=g.clone().invert().multiply(v),T=i,w=new G;if(0===p)w.copy(g).multiply(f).multiply(x).multiply(T);else if(1===p)w.copy(g).multiply(x).multiply(f).multiply(T);else{const e=(new G).scale((new Pe).setFromMatrixScale(h)).clone().invert(),t=x.clone().multiply(e);w.copy(g).multiply(f).multiply(t).multiply(T)}const I=l.clone().invert(),b=o.clone().invert();let A=t.clone().multiply(c).multiply(l).multiply(n).multiply(r).multiply(s).multiply(I).multiply(a).multiply(o).multiply(i).multiply(b);const R=(new G).copyPosition(A),M=u.clone().multiply(R);return d.copyPosition(M),A=d.clone().multiply(w),A.premultiply(u.invert()),A}function an(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?t[0]:t[e]}function cn(e){return e.split(",").map(function(e){return parseFloat(e)})}function ln(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,n))}function un(e,t){if(t===_e)return e;if(t===Se||t===Ee){let n=e.getIndex();if(null===n){const t=[],r=e.getAttribute("position");if(void 0===r)return e;for(let e=0;e<r.count;e++)t.push(e);e.setIndex(t),n=e.getIndex()}const r=n.count-2,s=[];if(t===Se)for(let e=1;e<=r;e++)s.push(n.getX(0)),s.push(n.getX(e)),s.push(n.getX(e+1));else for(let e=0;e<r;e++)e%2==0?(s.push(n.getX(e)),s.push(n.getX(e+1)),s.push(n.getX(e+2))):(s.push(n.getX(e+2)),s.push(n.getX(e+1)),s.push(n.getX(e)));s.length;const i=e.clone();return i.setIndex(s),i.clearGroups(),i}return e}function hn(){let e={};return{get:function(t){return e[t]},add:function(t,n){e[t]=n},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const dn={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 pn{constructor(e){this.parser=e,this.name=dn.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n];r.extensions&&r.extensions[this.name]&&void 0!==r.extensions[this.name].light&&e._addNodeRef(this.cache,r.extensions[this.name].light)}}_loadLight(e){const t=this.parser,n="light:"+e;let r=t.cache.get(n);if(r)return r;const s=t.json,i=((s.extensions&&s.extensions[this.name]||{}).lights||[])[e];let o;const a=new d(16777215);void 0!==i.color&&a.setRGB(i.color[0],i.color[1],i.color[2],U);const c=void 0!==i.range?i.range:0;switch(i.type){case"directional":o=new f(a),o.target.position.set(0,0,-1),o.add(o.target);break;case"point":o=new ce(a),o.distance=c;break;case"spot":o=new be(a),o.distance=c,i.spot=i.spot||{},i.spot.innerConeAngle=void 0!==i.spot.innerConeAngle?i.spot.innerConeAngle:0,i.spot.outerConeAngle=void 0!==i.spot.outerConeAngle?i.spot.outerConeAngle:Math.PI/4,o.angle=i.spot.outerConeAngle,o.penumbra=1-i.spot.innerConeAngle/i.spot.outerConeAngle,o.target.position.set(0,0,-1),o.add(o.target);break;default:throw new Error("THREE.GLTFLoader: Unexpected light type: "+i.type)}return o.position.set(0,0,0),er(o,i),void 0!==i.intensity&&(o.intensity=i.intensity),o.name=t.createUniqueName(i.name||"light_"+e),r=Promise.resolve(o),t.cache.add(n,r),r}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,n=this.parser,r=n.json.nodes[e],s=(r.extensions&&r.extensions[this.name]||{}).light;return void 0===s?null:this._loadLight(s).then(function(e){return n._getNodeRef(t.cache,s,e)})}}class mn{constructor(){this.name=dn.KHR_MATERIALS_UNLIT}getMaterialType(){return W}extendParams(e,t,n){const r=[];e.color=new d(1,1,1),e.opacity=1;const s=t.pbrMetallicRoughness;if(s){if(Array.isArray(s.baseColorFactor)){const t=s.baseColorFactor;e.color.setRGB(t[0],t[1],t[2],U),e.opacity=t[3]}void 0!==s.baseColorTexture&&r.push(n.assignTexture(e,"map",s.baseColorTexture,ge))}return Promise.all(r)}}class fn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name].emissiveStrength;return void 0!==r&&(t.emissiveIntensity=r),Promise.resolve()}}class gn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_CLEARCOAT}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&s.push(n.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&s.push(n.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(s.push(n.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Oe(e,e)}return Promise.all(s)}}class yn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_DISPERSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.dispersion=void 0!==r.dispersion?r.dispersion:0,Promise.resolve()}}class vn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_IRIDESCENCE}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&s.push(n.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&&s.push(n.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}}class xn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_SHEEN}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new d(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=r.extensions[this.name];if(void 0!==i.sheenColorFactor){const e=i.sheenColorFactor;t.sheenColor.setRGB(e[0],e[1],e[2],U)}return void 0!==i.sheenRoughnessFactor&&(t.sheenRoughness=i.sheenRoughnessFactor),void 0!==i.sheenColorTexture&&s.push(n.assignTexture(t,"sheenColorMap",i.sheenColorTexture,ge)),void 0!==i.sheenRoughnessTexture&&s.push(n.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class Tn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_TRANSMISSION}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&s.push(n.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}}class wn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_VOLUME}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&s.push(n.assignTexture(t,"thicknessMap",i.thicknessTexture)),t.attenuationDistance=i.attenuationDistance||1/0;const o=i.attenuationColor||[1,1,1];return t.attenuationColor=(new d).setRGB(o[0],o[1],o[2],U),Promise.all(s)}}class In{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_IOR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const r=n.extensions[this.name];return t.ior=void 0!==r.ior?r.ior:1.5,Promise.resolve()}}class bn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_SPECULAR}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&s.push(n.assignTexture(t,"specularIntensityMap",i.specularTexture));const o=i.specularColorFactor||[1,1,1];return t.specularColor=(new d).setRGB(o[0],o[1],o[2],U),void 0!==i.specularColorTexture&&s.push(n.assignTexture(t,"specularColorMap",i.specularColorTexture,ge)),Promise.all(s)}}class An{constructor(e){this.parser=e,this.name=dn.EXT_MATERIALS_BUMP}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&s.push(n.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}}class Rn{constructor(e){this.parser=e,this.name=dn.KHR_MATERIALS_ANISOTROPY}getMaterialType(e){const t=this.parser.json.materials[e];return t.extensions&&t.extensions[this.name]?q:null}extendMaterialParams(e,t){const n=this.parser,r=n.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const s=[],i=r.extensions[this.name];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&s.push(n.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}}class Mn{constructor(e){this.parser=e,this.name=dn.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,n=t.json,r=n.textures[e];if(!r.extensions||!r.extensions[this.name])return null;const s=r.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(n.extensionsRequired&&n.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");return null}return t.loadTextureImage(e,s.source,i)}}class Sn{constructor(e){this.parser=e,this.name=dn.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],o=r.images[i.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return n.loadTextureImage(e,i.source,a)}}class En{constructor(e){this.parser=e,this.name=dn.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,n=this.parser,r=n.json,s=r.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],o=r.images[i.source];let a=n.textureLoader;if(o.uri){const e=n.options.manager.getHandler(o.uri);null!==e&&(a=e)}return n.loadTextureImage(e,i.source,a)}}class _n{constructor(e){this.name=dn.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,n=t.bufferViews[e];if(n.extensions&&n.extensions[this.name]){const e=n.extensions[this.name],r=this.parser.getDependency("buffer",e.buffer),s=this.parser.options.meshoptDecoder;if(!s||!s.supported){if(t.extensionsRequired&&t.extensionsRequired.indexOf(this.name)>=0)throw new Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");return null}return r.then(function(t){const n=e.byteOffset||0,r=e.byteLength||0,i=e.count,o=e.byteStride,a=new Uint8Array(t,n,r);return s.decodeGltfBufferAsync?s.decodeGltfBufferAsync(i,o,a,e.mode,e.filter).then(function(e){return e.buffer}):s.ready.then(function(){const t=new ArrayBuffer(i*o);return s.decodeGltfBuffer(new Uint8Array(t),i,o,a,e.mode,e.filter),t})})}return null}}class Ln{constructor(e){this.name=dn.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,n=t.nodes[e];if(!n.extensions||!n.extensions[this.name]||void 0===n.mesh)return null;const r=t.meshes[n.mesh];for(const e of r.primitives)if(e.mode!==Vn.TRIANGLES&&e.mode!==Vn.TRIANGLE_STRIP&&e.mode!==Vn.TRIANGLE_FAN&&void 0!==e.mode)return null;const s=n.extensions[this.name].attributes,i=[],o={};for(const e in s)i.push(this.parser.getDependency("accessor",s[e]).then(t=>(o[e]=t,o[e])));return i.length<1?null:(i.push(this.parser.createNodeMesh(e)),Promise.all(i).then(e=>{const t=e.pop(),n=t.isGroup?t.children:[t],r=e[0].count,s=[];for(const e of n){const t=new G,n=new Pe,i=new pe,a=new Pe(1,1,1),c=new R(e.geometry,e.material,r);for(let e=0;e<r;e++)o.TRANSLATION&&n.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&i.fromBufferAttribute(o.ROTATION,e),o.SCALE&&a.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(n,i,a));for(const t in o)if("_COLOR_0"===t){const e=o[t];c.instanceColor=new A(e.array,e.itemSize,e.normalized)}else"TRANSLATION"!==t&&"ROTATION"!==t&&"SCALE"!==t&&e.geometry.setAttribute(t,o[t]);ie.prototype.copy.call(c,e),this.parser.assignFinalMaterial(c),s.push(c)}return t.isGroup?(t.clear(),t.add(...s),t):s[0]}))}}const On="glTF",Pn=1313821514,Cn=5130562;class Nn{constructor(e){this.name=dn.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),n=new TextDecoder;if(this.header={magic:n.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==On)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const r=this.header.length-12,s=new DataView(e,12);let i=0;for(;i<r;){const t=s.getUint32(i,!0);i+=4;const r=s.getUint32(i,!0);if(i+=4,r===Pn){const r=new Uint8Array(e,12+i,t);this.content=n.decode(r)}else if(r===Cn){const n=12+i;this.body=e.slice(n,n+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class kn{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=dn.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const n=this.json,r=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},a={},c={};for(const e in i){const t=Wn[e]||e.toLowerCase();o[t]=i[e]}for(const t in e.attributes){const r=Wn[t]||t.toLowerCase();if(void 0!==i[t]){const s=n.accessors[e.attributes[t]],i=Hn[s.componentType];c[r]=i.name,a[r]=!0===s.normalized}}return t.getDependency("bufferView",s).then(function(e){return new Promise(function(t,n){r.decodeDracoFile(e,function(e){for(const t in e.attributes){const n=e.attributes[t],r=a[t];void 0!==r&&(n.normalized=r)}t(e)},o,c,U,n)})})}}class Dn{constructor(){this.name=dn.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):e}}class Fn{constructor(){this.name=dn.KHR_MESH_QUANTIZATION}}class Un extends E{constructor(e,t,n,r){super(e,t,n,r)}copySampleValue_(e){const t=this.resultBuffer,n=this.sampleValues,r=this.valueSize,s=e*r*3+r;for(let e=0;e!==r;e++)t[e]=n[s+e];return t}interpolate_(e,t,n,r){const s=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,l=r-t,u=(n-t)/l,h=u*u,d=h*u,p=e*c,m=p-c,f=-2*d+3*h,g=d-h,y=1-f,v=g-h+u;for(let e=0;e!==o;e++){const t=i[m+e+o],n=i[m+e+a]*l,r=i[p+e+o],c=i[p+e]*l;s[e]=y*t+v*n+f*r+g*c}return s}}const zn=new pe;class Bn extends Un{interpolate_(e,t,n,r){const s=super.interpolate_(e,t,n,r);return zn.fromArray(s).normalize().toArray(s),s}}const Vn={FLOAT:5126,FLOAT_MAT3:35675,FLOAT_MAT4:35676,FLOAT_VEC2:35664,FLOAT_VEC3:35665,FLOAT_VEC4:35666,LINEAR:9729,REPEAT:10497,SAMPLER_2D:35678,POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6,UNSIGNED_BYTE:5121,UNSIGNED_SHORT:5123},Hn={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},jn={9728:J,9729:k,9984:te,9985:F,9986:ee,9987:D},Gn={33071:h,33648:Z,10497:fe},Kn={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Wn={POSITION:"position",NORMAL:"normal",TANGENT:"tangent",TEXCOORD_0:"uv",TEXCOORD_1:"uv1",TEXCOORD_2:"uv2",TEXCOORD_3:"uv3",COLOR_0:"color",WEIGHTS_0:"skinWeight",JOINTS_0:"skinIndex"},Xn={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Qn={CUBICSPLINE:void 0,LINEAR:L,STEP:_},qn="OPAQUE",Yn="MASK",Zn="BLEND";function $n(e){return void 0===e.DefaultMaterial&&(e.DefaultMaterial=new Y({color:16777215,emissive:0,metalness:1,roughness:1,transparent:!1,depthTest:!0,side:w})),e.DefaultMaterial}function Jn(e,t,n){for(const r in n.extensions)void 0===e[r]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[r]=n.extensions[r])}function er(e,t){void 0!==t.extras&&"object"==typeof t.extras&&Object.assign(e.userData,t.extras)}function tr(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let n=0,r=t.weights.length;n<r;n++)e.morphTargetInfluences[n]=t.weights[n];if(t.extras&&Array.isArray(t.extras.targetNames)){const n=t.extras.targetNames;if(e.morphTargetInfluences.length===n.length){e.morphTargetDictionary={};for(let t=0,r=n.length;t<r;t++)e.morphTargetDictionary[n[t]]=t}}}function nr(e){let t;const n=e.extensions&&e.extensions[dn.KHR_DRACO_MESH_COMPRESSION];if(t=n?"draco:"+n.bufferView+":"+n.indices+":"+rr(n.attributes):e.indices+":"+rr(e.attributes)+":"+e.mode,void 0!==e.targets)for(let n=0,r=e.targets.length;n<r;n++)t+=":"+rr(e.targets[n]);return t}function rr(e){let t="";const n=Object.keys(e).sort();for(let r=0,s=n.length;r<s;r++)t+=n[r]+":"+e[n[r]]+";";return t}function sr(e){switch(e){case Int8Array:return 1/127;case Uint8Array:return 1/255;case Int16Array:return 1/32767;case Uint16Array:return 1/65535;default:throw new Error("THREE.GLTFLoader: Unsupported normalized accessor component type.")}}const ir=new G;class or{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new hn,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 n=!1,r=-1,s=!1,i=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;n=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);r=n&&t?parseInt(t[1],10):-1,s=e.indexOf("Firefox")>-1,i=s?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||n&&r<17||s&&i<98?this.textureLoader=new Me(this.options.manager):this.textureLoader=new b(this.options.manager),this.textureLoader.setCrossOrigin(this.options.crossOrigin),this.textureLoader.setRequestHeader(this.options.requestHeader),this.fileLoader=new x(this.options.manager),this.fileLoader.setResponseType("arraybuffer"),"use-credentials"===this.options.crossOrigin&&this.fileLoader.setWithCredentials(!0)}setExtensions(e){this.extensions=e}setPlugins(e){this.plugins=e}parse(e,t){const n=this,r=this.json,s=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([n.getDependencies("scene"),n.getDependencies("animation"),n.getDependencies("camera")])}).then(function(t){const i={scene:t[0][r.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:r.asset,parser:n,userData:{}};return Jn(s,i,r),er(i,r),Promise.all(n._invokeAll(function(e){return e.afterRoot&&e.afterRoot(i)})).then(function(){for(const e of i.scenes)e.updateMatrixWorld();e(i)})}).catch(t)}_markDefs(){const e=this.json.nodes||[],t=this.json.skins||[],n=this.json.meshes||[];for(let n=0,r=t.length;n<r;n++){const r=t[n].joints;for(let t=0,n=r.length;t<n;t++)e[r[t]].isBone=!0}for(let t=0,r=e.length;t<r;t++){const r=e[t];void 0!==r.mesh&&(this._addNodeRef(this.meshCache,r.mesh),void 0!==r.skin&&(n[r.mesh].isSkinnedMesh=!0)),void 0!==r.camera&&this._addNodeRef(this.cameraCache,r.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,n){if(e.refs[t]<=1)return n;const r=n.clone(),s=(e,t)=>{const n=this.associations.get(e);null!=n&&this.associations.set(t,n);for(const[n,r]of e.children.entries())s(r,t.children[n])};return s(n,r),r.name+="_instance_"+e.uses[t]++,r}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let n=0;n<t.length;n++){const r=e(t[n]);if(r)return r}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const n=[];for(let r=0;r<t.length;r++){const s=e(t[r]);s&&n.push(s)}return n}getDependency(e,t){const n=e+":"+t;let r=this.cache.get(n);if(!r){switch(e){case"scene":r=this.loadScene(t);break;case"node":r=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":r=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":r=this.loadAccessor(t);break;case"bufferView":r=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":r=this.loadBuffer(t);break;case"material":r=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":r=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":r=this.loadSkin(t);break;case"animation":r=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":r=this.loadCamera(t);break;default:if(r=this._invokeOne(function(n){return n!=this&&n.getDependency&&n.getDependency(e,t)}),!r)throw new Error("Unknown type: "+e)}this.cache.add(n,r)}return r}getDependencies(e){let t=this.cache.get(e);if(!t){const n=this,r=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(r.map(function(t,r){return n.getDependency(e,r)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],n=this.fileLoader;if(t.type&&"arraybuffer"!==t.type)throw new Error("THREE.GLTFLoader: "+t.type+" buffer type is not supported.");if(void 0===t.uri&&0===e)return Promise.resolve(this.extensions[dn.KHR_BINARY_GLTF].body);const r=this.options;return new Promise(function(e,s){n.load(B.resolveURL(t.uri,r.path),e,void 0,function(){s(new Error('THREE.GLTFLoader: Failed to load buffer "'+t.uri+'".'))})})}loadBufferView(e){const t=this.json.bufferViews[e];return this.getDependency("buffer",t.buffer).then(function(e){const n=t.byteLength||0,r=t.byteOffset||0;return e.slice(r,r+n)})}loadAccessor(e){const t=this,n=this.json,r=this.json.accessors[e];if(void 0===r.bufferView&&void 0===r.sparse){const e=Kn[r.type],t=Hn[r.componentType],n=!0===r.normalized,s=new t(r.count*e);return Promise.resolve(new c(s,e,n))}const s=[];return void 0!==r.bufferView?s.push(this.getDependency("bufferView",r.bufferView)):s.push(null),void 0!==r.sparse&&(s.push(this.getDependency("bufferView",r.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",r.sparse.values.bufferView))),Promise.all(s).then(function(e){const s=e[0],i=Kn[r.type],o=Hn[r.componentType],a=o.BYTES_PER_ELEMENT,l=a*i,u=r.byteOffset||0,h=void 0!==r.bufferView?n.bufferViews[r.bufferView].byteStride:void 0,d=!0===r.normalized;let p,m;if(h&&h!==l){const e=Math.floor(u/h),n="InterleavedBuffer:"+r.bufferView+":"+r.componentType+":"+e+":"+r.count;let c=t.cache.get(n);c||(p=new o(s,e*h,r.count*h/a),c=new M(p,h/a),t.cache.add(n,c)),m=new S(c,i,u%h/a,d)}else p=null===s?new o(r.count*i):new o(s,u,r.count*i),m=new c(p,i,d);if(void 0!==r.sparse){const t=Kn.SCALAR,n=Hn[r.sparse.indices.componentType],a=r.sparse.indices.byteOffset||0,l=r.sparse.values.byteOffset||0,u=new n(e[1],a,r.sparse.count*t),h=new o(e[2],l,r.sparse.count*i);null!==s&&(m=new c(m.array.slice(),m.itemSize,m.normalized)),m.normalized=!1;for(let e=0,t=u.length;e<t;e++){const t=u[e];if(m.setX(t,h[e*i]),i>=2&&m.setY(t,h[e*i+1]),i>=3&&m.setZ(t,h[e*i+2]),i>=4&&m.setW(t,h[e*i+3]),i>=5)throw new Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.")}m.normalized=d}return m})}loadTexture(e){const t=this.json,n=this.options,r=t.textures[e].source,s=t.images[r];let i=this.textureLoader;if(s.uri){const e=n.manager.getHandler(s.uri);null!==e&&(i=e)}return this.loadTextureImage(e,r,i)}loadTextureImage(e,t,n){const r=this,s=this.json,i=s.textures[e],o=s.images[t],a=(o.uri||o.bufferView)+":"+i.sampler;if(this.textureCache[a])return this.textureCache[a];const c=this.loadImageSource(t,n).then(function(t){t.flipY=!1,t.name=i.name||o.name||"",""===t.name&&"string"==typeof o.uri&&!1===o.uri.startsWith("data:image/")&&(t.name=o.uri);const n=(s.samplers||{})[i.sampler]||{};return t.magFilter=jn[n.magFilter]||k,t.minFilter=jn[n.minFilter]||D,t.wrapS=Gn[n.wrapS]||fe,t.wrapT=Gn[n.wrapT]||fe,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==J&&t.minFilter!==k,r.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const n=this,r=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const i=r.images[e],o=self.URL||self.webkitURL;let a=i.uri||"",c=!1;if(void 0!==i.bufferView)a=n.getDependency("bufferView",i.bufferView).then(function(e){c=!0;const t=new Blob([e],{type:i.mimeType});return a=o.createObjectURL(t),a});else if(void 0===i.uri)throw new Error("THREE.GLTFLoader: Image "+e+" is missing URI and bufferView");const l=Promise.resolve(a).then(function(e){return new Promise(function(n,r){let i=n;!0===t.isImageBitmapLoader&&(i=function(e){const t=new Re(e);t.needsUpdate=!0,n(t)}),t.load(B.resolveURL(e,s.path),i,void 0,r)})}).then(function(e){var t;return!0===c&&o.revokeObjectURL(a),er(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":t.search(/\.ktx2($|\?)/i)>0||0===t.search(/^data\:image\/ktx2/)?"image/ktx2":"image/png"),e}).catch(function(e){throw e});return this.sourceCache[e]=l,l}assignTexture(e,t,n,r){const s=this;return this.getDependency("texture",n.index).then(function(i){if(!i)return null;if(void 0!==n.texCoord&&n.texCoord>0&&((i=i.clone()).channel=n.texCoord),s.extensions[dn.KHR_TEXTURE_TRANSFORM]){const e=void 0!==n.extensions?n.extensions[dn.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=s.associations.get(i);i=s.extensions[dn.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),s.associations.set(i,t)}}return void 0!==r&&(i.colorSpace=r),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let n=e.material;const r=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,i=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new ue,V.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,t.sizeAttenuation=!1,this.cache.add(e,t)),n=t}else if(e.isLine){const e="LineBasicMaterial:"+n.uuid;let t=this.cache.get(e);t||(t=new P,V.prototype.copy.call(t,n),t.color.copy(n.color),t.map=n.map,this.cache.add(e,t)),n=t}if(r||s||i){let e="ClonedMaterial:"+n.uuid+":";r&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),i&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=n.clone(),s&&(t.vertexColors=!0),i&&(t.flatShading=!0),r&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(n))),n=t}e.material=n}getMaterialType(){return Y}loadMaterial(e){const t=this,n=this.json,r=this.extensions,s=n.materials[e];let i;const o={},a=[];if((s.extensions||{})[dn.KHR_MATERIALS_UNLIT]){const e=r[dn.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),a.push(e.extendParams(o,s,t))}else{const n=s.pbrMetallicRoughness||{};if(o.color=new d(1,1,1),o.opacity=1,Array.isArray(n.baseColorFactor)){const e=n.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],U),o.opacity=e[3]}void 0!==n.baseColorTexture&&a.push(t.assignTexture(o,"map",n.baseColorTexture,ge)),o.metalness=void 0!==n.metallicFactor?n.metallicFactor:1,o.roughness=void 0!==n.roughnessFactor?n.roughnessFactor:1,void 0!==n.metallicRoughnessTexture&&(a.push(t.assignTexture(o,"metalnessMap",n.metallicRoughnessTexture)),a.push(t.assignTexture(o,"roughnessMap",n.metallicRoughnessTexture))),i=this._invokeOne(function(t){return t.getMaterialType&&t.getMaterialType(e)}),a.push(Promise.all(this._invokeAll(function(t){return t.extendMaterialParams&&t.extendMaterialParams(e,o)})))}!0===s.doubleSided&&(o.side=g);const c=s.alphaMode||qn;if(c===Zn?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===Yn&&(o.alphaTest=void 0!==s.alphaCutoff?s.alphaCutoff:.5)),void 0!==s.normalTexture&&i!==W&&(a.push(t.assignTexture(o,"normalMap",s.normalTexture)),o.normalScale=new Oe(1,1),void 0!==s.normalTexture.scale)){const e=s.normalTexture.scale;o.normalScale.set(e,e)}if(void 0!==s.occlusionTexture&&i!==W&&(a.push(t.assignTexture(o,"aoMap",s.occlusionTexture)),void 0!==s.occlusionTexture.strength&&(o.aoMapIntensity=s.occlusionTexture.strength)),void 0!==s.emissiveFactor&&i!==W){const e=s.emissiveFactor;o.emissive=(new d).setRGB(e[0],e[1],e[2],U)}return void 0!==s.emissiveTexture&&i!==W&&a.push(t.assignTexture(o,"emissiveMap",s.emissiveTexture,ge)),Promise.all(a).then(function(){const n=new i(o);return s.name&&(n.name=s.name),er(n,s),t.associations.set(n,{materials:e}),s.extensions&&Jn(r,n,s),n})}createUniqueName(e){const t=de.sanitizeNodeName(e||"");return t in this.nodeNamesUsed?t+"_"+ ++this.nodeNamesUsed[t]:(this.nodeNamesUsed[t]=0,t)}loadGeometries(e){const t=this,n=this.extensions,r=this.primitiveCache;function s(e){return n[dn.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(n){return ar(n,e,t)})}const i=[];for(let n=0,o=e.length;n<o;n++){const o=e[n],a=nr(o),c=r[a];if(c)i.push(c.promise);else{let e;e=o.extensions&&o.extensions[dn.KHR_DRACO_MESH_COMPRESSION]?s(o):ar(new l,o,t),r[a]={primitive:o,promise:e},i.push(e)}}return Promise.all(i)}loadMesh(e){const t=this,n=this.json,r=this.extensions,s=n.meshes[e],i=s.primitives,o=[];for(let e=0,t=i.length;e<t;e++){const t=void 0===i[e].material?$n(this.cache):this.getDependency("material",i[e].material);o.push(t)}return o.push(t.loadGeometries(i)),Promise.all(o).then(function(n){const o=n.slice(0,n.length-1),a=n[n.length-1],c=[];for(let n=0,l=a.length;n<l;n++){const l=a[n],u=i[n];let h;const d=o[n];if(u.mode===Vn.TRIANGLES||u.mode===Vn.TRIANGLE_STRIP||u.mode===Vn.TRIANGLE_FAN||void 0===u.mode)h=!0===s.isSkinnedMesh?new Te(l,d):new K(l,d),!0===h.isSkinnedMesh&&h.normalizeSkinWeights(),u.mode===Vn.TRIANGLE_STRIP?h.geometry=un(h.geometry,Ee):u.mode===Vn.TRIANGLE_FAN&&(h.geometry=un(h.geometry,Se));else if(u.mode===Vn.LINES)h=new N(l,d);else if(u.mode===Vn.LINE_STRIP)h=new O(l,d);else if(u.mode===Vn.LINE_LOOP)h=new C(l,d);else{if(u.mode!==Vn.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new le(l,d)}Object.keys(h.geometry.morphAttributes).length>0&&tr(h,s),h.name=t.createUniqueName(s.name||"mesh_"+e),er(h,s),u.extensions&&Jn(r,h,u),t.assignFinalMaterial(h),c.push(h)}for(let n=0,r=c.length;n<r;n++)t.associations.set(c[n],{meshes:e,primitives:n});if(1===c.length)return s.extensions&&Jn(r,c[0],s),c[0];const l=new I;s.extensions&&Jn(r,l,s),t.associations.set(l,{meshes:e});for(let e=0,t=c.length;e<t;e++)l.add(c[e]);return l})}loadCamera(e){let t;const n=this.json.cameras[e],r=n[n.type];if(r)return"perspective"===n.type?t=new ae(H.radToDeg(r.yfov),r.aspectRatio||1,r.znear||1,r.zfar||2e6):"orthographic"===n.type&&(t=new oe(-r.xmag,r.xmag,r.ymag,-r.ymag,r.znear,r.zfar)),n.name&&(t.name=this.createUniqueName(n.name)),er(t,n),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],n=[];for(let e=0,r=t.joints.length;e<r;e++)n.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?n.push(this.getDependency("accessor",t.inverseBindMatrices)):n.push(null),Promise.all(n).then(function(e){const t=e.pop(),n=e,r=[],s=[];for(let e=0,i=n.length;e<i;e++){const i=n[e];if(i){r.push(i);const n=new G;null!==t&&n.fromArray(t.array,16*e),s.push(n)}}return new xe(r,s)})}loadAnimation(e){const t=this.json,r=this,s=t.animations[e],i=s.name?s.name:"animation_"+e,o=[],a=[],c=[],l=[],u=[];for(let e=0,t=s.channels.length;e<t;e++){const t=s.channels[e],n=s.samplers[t.sampler],r=t.target,i=r.node,h=void 0!==s.parameters?s.parameters[n.input]:n.input,d=void 0!==s.parameters?s.parameters[n.output]:n.output;void 0!==r.node&&(o.push(this.getDependency("node",i)),a.push(this.getDependency("accessor",h)),c.push(this.getDependency("accessor",d)),l.push(n),u.push(r))}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c),Promise.all(l),Promise.all(u)]).then(function(e){const t=e[0],o=e[1],a=e[2],c=e[3],l=e[4],u=[];for(let e=0,n=t.length;e<n;e++){const n=t[e],s=o[e],i=a[e],h=c[e],d=l[e];if(void 0===n)continue;n.updateMatrix&&n.updateMatrix();const p=r._createAnimationTracks(n,s,i,h,d);if(p)for(let e=0;e<p.length;e++)u.push(p[e])}const h=new n(i,void 0,u);return er(h,s),h})}createNodeMesh(e){const t=this.json,n=this,r=t.nodes[e];return void 0===r.mesh?null:n.getDependency("mesh",r.mesh).then(function(e){const t=n._getNodeRef(n.meshCache,r.mesh,e);return void 0!==r.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,n=r.weights.length;t<n;t++)e.morphTargetInfluences[t]=r.weights[t]}),t})}loadNode(e){const t=this,n=this.json.nodes[e],r=t._loadNodeShallow(e),s=[],i=n.children||[];for(let e=0,n=i.length;e<n;e++)s.push(t.getDependency("node",i[e]));const o=void 0===n.skin?Promise.resolve(null):t.getDependency("skin",n.skin);return Promise.all([r,Promise.all(s),o]).then(function(e){const t=e[0],n=e[1],r=e[2];null!==r&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(r,ir)});for(let e=0,r=n.length;e<r;e++)t.add(n[e]);return t})}_loadNodeShallow(e){const t=this.json,n=this.extensions,r=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const s=t.nodes[e],i=s.name?r.createUniqueName(s.name):"",a=[],c=r._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return c&&a.push(c),void 0!==s.camera&&a.push(r.getDependency("camera",s.camera).then(function(e){return r._getNodeRef(r.cameraCache,s.camera,e)})),r._invokeAll(function(t){return t.createNodeAttachment&&t.createNodeAttachment(e)}).forEach(function(e){a.push(e)}),this.nodeCache[e]=Promise.all(a).then(function(t){let a;if(a=!0===s.isBone?new o:t.length>1?new I:1===t.length?t[0]:new ie,a!==t[0])for(let e=0,n=t.length;e<n;e++)a.add(t[e]);if(s.name&&(a.userData.name=s.name,a.name=i),er(a,s),s.extensions&&Jn(n,a,s),void 0!==s.matrix){const e=new G;e.fromArray(s.matrix),a.applyMatrix4(e)}else void 0!==s.translation&&a.position.fromArray(s.translation),void 0!==s.rotation&&a.quaternion.fromArray(s.rotation),void 0!==s.scale&&a.scale.fromArray(s.scale);if(r.associations.has(a)){if(void 0!==s.mesh&&r.meshCache.refs[s.mesh]>1){const e=r.associations.get(a);r.associations.set(a,{...e})}}else r.associations.set(a,{});return r.associations.get(a).nodes=e,a}),this.nodeCache[e]}loadScene(e){const t=this.extensions,n=this.json.scenes[e],r=this,s=new I;n.name&&(s.name=r.createUniqueName(n.name)),er(s,n),n.extensions&&Jn(t,s,n);const i=n.nodes||[],o=[];for(let e=0,t=i.length;e<t;e++)o.push(r.getDependency("node",i[e]));return Promise.all(o).then(function(e){for(let t=0,n=e.length;t<n;t++)s.add(e[t]);return r.associations=(e=>{const t=new Map;for(const[e,n]of r.associations)(e instanceof V||e instanceof Re)&&t.set(e,n);return e.traverse(e=>{const n=r.associations.get(e);null!=n&&t.set(e,n)}),t})(s),s})}_createAnimationTracks(e,t,n,r,s){const i=[],o=e.name?e.name:e.uuid,a=[];let c;switch(Xn[s.path]===Xn.weights?e.traverse(function(e){e.morphTargetInfluences&&a.push(e.name?e.name:e.uuid)}):a.push(o),Xn[s.path]){case Xn.weights:c=se;break;case Xn.rotation:c=me;break;case Xn.translation:case Xn.scale:c=Ne;break;default:if(1===n.itemSize)c=se;else c=Ne}const l=void 0!==r.interpolation?Qn[r.interpolation]:L,u=this._getArrayFromAccessor(n);for(let e=0,n=a.length;e<n;e++){const n=new c(a[e]+"."+Xn[s.path],t.array,u,l);"CUBICSPLINE"===r.interpolation&&this._createCubicSplineTrackInterpolant(n),i.push(n)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=sr(t.constructor),n=new Float32Array(t.length);for(let r=0,s=t.length;r<s;r++)n[r]=t[r]*e;t=n}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof me?Bn:Un)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function ar(e,t,n){const r=t.attributes,s=[];function i(t,r){return n.getDependency("accessor",t).then(function(t){e.setAttribute(r,t)})}for(const t in r){const n=Wn[t]||t.toLowerCase();n in e.attributes||s.push(i(r[t],n))}if(void 0!==t.indices&&!e.index){const r=n.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});s.push(r)}return p.workingColorSpace,er(e,t),function(e,t,n){const r=t.attributes,s=new a;if(void 0===r.POSITION)return;{const e=n.json.accessors[r.POSITION],t=e.min,i=e.max;if(void 0===t||void 0===i)return;if(s.set(new Pe(t[0],t[1],t[2]),new Pe(i[0],i[1],i[2])),e.normalized){const t=sr(Hn[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}const i=t.targets;if(void 0!==i){const e=new Pe,t=new Pe;for(let r=0,s=i.length;r<s;r++){const s=i[r];if(void 0!==s.POSITION){const r=n.json.accessors[s.POSITION],i=r.min,o=r.max;if(void 0!==i&&void 0!==o){if(t.setX(Math.max(Math.abs(i[0]),Math.abs(o[0]))),t.setY(Math.max(Math.abs(i[1]),Math.abs(o[1]))),t.setZ(Math.max(Math.abs(i[2]),Math.abs(o[2]))),r.normalized){const e=sr(Hn[r.componentType]);t.multiplyScalar(e)}e.max(t)}}}s.expandByVector(e)}e.boundingBox=s;const o=new we;s.getCenter(o.center),o.radius=s.min.distanceTo(s.max)/2,e.boundingSphere=o}(e,t,n),Promise.all(s).then(function(){return void 0!==t.targets?function(e,t,n){let r=!1,s=!1,i=!1;for(let e=0,n=t.length;e<n;e++){const n=t[e];if(void 0!==n.POSITION&&(r=!0),void 0!==n.NORMAL&&(s=!0),void 0!==n.COLOR_0&&(i=!0),r&&s&&i)break}if(!r&&!s&&!i)return Promise.resolve(e);const o=[],a=[],c=[];for(let l=0,u=t.length;l<u;l++){const u=t[l];if(r){const t=void 0!==u.POSITION?n.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(s){const t=void 0!==u.NORMAL?n.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==u.COLOR_0?n.getDependency("accessor",u.COLOR_0):e.attributes.color;c.push(t)}}return Promise.all([Promise.all(o),Promise.all(a),Promise.all(c)]).then(function(t){const n=t[0],o=t[1],a=t[2];return r&&(e.morphAttributes.position=n),s&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(e,t.targets,n):e})}new class extends z{constructor(e){super(e),this.dracoLoader=null,this.ktx2Loader=null,this.meshoptDecoder=null,this.pluginCallbacks=[],this.register(function(e){return new gn(e)}),this.register(function(e){return new yn(e)}),this.register(function(e){return new Mn(e)}),this.register(function(e){return new Sn(e)}),this.register(function(e){return new En(e)}),this.register(function(e){return new xn(e)}),this.register(function(e){return new Tn(e)}),this.register(function(e){return new wn(e)}),this.register(function(e){return new In(e)}),this.register(function(e){return new fn(e)}),this.register(function(e){return new bn(e)}),this.register(function(e){return new vn(e)}),this.register(function(e){return new Rn(e)}),this.register(function(e){return new An(e)}),this.register(function(e){return new pn(e)}),this.register(function(e){return new _n(e)}),this.register(function(e){return new Ln(e)})}load(e,t,n,r){const s=this;let i;if(""!==this.resourcePath)i=this.resourcePath;else if(""!==this.path){const t=B.extractUrlBase(e);i=B.resolveURL(t,this.path)}else i=B.extractUrlBase(e);this.manager.itemStart(e);const o=function(t){r&&r(t),s.manager.itemError(e),s.manager.itemEnd(e)},a=new x(this.manager);a.setPath(this.path),a.setResponseType("arraybuffer"),a.setRequestHeader(this.requestHeader),a.setWithCredentials(this.withCredentials),a.load(e,function(n){try{s.parse(n,i,function(n){t(n),s.manager.itemEnd(e)},o)}catch(e){o(e)}},n,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,n,r){let s;const i={},o={},a=new TextDecoder;if("string"==typeof e)s=JSON.parse(e);else if(e instanceof ArrayBuffer){if(a.decode(new Uint8Array(e,0,4))===On){try{i[dn.KHR_BINARY_GLTF]=new Nn(e)}catch(e){return void(r&&r(e))}s=JSON.parse(i[dn.KHR_BINARY_GLTF].content)}else s=JSON.parse(a.decode(e))}else s=e;if(void 0===s.asset||s.asset.version[0]<2)return void(r&&r(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new or(s,{path:t||this.resourcePath||"",crossOrigin:this.crossOrigin,requestHeader:this.requestHeader,manager:this.manager,ktx2Loader:this.ktx2Loader,meshoptDecoder:this.meshoptDecoder});c.fileLoader.setRequestHeader(this.requestHeader);for(let e=0;e<this.pluginCallbacks.length;e++){const t=this.pluginCallbacks[e](c);t.name,o[t.name]=t,i[t.name]=!0}if(s.extensionsUsed)for(let e=0;e<s.extensionsUsed.length;++e){const t=s.extensionsUsed[e],n=s.extensionsRequired||[];switch(t){case dn.KHR_MATERIALS_UNLIT:i[t]=new mn;break;case dn.KHR_DRACO_MESH_COMPRESSION:i[t]=new kn(s,this.dracoLoader);break;case dn.KHR_TEXTURE_TRANSFORM:i[t]=new Dn;break;case dn.KHR_MESH_QUANTIZATION:i[t]=new Fn;break;default:n.indexOf(t)>=0&&o[t]}}c.setExtensions(i),c.setPlugins(o),c.parse(n,r)}parseAsync(e,t){const n=this;return new Promise(function(r,s){n.parse(e,t,r,s)})}},Array.from({length:3},()=>({loader:new Kt,isUsed:!1}));Array.from({length:3},()=>({loader:new Me,isUsed:!1}));Array.from({length:3},()=>({loader:new i,isUsed:!1}));const cr=new Pe,lr=new pe,ur=new Pe,hr=new Pe,dr=new pe,pr=new Pe;class mr extends ie{constructor(){super()}updateMatrixWorld(e){this.matrixAutoUpdate&&this.updateMatrix(),(this.matrixWorldNeedsUpdate||e)&&(null!==this.parent?(this.matrixWorld.multiplyMatrices(this.parent.matrixWorld,this.matrix),this.matrixWorld.decompose(hr,dr,pr),this.matrix.decompose(cr,lr,ur),this.matrixWorld.compose(hr,lr,pr)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let t=0,n=this.children.length;t<n;t++)this.children[t].updateMatrixWorld(e)}}var fr=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180];class gr{constructor(e){const t=[new Pe(1,1,0),new Pe(-1,1,0),new Pe(1,-1,0),new Pe(-1,-1,0),new Pe(1,0,1),new Pe(-1,0,1),new Pe(1,0,-1),new Pe(-1,0,-1),new Pe(0,1,1),new Pe(0,-1,1),new Pe(0,1,-1),new Pe(0,-1,-1)];var n=new Array(512),r=new Array(512);e||(e=1),e*=65536,(e=Math.floor(e))<256&&(e|=e<<8);for(var s=0;s<256;s++){var i;i=1&s?fr[s]^255&e:fr[s]^e>>8&255,n[s]=n[s+256]=i,r[s]=r[s+256]=t[i%12]}this._seed=e,this._offsetMatrix=[new Pe(0,0,0),new Pe(0,0,1),new Pe(0,1,0),new Pe(0,1,1),new Pe(1,0,0),new Pe(1,0,1),new Pe(1,1,0),new Pe(1,1,1)],this.shaderChunk={defines:"",header:'#define GLSLIFY 1\n// From https://github.com/hughsk/glsl-noise/blob/master/periodic/2d.glsl\n\n//\n// GLSL textureless classic 2D noise "cnoise",\n// with an RSL-style periodic variant "pnoise".\n// Author: Stefan Gustavson (stefan.gustavson@liu.se)\n// Version: 2011-08-22\n//\n// Many thanks to Ian McEwan of Ashima Arts for the\n// ideas for permutation and gradient selection.\n//\n// Copyright (c) 2011 Stefan Gustavson. All rights reserved.\n// Distributed under the MIT license. See LICENSE file.\n// https://github.com/ashima/webgl-noise\n//\n\nvec4 mod289(vec4 x) { return x - floor(x * (1.0 / 289.0)) * 289.0; }\n\nvec4 permute(vec4 x) { return mod289(((x * 34.0) + 1.0) * x); }\n\nvec4 taylorInvSqrt(vec4 r) { return 1.79284291400159 - 0.85373472095314 * r; }\n\nvec2 fade(vec2 t) { return t * t * t * (t * (t * 6.0 - 15.0) + 10.0); }\n\nfloat map(float value, float min1, float max1, float min2, float max2) {\n return min2 + (value - min1) * (max2 - min2) / (max1 - min1);\n}\n\n// Classic Perlin noise, periodic variant\nfloat perlin(vec2 P) {\n\n vec2 rep = vec2(255.0, 255.0);\n\n vec4 Pi = floor(P.xyxy) + vec4(0.0, 0.0, 1.0, 1.0);\n vec4 Pf = fract(P.xyxy) - vec4(0.0, 0.0, 1.0, 1.0);\n Pi = mod(Pi, rep.xyxy); // To create noise with explicit period\n Pi = mod289(Pi); // To avoid truncation effects in permutation\n vec4 ix = Pi.xzxz;\n vec4 iy = Pi.yyww;\n vec4 fx = Pf.xzxz;\n vec4 fy = Pf.yyww;\n\n vec4 i = permute(permute(ix) + iy);\n\n vec4 gx = fract(i * (1.0 / 41.0)) * 2.0 - 1.0;\n vec4 gy = abs(gx) - 0.5;\n vec4 tx = floor(gx + 0.5);\n gx = gx - tx;\n\n vec2 g00 = vec2(gx.x, gy.x);\n vec2 g10 = vec2(gx.y, gy.y);\n vec2 g01 = vec2(gx.z, gy.z);\n vec2 g11 = vec2(gx.w, gy.w);\n\n vec4 norm = taylorInvSqrt(\n vec4(dot(g00, g00), dot(g01, g01), dot(g10, g10), dot(g11, g11)));\n g00 *= norm.x;\n g01 *= norm.y;\n g10 *= norm.z;\n g11 *= norm.w;\n\n float n00 = dot(g00, vec2(fx.x, fy.x));\n float n10 = dot(g10, vec2(fx.y, fy.y));\n float n01 = dot(g01, vec2(fx.z, fy.z));\n float n11 = dot(g11, vec2(fx.w, fy.w));\n\n vec2 fade_xy = fade(Pf.xy);\n vec2 n_x = mix(vec2(n00, n01), vec2(n10, n11), fade_xy.x);\n float n_xy = mix(n_x.x, n_x.y, fade_xy.y);\n return map(2.3 * n_xy, -1.0, 1.0, 0.0, 1.0);\n}\n\nfloat fbm(vec2 pos, vec4 props) {\n float persistance = props.x;\n float lacunarity = props.y;\n float redistribution = props.z;\n int octaves = int(props.w);\n\n float result = 0.0;\n float amplitude = 1.0;\n float frequency = 1.0;\n float maximum = amplitude;\n\n for (int i = 0; i < 2; i++) {\n\n vec2 p = pos.xy * frequency;\n\n float noiseVal = perlin(p);\n result += noiseVal * amplitude;\n\n frequency *= lacunarity;\n amplitude *= persistance;\n maximum += amplitude;\n }\n\n float redistributed = pow(result, redistribution);\n return redistributed / maximum;\n}\n',main:"",uniforms:[{three_noise_seed:this._seed}]},this.perm=n,this.gradP=r}_fade(e){return e*e*e*(e*(6*e-15)+10)}_lerp(e,t,n){return(1-n)*e+n*t}_gradient(e){return e instanceof Pe?e.x+this.perm[e.y+this.perm[e.z]]:e.x+this.perm[e.y]}static map(e,t,n,r,s){return(e-t)*(s-r)/(n-t)+r}get2(e){void 0!==e.z&&(e=new Oe(e.x,e.y));const t=new Oe(Math.floor(e.x),Math.floor(e.y));e.sub(t),t.x&=255,t.y&=255;const n=[];for(let r=0;r<4;r++){const s=this._offsetMatrix[2*r],i=new Oe(s.x,s.y),o=this.gradP[this._gradient((new Oe).addVectors(t,i))],a=new Oe(o.x,o.y),c=(new Oe).subVectors(e,i);n.push(a.dot(c))}const r=this._fade(e.x),s=this._fade(e.y);return this._lerp(this._lerp(n[0],n[2],r),this._lerp(n[1],n[3],r),s)}get3(e){if(void 0===e.z)throw"Input to Perlin::get3() must be of type THREE.Vector3";const t=new Pe(Math.floor(e.x),Math.floor(e.y),Math.floor(e.z));e.sub(t),t.x&=255,t.y&=255,t.z&=255;const n=[];for(let r=0;r<8;r++){const s=this._offsetMatrix[r],i=this.gradP[this._gradient((new Pe).addVectors(t,s))],o=(new Pe).subVectors(e,s);n.push(i.dot(o))}const r=this._fade(e.x),s=this._fade(e.y),i=this._fade(e.z);return this._lerp(this._lerp(this._lerp(n[0],n[4],r),this._lerp(n[1],n[5],r),i),this._lerp(this._lerp(n[2],n[6],r),this._lerp(n[3],n[7],r),i),s)}}class yr{constructor(e){const{seed:t,scale:n,persistance:r,lacunarity:s,octaves:i,redistribution:o}=e;this._noise=new gr(t),this._scale=n||1,this._persistance=r||.5,this._lacunarity=s||2,this._octaves=i||6,this._redistribution=o||1}get2(e){let t=0,n=1,r=1,s=n,i=this._noise.get2.bind(this._noise);for(let o=0;o<this._octaves;o++){t+=i(new Oe(e.x*this._scale*r,e.y*this._scale*r))*n,r*=this._lacunarity,n*=this._persistance,s+=n}return Math.pow(t,this._redistribution)/s}get3(e){let t=0,n=1,r=1,s=n,i=this._noise.get3.bind(this._noise);for(let o=0;o<this._octaves;o++){t+=i(new Pe(e.x*this._scale*r,e.y*this._scale*r,e.z*this._scale*r))*n,r*=this._lacunarity,n*=this._persistance,s+=n}return Math.pow(t,this._redistribution)/s}}let vr=0,xr=[];const Tr={"THREE.NoBlending":ne,"THREE.NormalBlending":re,"THREE.AdditiveBlending":e,"THREE.SubtractiveBlending":Ae,"THREE.MultiplyBlending":$},wr=()=>JSON.parse(JSON.stringify(Ir)),Ir={transform:{position:new Pe,rotation:new Pe,scale:new Pe(1,1,1)},duration:5,looping:!0,startDelay:0,startLifetime:5,startSpeed:1,startSize:1,startOpacity:1,startRotation:0,startColor:{min:{r:1,g:1,b:1},max:{r:1,g:1,b:1}},gravity:0,simulationSpace:"LOCAL",maxParticles:100,emission:{rateOverTime:10,rateOverDistance:0},shape:{shape:"SPHERE",sphere:{radius:1,radiusThickness:1,arc:360},cone:{angle:25,radius:1,radiusThickness:1,arc:360},circle:{radius:1,radiusThickness:1,arc:360},rectangle:{rotation:{x:0,y:0},scale:{x:1,y:1}},box:{scale:{x:1,y:1,z:1},emitFrom:"VOLUME"}},map:void 0,renderer:{blending:re,discardBackgroundColor:!1,backgroundColorTolerance:1,backgroundColor:{r:1,g:1,b:1},transparent:!0,depthTest:!0,depthWrite:!1},velocityOverLifetime:{isActive:!1,linear:{x:0,y:0,z:0},orbital:{x:0,y:0,z:0}},sizeOverLifetime:{isActive:!1,lifetimeCurve:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:0,percentage:0},{x:1,y:1,percentage:1}]}},colorOverLifetime:{isActive:!1,r:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]},g:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]},b:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:1,percentage:0},{x:1,y:1,percentage:1}]}},opacityOverLifetime:{isActive:!1,lifetimeCurve:{type:"BEZIER",scale:1,bezierPoints:[{x:0,y:0,percentage:0},{x:1,y:1,percentage:1}]}},rotationOverLifetime:{isActive:!1,min:0,max:0},noise:{isActive:!1,useRandomOffset:!1,strength:1,frequency:.5,octaves:1,positionAmount:1,rotationAmount:0,sizeAmount:0},textureSheetAnimation:{tiles:new Oe(1,1),timeMode:"LIFETIME",fps:30,startFrame:0}},br=(e,{shape:t,sphere:n,cone:r,circle:s,rectangle:i,box:o},a,c,l)=>{const u=et(e.particleSystemId,a,e.normalizedLifetimePercentage);switch(t){case"SPHERE":We(c,e.wrapperQuaternion,l,u,n);break;case"CONE":Xe(c,e.wrapperQuaternion,l,u,r);break;case"CIRCLE":qe(c,e.wrapperQuaternion,l,u,s);break;case"RECTANGLE":Ye(c,e.wrapperQuaternion,l,u,i);break;case"BOX":Qe(c,e.wrapperQuaternion,l,u,o)}},Ar=(e=Ir,t)=>{const n=t||Date.now(),r={particleSystemId:vr++,normalizedLifetimePercentage:0,distanceFromLastEmitByDistance:0,lastWorldPosition:new Pe(-99999),currentWorldPosition:new Pe(-99999),worldPositionChange:new Pe,worldQuaternion:new pe,wrapperQuaternion:new pe,lastWorldQuaternion:new pe(-99999),worldEuler:new v,gravityVelocity:new Pe(0,0,0),startValues:{},linearVelocityData:void 0,orbitalVelocityData:void 0,lifetimeValues:{},creationTimes:[],noise:{isActive:!1,strength:0,positionAmount:0,rotationAmount:0,sizeAmount:0},isEnabled:!0},s=st(Ir,e,{applyToFirstObject:!1,skippedProperties:[]});let i=s.map||Ze();const{transform:o,duration:a,looping:u,startDelay:h,startLifetime:d,startSpeed:p,startSize:m,startRotation:f,startColor:g,startOpacity:y,gravity:x,simulationSpace:T,maxParticles:w,emission:I,shape:b,renderer:A,noise:R,velocityOverLifetime:M,onUpdate:S,onComplete:E,textureSheetAnimation:_}=s;"string"==typeof A?.blending&&(A.blending=Tr[A.blending]);const L=Array.from({length:w},()=>new Pe),O=Array.from({length:w},()=>new Pe);r.creationTimes=Array.from({length:w},()=>0),M.isActive&&(r.linearVelocityData=Array.from({length:w},()=>({speed:new Pe(M.linear.x?et(r.particleSystemId,M.linear.x,0):0,M.linear.y?et(r.particleSystemId,M.linear.y,0):0,M.linear.z?et(r.particleSystemId,M.linear.z,0):0),valueModifiers:{x:$e(M.linear.x||0)?Je(r.particleSystemId,M.linear.x):void 0,y:$e(M.linear.y||0)?Je(r.particleSystemId,M.linear.y):void 0,z:$e(M.linear.z||0)?Je(r.particleSystemId,M.linear.z):void 0}})),r.orbitalVelocityData=Array.from({length:w},()=>({speed:new Pe(M.orbital.x?et(r.particleSystemId,M.orbital.x,0):0,M.orbital.y?et(r.particleSystemId,M.orbital.y,0):0,M.orbital.z?et(r.particleSystemId,M.orbital.z,0):0),valueModifiers:{x:$e(M.orbital.x||0)?Je(r.particleSystemId,M.orbital.x):void 0,y:$e(M.orbital.y||0)?Je(r.particleSystemId,M.orbital.y):void 0,z:$e(M.orbital.z||0)?Je(r.particleSystemId,M.orbital.z):void 0},positionOffset:new Pe})));["startSize","startOpacity"].forEach(e=>{r.startValues[e]=Array.from({length:w},()=>et(r.particleSystemId,s[e],0))}),r.startValues.startColorR=Array.from({length:w},()=>0),r.startValues.startColorG=Array.from({length:w},()=>0),r.startValues.startColorB=Array.from({length:w},()=>0);["rotationOverLifetime"].forEach(e=>{const t=s[e];t.isActive&&(r.lifetimeValues[e]=Array.from({length:w},()=>H.randFloat(t.min,t.max)))}),r.noise={isActive:R.isActive,strength:R.strength,positionAmount:R.positionAmount,rotationAmount:R.rotationAmount,sizeAmount:R.sizeAmount,sampler:R.isActive?new yr({seed:Math.random(),scale:R.frequency,octaves:R.octaves}):void 0,offsets:R.useRandomOffset?Array.from({length:w},()=>100*Math.random()):void 0};const P=new ye({uniforms:{elapsed:{value:0},map:{value:i},tiles:{value:_.tiles},fps:{value:_.fps},useFPSForFrameIndex:{value:"FPS"===_.timeMode},backgroundColor:{value:A.backgroundColor},discardBackgroundColor:{value:A.discardBackgroundColor},backgroundColorTolerance:{value:A.backgroundColorTolerance}},vertexShader:"\n attribute float size;\n attribute float colorR;\n attribute float colorG;\n attribute float colorB;\n attribute float colorA;\n attribute float lifetime;\n attribute float startLifetime;\n attribute float rotation;\n attribute float startFrame;\n\n varying mat4 vPosition;\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n\n #include <common>\n #include <logdepthbuf_pars_vertex>\n\n void main()\n {\n vColor = vec4(colorR, colorG, colorB, colorA);\n vLifetime = lifetime;\n vStartLifetime = startLifetime;\n vRotation = rotation;\n vStartFrame = startFrame;\n\n vec4 mvPosition = modelViewMatrix * vec4(position, 1.0);\n gl_PointSize = size * (100.0 / length(mvPosition.xyz));\n gl_Position = projectionMatrix * mvPosition;\n\n #include <logdepthbuf_vertex>\n }\n",fragmentShader:"\n uniform sampler2D map;\n uniform float elapsed;\n uniform float fps;\n uniform bool useFPSForFrameIndex;\n uniform vec2 tiles;\n uniform bool discardBackgroundColor;\n uniform vec3 backgroundColor;\n uniform float backgroundColorTolerance;\n\n varying vec4 vColor;\n varying float vLifetime;\n varying float vStartLifetime;\n varying float vRotation;\n varying float vStartFrame;\n\n #include <common>\n #include <logdepthbuf_pars_fragment>\n\n void main()\n {\n gl_FragColor = vColor;\n float mid = 0.5;\n\n float frameIndex = round(vStartFrame) + (\n useFPSForFrameIndex == true\n ? fps == 0.0\n ? 0.0\n : max((vLifetime / 1000.0) * fps, 0.0)\n : max(min(floor(min(vLifetime / vStartLifetime, 1.0) * (tiles.x * tiles.y)), tiles.x * tiles.y - 1.0), 0.0)\n );\n \n float spriteXIndex = floor(mod(frameIndex, tiles.x));\n float spriteYIndex = floor(mod(frameIndex / tiles.x, tiles.y));\n\n vec2 frameUV = vec2(\n gl_PointCoord.x / tiles.x + spriteXIndex / tiles.x,\n gl_PointCoord.y / tiles.y + spriteYIndex / tiles.y);\n\n vec2 center = vec2(0.5, 0.5);\n vec2 centeredPoint = gl_PointCoord - center;\n\n mat2 rotation = mat2(\n cos(vRotation), sin(vRotation),\n -sin(vRotation), cos(vRotation)\n );\n\n centeredPoint = rotation * centeredPoint;\n vec2 centeredMiddlePoint = vec2(\n centeredPoint.x + center.x,\n centeredPoint.y + center.y\n );\n\n float dist = distance(centeredMiddlePoint, center);\n if (dist > 0.5) discard;\n\n vec2 uvPoint = vec2(\n centeredMiddlePoint.x / tiles.x + spriteXIndex / tiles.x,\n centeredMiddlePoint.y / tiles.y + spriteYIndex / tiles.y\n );\n\n vec4 rotatedTexture = texture2D(map, uvPoint);\n\n gl_FragColor = gl_FragColor * rotatedTexture;\n\n if (discardBackgroundColor && abs(length(rotatedTexture.rgb - backgroundColor.rgb)) < backgroundColorTolerance) discard;\n \n #include <logdepthbuf_fragment>\n }\n",transparent:A.transparent,blending:A.blending,depthTest:A.depthTest,depthWrite:A.depthWrite}),C=new l;for(let e=0;e<w;e++)br(r,b,p,L[e],O[e]);C.setFromPoints(Array.from({length:w},(e,t)=>L[t].clone()));const N=(e,t)=>{(({geometry:e,propertyName:t,maxParticles:n,factory:r})=>{e.setAttribute(t,new c(new Float32Array(Array.from({length:n},"function"==typeof r?r:()=>r)),1))})({geometry:C,propertyName:e,maxParticles:w,factory:t})};N("isActive",0),N("lifetime",0),N("startLifetime",()=>1e3*et(r.particleSystemId,d,0)),N("startFrame",()=>_.startFrame?et(r.particleSystemId,_.startFrame,0):0),N("opacity",()=>et(r.particleSystemId,y,0)),N("rotation",()=>et(r.particleSystemId,f,0)),N("size",(e,t)=>r.startValues.startSize[t]),N("rotation",0);const k=Math.random();N("colorR",()=>g.min.r+k*(g.max.r-g.min.r)),N("colorG",()=>g.min.g+k*(g.max.g-g.min.g)),N("colorB",()=>g.min.b+k*(g.max.b-g.min.b)),N("colorA",0);let D=new le(C,P);D.position.copy(o.position),D.rotation.x=H.degToRad(o.rotation.x),D.rotation.y=H.degToRad(o.rotation.y),D.rotation.z=H.degToRad(o.rotation.z),D.scale.copy(o.scale);const F=n+1e3*et(r.particleSystemId,h);let U;"WORLD"===s.simulationSpace&&(U=new mr,U.add(D)),xr.push({particleSystem:D,wrapper:U,generalData:r,onUpdate:S,onComplete:E,creationTime:F,lastEmissionTime:F,duration:a,looping:u,simulationSpace:T,gravity:x,emission:I,normalizedConfig:s,iterationCount:0,velocities:O,deactivateParticle:e=>{C.attributes.isActive.array[e]=0,C.attributes.colorA.array[e]=0,C.attributes.colorA.needsUpdate=!0},activateParticle:({particleIndex:e,activationTime:t,position:n})=>{C.attributes.isActive.array[e]=1,r.creationTimes[e]=t,r.noise.offsets&&(r.noise.offsets[e]=100*Math.random());const i=Math.random();C.attributes.colorR.array[e]=g.min.r+i*(g.max.r-g.min.r),C.attributes.colorR.needsUpdate=!0,C.attributes.colorG.array[e]=g.min.g+i*(g.max.g-g.min.g),C.attributes.colorG.needsUpdate=!0,C.attributes.colorB.array[e]=g.min.b+i*(g.max.b-g.min.b),C.attributes.colorB.needsUpdate=!0,r.startValues.startColorR[e]=C.attributes.colorR.array[e],r.startValues.startColorG[e]=C.attributes.colorG.array[e],r.startValues.startColorB[e]=C.attributes.colorB.array[e],C.attributes.startFrame.array[e]=_.startFrame?et(r.particleSystemId,_.startFrame,0):0,C.attributes.startFrame.needsUpdate=!0,C.attributes.startLifetime.array[e]=1e3*et(r.particleSystemId,d,r.normalizedLifetimePercentage),C.attributes.startLifetime.needsUpdate=!0,r.startValues.startSize[e]=et(r.particleSystemId,m,r.normalizedLifetimePercentage),C.attributes.size.array[e]=r.startValues.startSize[e],C.attributes.size.needsUpdate=!0,r.startValues.startOpacity[e]=et(r.particleSystemId,y,r.normalizedLifetimePercentage),C.attributes.colorA.array[e]=r.startValues.startOpacity[e],C.attributes.colorA.needsUpdate=!0,C.attributes.rotation.array[e]=et(r.particleSystemId,f,r.normalizedLifetimePercentage),C.attributes.rotation.needsUpdate=!0,s.rotationOverLifetime.isActive&&(r.lifetimeValues.rotationOverLifetime[e]=H.randFloat(s.rotationOverLifetime.min,s.rotationOverLifetime.max)),br(r,b,p,L[e],O[e]);const o=Math.floor(3*e);C.attributes.position.array[o]=n.x+L[e].x,C.attributes.position.array[o+1]=n.y+L[e].y,C.attributes.position.array[o+2]=n.z+L[e].z,C.attributes.position.needsUpdate=!0,r.linearVelocityData&&r.linearVelocityData[e].speed.set(s.velocityOverLifetime.linear.x?et(r.particleSystemId,s.velocityOverLifetime.linear.x,0):0,s.velocityOverLifetime.linear.y?et(r.particleSystemId,s.velocityOverLifetime.linear.y,0):0,s.velocityOverLifetime.linear.z?et(r.particleSystemId,s.velocityOverLifetime.linear.z,0):0),r.orbitalVelocityData&&(r.orbitalVelocityData[e].speed.set(s.velocityOverLifetime.orbital.x?et(r.particleSystemId,s.velocityOverLifetime.orbital.x,0):0,s.velocityOverLifetime.orbital.y?et(r.particleSystemId,s.velocityOverLifetime.orbital.y,0):0,s.velocityOverLifetime.orbital.z?et(r.particleSystemId,s.velocityOverLifetime.orbital.z,0):0),r.orbitalVelocityData[e].positionOffset.set(L[e].x,L[e].y,L[e].z)),C.attributes.lifetime.array[e]=0,C.attributes.lifetime.needsUpdate=!0,rt({delta:0,generalData:r,normalizedConfig:s,attributes:D.geometry.attributes,particleLifetimePercentage:0,particleIndex:e})}});return{instance:U||D,resumeEmitter:()=>r.isEnabled=!0,pauseEmitter:()=>r.isEnabled=!1,dispose:()=>(e=>{xr=xr.filter(({particleSystem:t,wrapper:n,generalData:{particleSystemId:r}})=>t!==e&&n!==e||(Ve(r),t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach(e=>e.dispose()):t.material.dispose(),t.parent&&t.parent.remove(t),!1))})(D)}},Rr=({now:e,delta:t,elapsed:n})=>{xr.forEach(r=>{const{onUpdate:s,generalData:i,onComplete:o,particleSystem:a,wrapper:c,creationTime:l,lastEmissionTime:u,duration:h,looping:d,emission:p,normalizedConfig:m,iterationCount:f,velocities:g,deactivateParticle:y,activateParticle:v,simulationSpace:x,gravity:T}=r,w=e-l,I=w%(1e3*h);i.normalizedLifetimePercentage=Math.max(Math.min(I/(1e3*h),1),0);const{lastWorldPosition:b,currentWorldPosition:A,worldPositionChange:R,lastWorldQuaternion:M,worldQuaternion:S,worldEuler:E,gravityVelocity:_,isEnabled:L}=i;c?.parent&&i.wrapperQuaternion.copy(c.parent.quaternion);const O={...b};if(Array.isArray(a.material)?a.material.forEach(e=>{e instanceof ye&&(e.uniforms.elapsed.value=n)}):a.material instanceof ye&&(a.material.uniforms.elapsed.value=n),a.getWorldPosition(A),-99999!==b.x&&R.set(A.x-b.x,A.y-b.y,A.z-b.z),i.distanceFromLastEmitByDistance+=R.length(),a.getWorldPosition(b),a.getWorldQuaternion(S),-99999!==M.x&&M.x===S.x&&M.y===S.y&&M.z===S.z||(E.setFromQuaternion(S),M.copy(S),_.set(b.x,b.y+T,b.z),a.worldToLocal(_)),i.creationTimes.forEach((n,r)=>{if(a.geometry.attributes.isActive.array[r]){const s=e-n;if(s>a.geometry.attributes.startLifetime.array[r])y(r);else{const e=g[r];if(e.x-=_.x*t,e.y-=_.y*t,e.z-=_.z*t,0!==T||0!==e.x||0!==e.y||0!==e.z||0!==R.x||0!==R.y||0!==R.z){const n=3*r,s=a.geometry.attributes.position.array;"WORLD"===x&&(s[n]-=R.x,s[n+1]-=R.y,s[n+2]-=R.z),s[n]+=e.x*t,s[n+1]+=e.y*t,s[n+2]+=e.z*t,a.geometry.attributes.position.needsUpdate=!0}a.geometry.attributes.lifetime.array[r]=s,a.geometry.attributes.lifetime.needsUpdate=!0;const n=s/a.geometry.attributes.startLifetime.array[r];rt({delta:t,generalData:i,normalizedConfig:m,attributes:a.geometry.attributes,particleLifetimePercentage:n,particleIndex:r})}}}),L&&(d||w<1e3*h)){const o=e-u,c=p.rateOverTime?Math.floor(et(i.particleSystemId,p.rateOverTime,i.normalizedLifetimePercentage)*(o/1e3)):0,l=p.rateOverDistance?et(i.particleSystemId,p.rateOverDistance,i.normalizedLifetimePercentage):0,h=l>0&&i.distanceFromLastEmitByDistance>0?Math.floor(i.distanceFromLastEmitByDistance/(1/l)):0,d=h>0?{x:(A.x-O.x)/h,y:(A.y-O.y)/h,z:(A.z-O.z)/h}:null,m=c+h;if(l>0&&h>=1&&(i.distanceFromLastEmitByDistance=0),m>0){let t=0;for(let n=0;n<m;n++){let n=-1;if(a.geometry.attributes.isActive.array.find((e,t)=>!e&&(n=t,!0)),-1!==n&&n<a.geometry.attributes.isActive.array.length){let s={x:0,y:0,z:0};d&&t<h&&(s={x:d.x*t,y:d.y*t,z:d.z*t},t++),v({particleIndex:n,activationTime:e,position:s}),r.lastEmissionTime=e}}}s&&s({particleSystem:a,delta:t,elapsed:n,lifetime:w,normalizedLifetime:I,iterationCount:f+1})}else o&&o({particleSystem:a})})};export{rt as applyModifiers,Tr as blendingMap,Qe as calculateRandomPositionAndVelocityOnBox,qe as calculateRandomPositionAndVelocityOnCircle,Xe as calculateRandomPositionAndVelocityOnCone,Ye as calculateRandomPositionAndVelocityOnRectangle,We as calculateRandomPositionAndVelocityOnSphere,et as calculateValue,Be as createBezierCurveFunction,Ze as createDefaultParticleTexture,Ar as createParticleSystem,He as getBezierCacheSize,Ke as getCurveFunction,Je as getCurveFunctionFromConfig,wr as getDefaultParticleSystemConfig,$e as isLifeTimeCurve,Ve as removeBezierCurveFunction,Rr as updateParticleSystems};
|