hz-particles 1.0.10 → 1.0.12

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.
@@ -1,13 +1,13 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const $e=require("react/jsx-runtime"),r=require("react"),at=require("@react-three/fiber"),mn=require("three"),Et=require("hz-particles");function hn(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const i in t)if(i!=="default"){const z=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(a,i,z.get?z:{enumerable:!0,get:()=>t[i]})}}return a.default=t,Object.freeze(a)}const o=hn(mn);function Ut(t){return Math.abs(Math.sin(t*12.9898)*43758.5453)%1}function yn(t){const a=Math.sin(t*54321.67)*43758.5453%1;return a<0?a+1:a}function It(t,a,i,z){if(i<=0)return 0;const l=a/i;let O=t.particleSize??.5;if(t.randomSize){const F=t.minSize??.1,_=t.maxSize??.5;O=F+(_-F)*yn(i)}const L=Math.max(.01,Math.min(10,t.sizeLifetimeSpeed??1));if(t.fadeSizeEnabled&&(O*=1-Math.pow(l,1/L)),t.increaseSizeEnabled&&(O*=1+Math.pow(l,1/L)),t.pulseEnabled){const F=t.pulseAmplitude??.5,_=t.pulseFrequency??1,K=(t.pulsePhaseRandom??0)*Ut(z)*Math.PI*2;O*=1+F*Math.sin(a*_*Math.PI*2+K)}return Math.max(0,O)}function Ft(t,a,i,z){if(i<=0)return 0;let l=t.opacity??1;const O=a/i;if(t.fadeEnabled&&(l*=Math.max(0,1-O)),t.pulseEnabled&&t.pulseOpacity){const L=t.pulseAmplitude??.5,F=t.pulseFrequency??1,G=(t.pulsePhaseRandom??0)*Ut(z)*Math.PI*2;l*=Math.max(0,1+L*Math.sin(a*F*Math.PI*2+G))}return Math.max(0,Math.min(1,l))}function Jt(t,a){return a===1?t:{...t,systems:t.systems.map(i=>({...i,particleSize:(i.particleSize??.5)*a,minSize:i.minSize!=null?i.minSize*a:void 0,maxSize:i.maxSize!=null?i.maxSize*a:void 0,particleSpeed:(i.particleSpeed??1)*a,minSpeed:i.minSpeed!=null?i.minSpeed*a:void 0,maxSpeed:i.maxSpeed!=null?i.maxSpeed*a:void 0}))}}function Mn(t){let a=0;for(const i of t.systems)a+=i.maxParticles??1e4;return a}function Sn({preset:t,position:a,positionRef:i,autoPlay:z=!0,visible:l=!0,scale:O=1,resetKey:L=0,onComplete:F}){var Ce;const[_,G]=r.useState(typeof t=="string"?null:t);r.useEffect(()=>{typeof t=="string"?(G(null),Et.fetchPreset(t).then(G).catch(c=>{console.error("[HZParticlesFX] Failed to fetch preset:",c)})):G(t)},[t]);const{camera:K,gl:it}=at.useThree(),ce=r.useRef(null);if(!ce.current){const c=(Ce=it.backend)==null?void 0:Ce.device;c&&(ce.current=c)}const Ae=ce.current,Re=r.useRef(null),he=r.useRef(null),Pe=r.useRef(!1),P=r.useRef(!1),f=r.useMemo(()=>_?Jt(_,O):null,[_,O]),Ke=r.useMemo(()=>f?Mn(f):0,[f]),lt=r.useMemo(()=>a?a instanceof o.Vector3?a.clone():new o.Vector3(...a):new o.Vector3(0,0,0),[a]),Te=r.useMemo(()=>(f==null?void 0:f.systems.some(c=>c.emissionTrailEnabled))??!1,[f]),qe=r.useMemo(()=>new o.PlaneGeometry(1,1),[]),je=r.useMemo(()=>{const c=document.createElement("canvas");c.width=64,c.height=64;const A=c.getContext("2d");A.clearRect(0,0,64,64);const V=A.createRadialGradient(32,32,0,32,32,32);V.addColorStop(0,"rgba(255,255,255,1)"),V.addColorStop(.7,"rgba(255,255,255,1)"),V.addColorStop(1,"rgba(255,255,255,0)"),A.fillStyle=V,A.beginPath(),A.arc(32,32,32,0,Math.PI*2),A.fill();const p=new o.CanvasTexture(c);p.flipY=!1;const B=new o.MeshBasicMaterial({color:16777215,transparent:!0,depthWrite:!1,alphaTest:.01,map:p,vertexColors:!0,side:o.DoubleSide,blending:o.AdditiveBlending});return B.needsUpdate=!0,B},[]),e=64,T=100,ye=r.useRef(null),U=r.useRef(0),u=512,M=r.useRef({buf:new Float32Array(u*4),head:0,count:0,elapsed:0}),{trailGeo:Y,trailPosAttr:ee,trailColAttr:d}=r.useMemo(()=>{const c=T*e*6,A=new Float32Array(c*3),V=new Float32Array(c*3),p=new o.BufferGeometry,B=new o.BufferAttribute(A,3);B.setUsage(o.DynamicDrawUsage),p.setAttribute("position",B);const ae=new o.BufferAttribute(V,3);return ae.setUsage(o.DynamicDrawUsage),p.setAttribute("color",ae),p.setDrawRange(0,0),{trailGeo:p,trailPosAttr:B,trailColAttr:ae}},[]),E=r.useMemo(()=>new o.MeshBasicMaterial({vertexColors:!0,transparent:!0,depthWrite:!1,side:o.DoubleSide,blending:o.AdditiveBlending}),[]);r.useEffect(()=>{if(!Ae||!f)return;const c=new Et.ParticleSystemManager(Ae);return he.current=c,P.current=!1,c.replaceSystems(f).then(()=>{z&&l&&(c.respawnAllSystems(),P.current=!0)}).catch(A=>{console.error("[HZParticlesFX] replaceSystems FAILED:",A)}),()=>{typeof c.destroy=="function"&&c.destroy(),he.current=null}},[Ae,f]),r.useEffect(()=>{const c=he.current;c&&z&&l&&!P.current&&(c.respawnAllSystems(),P.current=!0,Pe.current=!1)},[z,l]);const Me=r.useRef(L);r.useEffect(()=>{if(L===Me.current)return;Me.current=L;const c=M.current;c.head=0,c.count=0,c.elapsed=0,Y.setDrawRange(0,0),x.current=null;const A=he.current;A&&(A.respawnAllSystems(),P.current=!0,Pe.current=!1)},[L]);const Se=r.useMemo(()=>new o.Matrix4,[]),te=r.useMemo(()=>new o.Vector3,[]),Ve=r.useMemo(()=>new o.Vector3,[]),xe=r.useMemo(()=>new o.Quaternion,[]),W=r.useMemo(()=>new o.Vector3,[]),ne=r.useMemo(()=>new o.Vector3(0,0,1),[]),Xe=r.useMemo(()=>new o.Color,[]),x=r.useRef(null);return at.useFrame((c,A)=>{if(!l||!Re.current||!he.current)return;const V=he.current,p=(i==null?void 0:i.current)??lt,B=A>1?A/1e3:A,ae=x.current,ut=ae&&B>0,$t=ut?(p.x-ae.x)/B:0,Kt=ut?(p.y-ae.y)/B:0,en=ut?(p.z-ae.z)/B:0;x.current={x:p.x,y:p.y,z:p.z};for(const{system:n,config:s}of V.particleSystems)s.emissionTrailEnabled?(n.setSimulationTransform({position:[p.x,p.y,p.z],velocity:[$t,Kt,en]}),s.shapeTranslationX=0,s.shapeTranslationY=0,s.shapeTranslationZ=0):(s.shapeTranslationX=p.x,s.shapeTranslationY=p.y,s.shapeTranslationZ=p.z);V.updateAllSystems(B);for(const{system:n}of V.particleSystems)n.readbackAndProcessParticles();if(Te){const n=M.current;n.elapsed+=B;const s=n.head*4;n.buf[s]=p.x,n.buf[s+1]=p.y,n.buf[s+2]=p.z,n.buf[s+3]=n.elapsed,n.head=(n.head+1)%u,n.count<u&&n.count++}const De=Re.current;let Ze=0;for(let n=0;n<V.particleSystems.length;n++){const{system:s,config:m}=V.particleSystems[n];if(m.emissionTrailEnabled)continue;const q=s.particleData,ie=s.activeParticles;if(!q||ie<=0)continue;const I=s._simPosition,b=m.emissionTrailEnabled&&I?I[0]:0,h=m.emissionTrailEnabled&&I?I[1]:0,Ee=m.emissionTrailEnabled&&I?I[2]:0;for(let se=0;se<ie;se++){const k=se*8,ft=q[k+0]+b,le=q[k+1]+h,dt=q[k+2]+Ee;let be=q[k+3],ge=q[k+4],j=q[k+5];const Ie=q[k+6],ve=q[k+7];if(Ie>=ve||ve<=0)continue;const Le=Ie/ve;if(m.colorTransitionEnabled){const C=m.startColor??[1,0,0],X=m.endColor??[0,0,1];be=C[0]+(X[0]-C[0])*Le,ge=C[1]+(X[1]-C[1])*Le,j=C[2]+(X[2]-C[2])*Le}const ue=m.bloomIntensity??1;be=Math.min(1,be*ue),ge=Math.min(1,ge*ue),j=Math.min(1,j*ue);const S=Ft(m,Ie,ve,se);be*=S,ge*=S,j*=S;const H=It(m,Ie,ve,se);if(!(H<=0)){if(te.set(ft,le,dt),Ve.subVectors(K.position,te).normalize(),xe.setFromUnitVectors(ne,Ve),m.velocityStretchEnabled&&s.particleVelocities){const C=se*4,X=s.particleVelocities[C],Fe=s.particleVelocities[C+1],Ue=s.particleVelocities[C+2],Ge=Math.sqrt(X*X+Fe*Fe+Ue*Ue);if(Ge>.001){const N=m.velocityStretchFactor??1,y=H*(1+Ge*N);W.set(H,y,1),Ve.set(X,Fe,Ue).normalize(),xe.setFromUnitVectors(ne,Ve);const pt=(y-H)*.5;te.addScaledVector(Ve,pt)}else W.set(H,H,1)}else W.set(H,H,1);Se.compose(te,xe,W),De.setMatrixAt(Ze,Se),Xe.setRGB(be,ge,j),De.setColorAt(Ze,Xe),Ze++}}}De.count=Ze,De.instanceMatrix.needsUpdate=!0,De.instanceColor&&(De.instanceColor.needsUpdate=!0);const Bt=Ze>0||V.particleSystems.some(({system:n})=>n.emitting||n.activeParticles>0);if(Pe.current&&!Bt&&(P.current=!1,F==null||F()),Pe.current=Bt,Te&&ye.current){const n=ee.array,s=d.array;let m=0;for(let ie=0;ie<V.particleSystems.length;ie++){const{system:I,config:b}=V.particleSystems[ie];if(!b.emissionTrailEnabled||b.glbModelEnabled||b.textureEnabled)continue;const h=I.particleData,Ee=I.particleVelocities,se=I.activeParticles;if(!h||!Ee||se<=0)continue;const k=b.emissionTrailDuration??1,ft=b.emissionTrailWidth??.3,le=I._simPosition,dt=le?le[0]:0,be=le?le[1]:0,ge=le?le[2]:0,j=I._simVelocity,Ie=j?j[0]:0,ve=j?j[1]:0,Le=j?j[2]:0,ue=M.current,S=ue.buf,H=ue.count,C=ue.head,X=ue.elapsed,Fe=H>=2;let Ue=X;if(Fe){const N=((C-H)%u+u)%u;Ue=X-S[N*4+3]}const Ge=X;for(let N=0;N<se&&!(m+e*6>T*e*6);N++){const y=N*8,pt=h[y+6],Be=h[y+7];if(pt>=Be||Be<=0)continue;const mt=Math.min(Ge,Be),ht=mt/Be;let Ye=h[y+3],We=h[y+4],ke=h[y+5];if(b.colorTransitionEnabled){const R=b.startColor??[1,0,0],g=b.endColor??[0,0,1];Ye=R[0]+(g[0]-R[0])*ht,We=R[1]+(g[1]-R[1])*ht,ke=R[2]+(g[2]-R[2])*ht}const yt=b.bloomIntensity??1;if(Ye=Math.min(1,Ye*yt),We=Math.min(1,We*yt),ke=Math.min(1,ke*yt),It(b,mt,Be,N)<=0)continue;const Ht=ft*.5,Mt=Ft(b,mt,Be,N);if(Mt<.01)continue;const St=N*4,Ne=Ee[St],Qe=Ee[St+1],Je=Ee[St+2],we=Math.sqrt(Ne*Ne+Qe*Qe+Je*Je)>.05,ze=Math.min(k,Ge,Ue);if(ze<.001)continue;const et=(R,g)=>{if(!Fe){g[0]=dt-Ie*R,g[1]=be-ve*R,g[2]=ge-Le*R;return}const fe=X-R;for(let re=0;re<H-1;re++){const Z=((C-1-re)%u+u)%u,D=((C-2-re)%u+u)%u,pe=S[Z*4+3],oe=S[D*4+3];if(fe>=oe&&fe<=pe){const me=pe!==oe?(fe-oe)/(pe-oe):0;g[0]=S[D*4]+(S[Z*4]-S[D*4])*me,g[1]=S[D*4+1]+(S[Z*4+1]-S[D*4+1])*me,g[2]=S[D*4+2]+(S[Z*4+2]-S[D*4+2])*me;return}}const de=((C-H)%u+u)%u;g[0]=S[de*4],g[1]=S[de*4+1],g[2]=S[de*4+2]},tn=K.position.x,nn=K.position.y,sn=K.position.z,tt=[0,0,0],nt=[0,0,0];et(0,tt),et(ze,nt);const Ot=(we?h[y]:0)+tt[0],_t=(we?h[y+1]:0)+tt[1],qt=(we?h[y+2]:0)+tt[2],rn=(we?h[y]-Ne*ze:0)+nt[0],on=(we?h[y+1]-Qe*ze:0)+nt[1],cn=(we?h[y+2]-Je*ze:0)+nt[2],xt=rn-Ot,bt=on-_t,gt=cn-qt,st=Math.sqrt(xt*xt+bt*bt+gt*gt);if(st<1e-6)continue;const vt=xt/st,jt=bt/st,wt=gt/st,Xt=tn-Ot,Zt=nn-_t,Lt=sn-qt;let Q=jt*Lt-wt*Zt,J=wt*Xt-vt*Lt,$=vt*Zt-jt*Xt,He=Math.sqrt(Q*Q+J*J+$*$);if(He<1e-6&&(Q=-wt,J=0,$=vt,He=Math.sqrt(Q*Q+J*J+$*$)),!(He<1e-6)){Q/=He,J/=He,$/=He;for(let R=0;R<e;R++){const g=R/e,fe=(R+1)/e,de=g*ze,re=fe*ze,Z=[0,0,0],D=[0,0,0];et(de,Z),et(re,D);let pe,oe,me,rt,ot,ct;we?(pe=h[y]-Ne*de+Z[0],oe=h[y+1]-Qe*de+Z[1],me=h[y+2]-Je*de+Z[2],rt=h[y]-Ne*re+D[0],ot=h[y+1]-Qe*re+D[1],ct=h[y+2]-Je*re+D[2]):(pe=Z[0],oe=Z[1],me=Z[2],rt=D[0],ot=D[1],ct=D[2]);const Oe=Ht*(1-g),_e=Ht*(1-fe),zt=Mt*(1-g)*(1-g),At=Mt*(1-fe)*(1-fe),an=pe+Q*Oe,ln=oe+J*Oe,un=me+$*Oe,Gt=pe-Q*Oe,Yt=oe-J*Oe,Wt=me-$*Oe,kt=rt+Q*_e,Nt=ot+J*_e,Qt=ct+$*_e,fn=rt-Q*_e,dn=ot-J*_e,pn=ct-$*_e,Rt=Ye*zt,Pt=We*zt,Tt=ke*zt,Vt=Ye*At,Ct=We*At,Dt=ke*At,v=m*3,w=m*3;n[v]=an,n[v+1]=ln,n[v+2]=un,s[w]=Rt,s[w+1]=Pt,s[w+2]=Tt,n[v+3]=Gt,n[v+4]=Yt,n[v+5]=Wt,s[w+3]=Rt,s[w+4]=Pt,s[w+5]=Tt,n[v+6]=kt,n[v+7]=Nt,n[v+8]=Qt,s[w+6]=Vt,s[w+7]=Ct,s[w+8]=Dt,n[v+9]=Gt,n[v+10]=Yt,n[v+11]=Wt,s[w+9]=Rt,s[w+10]=Pt,s[w+11]=Tt,n[v+12]=fn,n[v+13]=dn,n[v+14]=pn,s[w+12]=Vt,s[w+13]=Ct,s[w+14]=Dt,n[v+15]=kt,n[v+16]=Nt,n[v+17]=Qt,s[w+15]=Vt,s[w+16]=Ct,s[w+17]=Dt,m+=6}}}}const q=U.current;if(m<q){const ie=m*3,I=q*3;for(let b=ie;b<I;b++)n[b]=0,s[b]=0}U.current=m,Y.setDrawRange(0,m),ee.needsUpdate=!0,d.needsUpdate=!0}}),_?$e.jsxs($e.Fragment,{children:[$e.jsx("instancedMesh",{ref:c=>{Re.current=c,c&&(c.count=0)},args:[qe,je,Ke],frustumCulled:!1,renderOrder:100,visible:l}),Te&&$e.jsx("mesh",{ref:ye,geometry:Y,material:E,frustumCulled:!1,renderOrder:99,visible:l})]}):null}const xn=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Le=require("react/jsx-runtime"),o=require("react"),Qe=require("@react-three/fiber"),Qt=require("three"),ht=require("hz-particles");function Jt(t){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const u in t)if(u!=="default"){const T=Object.getOwnPropertyDescriptor(t,u);Object.defineProperty(l,u,T.get?T:{enumerable:!0,get:()=>t[u]})}}return l.default=t,Object.freeze(l)}const c=Jt(Qt);function bt(t){return Math.abs(Math.sin(t*12.9898)*43758.5453)%1}function $t(t){const l=Math.sin(t*54321.67)*43758.5453%1;return l<0?l+1:l}function yt(t,l,u,T){if(u<=0)return 0;const h=l/u;let X=t.particleSize??.5;if(t.randomSize){const U=t.minSize??.1,Z=t.maxSize??.5;X=U+(Z-U)*$t(u)}const k=Math.max(.01,Math.min(10,t.sizeLifetimeSpeed??1));if(t.fadeSizeEnabled&&(X*=1-Math.pow(h,1/k)),t.increaseSizeEnabled&&(X*=1+Math.pow(h,1/k)),t.pulseEnabled){const U=t.pulseAmplitude??.5,Z=t.pulseFrequency??1,se=(t.pulsePhaseRandom??0)*bt(T)*Math.PI*2;X*=1+U*Math.sin(l*Z*Math.PI*2+se)}return Math.max(0,X)}function Mt(t,l,u,T){if(u<=0)return 0;let h=t.opacity??1;const X=l/u;if(t.fadeEnabled&&(h*=Math.max(0,1-X)),t.pulseEnabled&&t.pulseOpacity){const k=t.pulseAmplitude??.5,U=t.pulseFrequency??1,N=(t.pulsePhaseRandom??0)*bt(T)*Math.PI*2;h*=Math.max(0,1+k*Math.sin(l*U*Math.PI*2+N))}return Math.max(0,Math.min(1,h))}function Bt(t,l){return l===1?t:{...t,systems:t.systems.map(u=>({...u,particleSize:(u.particleSize??.5)*l,minSize:u.minSize!=null?u.minSize*l:void 0,maxSize:u.maxSize!=null?u.maxSize*l:void 0,particleSpeed:(u.particleSpeed??1)*l,minSpeed:u.minSpeed!=null?u.minSpeed*l:void 0,maxSpeed:u.maxSpeed!=null?u.maxSpeed*l:void 0,emissionTrailWidth:u.emissionTrailWidth!=null?u.emissionTrailWidth*l:void 0}))}}function Kt(t){let l=0;for(const u of t.systems)l+=u.maxParticles??1e4;return l}function en({preset:t,position:l,positionRef:u,autoPlay:T=!0,visible:h=!0,scale:X=1,resetKey:k=0,onComplete:U}){var We;const[Z,N]=o.useState(typeof t=="string"?null:t);o.useEffect(()=>{typeof t=="string"?(N(null),ht.fetchPreset(t).then(N).catch(i=>{console.error("[HZParticlesFX] Failed to fetch preset:",i)})):N(t)},[t]);const{camera:se,gl:Je}=Qe.useThree(),ae=o.useRef(null);if(!ae.current){const i=(We=Je.backend)==null?void 0:We.device;i&&(ae.current=i)}const Ce=ae.current,De=o.useRef(null),Me=o.useRef(null),Ve=o.useRef(!1),D=o.useRef(!1),p=o.useMemo(()=>Z?Bt(Z,X):null,[Z,X]),He=o.useMemo(()=>(p==null?void 0:p.systems.every(i=>i.emissionTrailEnabled))??!1,[p]),$e=o.useMemo(()=>p?p.systems.every(i=>i.emissionTrailEnabled)?1:Kt(p):0,[p]),ke=o.useMemo(()=>l?l instanceof c.Vector3?l.clone():new c.Vector3(...l):new c.Vector3(0,0,0),[l]),be=o.useMemo(()=>(p==null?void 0:p.systems.some(i=>i.emissionTrailEnabled))??!1,[p]),_e=o.useMemo(()=>new c.PlaneGeometry(1,1),[]),s=o.useMemo(()=>{const i=document.createElement("canvas");i.width=64,i.height=64;const C=i.getContext("2d");C.clearRect(0,0,64,64);const E=C.createRadialGradient(32,32,0,32,32,32);E.addColorStop(0,"rgba(255,255,255,1)"),E.addColorStop(.7,"rgba(255,255,255,1)"),E.addColorStop(1,"rgba(255,255,255,0)"),C.fillStyle=E,C.beginPath(),C.arc(32,32,32,0,Math.PI*2),C.fill();const M=new c.CanvasTexture(i);M.flipY=!1;const H=new c.MeshBasicMaterial({color:16777215,transparent:!0,depthWrite:!1,alphaTest:.01,map:M,vertexColors:!0,side:c.DoubleSide,blending:c.AdditiveBlending});return H.needsUpdate=!0,H},[]),m=64,xe=100,B=o.useRef(null),O=o.useRef(0),f=512,Q=o.useRef({buf:new Float32Array(f*4),head:0,count:0,elapsed:0}),{trailGeo:J,trailPosAttr:y,trailColAttr:V}=o.useMemo(()=>{const i=xe*m*6,C=new Float32Array(i*3),E=new Float32Array(i*3),M=new c.BufferGeometry,H=new c.BufferAttribute(C,3);H.setUsage(c.DynamicDrawUsage),M.setAttribute("position",H);const le=new c.BufferAttribute(E,3);return le.setUsage(c.DynamicDrawUsage),M.setAttribute("color",le),M.setDrawRange(0,0),{trailGeo:M,trailPosAttr:H,trailColAttr:le}},[]),Ee=o.useMemo(()=>new c.MeshBasicMaterial({vertexColors:!0,transparent:!0,depthWrite:!1,side:c.DoubleSide,blending:c.AdditiveBlending}),[]);o.useEffect(()=>{if(!Ce||!p)return;const i=new ht.ParticleSystemManager(Ce);return Me.current=i,D.current=!1,i.replaceSystems(p).then(()=>{T&&h&&(i.respawnAllSystems(),D.current=!0)}).catch(C=>{console.error("[HZParticlesFX] replaceSystems FAILED:",C)}),()=>{typeof i.destroy=="function"&&i.destroy(),Me.current=null}},[Ce,p]),o.useEffect(()=>{const i=Me.current;i&&T&&h&&!D.current&&(i.respawnAllSystems(),D.current=!0,Ve.current=!1)},[T,h]);const ve=o.useRef(k);o.useEffect(()=>{if(k===ve.current)return;ve.current=k;const i=Q.current;i.head=0,i.count=0,i.elapsed=0,J.setDrawRange(0,0),ge.current=null;const C=Me.current;C&&(C.respawnAllSystems(),D.current=!0,Ve.current=!1)},[k]);const Se=o.useMemo(()=>new c.Matrix4,[]),qe=o.useMemo(()=>new c.Vector3,[]),re=o.useMemo(()=>new c.Vector3,[]),oe=o.useMemo(()=>new c.Quaternion,[]),Y=o.useMemo(()=>new c.Vector3,[]),je=o.useMemo(()=>new c.Vector3(0,0,1),[]),P=o.useMemo(()=>new c.Color,[]),ge=o.useRef(null);return Qe.useFrame((i,C)=>{if(!h||!De.current||!Me.current)return;const E=Me.current,M=(u==null?void 0:u.current)??ke,H=C>1?C/1e3:C,le=ge.current,Ke=le&&H>0,Ot=Ke?(M.x-le.x)/H:0,Ht=Ke?(M.y-le.y)/H:0,_t=Ke?(M.z-le.z)/H:0;ge.current={x:M.x,y:M.y,z:M.z};for(const{system:n,config:r}of E.particleSystems)r.emissionTrailEnabled?(n.setSimulationTransform({position:[M.x,M.y,M.z],velocity:[Ot,Ht,_t]}),r.shapeTranslationX=0,r.shapeTranslationY=0,r.shapeTranslationZ=0):(r.shapeTranslationX=M.x,r.shapeTranslationY=M.y,r.shapeTranslationZ=M.z);E.updateAllSystems(H);for(const{system:n}of E.particleSystems)n.readbackAndProcessParticles();if(be){const n=Q.current;n.elapsed+=H;const r=n.head*4;n.buf[r]=M.x,n.buf[r+1]=M.y,n.buf[r+2]=M.z,n.buf[r+3]=n.elapsed,n.head=(n.head+1)%f,n.count<f&&n.count++}const we=De.current;let ze=0;for(let n=0;n<E.particleSystems.length;n++){const{system:r,config:x}=E.particleSystems[n];if(x.emissionTrailEnabled)continue;const G=r.particleData,ue=r.activeParticles;if(!G||ue<=0)continue;const _=r._simPosition,z=x.emissionTrailEnabled&&_?_[0]:0,fe=x.emissionTrailEnabled&&_?_[1]:0,Ye=x.emissionTrailEnabled&&_?_[2]:0;for(let de=0;de<ue;de++){const $=de*8,pe=G[$+0]+z,et=G[$+1]+fe,tt=G[$+2]+Ye;let Ae=G[$+3],L=G[$+4],Re=G[$+5];const Ie=G[$+6],Te=G[$+7];if(Ie>=Te||Te<=0)continue;const me=Ie/Te;if(x.colorTransitionEnabled){const I=x.startColor??[1,0,0],K=x.endColor??[0,0,1];Ae=I[0]+(K[0]-I[0])*me,L=I[1]+(K[1]-I[1])*me,Re=I[2]+(K[2]-I[2])*me}const S=x.bloomIntensity??1;Ae=Math.min(1,Ae*S),L=Math.min(1,L*S),Re=Math.min(1,Re*S);const he=Mt(x,Ie,Te,de);Ae*=he,L*=he,Re*=he;const q=yt(x,Ie,Te,de);if(!(q<=0)){if(qe.set(pe,et,tt),re.subVectors(se.position,qe).normalize(),oe.setFromUnitVectors(je,re),x.velocityStretchEnabled&&r.particleVelocities){const I=de*4,K=r.particleVelocities[I],Fe=r.particleVelocities[I+1],Ue=r.particleVelocities[I+2],ee=Math.sqrt(K*K+Fe*Fe+Ue*Ue);if(ee>.001){const Pe=x.velocityStretchFactor??1,Ne=q*(1+ee*Pe);Y.set(q,Ne,1),re.set(K,Fe,Ue).normalize(),oe.setFromUnitVectors(je,re);const ye=(Ne-q)*.5;qe.addScaledVector(re,ye)}else Y.set(q,q,1)}else Y.set(q,q,1);Se.compose(qe,oe,Y),we.setMatrixAt(ze,Se),P.setRGB(Ae,L,Re),we.setColorAt(ze,P),ze++}}}we.count=ze,we.visible=ze>0,ze>0&&(we.instanceMatrix.needsUpdate=!0,we.instanceColor&&(we.instanceColor.needsUpdate=!0));const xt=ze>0||E.particleSystems.some(({system:n})=>n.emitting||n.activeParticles>0);if(Ve.current&&!xt&&(D.current=!1,U==null||U()),Ve.current=xt,be&&B.current){const n=y.array,r=V.array;let x=0;for(let ue=0;ue<E.particleSystems.length;ue++){const{system:_,config:z}=E.particleSystems[ue];if(!z.emissionTrailEnabled||z.glbModelEnabled||z.textureEnabled)continue;const fe=_.particleData,Ye=_.activeParticles;if(!fe||Ye<=0)continue;const de=z.emissionTrailDuration??1,$=z.emissionTrailWidth??.3,pe=_._simPosition,et=pe?pe[0]:0,tt=pe?pe[1]:0,Ae=pe?pe[2]:0,L=_._simVelocity,Re=L?L[0]:0,Ie=L?L[1]:0,Te=L?L[2]:0,me=Q.current,S=me.buf,he=me.count,q=me.head,I=me.elapsed,K=he>=2;let Fe=I;if(K){const ee=((q-he)%f+f)%f;Fe=I-S[ee*4+3]}const Ue=I;for(let ee=0;ee<Ye&&!(x+m*6>xe*m*6);ee++){const Pe=ee*8,Ne=fe[Pe+6],ye=fe[Pe+7];if(Ne>=ye||ye<=0)continue;const nt=Math.min(Ue,ye),st=nt/ye;let Xe=fe[Pe+3],Ze=fe[Pe+4],Ge=fe[Pe+5];if(z.colorTransitionEnabled){const e=z.startColor??[1,0,0],d=z.endColor??[0,0,1];Xe=e[0]+(d[0]-e[0])*st,Ze=e[1]+(d[1]-e[1])*st,Ge=e[2]+(d[2]-e[2])*st}const rt=z.bloomIntensity??1;if(Xe=Math.min(1,Xe*rt),Ze=Math.min(1,Ze*rt),Ge=Math.min(1,Ge*rt),yt(z,nt,ye,ee)<=0)continue;const vt=$*.5,ot=Mt(z,nt,ye,ee);if(ot<.01)continue;const St=Math.min(de,Ue,Fe);if(St<.001)continue;const qt=(e,d)=>{if(!K){d[0]=et-Re*e,d[1]=tt-Ie*e,d[2]=Ae-Te*e;return}const g=I-e;for(let j=0;j<he-1;j++){const te=((q-1-j)%f+f)%f,W=((q-2-j)%f+f)%f,ie=S[te*4+3],v=S[W*4+3];if(g>=v&&g<=ie){const w=ie!==v?(g-v)/(ie-v):0;d[0]=S[W*4]+(S[te*4]-S[W*4])*w,d[1]=S[W*4+1]+(S[te*4+1]-S[W*4+1])*w,d[2]=S[W*4+2]+(S[te*4+2]-S[W*4+2])*w;return}}const b=((q-he)%f+f)%f;d[0]=S[b*4],d[1]=S[b*4+1],d[2]=S[b*4+2]},jt=se.position.x,Wt=se.position.y,Xt=se.position.z,a=new Array((m+1)*3);for(let e=0;e<=m;e++){const g=e/m*St,b=[0,0,0];qt(g,b),a[e*3]=b[0],a[e*3+1]=b[1],a[e*3+2]=b[2]}const gt=a[0]-a[m*3],wt=a[1]-a[m*3+1],zt=a[2]-a[m*3+2];if(gt*gt+wt*wt+zt*zt<1e-4)continue;const ce=new Array((m+1)*3);let At=0,Rt=0,Tt=0;for(let e=0;e<=m;e++){let d,g,b;e===0?(d=a[3]-a[0],g=a[4]-a[1],b=a[5]-a[2]):e===m?(d=a[e*3]-a[(e-1)*3],g=a[e*3+1]-a[(e-1)*3+1],b=a[e*3+2]-a[(e-1)*3+2]):(d=a[(e+1)*3]-a[(e-1)*3],g=a[(e+1)*3+1]-a[(e-1)*3+1],b=a[(e+1)*3+2]-a[(e-1)*3+2]);let j=Math.sqrt(d*d+g*g+b*b);j<1e-8&&(d=0,g=0,b=1,j=1),d/=j,g/=j,b/=j;const te=jt-a[e*3],W=Wt-a[e*3+1],ie=Xt-a[e*3+2];let v=g*ie-b*W,w=b*te-d*ie,F=d*W-g*te,ne=Math.sqrt(v*v+w*w+F*F);ne<1e-8&&(v=-b,w=0,F=d,ne=Math.sqrt(v*v+w*w+F*F)),ne<1e-8&&(v=0,w=1,F=0,ne=1),v/=ne,w/=ne,F/=ne,e>0&&v*At+w*Rt+F*Tt<0&&(v=-v,w=-w,F=-F),At=v,Rt=w,Tt=F,ce[e*3]=v,ce[e*3+1]=w,ce[e*3+2]=F}for(let e=0;e<m;e++){const d=e/m,g=(e+1)/m,b=a[e*3],j=a[e*3+1],te=a[e*3+2],W=a[(e+1)*3],ie=a[(e+1)*3+1],v=a[(e+1)*3+2],w=ce[e*3],F=ce[e*3+1],ne=ce[e*3+2],ct=ce[(e+1)*3],Pt=ce[(e+1)*3+1],Ct=ce[(e+1)*3+2],Be=vt*(1-d),Oe=vt*(1-g),it=ot*(1-d)*(1-d),at=ot*(1-g)*(1-g),Zt=b+w*Be,Gt=j+F*Be,Lt=te+ne*Be,Dt=b-w*Be,Vt=j-F*Be,Et=te-ne*Be,It=W+ct*Oe,Ft=ie+Pt*Oe,Ut=v+Ct*Oe,kt=W-ct*Oe,Yt=ie-Pt*Oe,Nt=v-Ct*Oe,lt=Xe*it,ut=Ze*it,ft=Ge*it,dt=Xe*at,pt=Ze*at,mt=Ge*at,A=x*3,R=x*3;n[A]=Zt,n[A+1]=Gt,n[A+2]=Lt,r[R]=lt,r[R+1]=ut,r[R+2]=ft,n[A+3]=Dt,n[A+4]=Vt,n[A+5]=Et,r[R+3]=lt,r[R+4]=ut,r[R+5]=ft,n[A+6]=It,n[A+7]=Ft,n[A+8]=Ut,r[R+6]=dt,r[R+7]=pt,r[R+8]=mt,n[A+9]=Dt,n[A+10]=Vt,n[A+11]=Et,r[R+9]=lt,r[R+10]=ut,r[R+11]=ft,n[A+12]=kt,n[A+13]=Yt,n[A+14]=Nt,r[R+12]=dt,r[R+13]=pt,r[R+14]=mt,n[A+15]=It,n[A+16]=Ft,n[A+17]=Ut,r[R+15]=dt,r[R+16]=pt,r[R+17]=mt,x+=6}}}const G=O.current;if(x<G){const ue=x*3,_=G*3;for(let z=ue;z<_;z++)n[z]=0,r[z]=0}O.current=x,J.setDrawRange(0,x),y.needsUpdate=!0,V.needsUpdate=!0}}),Z?Le.jsxs(Le.Fragment,{children:[Le.jsx("instancedMesh",{ref:i=>{De.current=i,i&&(i.count=0,i.visible=!He)},args:[_e,s,$e],frustumCulled:!1,renderOrder:100,visible:h&&!He}),be&&Le.jsx("mesh",{ref:B,geometry:J,material:Ee,frustumCulled:!1,renderOrder:99,visible:h})]}):null}const tn=`
2
2
  attribute vec4 aColor;
3
3
  varying vec4 vColor;
4
4
  void main() {
5
5
  vColor = aColor;
6
6
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
7
7
  }
8
- `,bn=`
8
+ `,nn=`
9
9
  varying vec4 vColor;
10
10
  void main() {
11
11
  gl_FragColor = vColor;
12
12
  }
13
- `;function gn({positionRef:t,duration:a=1,width:i=.3,color:z=[1,1,1],maxPoints:l=256,minDistance:O=.05,opacity:L=1,blending:F=o.AdditiveBlending,visible:_=!0}){const{camera:G}=at.useThree(),K=r.useRef(null),it=r.useRef({positions:new Float32Array(l*3),times:new Float32Array(l),head:0,count:0,lastPos:new o.Vector3(1/0,1/0,1/0),elapsed:0}),{geometry:ce,posAttr:Ae,colorAttr:Re,indexBuf:he}=r.useMemo(()=>{const qe=l*2,je=new Float32Array(qe*3),e=new Float32Array(qe*4),T=new o.BufferGeometry,ye=new o.BufferAttribute(je,3);ye.setUsage(o.DynamicDrawUsage),T.setAttribute("position",ye);const U=new o.BufferAttribute(e,4);U.setUsage(o.DynamicDrawUsage),T.setAttribute("aColor",U);const u=(l-1)*6,M=new Uint32Array(u);for(let ee=0;ee<l-1;ee++){const d=ee*2,E=ee*6;M[E]=d,M[E+1]=d+1,M[E+2]=d+2,M[E+3]=d+1,M[E+4]=d+3,M[E+5]=d+2}const Y=new o.BufferAttribute(M,1);return T.setIndex(Y),T.setDrawRange(0,0),{geometry:T,posAttr:ye,colorAttr:U,indexBuf:Y}},[l]),Pe=r.useMemo(()=>new o.ShaderMaterial({vertexShader:xn,fragmentShader:bn,transparent:!0,depthWrite:!1,side:o.DoubleSide,blending:F}),[F]),P=r.useMemo(()=>new o.Vector3,[]),f=r.useMemo(()=>new o.Vector3,[]),Ke=r.useMemo(()=>new o.Vector3,[]),lt=r.useMemo(()=>new o.Vector3(0,1,0),[]),Te=r.useMemo(()=>new o.Vector3,[]);return at.useFrame((qe,je)=>{if(!K.current)return;const e=it.current;if(e.elapsed+=je,!_){e.count=0,e.head=0,e.lastPos.set(1/0,1/0,1/0),ce.setDrawRange(0,0);return}const T=t.current;if(!T)return;if(e.lastPos.distanceTo(T)>=O){const d=(e.head+e.count)%l;e.positions[d*3]=T.x,e.positions[d*3+1]=T.y,e.positions[d*3+2]=T.z,e.times[d]=e.elapsed,e.count<l?e.count++:e.head=(e.head+1)%l,e.lastPos.copy(T)}for(;e.count>0;){const d=e.head;if(e.elapsed-e.times[d]>a)e.head=(e.head+1)%l,e.count--;else break}if(e.count<2){ce.setDrawRange(0,0);return}const U=Ae.array,u=Re.array;let M=null;const Y=e.count;for(let d=0;d<Y;d++){const E=(e.head+d)%l,Me=e.positions[E*3],Se=e.positions[E*3+1],te=e.positions[E*3+2],xe=1-(e.elapsed-e.times[E])/a;if(d<Y-1){const Ce=(e.head+d+1)%l;P.set(e.positions[Ce*3]-Me,e.positions[Ce*3+1]-Se,e.positions[Ce*3+2]-te);const c=P.length();c>1e-6?P.divideScalar(c):M&&P.copy(M)}else M&&P.copy(M);Ke.set(G.position.x-Me,G.position.y-Se,G.position.z-te),f.crossVectors(P,Ke);let W=f.length();W<1e-6&&(Te.crossVectors(P,lt),f.copy(Te),W=f.length(),W<1e-6&&(f.set(1,0,0),W=1)),f.divideScalar(W);const ne=i*xe,Xe=L*xe*xe,x=d*2;U[x*3]=Me+f.x*ne,U[x*3+1]=Se+f.y*ne,U[x*3+2]=te+f.z*ne,U[(x+1)*3]=Me-f.x*ne,U[(x+1)*3+1]=Se-f.y*ne,U[(x+1)*3+2]=te-f.z*ne,u[x*4]=z[0],u[x*4+1]=z[1],u[x*4+2]=z[2],u[x*4+3]=Xe,u[(x+1)*4]=z[0],u[(x+1)*4+1]=z[1],u[(x+1)*4+2]=z[2],u[(x+1)*4+3]=Xe,M=M||new o.Vector3,M.copy(P)}const ee=(Y-1)*6;ce.setDrawRange(0,ee),Ae.needsUpdate=!0,Re.needsUpdate=!0}),$e.jsx("mesh",{ref:K,geometry:ce,material:Pe,frustumCulled:!1,renderOrder:101,visible:_})}Object.defineProperty(exports,"fetchPreset",{enumerable:!0,get:()=>Et.fetchPreset});exports.HZParticlesFX=Sn;exports.HZTrailRibbon=gn;exports.computeParticleOpacity=Ft;exports.computeParticleSize=It;exports.particleHash=Ut;exports.scalePreset=Jt;
13
+ `;function sn({positionRef:t,duration:l=1,width:u=.3,color:T=[1,1,1],maxPoints:h=256,minDistance:X=.05,opacity:k=1,blending:U=c.AdditiveBlending,visible:Z=!0}){const{camera:N}=Qe.useThree(),se=o.useRef(null),Je=o.useRef({positions:new Float32Array(h*3),times:new Float32Array(h),head:0,count:0,lastPos:new c.Vector3(1/0,1/0,1/0),elapsed:0}),{geometry:ae,posAttr:Ce,colorAttr:De,indexBuf:Me}=o.useMemo(()=>{const be=h*2,_e=new Float32Array(be*3),s=new Float32Array(be*4),m=new c.BufferGeometry,xe=new c.BufferAttribute(_e,3);xe.setUsage(c.DynamicDrawUsage),m.setAttribute("position",xe);const B=new c.BufferAttribute(s,4);B.setUsage(c.DynamicDrawUsage),m.setAttribute("aColor",B);const O=(h-1)*6,f=new Uint32Array(O);for(let J=0;J<h-1;J++){const y=J*2,V=J*6;f[V]=y,f[V+1]=y+1,f[V+2]=y+2,f[V+3]=y+1,f[V+4]=y+3,f[V+5]=y+2}const Q=new c.BufferAttribute(f,1);return m.setIndex(Q),m.setDrawRange(0,0),{geometry:m,posAttr:xe,colorAttr:B,indexBuf:Q}},[h]),Ve=o.useMemo(()=>new c.ShaderMaterial({vertexShader:tn,fragmentShader:nn,transparent:!0,depthWrite:!1,side:c.DoubleSide,blending:U}),[U]),D=o.useMemo(()=>new c.Vector3,[]),p=o.useMemo(()=>new c.Vector3,[]),He=o.useMemo(()=>new c.Vector3,[]),$e=o.useMemo(()=>new c.Vector3(0,1,0),[]),ke=o.useMemo(()=>new c.Vector3,[]);return Qe.useFrame((be,_e)=>{if(!se.current)return;const s=Je.current;if(s.elapsed+=_e,!Z){s.count=0,s.head=0,s.lastPos.set(1/0,1/0,1/0),ae.setDrawRange(0,0);return}const m=t.current;if(!m)return;if(s.lastPos.distanceTo(m)>=X){const y=(s.head+s.count)%h;s.positions[y*3]=m.x,s.positions[y*3+1]=m.y,s.positions[y*3+2]=m.z,s.times[y]=s.elapsed,s.count<h?s.count++:s.head=(s.head+1)%h,s.lastPos.copy(m)}for(;s.count>0;){const y=s.head;if(s.elapsed-s.times[y]>l)s.head=(s.head+1)%h,s.count--;else break}if(s.count<2){ae.setDrawRange(0,0);return}const B=Ce.array,O=De.array;let f=null;const Q=s.count;for(let y=0;y<Q;y++){const V=(s.head+y)%h,Ee=s.positions[V*3],ve=s.positions[V*3+1],Se=s.positions[V*3+2],re=1-(s.elapsed-s.times[V])/l;if(y<Q-1){const ge=(s.head+y+1)%h;D.set(s.positions[ge*3]-Ee,s.positions[ge*3+1]-ve,s.positions[ge*3+2]-Se);const We=D.length();We>1e-6?D.divideScalar(We):f&&D.copy(f)}else f&&D.copy(f);He.set(N.position.x-Ee,N.position.y-ve,N.position.z-Se),p.crossVectors(D,He);let oe=p.length();oe<1e-6&&(ke.crossVectors(D,$e),p.copy(ke),oe=p.length(),oe<1e-6&&(p.set(1,0,0),oe=1)),p.divideScalar(oe);const Y=u*re,je=k*re*re,P=y*2;B[P*3]=Ee+p.x*Y,B[P*3+1]=ve+p.y*Y,B[P*3+2]=Se+p.z*Y,B[(P+1)*3]=Ee-p.x*Y,B[(P+1)*3+1]=ve-p.y*Y,B[(P+1)*3+2]=Se-p.z*Y,O[P*4]=T[0],O[P*4+1]=T[1],O[P*4+2]=T[2],O[P*4+3]=je,O[(P+1)*4]=T[0],O[(P+1)*4+1]=T[1],O[(P+1)*4+2]=T[2],O[(P+1)*4+3]=je,f=f||new c.Vector3,f.copy(D)}const J=(Q-1)*6;ae.setDrawRange(0,J),Ce.needsUpdate=!0,De.needsUpdate=!0}),Le.jsx("mesh",{ref:se,geometry:ae,material:Ve,frustumCulled:!1,renderOrder:101,visible:Z})}Object.defineProperty(exports,"fetchPreset",{enumerable:!0,get:()=>ht.fetchPreset});exports.HZParticlesFX=en;exports.HZTrailRibbon=sn;exports.computeParticleOpacity=Mt;exports.computeParticleSize=yt;exports.particleHash=bt;exports.scalePreset=Bt;
@@ -1,316 +1,325 @@
1
- import { jsxs as hn, Fragment as yn, jsx as Ie } from "react/jsx-runtime";
2
- import { useState as xn, useEffect as ae, useRef as O, useMemo as f } from "react";
3
- import { useThree as Ne, useFrame as Je } from "@react-three/fiber";
4
- import * as s from "three";
5
- import { fetchPreset as Sn, ParticleSystemManager as vn } from "hz-particles";
6
- import { fetchPreset as Un } from "hz-particles";
7
- function $e(r) {
8
- return Math.abs(Math.sin(r * 12.9898) * 43758.5453) % 1;
1
+ import { jsxs as Je, Fragment as $e, jsx as he } from "react/jsx-runtime";
2
+ import { useState as Ke, useEffect as Nt, useRef as k, useMemo as x } from "react";
3
+ import { useThree as Ue, useFrame as Be } from "@react-three/fiber";
4
+ import * as r from "three";
5
+ import { fetchPreset as tn, ParticleSystemManager as en } from "hz-particles";
6
+ import { fetchPreset as xn } from "hz-particles";
7
+ function _e(o) {
8
+ return Math.abs(Math.sin(o * 12.9898) * 43758.5453) % 1;
9
9
  }
10
- function gn(r) {
11
- const c = Math.sin(r * 54321.67) * 43758.5453 % 1;
12
- return c < 0 ? c + 1 : c;
10
+ function nn(o) {
11
+ const l = Math.sin(o * 54321.67) * 43758.5453 % 1;
12
+ return l < 0 ? l + 1 : l;
13
13
  }
14
- function je(r, c, a, D) {
15
- if (a <= 0) return 0;
16
- const i = c / a;
17
- let _ = r.particleSize ?? 0.5;
18
- if (r.randomSize) {
19
- const F = r.minSize ?? 0.1, X = r.maxSize ?? 0.5;
20
- _ = F + (X - F) * gn(a);
14
+ function Ee(o, l, d, F) {
15
+ if (d <= 0) return 0;
16
+ const m = l / d;
17
+ let O = o.particleSize ?? 0.5;
18
+ if (o.randomSize) {
19
+ const U = o.minSize ?? 0.1, Z = o.maxSize ?? 0.5;
20
+ O = U + (Z - U) * nn(d);
21
21
  }
22
- const Y = Math.max(0.01, Math.min(10, r.sizeLifetimeSpeed ?? 1));
23
- if (r.fadeSizeEnabled && (_ *= 1 - Math.pow(i, 1 / Y)), r.increaseSizeEnabled && (_ *= 1 + Math.pow(i, 1 / Y)), r.pulseEnabled) {
24
- const F = r.pulseAmplitude ?? 0.5, X = r.pulseFrequency ?? 1, tt = (r.pulsePhaseRandom ?? 0) * $e(D) * Math.PI * 2;
25
- _ *= 1 + F * Math.sin(c * X * Math.PI * 2 + tt);
22
+ const j = Math.max(0.01, Math.min(10, o.sizeLifetimeSpeed ?? 1));
23
+ if (o.fadeSizeEnabled && (O *= 1 - Math.pow(m, 1 / j)), o.increaseSizeEnabled && (O *= 1 + Math.pow(m, 1 / j)), o.pulseEnabled) {
24
+ const U = o.pulseAmplitude ?? 0.5, Z = o.pulseFrequency ?? 1, rt = (o.pulsePhaseRandom ?? 0) * _e(F) * Math.PI * 2;
25
+ O *= 1 + U * Math.sin(l * Z * Math.PI * 2 + rt);
26
26
  }
27
- return Math.max(0, _);
27
+ return Math.max(0, O);
28
28
  }
29
- function Qe(r, c, a, D) {
30
- if (a <= 0) return 0;
31
- let i = r.opacity ?? 1;
32
- const _ = c / a;
33
- if (r.fadeEnabled && (i *= Math.max(0, 1 - _)), r.pulseEnabled && r.pulseOpacity) {
34
- const Y = r.pulseAmplitude ?? 0.5, F = r.pulseFrequency ?? 1, W = (r.pulsePhaseRandom ?? 0) * $e(D) * Math.PI * 2;
35
- i *= Math.max(0, 1 + Y * Math.sin(c * F * Math.PI * 2 + W));
29
+ function Fe(o, l, d, F) {
30
+ if (d <= 0) return 0;
31
+ let m = o.opacity ?? 1;
32
+ const O = l / d;
33
+ if (o.fadeEnabled && (m *= Math.max(0, 1 - O)), o.pulseEnabled && o.pulseOpacity) {
34
+ const j = o.pulseAmplitude ?? 0.5, U = o.pulseFrequency ?? 1, N = (o.pulsePhaseRandom ?? 0) * _e(F) * Math.PI * 2;
35
+ m *= Math.max(0, 1 + j * Math.sin(l * U * Math.PI * 2 + N));
36
36
  }
37
- return Math.max(0, Math.min(1, i));
37
+ return Math.max(0, Math.min(1, m));
38
38
  }
39
- function wn(r, c) {
40
- return c === 1 ? r : {
41
- ...r,
42
- systems: r.systems.map((a) => ({
43
- ...a,
44
- particleSize: (a.particleSize ?? 0.5) * c,
45
- minSize: a.minSize != null ? a.minSize * c : void 0,
46
- maxSize: a.maxSize != null ? a.maxSize * c : void 0,
47
- particleSpeed: (a.particleSpeed ?? 1) * c,
48
- minSpeed: a.minSpeed != null ? a.minSpeed * c : void 0,
49
- maxSpeed: a.maxSpeed != null ? a.maxSpeed * c : void 0
39
+ function sn(o, l) {
40
+ return l === 1 ? o : {
41
+ ...o,
42
+ systems: o.systems.map((d) => ({
43
+ ...d,
44
+ particleSize: (d.particleSize ?? 0.5) * l,
45
+ minSize: d.minSize != null ? d.minSize * l : void 0,
46
+ maxSize: d.maxSize != null ? d.maxSize * l : void 0,
47
+ particleSpeed: (d.particleSpeed ?? 1) * l,
48
+ minSpeed: d.minSpeed != null ? d.minSpeed * l : void 0,
49
+ maxSpeed: d.maxSpeed != null ? d.maxSpeed * l : void 0,
50
+ emissionTrailWidth: d.emissionTrailWidth != null ? d.emissionTrailWidth * l : void 0
50
51
  }))
51
52
  };
52
53
  }
53
- function An(r) {
54
- let c = 0;
55
- for (const a of r.systems)
56
- c += a.maxParticles ?? 1e4;
57
- return c;
54
+ function rn(o) {
55
+ let l = 0;
56
+ for (const d of o.systems)
57
+ l += d.maxParticles ?? 1e4;
58
+ return l;
58
59
  }
59
- function Dn({
60
- preset: r,
61
- position: c,
62
- positionRef: a,
63
- autoPlay: D = !0,
64
- visible: i = !0,
65
- scale: _ = 1,
66
- resetKey: Y = 0,
67
- onComplete: F
60
+ function pn({
61
+ preset: o,
62
+ position: l,
63
+ positionRef: d,
64
+ autoPlay: F = !0,
65
+ visible: m = !0,
66
+ scale: O = 1,
67
+ resetKey: j = 0,
68
+ onComplete: U
68
69
  }) {
69
- var Dt;
70
- const [X, W] = xn(
71
- typeof r == "string" ? null : r
70
+ var Ot;
71
+ const [Z, N] = Ke(
72
+ typeof o == "string" ? null : o
72
73
  );
73
- ae(() => {
74
- typeof r == "string" ? (W(null), Sn(r).then(W).catch((o) => {
75
- console.error("[HZParticlesFX] Failed to fetch preset:", o);
76
- })) : W(r);
77
- }, [r]);
78
- const { camera: tt, gl: ie } = Ne(), at = O(null);
79
- if (!at.current) {
80
- const o = (Dt = ie.backend) == null ? void 0 : Dt.device;
81
- o && (at.current = o);
74
+ Nt(() => {
75
+ typeof o == "string" ? (N(null), tn(o).then(N).catch((i) => {
76
+ console.error("[HZParticlesFX] Failed to fetch preset:", i);
77
+ })) : N(o);
78
+ }, [o]);
79
+ const { camera: rt, gl: Jt } = Ue(), lt = k(null);
80
+ if (!lt.current) {
81
+ const i = (Ot = Jt.backend) == null ? void 0 : Ot.device;
82
+ i && (lt.current = i);
82
83
  }
83
- const Vt = at.current, Rt = O(null), yt = O(null), Tt = O(!1), V = O(!1), u = f(
84
- () => X ? wn(X, _) : null,
85
- [X, _]
86
- ), Kt = f(
87
- () => u ? An(u) : 0,
88
- [u]
89
- ), le = f(() => c ? c instanceof s.Vector3 ? c.clone() : new s.Vector3(...c) : new s.Vector3(0, 0, 0), [c]), Ct = f(
90
- () => (u == null ? void 0 : u.systems.some((o) => o.emissionTrailEnabled)) ?? !1,
91
- [u]
92
- ), qt = f(() => new s.PlaneGeometry(1, 1), []), Lt = f(() => {
93
- const o = document.createElement("canvas");
94
- o.width = 64, o.height = 64;
95
- const z = o.getContext("2d");
96
- z.clearRect(0, 0, 64, 64);
97
- const T = z.createRadialGradient(32, 32, 0, 32, 32, 32);
98
- T.addColorStop(0, "rgba(255,255,255,1)"), T.addColorStop(0.7, "rgba(255,255,255,1)"), T.addColorStop(1, "rgba(255,255,255,0)"), z.fillStyle = T, z.beginPath(), z.arc(32, 32, 32, 0, Math.PI * 2), z.fill();
99
- const p = new s.CanvasTexture(o);
100
- p.flipY = !1;
101
- const B = new s.MeshBasicMaterial({
84
+ const Vt = lt.current, Dt = k(null), vt = k(null), It = k(!1), C = k(!1), f = x(
85
+ () => Z ? sn(Z, O) : null,
86
+ [Z, O]
87
+ ), Wt = x(
88
+ () => (f == null ? void 0 : f.systems.every((i) => i.emissionTrailEnabled)) ?? !1,
89
+ [f]
90
+ ), $t = x(
91
+ () => f ? f.systems.every((i) => i.emissionTrailEnabled) ? 1 : rn(f) : 0,
92
+ [f]
93
+ ), kt = x(() => l ? l instanceof r.Vector3 ? l.clone() : new r.Vector3(...l) : new r.Vector3(0, 0, 0), [l]), St = x(
94
+ () => (f == null ? void 0 : f.systems.some((i) => i.emissionTrailEnabled)) ?? !1,
95
+ [f]
96
+ ), Xt = x(() => new r.PlaneGeometry(1, 1), []), n = x(() => {
97
+ const i = document.createElement("canvas");
98
+ i.width = 64, i.height = 64;
99
+ const R = i.getContext("2d");
100
+ R.clearRect(0, 0, 64, 64);
101
+ const D = R.createRadialGradient(32, 32, 0, 32, 32, 32);
102
+ D.addColorStop(0, "rgba(255,255,255,1)"), D.addColorStop(0.7, "rgba(255,255,255,1)"), D.addColorStop(1, "rgba(255,255,255,0)"), R.fillStyle = D, R.beginPath(), R.arc(32, 32, 32, 0, Math.PI * 2), R.fill();
103
+ const y = new r.CanvasTexture(i);
104
+ y.flipY = !1;
105
+ const H = new r.MeshBasicMaterial({
102
106
  color: 16777215,
103
107
  transparent: !0,
104
108
  depthWrite: !1,
105
109
  alphaTest: 0.01,
106
- map: p,
110
+ map: y,
107
111
  vertexColors: !0,
108
- side: s.DoubleSide,
109
- blending: s.AdditiveBlending
112
+ side: r.DoubleSide,
113
+ blending: r.AdditiveBlending
110
114
  });
111
- return B.needsUpdate = !0, B;
112
- }, []), t = 64, R = 100, xt = O(null), U = O(0), l = 512, x = O({
113
- buf: new Float32Array(l * 4),
115
+ return H.needsUpdate = !0, H;
116
+ }, []), p = 64, gt = 100, B = k(null), _ = k(0), c = 512, J = k({
117
+ buf: new Float32Array(c * 4),
114
118
  // x, y, z, time
115
119
  head: 0,
116
120
  count: 0,
117
121
  elapsed: 0
118
- }), { trailGeo: k, trailPosAttr: et, trailColAttr: d } = f(() => {
119
- const o = R * t * 6, z = new Float32Array(o * 3), T = new Float32Array(o * 3), p = new s.BufferGeometry(), B = new s.BufferAttribute(z, 3);
120
- B.setUsage(s.DynamicDrawUsage), p.setAttribute("position", B);
121
- const it = new s.BufferAttribute(T, 3);
122
- return it.setUsage(s.DynamicDrawUsage), p.setAttribute("color", it), p.setDrawRange(0, 0), { trailGeo: p, trailPosAttr: B, trailColAttr: it };
123
- }, []), I = f(() => new s.MeshBasicMaterial({
122
+ }), { trailGeo: $, trailPosAttr: h, trailColAttr: V } = x(() => {
123
+ const i = gt * p * 6, R = new Float32Array(i * 3), D = new Float32Array(i * 3), y = new r.BufferGeometry(), H = new r.BufferAttribute(R, 3);
124
+ H.setUsage(r.DynamicDrawUsage), y.setAttribute("position", H);
125
+ const ut = new r.BufferAttribute(D, 3);
126
+ return ut.setUsage(r.DynamicDrawUsage), y.setAttribute("color", ut), y.setDrawRange(0, 0), { trailGeo: y, trailPosAttr: H, trailColAttr: ut };
127
+ }, []), Et = x(() => new r.MeshBasicMaterial({
124
128
  vertexColors: !0,
125
129
  transparent: !0,
126
130
  depthWrite: !1,
127
- side: s.DoubleSide,
128
- blending: s.AdditiveBlending
131
+ side: r.DoubleSide,
132
+ blending: r.AdditiveBlending
129
133
  }), []);
130
- ae(() => {
131
- if (!Vt || !u)
134
+ Nt(() => {
135
+ if (!Vt || !f)
132
136
  return;
133
- const o = new vn(Vt);
134
- return yt.current = o, V.current = !1, o.replaceSystems(u).then(() => {
135
- D && i && (o.respawnAllSystems(), V.current = !0);
136
- }).catch((z) => {
137
- console.error("[HZParticlesFX] replaceSystems FAILED:", z);
137
+ const i = new en(Vt);
138
+ return vt.current = i, C.current = !1, i.replaceSystems(f).then(() => {
139
+ F && m && (i.respawnAllSystems(), C.current = !0);
140
+ }).catch((R) => {
141
+ console.error("[HZParticlesFX] replaceSystems FAILED:", R);
138
142
  }), () => {
139
- typeof o.destroy == "function" && o.destroy(), yt.current = null;
143
+ typeof i.destroy == "function" && i.destroy(), vt.current = null;
140
144
  };
141
- }, [Vt, u]), ae(() => {
142
- const o = yt.current;
143
- o && D && i && !V.current && (o.respawnAllSystems(), V.current = !0, Tt.current = !1);
144
- }, [D, i]);
145
- const St = O(Y);
146
- ae(() => {
147
- if (Y === St.current) return;
148
- St.current = Y;
149
- const o = x.current;
150
- o.head = 0, o.count = 0, o.elapsed = 0, k.setDrawRange(0, 0), v.current = null;
151
- const z = yt.current;
152
- z && (z.respawnAllSystems(), V.current = !0, Tt.current = !1);
153
- }, [Y]);
154
- const vt = f(() => new s.Matrix4(), []), nt = f(() => new s.Vector3(), []), Pt = f(() => new s.Vector3(), []), gt = f(() => new s.Quaternion(), []), j = f(() => new s.Vector3(), []), st = f(() => new s.Vector3(0, 0, 1), []), Gt = f(() => new s.Color(), []), v = O(null);
155
- return Je((o, z) => {
156
- if (!i || !Rt.current || !yt.current) return;
157
- const T = yt.current, p = (a == null ? void 0 : a.current) ?? le, B = z > 1 ? z / 1e3 : z, it = v.current, ue = it && B > 0, Ke = ue ? (p.x - it.x) / B : 0, tn = ue ? (p.y - it.y) / B : 0, en = ue ? (p.z - it.z) / B : 0;
158
- v.current = { x: p.x, y: p.y, z: p.z };
159
- for (const { system: e, config: n } of T.particleSystems)
160
- n.emissionTrailEnabled ? (e.setSimulationTransform({
161
- position: [p.x, p.y, p.z],
162
- velocity: [Ke, tn, en]
163
- }), n.shapeTranslationX = 0, n.shapeTranslationY = 0, n.shapeTranslationZ = 0) : (n.shapeTranslationX = p.x, n.shapeTranslationY = p.y, n.shapeTranslationZ = p.z);
164
- T.updateAllSystems(B);
165
- for (const { system: e } of T.particleSystems)
145
+ }, [Vt, f]), Nt(() => {
146
+ const i = vt.current;
147
+ i && F && m && !C.current && (i.respawnAllSystems(), C.current = !0, It.current = !1);
148
+ }, [F, m]);
149
+ const wt = k(j);
150
+ Nt(() => {
151
+ if (j === wt.current) return;
152
+ wt.current = j;
153
+ const i = J.current;
154
+ i.head = 0, i.count = 0, i.elapsed = 0, $.setDrawRange(0, 0), At.current = null;
155
+ const R = vt.current;
156
+ R && (R.respawnAllSystems(), C.current = !0, It.current = !1);
157
+ }, [j]);
158
+ const bt = x(() => new r.Matrix4(), []), qt = x(() => new r.Vector3(), []), ot = x(() => new r.Vector3(), []), it = x(() => new r.Quaternion(), []), Q = x(() => new r.Vector3(), []), Gt = x(() => new r.Vector3(0, 0, 1), []), P = x(() => new r.Color(), []), At = k(null);
159
+ return Be((i, R) => {
160
+ if (!m || !Dt.current || !vt.current) return;
161
+ const D = vt.current, y = (d == null ? void 0 : d.current) ?? kt, H = R > 1 ? R / 1e3 : R, ut = At.current, Kt = ut && H > 0, He = Kt ? (y.x - ut.x) / H : 0, We = Kt ? (y.y - ut.y) / H : 0, Xe = Kt ? (y.z - ut.z) / H : 0;
162
+ At.current = { x: y.x, y: y.y, z: y.z };
163
+ for (const { system: e, config: s } of D.particleSystems)
164
+ s.emissionTrailEnabled ? (e.setSimulationTransform({
165
+ position: [y.x, y.y, y.z],
166
+ velocity: [He, We, Xe]
167
+ }), s.shapeTranslationX = 0, s.shapeTranslationY = 0, s.shapeTranslationZ = 0) : (s.shapeTranslationX = y.x, s.shapeTranslationY = y.y, s.shapeTranslationZ = y.z);
168
+ D.updateAllSystems(H);
169
+ for (const { system: e } of D.particleSystems)
166
170
  e.readbackAndProcessParticles();
167
- if (Ct) {
168
- const e = x.current;
169
- e.elapsed += B;
170
- const n = e.head * 4;
171
- e.buf[n] = p.x, e.buf[n + 1] = p.y, e.buf[n + 2] = p.z, e.buf[n + 3] = e.elapsed, e.head = (e.head + 1) % l, e.count < l && e.count++;
171
+ if (St) {
172
+ const e = J.current;
173
+ e.elapsed += H;
174
+ const s = e.head * 4;
175
+ e.buf[s] = y.x, e.buf[s + 1] = y.y, e.buf[s + 2] = y.z, e.buf[s + 3] = e.elapsed, e.head = (e.head + 1) % c, e.count < c && e.count++;
172
176
  }
173
- const It = Rt.current;
174
- let Ot = 0;
175
- for (let e = 0; e < T.particleSystems.length; e++) {
176
- const { system: n, config: m } = T.particleSystems[e];
177
- if (m.emissionTrailEnabled) continue;
178
- const Z = n.particleData, lt = n.activeParticles;
179
- if (!Z || lt <= 0) continue;
180
- const E = n._simPosition, g = m.emissionTrailEnabled && E ? E[0] : 0, h = m.emissionTrailEnabled && E ? E[1] : 0, Et = m.emissionTrailEnabled && E ? E[2] : 0;
181
- for (let rt = 0; rt < lt; rt++) {
182
- const Q = rt * 8, de = Z[Q + 0] + g, ut = Z[Q + 1] + h, pe = Z[Q + 2] + Et;
183
- let wt = Z[Q + 3], At = Z[Q + 4], q = Z[Q + 5];
184
- const Ft = Z[Q + 6], bt = Z[Q + 7];
185
- if (Ft >= bt || bt <= 0) continue;
186
- const Yt = Ft / bt;
187
- if (m.colorTransitionEnabled) {
188
- const C = m.startColor ?? [1, 0, 0], L = m.endColor ?? [0, 0, 1];
189
- wt = C[0] + (L[0] - C[0]) * Yt, At = C[1] + (L[1] - C[1]) * Yt, q = C[2] + (L[2] - C[2]) * Yt;
177
+ const zt = Dt.current;
178
+ let Mt = 0;
179
+ for (let e = 0; e < D.particleSystems.length; e++) {
180
+ const { system: s, config: S } = D.particleSystems[e];
181
+ if (S.emissionTrailEnabled) continue;
182
+ const L = s.particleData, dt = s.activeParticles;
183
+ if (!L || dt <= 0) continue;
184
+ const W = s._simPosition, z = S.emissionTrailEnabled && W ? W[0] : 0, ft = S.emissionTrailEnabled && W ? W[1] : 0, jt = S.emissionTrailEnabled && W ? W[2] : 0;
185
+ for (let pt = 0; pt < dt; pt++) {
186
+ const K = pt * 8, mt = L[K + 0] + z, te = L[K + 1] + ft, ee = L[K + 2] + jt;
187
+ let Tt = L[K + 3], Y = L[K + 4], Pt = L[K + 5];
188
+ const Ft = L[K + 6], Rt = L[K + 7];
189
+ if (Ft >= Rt || Rt <= 0) continue;
190
+ const ht = Ft / Rt;
191
+ if (S.colorTransitionEnabled) {
192
+ const I = S.startColor ?? [1, 0, 0], tt = S.endColor ?? [0, 0, 1];
193
+ Tt = I[0] + (tt[0] - I[0]) * ht, Y = I[1] + (tt[1] - I[1]) * ht, Pt = I[2] + (tt[2] - I[2]) * ht;
190
194
  }
191
- const dt = m.bloomIntensity ?? 1;
192
- wt = Math.min(1, wt * dt), At = Math.min(1, At * dt), q = Math.min(1, q * dt);
193
- const S = Qe(m, Ft, bt, rt);
194
- wt *= S, At *= S, q *= S;
195
- const H = je(m, Ft, bt, rt);
196
- if (!(H <= 0)) {
197
- if (nt.set(de, ut, pe), Pt.subVectors(tt.position, nt).normalize(), gt.setFromUnitVectors(st, Pt), m.velocityStretchEnabled && n.particleVelocities) {
198
- const C = rt * 4, L = n.particleVelocities[C], Ut = n.particleVelocities[C + 1], Bt = n.particleVelocities[C + 2], Wt = Math.sqrt(L * L + Ut * Ut + Bt * Bt);
199
- if (Wt > 1e-3) {
200
- const N = m.velocityStretchFactor ?? 1, y = H * (1 + Wt * N);
201
- j.set(H, y, 1), Pt.set(L, Ut, Bt).normalize(), gt.setFromUnitVectors(st, Pt);
202
- const fe = (y - H) * 0.5;
203
- nt.addScaledVector(Pt, fe);
195
+ const w = S.bloomIntensity ?? 1;
196
+ Tt = Math.min(1, Tt * w), Y = Math.min(1, Y * w), Pt = Math.min(1, Pt * w);
197
+ const yt = Fe(S, Ft, Rt, pt);
198
+ Tt *= yt, Y *= yt, Pt *= yt;
199
+ const X = Ee(S, Ft, Rt, pt);
200
+ if (!(X <= 0)) {
201
+ if (qt.set(mt, te, ee), ot.subVectors(rt.position, qt).normalize(), it.setFromUnitVectors(Gt, ot), S.velocityStretchEnabled && s.particleVelocities) {
202
+ const I = pt * 4, tt = s.particleVelocities[I], Ut = s.particleVelocities[I + 1], Bt = s.particleVelocities[I + 2], et = Math.sqrt(tt * tt + Ut * Ut + Bt * Bt);
203
+ if (et > 1e-3) {
204
+ const Ct = S.velocityStretchFactor ?? 1, Qt = X * (1 + et * Ct);
205
+ Q.set(X, Qt, 1), ot.set(tt, Ut, Bt).normalize(), it.setFromUnitVectors(Gt, ot);
206
+ const xt = (Qt - X) * 0.5;
207
+ qt.addScaledVector(ot, xt);
204
208
  } else
205
- j.set(H, H, 1);
209
+ Q.set(X, X, 1);
206
210
  } else
207
- j.set(H, H, 1);
208
- vt.compose(nt, gt, j), It.setMatrixAt(Ot, vt), Gt.setRGB(wt, At, q), It.setColorAt(Ot, Gt), Ot++;
211
+ Q.set(X, X, 1);
212
+ bt.compose(qt, it, Q), zt.setMatrixAt(Mt, bt), P.setRGB(Tt, Y, Pt), zt.setColorAt(Mt, P), Mt++;
209
213
  }
210
214
  }
211
215
  }
212
- It.count = Ot, It.instanceMatrix.needsUpdate = !0, It.instanceColor && (It.instanceColor.needsUpdate = !0);
213
- const Ee = Ot > 0 || T.particleSystems.some(({ system: e }) => e.emitting || e.activeParticles > 0);
214
- if (Tt.current && !Ee && (V.current = !1, F == null || F()), Tt.current = Ee, Ct && xt.current) {
215
- const e = et.array, n = d.array;
216
- let m = 0;
217
- for (let lt = 0; lt < T.particleSystems.length; lt++) {
218
- const { system: E, config: g } = T.particleSystems[lt];
219
- if (!g.emissionTrailEnabled || g.glbModelEnabled || g.textureEnabled) continue;
220
- const h = E.particleData, Et = E.particleVelocities, rt = E.activeParticles;
221
- if (!h || !Et || rt <= 0) continue;
222
- const Q = g.emissionTrailDuration ?? 1, de = g.emissionTrailWidth ?? 0.3, ut = E._simPosition, pe = ut ? ut[0] : 0, wt = ut ? ut[1] : 0, At = ut ? ut[2] : 0, q = E._simVelocity, Ft = q ? q[0] : 0, bt = q ? q[1] : 0, Yt = q ? q[2] : 0, dt = x.current, S = dt.buf, H = dt.count, C = dt.head, L = dt.elapsed, Ut = H >= 2;
223
- let Bt = L;
224
- if (Ut) {
225
- const N = ((C - H) % l + l) % l;
226
- Bt = L - S[N * 4 + 3];
216
+ zt.count = Mt, zt.visible = Mt > 0, Mt > 0 && (zt.instanceMatrix.needsUpdate = !0, zt.instanceColor && (zt.instanceColor.needsUpdate = !0));
217
+ const ye = Mt > 0 || D.particleSystems.some(({ system: e }) => e.emitting || e.activeParticles > 0);
218
+ if (It.current && !ye && (C.current = !1, U == null || U()), It.current = ye, St && B.current) {
219
+ const e = h.array, s = V.array;
220
+ let S = 0;
221
+ for (let dt = 0; dt < D.particleSystems.length; dt++) {
222
+ const { system: W, config: z } = D.particleSystems[dt];
223
+ if (!z.emissionTrailEnabled || z.glbModelEnabled || z.textureEnabled) continue;
224
+ const ft = W.particleData, jt = W.activeParticles;
225
+ if (!ft || jt <= 0) continue;
226
+ const pt = z.emissionTrailDuration ?? 1, K = z.emissionTrailWidth ?? 0.3, mt = W._simPosition, te = mt ? mt[0] : 0, ee = mt ? mt[1] : 0, Tt = mt ? mt[2] : 0, Y = W._simVelocity, Pt = Y ? Y[0] : 0, Ft = Y ? Y[1] : 0, Rt = Y ? Y[2] : 0, ht = J.current, w = ht.buf, yt = ht.count, X = ht.head, I = ht.elapsed, tt = yt >= 2;
227
+ let Ut = I;
228
+ if (tt) {
229
+ const et = ((X - yt) % c + c) % c;
230
+ Ut = I - w[et * 4 + 3];
227
231
  }
228
- const Wt = L;
229
- for (let N = 0; N < rt && !(m + t * 6 > R * t * 6); N++) {
230
- const y = N * 8, fe = h[y + 6], Ht = h[y + 7];
231
- if (fe >= Ht || Ht <= 0) continue;
232
- const me = Math.min(Wt, Ht), he = me / Ht;
233
- let kt = h[y + 3], jt = h[y + 4], Qt = h[y + 5];
234
- if (g.colorTransitionEnabled) {
235
- const M = g.startColor ?? [1, 0, 0], w = g.endColor ?? [0, 0, 1];
236
- kt = M[0] + (w[0] - M[0]) * he, jt = M[1] + (w[1] - M[1]) * he, Qt = M[2] + (w[2] - M[2]) * he;
232
+ const Bt = I;
233
+ for (let et = 0; et < jt && !(S + p * 6 > gt * p * 6); et++) {
234
+ const Ct = et * 8, Qt = ft[Ct + 6], xt = ft[Ct + 7];
235
+ if (Qt >= xt || xt <= 0) continue;
236
+ const ne = Math.min(Bt, xt), se = ne / xt;
237
+ let Zt = ft[Ct + 3], Lt = ft[Ct + 4], Yt = ft[Ct + 5];
238
+ if (z.colorTransitionEnabled) {
239
+ const t = z.startColor ?? [1, 0, 0], u = z.endColor ?? [0, 0, 1];
240
+ Zt = t[0] + (u[0] - t[0]) * se, Lt = t[1] + (u[1] - t[1]) * se, Yt = t[2] + (u[2] - t[2]) * se;
237
241
  }
238
- const ye = g.bloomIntensity ?? 1;
239
- if (kt = Math.min(1, kt * ye), jt = Math.min(1, jt * ye), Qt = Math.min(1, Qt * ye), je(g, me, Ht, N) <= 0) continue;
240
- const Fe = de * 0.5, xe = Qe(g, me, Ht, N);
241
- if (xe < 0.01) continue;
242
- const Se = N * 4, Nt = Et[Se], Jt = Et[Se + 1], $t = Et[Se + 2], zt = Math.sqrt(Nt * Nt + Jt * Jt + $t * $t) > 0.05, Mt = Math.min(Q, Wt, Bt);
243
- if (Mt < 1e-3) continue;
244
- const te = (M, w) => {
245
- if (!Ut) {
246
- w[0] = pe - Ft * M, w[1] = wt - bt * M, w[2] = At - Yt * M;
242
+ const re = z.bloomIntensity ?? 1;
243
+ if (Zt = Math.min(1, Zt * re), Lt = Math.min(1, Lt * re), Yt = Math.min(1, Yt * re), Ee(z, ne, xt, et) <= 0) continue;
244
+ const xe = K * 0.5, oe = Fe(z, ne, xt, et);
245
+ if (oe < 0.01) continue;
246
+ const ve = Math.min(pt, Bt, Ut);
247
+ if (ve < 1e-3) continue;
248
+ const qe = (t, u) => {
249
+ if (!tt) {
250
+ u[0] = te - Pt * t, u[1] = ee - Ft * t, u[2] = Tt - Rt * t;
247
251
  return;
248
252
  }
249
- const pt = L - M;
250
- for (let ot = 0; ot < H - 1; ot++) {
251
- const G = ((C - 1 - ot) % l + l) % l, P = ((C - 2 - ot) % l + l) % l, mt = S[G * 4 + 3], ct = S[P * 4 + 3];
252
- if (pt >= ct && pt <= mt) {
253
- const ht = mt !== ct ? (pt - ct) / (mt - ct) : 0;
254
- w[0] = S[P * 4] + (S[G * 4] - S[P * 4]) * ht, w[1] = S[P * 4 + 1] + (S[G * 4 + 1] - S[P * 4 + 1]) * ht, w[2] = S[P * 4 + 2] + (S[G * 4 + 2] - S[P * 4 + 2]) * ht;
253
+ const b = I - t;
254
+ for (let q = 0; q < yt - 1; q++) {
255
+ const nt = ((X - 1 - q) % c + c) % c, G = ((X - 2 - q) % c + c) % c, ct = w[nt * 4 + 3], g = w[G * 4 + 3];
256
+ if (b >= g && b <= ct) {
257
+ const A = ct !== g ? (b - g) / (ct - g) : 0;
258
+ u[0] = w[G * 4] + (w[nt * 4] - w[G * 4]) * A, u[1] = w[G * 4 + 1] + (w[nt * 4 + 1] - w[G * 4 + 1]) * A, u[2] = w[G * 4 + 2] + (w[nt * 4 + 2] - w[G * 4 + 2]) * A;
255
259
  return;
256
260
  }
257
261
  }
258
- const ft = ((C - H) % l + l) % l;
259
- w[0] = S[ft * 4], w[1] = S[ft * 4 + 1], w[2] = S[ft * 4 + 2];
260
- }, nn = tt.position.x, sn = tt.position.y, rn = tt.position.z, ee = [0, 0, 0], ne = [0, 0, 0];
261
- te(0, ee), te(Mt, ne);
262
- const Ue = (zt ? h[y] : 0) + ee[0], Be = (zt ? h[y + 1] : 0) + ee[1], He = (zt ? h[y + 2] : 0) + ee[2], on = (zt ? h[y] - Nt * Mt : 0) + ne[0], cn = (zt ? h[y + 1] - Jt * Mt : 0) + ne[1], an = (zt ? h[y + 2] - $t * Mt : 0) + ne[2], ve = on - Ue, ge = cn - Be, we = an - He, se = Math.sqrt(ve * ve + ge * ge + we * we);
263
- if (se < 1e-6) continue;
264
- const Ae = ve / se, _e = ge / se, be = we / se, Xe = nn - Ue, Ze = sn - Be, qe = rn - He;
265
- let J = _e * qe - be * Ze, $ = be * Xe - Ae * qe, K = Ae * Ze - _e * Xe, _t = Math.sqrt(J * J + $ * $ + K * K);
266
- if (_t < 1e-6 && (J = -be, $ = 0, K = Ae, _t = Math.sqrt(J * J + $ * $ + K * K)), !(_t < 1e-6)) {
267
- J /= _t, $ /= _t, K /= _t;
268
- for (let M = 0; M < t; M++) {
269
- const w = M / t, pt = (M + 1) / t, ft = w * Mt, ot = pt * Mt, G = [0, 0, 0], P = [0, 0, 0];
270
- te(ft, G), te(ot, P);
271
- let mt, ct, ht, re, oe, ce;
272
- zt ? (mt = h[y] - Nt * ft + G[0], ct = h[y + 1] - Jt * ft + G[1], ht = h[y + 2] - $t * ft + G[2], re = h[y] - Nt * ot + P[0], oe = h[y + 1] - Jt * ot + P[1], ce = h[y + 2] - $t * ot + P[2]) : (mt = G[0], ct = G[1], ht = G[2], re = P[0], oe = P[1], ce = P[2]);
273
- const Xt = Fe * (1 - w), Zt = Fe * (1 - pt), ze = xe * (1 - w) * (1 - w), Me = xe * (1 - pt) * (1 - pt), ln = mt + J * Xt, un = ct + $ * Xt, dn = ht + K * Xt, Le = mt - J * Xt, Ge = ct - $ * Xt, Oe = ht - K * Xt, Ye = re + J * Zt, We = oe + $ * Zt, ke = ce + K * Zt, pn = re - J * Zt, fn = oe - $ * Zt, mn = ce - K * Zt, Ve = kt * ze, Re = jt * ze, Te = Qt * ze, Ce = kt * Me, Pe = jt * Me, De = Qt * Me, A = m * 3, b = m * 3;
274
- e[A] = ln, e[A + 1] = un, e[A + 2] = dn, n[b] = Ve, n[b + 1] = Re, n[b + 2] = Te, e[A + 3] = Le, e[A + 4] = Ge, e[A + 5] = Oe, n[b + 3] = Ve, n[b + 4] = Re, n[b + 5] = Te, e[A + 6] = Ye, e[A + 7] = We, e[A + 8] = ke, n[b + 6] = Ce, n[b + 7] = Pe, n[b + 8] = De, e[A + 9] = Le, e[A + 10] = Ge, e[A + 11] = Oe, n[b + 9] = Ve, n[b + 10] = Re, n[b + 11] = Te, e[A + 12] = pn, e[A + 13] = fn, e[A + 14] = mn, n[b + 12] = Ce, n[b + 13] = Pe, n[b + 14] = De, e[A + 15] = Ye, e[A + 16] = We, e[A + 17] = ke, n[b + 15] = Ce, n[b + 16] = Pe, n[b + 17] = De, m += 6;
275
- }
262
+ const v = ((X - yt) % c + c) % c;
263
+ u[0] = w[v * 4], u[1] = w[v * 4 + 1], u[2] = w[v * 4 + 2];
264
+ }, Ge = rt.position.x, Oe = rt.position.y, Ze = rt.position.z, a = new Array((p + 1) * 3);
265
+ for (let t = 0; t <= p; t++) {
266
+ const b = t / p * ve, v = [0, 0, 0];
267
+ qe(b, v), a[t * 3] = v[0], a[t * 3 + 1] = v[1], a[t * 3 + 2] = v[2];
268
+ }
269
+ const Se = a[0] - a[p * 3], ge = a[1] - a[p * 3 + 1], we = a[2] - a[p * 3 + 2];
270
+ if (Se * Se + ge * ge + we * we < 1e-4) continue;
271
+ const at = new Array((p + 1) * 3);
272
+ let be = 0, Ae = 0, ze = 0;
273
+ for (let t = 0; t <= p; t++) {
274
+ let u, b, v;
275
+ t === 0 ? (u = a[3] - a[0], b = a[4] - a[1], v = a[5] - a[2]) : t === p ? (u = a[t * 3] - a[(t - 1) * 3], b = a[t * 3 + 1] - a[(t - 1) * 3 + 1], v = a[t * 3 + 2] - a[(t - 1) * 3 + 2]) : (u = a[(t + 1) * 3] - a[(t - 1) * 3], b = a[(t + 1) * 3 + 1] - a[(t - 1) * 3 + 1], v = a[(t + 1) * 3 + 2] - a[(t - 1) * 3 + 2]);
276
+ let q = Math.sqrt(u * u + b * b + v * v);
277
+ q < 1e-8 && (u = 0, b = 0, v = 1, q = 1), u /= q, b /= q, v /= q;
278
+ const nt = Ge - a[t * 3], G = Oe - a[t * 3 + 1], ct = Ze - a[t * 3 + 2];
279
+ let g = b * ct - v * G, A = v * nt - u * ct, E = u * G - b * nt, st = Math.sqrt(g * g + A * A + E * E);
280
+ st < 1e-8 && (g = -v, A = 0, E = u, st = Math.sqrt(g * g + A * A + E * E)), st < 1e-8 && (g = 0, A = 1, E = 0, st = 1), g /= st, A /= st, E /= st, t > 0 && g * be + A * Ae + E * ze < 0 && (g = -g, A = -A, E = -E), be = g, Ae = A, ze = E, at[t * 3] = g, at[t * 3 + 1] = A, at[t * 3 + 2] = E;
281
+ }
282
+ for (let t = 0; t < p; t++) {
283
+ const u = t / p, b = (t + 1) / p, v = a[t * 3], q = a[t * 3 + 1], nt = a[t * 3 + 2], G = a[(t + 1) * 3], ct = a[(t + 1) * 3 + 1], g = a[(t + 1) * 3 + 2], A = at[t * 3], E = at[t * 3 + 1], st = at[t * 3 + 2], ie = at[(t + 1) * 3], Me = at[(t + 1) * 3 + 1], Te = at[(t + 1) * 3 + 2], _t = xe * (1 - u), Ht = xe * (1 - b), ae = oe * (1 - u) * (1 - u), ce = oe * (1 - b) * (1 - b), Le = v + A * _t, Ye = q + E * _t, ke = nt + st * _t, Pe = v - A * _t, Re = q - E * _t, Ce = nt - st * _t, Ve = G + ie * Ht, De = ct + Me * Ht, Ie = g + Te * Ht, je = G - ie * Ht, Qe = ct - Me * Ht, Ne = g - Te * Ht, le = Zt * ae, ue = Lt * ae, de = Yt * ae, fe = Zt * ce, pe = Lt * ce, me = Yt * ce, M = S * 3, T = S * 3;
284
+ e[M] = Le, e[M + 1] = Ye, e[M + 2] = ke, s[T] = le, s[T + 1] = ue, s[T + 2] = de, e[M + 3] = Pe, e[M + 4] = Re, e[M + 5] = Ce, s[T + 3] = le, s[T + 4] = ue, s[T + 5] = de, e[M + 6] = Ve, e[M + 7] = De, e[M + 8] = Ie, s[T + 6] = fe, s[T + 7] = pe, s[T + 8] = me, e[M + 9] = Pe, e[M + 10] = Re, e[M + 11] = Ce, s[T + 9] = le, s[T + 10] = ue, s[T + 11] = de, e[M + 12] = je, e[M + 13] = Qe, e[M + 14] = Ne, s[T + 12] = fe, s[T + 13] = pe, s[T + 14] = me, e[M + 15] = Ve, e[M + 16] = De, e[M + 17] = Ie, s[T + 15] = fe, s[T + 16] = pe, s[T + 17] = me, S += 6;
276
285
  }
277
286
  }
278
287
  }
279
- const Z = U.current;
280
- if (m < Z) {
281
- const lt = m * 3, E = Z * 3;
282
- for (let g = lt; g < E; g++)
283
- e[g] = 0, n[g] = 0;
288
+ const L = _.current;
289
+ if (S < L) {
290
+ const dt = S * 3, W = L * 3;
291
+ for (let z = dt; z < W; z++)
292
+ e[z] = 0, s[z] = 0;
284
293
  }
285
- U.current = m, k.setDrawRange(0, m), et.needsUpdate = !0, d.needsUpdate = !0;
294
+ _.current = S, $.setDrawRange(0, S), h.needsUpdate = !0, V.needsUpdate = !0;
286
295
  }
287
- }), X ? /* @__PURE__ */ hn(yn, { children: [
288
- /* @__PURE__ */ Ie(
296
+ }), Z ? /* @__PURE__ */ Je($e, { children: [
297
+ /* @__PURE__ */ he(
289
298
  "instancedMesh",
290
299
  {
291
- ref: (o) => {
292
- Rt.current = o, o && (o.count = 0);
300
+ ref: (i) => {
301
+ Dt.current = i, i && (i.count = 0, i.visible = !Wt);
293
302
  },
294
- args: [qt, Lt, Kt],
303
+ args: [Xt, n, $t],
295
304
  frustumCulled: !1,
296
305
  renderOrder: 100,
297
- visible: i
306
+ visible: m && !Wt
298
307
  }
299
308
  ),
300
- Ct && /* @__PURE__ */ Ie(
309
+ St && /* @__PURE__ */ he(
301
310
  "mesh",
302
311
  {
303
- ref: xt,
304
- geometry: k,
305
- material: I,
312
+ ref: B,
313
+ geometry: $,
314
+ material: Et,
306
315
  frustumCulled: !1,
307
316
  renderOrder: 99,
308
- visible: i
317
+ visible: m
309
318
  }
310
319
  )
311
320
  ] }) : null;
312
321
  }
313
- const bn = (
322
+ const on = (
314
323
  /* glsl */
315
324
  `
316
325
  attribute vec4 aColor;
@@ -320,7 +329,7 @@ void main() {
320
329
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
321
330
  }
322
331
  `
323
- ), zn = (
332
+ ), an = (
324
333
  /* glsl */
325
334
  `
326
335
  varying vec4 vColor;
@@ -329,113 +338,113 @@ void main() {
329
338
  }
330
339
  `
331
340
  );
332
- function In({
333
- positionRef: r,
334
- duration: c = 1,
335
- width: a = 0.3,
336
- color: D = [1, 1, 1],
337
- maxPoints: i = 256,
338
- minDistance: _ = 0.05,
339
- opacity: Y = 1,
340
- blending: F = s.AdditiveBlending,
341
- visible: X = !0
341
+ function mn({
342
+ positionRef: o,
343
+ duration: l = 1,
344
+ width: d = 0.3,
345
+ color: F = [1, 1, 1],
346
+ maxPoints: m = 256,
347
+ minDistance: O = 0.05,
348
+ opacity: j = 1,
349
+ blending: U = r.AdditiveBlending,
350
+ visible: Z = !0
342
351
  }) {
343
- const { camera: W } = Ne(), tt = O(null), ie = O({
344
- positions: new Float32Array(i * 3),
345
- times: new Float32Array(i),
352
+ const { camera: N } = Ue(), rt = k(null), Jt = k({
353
+ positions: new Float32Array(m * 3),
354
+ times: new Float32Array(m),
346
355
  head: 0,
347
356
  count: 0,
348
- lastPos: new s.Vector3(1 / 0, 1 / 0, 1 / 0),
357
+ lastPos: new r.Vector3(1 / 0, 1 / 0, 1 / 0),
349
358
  elapsed: 0
350
- }), { geometry: at, posAttr: Vt, colorAttr: Rt, indexBuf: yt } = f(() => {
351
- const qt = i * 2, Lt = new Float32Array(qt * 3), t = new Float32Array(qt * 4), R = new s.BufferGeometry(), xt = new s.BufferAttribute(Lt, 3);
352
- xt.setUsage(s.DynamicDrawUsage), R.setAttribute("position", xt);
353
- const U = new s.BufferAttribute(t, 4);
354
- U.setUsage(s.DynamicDrawUsage), R.setAttribute("aColor", U);
355
- const l = (i - 1) * 6, x = new Uint32Array(l);
356
- for (let et = 0; et < i - 1; et++) {
357
- const d = et * 2, I = et * 6;
358
- x[I] = d, x[I + 1] = d + 1, x[I + 2] = d + 2, x[I + 3] = d + 1, x[I + 4] = d + 3, x[I + 5] = d + 2;
359
+ }), { geometry: lt, posAttr: Vt, colorAttr: Dt, indexBuf: vt } = x(() => {
360
+ const St = m * 2, Xt = new Float32Array(St * 3), n = new Float32Array(St * 4), p = new r.BufferGeometry(), gt = new r.BufferAttribute(Xt, 3);
361
+ gt.setUsage(r.DynamicDrawUsage), p.setAttribute("position", gt);
362
+ const B = new r.BufferAttribute(n, 4);
363
+ B.setUsage(r.DynamicDrawUsage), p.setAttribute("aColor", B);
364
+ const _ = (m - 1) * 6, c = new Uint32Array(_);
365
+ for (let $ = 0; $ < m - 1; $++) {
366
+ const h = $ * 2, V = $ * 6;
367
+ c[V] = h, c[V + 1] = h + 1, c[V + 2] = h + 2, c[V + 3] = h + 1, c[V + 4] = h + 3, c[V + 5] = h + 2;
359
368
  }
360
- const k = new s.BufferAttribute(x, 1);
361
- return R.setIndex(k), R.setDrawRange(0, 0), { geometry: R, posAttr: xt, colorAttr: U, indexBuf: k };
362
- }, [i]), Tt = f(() => new s.ShaderMaterial({
363
- vertexShader: bn,
364
- fragmentShader: zn,
369
+ const J = new r.BufferAttribute(c, 1);
370
+ return p.setIndex(J), p.setDrawRange(0, 0), { geometry: p, posAttr: gt, colorAttr: B, indexBuf: J };
371
+ }, [m]), It = x(() => new r.ShaderMaterial({
372
+ vertexShader: on,
373
+ fragmentShader: an,
365
374
  transparent: !0,
366
375
  depthWrite: !1,
367
- side: s.DoubleSide,
368
- blending: F
369
- }), [F]), V = f(() => new s.Vector3(), []), u = f(() => new s.Vector3(), []), Kt = f(() => new s.Vector3(), []), le = f(() => new s.Vector3(0, 1, 0), []), Ct = f(() => new s.Vector3(), []);
370
- return Je((qt, Lt) => {
371
- if (!tt.current) return;
372
- const t = ie.current;
373
- if (t.elapsed += Lt, !X) {
374
- t.count = 0, t.head = 0, t.lastPos.set(1 / 0, 1 / 0, 1 / 0), at.setDrawRange(0, 0);
376
+ side: r.DoubleSide,
377
+ blending: U
378
+ }), [U]), C = x(() => new r.Vector3(), []), f = x(() => new r.Vector3(), []), Wt = x(() => new r.Vector3(), []), $t = x(() => new r.Vector3(0, 1, 0), []), kt = x(() => new r.Vector3(), []);
379
+ return Be((St, Xt) => {
380
+ if (!rt.current) return;
381
+ const n = Jt.current;
382
+ if (n.elapsed += Xt, !Z) {
383
+ n.count = 0, n.head = 0, n.lastPos.set(1 / 0, 1 / 0, 1 / 0), lt.setDrawRange(0, 0);
375
384
  return;
376
385
  }
377
- const R = r.current;
378
- if (!R) return;
379
- if (t.lastPos.distanceTo(R) >= _) {
380
- const d = (t.head + t.count) % i;
381
- t.positions[d * 3] = R.x, t.positions[d * 3 + 1] = R.y, t.positions[d * 3 + 2] = R.z, t.times[d] = t.elapsed, t.count < i ? t.count++ : t.head = (t.head + 1) % i, t.lastPos.copy(R);
386
+ const p = o.current;
387
+ if (!p) return;
388
+ if (n.lastPos.distanceTo(p) >= O) {
389
+ const h = (n.head + n.count) % m;
390
+ n.positions[h * 3] = p.x, n.positions[h * 3 + 1] = p.y, n.positions[h * 3 + 2] = p.z, n.times[h] = n.elapsed, n.count < m ? n.count++ : n.head = (n.head + 1) % m, n.lastPos.copy(p);
382
391
  }
383
- for (; t.count > 0; ) {
384
- const d = t.head;
385
- if (t.elapsed - t.times[d] > c)
386
- t.head = (t.head + 1) % i, t.count--;
392
+ for (; n.count > 0; ) {
393
+ const h = n.head;
394
+ if (n.elapsed - n.times[h] > l)
395
+ n.head = (n.head + 1) % m, n.count--;
387
396
  else
388
397
  break;
389
398
  }
390
- if (t.count < 2) {
391
- at.setDrawRange(0, 0);
399
+ if (n.count < 2) {
400
+ lt.setDrawRange(0, 0);
392
401
  return;
393
402
  }
394
- const U = Vt.array, l = Rt.array;
395
- let x = null;
396
- const k = t.count;
397
- for (let d = 0; d < k; d++) {
398
- const I = (t.head + d) % i, St = t.positions[I * 3], vt = t.positions[I * 3 + 1], nt = t.positions[I * 3 + 2], gt = 1 - (t.elapsed - t.times[I]) / c;
399
- if (d < k - 1) {
400
- const Dt = (t.head + d + 1) % i;
401
- V.set(
402
- t.positions[Dt * 3] - St,
403
- t.positions[Dt * 3 + 1] - vt,
404
- t.positions[Dt * 3 + 2] - nt
403
+ const B = Vt.array, _ = Dt.array;
404
+ let c = null;
405
+ const J = n.count;
406
+ for (let h = 0; h < J; h++) {
407
+ const V = (n.head + h) % m, Et = n.positions[V * 3], wt = n.positions[V * 3 + 1], bt = n.positions[V * 3 + 2], ot = 1 - (n.elapsed - n.times[V]) / l;
408
+ if (h < J - 1) {
409
+ const At = (n.head + h + 1) % m;
410
+ C.set(
411
+ n.positions[At * 3] - Et,
412
+ n.positions[At * 3 + 1] - wt,
413
+ n.positions[At * 3 + 2] - bt
405
414
  );
406
- const o = V.length();
407
- o > 1e-6 ? V.divideScalar(o) : x && V.copy(x);
408
- } else x && V.copy(x);
409
- Kt.set(
410
- W.position.x - St,
411
- W.position.y - vt,
412
- W.position.z - nt
413
- ), u.crossVectors(V, Kt);
414
- let j = u.length();
415
- j < 1e-6 && (Ct.crossVectors(V, le), u.copy(Ct), j = u.length(), j < 1e-6 && (u.set(1, 0, 0), j = 1)), u.divideScalar(j);
416
- const st = a * gt, Gt = Y * gt * gt, v = d * 2;
417
- U[v * 3] = St + u.x * st, U[v * 3 + 1] = vt + u.y * st, U[v * 3 + 2] = nt + u.z * st, U[(v + 1) * 3] = St - u.x * st, U[(v + 1) * 3 + 1] = vt - u.y * st, U[(v + 1) * 3 + 2] = nt - u.z * st, l[v * 4] = D[0], l[v * 4 + 1] = D[1], l[v * 4 + 2] = D[2], l[v * 4 + 3] = Gt, l[(v + 1) * 4] = D[0], l[(v + 1) * 4 + 1] = D[1], l[(v + 1) * 4 + 2] = D[2], l[(v + 1) * 4 + 3] = Gt, x = x || new s.Vector3(), x.copy(V);
415
+ const Ot = C.length();
416
+ Ot > 1e-6 ? C.divideScalar(Ot) : c && C.copy(c);
417
+ } else c && C.copy(c);
418
+ Wt.set(
419
+ N.position.x - Et,
420
+ N.position.y - wt,
421
+ N.position.z - bt
422
+ ), f.crossVectors(C, Wt);
423
+ let it = f.length();
424
+ it < 1e-6 && (kt.crossVectors(C, $t), f.copy(kt), it = f.length(), it < 1e-6 && (f.set(1, 0, 0), it = 1)), f.divideScalar(it);
425
+ const Q = d * ot, Gt = j * ot * ot, P = h * 2;
426
+ B[P * 3] = Et + f.x * Q, B[P * 3 + 1] = wt + f.y * Q, B[P * 3 + 2] = bt + f.z * Q, B[(P + 1) * 3] = Et - f.x * Q, B[(P + 1) * 3 + 1] = wt - f.y * Q, B[(P + 1) * 3 + 2] = bt - f.z * Q, _[P * 4] = F[0], _[P * 4 + 1] = F[1], _[P * 4 + 2] = F[2], _[P * 4 + 3] = Gt, _[(P + 1) * 4] = F[0], _[(P + 1) * 4 + 1] = F[1], _[(P + 1) * 4 + 2] = F[2], _[(P + 1) * 4 + 3] = Gt, c = c || new r.Vector3(), c.copy(C);
418
427
  }
419
- const et = (k - 1) * 6;
420
- at.setDrawRange(0, et), Vt.needsUpdate = !0, Rt.needsUpdate = !0;
421
- }), /* @__PURE__ */ Ie(
428
+ const $ = (J - 1) * 6;
429
+ lt.setDrawRange(0, $), Vt.needsUpdate = !0, Dt.needsUpdate = !0;
430
+ }), /* @__PURE__ */ he(
422
431
  "mesh",
423
432
  {
424
- ref: tt,
425
- geometry: at,
426
- material: Tt,
433
+ ref: rt,
434
+ geometry: lt,
435
+ material: It,
427
436
  frustumCulled: !1,
428
437
  renderOrder: 101,
429
- visible: X
438
+ visible: Z
430
439
  }
431
440
  );
432
441
  }
433
442
  export {
434
- Dn as HZParticlesFX,
435
- In as HZTrailRibbon,
436
- Qe as computeParticleOpacity,
437
- je as computeParticleSize,
438
- Un as fetchPreset,
439
- $e as particleHash,
440
- wn as scalePreset
443
+ pn as HZParticlesFX,
444
+ mn as HZTrailRibbon,
445
+ Fe as computeParticleOpacity,
446
+ Ee as computeParticleSize,
447
+ xn as fetchPreset,
448
+ _e as particleHash,
449
+ sn as scalePreset
441
450
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hz-particles",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "High-performance WebGPU particle engine with compute shaders, GPU instancing, GLB model support, and skeletal animations",
5
5
  "type": "module",
6
6
  "main": "dist-lib/hz-particles.cjs",