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