hz-particles 1.0.10 → 1.0.11

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