hz-particles 1.0.14 → 1.0.15

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,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _e=require("react/jsx-runtime"),i=require("react"),ke=require("@react-three/fiber"),qt=require("three"),Qe=require("hz-particles");function Ut(s){const p=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const d in s)if(d!=="default"){const V=Object.getOwnPropertyDescriptor(s,d);Object.defineProperty(p,d,V.get?V:{enumerable:!0,get:()=>s[d]})}}return p.default=s,Object.freeze(p)}const c=Ut(qt);function Je(s){return Math.abs(Math.sin(s*12.9898)*43758.5453)%1}function Bt(s){const p=Math.sin(s*54321.67)*43758.5453%1;return p<0?p+1:p}function wt(s,p,d,V){if(d<=0)return 0;const S=p/d;let Y=s.particleSize??.5;if(s.randomSize){const Z=s.minSize??.1,N=s.maxSize??.5;Y=Z+(N-Z)*Bt(d)}const $=Math.max(.01,Math.min(10,s.sizeLifetimeSpeed??1));if(s.fadeSizeEnabled&&(Y*=1-Math.pow(S,1/$)),s.increaseSizeEnabled&&(Y*=1+Math.pow(S,1/$)),s.pulseEnabled){const Z=s.pulseAmplitude??.5,N=s.pulseFrequency??1,oe=(s.pulsePhaseRandom??0)*Je(V)*Math.PI*2;Y*=1+Z*Math.sin(p*N*Math.PI*2+oe)}return Math.max(0,Y)}function zt(s,p,d,V){if(d<=0)return 0;let S=s.opacity??1;const Y=p/d;if(s.fadeEnabled&&(S*=Math.max(0,1-Y)),s.pulseEnabled&&s.pulseOpacity){const $=s.pulseAmplitude??.5,Z=s.pulseFrequency??1,se=(s.pulsePhaseRandom??0)*Je(V)*Math.PI*2;S*=Math.max(0,1+$*Math.sin(p*Z*Math.PI*2+se))}return Math.max(0,Math.min(1,S))}function At(s,p){return p===1?s:{...s,systems:s.systems.map(d=>({...d,particleSize:(d.particleSize??.5)*p,minSize:d.minSize!=null?d.minSize*p:void 0,maxSize:d.maxSize!=null?d.maxSize*p:void 0,particleSpeed:(d.particleSpeed??1)*p,minSpeed:d.minSpeed!=null?d.minSpeed*p:void 0,maxSpeed:d.maxSpeed!=null?d.maxSpeed*p:void 0,emissionTrailWidth:(d.emissionTrailWidth??.3)*p,emissionTrailShapeAmplitude:d.emissionTrailShapeAmplitude!=null?d.emissionTrailShapeAmplitude*p:void 0}))}}function Ot(s){let p=0;for(const d of s.systems)p+=d.maxParticles??1e4;return p}function Ht({preset:s,position:p,positionRef:d,autoPlay:V=!0,visible:S=!0,scale:Y=1,resetKey:$=0,onComplete:Z}){var Fe;const[N,se]=i.useState(typeof s=="string"?null:s);i.useEffect(()=>{typeof s=="string"?(se(null),Qe.fetchPreset(s).then(se).catch(l=>{console.error("[HZParticlesFX] Failed to fetch preset:",l)})):se(s)},[s]);const{camera:oe,gl:Le}=ke.useThree(),pe=i.useRef(null);if(!pe.current){const l=(Fe=Le.backend)==null?void 0:Fe.device;l&&(pe.current=l)}const Ce=pe.current,De=i.useRef(null),he=i.useRef(null),Ve=i.useRef(!1),O=i.useRef(!1),y=i.useMemo(()=>N?At(N,Y):null,[N,Y]),qe=i.useMemo(()=>(y==null?void 0:y.systems.every(l=>l.emissionTrailEnabled))??!1,[y]),Ye=i.useMemo(()=>y?y.systems.every(l=>l.emissionTrailEnabled)?1:Ot(y):0,[y]),We=i.useMemo(()=>p?p instanceof c.Vector3?p.clone():new c.Vector3(...p):new c.Vector3(0,0,0),[p]),ye=i.useMemo(()=>(y==null?void 0:y.systems.some(l=>l.emissionTrailEnabled))??!1,[y]),Ue=i.useMemo(()=>new c.PlaneGeometry(1,1),[]),o=i.useMemo(()=>{const l=document.createElement("canvas");l.width=64,l.height=64;const C=l.getContext("2d");C.clearRect(0,0,64,64);const q=C.createRadialGradient(32,32,0,32,32,32);q.addColorStop(0,"rgba(255,255,255,1)"),q.addColorStop(.7,"rgba(255,255,255,1)"),q.addColorStop(1,"rgba(255,255,255,0)"),C.fillStyle=q,C.beginPath(),C.arc(32,32,32,0,Math.PI*2),C.fill();const z=new c.CanvasTexture(l);z.flipY=!1;const G=new c.MeshBasicMaterial({color:16777215,transparent:!0,depthWrite:!1,alphaTest:.01,map:z,vertexColors:!0,side:c.DoubleSide,blending:c.AdditiveBlending});return G.needsUpdate=!0,G},[]),H=64,Me=i.useRef(null),k=i.useRef(0),v=512,R=i.useRef({buf:new Float32Array(v*6),head:0,count:0,elapsed:0}),{trailGeo:ne,trailPosAttr:ie,trailColAttr:w}=i.useMemo(()=>{const C=8*H*6,q=new Float32Array(C*3),z=new Float32Array(C*3),G=new c.BufferGeometry,me=new c.BufferAttribute(q,3);me.setUsage(c.DynamicDrawUsage),G.setAttribute("position",me);const xe=new c.BufferAttribute(z,3);return xe.setUsage(c.DynamicDrawUsage),G.setAttribute("color",xe),G.setDrawRange(0,0),{trailGeo:G,trailPosAttr:me,trailColAttr:xe}},[]),W=i.useMemo(()=>new c.MeshBasicMaterial({color:16777215,vertexColors:!0,transparent:!0,depthWrite:!1,side:c.DoubleSide,blending:c.AdditiveBlending}),[]);i.useEffect(()=>{if(!Ce||!y)return;const l=new Qe.ParticleSystemManager(Ce);return he.current=l,O.current=!1,l.replaceSystems(y).then(()=>{V&&S&&(l.respawnAllSystems(),O.current=!0)}).catch(C=>{console.error("[HZParticlesFX] replaceSystems FAILED:",C)}),()=>{typeof l.destroy=="function"&&l.destroy(),he.current=null}},[Ce,y]),i.useEffect(()=>{const l=he.current;l&&V&&S&&!O.current&&(l.respawnAllSystems(),O.current=!0,Ve.current=!1)},[V,S]);const de=i.useRef(null),ge=i.useRef($);i.useEffect(()=>{if($===ge.current)return;ge.current=$;const l=R.current;l.head=0,l.count=0,l.elapsed=0,ne.setDrawRange(0,0),de.current=null;const C=he.current;C&&(C.respawnAllSystems(),O.current=!0,Ve.current=!1)},[$]);const Se=i.useMemo(()=>new c.Matrix4,[]),Be=i.useMemo(()=>new c.Vector3,[]),ae=i.useMemo(()=>new c.Vector3,[]),ce=i.useMemo(()=>new c.Quaternion,[]),K=i.useMemo(()=>new c.Vector3,[]),Oe=i.useMemo(()=>new c.Vector3(0,0,1),[]),F=i.useMemo(()=>new c.Color,[]);return ke.useFrame((l,C)=>{var Ke;if(!S||!De.current||!he.current)return;const q=he.current,z=(d==null?void 0:d.current)??We,G=C>1?C/1e3:C,me=de.current,xe=me&&G>0,Tt=xe?(z.x-me.x)/G:0,Rt=xe?(z.y-me.y)/G:0,Pt=xe?(z.z-me.z)/G:0;de.current={x:z.x,y:z.y,z:z.z};for(const{system:t,config:a}of q.particleSystems)a.emissionTrailEnabled?(t.setSimulationTransform({position:[z.x,z.y,z.z],velocity:[Tt,Rt,Pt]}),a.shapeTranslationX=0,a.shapeTranslationY=0,a.shapeTranslationZ=0):(a.shapeTranslationX=z.x,a.shapeTranslationY=z.y,a.shapeTranslationZ=z.z);q.updateAllSystems(G);for(const{system:t}of q.particleSystems)t.readbackAndProcessParticles();if(ye){const t=R.current;t.elapsed+=G;let a=0,P=0;const U=(Ke=q.particleSystems.find(({config:j})=>j.emissionTrailEnabled))==null?void 0:Ke.config;if(U){const j=U.emissionTrailShape??"straight";if(j!=="straight"){const B=U.emissionTrailShapeAmplitude??.1,le=U.emissionTrailShapeFrequency??4,te=2*Math.PI*le*t.elapsed;j==="zigzag"?a=B*Math.sign(Math.sin(te)):j==="sine"?a=B*Math.sin(te):j==="spiral"&&(a=B*Math.sin(te),P=B*Math.cos(te))}}const ee=t.head*6;t.buf[ee]=z.x,t.buf[ee+1]=z.y,t.buf[ee+2]=z.z,t.buf[ee+3]=t.elapsed,t.buf[ee+4]=a,t.buf[ee+5]=P,t.head=(t.head+1)%v,t.count<v&&t.count++}const be=De.current;let ve=0;for(let t=0;t<q.particleSystems.length;t++){const{system:a,config:P}=q.particleSystems[t];if(P.emissionTrailEnabled)continue;const U=a.particleData,ee=a.activeParticles;if(!(!U||ee<=0))for(let j=0;j<ee;j++){const B=j*8,le=U[B+0],te=U[B+1],D=U[B+2];let we=U[B+3],ze=U[B+4],Q=U[B+5];const Ae=U[B+6],re=U[B+7];if(Ae>=re||re<=0)continue;const g=Ae/re;if(P.colorTransitionEnabled){const I=P.startColor??[1,0,0],ue=P.endColor??[0,0,1];we=I[0]+(ue[0]-I[0])*g,ze=I[1]+(ue[1]-I[1])*g,Q=I[2]+(ue[2]-I[2])*g}const Te=P.bloomIntensity??1;we=Math.min(1,we*Te),ze=Math.min(1,ze*Te),Q=Math.min(1,Q*Te);const Re=zt(P,Ae,re,j);we*=Re,ze*=Re,Q*=Re;const J=wt(P,Ae,re,j);if(!(J<=0)){if(Be.set(le,te,D),ae.subVectors(oe.position,Be).normalize(),ce.setFromUnitVectors(Oe,ae),P.velocityStretchEnabled&&a.particleVelocities){const I=j*4,ue=a.particleVelocities[I],Ie=a.particleVelocities[I+1],E=a.particleVelocities[I+2],fe=Math.sqrt(ue*ue+Ie*Ie+E*E);if(fe>.001){const Ne=P.velocityStretchFactor??1,X=J*(1+fe*Ne);K.set(J,X,1),ae.set(ue,Ie,E).normalize(),ce.setFromUnitVectors(Oe,ae);const n=(X-J)*.5;Be.addScaledVector(ae,n)}else K.set(J,J,1)}else K.set(J,J,1);Se.compose(Be,ce,K),be.setMatrixAt(ve,Se),F.setRGB(we,ze,Q),be.setColorAt(ve,F),ve++}}}be.count=ve,be.visible=ve>0,ve>0&&(be.instanceMatrix.needsUpdate=!0,be.instanceColor&&(be.instanceColor.needsUpdate=!0));const $e=ve>0||q.particleSystems.some(({system:t})=>t.emitting||t.activeParticles>0);if(Ve.current&&!$e&&(O.current=!1,Z==null||Z()),Ve.current=$e,ye&&Me.current){const t=ie.array,a=w.array;let P=0;const U=oe.position.x,ee=oe.position.y,j=oe.position.z;for(let le=0;le<q.particleSystems.length;le++){const{system:te,config:D}=q.particleSystems[le];if(!D.emissionTrailEnabled||!te.emitting&&te.activeParticles<=0)continue;const we=D.emissionTrailDuration??1,ze=D.emissionTrailWidth??.3,Q=D.bloomIntensity??1,Ae=ze*.5,re=R.current,g=re.buf,Te=re.count,Re=re.head,J=re.elapsed;if(Te<2)continue;const I=((Re-Te)%v+v)%v,ue=J-g[I*6+3],Ie=Math.min(we,ue);if(Ie<.001)continue;const E=D.startColor??[1,1,1],fe=D.colorTransitionEnabled?D.endColor??[1,1,1]:E,Ne=(e,r)=>{const h=J-e;for(let u=0;u<Te-1;u++){const x=((Re-1-u)%v+v)%v,T=((Re-2-u)%v+v)%v,_=g[x*6+3],A=g[T*6+3];if(h>=A&&h<=_){const m=_!==A?(h-A)/(_-A):0;r[0]=g[T*6]+(g[x*6]-g[T*6])*m,r[1]=g[T*6+1]+(g[x*6+1]-g[T*6+1])*m,r[2]=g[T*6+2]+(g[x*6+2]-g[T*6+2])*m,r[3]=g[T*6+4]+(g[x*6+4]-g[T*6+4])*m,r[4]=g[T*6+5]+(g[x*6+5]-g[T*6+5])*m;return}}r[0]=g[I*6],r[1]=g[I*6+1],r[2]=g[I*6+2],r[3]=g[I*6+4],r[4]=g[I*6+5]},X=Math.max(1,Math.min(H,D.emissionTrailSegments??8)),n=[z.x,z.y,z.z],He=D.emissionTrailShape??"straight",Ge=[];{const e=D.emissionTrailShapeAmplitude??.1,r=D.emissionTrailShapeFrequency??4,h=2*Math.PI*r*J;let u=0,x=0;He==="zigzag"?u=e*Math.sign(Math.sin(h)):He==="sine"?u=e*Math.sin(h):He==="spiral"&&(u=e*Math.sin(h),x=e*Math.cos(h)),Ge.push(u,x)}const Ee=[0,0,0,0,0];for(let e=1;e<=X;e++){const r=e/X*Ie;Ne(r,Ee),n.push(Ee[0],Ee[1],Ee[2]),Ge.push(Ee[3],Ee[4])}const et=n[0]-n[X*3],tt=n[1]-n[X*3+1],st=n[2]-n[X*3+2];if(et*et+tt*tt+st*st<1e-6)continue;let nt=0,rt=0,ot=0;const Pe=[],Xe=[];for(let e=0;e<=X;e++){let r,h,u;e===0?(r=n[3]-n[0],h=n[4]-n[1],u=n[5]-n[2]):e===X?(r=n[e*3]-n[(e-1)*3],h=n[e*3+1]-n[(e-1)*3+1],u=n[e*3+2]-n[(e-1)*3+2]):(r=n[(e+1)*3]-n[(e-1)*3],h=n[(e+1)*3+1]-n[(e-1)*3+1],u=n[(e+1)*3+2]-n[(e-1)*3+2]);let x=Math.sqrt(r*r+h*h+u*u);x<1e-8&&(r=0,h=0,u=1,x=1),r/=x,h/=x,u/=x,Xe.push(r,h,u);const T=U-n[e*3],_=ee-n[e*3+1],A=j-n[e*3+2];let m=h*A-u*_,M=u*T-r*A,b=r*_-h*T,L=Math.sqrt(m*m+M*M+b*b);L<1e-8&&(m=-u,M=0,b=r,L=Math.sqrt(m*m+M*M+b*b)),L<1e-8&&(m=0,M=1,b=0,L=1),m/=L,M/=L,b/=L,e>0&&m*nt+M*rt+b*ot<0&&(m=-m,M=-M,b=-b),nt=m,rt=M,ot=b,Pe.push(m,M,b)}if(He!=="straight")for(let e=1;e<=X;e++){const r=Ge[e*2],h=Ge[e*2+1];if(Math.abs(r)<1e-8&&Math.abs(h)<1e-8)continue;const u=e*3,x=Xe[u],T=Xe[u+1],_=Xe[u+2];let A=-_,m=0,M=x,b=Math.sqrt(A*A+M*M);if(b<1e-6&&(A=0,m=_,M=-T,b=Math.sqrt(A*A+m*m+M*M),b<1e-6&&(A=1,m=0,M=0,b=1)),A/=b,m/=b,M/=b,He==="spiral"){const L=T*M-_*m,je=_*A-x*M,Ze=x*m-T*A;n[u]+=A*r+L*h,n[u+1]+=m*r+je*h,n[u+2]+=M*r+Ze*h}else n[u]+=A*r,n[u+1]+=m*r,n[u+2]+=M*r}for(let e=0;e<X;e++){const r=e/X,h=(e+1)/X,u=Ae*(1-r),x=Ae*(1-h),T=(1-r)*(1-r),_=(1-h)*(1-h),A=Math.min(1,(E[0]+(fe[0]-E[0])*r)*Q)*T,m=Math.min(1,(E[1]+(fe[1]-E[1])*r)*Q)*T,M=Math.min(1,(E[2]+(fe[2]-E[2])*r)*Q)*T,b=Math.min(1,(E[0]+(fe[0]-E[0])*h)*Q)*_,L=Math.min(1,(E[1]+(fe[1]-E[1])*h)*Q)*_,je=Math.min(1,(E[2]+(fe[2]-E[2])*h)*Q)*_,Ze=n[e*3],it=n[e*3+1],at=n[e*3+2],ct=n[(e+1)*3],lt=n[(e+1)*3+1],ut=n[(e+1)*3+2],ft=Pe[e*3],pt=Pe[e*3+1],dt=Pe[e*3+2],mt=Pe[(e+1)*3],ht=Pe[(e+1)*3+1],yt=Pe[(e+1)*3+2],Ct=Ze+ft*u,Dt=it+pt*u,Vt=at+dt*u,Mt=Ze-ft*u,gt=it-pt*u,St=at-dt*u,xt=ct+mt*x,bt=lt+ht*x,vt=ut+yt*x,Ft=ct-mt*x,It=lt-ht*x,Et=ut-yt*x,f=P*3;t[f]=Ct,t[f+1]=Dt,t[f+2]=Vt,a[f]=A,a[f+1]=m,a[f+2]=M,t[f+3]=Mt,t[f+4]=gt,t[f+5]=St,a[f+3]=A,a[f+4]=m,a[f+5]=M,t[f+6]=xt,t[f+7]=bt,t[f+8]=vt,a[f+6]=b,a[f+7]=L,a[f+8]=je,t[f+9]=Mt,t[f+10]=gt,t[f+11]=St,a[f+9]=A,a[f+10]=m,a[f+11]=M,t[f+12]=Ft,t[f+13]=It,t[f+14]=Et,a[f+12]=b,a[f+13]=L,a[f+14]=je,t[f+15]=xt,t[f+16]=bt,t[f+17]=vt,a[f+15]=b,a[f+16]=L,a[f+17]=je,P+=6}}const B=k.current;if(P<B){const le=P*3,te=B*3;for(let D=le;D<te;D++)t[D]=0,a[D]=0}k.current=P,ne.setDrawRange(0,P),ie.needsUpdate=!0,w.needsUpdate=!0}}),N?_e.jsxs(_e.Fragment,{children:[_e.jsx("instancedMesh",{ref:l=>{De.current=l,l&&(l.count=0,l.visible=!qe)},args:[Ue,o,Ye],frustumCulled:!1,renderOrder:100,visible:S&&!qe}),ye&&_e.jsx("mesh",{ref:Me,geometry:ne,material:W,frustumCulled:!1,renderOrder:99,visible:S})]}):null}const jt=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const je=require("react/jsx-runtime"),a=require("react"),Ze=require("@react-three/fiber"),Ut=require("three"),Je=require("hz-particles");function Ot(i){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const I in i)if(I!=="default"){const e=Object.getOwnPropertyDescriptor(i,I);Object.defineProperty(n,I,e.get?e:{enumerable:!0,get:()=>i[I]})}}return n.default=i,Object.freeze(n)}const l=Ot(Ut);function $e(i){return Math.abs(Math.sin(i*12.9898)*43758.5453)%1}function Bt(i){const n=Math.sin(i*54321.67)*43758.5453%1;return n<0?n+1:n}function wt(i,n,I,e){if(I<=0)return 0;const y=n/I;let N=i.particleSize??.5;if(i.randomSize){const G=i.minSize??.1,Y=i.maxSize??.5;N=G+(Y-G)*Bt(I)}const $=Math.max(.01,Math.min(10,i.sizeLifetimeSpeed??1));if(i.fadeSizeEnabled&&(N*=1-Math.pow(y,1/$)),i.increaseSizeEnabled&&(N*=1+Math.pow(y,1/$)),i.pulseEnabled){const G=i.pulseAmplitude??.5,Y=i.pulseFrequency??1,ae=(i.pulsePhaseRandom??0)*$e(e)*Math.PI*2;N*=1+G*Math.sin(n*Y*Math.PI*2+ae)}return Math.max(0,N)}function Rt(i,n,I,e){if(I<=0)return 0;let y=i.opacity??1;const N=n/I;if(i.fadeEnabled&&(y*=Math.max(0,1-N)),i.pulseEnabled&&i.pulseOpacity){const $=i.pulseAmplitude??.5,G=i.pulseFrequency??1,ne=(i.pulsePhaseRandom??0)*$e(e)*Math.PI*2;y*=Math.max(0,1+$*Math.sin(n*G*Math.PI*2+ne))}return Math.max(0,Math.min(1,y))}function Tt(i,n){if(n===1)return i;const I=(e,y)=>e!=null?e*n:y*n;return{...i,systems:i.systems.map(e=>({...e,particleSize:I(e.particleSize,.5),minSize:e.minSize!=null?e.minSize*n:void 0,maxSize:e.maxSize!=null?e.maxSize*n:void 0,particleSpeed:(e.particleSpeed??1)*n,minSpeed:e.minSpeed!=null?e.minSpeed*n:void 0,maxSpeed:e.maxSpeed!=null?e.maxSpeed*n:void 0,cubeLength:e.cubeLength!=null?e.cubeLength*n:void 0,outerLength:e.outerLength!=null?e.outerLength*n:void 0,innerLength:e.innerLength!=null?e.innerLength*n:void 0,outerRadius:e.outerRadius!=null?e.outerRadius*n:void 0,innerRadius:e.innerRadius!=null?e.innerRadius*n:void 0,squareSize:e.squareSize!=null?e.squareSize*n:void 0,squareInnerSize:e.squareInnerSize!=null?e.squareInnerSize*n:void 0,circleInnerRadius:e.circleInnerRadius!=null?e.circleInnerRadius*n:void 0,circleOuterRadius:e.circleOuterRadius!=null?e.circleOuterRadius*n:void 0,cylinderInnerRadius:e.cylinderInnerRadius!=null?e.cylinderInnerRadius*n:void 0,cylinderOuterRadius:e.cylinderOuterRadius!=null?e.cylinderOuterRadius*n:void 0,cylinderHeight:e.cylinderHeight!=null?e.cylinderHeight*n:void 0,emissionTrailWidth:(e.emissionTrailWidth??.3)*n,emissionTrailDuration:(e.emissionTrailDuration??1)*n,emissionTrailMinDistance:e.emissionTrailMinDistance!=null?e.emissionTrailMinDistance*n:void 0,emissionTrailShapeAmplitude:e.emissionTrailShapeAmplitude!=null?e.emissionTrailShapeAmplitude*n:void 0}))}}function Ht(i){let n=0;for(const I of i.systems)n+=I.maxParticles??1e4;return n}function Lt({preset:i,position:n,positionRef:I,autoPlay:e=!0,visible:y=!0,scale:N=1,resetKey:$=0,onComplete:G}){var Be;const[Y,ne]=a.useState(typeof i=="string"?null:i);a.useEffect(()=>{typeof i=="string"?(ne(null),Je.fetchPreset(i).then(ne).catch(d=>{console.error("[HZParticlesFX] Failed to fetch preset:",d)})):ne(i)},[i]);const{camera:ae,gl:ke}=Ze.useThree(),de=a.useRef(null);if(!de.current){const d=(Be=ke.backend)==null?void 0:Be.device;d&&(de.current=d)}const Ie=de.current,De=a.useRef(null),he=a.useRef(null),Ce=a.useRef(!1),B=a.useRef(!1),h=a.useMemo(()=>Y?Tt(Y,N):null,[Y,N]),Ue=a.useMemo(()=>(h==null?void 0:h.systems.every(d=>d.emissionTrailEnabled))??!1,[h]),Ne=a.useMemo(()=>h?h.systems.every(d=>d.emissionTrailEnabled)?1:Ht(h):0,[h]),_e=a.useMemo(()=>n?n instanceof l.Vector3?n.clone():new l.Vector3(...n):new l.Vector3(0,0,0),[n]),ge=a.useMemo(()=>(h==null?void 0:h.systems.some(d=>d.emissionTrailEnabled))??!1,[h]),Oe=a.useMemo(()=>new l.PlaneGeometry(1,1),[]),r=a.useMemo(()=>{const d=document.createElement("canvas");d.width=64,d.height=64;const A=d.getContext("2d");A.clearRect(0,0,64,64);const w=A.createRadialGradient(32,32,0,32,32,32);w.addColorStop(0,"rgba(255,255,255,1)"),w.addColorStop(.7,"rgba(255,255,255,1)"),w.addColorStop(1,"rgba(255,255,255,0)"),A.fillStyle=w,A.beginPath(),A.arc(32,32,32,0,Math.PI*2),A.fill();const R=new l.CanvasTexture(d);R.flipY=!1;const _=new l.MeshBasicMaterial({color:16777215,transparent:!0,depthWrite:!1,alphaTest:.01,map:R,vertexColors:!0,side:l.DoubleSide,blending:l.NormalBlending});return _.needsUpdate=!0,_},[]),C=a.useRef(null);a.useEffect(()=>{if(!h)return;const d=h.systems.find(w=>!w.emissionTrailEnabled&&w.textureEnabled&&w.textureImageData);if(!d){C.current&&r.map!==C.current&&(r.map=C.current,r.needsUpdate=!0);return}C.current||(C.current=r.map);const A=new Image;return A.onload=()=>{const w=new l.Texture(A);w.needsUpdate=!0,r.map=w,r.needsUpdate=!0},A.src=d.textureImageData,()=>{r.map&&r.map!==C.current&&r.map.dispose()}},[h,r]);const ye=64,X=a.useRef(null),Z=a.useRef(0),M=512,re=a.useRef({buf:new Float32Array(M*6),head:0,count:0,elapsed:0}),{trailGeo:se,trailPosAttr:z,trailColAttr:H}=a.useMemo(()=>{const A=8*ye*6,w=new Float32Array(A*3),R=new Float32Array(A*3),_=new l.BufferGeometry,pe=new l.BufferAttribute(w,3);pe.setUsage(l.DynamicDrawUsage),_.setAttribute("position",pe);const xe=new l.BufferAttribute(R,3);return xe.setUsage(l.DynamicDrawUsage),_.setAttribute("color",xe),_.setDrawRange(0,0),{trailGeo:_,trailPosAttr:pe,trailColAttr:xe}},[]),Ee=a.useMemo(()=>new l.MeshBasicMaterial({color:16777215,vertexColors:!0,transparent:!0,depthWrite:!1,side:l.DoubleSide,blending:l.NormalBlending}),[]);a.useEffect(()=>{if(!Ie||!h)return;const d=new Je.ParticleSystemManager(Ie);return he.current=d,B.current=!1,d.replaceSystems(h).then(()=>{e&&y&&(d.respawnAllSystems(),B.current=!0)}).catch(A=>{console.error("[HZParticlesFX] replaceSystems FAILED:",A)}),()=>{typeof d.destroy=="function"&&d.destroy(),he.current=null}},[Ie,h]),a.useEffect(()=>{const d=he.current;d&&e&&y&&!B.current&&(d.respawnAllSystems(),B.current=!0,Ce.current=!1)},[e,y]);const fe=a.useRef(null),Me=a.useRef($);a.useEffect(()=>{if($===Me.current)return;Me.current=$;const d=re.current;d.head=0,d.count=0,d.elapsed=0,se.setDrawRange(0,0),fe.current=null;const A=he.current;A&&(A.respawnAllSystems(),B.current=!0,Ce.current=!1)},[$]);const Ye=a.useMemo(()=>new l.Matrix4,[]),me=a.useMemo(()=>new l.Vector3,[]),K=a.useMemo(()=>new l.Vector3,[]),ie=a.useMemo(()=>new l.Quaternion,[]),Se=a.useMemo(()=>new l.Vector3,[]),V=a.useMemo(()=>new l.Vector3(0,0,1),[]),Ve=a.useMemo(()=>new l.Color,[]);return Ze.useFrame((d,A)=>{var et;if(!y||!De.current||!he.current)return;const w=he.current,R=(I==null?void 0:I.current)??_e,_=A>1?A/1e3:A,pe=fe.current,xe=pe&&_>0,At=xe?(R.x-pe.x)/_:0,Pt=xe?(R.y-pe.y)/_:0,It=xe?(R.z-pe.z)/_:0;fe.current={x:R.x,y:R.y,z:R.z};for(const{system:s,config:u}of w.particleSystems)u.emissionTrailEnabled?(s.setSimulationTransform({position:[R.x,R.y,R.z],velocity:[At,Pt,It]}),u.emissionTranslationX=0,u.emissionTranslationY=0,u.emissionTranslationZ=0):(u.emissionTranslationX=R.x,u.emissionTranslationY=R.y,u.emissionTranslationZ=R.z);w.updateAllSystems(_);for(const{system:s}of w.particleSystems)s.readbackAndProcessParticles();if(ge){const s=re.current;s.elapsed+=_;let u=0,E=0;const U=(et=w.particleSystems.find(({config:L})=>L.emissionTrailEnabled))==null?void 0:et.config;if(U){const L=U.emissionTrailShape??"straight";if(L!=="straight"){const O=U.emissionTrailShapeAmplitude??.1,ce=U.emissionTrailShapeFrequency??4,te=2*Math.PI*ce*s.elapsed;L==="zigzag"?u=O*Math.sign(Math.sin(te)):L==="sine"?u=O*Math.sin(te):L==="spiral"&&(u=O*Math.sin(te),E=O*Math.cos(te))}}const ee=s.head*6;s.buf[ee]=R.x,s.buf[ee+1]=R.y,s.buf[ee+2]=R.z,s.buf[ee+3]=s.elapsed,s.buf[ee+4]=u,s.buf[ee+5]=E,s.head=(s.head+1)%M,s.count<M&&s.count++}const be=De.current;let ve=0;for(let s=0;s<w.particleSystems.length;s++){const{system:u,config:E}=w.particleSystems[s];if(E.emissionTrailEnabled)continue;const U=u.particleData,ee=u.activeParticles;if(!(!U||ee<=0))for(let L=0;L<ee;L++){const O=L*8,ce=U[O+0],te=U[O+1],D=U[O+2];let ze=U[O+3],we=U[O+4],Q=U[O+5];const Re=U[O+6],oe=U[O+7];if(Re>=oe||oe<=0)continue;const x=Re/oe;if(E.colorTransitionEnabled){const F=E.startColor??[1,0,0],le=E.endColor??[0,0,1];ze=F[0]+(le[0]-F[0])*x,we=F[1]+(le[1]-F[1])*x,Q=F[2]+(le[2]-F[2])*x}const Te=E.bloomIntensity??1;ze=Math.min(1,ze*Te),we=Math.min(1,we*Te),Q=Math.min(1,Q*Te);const Ae=Rt(E,Re,oe,L);ze*=Ae,we*=Ae,Q*=Ae;const J=wt(E,Re,oe,L);if(!(J<=0)){if(me.set(ce,te,D),K.subVectors(ae.position,me).normalize(),ie.setFromUnitVectors(V,K),E.velocityStretchEnabled&&u.particleVelocities){const F=L*4,le=u.particleVelocities[F],Fe=u.particleVelocities[F+1],q=u.particleVelocities[F+2],ue=Math.sqrt(le*le+Fe*Fe+q*q);if(ue>.001){const Qe=E.velocityStretchFactor??1,W=J*(1+ue*Qe);Se.set(J,W,1),K.set(le,Fe,q).normalize(),ie.setFromUnitVectors(V,K);const o=(W-J)*.5;me.addScaledVector(K,o)}else Se.set(J,J,1)}else Se.set(J,J,1);Ye.compose(me,ie,Se),be.setMatrixAt(ve,Ye),Ve.setRGB(ze,we,Q),be.setColorAt(ve,Ve),ve++}}}be.count=ve,be.visible=ve>0,ve>0&&(be.instanceMatrix.needsUpdate=!0,be.instanceColor&&(be.instanceColor.needsUpdate=!0));const Ke=ve>0||w.particleSystems.some(({system:s})=>s.emitting||s.activeParticles>0);if(Ce.current&&!Ke&&(B.current=!1,G==null||G()),Ce.current=Ke,ge&&X.current){const s=z.array,u=H.array;let E=0;const U=ae.position.x,ee=ae.position.y,L=ae.position.z;for(let ce=0;ce<w.particleSystems.length;ce++){const{system:te,config:D}=w.particleSystems[ce];if(!D.emissionTrailEnabled||!te.emitting&&te.activeParticles<=0)continue;const ze=D.emissionTrailDuration??1,we=D.emissionTrailWidth??.3,Q=D.bloomIntensity??1,Re=we*.5,oe=re.current,x=oe.buf,Te=oe.count,Ae=oe.head,J=oe.elapsed;if(Te<2)continue;const F=((Ae-Te)%M+M)%M,le=J-x[F*6+3],Fe=Math.min(ze,le);if(Fe<.001)continue;const q=D.colorTransitionEnabled?D.startColor??[1,1,1]:D.particleColor??[1,1,1],ue=D.colorTransitionEnabled?D.endColor??[1,1,1]:q,Qe=(t,c)=>{const g=J-t;for(let f=0;f<Te-1;f++){const b=((Ae-1-f)%M+M)%M,P=((Ae-2-f)%M+M)%M,j=x[b*6+3],T=x[P*6+3];if(g>=T&&g<=j){const p=j!==T?(g-T)/(j-T):0;c[0]=x[P*6]+(x[b*6]-x[P*6])*p,c[1]=x[P*6+1]+(x[b*6+1]-x[P*6+1])*p,c[2]=x[P*6+2]+(x[b*6+2]-x[P*6+2])*p,c[3]=x[P*6+4]+(x[b*6+4]-x[P*6+4])*p,c[4]=x[P*6+5]+(x[b*6+5]-x[P*6+5])*p;return}}c[0]=x[F*6],c[1]=x[F*6+1],c[2]=x[F*6+2],c[3]=x[F*6+4],c[4]=x[F*6+5]},W=Math.max(1,Math.min(ye,D.emissionTrailSegments??8)),o=[R.x,R.y,R.z],He=D.emissionTrailShape??"straight",We=[];{const t=D.emissionTrailShapeAmplitude??.1,c=D.emissionTrailShapeFrequency??4,g=2*Math.PI*c*J;let f=0,b=0;He==="zigzag"?f=t*Math.sign(Math.sin(g)):He==="sine"?f=t*Math.sin(g):He==="spiral"&&(f=t*Math.sin(g),b=t*Math.cos(g)),We.push(f,b)}const qe=[0,0,0,0,0];for(let t=1;t<=W;t++){const c=t/W*Fe;Qe(c,qe),o.push(qe[0],qe[1],qe[2]),We.push(qe[3],qe[4])}const tt=o[0]-o[W*3],nt=o[1]-o[W*3+1],rt=o[2]-o[W*3+2];if(tt*tt+nt*nt+rt*rt<1e-6)continue;let st=0,it=0,ot=0;const Pe=[],Ge=[];for(let t=0;t<=W;t++){let c,g,f;t===0?(c=o[3]-o[0],g=o[4]-o[1],f=o[5]-o[2]):t===W?(c=o[t*3]-o[(t-1)*3],g=o[t*3+1]-o[(t-1)*3+1],f=o[t*3+2]-o[(t-1)*3+2]):(c=o[(t+1)*3]-o[(t-1)*3],g=o[(t+1)*3+1]-o[(t-1)*3+1],f=o[(t+1)*3+2]-o[(t-1)*3+2]);let b=Math.sqrt(c*c+g*g+f*f);b<1e-8&&(c=0,g=0,f=1,b=1),c/=b,g/=b,f/=b,Ge.push(c,g,f);const P=U-o[t*3],j=ee-o[t*3+1],T=L-o[t*3+2];let p=g*T-f*j,S=f*P-c*T,v=c*j-g*P,k=Math.sqrt(p*p+S*S+v*v);k<1e-8&&(p=-f,S=0,v=c,k=Math.sqrt(p*p+S*S+v*v)),k<1e-8&&(p=0,S=1,v=0,k=1),p/=k,S/=k,v/=k,t>0&&p*st+S*it+v*ot<0&&(p=-p,S=-S,v=-v),st=p,it=S,ot=v,Pe.push(p,S,v)}if(He!=="straight")for(let t=1;t<=W;t++){const c=We[t*2],g=We[t*2+1];if(Math.abs(c)<1e-8&&Math.abs(g)<1e-8)continue;const f=t*3,b=Ge[f],P=Ge[f+1],j=Ge[f+2];let T=-j,p=0,S=b,v=Math.sqrt(T*T+S*S);if(v<1e-6&&(T=0,p=j,S=-P,v=Math.sqrt(T*T+p*p+S*S),v<1e-6&&(T=1,p=0,S=0,v=1)),T/=v,p/=v,S/=v,He==="spiral"){const k=P*S-j*p,Le=j*T-b*S,Xe=b*p-P*T;o[f]+=T*c+k*g,o[f+1]+=p*c+Le*g,o[f+2]+=S*c+Xe*g}else o[f]+=T*c,o[f+1]+=p*c,o[f+2]+=S*c}for(let t=0;t<W;t++){const c=t/W,g=(t+1)/W,f=Re*(1-c),b=Re*(1-g),P=(1-c)*(1-c),j=(1-g)*(1-g),T=Math.min(1,(q[0]+(ue[0]-q[0])*c)*Q)*P,p=Math.min(1,(q[1]+(ue[1]-q[1])*c)*Q)*P,S=Math.min(1,(q[2]+(ue[2]-q[2])*c)*Q)*P,v=Math.min(1,(q[0]+(ue[0]-q[0])*g)*Q)*j,k=Math.min(1,(q[1]+(ue[1]-q[1])*g)*Q)*j,Le=Math.min(1,(q[2]+(ue[2]-q[2])*g)*Q)*j,Xe=o[t*3],at=o[t*3+1],ct=o[t*3+2],lt=o[(t+1)*3],ut=o[(t+1)*3+1],dt=o[(t+1)*3+2],ft=Pe[t*3],mt=Pe[t*3+1],pt=Pe[t*3+2],ht=Pe[(t+1)*3],gt=Pe[(t+1)*3+1],yt=Pe[(t+1)*3+2],Dt=Xe+ft*f,Ct=at+mt*f,Et=ct+pt*f,Mt=Xe-ft*f,St=at-mt*f,xt=ct-pt*f,bt=lt+ht*b,vt=ut+gt*b,zt=dt+yt*b,Vt=lt-ht*b,Ft=ut-gt*b,qt=dt-yt*b,m=E*3;s[m]=Dt,s[m+1]=Ct,s[m+2]=Et,u[m]=T,u[m+1]=p,u[m+2]=S,s[m+3]=Mt,s[m+4]=St,s[m+5]=xt,u[m+3]=T,u[m+4]=p,u[m+5]=S,s[m+6]=bt,s[m+7]=vt,s[m+8]=zt,u[m+6]=v,u[m+7]=k,u[m+8]=Le,s[m+9]=Mt,s[m+10]=St,s[m+11]=xt,u[m+9]=T,u[m+10]=p,u[m+11]=S,s[m+12]=Vt,s[m+13]=Ft,s[m+14]=qt,u[m+12]=v,u[m+13]=k,u[m+14]=Le,s[m+15]=bt,s[m+16]=vt,s[m+17]=zt,u[m+15]=v,u[m+16]=k,u[m+17]=Le,E+=6}}const O=Z.current;if(E<O){const ce=E*3,te=O*3;for(let D=ce;D<te;D++)s[D]=0,u[D]=0}Z.current=E,se.setDrawRange(0,E),z.needsUpdate=!0,H.needsUpdate=!0}}),Y?je.jsxs(je.Fragment,{children:[je.jsx("instancedMesh",{ref:d=>{De.current=d,d&&(d.count=0,d.visible=!Ue)},args:[Oe,r,Ne],frustumCulled:!1,renderOrder:100,visible:y&&!Ue}),ge&&je.jsx("mesh",{ref:X,geometry:se,material:Ee,frustumCulled:!1,renderOrder:99,visible:y})]}):null}const jt=`
2
2
  attribute vec4 aColor;
3
3
  varying vec4 vColor;
4
4
  void main() {
@@ -10,4 +10,4 @@ varying vec4 vColor;
10
10
  void main() {
11
11
  gl_FragColor = vColor;
12
12
  }
13
- `;function Wt({positionRef:s,duration:p=1,width:d=.3,color:V=[1,1,1],maxPoints:S=256,minDistance:Y=.05,opacity:$=1,blending:Z=c.AdditiveBlending,visible:N=!0}){const{camera:se}=ke.useThree(),oe=i.useRef(null),Le=i.useRef({positions:new Float32Array(S*3),times:new Float32Array(S),head:0,count:0,lastPos:new c.Vector3(1/0,1/0,1/0),elapsed:0}),{geometry:pe,posAttr:Ce,colorAttr:De,indexBuf:he}=i.useMemo(()=>{const ye=S*2,Ue=new Float32Array(ye*3),o=new Float32Array(ye*4),H=new c.BufferGeometry,Me=new c.BufferAttribute(Ue,3);Me.setUsage(c.DynamicDrawUsage),H.setAttribute("position",Me);const k=new c.BufferAttribute(o,4);k.setUsage(c.DynamicDrawUsage),H.setAttribute("aColor",k);const v=(S-1)*6,R=new Uint32Array(v);for(let ie=0;ie<S-1;ie++){const w=ie*2,W=ie*6;R[W]=w,R[W+1]=w+1,R[W+2]=w+2,R[W+3]=w+1,R[W+4]=w+3,R[W+5]=w+2}const ne=new c.BufferAttribute(R,1);return H.setIndex(ne),H.setDrawRange(0,0),{geometry:H,posAttr:Me,colorAttr:k,indexBuf:ne}},[S]),Ve=i.useMemo(()=>new c.ShaderMaterial({vertexShader:jt,fragmentShader:_t,transparent:!0,depthWrite:!1,side:c.DoubleSide,blending:Z}),[Z]),O=i.useMemo(()=>new c.Vector3,[]),y=i.useMemo(()=>new c.Vector3,[]),qe=i.useMemo(()=>new c.Vector3,[]),Ye=i.useMemo(()=>new c.Vector3(0,1,0),[]),We=i.useMemo(()=>new c.Vector3,[]);return ke.useFrame((ye,Ue)=>{if(!oe.current)return;const o=Le.current;if(o.elapsed+=Ue,!N){o.count=0,o.head=0,o.lastPos.set(1/0,1/0,1/0),pe.setDrawRange(0,0);return}const H=s.current;if(!H)return;if(o.lastPos.distanceTo(H)>=Y){const w=(o.head+o.count)%S;o.positions[w*3]=H.x,o.positions[w*3+1]=H.y,o.positions[w*3+2]=H.z,o.times[w]=o.elapsed,o.count<S?o.count++:o.head=(o.head+1)%S,o.lastPos.copy(H)}for(;o.count>0;){const w=o.head;if(o.elapsed-o.times[w]>p)o.head=(o.head+1)%S,o.count--;else break}if(o.count<2){pe.setDrawRange(0,0);return}const k=Ce.array,v=De.array;let R=null;const ne=o.count;for(let w=0;w<ne;w++){const W=(o.head+w)%S,de=o.positions[W*3],ge=o.positions[W*3+1],Se=o.positions[W*3+2],ae=1-(o.elapsed-o.times[W])/p;if(w<ne-1){const Fe=(o.head+w+1)%S;O.set(o.positions[Fe*3]-de,o.positions[Fe*3+1]-ge,o.positions[Fe*3+2]-Se);const l=O.length();l>1e-6?O.divideScalar(l):R&&O.copy(R)}else R&&O.copy(R);qe.set(se.position.x-de,se.position.y-ge,se.position.z-Se),y.crossVectors(O,qe);let ce=y.length();ce<1e-6&&(We.crossVectors(O,Ye),y.copy(We),ce=y.length(),ce<1e-6&&(y.set(1,0,0),ce=1)),y.divideScalar(ce);const K=d*ae,Oe=$*ae*ae,F=w*2;k[F*3]=de+y.x*K,k[F*3+1]=ge+y.y*K,k[F*3+2]=Se+y.z*K,k[(F+1)*3]=de-y.x*K,k[(F+1)*3+1]=ge-y.y*K,k[(F+1)*3+2]=Se-y.z*K,v[F*4]=V[0],v[F*4+1]=V[1],v[F*4+2]=V[2],v[F*4+3]=Oe,v[(F+1)*4]=V[0],v[(F+1)*4+1]=V[1],v[(F+1)*4+2]=V[2],v[(F+1)*4+3]=Oe,R=R||new c.Vector3,R.copy(O)}const ie=(ne-1)*6;pe.setDrawRange(0,ie),Ce.needsUpdate=!0,De.needsUpdate=!0}),_e.jsx("mesh",{ref:oe,geometry:pe,material:Ve,frustumCulled:!1,renderOrder:101,visible:N})}Object.defineProperty(exports,"fetchPreset",{enumerable:!0,get:()=>Qe.fetchPreset});exports.HZParticlesFX=Ht;exports.HZTrailRibbon=Wt;exports.computeParticleOpacity=zt;exports.computeParticleSize=wt;exports.particleHash=Je;exports.scalePreset=At;
13
+ `;function Wt({positionRef:i,duration:n=1,width:I=.3,color:e=[1,1,1],maxPoints:y=256,minDistance:N=.05,opacity:$=1,blending:G=l.AdditiveBlending,visible:Y=!0}){const{camera:ne}=Ze.useThree(),ae=a.useRef(null),ke=a.useRef({positions:new Float32Array(y*3),times:new Float32Array(y),head:0,count:0,lastPos:new l.Vector3(1/0,1/0,1/0),elapsed:0}),{geometry:de,posAttr:Ie,colorAttr:De,indexBuf:he}=a.useMemo(()=>{const ge=y*2,Oe=new Float32Array(ge*3),r=new Float32Array(ge*4),C=new l.BufferGeometry,ye=new l.BufferAttribute(Oe,3);ye.setUsage(l.DynamicDrawUsage),C.setAttribute("position",ye);const X=new l.BufferAttribute(r,4);X.setUsage(l.DynamicDrawUsage),C.setAttribute("aColor",X);const Z=(y-1)*6,M=new Uint32Array(Z);for(let se=0;se<y-1;se++){const z=se*2,H=se*6;M[H]=z,M[H+1]=z+1,M[H+2]=z+2,M[H+3]=z+1,M[H+4]=z+3,M[H+5]=z+2}const re=new l.BufferAttribute(M,1);return C.setIndex(re),C.setDrawRange(0,0),{geometry:C,posAttr:ye,colorAttr:X,indexBuf:re}},[y]),Ce=a.useMemo(()=>new l.ShaderMaterial({vertexShader:jt,fragmentShader:_t,transparent:!0,depthWrite:!1,side:l.DoubleSide,blending:G}),[G]),B=a.useMemo(()=>new l.Vector3,[]),h=a.useMemo(()=>new l.Vector3,[]),Ue=a.useMemo(()=>new l.Vector3,[]),Ne=a.useMemo(()=>new l.Vector3(0,1,0),[]),_e=a.useMemo(()=>new l.Vector3,[]);return Ze.useFrame((ge,Oe)=>{if(!ae.current)return;const r=ke.current;if(r.elapsed+=Oe,!Y){r.count=0,r.head=0,r.lastPos.set(1/0,1/0,1/0),de.setDrawRange(0,0);return}const C=i.current;if(!C)return;if(r.lastPos.distanceTo(C)>=N){const z=(r.head+r.count)%y;r.positions[z*3]=C.x,r.positions[z*3+1]=C.y,r.positions[z*3+2]=C.z,r.times[z]=r.elapsed,r.count<y?r.count++:r.head=(r.head+1)%y,r.lastPos.copy(C)}for(;r.count>0;){const z=r.head;if(r.elapsed-r.times[z]>n)r.head=(r.head+1)%y,r.count--;else break}if(r.count<2){de.setDrawRange(0,0);return}const X=Ie.array,Z=De.array;let M=null;const re=r.count;for(let z=0;z<re;z++){const H=(r.head+z)%y,Ee=r.positions[H*3],fe=r.positions[H*3+1],Me=r.positions[H*3+2],me=1-(r.elapsed-r.times[H])/n;if(z<re-1){const Ve=(r.head+z+1)%y;B.set(r.positions[Ve*3]-Ee,r.positions[Ve*3+1]-fe,r.positions[Ve*3+2]-Me);const Be=B.length();Be>1e-6?B.divideScalar(Be):M&&B.copy(M)}else M&&B.copy(M);Ue.set(ne.position.x-Ee,ne.position.y-fe,ne.position.z-Me),h.crossVectors(B,Ue);let K=h.length();K<1e-6&&(_e.crossVectors(B,Ne),h.copy(_e),K=h.length(),K<1e-6&&(h.set(1,0,0),K=1)),h.divideScalar(K);const ie=I*me,Se=$*me*me,V=z*2;X[V*3]=Ee+h.x*ie,X[V*3+1]=fe+h.y*ie,X[V*3+2]=Me+h.z*ie,X[(V+1)*3]=Ee-h.x*ie,X[(V+1)*3+1]=fe-h.y*ie,X[(V+1)*3+2]=Me-h.z*ie,Z[V*4]=e[0],Z[V*4+1]=e[1],Z[V*4+2]=e[2],Z[V*4+3]=Se,Z[(V+1)*4]=e[0],Z[(V+1)*4+1]=e[1],Z[(V+1)*4+2]=e[2],Z[(V+1)*4+3]=Se,M=M||new l.Vector3,M.copy(B)}const se=(re-1)*6;de.setDrawRange(0,se),Ie.needsUpdate=!0,De.needsUpdate=!0}),je.jsx("mesh",{ref:ae,geometry:de,material:Ce,frustumCulled:!1,renderOrder:101,visible:Y})}Object.defineProperty(exports,"fetchPreset",{enumerable:!0,get:()=>Je.fetchPreset});exports.HZParticlesFX=Lt;exports.HZTrailRibbon=Wt;exports.computeParticleOpacity=Rt;exports.computeParticleSize=wt;exports.particleHash=$e;exports.scalePreset=Tt;