@newkrok/three-particles 2.6.3 → 2.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1782 -7
- package/dist/index.js +1578 -6
- package/dist/index.js.map +1 -0
- package/dist/three-particles.min.js +1 -2
- package/dist/three-particles.min.js.map +1 -0
- package/package.json +5 -7
- package/dist/bundle-report.json +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/js/effects/three-particles/index.d.ts +0 -7
- package/dist/js/effects/three-particles/index.d.ts.map +0 -1
- package/dist/js/effects/three-particles/index.js +0 -6
- package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.d.ts +0 -3
- package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.d.ts.map +0 -1
- package/dist/js/effects/three-particles/shaders/particle-system-fragment-shader.glsl.js +0 -71
- package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.d.ts +0 -3
- package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.d.ts.map +0 -1
- package/dist/js/effects/three-particles/shaders/particle-system-vertex-shader.glsl.js +0 -37
- package/dist/js/effects/three-particles/three-particles-bezier.d.ts +0 -5
- package/dist/js/effects/three-particles/three-particles-bezier.d.ts.map +0 -1
- package/dist/js/effects/three-particles/three-particles-bezier.js +0 -62
- package/dist/js/effects/three-particles/three-particles-curves.d.ts +0 -108
- package/dist/js/effects/three-particles/three-particles-curves.d.ts.map +0 -1
- package/dist/js/effects/three-particles/three-particles-curves.js +0 -62
- package/dist/js/effects/three-particles/three-particles-enums.d.ts +0 -115
- package/dist/js/effects/three-particles/three-particles-enums.d.ts.map +0 -1
- package/dist/js/effects/three-particles/three-particles-enums.js +0 -1
- package/dist/js/effects/three-particles/three-particles-modifiers.d.ts +0 -73
- package/dist/js/effects/three-particles/three-particles-modifiers.d.ts.map +0 -1
- package/dist/js/effects/three-particles/three-particles-modifiers.js +0 -168
- package/dist/js/effects/three-particles/three-particles-utils.d.ts +0 -159
- package/dist/js/effects/three-particles/three-particles-utils.d.ts.map +0 -1
- package/dist/js/effects/three-particles/three-particles-utils.js +0 -302
- package/dist/js/effects/three-particles/three-particles.d.ts +0 -107
- package/dist/js/effects/three-particles/three-particles.d.ts.map +0 -1
- package/dist/js/effects/three-particles/three-particles.js +0 -972
- package/dist/js/effects/three-particles/types.d.ts +0 -1223
- package/dist/js/effects/three-particles/types.d.ts.map +0 -1
- package/dist/js/effects/three-particles/types.js +0 -1
- package/dist/three-particles.min.js.LICENSE.txt +0 -6
|
@@ -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 r,Audio as n,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 P,Line as L,LineBasicMaterial as O,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 re,NormalBlending as ne,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 Pe,Vector2 as Le,Vector3 as Oe,Vector4 as Ce,VectorKeyframeTrack as Ne}from"THREE";var ke={300(e){const t=e=>e,r={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))}},n={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 r;return 0===e?0:1===e?1:(t<1?(t=1,r=.1):r=.4*Math.asin(1/t)/(2*Math.PI),-t*2**(10*(e-=1))*Math.sin((e-r)*(2*Math.PI)/.4))},Out(e){let t=.1;let r;return 0===e?0:1===e?1:(t<1?(t=1,r=.1):r=.4*Math.asin(1/t)/(2*Math.PI),t*2**(-10*e)*Math.sin((e-r)*(2*Math.PI)/.4)+1)},InOut(e){let t=.1;const r=.4;let n;if(0===e)return 0;if(1===e)return 1;t<1?(t=1,n=.1):n=r*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-n)*(2*Math.PI)/r)*-.5}const i=s-1;return t*2**(-10*i)*Math.sin((i-n)*(2*Math.PI)/r)*.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 r=2*e;return r<1?r*r*((t+1)*r-t)*.5:(r-=2,.5*(r*r*((t+1)*r+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:r,Cubic:n,Quartic:s,Quintic:i,Sinusoidal:o,Exponential:a,Circular:c,Elastic:l,Back:u,Bounce:h},p=(e,t,r)=>Object.defineProperty(e,t,{value:r});for(const e of Object.keys(d)){const t=d[e],r=e.toLowerCase();p(d,r,t);for(const n of Object.keys(t)){const s=t[n],i=n.toLowerCase();p(d,`${e}.${n}`,s),p(d,`${r}.${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 r=De[e]={exports:{}};return ke[e](r,r.exports,Fe),r.exports}Fe.d=(e,t)=>{for(var r in t)Fe.o(t,r)&&!Fe.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},Fe.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const Ue=[],ze=(e,t)=>{let r=1;for(let n=1;n<=t;n++)r*=(e+1-n)/n;return r},Be=(e,t)=>{const r=Ue.find(e=>e.bezierPoints===t);if(r)return r.referencedBy.includes(e)||r.referencedBy.push(e),r.curveFunction;const n={referencedBy:[e],bezierPoints:t,curveFunction:e=>{if(e<0)return t[0].y;if(e>1)return t[t.length-1].y;let r=0,n=t.length-1;t.find((t,s)=>{const i=e<(t.percentage??0);return i?n=s:void 0!==t.percentage&&(r=s),i});const s=n-r,i=(e-(t[r].percentage??0))/((t[n].percentage??1)-(t[r].percentage??0));let o=0;for(let e=0;e<=s;e++){const n=t[r+e];o+=ze(s,e)*Math.pow(1-i,s-e)*Math.pow(i,e)*n.y}return o}};return Ue.push(n),n.curveFunction},Ve=e=>{for(;;){const t=Ue.findIndex(t=>t.referencedBy.includes(e));if(-1===t)break;const r=Ue[t];r.referencedBy=r.referencedBy.filter(t=>t!==e),0===r.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,r,n,{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();r.set(e.x*y*n,e.y*y*n,e.z*y*n),r.applyQuaternion(t)},Xe=(e,t,r,n,{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;r.set(e.x*f*g*n,e.y*f*g*n,Math.cos(m)*n),r.applyQuaternion(t)},Qe=(e,t,r,n,{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()),r=t%3,n=[];n[r]=t>2?1:0,n[(r+1)%3]=Math.random(),n[(r+2)%3]=Math.random(),e.x=n[0]*o.x-o.x/2,e.y=n[1]*o.y-o.y/2,e.z=n[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),r.set(0,0,n),r.applyQuaternion(t)},qe=(e,t,r,n,{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();r.set(e.x*d*n,e.y*d*n,0),r.applyQuaternion(t)},Ye=(e,t,r,n,{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),r.set(0,0,n),r.applyQuaternion(t)},Ze=()=>{try{const e=document.createElement("canvas"),t=64;e.width=t,e.height=t;const r=e.getContext("2d");if(r){const n=t/2,s=t/2,i=t/2-2;r.beginPath(),r.arc(n,s,i,0,2*Math.PI,!1),r.fillStyle="white",r.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,r=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 n=t;return Je(e,n)(r)*(n.scale??1)},tt=new Oe(0,0,0),rt=new v,nt=({delta:e,generalData:t,normalizedConfig:r,attributes:n,particleLifetimePercentage:s,particleIndex:i})=>{const{particleSystemId:o,startValues:a,lifetimeValues:c,linearVelocityData:l,orbitalVelocityData:u,noise:h}=t,d=3*i,p=n.position.array;if(l){const{speed:t,valueModifiers:r}=l[i],o=r.x?r.x(s):t.x,a=r.y?r.y(s):t.y,c=r.z?r.z(s):t.z;p[d]+=o*e,p[d+1]+=a*e,p[d+2]+=c*e,n.position.needsUpdate=!0}if(u){const{speed:t,positionOffset:r,valueModifiers:o}=u[i];p[d]-=r.x,p[d+1]-=r.y,p[d+2]-=r.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;rt.set(a*e,l*e,c*e),r.applyEuler(rt),p[d]+=r.x,p[d+1]+=r.y,p[d+2]+=r.z,n.position.needsUpdate=!0}if(r.sizeOverLifetime.isActive){const e=et(o,r.sizeOverLifetime.lifetimeCurve,s);n.size.array[i]=a.startSize[i]*e,n.size.needsUpdate=!0}if(r.opacityOverLifetime.isActive){const e=et(o,r.opacityOverLifetime.lifetimeCurve,s);n.colorA.array[i]=a.startOpacity[i]*e,n.colorA.needsUpdate=!0}if(r.colorOverLifetime.isActive){const e=et(o,r.colorOverLifetime.r,s),t=et(o,r.colorOverLifetime.g,s),c=et(o,r.colorOverLifetime.b,s);n.colorR.array[i]=a.startColorR[i]*e,n.colorG.array[i]=a.startColorG[i]*t,n.colorB.array[i]=a.startColorB[i]*c,n.colorR.needsUpdate=!0,n.colorG.needsUpdate=!0,n.colorB.needsUpdate=!0}if(c.rotationOverLifetime&&(n.rotation.array[i]+=c.rotationOverLifetime[i]*e*.02,n.rotation.needsUpdate=!0),h.isActive){const{sampler:e,strength:t,noisePower:r,offsets:o,positionAmount:a,rotationAmount:c,sizeAmount:l}=h;let u;const m=10*(s+(o?o[i]:0))*t;tt.set(m,0,0),u=e.get3(tt),p[d]+=u*r*a,0!==c&&(n.rotation.array[i]+=u*r*c,n.rotation.needsUpdate=!0),0!==l&&(n.size.array[i]+=u*r*l,n.size.needsUpdate=!0),tt.set(m,m,0),u=e.get3(tt),p[d+1]+=u*r*a,tt.set(m,m,m),u=e.get3(tt),p[d+2]+=u*r*a,n.position.needsUpdate=!0}};const st=(e,t,r={skippedProperties:[],applyToFirstObject:!1})=>{const n={};return Array.from(new Set([...Object.keys(e||{}),...Object.keys(t||{})])).forEach(s=>{r.skippedProperties&&r.skippedProperties.includes(s)||("object"==typeof e?.[s]&&e?.[s]&&t?.[s]&&!Array.isArray(e[s])?n[s]=st(e[s],t[s],r):(n[s]=0===t?.[s]?0:!1!==t?.[s]&&(t?.[s]||e?.[s]),r.applyToFirstObject&&(e[s]=n[s])))}),n};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 r=new ot(31),n=0;n<31;++n)r[n]=t+=1<<e[n-1];var s=new at(r[30]);for(n=1;n<30;++n)for(var i=r[n];i<r[n+1];++i)s[i]=i-r[n]<<5|n;return{b:r,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,r){for(var n=e.length,s=0,i=new ot(t);s<n;++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(r){o=new ot(1<<t);var c=15-t;for(s=0;s<n;++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(n),s=0;s<n;++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],r=1;r<e.length;++r)e[r]>t&&(t=e[r]);return t},Mt=function(e,t,r){var n=t/8|0;return(e[n]|e[n+1]<<8)>>(7&t)&r},St=function(e,t){var r=t/8|0;return(e[r]|e[r+1]<<8|e[r+2]<<16)>>(7&t)},Et=function(e){return(e+7)/8|0},_t=function(e,t,r){return(null==t||t<0)&&(t=0),(null==r||r>e.length)&&(r=e.length),new it(e.subarray(t,r))},Pt=["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"],Lt=function(e,t,r){var n=new Error(t||Pt[e]);if(n.code=e,Error.captureStackTrace&&Error.captureStackTrace(n,Lt),!r)throw n;return n},Ot=function(e,t,r,n){var s=e.length,i=n?n.length:0;if(!s||t.f&&!t.l)return r||new it(0);var o=!r,a=o||2!=t.i,c=t.i;o&&(r=new it(3*s));var l=function(e){var t=r.length;if(e>t){var n=new it(Math.max(2*t,e));n.set(r),r=n}},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[(P=Et(h)+4)-4]|e[P-3]<<8,T=P+x;if(T>s){c&&Lt(0);break}a&&l(d+x),r.set(e.subarray(P,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 P,L=_[Mt(e,h,E)];if(h+=15&L,(P=L>>4)<16)A[M++]=P;else{var O=0,C=0;for(16==P?(C=3+Mt(e,h,3),h+=2,O=A[M-1]):17==P?(C=3+Mt(e,h,7),h+=3):18==P&&(C=11+Mt(e,h,127),h+=7);C--;)A[M++]=O}}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 Lt(1);if(h>y){c&&Lt(0);break}}a&&l(d+131072);for(var D=(1<<f)-1,F=(1<<g)-1,U=h;;U=h){var z=(O=p[St(e,h)&D])>>4;if((h+=15&O)>y){c&&Lt(0);break}if(O||Lt(2),z<256)r[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||Lt(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&&Lt(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&&Lt(3);d<W;++d)r[d]=n[K+d]}for(;d<G;++d)r[d]=r[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!=r.length&&o?_t(r,0,d):r.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)&&Lt(6,"invalid zlib data"),(e[1]>>5&1)==+!t&&Lt(6,"invalid zlib data: "+(32&e[1]?"need":"unexpected")+" dictionary"),2+(e[1]>>3&4)};function kt(e,t){return Ot(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,r){const n=r.length-e-1;if(t>=r[n])return n-1;if(t<=r[e])return e;let s=e,i=n,o=Math.floor((s+i)/2);for(;t<r[o]||t>=r[o+1];)t<r[o]?i=o:s=o,o=Math.floor((s+i)/2);return o}function Ut(e,t,r,n){const s=[],i=[],o=[];s[0]=1;for(let a=1;a<=r;++a){i[a]=t-n[e+1-a],o[a]=n[e+a]-t;let r=0;for(let e=0;e<a;++e){const t=o[e+1],n=i[a-e],c=s[e]/(t+n);s[e]=r+t*c,r=n*c}s[a]=r}return s}function zt(e,t){let r=1;for(let t=2;t<=e;++t)r*=t;let n=1;for(let e=2;e<=t;++e)n*=e;for(let r=2;r<=e-t;++r)n*=r;return r/n}function Bt(e,t,r,n,s){const i=function(e,t,r,n,s){const i=s<e?s:e,o=[],a=Ft(e,n,t),c=function(e,t,r,n,s){const i=[];for(let e=0;e<=r;++e)i[e]=0;const o=[];for(let e=0;e<=n;++e)o[e]=i.slice(0);const a=[];for(let e=0;e<=r;++e)a[e]=i.slice(0);a[0][0]=1;const c=i.slice(0),l=i.slice(0);for(let n=1;n<=r;++n){c[n]=t-s[e+1-n],l[n]=s[e+n]-t;let r=0;for(let e=0;e<n;++e){const t=l[e+1],s=c[n-e];a[n][e]=t+s;const i=a[e][n-1]/a[n][e];a[e][n]=r+t*i,r=s*i}a[n][n]=r}for(let e=0;e<=r;++e)o[0][e]=a[e][r];for(let e=0;e<=r;++e){let t=0,s=1;const c=[];for(let e=0;e<=r;++e)c[e]=i.slice(0);c[0][0]=1;for(let i=1;i<=n;++i){let n=0;const l=e-i,u=r-i;e>=i&&(c[s][0]=c[t][0]/a[u+1][l],n=c[s][0]*a[l][u]);const h=e-1<=u?i-1:r-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],n+=c[s][e]*a[l+e][u];e<=u&&(c[s][i]=-c[t][i-1]/a[u+1][e],n+=c[s][i]*a[e][u]),o[i][e]=n;const d=t;t=s,s=d}}let u=r;for(let e=1;e<=n;++e){for(let t=0;t<=r;++t)o[e][t]*=u;u*=r-e}return o}(a,n,e,i,t),l=[];for(let e=0;e<r.length;++e){const t=r[e].clone(),n=t.w;t.x*=n,t.y*=n,t.z*=n,l[e]=t}for(let t=0;t<=i;++t){const r=l[a-e].clone().multiplyScalar(c[t][0]);for(let n=1;n<=e;++n)r.add(l[a-e+n].clone().multiplyScalar(c[t][n]));o[t]=r}for(let e=i+1;e<=s+1;++e)o[e]=new Ce(0,0,0);return o}(e,t,r,n,s);return function(e){const t=e.length,r=[],n=[];for(let s=0;s<t;++s){const t=e[s];r[s]=new Oe(t.x,t.y,t.z),n[s]=t.w}const s=[];for(let e=0;e<t;++e){const t=r[e].clone();for(let r=1;r<=e;++r)t.sub(s[e-r].clone().multiplyScalar(zt(e,r)*n[r]));s[e]=t.divideScalar(n[0])}return s}(i)}class Vt extends m{constructor(e,t,r,n,s){super();const i=t?t.length-1:0,o=r?r.length:0;this.degree=e,this.knots=t,this.controlPoints=[],this.startKnot=n||0,this.endKnot=s||i;for(let e=0;e<o;++e){const t=r[e];this.controlPoints[e]=new Ce(t.x,t.y,t.z,t.w)}}getPoint(e,t=new Oe){const r=t,n=this.knots[this.startKnot]+e*(this.knots[this.endKnot]-this.knots[this.startKnot]),s=function(e,t,r,n){const s=Ft(e,n,t),i=Ut(s,n,e,t),o=new Ce(0,0,0,0);for(let t=0;t<=e;++t){const n=r[s-e+t],a=i[t],c=n.w*a;o.x+=n.x*c,o.y+=n.y*c,o.z+=n.z*c,o.w+=n.w*a}return o}(this.degree,this.knots,this.controlPoints,n);return 1!==s.w&&s.divideScalar(s.w),r.set(s.x,s.y,s.z)}getTangent(e,t=new Oe){const r=t,n=this.knots[0]+e*(this.knots[this.knots.length-1]-this.knots[0]),s=Bt(this.degree,this.knots,this.controlPoints,n,1);return r.copy(s[1]).normalize(),r}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,r,n){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(r){try{t(s.parse(r,i))}catch(t){n&&n(t),s.manager.itemError(e)}},r,n)}parse(e,t){if(function(e){const t="Kaydara FBX Binary \0";return e.byteLength>=t.length&&t===cr(e,0,t.length)}(e))Ht=(new Yt).parse(e);else{const t=cr(e);if(!function(e){const t=["K","a","y","d","a","r","a","\\","F","B","X","\\","B","i","n","a","r","y","\\","\\"];let r=0;function n(t){const n=e[t-1];return e=e.slice(r+t),r++,n}for(let e=0;e<t.length;++e){if(n(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 r=new Me(this.manager).setPath(this.resourcePath||t).setCrossOrigin(this.crossOrigin);return new Wt(r,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),r=this.parseMaterials(t),n=this.parseDeformers(),s=(new Xt).parse(n);return this.parseScene(n,s,r),Gt}parseConnections(){const e=new Map;if("Connections"in Ht){Ht.Connections.connections.forEach(function(t){const r=t[0],n=t[1],s=t[2];e.has(r)||e.set(r,{parents:[],children:[]});const i={ID:n,relationship:s};e.get(r).parents.push(i),e.has(n)||e.set(n,{parents:[],children:[]});const o={ID:r,relationship:s};e.get(n).children.push(o)})}return e}parseImages(){const e={},t={};if("Video"in Ht.Objects){const r=Ht.Objects.Video;for(const n in r){const s=r[n];if(e[parseInt(n)]=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(r[n]);t[s.RelativeFilename||s.Filename]=e}}}}for(const r in e){const n=e[r];void 0!==t[n]?e[r]=t[n]:e[r]=e[r].split("\\").pop()}return e}parseImage(e){const t=e.Content,r=e.RelativeFilename||e.Filename;let n;switch(r.slice(r.lastIndexOf(".")+1).toLowerCase()){case"bmp":n="image/bmp";break;case"jpg":case"jpeg":n="image/jpeg";break;case"png":n="image/png";break;case"tif":n="image/tiff";break;case"tga":this.manager.getHandler(".tga"),n="image/tga";break;case"webp":n="image/webp";break;default:return}if("string"==typeof t)return"data:"+n+";base64,"+t;{const e=new Uint8Array(t);return window.URL.createObjectURL(new Blob([e],{type:n}))}}parseTextures(e){const t=new Map;if("Texture"in Ht.Objects){const r=Ht.Objects.Texture;for(const n in r){const s=this.parseTexture(r[n],e);t.set(parseInt(n),s)}}return t}parseTexture(e,t){const r=this.loadTexture(e,t);r.ID=e.id,r.name=e.attrName;const n=e.WrapModeU,s=e.WrapModeV,i=void 0!==n?n.value:0,o=void 0!==s?s.value:0;if(r.wrapS=0===i?fe:h,r.wrapT=0===o?fe:h,"Scaling"in e){const t=e.Scaling.value;r.repeat.x=t[0],r.repeat.y=t[1]}if("Translation"in e){const t=e.Translation.value;r.offset.x=t[0],r.offset.y=t[1]}return r}loadTexture(e,t){const r=e.FileName.split(".").pop().toLowerCase();let n=this.manager.getHandler(`.${r}`);null===n&&(n=this.textureLoader);const s=n.path;s||n.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:")||n.setPath(void 0)),void 0===o)return new Re;const a=n.load(o);return n.setPath(s),a}parseMaterials(e){const t=new Map;if("Material"in Ht.Objects){const r=Ht.Objects.Material;for(const n in r){const s=this.parseMaterial(r[n],e);null!==s&&t.set(parseInt(n),s)}}return t}parseMaterial(e,t){const r=e.id,n=e.attrName;let s=e.ShadingModel;if("object"==typeof s&&(s=s.value),!jt.has(r))return null;const i=this.parseParameters(e,t,r);let o;switch(s.toLowerCase()){case"phong":default:o=new Q;break;case"lambert":o=new X}return o.setValues(i),o.name=n,o}parseParameters(e,t,r){const n={};e.BumpFactor&&(n.bumpScale=e.BumpFactor.value),e.Diffuse?n.color=p.colorSpaceToWorking((new d).fromArray(e.Diffuse.value),ge):!e.DiffuseColor||"Color"!==e.DiffuseColor.type&&"ColorRGB"!==e.DiffuseColor.type||(n.color=p.colorSpaceToWorking((new d).fromArray(e.DiffuseColor.value),ge)),e.DisplacementFactor&&(n.displacementScale=e.DisplacementFactor.value),e.Emissive?n.emissive=p.colorSpaceToWorking((new d).fromArray(e.Emissive.value),ge):!e.EmissiveColor||"Color"!==e.EmissiveColor.type&&"ColorRGB"!==e.EmissiveColor.type||(n.emissive=p.colorSpaceToWorking((new d).fromArray(e.EmissiveColor.value),ge)),e.EmissiveFactor&&(n.emissiveIntensity=parseFloat(e.EmissiveFactor.value)),n.opacity=1-(e.TransparencyFactor?parseFloat(e.TransparencyFactor.value):0),1!==n.opacity&&0!==n.opacity||(n.opacity=e.Opacity?parseFloat(e.Opacity.value):null,null===n.opacity&&(n.opacity=1-(e.TransparentColor?parseFloat(e.TransparentColor.value[0]):0))),n.opacity<1&&(n.transparent=!0),e.ReflectionFactor&&(n.reflectivity=e.ReflectionFactor.value),e.Shininess&&(n.shininess=e.Shininess.value),e.Specular?n.specular=p.colorSpaceToWorking((new d).fromArray(e.Specular.value),ge):e.SpecularColor&&"Color"===e.SpecularColor.type&&(n.specular=p.colorSpaceToWorking((new d).fromArray(e.SpecularColor.value),ge));const s=this;return jt.get(r).children.forEach(function(e){switch(e.relationship){case"Bump":n.bumpMap=s.getTexture(t,e.ID);break;case"Maya|TEX_ao_map":n.aoMap=s.getTexture(t,e.ID);break;case"DiffuseColor":case"Maya|TEX_color_map":n.map=s.getTexture(t,e.ID),void 0!==n.map&&(n.map.colorSpace=ge);break;case"DisplacementColor":n.displacementMap=s.getTexture(t,e.ID);break;case"EmissiveColor":n.emissiveMap=s.getTexture(t,e.ID),void 0!==n.emissiveMap&&(n.emissiveMap.colorSpace=ge);break;case"NormalMap":case"Maya|TEX_normal_map":n.normalMap=s.getTexture(t,e.ID);break;case"ReflectionColor":n.envMap=s.getTexture(t,e.ID),void 0!==n.envMap&&(n.envMap.mapping=y,n.envMap.colorSpace=ge);break;case"SpecularColor":n.specularMap=s.getTexture(t,e.ID),void 0!==n.specularMap&&(n.specularMap.colorSpace=ge);break;case"TransparentColor":case"TransparencyFactor":n.alphaMap=s.getTexture(t,e.ID),n.transparent=!0}}),n}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 r=Ht.Objects.Deformer;for(const n in r){const s=r[n],i=jt.get(parseInt(n));if("Skin"===s.attrType){const t=this.parseSkeleton(i,r);t.ID=n,i.parents.length,t.geometryID=i.parents[0].ID,e[n]=t}else if("BlendShape"===s.attrType){const e={id:n};e.rawTargets=this.parseMorphTargets(i,r),e.id=n,i.parents.length,t[n]=e}}}return{skeletons:e,morphTargets:t}}parseSkeleton(e,t){const r=[];return e.children.forEach(function(e){const n=t[e.ID];if("Cluster"!==n.attrType)return;const s={ID:e.ID,indices:[],weights:[],transformLink:(new G).fromArray(n.TransformLink.a)};"Indexes"in n&&(s.indices=n.Indexes.a,s.weights=n.Weights.a),r.push(s)}),{rawBones:r,bones:[]}}parseMorphTargets(e,t){const r=[];for(let n=0;n<e.children.length;n++){const s=e.children[n],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,r.push(o)}return r}parseScene(e,t,r){Gt=new I;const n=this.parseModels(e.skeletons,t,r),s=Ht.Objects.Model,i=this;n.forEach(function(e){const t=s[e.ID];i.setLookAtProperties(e,t);jt.get(e.ID).parents.forEach(function(t){const r=n.get(t.ID);void 0!==r&&r.add(e)}),null===e.parent&&Gt.add(e)}),this.bindSkeleton(e.skeletons,t,n),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=ir(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,r){const n=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,r);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),n.set(a,u)}return n}buildSkeleton(e,t,r,n){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=n?de.sanitizeNodeName(n):"",s.userData.originalName=n,s.ID=r,a.bones[i]=s,null!==e&&s.add(e)}})}}),s}createCamera(e){let t,r;if(e.children.forEach(function(e){const t=Ht.Objects.NodeAttribute[e.ID];void 0!==t&&(r=t)}),void 0===r)t=new ie;else{let e=0;void 0!==r.CameraProjectionType&&1===r.CameraProjectionType.value&&(e=1);let n=1;void 0!==r.NearPlane&&(n=r.NearPlane.value/1e3);let s=1e3;void 0!==r.FarPlane&&(s=r.FarPlane.value/1e3);let i=window.innerWidth,o=window.innerHeight;void 0!==r.AspectWidth&&void 0!==r.AspectHeight&&(i=r.AspectWidth.value,o=r.AspectHeight.value);const a=i/o;let c=45;void 0!==r.FieldOfView&&(c=r.FieldOfView.value);const l=r.FocalLength?r.FocalLength.value:null;if(0===e)t=new ae(c,a,n,s),null!==l&&t.setFocalLength(l);else t=new ie}return t}createLight(e){let t,r;if(e.children.forEach(function(e){const t=Ht.Objects.NodeAttribute[e.ID];void 0!==t&&(r=t)}),void 0===r)t=new ie;else{let e;e=void 0===r.LightType?0:r.LightType.value;let n=16777215;void 0!==r.Color&&(n=p.colorSpaceToWorking((new d).fromArray(r.Color.value),ge));let s=void 0===r.Intensity?1:r.Intensity.value/100;void 0!==r.CastLightOnObject&&0===r.CastLightOnObject.value&&(s=0);let i=0;void 0!==r.FarAttenuationEnd&&(i=void 0!==r.EnableFarAttenuation&&0===r.EnableFarAttenuation.value?0:r.FarAttenuationEnd.value);const o=1;switch(e){case 0:t=new ce(n,s,i,o);break;case 1:t=new f(n,s);break;case 2:let e=Math.PI/3;void 0!==r.InnerAngle&&(e=H.degToRad(r.InnerAngle.value));let a=0;void 0!==r.OuterAngle&&(a=H.degToRad(r.OuterAngle.value),a=Math.max(a,1)),t=new be(n,s,i,e,a,o);break;default:t=new ce(n,s)}void 0!==r.CastShadows&&1===r.CastShadows.value&&(t.castShadow=!0)}return t}createMesh(e,t,r){let n,s=null,i=null;const o=[];if(e.children.forEach(function(e){t.has(e.ID)&&(s=t.get(e.ID)),r.has(e.ID)&&o.push(r.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,r=s.groups.length;t<r;t++){const r=s.groups[t];(r.materialIndex<0||r.materialIndex>=o.length)&&(r.materialIndex=o.length,e=!0)}if(e){const e=new Q;o.push(e)}}return s.FBX_Deformer?(n=new Te(s,i),n.normalizeSkinWeights()):n=new K(s,i),n}createCurve(e,t){const r=e.children.reduce(function(e,r){return t.has(r.ID)&&(e=t.get(r.ID)),e},null),n=new O({name:z.DEFAULT_MATERIAL_NAME,color:3342591,linewidth:1});return new L(r,n)}getTransformData(e,t){const r={};"InheritType"in t&&(r.inheritType=parseInt(t.InheritType.value)),r.eulerOrder=or("RotationOrder"in t?t.RotationOrder.value:0),"Lcl_Translation"in t&&(r.translation=t.Lcl_Translation.value),"PreRotation"in t&&(r.preRotation=t.PreRotation.value),"Lcl_Rotation"in t&&(r.rotation=t.Lcl_Rotation.value),"PostRotation"in t&&(r.postRotation=t.PostRotation.value),"Lcl_Scaling"in t&&(r.scale=t.Lcl_Scaling.value),"ScalingOffset"in t&&(r.scalingOffset=t.ScalingOffset.value),"ScalingPivot"in t&&(r.scalingPivot=t.ScalingPivot.value),"RotationOffset"in t&&(r.rotationOffset=t.RotationOffset.value),"RotationPivot"in t&&(r.rotationPivot=t.RotationPivot.value),e.userData.transformData=r}setLookAtProperties(e,t){if("LookAtProperty"in t){jt.get(e.ID).children.forEach(function(t){if("LookAtProperty"===t.relationship){const r=Ht.Objects.Model[t.ID];if("Lcl_Translation"in r){const t=r.Lcl_Translation.value;void 0!==e.target?(e.target.position.fromArray(t),Gt.add(e.target)):e.lookAt((new Oe).fromArray(t))}}})}}bindSkeleton(e,t,r){const n=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(r.has(e.ID)){r.get(e.ID).bind(new xe(i.bones),n[e.ID])}})}})}}parsePoseNodes(){const e={};if("Pose"in Ht.Objects){const t=Ht.Objects.Pose;for(const r in t)if("BindPose"===t[r].attrType&&t[r].NbPoseNodes>0){const n=t[r].PoseNode;Array.isArray(n)?n.forEach(function(t){e[t.Node]=(new G).fromArray(t.Matrix.a)}):e[n.Node]=(new G).fromArray(n.Matrix.a)}}return e}addGlobalSceneSettings(){if("GlobalSettings"in Ht){if("AmbientColor"in Ht.GlobalSettings){const e=Ht.GlobalSettings.AmbientColor.value,r=e[0],n=e[1],s=e[2];if(0!==r||0!==n||0!==s){const e=(new d).setRGB(r,n,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 r=Ht.Objects.Geometry;for(const n in r){const s=jt.get(parseInt(n)),i=this.parseGeometry(s,r[n],e);t.set(parseInt(n),i)}}return this.negativeMaterialIndices,t}parseGeometry(e,t,r){switch(t.attrType){case"Mesh":return this.parseMeshGeometry(e,t,r);case"NurbsCurve":return this.parseNurbsGeometry(t)}}parseMeshGeometry(e,t,r){const n=r.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!==n[t.ID]&&(e=n[t.ID]),e},null);e.children.forEach(function(e){void 0!==r.morphTargets[e.ID]&&s.push(r.morphTargets[e.ID])});const a=i[0],c={};"RotationOrder"in a&&(c.eulerOrder=or(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=ir(c);return this.genGeometry(t,o,s,l)}genGeometry(e,t,r,n){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(n),s.setAttribute("position",a),o.colors.length>0&&s.setAttribute("color",new T(o.colors,3)),t&&(s.setAttribute("skinIndex",new Pe(o.weightsIndices,4)),s.setAttribute("skinWeight",new T(o.vertexWeights,4)),s.FBX_Deformer=t),o.normal.length>0){const e=(new j).getNormalMatrix(n),t=new T(o.normal,3);t.applyNormalMatrix(e),s.setAttribute("normal",t)}if(o.uvs.forEach(function(e,t){const r=0===t?"uv":`uv${t}`;s.setAttribute(r,new T(o.uvs[t],2))}),i.material&&"AllSame"!==i.material.mappingType){let e=o.materialIndex[0],t=0;if(o.materialIndex.forEach(function(r,n){r!==e&&(s.addGroup(t,n-t,e),e=r,t=n)}),s.groups.length>0){const t=s.groups[s.groups.length-1],r=t.start+t.count;r!==o.materialIndex.length&&s.addGroup(r,o.materialIndex.length-r,e)}0===s.groups.length&&s.addGroup(0,o.materialIndex.length,o.materialIndex[0])}return this.addMorphTargets(s,e,r,n),s}parseGeoNode(e,t){const r={};if(r.vertexPositions=void 0!==e.Vertices?e.Vertices.a:[],r.vertexIndices=void 0!==e.PolygonVertexIndex?e.PolygonVertexIndex.a:[],e.LayerElementColor&&e.LayerElementColor[0].Colors&&(r.color=this.parseVertexColors(e.LayerElementColor[0])),e.LayerElementMaterial&&(r.material=this.parseMaterialIndices(e.LayerElementMaterial[0])),e.LayerElementNormal&&(r.normal=this.parseNormals(e.LayerElementNormal[0])),e.LayerElementUV){r.uv=[];let t=0;for(;e.LayerElementUV[t];)e.LayerElementUV[t].UV&&r.uv.push(this.parseUVs(e.LayerElementUV[t])),t++}return r.weightTable={},null!==t&&(r.skeleton=t,t.rawBones.forEach(function(e,t){e.indices.forEach(function(n,s){void 0===r.weightTable[n]&&(r.weightTable[n]=[]),r.weightTable[n].push({id:t,weight:e.weights[s]})})})),r}genBuffers(e){const t={vertex:[],normal:[],colors:[],uvs:[],materialIndex:[],vertexWeights:[],weightsIndices:[]};let r=0,n=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=rr(p,r,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(r,n){let s=r,i=g[n];t.forEach(function(t,r,n){if(s>t){n[r]=s,s=t;const o=e[r];e[r]=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=rr(p,r,d,e.normal);o.push(t[0],t[1],t[2])}e.material&&"AllSame"!==e.material.mappingType&&(m=rr(p,r,d,e.material)[0],m<0&&(h.negativeMaterialIndices=!0,m=0)),e.uv&&e.uv.forEach(function(e,t){const n=rr(p,r,d,e);void 0===c[t]&&(c[t]=[]),c[t].push(n[0]),c[t].push(n[1])}),n++,f&&(h.genFace(t,e,i,m,o,a,c,l,u,n),r++,n=0,i=[],o=[],a=[],c=[],l=[],u=[])}),t}getNormalNewell(e){const t=new Oe(0,0,0);for(let r=0;r<e.length;r++){const n=e[r],s=e[(r+1)%e.length];t.x+=(n.y-s.y)*(n.z+s.z),t.y+=(n.z-s.z)*(n.x+s.x),t.z+=(n.x-s.x)*(n.y+s.y)}return t.normalize(),t}getNormalTangentAndBitangent(e){const t=this.getNormalNewell(e),r=(Math.abs(t.z)>.5?new Oe(0,1,0):new Oe(0,0,1)).cross(t).normalize(),n=t.clone().cross(r).normalize();return{normal:t,tangent:r,bitangent:n}}flattenVertex(e,t,r){return new Le(e.dot(t),e.dot(r))}genFace(e,t,r,n,s,i,o,a,c,l){let u;if(l>3){const e=[],n=t.baseVertexPositions||t.vertexPositions;for(let t=0;t<r.length;t+=3)e.push(new Oe(n[r[t]],n[r[t+1]],n[r[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[r[3*l]]),e.vertex.push(t.vertexPositions[r[3*l+1]]),e.vertex.push(t.vertexPositions[r[3*l+2]]),e.vertex.push(t.vertexPositions[r[3*h]]),e.vertex.push(t.vertexPositions[r[3*h+1]]),e.vertex.push(t.vertexPositions[r[3*h+2]]),e.vertex.push(t.vertexPositions[r[3*d]]),e.vertex.push(t.vertexPositions[r[3*d+1]]),e.vertex.push(t.vertexPositions[r[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(n),e.materialIndex.push(n),e.materialIndex.push(n)),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,r){void 0===e.uvs[r]&&(e.uvs[r]=[]),e.uvs[r].push(o[r][2*l]),e.uvs[r].push(o[r][2*l+1]),e.uvs[r].push(o[r][2*h]),e.uvs[r].push(o[r][2*h+1]),e.uvs[r].push(o[r][2*d]),e.uvs[r].push(o[r][2*d+1])})}addMorphTargets(e,t,r,n){if(0===r.length)return;e.morphTargetsRelative=!0,e.morphAttributes.position=[];const s=this;r.forEach(function(r){r.rawTargets.forEach(function(r){const i=Ht.Objects.Geometry[r.geoID];void 0!==i&&s.genMorphGeometry(e,t,i,n,r.name)})})}genMorphGeometry(e,t,r,n,s){const i=void 0!==t.Vertices?t.Vertices.a:[],o=void 0!==t.PolygonVertexIndex?t.PolygonVertexIndex.a:[],a=void 0!==r.Vertices?r.Vertices.a:[],c=void 0!==r.Indexes?r.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||r.attrName,p.applyMatrix4(n),e.morphAttributes.position.push(p)}parseNormals(e){const t=e.MappingInformationType,r=e.ReferenceInformationType,n=e.Normals.a;let s=[];return"IndexToDirect"===r&&("NormalIndex"in e?s=e.NormalIndex.a:"NormalsIndex"in e&&(s=e.NormalsIndex.a)),{dataSize:3,buffer:n,indices:s,mappingType:t,referenceType:r}}parseUVs(e){const t=e.MappingInformationType,r=e.ReferenceInformationType,n=e.UV.a;let s=[];return"IndexToDirect"===r&&(s=e.UVIndex.a),{dataSize:2,buffer:n,indices:s,mappingType:t,referenceType:r}}parseVertexColors(e){const t=e.MappingInformationType,r=e.ReferenceInformationType,n=e.Colors.a;let s=[];"IndexToDirect"===r&&(s=e.ColorIndex.a);for(let e=0,t=new d;e<n.length;e+=4)t.fromArray(n,e),p.colorSpaceToWorking(t,ge),t.toArray(n,e);return{dataSize:4,buffer:n,indices:s,mappingType:t,referenceType:r}}parseMaterialIndices(e){const t=e.MappingInformationType,r=e.ReferenceInformationType;if("NoMappingInformation"===t)return{dataSize:1,buffer:[0],indices:[0],mappingType:"AllSame",referenceType:r};const n=e.Materials.a,s=[];for(let e=0;e<n.length;++e)s.push(e);return{dataSize:1,buffer:n,indices:s,mappingType:t,referenceType:r}}parseNurbsGeometry(e){const t=parseInt(e.Order);if(isNaN(t))return new l;const r=t-1,n=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=r,a=n.length-1-o;for(let e=0;e<r;++e)s.push(s[e])}const c=new Vt(r,n,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 r in t){const n=t[r],s=this.addClip(n);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 r in e){const n=e[r];if(null!==n.attrName.match(/S|R|T|DeformPercent/)){const e={id:n.id,attr:n.attrName,curves:{}};t.set(e.id,e)}}return t}parseAnimationCurves(e){const t=Ht.Objects.AnimationCurve;for(const r in t){const n={id:t[r].id,times:t[r].KeyTime.a.map(er),values:t[r].KeyValueFloat.a},s=jt.get(n.id);if(void 0!==s){const t=s.parents[0].ID,r=s.parents[0].relationship;r.match(/X/)?e.get(t).curves.x=n:r.match(/Y/)?e.get(t).curves.y=n:r.match(/Z/)?e.get(t).curves.z=n:r.match(/DeformPercent/)&&e.has(t)&&(e.get(t).curves.morph=n)}}}parseAnimationLayers(e){const t=Ht.Objects.AnimationLayer,r=new Map;for(const n in t){const t=[],s=jt.get(parseInt(n));if(void 0!==s){s.children.forEach(function(r,n){if(e.has(r.ID)){const s=e.get(r.ID);if(void 0!==s.curves.x||void 0!==s.curves.y||void 0!==s.curves.z){if(void 0===t[n]){const e=jt.get(r.ID).parents.filter(function(e){return void 0!==e.relationship})[0].ID;if(void 0!==e){const r=Ht.Objects.Model[e.toString()];if(void 0===r)return;const s={modelName:r.attrName?de.sanitizeNodeName(r.attrName):"",ID:r.id,initialPosition:[0,0,0],initialRotation:[0,0,0],initialScale:[1,1,1]};Gt.traverse(function(e){e.ID===r.id&&(s.transform=e.matrix,e.userData.transformData&&(s.eulerOrder=e.userData.transformData.eulerOrder))}),s.transform||(s.transform=new G),"PreRotation"in r&&(s.preRotation=r.PreRotation.value),"PostRotation"in r&&(s.postRotation=r.PostRotation.value),t[n]=s}}t[n]&&(t[n][s.attr]=s)}else if(void 0!==s.curves.morph){if(void 0===t[n]){const e=jt.get(r.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[n]=c}t[n][s.attr]=s}}}),r.set(parseInt(n),t)}}return r}parseAnimStacks(e){const t=Ht.Objects.AnimationStack,r={};for(const n in t){const s=jt.get(parseInt(n)).children;s.length;const i=e.get(s[0].ID);r[n]={name:t[n].attrName,layer:i}}return r}addClip(e){let t=[];const n=this;return e.layer.forEach(function(e){t=t.concat(n.generateTracks(e))}),new r(e.name,-1,t)}generateTracks(e){const t=[];let r=new Oe,n=new Oe;if(e.transform&&e.transform.decompose(r,new pe,n),r=r.toArray(),n=n.toArray(),void 0!==e.T&&Object.keys(e.T.curves).length>0){const n=this.generateVectorTrack(e.modelName,e.T.curves,r,"position");void 0!==n&&t.push(n)}if(void 0!==e.R&&Object.keys(e.R.curves).length>0){const r=this.generateRotationTrack(e.modelName,e.R.curves,e.preRotation,e.postRotation,e.eulerOrder);void 0!==r&&t.push(r)}if(void 0!==e.S&&Object.keys(e.S.curves).length>0){const r=this.generateVectorTrack(e.modelName,e.S.curves,n,"scale");void 0!==r&&t.push(r)}if(void 0!==e.DeformPercent){const r=this.generateMorphTrack(e);void 0!==r&&t.push(r)}return t}generateVectorTrack(e,t,r,n){const s=this.getTimesForAllAxes(t),i=this.getKeyframeTrackValues(s,t,r);return new Ne(e+"."+n,s,i)}generateRotationTrack(e,t,r,n,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=or(0);void 0!==r&&((r=r.map(H.degToRad)).push(a),r=(new v).fromArray(r),r=(new pe).setFromEuler(r)),void 0!==n&&((n=n.map(H.degToRad)).push(a),n=(new v).fromArray(n),n=(new pe).setFromEuler(n).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!==r&&c.premultiply(r),void 0!==n&&c.multiply(n),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,r=t.values.map(function(e){return e/100}),n=Gt.getObjectByName(e.modelName).morphTargetDictionary[e.morphName];return new se(e.modelName+".morphTargetInfluences["+n+"]",t.times,r)}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,r=t[0];for(let n=1;n<t.length;n++){const s=t[n];s!==r&&(t[e]=s,r=s,e++)}t=t.slice(0,e)}return t}getKeyframeTrackValues(e,t,r){const n=r,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),n[0]=e}else s.push(n[0]);if(-1!==o){const e=t.y.values[o];s.push(e),n[1]=e}else s.push(n[1]);if(-1!==a){const e=t.z.values[a];s.push(e),n[2]=e}else s.push(n[2])}),s}interpolateRotations(e,t,r,n){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(r.values[0]));for(let o=1;o<e.values.length;o++){const a=[e.values[o-1],t.values[o-1],r.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],r.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,r=new v(...c,n),a=new v(...u,n),l=(new pe).setFromEuler(r),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,n),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(r.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,r=e.split(/[\r\n]+/);return r.forEach(function(e,n){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,r[++n]):c?t.popStack():e.match(/^[^\s\t}]/)&&t.parseNodePropertyContinued(e)}),this.allNodes}parseNodeBegin(e,t){const r=t[1].trim().replace(/^"/,"").replace(/"$/,""),n=t[2].split(",").map(function(e){return e.trim().replace(/^"/,"").replace(/"$/,"")}),s={name:r},i=this.parseNodeAttr(n),o=this.getCurrentNode();0===this.currentIndent?this.allNodes.add(r,s):r in o?("PoseNode"===r?o.PoseNode.push(s):void 0!==o[r].id&&(o[r]={},o[r][o[r].id]=o[r]),""!==i.id&&(o[r][i.id]=s)):"number"==typeof i.id?(o[r]={},o[r][i.id]=s):"Properties70"!==r&&(o[r]="PoseNode"===r?[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 r="",n="";return e.length>1&&(r=e[1].replace(/^(\w+)::/,""),n=e[2]),{id:t,name:r,type:n}}parseNodeProperty(e,t,r){let n=t[1].replace(/^"/,"").replace(/"$/,"").trim(),s=t[2].replace(/^"/,"").replace(/"$/,"").trim();"Content"===n&&","===s&&(s=r.replace(/"/g,"").replace(/,$/,"").trim());const i=this.getCurrentNode();if("Properties70"!==i.name){if("C"===n){const e=s.split(",").slice(1),t=parseInt(e[0]),r=parseInt(e[1]);let o=s.split(",").slice(3);o=o.map(function(e){return e.trim().replace(/^"/,"")}),n="connections",s=[t,r],function(e,t){for(let r=0,n=e.length,s=t.length;r<s;r++,n++)e[n]=t[r]}(s,o),void 0===i[n]&&(i[n]=[])}"Node"===n&&(i.id=s),n in i&&Array.isArray(i[n])?i[n].push(s):"a"!==n?i[n]=s:i.a=s,this.setCurrentProp(i,n),"a"===n&&","!==s.slice(-1)&&(i.a=ar(s))}else this.parseNodeSpecialProperty(e,n,s)}parseNodePropertyContinued(e){const t=this.getCurrentNode();t.a+=e,","!==e.slice(-1)&&(t.a=ar(t.a))}parseNodeSpecialProperty(e,t,r){const n=r.split('",').map(function(e){return e.trim().replace(/^\"/,"").replace(/\s/,"_")}),s=n[0],i=n[1],o=n[2],a=n[3];let c=n[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=ar(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 r=t.getUint32();if(r<6400)throw new Error("THREE.FBXLoader: FBX version not supported, FileVersion: "+r);const n=new $t;for(;!this.endOfContent(t);){const e=this.parseNode(t,r);null!==e&&n.add(e.name,e)}return n}endOfContent(e){return e.size()%16==0?(e.getOffset()+160+16&-16)>=e.size():e.getOffset()+160+16>=e.size()}parseNode(e,t){const r={},n=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===n)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(r.singleProperty=1===s&&e.getOffset()===n;n>e.getOffset();){const n=this.parseNode(e,t);null!==n&&this.parseSubNode(o,r,n)}return r.propertyList=a,"number"==typeof c&&(r.id=c),""!==l&&(r.attrName=l),""!==u&&(r.attrType=u),""!==o&&(r.name=o),r}parseSubNode(e,t,r){if(!0===r.singleProperty){const e=r.propertyList[0];Array.isArray(e)?(t[r.name]=r,r.a=e):t[r.name]=e}else if("Connections"===e&&"C"===r.name){const e=[];r.propertyList.forEach(function(t,r){0!==r&&e.push(t)}),void 0===t.connections&&(t.connections=[]),t.connections.push(e)}else if("Properties70"===r.name){Object.keys(r).forEach(function(e){t[e]=r[e]})}else if("Properties70"===e&&"P"===r.name){let e=r.propertyList[0],n=r.propertyList[1];const s=r.propertyList[2],i=r.propertyList[3];let o;0===e.indexOf("Lcl ")&&(e=e.replace("Lcl ","Lcl_")),0===n.indexOf("Lcl ")&&(n=n.replace("Lcl ","Lcl_")),o="Color"===n||"ColorRGB"===n||"Vector"===n||"Vector3D"===n||0===n.indexOf("Lcl_")?[r.propertyList[4],r.propertyList[5],r.propertyList[6]]:r.propertyList[4],t[e]={type:n,type2:s,flag:i,value:o}}else void 0===t[r.name]?"number"==typeof r.id?(t[r.name]={},t[r.name][r.id]=r):t[r.name]=r:"PoseNode"===r.name?(Array.isArray(t[r.name])||(t[r.name]=[t[r.name]]),t[r.name].push(r)):void 0===t[r.name][r.id]&&(t[r.name][r.id]=r)}parseProperty(e){const t=e.getString(1);let r;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 r=e.getUint32(),e.getArrayBuffer(r);case"S":return r=e.getUint32(),e.getString(r);case"Y":return e.getInt16();case"b":case"c":case"d":case"f":case"i":case"l":const n=e.getUint32(),s=e.getUint32(),i=e.getUint32();if(0===s)switch(t){case"b":case"c":return e.getBooleanArray(n);case"d":return e.getFloat64Array(n);case"f":return e.getFloat32Array(n);case"i":return e.getInt32Array(n);case"l":return e.getInt64Array(n)}const o=kt(new Uint8Array(e.getArrayBuffer(i))),a=new Zt(o.buffer);switch(t){case"b":case"c":return a.getBooleanArray(n);case"d":return a.getFloat64Array(n);case"f":return a.getFloat32Array(n);case"i":return a.getInt32Array(n);case"l":return a.getInt64Array(n)}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 r=0;r<e;r++)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 r=0;r<e;r++)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 r=0;r<e;r++)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 r=0;r<e;r++)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 r=0;r<e;r++)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 r=new Uint8Array(this.dv.buffer,t,e);this.skip(e);const n=r.indexOf(0);return n>=0&&(r=new Uint8Array(this.dv.buffer,t,n)),this._textDecoder.decode(r)}}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 er(e){return e/46186158e3}const tr=[];function rr(e,t,r,n){let s;switch(n.mappingType){case"ByPolygonVertex":s=e;break;case"ByPolygon":s=t;break;case"ByVertice":s=r;break;case"AllSame":s=n.indices[0]}"IndexToDirect"===n.referenceType&&(s=n.indices[s]);const i=s*n.dataSize,o=i+n.dataSize;return function(e,t,r,n){for(let s=r,i=0;s<n;s++,i++)e[i]=t[s];return e}(tr,n.buffer,i,o)}const nr=new v,sr=new Oe;function ir(e){const t=new G,r=new G,n=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(sr.fromArray(e.translation));const m=or(0);if(e.preRotation){const t=e.preRotation.map(H.degToRad);t.push(m),r.makeRotationFromEuler(nr.fromArray(t))}if(e.rotation){const t=e.rotation.map(H.degToRad);t.push(e.eulerOrder||m),n.makeRotationFromEuler(nr.fromArray(t))}if(e.postRotation){const t=e.postRotation.map(H.degToRad);t.push(m),s.makeRotationFromEuler(nr.fromArray(t)),s.invert()}e.scale&&i.scale(sr.fromArray(e.scale)),e.scalingOffset&&a.setPosition(sr.fromArray(e.scalingOffset)),e.scalingPivot&&o.setPosition(sr.fromArray(e.scalingPivot)),e.rotationOffset&&c.setPosition(sr.fromArray(e.rotationOffset)),e.rotationPivot&&l.setPosition(sr.fromArray(e.rotationPivot)),e.parentMatrixWorld&&(h.copy(e.parentMatrix),u.copy(e.parentMatrixWorld));const f=r.clone().multiply(n).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 Oe).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(r).multiply(n).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 or(e){const t=["ZYX","YZX","XZY","ZXY","YXZ","XYZ"];return 6===(e=e||0)?t[0]:t[e]}function ar(e){return e.split(",").map(function(e){return parseFloat(e)})}function cr(e,t,r){return void 0===t&&(t=0),void 0===r&&(r=e.byteLength),(new TextDecoder).decode(new Uint8Array(e,t,r))}function lr(e,t){if(t===_e)return e;if(t===Se||t===Ee){let r=e.getIndex();if(null===r){const t=[],n=e.getAttribute("position");if(void 0===n)return e;for(let e=0;e<n.count;e++)t.push(e);e.setIndex(t),r=e.getIndex()}const n=r.count-2,s=[];if(t===Se)for(let e=1;e<=n;e++)s.push(r.getX(0)),s.push(r.getX(e)),s.push(r.getX(e+1));else for(let e=0;e<n;e++)e%2==0?(s.push(r.getX(e)),s.push(r.getX(e+1)),s.push(r.getX(e+2))):(s.push(r.getX(e+2)),s.push(r.getX(e+1)),s.push(r.getX(e)));s.length;const i=e.clone();return i.setIndex(s),i.clearGroups(),i}return e}function ur(){let e={};return{get:function(t){return e[t]},add:function(t,r){e[t]=r},remove:function(t){delete e[t]},removeAll:function(){e={}}}}const hr={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 dr{constructor(e){this.parser=e,this.name=hr.KHR_LIGHTS_PUNCTUAL,this.cache={refs:{},uses:{}}}_markDefs(){const e=this.parser,t=this.parser.json.nodes||[];for(let r=0,n=t.length;r<n;r++){const n=t[r];n.extensions&&n.extensions[this.name]&&void 0!==n.extensions[this.name].light&&e._addNodeRef(this.cache,n.extensions[this.name].light)}}_loadLight(e){const t=this.parser,r="light:"+e;let n=t.cache.get(r);if(n)return n;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),Jr(o,i),void 0!==i.intensity&&(o.intensity=i.intensity),o.name=t.createUniqueName(i.name||"light_"+e),n=Promise.resolve(o),t.cache.add(r,n),n}getDependency(e,t){if("light"===e)return this._loadLight(t)}createNodeAttachment(e){const t=this,r=this.parser,n=r.json.nodes[e],s=(n.extensions&&n.extensions[this.name]||{}).light;return void 0===s?null:this._loadLight(s).then(function(e){return r._getNodeRef(t.cache,s,e)})}}class pr{constructor(){this.name=hr.KHR_MATERIALS_UNLIT}getMaterialType(){return W}extendParams(e,t,r){const n=[];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&&n.push(r.assignTexture(e,"map",s.baseColorTexture,ge))}return Promise.all(n)}}class mr{constructor(e){this.parser=e,this.name=hr.KHR_MATERIALS_EMISSIVE_STRENGTH}extendMaterialParams(e,t){const r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=r.extensions[this.name].emissiveStrength;return void 0!==n&&(t.emissiveIntensity=n),Promise.resolve()}}class fr{constructor(e){this.parser=e,this.name=hr.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 r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];if(void 0!==i.clearcoatFactor&&(t.clearcoat=i.clearcoatFactor),void 0!==i.clearcoatTexture&&s.push(r.assignTexture(t,"clearcoatMap",i.clearcoatTexture)),void 0!==i.clearcoatRoughnessFactor&&(t.clearcoatRoughness=i.clearcoatRoughnessFactor),void 0!==i.clearcoatRoughnessTexture&&s.push(r.assignTexture(t,"clearcoatRoughnessMap",i.clearcoatRoughnessTexture)),void 0!==i.clearcoatNormalTexture&&(s.push(r.assignTexture(t,"clearcoatNormalMap",i.clearcoatNormalTexture)),void 0!==i.clearcoatNormalTexture.scale)){const e=i.clearcoatNormalTexture.scale;t.clearcoatNormalScale=new Le(e,e)}return Promise.all(s)}}class gr{constructor(e){this.parser=e,this.name=hr.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 r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=r.extensions[this.name];return t.dispersion=void 0!==n.dispersion?n.dispersion:0,Promise.resolve()}}class yr{constructor(e){this.parser=e,this.name=hr.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 r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return void 0!==i.iridescenceFactor&&(t.iridescence=i.iridescenceFactor),void 0!==i.iridescenceTexture&&s.push(r.assignTexture(t,"iridescenceMap",i.iridescenceTexture)),void 0!==i.iridescenceIor&&(t.iridescenceIOR=i.iridescenceIor),void 0===t.iridescenceThicknessRange&&(t.iridescenceThicknessRange=[100,400]),void 0!==i.iridescenceThicknessMinimum&&(t.iridescenceThicknessRange[0]=i.iridescenceThicknessMinimum),void 0!==i.iridescenceThicknessMaximum&&(t.iridescenceThicknessRange[1]=i.iridescenceThicknessMaximum),void 0!==i.iridescenceThicknessTexture&&s.push(r.assignTexture(t,"iridescenceThicknessMap",i.iridescenceThicknessTexture)),Promise.all(s)}}class vr{constructor(e){this.parser=e,this.name=hr.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 r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[];t.sheenColor=new d(0,0,0),t.sheenRoughness=0,t.sheen=1;const i=n.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(r.assignTexture(t,"sheenColorMap",i.sheenColorTexture,ge)),void 0!==i.sheenRoughnessTexture&&s.push(r.assignTexture(t,"sheenRoughnessMap",i.sheenRoughnessTexture)),Promise.all(s)}}class xr{constructor(e){this.parser=e,this.name=hr.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 r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return void 0!==i.transmissionFactor&&(t.transmission=i.transmissionFactor),void 0!==i.transmissionTexture&&s.push(r.assignTexture(t,"transmissionMap",i.transmissionTexture)),Promise.all(s)}}class Tr{constructor(e){this.parser=e,this.name=hr.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 r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];t.thickness=void 0!==i.thicknessFactor?i.thicknessFactor:0,void 0!==i.thicknessTexture&&s.push(r.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 wr{constructor(e){this.parser=e,this.name=hr.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 r=this.parser.json.materials[e];if(!r.extensions||!r.extensions[this.name])return Promise.resolve();const n=r.extensions[this.name];return t.ior=void 0!==n.ior?n.ior:1.5,Promise.resolve()}}class Ir{constructor(e){this.parser=e,this.name=hr.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 r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];t.specularIntensity=void 0!==i.specularFactor?i.specularFactor:1,void 0!==i.specularTexture&&s.push(r.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(r.assignTexture(t,"specularColorMap",i.specularColorTexture,ge)),Promise.all(s)}}class br{constructor(e){this.parser=e,this.name=hr.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 r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return t.bumpScale=void 0!==i.bumpFactor?i.bumpFactor:1,void 0!==i.bumpTexture&&s.push(r.assignTexture(t,"bumpMap",i.bumpTexture)),Promise.all(s)}}class Ar{constructor(e){this.parser=e,this.name=hr.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 r=this.parser,n=r.json.materials[e];if(!n.extensions||!n.extensions[this.name])return Promise.resolve();const s=[],i=n.extensions[this.name];return void 0!==i.anisotropyStrength&&(t.anisotropy=i.anisotropyStrength),void 0!==i.anisotropyRotation&&(t.anisotropyRotation=i.anisotropyRotation),void 0!==i.anisotropyTexture&&s.push(r.assignTexture(t,"anisotropyMap",i.anisotropyTexture)),Promise.all(s)}}class Rr{constructor(e){this.parser=e,this.name=hr.KHR_TEXTURE_BASISU}loadTexture(e){const t=this.parser,r=t.json,n=r.textures[e];if(!n.extensions||!n.extensions[this.name])return null;const s=n.extensions[this.name],i=t.options.ktx2Loader;if(!i){if(r.extensionsRequired&&r.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 Mr{constructor(e){this.parser=e,this.name=hr.EXT_TEXTURE_WEBP}loadTexture(e){const t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],o=n.images[i.source];let a=r.textureLoader;if(o.uri){const e=r.options.manager.getHandler(o.uri);null!==e&&(a=e)}return r.loadTextureImage(e,i.source,a)}}class Sr{constructor(e){this.parser=e,this.name=hr.EXT_TEXTURE_AVIF}loadTexture(e){const t=this.name,r=this.parser,n=r.json,s=n.textures[e];if(!s.extensions||!s.extensions[t])return null;const i=s.extensions[t],o=n.images[i.source];let a=r.textureLoader;if(o.uri){const e=r.options.manager.getHandler(o.uri);null!==e&&(a=e)}return r.loadTextureImage(e,i.source,a)}}class Er{constructor(e){this.name=hr.EXT_MESHOPT_COMPRESSION,this.parser=e}loadBufferView(e){const t=this.parser.json,r=t.bufferViews[e];if(r.extensions&&r.extensions[this.name]){const e=r.extensions[this.name],n=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 n.then(function(t){const r=e.byteOffset||0,n=e.byteLength||0,i=e.count,o=e.byteStride,a=new Uint8Array(t,r,n);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 _r{constructor(e){this.name=hr.EXT_MESH_GPU_INSTANCING,this.parser=e}createNodeMesh(e){const t=this.parser.json,r=t.nodes[e];if(!r.extensions||!r.extensions[this.name]||void 0===r.mesh)return null;const n=t.meshes[r.mesh];for(const e of n.primitives)if(e.mode!==Br.TRIANGLES&&e.mode!==Br.TRIANGLE_STRIP&&e.mode!==Br.TRIANGLE_FAN&&void 0!==e.mode)return null;const s=r.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(),r=t.isGroup?t.children:[t],n=e[0].count,s=[];for(const e of r){const t=new G,r=new Oe,i=new pe,a=new Oe(1,1,1),c=new R(e.geometry,e.material,n);for(let e=0;e<n;e++)o.TRANSLATION&&r.fromBufferAttribute(o.TRANSLATION,e),o.ROTATION&&i.fromBufferAttribute(o.ROTATION,e),o.SCALE&&a.fromBufferAttribute(o.SCALE,e),c.setMatrixAt(e,t.compose(r,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 Pr="glTF",Lr=1313821514,Or=5130562;class Cr{constructor(e){this.name=hr.KHR_BINARY_GLTF,this.content=null,this.body=null;const t=new DataView(e,0,12),r=new TextDecoder;if(this.header={magic:r.decode(new Uint8Array(e.slice(0,4))),version:t.getUint32(4,!0),length:t.getUint32(8,!0)},this.header.magic!==Pr)throw new Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");if(this.header.version<2)throw new Error("THREE.GLTFLoader: Legacy binary file detected.");const n=this.header.length-12,s=new DataView(e,12);let i=0;for(;i<n;){const t=s.getUint32(i,!0);i+=4;const n=s.getUint32(i,!0);if(i+=4,n===Lr){const n=new Uint8Array(e,12+i,t);this.content=r.decode(n)}else if(n===Or){const r=12+i;this.body=e.slice(r,r+t)}i+=t}if(null===this.content)throw new Error("THREE.GLTFLoader: JSON content not found.")}}class Nr{constructor(e,t){if(!t)throw new Error("THREE.GLTFLoader: No DRACOLoader instance provided.");this.name=hr.KHR_DRACO_MESH_COMPRESSION,this.json=e,this.dracoLoader=t,this.dracoLoader.preload()}decodePrimitive(e,t){const r=this.json,n=this.dracoLoader,s=e.extensions[this.name].bufferView,i=e.extensions[this.name].attributes,o={},a={},c={};for(const e in i){const t=Kr[e]||e.toLowerCase();o[t]=i[e]}for(const t in e.attributes){const n=Kr[t]||t.toLowerCase();if(void 0!==i[t]){const s=r.accessors[e.attributes[t]],i=Vr[s.componentType];c[n]=i.name,a[n]=!0===s.normalized}}return t.getDependency("bufferView",s).then(function(e){return new Promise(function(t,r){n.decodeDracoFile(e,function(e){for(const t in e.attributes){const r=e.attributes[t],n=a[t];void 0!==n&&(r.normalized=n)}t(e)},o,c,U,r)})})}}class kr{constructor(){this.name=hr.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 Dr{constructor(){this.name=hr.KHR_MESH_QUANTIZATION}}class Fr extends E{constructor(e,t,r,n){super(e,t,r,n)}copySampleValue_(e){const t=this.resultBuffer,r=this.sampleValues,n=this.valueSize,s=e*n*3+n;for(let e=0;e!==n;e++)t[e]=r[s+e];return t}interpolate_(e,t,r,n){const s=this.resultBuffer,i=this.sampleValues,o=this.valueSize,a=2*o,c=3*o,l=n-t,u=(r-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],r=i[m+e+a]*l,n=i[p+e+o],c=i[p+e]*l;s[e]=y*t+v*r+f*n+g*c}return s}}const Ur=new pe;class zr extends Fr{interpolate_(e,t,r,n){const s=super.interpolate_(e,t,r,n);return Ur.fromArray(s).normalize().toArray(s),s}}const Br={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},Vr={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Hr={9728:J,9729:k,9984:te,9985:F,9986:ee,9987:D},jr={33071:h,33648:Z,10497:fe},Gr={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Kr={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"},Wr={scale:"scale",translation:"position",rotation:"quaternion",weights:"morphTargetInfluences"},Xr={CUBICSPLINE:void 0,LINEAR:P,STEP:_},Qr="OPAQUE",qr="MASK",Yr="BLEND";function Zr(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 $r(e,t,r){for(const n in r.extensions)void 0===e[n]&&(t.userData.gltfExtensions=t.userData.gltfExtensions||{},t.userData.gltfExtensions[n]=r.extensions[n])}function Jr(e,t){void 0!==t.extras&&"object"==typeof t.extras&&Object.assign(e.userData,t.extras)}function en(e,t){if(e.updateMorphTargets(),void 0!==t.weights)for(let r=0,n=t.weights.length;r<n;r++)e.morphTargetInfluences[r]=t.weights[r];if(t.extras&&Array.isArray(t.extras.targetNames)){const r=t.extras.targetNames;if(e.morphTargetInfluences.length===r.length){e.morphTargetDictionary={};for(let t=0,n=r.length;t<n;t++)e.morphTargetDictionary[r[t]]=t}}}function tn(e){let t;const r=e.extensions&&e.extensions[hr.KHR_DRACO_MESH_COMPRESSION];if(t=r?"draco:"+r.bufferView+":"+r.indices+":"+rn(r.attributes):e.indices+":"+rn(e.attributes)+":"+e.mode,void 0!==e.targets)for(let r=0,n=e.targets.length;r<n;r++)t+=":"+rn(e.targets[r]);return t}function rn(e){let t="";const r=Object.keys(e).sort();for(let n=0,s=r.length;n<s;n++)t+=r[n]+":"+e[r[n]]+";";return t}function nn(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 sn=new G;class on{constructor(e={},t={}){this.json=e,this.extensions={},this.plugins={},this.options=t,this.cache=new ur,this.associations=new Map,this.primitiveCache={},this.nodeCache={},this.meshCache={refs:{},uses:{}},this.cameraCache={refs:{},uses:{}},this.lightCache={refs:{},uses:{}},this.sourceCache={},this.textureCache={},this.nodeNamesUsed={};let r=!1,n=-1,s=!1,i=-1;if("undefined"!=typeof navigator){const e=navigator.userAgent;r=!0===/^((?!chrome|android).)*safari/i.test(e);const t=e.match(/Version\/(\d+)/);n=r&&t?parseInt(t[1],10):-1,s=e.indexOf("Firefox")>-1,i=s?e.match(/Firefox\/([0-9]+)\./)[1]:-1}"undefined"==typeof createImageBitmap||r&&n<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 r=this,n=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([r.getDependencies("scene"),r.getDependencies("animation"),r.getDependencies("camera")])}).then(function(t){const i={scene:t[0][n.scene||0],scenes:t[0],animations:t[1],cameras:t[2],asset:n.asset,parser:r,userData:{}};return $r(s,i,n),Jr(i,n),Promise.all(r._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||[],r=this.json.meshes||[];for(let r=0,n=t.length;r<n;r++){const n=t[r].joints;for(let t=0,r=n.length;t<r;t++)e[n[t]].isBone=!0}for(let t=0,n=e.length;t<n;t++){const n=e[t];void 0!==n.mesh&&(this._addNodeRef(this.meshCache,n.mesh),void 0!==n.skin&&(r[n.mesh].isSkinnedMesh=!0)),void 0!==n.camera&&this._addNodeRef(this.cameraCache,n.camera)}}_addNodeRef(e,t){void 0!==t&&(void 0===e.refs[t]&&(e.refs[t]=e.uses[t]=0),e.refs[t]++)}_getNodeRef(e,t,r){if(e.refs[t]<=1)return r;const n=r.clone(),s=(e,t)=>{const r=this.associations.get(e);null!=r&&this.associations.set(t,r);for(const[r,n]of e.children.entries())s(n,t.children[r])};return s(r,n),n.name+="_instance_"+e.uses[t]++,n}_invokeOne(e){const t=Object.values(this.plugins);t.push(this);for(let r=0;r<t.length;r++){const n=e(t[r]);if(n)return n}return null}_invokeAll(e){const t=Object.values(this.plugins);t.unshift(this);const r=[];for(let n=0;n<t.length;n++){const s=e(t[n]);s&&r.push(s)}return r}getDependency(e,t){const r=e+":"+t;let n=this.cache.get(r);if(!n){switch(e){case"scene":n=this.loadScene(t);break;case"node":n=this._invokeOne(function(e){return e.loadNode&&e.loadNode(t)});break;case"mesh":n=this._invokeOne(function(e){return e.loadMesh&&e.loadMesh(t)});break;case"accessor":n=this.loadAccessor(t);break;case"bufferView":n=this._invokeOne(function(e){return e.loadBufferView&&e.loadBufferView(t)});break;case"buffer":n=this.loadBuffer(t);break;case"material":n=this._invokeOne(function(e){return e.loadMaterial&&e.loadMaterial(t)});break;case"texture":n=this._invokeOne(function(e){return e.loadTexture&&e.loadTexture(t)});break;case"skin":n=this.loadSkin(t);break;case"animation":n=this._invokeOne(function(e){return e.loadAnimation&&e.loadAnimation(t)});break;case"camera":n=this.loadCamera(t);break;default:if(n=this._invokeOne(function(r){return r!=this&&r.getDependency&&r.getDependency(e,t)}),!n)throw new Error("Unknown type: "+e)}this.cache.add(r,n)}return n}getDependencies(e){let t=this.cache.get(e);if(!t){const r=this,n=this.json[e+("mesh"===e?"es":"s")]||[];t=Promise.all(n.map(function(t,n){return r.getDependency(e,n)})),this.cache.add(e,t)}return t}loadBuffer(e){const t=this.json.buffers[e],r=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[hr.KHR_BINARY_GLTF].body);const n=this.options;return new Promise(function(e,s){r.load(B.resolveURL(t.uri,n.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 r=t.byteLength||0,n=t.byteOffset||0;return e.slice(n,n+r)})}loadAccessor(e){const t=this,r=this.json,n=this.json.accessors[e];if(void 0===n.bufferView&&void 0===n.sparse){const e=Gr[n.type],t=Vr[n.componentType],r=!0===n.normalized,s=new t(n.count*e);return Promise.resolve(new c(s,e,r))}const s=[];return void 0!==n.bufferView?s.push(this.getDependency("bufferView",n.bufferView)):s.push(null),void 0!==n.sparse&&(s.push(this.getDependency("bufferView",n.sparse.indices.bufferView)),s.push(this.getDependency("bufferView",n.sparse.values.bufferView))),Promise.all(s).then(function(e){const s=e[0],i=Gr[n.type],o=Vr[n.componentType],a=o.BYTES_PER_ELEMENT,l=a*i,u=n.byteOffset||0,h=void 0!==n.bufferView?r.bufferViews[n.bufferView].byteStride:void 0,d=!0===n.normalized;let p,m;if(h&&h!==l){const e=Math.floor(u/h),r="InterleavedBuffer:"+n.bufferView+":"+n.componentType+":"+e+":"+n.count;let c=t.cache.get(r);c||(p=new o(s,e*h,n.count*h/a),c=new M(p,h/a),t.cache.add(r,c)),m=new S(c,i,u%h/a,d)}else p=null===s?new o(n.count*i):new o(s,u,n.count*i),m=new c(p,i,d);if(void 0!==n.sparse){const t=Gr.SCALAR,r=Vr[n.sparse.indices.componentType],a=n.sparse.indices.byteOffset||0,l=n.sparse.values.byteOffset||0,u=new r(e[1],a,n.sparse.count*t),h=new o(e[2],l,n.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,r=this.options,n=t.textures[e].source,s=t.images[n];let i=this.textureLoader;if(s.uri){const e=r.manager.getHandler(s.uri);null!==e&&(i=e)}return this.loadTextureImage(e,n,i)}loadTextureImage(e,t,r){const n=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,r).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 r=(s.samplers||{})[i.sampler]||{};return t.magFilter=Hr[r.magFilter]||k,t.minFilter=Hr[r.minFilter]||D,t.wrapS=jr[r.wrapS]||fe,t.wrapT=jr[r.wrapT]||fe,t.generateMipmaps=!t.isCompressedTexture&&t.minFilter!==J&&t.minFilter!==k,n.associations.set(t,{textures:e}),t}).catch(function(){return null});return this.textureCache[a]=c,c}loadImageSource(e,t){const r=this,n=this.json,s=this.options;if(void 0!==this.sourceCache[e])return this.sourceCache[e].then(e=>e.clone());const i=n.images[e],o=self.URL||self.webkitURL;let a=i.uri||"",c=!1;if(void 0!==i.bufferView)a=r.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(r,n){let i=r;!0===t.isImageBitmapLoader&&(i=function(e){const t=new Re(e);t.needsUpdate=!0,r(t)}),t.load(B.resolveURL(e,s.path),i,void 0,n)})}).then(function(e){var t;return!0===c&&o.revokeObjectURL(a),Jr(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,r,n){const s=this;return this.getDependency("texture",r.index).then(function(i){if(!i)return null;if(void 0!==r.texCoord&&r.texCoord>0&&((i=i.clone()).channel=r.texCoord),s.extensions[hr.KHR_TEXTURE_TRANSFORM]){const e=void 0!==r.extensions?r.extensions[hr.KHR_TEXTURE_TRANSFORM]:void 0;if(e){const t=s.associations.get(i);i=s.extensions[hr.KHR_TEXTURE_TRANSFORM].extendTexture(i,e),s.associations.set(i,t)}}return void 0!==n&&(i.colorSpace=n),e[t]=i,i})}assignFinalMaterial(e){const t=e.geometry;let r=e.material;const n=void 0===t.attributes.tangent,s=void 0!==t.attributes.color,i=void 0===t.attributes.normal;if(e.isPoints){const e="PointsMaterial:"+r.uuid;let t=this.cache.get(e);t||(t=new ue,V.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,t.sizeAttenuation=!1,this.cache.add(e,t)),r=t}else if(e.isLine){const e="LineBasicMaterial:"+r.uuid;let t=this.cache.get(e);t||(t=new O,V.prototype.copy.call(t,r),t.color.copy(r.color),t.map=r.map,this.cache.add(e,t)),r=t}if(n||s||i){let e="ClonedMaterial:"+r.uuid+":";n&&(e+="derivative-tangents:"),s&&(e+="vertex-colors:"),i&&(e+="flat-shading:");let t=this.cache.get(e);t||(t=r.clone(),s&&(t.vertexColors=!0),i&&(t.flatShading=!0),n&&(t.normalScale&&(t.normalScale.y*=-1),t.clearcoatNormalScale&&(t.clearcoatNormalScale.y*=-1)),this.cache.add(e,t),this.associations.set(t,this.associations.get(r))),r=t}e.material=r}getMaterialType(){return Y}loadMaterial(e){const t=this,r=this.json,n=this.extensions,s=r.materials[e];let i;const o={},a=[];if((s.extensions||{})[hr.KHR_MATERIALS_UNLIT]){const e=n[hr.KHR_MATERIALS_UNLIT];i=e.getMaterialType(),a.push(e.extendParams(o,s,t))}else{const r=s.pbrMetallicRoughness||{};if(o.color=new d(1,1,1),o.opacity=1,Array.isArray(r.baseColorFactor)){const e=r.baseColorFactor;o.color.setRGB(e[0],e[1],e[2],U),o.opacity=e[3]}void 0!==r.baseColorTexture&&a.push(t.assignTexture(o,"map",r.baseColorTexture,ge)),o.metalness=void 0!==r.metallicFactor?r.metallicFactor:1,o.roughness=void 0!==r.roughnessFactor?r.roughnessFactor:1,void 0!==r.metallicRoughnessTexture&&(a.push(t.assignTexture(o,"metalnessMap",r.metallicRoughnessTexture)),a.push(t.assignTexture(o,"roughnessMap",r.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||Qr;if(c===Yr?(o.transparent=!0,o.depthWrite=!1):(o.transparent=!1,c===qr&&(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 Le(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 r=new i(o);return s.name&&(r.name=s.name),Jr(r,s),t.associations.set(r,{materials:e}),s.extensions&&$r(n,r,s),r})}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,r=this.extensions,n=this.primitiveCache;function s(e){return r[hr.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e,t).then(function(r){return an(r,e,t)})}const i=[];for(let r=0,o=e.length;r<o;r++){const o=e[r],a=tn(o),c=n[a];if(c)i.push(c.promise);else{let e;e=o.extensions&&o.extensions[hr.KHR_DRACO_MESH_COMPRESSION]?s(o):an(new l,o,t),n[a]={primitive:o,promise:e},i.push(e)}}return Promise.all(i)}loadMesh(e){const t=this,r=this.json,n=this.extensions,s=r.meshes[e],i=s.primitives,o=[];for(let e=0,t=i.length;e<t;e++){const t=void 0===i[e].material?Zr(this.cache):this.getDependency("material",i[e].material);o.push(t)}return o.push(t.loadGeometries(i)),Promise.all(o).then(function(r){const o=r.slice(0,r.length-1),a=r[r.length-1],c=[];for(let r=0,l=a.length;r<l;r++){const l=a[r],u=i[r];let h;const d=o[r];if(u.mode===Br.TRIANGLES||u.mode===Br.TRIANGLE_STRIP||u.mode===Br.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===Br.TRIANGLE_STRIP?h.geometry=lr(h.geometry,Ee):u.mode===Br.TRIANGLE_FAN&&(h.geometry=lr(h.geometry,Se));else if(u.mode===Br.LINES)h=new N(l,d);else if(u.mode===Br.LINE_STRIP)h=new L(l,d);else if(u.mode===Br.LINE_LOOP)h=new C(l,d);else{if(u.mode!==Br.POINTS)throw new Error("THREE.GLTFLoader: Primitive mode unsupported: "+u.mode);h=new le(l,d)}Object.keys(h.geometry.morphAttributes).length>0&&en(h,s),h.name=t.createUniqueName(s.name||"mesh_"+e),Jr(h,s),u.extensions&&$r(n,h,u),t.assignFinalMaterial(h),c.push(h)}for(let r=0,n=c.length;r<n;r++)t.associations.set(c[r],{meshes:e,primitives:r});if(1===c.length)return s.extensions&&$r(n,c[0],s),c[0];const l=new I;s.extensions&&$r(n,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 r=this.json.cameras[e],n=r[r.type];if(n)return"perspective"===r.type?t=new ae(H.radToDeg(n.yfov),n.aspectRatio||1,n.znear||1,n.zfar||2e6):"orthographic"===r.type&&(t=new oe(-n.xmag,n.xmag,n.ymag,-n.ymag,n.znear,n.zfar)),r.name&&(t.name=this.createUniqueName(r.name)),Jr(t,r),Promise.resolve(t)}loadSkin(e){const t=this.json.skins[e],r=[];for(let e=0,n=t.joints.length;e<n;e++)r.push(this._loadNodeShallow(t.joints[e]));return void 0!==t.inverseBindMatrices?r.push(this.getDependency("accessor",t.inverseBindMatrices)):r.push(null),Promise.all(r).then(function(e){const t=e.pop(),r=e,n=[],s=[];for(let e=0,i=r.length;e<i;e++){const i=r[e];if(i){n.push(i);const r=new G;null!==t&&r.fromArray(t.array,16*e),s.push(r)}}return new xe(n,s)})}loadAnimation(e){const t=this.json,n=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],r=s.samplers[t.sampler],n=t.target,i=n.node,h=void 0!==s.parameters?s.parameters[r.input]:r.input,d=void 0!==s.parameters?s.parameters[r.output]:r.output;void 0!==n.node&&(o.push(this.getDependency("node",i)),a.push(this.getDependency("accessor",h)),c.push(this.getDependency("accessor",d)),l.push(r),u.push(n))}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,r=t.length;e<r;e++){const r=t[e],s=o[e],i=a[e],h=c[e],d=l[e];if(void 0===r)continue;r.updateMatrix&&r.updateMatrix();const p=n._createAnimationTracks(r,s,i,h,d);if(p)for(let e=0;e<p.length;e++)u.push(p[e])}const h=new r(i,void 0,u);return Jr(h,s),h})}createNodeMesh(e){const t=this.json,r=this,n=t.nodes[e];return void 0===n.mesh?null:r.getDependency("mesh",n.mesh).then(function(e){const t=r._getNodeRef(r.meshCache,n.mesh,e);return void 0!==n.weights&&t.traverse(function(e){if(e.isMesh)for(let t=0,r=n.weights.length;t<r;t++)e.morphTargetInfluences[t]=n.weights[t]}),t})}loadNode(e){const t=this,r=this.json.nodes[e],n=t._loadNodeShallow(e),s=[],i=r.children||[];for(let e=0,r=i.length;e<r;e++)s.push(t.getDependency("node",i[e]));const o=void 0===r.skin?Promise.resolve(null):t.getDependency("skin",r.skin);return Promise.all([n,Promise.all(s),o]).then(function(e){const t=e[0],r=e[1],n=e[2];null!==n&&t.traverse(function(e){e.isSkinnedMesh&&e.bind(n,sn)});for(let e=0,n=r.length;e<n;e++)t.add(r[e]);return t})}_loadNodeShallow(e){const t=this.json,r=this.extensions,n=this;if(void 0!==this.nodeCache[e])return this.nodeCache[e];const s=t.nodes[e],i=s.name?n.createUniqueName(s.name):"",a=[],c=n._invokeOne(function(t){return t.createNodeMesh&&t.createNodeMesh(e)});return c&&a.push(c),void 0!==s.camera&&a.push(n.getDependency("camera",s.camera).then(function(e){return n._getNodeRef(n.cameraCache,s.camera,e)})),n._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,r=t.length;e<r;e++)a.add(t[e]);if(s.name&&(a.userData.name=s.name,a.name=i),Jr(a,s),s.extensions&&$r(r,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(n.associations.has(a)){if(void 0!==s.mesh&&n.meshCache.refs[s.mesh]>1){const e=n.associations.get(a);n.associations.set(a,{...e})}}else n.associations.set(a,{});return n.associations.get(a).nodes=e,a}),this.nodeCache[e]}loadScene(e){const t=this.extensions,r=this.json.scenes[e],n=this,s=new I;r.name&&(s.name=n.createUniqueName(r.name)),Jr(s,r),r.extensions&&$r(t,s,r);const i=r.nodes||[],o=[];for(let e=0,t=i.length;e<t;e++)o.push(n.getDependency("node",i[e]));return Promise.all(o).then(function(e){for(let t=0,r=e.length;t<r;t++)s.add(e[t]);return n.associations=(e=>{const t=new Map;for(const[e,r]of n.associations)(e instanceof V||e instanceof Re)&&t.set(e,r);return e.traverse(e=>{const r=n.associations.get(e);null!=r&&t.set(e,r)}),t})(s),s})}_createAnimationTracks(e,t,r,n,s){const i=[],o=e.name?e.name:e.uuid,a=[];let c;switch(Wr[s.path]===Wr.weights?e.traverse(function(e){e.morphTargetInfluences&&a.push(e.name?e.name:e.uuid)}):a.push(o),Wr[s.path]){case Wr.weights:c=se;break;case Wr.rotation:c=me;break;case Wr.translation:case Wr.scale:c=Ne;break;default:if(1===r.itemSize)c=se;else c=Ne}const l=void 0!==n.interpolation?Xr[n.interpolation]:P,u=this._getArrayFromAccessor(r);for(let e=0,r=a.length;e<r;e++){const r=new c(a[e]+"."+Wr[s.path],t.array,u,l);"CUBICSPLINE"===n.interpolation&&this._createCubicSplineTrackInterpolant(r),i.push(r)}return i}_getArrayFromAccessor(e){let t=e.array;if(e.normalized){const e=nn(t.constructor),r=new Float32Array(t.length);for(let n=0,s=t.length;n<s;n++)r[n]=t[n]*e;t=r}return t}_createCubicSplineTrackInterpolant(e){e.createInterpolant=function(e){return new(this instanceof me?zr:Fr)(this.times,this.values,this.getValueSize()/3,e)},e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline=!0}}function an(e,t,r){const n=t.attributes,s=[];function i(t,n){return r.getDependency("accessor",t).then(function(t){e.setAttribute(n,t)})}for(const t in n){const r=Kr[t]||t.toLowerCase();r in e.attributes||s.push(i(n[t],r))}if(void 0!==t.indices&&!e.index){const n=r.getDependency("accessor",t.indices).then(function(t){e.setIndex(t)});s.push(n)}return p.workingColorSpace,Jr(e,t),function(e,t,r){const n=t.attributes,s=new a;if(void 0===n.POSITION)return;{const e=r.json.accessors[n.POSITION],t=e.min,i=e.max;if(void 0===t||void 0===i)return;if(s.set(new Oe(t[0],t[1],t[2]),new Oe(i[0],i[1],i[2])),e.normalized){const t=nn(Vr[e.componentType]);s.min.multiplyScalar(t),s.max.multiplyScalar(t)}}const i=t.targets;if(void 0!==i){const e=new Oe,t=new Oe;for(let n=0,s=i.length;n<s;n++){const s=i[n];if(void 0!==s.POSITION){const n=r.json.accessors[s.POSITION],i=n.min,o=n.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]))),n.normalized){const e=nn(Vr[n.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,r),Promise.all(s).then(function(){return void 0!==t.targets?function(e,t,r){let n=!1,s=!1,i=!1;for(let e=0,r=t.length;e<r;e++){const r=t[e];if(void 0!==r.POSITION&&(n=!0),void 0!==r.NORMAL&&(s=!0),void 0!==r.COLOR_0&&(i=!0),n&&s&&i)break}if(!n&&!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(n){const t=void 0!==u.POSITION?r.getDependency("accessor",u.POSITION):e.attributes.position;o.push(t)}if(s){const t=void 0!==u.NORMAL?r.getDependency("accessor",u.NORMAL):e.attributes.normal;a.push(t)}if(i){const t=void 0!==u.COLOR_0?r.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 r=t[0],o=t[1],a=t[2];return n&&(e.morphAttributes.position=r),s&&(e.morphAttributes.normal=o),i&&(e.morphAttributes.color=a),e.morphTargetsRelative=!0,e})}(e,t.targets,r):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 fr(e)}),this.register(function(e){return new gr(e)}),this.register(function(e){return new Rr(e)}),this.register(function(e){return new Mr(e)}),this.register(function(e){return new Sr(e)}),this.register(function(e){return new vr(e)}),this.register(function(e){return new xr(e)}),this.register(function(e){return new Tr(e)}),this.register(function(e){return new wr(e)}),this.register(function(e){return new mr(e)}),this.register(function(e){return new Ir(e)}),this.register(function(e){return new yr(e)}),this.register(function(e){return new Ar(e)}),this.register(function(e){return new br(e)}),this.register(function(e){return new dr(e)}),this.register(function(e){return new Er(e)}),this.register(function(e){return new _r(e)})}load(e,t,r,n){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){n&&n(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(r){try{s.parse(r,i,function(r){t(r),s.manager.itemEnd(e)},o)}catch(e){o(e)}},r,o)}setDRACOLoader(e){return this.dracoLoader=e,this}setKTX2Loader(e){return this.ktx2Loader=e,this}setMeshoptDecoder(e){return this.meshoptDecoder=e,this}register(e){return-1===this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.push(e),this}unregister(e){return-1!==this.pluginCallbacks.indexOf(e)&&this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e),1),this}parse(e,t,r,n){let 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))===Pr){try{i[hr.KHR_BINARY_GLTF]=new Cr(e)}catch(e){return void(n&&n(e))}s=JSON.parse(i[hr.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(n&&n(new Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported.")));const c=new on(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],r=s.extensionsRequired||[];switch(t){case hr.KHR_MATERIALS_UNLIT:i[t]=new pr;break;case hr.KHR_DRACO_MESH_COMPRESSION:i[t]=new Nr(s,this.dracoLoader);break;case hr.KHR_TEXTURE_TRANSFORM:i[t]=new kr;break;case hr.KHR_MESH_QUANTIZATION:i[t]=new Dr;break;default:r.indexOf(t)>=0&&o[t]}}c.setExtensions(i),c.setPlugins(o),c.parse(r,n)}parseAsync(e,t){const r=this;return new Promise(function(n,s){r.parse(e,t,n,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 cn=new Oe,ln=new pe,un=new Oe,hn=new Oe,dn=new pe,pn=new Oe;class mn 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(hn,dn,pn),this.matrix.decompose(cn,ln,un),this.matrixWorld.compose(hn,ln,pn)):this.matrixWorld.copy(this.matrix),this.matrixWorldNeedsUpdate=!1,e=!0);for(let t=0,r=this.children.length;t<r;t++)this.children[t].updateMatrixWorld(e)}}var fn=[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 gn{constructor(e){const t=[new Oe(1,1,0),new Oe(-1,1,0),new Oe(1,-1,0),new Oe(-1,-1,0),new Oe(1,0,1),new Oe(-1,0,1),new Oe(1,0,-1),new Oe(-1,0,-1),new Oe(0,1,1),new Oe(0,-1,1),new Oe(0,1,-1),new Oe(0,-1,-1)];var r=new Array(512),n=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?fn[s]^255&e:fn[s]^e>>8&255,r[s]=r[s+256]=i,n[s]=n[s+256]=t[i%12]}this._seed=e,this._offsetMatrix=[new Oe(0,0,0),new Oe(0,0,1),new Oe(0,1,0),new Oe(0,1,1),new Oe(1,0,0),new Oe(1,0,1),new Oe(1,1,0),new Oe(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=r,this.gradP=n}_fade(e){return e*e*e*(e*(6*e-15)+10)}_lerp(e,t,r){return(1-r)*e+r*t}_gradient(e){return e instanceof Oe?e.x+this.perm[e.y+this.perm[e.z]]:e.x+this.perm[e.y]}static map(e,t,r,n,s){return(e-t)*(s-n)/(r-t)+n}get2(e){void 0!==e.z&&(e=new Le(e.x,e.y));const t=new Le(Math.floor(e.x),Math.floor(e.y));e.sub(t),t.x&=255,t.y&=255;const r=[];for(let n=0;n<4;n++){const s=this._offsetMatrix[2*n],i=new Le(s.x,s.y),o=this.gradP[this._gradient((new Le).addVectors(t,i))],a=new Le(o.x,o.y),c=(new Le).subVectors(e,i);r.push(a.dot(c))}const n=this._fade(e.x),s=this._fade(e.y);return this._lerp(this._lerp(r[0],r[2],n),this._lerp(r[1],r[3],n),s)}get3(e){if(void 0===e.z)throw"Input to Perlin::get3() must be of type THREE.Vector3";const t=new Oe(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 r=[];for(let n=0;n<8;n++){const s=this._offsetMatrix[n],i=this.gradP[this._gradient((new Oe).addVectors(t,s))],o=(new Oe).subVectors(e,s);r.push(i.dot(o))}const n=this._fade(e.x),s=this._fade(e.y),i=this._fade(e.z);return this._lerp(this._lerp(this._lerp(r[0],r[4],n),this._lerp(r[1],r[5],n),i),this._lerp(this._lerp(r[2],r[6],n),this._lerp(r[3],r[7],n),i),s)}}class yn{constructor(e){const{seed:t,scale:r,persistance:n,lacunarity:s,octaves:i,redistribution:o}=e;this._noise=new gn(t),this._scale=r||1,this._persistance=n||.5,this._lacunarity=s||2,this._octaves=i||6,this._redistribution=o||1}get2(e){let t=0,r=1,n=1,s=r,i=this._noise.get2.bind(this._noise);for(let o=0;o<this._octaves;o++){t+=i(new Le(e.x*this._scale*n,e.y*this._scale*n))*r,n*=this._lacunarity,r*=this._persistance,s+=r}return Math.pow(t,this._redistribution)/s}get3(e){let t=0,r=1,n=1,s=r,i=this._noise.get3.bind(this._noise);for(let o=0;o<this._octaves;o++){t+=i(new Oe(e.x*this._scale*n,e.y*this._scale*n,e.z*this._scale*n))*r,n*=this._lacunarity,r*=this._persistance,s+=r}return Math.pow(t,this._redistribution)/s}}let vn=0,xn=[];const Tn=new Oe,wn={x:0,y:0,z:0},In={x:0,y:0,z:0},bn={delta:0,generalData:null,normalizedConfig:null,attributes:null,particleLifetimePercentage:0,particleIndex:0},An={"THREE.NoBlending":re,"THREE.NormalBlending":ne,"THREE.AdditiveBlending":e,"THREE.SubtractiveBlending":Ae,"THREE.MultiplyBlending":$},Rn=()=>JSON.parse(JSON.stringify(Mn)),Mn={transform:{position:new Oe,rotation:new Oe,scale:new Oe(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,bursts:[]},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:ne,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 Le(1,1),timeMode:"LIFETIME",fps:30,startFrame:0}},Sn=({geometry:e,propertyName:t,maxParticles:r,factory:n})=>{const s=new Float32Array(r);if("function"==typeof n)for(let e=0;e<r;e++)s[e]=n(void 0,e);else s.fill(n);e.setAttribute(t,new c(s,1))},En=(e,{shape:t,sphere:r,cone:n,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,r);break;case"CONE":Xe(c,e.wrapperQuaternion,l,u,n);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)}},_n=(e=Mn,t)=>{const r=t||Date.now(),n={particleSystemId:vn++,normalizedLifetimePercentage:0,distanceFromLastEmitByDistance:0,lastWorldPosition:new Oe(-99999),currentWorldPosition:new Oe(-99999),worldPositionChange:new Oe,worldQuaternion:new pe,wrapperQuaternion:new pe,lastWorldQuaternion:new pe(-99999),worldEuler:new v,gravityVelocity:new Oe(0,0,0),startValues:{},linearVelocityData:void 0,orbitalVelocityData:void 0,lifetimeValues:{},creationTimes:[],noise:{isActive:!1,strength:0,noisePower:0,positionAmount:0,rotationAmount:0,sizeAmount:0},isEnabled:!0},s=st(Mn,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=An[A.blending]);const P=Array.from({length:w},()=>new Oe),L=Array.from({length:w},()=>new Oe);n.creationTimes=Array.from({length:w},()=>0);const O=Array.from({length:w},(e,t)=>w-1-t);M.isActive&&(n.linearVelocityData=Array.from({length:w},()=>({speed:new Oe(M.linear.x?et(n.particleSystemId,M.linear.x,0):0,M.linear.y?et(n.particleSystemId,M.linear.y,0):0,M.linear.z?et(n.particleSystemId,M.linear.z,0):0),valueModifiers:{x:$e(M.linear.x||0)?Je(n.particleSystemId,M.linear.x):void 0,y:$e(M.linear.y||0)?Je(n.particleSystemId,M.linear.y):void 0,z:$e(M.linear.z||0)?Je(n.particleSystemId,M.linear.z):void 0}})),n.orbitalVelocityData=Array.from({length:w},()=>({speed:new Oe(M.orbital.x?et(n.particleSystemId,M.orbital.x,0):0,M.orbital.y?et(n.particleSystemId,M.orbital.y,0):0,M.orbital.z?et(n.particleSystemId,M.orbital.z,0):0),valueModifiers:{x:$e(M.orbital.x||0)?Je(n.particleSystemId,M.orbital.x):void 0,y:$e(M.orbital.y||0)?Je(n.particleSystemId,M.orbital.y):void 0,z:$e(M.orbital.z||0)?Je(n.particleSystemId,M.orbital.z):void 0},positionOffset:new Oe})));["startSize","startOpacity"].forEach(e=>{n.startValues[e]=Array.from({length:w},()=>et(n.particleSystemId,s[e],0))}),n.startValues.startColorR=Array.from({length:w},()=>0),n.startValues.startColorG=Array.from({length:w},()=>0),n.startValues.startColorB=Array.from({length:w},()=>0);["rotationOverLifetime"].forEach(e=>{const t=s[e];t.isActive&&(n.lifetimeValues[e]=Array.from({length:w},()=>H.randFloat(t.min,t.max)))}),n.noise={isActive:R.isActive,strength:R.strength,noisePower:.15*R.strength,positionAmount:R.positionAmount,rotationAmount:R.rotationAmount,sizeAmount:R.sizeAmount,sampler:R.isActive?new yn({seed:Math.random(),scale:R.frequency,octaves:R.octaves}):void 0,offsets:R.useRandomOffset?Array.from({length:w},()=>100*Math.random()):void 0},I.bursts&&I.bursts.length>0&&(n.burstStates=I.bursts.map(()=>({cyclesExecuted:0,lastCycleTime:0,probabilityPassed:!1})));const C=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++)En(n,b,p,P[e],L[e]);const k=new Float32Array(3*w);for(let e=0;e<w;e++)k[3*e]=P[e].x,k[3*e+1]=P[e].y,k[3*e+2]=P[e].z;N.setAttribute("position",new c(k,3)),Sn({geometry:N,propertyName:"isActive",maxParticles:w,factory:0}),Sn({geometry:N,propertyName:"lifetime",maxParticles:w,factory:0}),Sn({geometry:N,propertyName:"startLifetime",maxParticles:w,factory:()=>1e3*et(n.particleSystemId,d,0)}),Sn({geometry:N,propertyName:"startFrame",maxParticles:w,factory:()=>_.startFrame?et(n.particleSystemId,_.startFrame,0):0}),Sn({geometry:N,propertyName:"opacity",maxParticles:w,factory:()=>et(n.particleSystemId,y,0)}),Sn({geometry:N,propertyName:"rotation",maxParticles:w,factory:()=>et(n.particleSystemId,f,0)}),Sn({geometry:N,propertyName:"size",maxParticles:w,factory:(e,t)=>n.startValues.startSize[t]}),Sn({geometry:N,propertyName:"rotation",maxParticles:w,factory:0});const D=Math.random();Sn({geometry:N,propertyName:"colorR",maxParticles:w,factory:()=>g.min.r+D*(g.max.r-g.min.r)}),Sn({geometry:N,propertyName:"colorG",maxParticles:w,factory:()=>g.min.g+D*(g.max.g-g.min.g)}),Sn({geometry:N,propertyName:"colorB",maxParticles:w,factory:()=>g.min.b+D*(g.max.b-g.min.b)}),Sn({geometry:N,propertyName:"colorA",maxParticles:w,factory:0});let F=new le(N,C);F.position.copy(o.position),F.rotation.x=H.degToRad(o.rotation.x),F.rotation.y=H.degToRad(o.rotation.y),F.rotation.z=H.degToRad(o.rotation.z),F.scale.copy(o.scale);const U=r+1e3*et(n.particleSystemId,h);let z;"WORLD"===s.simulationSpace&&(z=new mn,z.add(F));const B={particleSystem:F,wrapper:z,elapsedUniform:C.uniforms.elapsed,generalData:n,onUpdate:S,onComplete:E,creationTime:U,lastEmissionTime:U,duration:a,looping:u,simulationSpace:T,gravity:x,emission:I,normalizedConfig:s,iterationCount:0,velocities:L,freeList:O,deactivateParticle:e=>{N.attributes.isActive.array[e]=0,N.attributes.colorA.array[e]=0,N.attributes.colorA.needsUpdate=!0,O.push(e)},activateParticle:({particleIndex:e,activationTime:t,position:r})=>{N.attributes.isActive.array[e]=1,n.creationTimes[e]=t,n.noise.offsets&&(n.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.startValues.startColorR[e]=N.attributes.colorR.array[e],n.startValues.startColorG[e]=N.attributes.colorG.array[e],n.startValues.startColorB[e]=N.attributes.colorB.array[e],N.attributes.startFrame.array[e]=_.startFrame?et(n.particleSystemId,_.startFrame,0):0,N.attributes.startFrame.needsUpdate=!0,N.attributes.startLifetime.array[e]=1e3*et(n.particleSystemId,d,n.normalizedLifetimePercentage),N.attributes.startLifetime.needsUpdate=!0,n.startValues.startSize[e]=et(n.particleSystemId,m,n.normalizedLifetimePercentage),N.attributes.size.array[e]=n.startValues.startSize[e],N.attributes.size.needsUpdate=!0,n.startValues.startOpacity[e]=et(n.particleSystemId,y,n.normalizedLifetimePercentage),N.attributes.colorA.array[e]=n.startValues.startOpacity[e],N.attributes.colorA.needsUpdate=!0,N.attributes.rotation.array[e]=et(n.particleSystemId,f,n.normalizedLifetimePercentage),N.attributes.rotation.needsUpdate=!0,s.rotationOverLifetime.isActive&&(n.lifetimeValues.rotationOverLifetime[e]=H.randFloat(s.rotationOverLifetime.min,s.rotationOverLifetime.max)),En(n,b,p,P[e],L[e]);const o=Math.floor(3*e);N.attributes.position.array[o]=r.x+P[e].x,N.attributes.position.array[o+1]=r.y+P[e].y,N.attributes.position.array[o+2]=r.z+P[e].z,N.attributes.position.needsUpdate=!0,n.linearVelocityData&&n.linearVelocityData[e].speed.set(s.velocityOverLifetime.linear.x?et(n.particleSystemId,s.velocityOverLifetime.linear.x,0):0,s.velocityOverLifetime.linear.y?et(n.particleSystemId,s.velocityOverLifetime.linear.y,0):0,s.velocityOverLifetime.linear.z?et(n.particleSystemId,s.velocityOverLifetime.linear.z,0):0),n.orbitalVelocityData&&(n.orbitalVelocityData[e].speed.set(s.velocityOverLifetime.orbital.x?et(n.particleSystemId,s.velocityOverLifetime.orbital.x,0):0,s.velocityOverLifetime.orbital.y?et(n.particleSystemId,s.velocityOverLifetime.orbital.y,0):0,s.velocityOverLifetime.orbital.z?et(n.particleSystemId,s.velocityOverLifetime.orbital.z,0):0),n.orbitalVelocityData[e].positionOffset.set(P[e].x,P[e].y,P[e].z)),N.attributes.lifetime.array[e]=0,N.attributes.lifetime.needsUpdate=!0,nt({delta:0,generalData:n,normalizedConfig:s,attributes:F.geometry.attributes,particleLifetimePercentage:0,particleIndex:e})}};xn.push(B);return{instance:z||F,resumeEmitter:()=>n.isEnabled=!0,pauseEmitter:()=>n.isEnabled=!1,dispose:()=>(e=>{xn=xn.filter(({particleSystem:t,wrapper:r,generalData:{particleSystemId:n}})=>t!==e&&r!==e||(Ve(n),t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach(e=>e.dispose()):t.material.dispose(),t.parent&&t.parent.remove(t),!1))})(F),update:e=>Pn(B,e)}},Pn=(e,{now:t,delta:r,elapsed:n})=>{const{onUpdate:s,generalData:i,onComplete:o,particleSystem:a,wrapper:c,elapsedUniform:l,creationTime:u,lastEmissionTime:h,duration:d,looping:p,emission:m,normalizedConfig:f,iterationCount:g,velocities:y,freeList:v,deactivateParticle:x,activateParticle:T,simulationSpace:w,gravity:I}=e,b=t-u,A=b%(1e3*d);i.normalizedLifetimePercentage=Math.max(Math.min(A/(1e3*d),1),0);const{lastWorldPosition:R,currentWorldPosition:M,worldPositionChange:S,lastWorldQuaternion:E,worldQuaternion:_,worldEuler:P,gravityVelocity:L,isEnabled:O}=i;c?.parent&&i.wrapperQuaternion.copy(c.parent.quaternion),Tn.copy(R),l.value=n,a.getWorldPosition(M),-99999!==R.x&&S.set(M.x-R.x,M.y-R.y,M.z-R.z),O&&(i.distanceFromLastEmitByDistance+=S.length()),a.getWorldPosition(R),a.getWorldQuaternion(_),-99999!==E.x&&E.x===_.x&&E.y===_.y&&E.z===_.z||(P.setFromQuaternion(_),E.copy(_),L.set(R.x,R.y+I,R.z),a.worldToLocal(L));const C=i.creationTimes,N=a.geometry.attributes,k=N.isActive.array,D=N.startLifetime.array,F=N.position.array,U=N.lifetime.array,z=C.length;let B=!1,V=!1;bn.delta=r,bn.generalData=i,bn.normalizedConfig=f,bn.attributes=N;for(let e=0;e<z;e++)if(k[e]){const n=t-C[e];if(n>D[e])x(e);else{const t=y[e];if(t.x-=L.x*r,t.y-=L.y*r,t.z-=L.z*r,0!==I||0!==t.x||0!==t.y||0!==t.z||0!==S.x||0!==S.y||0!==S.z){const n=3*e;"WORLD"===w&&(F[n]-=S.x,F[n+1]-=S.y,F[n+2]-=S.z),F[n]+=t.x*r,F[n+1]+=t.y*r,F[n+2]+=t.z*r,B=!0}U[e]=n,V=!0,bn.particleLifetimePercentage=n/D[e],bn.particleIndex=e,nt(bn)}}if(B&&(N.position.needsUpdate=!0),V&&(N.lifetime.needsUpdate=!0),O&&(p||b<1e3*d)){const o=t-h,c=m.rateOverTime?Math.floor(et(i.particleSystemId,m.rateOverTime,i.normalizedLifetimePercentage)*(o/1e3)):0,l=m.rateOverDistance?et(i.particleSystemId,m.rateOverDistance,i.normalizedLifetimePercentage):0,u=l>0&&i.distanceFromLastEmitByDistance>0?Math.floor(i.distanceFromLastEmitByDistance/(1/l)):0,d=u>0;d&&(wn.x=(M.x-Tn.x)/u,wn.y=(M.y-Tn.y)/u,wn.z=(M.z-Tn.z)/u);let f=c+u;if(l>0&&u>=1&&(i.distanceFromLastEmitByDistance=0),m.bursts&&i.burstStates){const e=m.bursts,t=i.burstStates,r=A;for(let n=0;n<e.length;n++){const s=e[n],o=t[n],a=1e3*s.time,c=s.cycles??1,l=1e3*(s.interval??0),u=s.probability??1;if(p&&r<a&&o.cyclesExecuted>0&&(o.cyclesExecuted=0,o.lastCycleTime=0,o.probabilityPassed=!1),o.cyclesExecuted>=c)continue;if(r>=a+o.cyclesExecuted*l){if(0===o.cyclesExecuted&&(o.probabilityPassed=Math.random()<u),o.probabilityPassed){f+=Math.floor(et(i.particleSystemId,s.count,i.normalizedLifetimePercentage))}o.cyclesExecuted++,o.lastCycleTime=r}}}if(f>0){let r=0;for(let n=0;n<f&&0!==v.length;n++){const n=v.pop();In.x=0,In.y=0,In.z=0,d&&r<u&&(In.x=wn.x*r,In.y=wn.y*r,In.z=wn.z*r,r++),T({particleIndex:n,activationTime:t,position:In}),e.lastEmissionTime=t}}s&&s({particleSystem:a,delta:r,elapsed:n,lifetime:b,normalizedLifetime:A,iterationCount:g+1})}else o&&o({particleSystem:a})},Ln=e=>{xn.forEach(t=>Pn(t,e))};export{nt as applyModifiers,An 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,_n as createParticleSystem,He as getBezierCacheSize,Ke as getCurveFunction,Je as getCurveFunctionFromConfig,Rn as getDefaultParticleSystemConfig,$e as isLifeTimeCurve,Ve as removeBezierCurveFunction,Ln as updateParticleSystems};
|
|
1
|
+
import e from"easing-functions";import*as t from"three";import{ObjectUtils as r}from"@newkrok/three-utils";import{Gyroscope as a}from"three/examples/jsm/misc/Gyroscope.js";import{FBM as i}from"three-noise/build/three-noise.module.js";var o=[],n=(e,t)=>{let r=1;for(let a=1;a<=t;a++)r*=(e+1-a)/a;return r},s=(e,t)=>{const r=o.find(e=>e.bezierPoints===t);if(r)return r.referencedBy.includes(e)||r.referencedBy.push(e),r.curveFunction;const a={referencedBy:[e],bezierPoints:t,curveFunction:e=>{if(e<0)return t[0].y;if(e>1)return t[t.length-1].y;let r=0,a=t.length-1;t.find((t,i)=>{const o=e<(t.percentage??0);return o?a=i:void 0!==t.percentage&&(r=i),o});const i=a-r,o=(e-(t[r].percentage??0))/((t[a].percentage??1)-(t[r].percentage??0));let s=0;for(let e=0;e<=i;e++){const a=t[r+e];s+=n(i,e)*Math.pow(1-o,i-e)*Math.pow(o,e)*a.y}return s}};return o.push(a),a.curveFunction},l=e=>{for(;;){const t=o.findIndex(t=>t.referencedBy.includes(e));if(-1===t)break;const r=o[t];r.referencedBy=r.referencedBy.filter(t=>t!==e),0===r.referencedBy.length&&o.splice(t,1)}},c=()=>o.length,m=(e=>(e.BEZIER="BEZIER",e.LINEAR="LINEAR",e.QUADRATIC_IN="QUADRATIC_IN",e.QUADRATIC_OUT="QUADRATIC_OUT",e.QUADRATIC_IN_OUT="QUADRATIC_IN_OUT",e.CUBIC_IN="CUBIC_IN",e.CUBIC_OUT="CUBIC_OUT",e.CUBIC_IN_OUT="CUBIC_IN_OUT",e.QUARTIC_IN="QUARTIC_IN",e.QUARTIC_OUT="QUARTIC_OUT",e.QUARTIC_IN_OUT="QUARTIC_IN_OUT",e.QUINTIC_IN="QUINTIC_IN",e.QUINTIC_OUT="QUINTIC_OUT",e.QUINTIC_IN_OUT="QUINTIC_IN_OUT",e.SINUSOIDAL_IN="SINUSOIDAL_IN",e.SINUSOIDAL_OUT="SINUSOIDAL_OUT",e.SINUSOIDAL_IN_OUT="SINUSOIDAL_IN_OUT",e.EXPONENTIAL_IN="EXPONENTIAL_IN",e.EXPONENTIAL_OUT="EXPONENTIAL_OUT",e.EXPONENTIAL_IN_OUT="EXPONENTIAL_IN_OUT",e.CIRCULAR_IN="CIRCULAR_IN",e.CIRCULAR_OUT="CIRCULAR_OUT",e.CIRCULAR_IN_OUT="CIRCULAR_IN_OUT",e.ELASTIC_IN="ELASTIC_IN",e.ELASTIC_OUT="ELASTIC_OUT",e.ELASTIC_IN_OUT="ELASTIC_IN_OUT",e.BACK_IN="BACK_IN",e.BACK_OUT="BACK_OUT",e.BACK_IN_OUT="BACK_IN_OUT",e.BOUNCE_IN="BOUNCE_IN",e.BOUNCE_OUT="BOUNCE_OUT",e.BOUNCE_IN_OUT="BOUNCE_IN_OUT",e))(m||{}),d={LINEAR:e.Linear.None,QUADRATIC_IN:e.Quadratic.In,QUADRATIC_OUT:e.Quadratic.Out,QUADRATIC_IN_OUT:e.Quadratic.InOut,CUBIC_IN:e.Cubic.In,CUBIC_OUT:e.Cubic.Out,CUBIC_IN_OUT:e.Cubic.InOut,QUARTIC_IN:e.Quartic.In,QUARTIC_OUT:e.Quartic.Out,QUARTIC_IN_OUT:e.Quartic.InOut,QUINTIC_IN:e.Quintic.In,QUINTIC_OUT:e.Quintic.Out,QUINTIC_IN_OUT:e.Quintic.InOut,SINUSOIDAL_IN:e.Sinusoidal.In,SINUSOIDAL_OUT:e.Sinusoidal.Out,SINUSOIDAL_IN_OUT:e.Sinusoidal.InOut,EXPONENTIAL_IN:e.Exponential.In,EXPONENTIAL_OUT:e.Exponential.Out,EXPONENTIAL_IN_OUT:e.Exponential.InOut,CIRCULAR_IN:e.Circular.In,CIRCULAR_OUT:e.Circular.Out,CIRCULAR_IN_OUT:e.Circular.InOut,ELASTIC_IN:e.Elastic.In,ELASTIC_OUT:e.Elastic.Out,ELASTIC_IN_OUT:e.Elastic.InOut,BACK_IN:e.Back.In,BACK_OUT:e.Back.Out,BACK_IN_OUT:e.Back.InOut,BOUNCE_IN:e.Bounce.In,BOUNCE_OUT:e.Bounce.Out,BOUNCE_IN_OUT:e.Bounce.InOut},y=e=>"function"==typeof e?e:d[e],p=(e=>(e.LOCAL="LOCAL",e.WORLD="WORLD",e))(p||{}),u=(e=>(e.SPHERE="SPHERE",e.CONE="CONE",e.BOX="BOX",e.CIRCLE="CIRCLE",e.RECTANGLE="RECTANGLE",e))(u||{}),f=(e=>(e.VOLUME="VOLUME",e.SHELL="SHELL",e.EDGE="EDGE",e))(f||{}),I=(e=>(e.LIFETIME="LIFETIME",e.FPS="FPS",e))(I||{}),g=(e=>(e.BEZIER="BEZIER",e.EASING="EASING",e))(g||{}),v=(e,t,r,a,{radius:i,radiusThickness:o,arc:n})=>{const s=Math.random()*(n/360),l=Math.random(),c=Math.random(),m=2*Math.PI*s,d=Math.acos(2*l-1),y=Math.sin(d),p=y*Math.cos(m),u=y*Math.sin(m),f=Math.cos(d),I=1-o;e.x=i*I*p+i*o*c*p,e.y=i*I*u+i*o*c*u,e.z=i*I*f+i*o*c*f,e.applyQuaternion(t);const g=1/e.length();r.set(e.x*g*a,e.y*g*a,e.z*g*a),r.applyQuaternion(t)},O=(e,r,a,i,{radius:o,radiusThickness:n,arc:s,angle:l=90})=>{const c=2*Math.PI*Math.random()*(s/360),m=Math.random(),d=Math.cos(c),y=Math.sin(c),p=1-n;e.x=o*p*d+o*n*m*d,e.y=o*p*y+o*n*m*y,e.z=0,e.applyQuaternion(r);const u=e.length(),f=Math.abs(u/o*t.MathUtils.degToRad(l)),I=Math.sin(f),g=1/u;a.set(e.x*I*g*i,e.y*I*g*i,Math.cos(f)*i),a.applyQuaternion(r)},x=(e,t,r,a,{scale:i,emitFrom:o})=>{const n=i;switch(o){case"VOLUME":e.x=Math.random()*n.x-n.x/2,e.y=Math.random()*n.y-n.y/2,e.z=Math.random()*n.z-n.z/2;break;case"SHELL":const t=Math.floor(6*Math.random()),r=t%3,a=[];a[r]=t>2?1:0,a[(r+1)%3]=Math.random(),a[(r+2)%3]=Math.random(),e.x=a[0]*n.x-n.x/2,e.y=a[1]*n.y-n.y/2,e.z=a[2]*n.z-n.z/2;break;case"EDGE":const i=Math.floor(6*Math.random()),o=i%3,s=Math.floor(4*Math.random()),l=[];l[o]=i>2?1:0,l[(o+1)%3]=s<2?Math.random():s-2,l[(o+2)%3]=s<2?s:Math.random(),e.x=l[0]*n.x-n.x/2,e.y=l[1]*n.y-n.y/2,e.z=l[2]*n.z-n.z/2}e.applyQuaternion(t),r.set(0,0,a),r.applyQuaternion(t)},C=(e,t,r,a,{radius:i,radiusThickness:o,arc:n})=>{const s=2*Math.PI*Math.random()*(n/360),l=Math.random(),c=Math.cos(s),m=Math.sin(s),d=1-o;e.x=i*d*c+i*o*l*c,e.y=i*d*m+i*o*l*m,e.z=0,e.applyQuaternion(t);const y=1/e.length();r.set(e.x*y*a,e.y*y*a,0),r.applyQuaternion(t)},U=(e,r,a,i,{rotation:o,scale:n})=>{const s=n,l=o,c=Math.random()*s.x-s.x/2,m=Math.random()*s.y-s.y/2,d=t.MathUtils.degToRad(l.x),y=t.MathUtils.degToRad(l.y);e.x=c*Math.cos(y),e.y=m*Math.cos(d),e.z=c*Math.sin(y)-m*Math.sin(d),e.applyQuaternion(r),a.set(0,0,i),a.applyQuaternion(r)},b=()=>{try{const e=document.createElement("canvas"),r=64;e.width=r,e.height=r;const a=e.getContext("2d");if(a){const i=r/2,o=r/2,n=r/2-2;a.beginPath(),a.arc(i,o,n,0,2*Math.PI,!1),a.fillStyle="white",a.fill();const s=new t.CanvasTexture(e);return s.needsUpdate=!0,s}return null}catch(e){return null}},T=e=>"number"!=typeof e&&"type"in e,A=(e,t)=>{if("BEZIER"===t.type)return s(e,t.bezierPoints);if("EASING"===t.type)return t.curveFunction;throw new Error(`Unsupported value type: ${t}`)},E=(e,r,a=0)=>{if("number"==typeof r)return r;if("min"in r&&"max"in r)return r.min===r.max?r.min??0:t.MathUtils.randFloat(r.min??0,r.max??1);const i=r;return A(e,i)(a)*(i.scale??1)},h=new t.Vector3(0,0,0),L=new t.Euler,N=({delta:e,generalData:t,normalizedConfig:r,attributes:a,particleLifetimePercentage:i,particleIndex:o})=>{const{particleSystemId:n,startValues:s,lifetimeValues:l,linearVelocityData:c,orbitalVelocityData:m,noise:d}=t,y=3*o,p=a.position.array;if(c){const{speed:t,valueModifiers:r}=c[o],n=r.x?r.x(i):t.x,s=r.y?r.y(i):t.y,l=r.z?r.z(i):t.z;p[y]+=n*e,p[y+1]+=s*e,p[y+2]+=l*e,a.position.needsUpdate=!0}if(m){const{speed:t,positionOffset:r,valueModifiers:n}=m[o];p[y]-=r.x,p[y+1]-=r.y,p[y+2]-=r.z;const s=n.x?n.x(i):t.x,l=n.y?n.y(i):t.y,c=n.z?n.z(i):t.z;L.set(s*e,c*e,l*e),r.applyEuler(L),p[y]+=r.x,p[y+1]+=r.y,p[y+2]+=r.z,a.position.needsUpdate=!0}if(r.sizeOverLifetime.isActive){const e=E(n,r.sizeOverLifetime.lifetimeCurve,i);a.size.array[o]=s.startSize[o]*e,a.size.needsUpdate=!0}if(r.opacityOverLifetime.isActive){const e=E(n,r.opacityOverLifetime.lifetimeCurve,i);a.colorA.array[o]=s.startOpacity[o]*e,a.colorA.needsUpdate=!0}if(r.colorOverLifetime.isActive){const e=E(n,r.colorOverLifetime.r,i),t=E(n,r.colorOverLifetime.g,i),l=E(n,r.colorOverLifetime.b,i);a.colorR.array[o]=s.startColorR[o]*e,a.colorG.array[o]=s.startColorG[o]*t,a.colorB.array[o]=s.startColorB[o]*l,a.colorR.needsUpdate=!0,a.colorG.needsUpdate=!0,a.colorB.needsUpdate=!0}if(l.rotationOverLifetime&&(a.rotation.array[o]+=l.rotationOverLifetime[o]*e*.02,a.rotation.needsUpdate=!0),d.isActive){const{sampler:e,strength:t,noisePower:r,offsets:n,positionAmount:s,rotationAmount:l,sizeAmount:c}=d;let m;const u=10*(i+(n?n[o]:0))*t;h.set(u,0,0),m=e.get3(h),p[y]+=m*r*s,0!==l&&(a.rotation.array[o]+=m*r*l,a.rotation.needsUpdate=!0),0!==c&&(a.size.array[o]+=m*r*c,a.size.needsUpdate=!0),h.set(u,u,0),m=e.get3(h),p[y+1]+=m*r*s,h.set(u,u,u),m=e.get3(h),p[y+2]+=m*r*s,a.position.needsUpdate=!0}},_=0,S=[],z=new t.Vector3,P={x:0,y:0,z:0},R={x:0,y:0,z:0},B={delta:0,generalData:null,normalizedConfig:null,attributes:null,particleLifetimePercentage:0,particleIndex:0},M={"THREE.NoBlending":t.NoBlending,"THREE.NormalBlending":t.NormalBlending,"THREE.AdditiveBlending":t.AdditiveBlending,"THREE.SubtractiveBlending":t.SubtractiveBlending,"THREE.MultiplyBlending":t.MultiplyBlending},w=()=>JSON.parse(JSON.stringify(Q)),Q={transform:{position:new t.Vector3,rotation:new t.Vector3,scale:new t.Vector3(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,bursts:[]},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:t.NormalBlending,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 t.Vector2(1,1),timeMode:"LIFETIME",fps:30,startFrame:0}},D=({geometry:e,propertyName:r,maxParticles:a,factory:i})=>{const o=new Float32Array(a);if("function"==typeof i)for(let e=0;e<a;e++)o[e]=i(void 0,e);else o.fill(i);e.setAttribute(r,new t.BufferAttribute(o,1))},V=(e,{shape:t,sphere:r,cone:a,circle:i,rectangle:o,box:n},s,l,c)=>{const m=E(e.particleSystemId,s,e.normalizedLifetimePercentage);switch(t){case"SPHERE":v(l,e.wrapperQuaternion,c,m,r);break;case"CONE":O(l,e.wrapperQuaternion,c,m,a);break;case"CIRCLE":C(l,e.wrapperQuaternion,c,m,i);break;case"RECTANGLE":U(l,e.wrapperQuaternion,c,m,o);break;case"BOX":x(l,e.wrapperQuaternion,c,m,n)}},F=(e=Q,o)=>{const n=o||Date.now(),s={particleSystemId:_++,normalizedLifetimePercentage:0,distanceFromLastEmitByDistance:0,lastWorldPosition:new t.Vector3(-99999),currentWorldPosition:new t.Vector3(-99999),worldPositionChange:new t.Vector3,worldQuaternion:new t.Quaternion,wrapperQuaternion:new t.Quaternion,lastWorldQuaternion:new t.Quaternion(-99999),worldEuler:new t.Euler,gravityVelocity:new t.Vector3(0,0,0),startValues:{},linearVelocityData:void 0,orbitalVelocityData:void 0,lifetimeValues:{},creationTimes:[],noise:{isActive:!1,strength:0,noisePower:0,positionAmount:0,rotationAmount:0,sizeAmount:0},isEnabled:!0},c=r.deepMerge(Q,e,{applyToFirstObject:!1,skippedProperties:[]});let m=c.map||b();const{transform:d,duration:y,looping:p,startDelay:u,startLifetime:f,startSpeed:I,startSize:g,startRotation:v,startColor:O,startOpacity:x,gravity:C,simulationSpace:U,maxParticles:h,emission:L,shape:z,renderer:P,noise:R,velocityOverLifetime:B,onUpdate:w,onComplete:F,textureSheetAnimation:G}=c;"string"==typeof P?.blending&&(P.blending=M[P.blending]);const W=Array.from({length:h},()=>new t.Vector3),X=Array.from({length:h},()=>new t.Vector3);s.creationTimes=Array.from({length:h},()=>0);const H=Array.from({length:h},(e,t)=>h-1-t);B.isActive&&(s.linearVelocityData=Array.from({length:h},()=>({speed:new t.Vector3(B.linear.x?E(s.particleSystemId,B.linear.x,0):0,B.linear.y?E(s.particleSystemId,B.linear.y,0):0,B.linear.z?E(s.particleSystemId,B.linear.z,0):0),valueModifiers:{x:T(B.linear.x||0)?A(s.particleSystemId,B.linear.x):void 0,y:T(B.linear.y||0)?A(s.particleSystemId,B.linear.y):void 0,z:T(B.linear.z||0)?A(s.particleSystemId,B.linear.z):void 0}})),s.orbitalVelocityData=Array.from({length:h},()=>({speed:new t.Vector3(B.orbital.x?E(s.particleSystemId,B.orbital.x,0):0,B.orbital.y?E(s.particleSystemId,B.orbital.y,0):0,B.orbital.z?E(s.particleSystemId,B.orbital.z,0):0),valueModifiers:{x:T(B.orbital.x||0)?A(s.particleSystemId,B.orbital.x):void 0,y:T(B.orbital.y||0)?A(s.particleSystemId,B.orbital.y):void 0,z:T(B.orbital.z||0)?A(s.particleSystemId,B.orbital.z):void 0},positionOffset:new t.Vector3})));["startSize","startOpacity"].forEach(e=>{s.startValues[e]=Array.from({length:h},()=>E(s.particleSystemId,c[e],0))}),s.startValues.startColorR=Array.from({length:h},()=>0),s.startValues.startColorG=Array.from({length:h},()=>0),s.startValues.startColorB=Array.from({length:h},()=>0);["rotationOverLifetime"].forEach(e=>{const r=c[e];r.isActive&&(s.lifetimeValues[e]=Array.from({length:h},()=>t.MathUtils.randFloat(r.min,r.max)))}),s.noise={isActive:R.isActive,strength:R.strength,noisePower:.15*R.strength,positionAmount:R.positionAmount,rotationAmount:R.rotationAmount,sizeAmount:R.sizeAmount,sampler:R.isActive?new i({seed:Math.random(),scale:R.frequency,octaves:R.octaves}):void 0,offsets:R.useRandomOffset?Array.from({length:h},()=>100*Math.random()):void 0},L.bursts&&L.bursts.length>0&&(s.burstStates=L.bursts.map(()=>({cyclesExecuted:0,lastCycleTime:0,probabilityPassed:!1})));const Z=new t.ShaderMaterial({uniforms:{elapsed:{value:0},map:{value:m},tiles:{value:G.tiles},fps:{value:G.fps},useFPSForFrameIndex:{value:"FPS"===G.timeMode},backgroundColor:{value:P.backgroundColor},discardBackgroundColor:{value:P.discardBackgroundColor},backgroundColorTolerance:{value:P.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:P.transparent,blending:P.blending,depthTest:P.depthTest,depthWrite:P.depthWrite}),K=new t.BufferGeometry;for(let e=0;e<h;e++)V(s,z,I,W[e],X[e]);const j=new Float32Array(3*h);for(let e=0;e<h;e++)j[3*e]=W[e].x,j[3*e+1]=W[e].y,j[3*e+2]=W[e].z;K.setAttribute("position",new t.BufferAttribute(j,3)),D({geometry:K,propertyName:"isActive",maxParticles:h,factory:0}),D({geometry:K,propertyName:"lifetime",maxParticles:h,factory:0}),D({geometry:K,propertyName:"startLifetime",maxParticles:h,factory:()=>1e3*E(s.particleSystemId,f,0)}),D({geometry:K,propertyName:"startFrame",maxParticles:h,factory:()=>G.startFrame?E(s.particleSystemId,G.startFrame,0):0}),D({geometry:K,propertyName:"opacity",maxParticles:h,factory:()=>E(s.particleSystemId,x,0)}),D({geometry:K,propertyName:"rotation",maxParticles:h,factory:()=>E(s.particleSystemId,v,0)}),D({geometry:K,propertyName:"size",maxParticles:h,factory:(e,t)=>s.startValues.startSize[t]}),D({geometry:K,propertyName:"rotation",maxParticles:h,factory:0});const q=Math.random();D({geometry:K,propertyName:"colorR",maxParticles:h,factory:()=>O.min.r+q*(O.max.r-O.min.r)}),D({geometry:K,propertyName:"colorG",maxParticles:h,factory:()=>O.min.g+q*(O.max.g-O.min.g)}),D({geometry:K,propertyName:"colorB",maxParticles:h,factory:()=>O.min.b+q*(O.max.b-O.min.b)}),D({geometry:K,propertyName:"colorA",maxParticles:h,factory:0});let Y=new t.Points(K,Z);Y.position.copy(d.position),Y.rotation.x=t.MathUtils.degToRad(d.rotation.x),Y.rotation.y=t.MathUtils.degToRad(d.rotation.y),Y.rotation.z=t.MathUtils.degToRad(d.rotation.z),Y.scale.copy(d.scale);const J=n+1e3*E(s.particleSystemId,u);let $;"WORLD"===c.simulationSpace&&($=new a,$.add(Y));const ee={particleSystem:Y,wrapper:$,elapsedUniform:Z.uniforms.elapsed,generalData:s,onUpdate:w,onComplete:F,creationTime:J,lastEmissionTime:J,duration:y,looping:p,simulationSpace:U,gravity:C,emission:L,normalizedConfig:c,iterationCount:0,velocities:X,freeList:H,deactivateParticle:e=>{K.attributes.isActive.array[e]=0,K.attributes.colorA.array[e]=0,K.attributes.colorA.needsUpdate=!0,H.push(e)},activateParticle:({particleIndex:e,activationTime:r,position:a})=>{K.attributes.isActive.array[e]=1,s.creationTimes[e]=r,s.noise.offsets&&(s.noise.offsets[e]=100*Math.random());const i=Math.random();K.attributes.colorR.array[e]=O.min.r+i*(O.max.r-O.min.r),K.attributes.colorR.needsUpdate=!0,K.attributes.colorG.array[e]=O.min.g+i*(O.max.g-O.min.g),K.attributes.colorG.needsUpdate=!0,K.attributes.colorB.array[e]=O.min.b+i*(O.max.b-O.min.b),K.attributes.colorB.needsUpdate=!0,s.startValues.startColorR[e]=K.attributes.colorR.array[e],s.startValues.startColorG[e]=K.attributes.colorG.array[e],s.startValues.startColorB[e]=K.attributes.colorB.array[e],K.attributes.startFrame.array[e]=G.startFrame?E(s.particleSystemId,G.startFrame,0):0,K.attributes.startFrame.needsUpdate=!0,K.attributes.startLifetime.array[e]=1e3*E(s.particleSystemId,f,s.normalizedLifetimePercentage),K.attributes.startLifetime.needsUpdate=!0,s.startValues.startSize[e]=E(s.particleSystemId,g,s.normalizedLifetimePercentage),K.attributes.size.array[e]=s.startValues.startSize[e],K.attributes.size.needsUpdate=!0,s.startValues.startOpacity[e]=E(s.particleSystemId,x,s.normalizedLifetimePercentage),K.attributes.colorA.array[e]=s.startValues.startOpacity[e],K.attributes.colorA.needsUpdate=!0,K.attributes.rotation.array[e]=E(s.particleSystemId,v,s.normalizedLifetimePercentage),K.attributes.rotation.needsUpdate=!0,c.rotationOverLifetime.isActive&&(s.lifetimeValues.rotationOverLifetime[e]=t.MathUtils.randFloat(c.rotationOverLifetime.min,c.rotationOverLifetime.max)),V(s,z,I,W[e],X[e]);const o=Math.floor(3*e);K.attributes.position.array[o]=a.x+W[e].x,K.attributes.position.array[o+1]=a.y+W[e].y,K.attributes.position.array[o+2]=a.z+W[e].z,K.attributes.position.needsUpdate=!0,s.linearVelocityData&&s.linearVelocityData[e].speed.set(c.velocityOverLifetime.linear.x?E(s.particleSystemId,c.velocityOverLifetime.linear.x,0):0,c.velocityOverLifetime.linear.y?E(s.particleSystemId,c.velocityOverLifetime.linear.y,0):0,c.velocityOverLifetime.linear.z?E(s.particleSystemId,c.velocityOverLifetime.linear.z,0):0),s.orbitalVelocityData&&(s.orbitalVelocityData[e].speed.set(c.velocityOverLifetime.orbital.x?E(s.particleSystemId,c.velocityOverLifetime.orbital.x,0):0,c.velocityOverLifetime.orbital.y?E(s.particleSystemId,c.velocityOverLifetime.orbital.y,0):0,c.velocityOverLifetime.orbital.z?E(s.particleSystemId,c.velocityOverLifetime.orbital.z,0):0),s.orbitalVelocityData[e].positionOffset.set(W[e].x,W[e].y,W[e].z)),K.attributes.lifetime.array[e]=0,K.attributes.lifetime.needsUpdate=!0,N({delta:0,generalData:s,normalizedConfig:c,attributes:Y.geometry.attributes,particleLifetimePercentage:0,particleIndex:e})}};S.push(ee);return{instance:$||Y,resumeEmitter:()=>s.isEnabled=!0,pauseEmitter:()=>s.isEnabled=!1,dispose:()=>(e=>{S=S.filter(({particleSystem:t,wrapper:r,generalData:{particleSystemId:a}})=>t!==e&&r!==e||(l(a),t.geometry.dispose(),Array.isArray(t.material)?t.material.forEach(e=>e.dispose()):t.material.dispose(),t.parent&&t.parent.remove(t),!1))})(Y),update:e=>k(ee,e)}},k=(e,{now:t,delta:r,elapsed:a})=>{const{onUpdate:i,generalData:o,onComplete:n,particleSystem:s,wrapper:l,elapsedUniform:c,creationTime:m,lastEmissionTime:d,duration:y,looping:p,emission:u,normalizedConfig:f,iterationCount:I,velocities:g,freeList:v,deactivateParticle:O,activateParticle:x,simulationSpace:C,gravity:U}=e,b=t-m,T=b%(1e3*y);o.normalizedLifetimePercentage=Math.max(Math.min(T/(1e3*y),1),0);const{lastWorldPosition:A,currentWorldPosition:h,worldPositionChange:L,lastWorldQuaternion:_,worldQuaternion:S,worldEuler:M,gravityVelocity:w,isEnabled:Q}=o;l?.parent&&o.wrapperQuaternion.copy(l.parent.quaternion),z.copy(A),c.value=a,s.getWorldPosition(h),-99999!==A.x&&L.set(h.x-A.x,h.y-A.y,h.z-A.z),Q&&(o.distanceFromLastEmitByDistance+=L.length()),s.getWorldPosition(A),s.getWorldQuaternion(S),-99999!==_.x&&_.x===S.x&&_.y===S.y&&_.z===S.z||(M.setFromQuaternion(S),_.copy(S),w.set(A.x,A.y+U,A.z),s.worldToLocal(w));const D=o.creationTimes,V=s.geometry.attributes,F=V.isActive.array,k=V.startLifetime.array,G=V.position.array,W=V.lifetime.array,X=D.length;let H=!1,Z=!1;B.delta=r,B.generalData=o,B.normalizedConfig=f,B.attributes=V;for(let e=0;e<X;e++)if(F[e]){const a=t-D[e];if(a>k[e])O(e);else{const t=g[e];if(t.x-=w.x*r,t.y-=w.y*r,t.z-=w.z*r,0!==U||0!==t.x||0!==t.y||0!==t.z||0!==L.x||0!==L.y||0!==L.z){const a=3*e;"WORLD"===C&&(G[a]-=L.x,G[a+1]-=L.y,G[a+2]-=L.z),G[a]+=t.x*r,G[a+1]+=t.y*r,G[a+2]+=t.z*r,H=!0}W[e]=a,Z=!0,B.particleLifetimePercentage=a/k[e],B.particleIndex=e,N(B)}}if(H&&(V.position.needsUpdate=!0),Z&&(V.lifetime.needsUpdate=!0),Q&&(p||b<1e3*y)){const n=t-d,l=u.rateOverTime?Math.floor(E(o.particleSystemId,u.rateOverTime,o.normalizedLifetimePercentage)*(n/1e3)):0,c=u.rateOverDistance?E(o.particleSystemId,u.rateOverDistance,o.normalizedLifetimePercentage):0,m=c>0&&o.distanceFromLastEmitByDistance>0?Math.floor(o.distanceFromLastEmitByDistance/(1/c)):0,y=m>0;y&&(P.x=(h.x-z.x)/m,P.y=(h.y-z.y)/m,P.z=(h.z-z.z)/m);let f=l+m;if(c>0&&m>=1&&(o.distanceFromLastEmitByDistance=0),u.bursts&&o.burstStates){const e=u.bursts,t=o.burstStates,r=T;for(let a=0;a<e.length;a++){const i=e[a],n=t[a],s=1e3*i.time,l=i.cycles??1,c=1e3*(i.interval??0),m=i.probability??1;if(p&&r<s&&n.cyclesExecuted>0&&(n.cyclesExecuted=0,n.lastCycleTime=0,n.probabilityPassed=!1),n.cyclesExecuted>=l)continue;if(r>=s+n.cyclesExecuted*c){if(0===n.cyclesExecuted&&(n.probabilityPassed=Math.random()<m),n.probabilityPassed){f+=Math.floor(E(o.particleSystemId,i.count,o.normalizedLifetimePercentage))}n.cyclesExecuted++,n.lastCycleTime=r}}}if(f>0){let r=0;for(let a=0;a<f&&0!==v.length;a++){const a=v.pop();R.x=0,R.y=0,R.z=0,y&&r<m&&(R.x=P.x*r,R.y=P.y*r,R.z=P.z*r,r++),x({particleIndex:a,activationTime:t,position:R}),e.lastEmissionTime=t}}i&&i({particleSystem:s,delta:r,elapsed:a,lifetime:b,normalizedLifetime:T,iterationCount:I+1})}else n&&n({particleSystem:s})},G=e=>{S.forEach(t=>k(t,e))};export{m as CurveFunctionId,f as EmitFrom,g as LifeTimeCurve,u as Shape,p as SimulationSpace,I as TimeMode,N as applyModifiers,M as blendingMap,x as calculateRandomPositionAndVelocityOnBox,C as calculateRandomPositionAndVelocityOnCircle,O as calculateRandomPositionAndVelocityOnCone,U as calculateRandomPositionAndVelocityOnRectangle,v as calculateRandomPositionAndVelocityOnSphere,E as calculateValue,s as createBezierCurveFunction,b as createDefaultParticleTexture,F as createParticleSystem,c as getBezierCacheSize,y as getCurveFunction,A as getCurveFunctionFromConfig,w as getDefaultParticleSystemConfig,T as isLifeTimeCurve,l as removeBezierCurveFunction,G as updateParticleSystems};//# sourceMappingURL=three-particles.min.js.map
|