hz-particles 1.0.11 → 1.0.12

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