hz-particles 1.4.2 → 1.4.3

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.
package/README.md CHANGED
@@ -348,7 +348,7 @@ class ParticleSystem {
348
348
  | `updateParticles(deltaTime)` | Execute a physics simulation step on the GPU. |
349
349
  | `spawnParticles()` | Emit new particles according to emitter configuration. |
350
350
  | `setGravity(value)` | Set gravity strength (default `9.8`). |
351
- | `setAttractor(strength, position)` | Set an attractor point `[x, y, z]`. |
351
+ | `setAttractor(strength, position, reverse?)` | Set an attractor or repulsor point `[x, y, z]`. |
352
352
  | `render(renderPass)` | Render particles to the current render pass. |
353
353
 
354
354
  ### `ParticleSystemManager`
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("react"),Z=require("@react-three/fiber"),X=require("hz-particles"),K=require("react/jsx-runtime"),Q=require("three");function Y(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const s in r)if(s!=="default"){const e=Object.getOwnPropertyDescriptor(r,s);Object.defineProperty(t,s,e.get?e:{enumerable:!0,get:()=>r[s]})}}return t.default=r,Object.freeze(t)}const p=Y(Q);function J(r,t){if(t===1)return r;const s=(e,u)=>e!=null?e*t:u*t;return{...r,systems:r.systems.map(e=>({...e,particleSize:s(e.particleSize,.5),minSize:e.minSize!=null?e.minSize*t:void 0,maxSize:e.maxSize!=null?e.maxSize*t:void 0,particleSpeed:(e.particleSpeed??1)*t,minSpeed:e.minSpeed!=null?e.minSpeed*t:void 0,maxSpeed:e.maxSpeed!=null?e.maxSpeed*t:void 0,cubeLength:e.cubeLength!=null?e.cubeLength*t:void 0,outerLength:e.outerLength!=null?e.outerLength*t:void 0,innerLength:e.innerLength!=null?e.innerLength*t:void 0,outerRadius:e.outerRadius!=null?e.outerRadius*t:void 0,innerRadius:e.innerRadius!=null?e.innerRadius*t:void 0,squareSize:e.squareSize!=null?e.squareSize*t:void 0,squareInnerSize:e.squareInnerSize!=null?e.squareInnerSize*t:void 0,circleInnerRadius:e.circleInnerRadius!=null?e.circleInnerRadius*t:void 0,circleOuterRadius:e.circleOuterRadius!=null?e.circleOuterRadius*t:void 0,cylinderInnerRadius:e.cylinderInnerRadius!=null?e.cylinderInnerRadius*t:void 0,cylinderOuterRadius:e.cylinderOuterRadius!=null?e.cylinderOuterRadius*t:void 0,cylinderHeight:e.cylinderHeight!=null?e.cylinderHeight*t:void 0,emissionTrailWidth:(e.emissionTrailWidth??.3)*t,emissionTrailDuration:(e.emissionTrailDuration??1)*t,emissionTrailMinDistance:e.emissionTrailMinDistance!=null?e.emissionTrailMinDistance*t:void 0,emissionTrailShapeAmplitude:e.emissionTrailShapeAmplitude!=null?e.emissionTrailShapeAmplitude*t:void 0}))}}function $({preset:r,positionRef:t,position:s=[0,0,0],scale:e=1,active:u=!0,renderPriority:w=1,noOcclusion:I=!1,respectReducedMotion:z=!0}){const R=c.useRef(null),g=c.useRef(null),T=c.useRef(!1),C=c.useRef(0),y=c.useRef(u);y.current=u;const P=c.useRef(s);P.current=s;const H=c.useRef(!1),q=c.useMemo(()=>e&&e!==1?J(r,e):r,[r,e]),V=i=>t?i.addMovingEmitter(q,{getPosition:()=>{const o=t.current;return y.current&&o?[o.x,o.y,o.z]:null}}):i.addEmitter(q,P.current);return c.useEffect(()=>{var l,m;const i=R.current;if(!i)return;let o=!1;return(m=(l=g.current)==null?void 0:l.remove)==null||m.call(l),g.current=null,V(i).then(d=>{var A;o?(A=d==null?void 0:d.remove)==null||A.call(d):g.current=d}),()=>{o=!0}},[q]),c.useEffect(()=>{var l;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia("(prefers-reduced-motion: reduce)"),o=()=>{H.current=i.matches};return o(),(l=i.addEventListener)==null||l.call(i,"change",o),()=>{var m;return(m=i.removeEventListener)==null?void 0:m.call(i,"change",o)}},[]),c.useEffect(()=>()=>{var i,o,l,m;(o=(i=g.current)==null?void 0:i.remove)==null||o.call(i),(m=(l=R.current)==null?void 0:l.destroy)==null||m.call(l),R.current=null,g.current=null,T.current=!1},[]),Z.useFrame(i=>{var n,f;i.gl.render(i.scene,i.camera);const o=performance.now(),l=C.current?Math.min(.05,(o-C.current)/1e3):.016;C.current=o;const m=i.gl,d=m.backend,A=(d==null?void 0:d.context)||((f=(n=m.domElement)==null?void 0:n.getContext)==null?void 0:f.call(n,"webgpu"));!R.current&&!T.current&&(d!=null&&d.device)&&A&&(T.current=!0,X.initHzFxOverlay({device:d.device,context:A,canvas:m.domElement},{getSceneDepth:I?()=>null:X.makeThreeSceneDepth(m)}).then(h=>(R.current=h,V(h))).then(h=>{g.current=h}).catch(h=>console.error("[HZFaithfulFX] init failed:",h)));const D=R.current;if(D){const h=i.camera;D.setCamera(h.projectionMatrix.elements,h.matrixWorldInverse.elements,h.position),z&&H.current||D.render(l)}},w),null}const ee=`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react"),N=require("@react-three/fiber"),X=require("hz-particles"),Q=require("react/jsx-runtime"),Y=require("three");function $(r){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const l in r)if(l!=="default"){const e=Object.getOwnPropertyDescriptor(r,l);Object.defineProperty(t,l,e.get?e:{enumerable:!0,get:()=>r[l]})}}return t.default=r,Object.freeze(t)}const p=$(Y);function K(r,t){if(t===1)return r;const l=(e,o)=>e!=null?e*t:o*t;return{...r,systems:r.systems.map(e=>({...e,particleSize:l(e.particleSize,.5),minSize:e.minSize!=null?e.minSize*t:void 0,maxSize:e.maxSize!=null?e.maxSize*t:void 0,particleSpeed:(e.particleSpeed??1)*t,minSpeed:e.minSpeed!=null?e.minSpeed*t:void 0,maxSpeed:e.maxSpeed!=null?e.maxSpeed*t:void 0,cubeLength:e.cubeLength!=null?e.cubeLength*t:void 0,outerLength:e.outerLength!=null?e.outerLength*t:void 0,innerLength:e.innerLength!=null?e.innerLength*t:void 0,outerRadius:e.outerRadius!=null?e.outerRadius*t:void 0,innerRadius:e.innerRadius!=null?e.innerRadius*t:void 0,squareSize:e.squareSize!=null?e.squareSize*t:void 0,squareInnerSize:e.squareInnerSize!=null?e.squareInnerSize*t:void 0,circleInnerRadius:e.circleInnerRadius!=null?e.circleInnerRadius*t:void 0,circleOuterRadius:e.circleOuterRadius!=null?e.circleOuterRadius*t:void 0,cylinderInnerRadius:e.cylinderInnerRadius!=null?e.cylinderInnerRadius*t:void 0,cylinderOuterRadius:e.cylinderOuterRadius!=null?e.cylinderOuterRadius*t:void 0,cylinderHeight:e.cylinderHeight!=null?e.cylinderHeight*t:void 0,rectangleWidth:e.rectangleWidth!=null?e.rectangleWidth*t:void 0,rectangleHeight:e.rectangleHeight!=null?e.rectangleHeight*t:void 0,coneOuterRadius:e.coneOuterRadius!=null?e.coneOuterRadius*t:void 0,coneInnerRadius:e.coneInnerRadius!=null?e.coneInnerRadius*t:void 0,coneHeight:e.coneHeight!=null?e.coneHeight*t:void 0,torusMajorRadius:e.torusMajorRadius!=null?e.torusMajorRadius*t:void 0,torusMinorRadius:e.torusMinorRadius!=null?e.torusMinorRadius*t:void 0,lineLength:e.lineLength!=null?e.lineLength*t:void 0,hemisphereOuterRadius:e.hemisphereOuterRadius!=null?e.hemisphereOuterRadius*t:void 0,hemisphereInnerRadius:e.hemisphereInnerRadius!=null?e.hemisphereInnerRadius*t:void 0,discRadius:e.discRadius!=null?e.discRadius*t:void 0,annulusInnerRadius:e.annulusInnerRadius!=null?e.annulusInnerRadius*t:void 0,annulusOuterRadius:e.annulusOuterRadius!=null?e.annulusOuterRadius*t:void 0,capsuleRadius:e.capsuleRadius!=null?e.capsuleRadius*t:void 0,capsuleHeight:e.capsuleHeight!=null?e.capsuleHeight*t:void 0,arcInnerRadius:e.arcInnerRadius!=null?e.arcInnerRadius*t:void 0,arcOuterRadius:e.arcOuterRadius!=null?e.arcOuterRadius*t:void 0,spiralRadiusStart:e.spiralRadiusStart!=null?e.spiralRadiusStart*t:void 0,spiralRadiusEnd:e.spiralRadiusEnd!=null?e.spiralRadiusEnd*t:void 0,spiralHeight:e.spiralHeight!=null?e.spiralHeight*t:void 0,frustumRadiusNear:e.frustumRadiusNear!=null?e.frustumRadiusNear*t:void 0,frustumRadiusFar:e.frustumRadiusFar!=null?e.frustumRadiusFar*t:void 0,frustumHeight:e.frustumHeight!=null?e.frustumHeight*t:void 0,cubeSurfaceSize:e.cubeSurfaceSize!=null?e.cubeSurfaceSize*t:void 0,sphereSurfaceRadius:e.sphereSurfaceRadius!=null?e.sphereSurfaceRadius*t:void 0,boxFrameSize:e.boxFrameSize!=null?e.boxFrameSize*t:void 0,polygonRadius:e.polygonRadius!=null?e.polygonRadius*t:void 0,emissionTrailWidth:(e.emissionTrailWidth??.3)*t,emissionTrailDuration:(e.emissionTrailDuration??1)*t,emissionTrailMinDistance:e.emissionTrailMinDistance!=null?e.emissionTrailMinDistance*t:void 0,emissionTrailShapeAmplitude:e.emissionTrailShapeAmplitude!=null?e.emissionTrailShapeAmplitude*t:void 0}))}}function y({preset:r,positionRef:t,position:l=[0,0,0],scale:e=1,active:o=!0,renderPriority:z=1,noOcclusion:O=!1,respectReducedMotion:w=!0}){const v=d.useRef(null),S=d.useRef(null),H=d.useRef(!1),L=d.useRef(0),A=d.useRef(o);A.current=o;const C=d.useRef(l);C.current=l;const P=d.useRef(!1),q=d.useMemo(()=>e&&e!==1?K(r,e):r,[r,e]),V=i=>t?i.addMovingEmitter(q,{getPosition:()=>{const u=t.current;return A.current&&u?[u.x,u.y,u.z]:null}}):i.addEmitter(q,C.current);return d.useEffect(()=>{var c,m;const i=v.current;if(!i)return;let u=!1;return(m=(c=S.current)==null?void 0:c.remove)==null||m.call(c),S.current=null,V(i).then(s=>{var x;u?(x=s==null?void 0:s.remove)==null||x.call(s):S.current=s}),()=>{u=!0}},[q]),d.useEffect(()=>{var c;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia("(prefers-reduced-motion: reduce)"),u=()=>{P.current=i.matches};return u(),(c=i.addEventListener)==null||c.call(i,"change",u),()=>{var m;return(m=i.removeEventListener)==null?void 0:m.call(i,"change",u)}},[]),d.useEffect(()=>()=>{var i,u,c,m;(u=(i=S.current)==null?void 0:i.remove)==null||u.call(i),(m=(c=v.current)==null?void 0:c.destroy)==null||m.call(c),v.current=null,S.current=null,H.current=!1},[]),N.useFrame(i=>{var n,h;i.gl.render(i.scene,i.camera);const u=performance.now(),c=L.current?Math.min(.05,(u-L.current)/1e3):.016;L.current=u;const m=i.gl,s=m.backend,x=(s==null?void 0:s.context)||((h=(n=m.domElement)==null?void 0:n.getContext)==null?void 0:h.call(n,"webgpu"));!v.current&&!H.current&&(s!=null&&s.device)&&x&&(H.current=!0,X.initHzFxOverlay({device:s.device,context:x,canvas:m.domElement},{getSceneDepth:O?()=>null:X.makeThreeSceneDepth(m)}).then(f=>(v.current=f,V(f))).then(f=>{S.current=f}).catch(f=>console.error("[HZFaithfulFX] init failed:",f)));const F=v.current;if(F){const f=i.camera;F.setCamera(f.projectionMatrix.elements,f.matrixWorldInverse.elements,f.position),w&&P.current||F.render(c)}},z),null}const ee=`
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 ne({positionRef:r,duration:t=1,width:s=.3,color:e=[1,1,1],maxPoints:u=256,minDistance:w=.05,opacity:I=1,blending:z=p.AdditiveBlending,visible:R=!0}){const{camera:g}=Z.useThree(),T=c.useRef(null),C=c.useRef({positions:new Float32Array(u*3),times:new Float32Array(u),head:0,count:0,lastPos:new p.Vector3(1/0,1/0,1/0),elapsed:0}),{geometry:y,posAttr:P,colorAttr:H,indexBuf:q}=c.useMemo(()=>{const A=u*2,D=new Float32Array(A*3),n=new Float32Array(A*4),f=new p.BufferGeometry,h=new p.BufferAttribute(D,3);h.setUsage(p.DynamicDrawUsage),f.setAttribute("position",h);const x=new p.BufferAttribute(n,4);x.setUsage(p.DynamicDrawUsage),f.setAttribute("aColor",x);const b=(u-1)*6,v=new Uint32Array(b);for(let O=0;O<u-1;O++){const a=O*2,M=O*6;v[M]=a,v[M+1]=a+1,v[M+2]=a+2,v[M+3]=a+1,v[M+4]=a+3,v[M+5]=a+2}const E=new p.BufferAttribute(v,1);return f.setIndex(E),f.setDrawRange(0,0),{geometry:f,posAttr:h,colorAttr:x,indexBuf:E}},[u]),V=c.useMemo(()=>new p.ShaderMaterial({vertexShader:ee,fragmentShader:te,transparent:!0,depthWrite:!1,side:p.DoubleSide,blending:z}),[z]),i=c.useMemo(()=>new p.Vector3,[]),o=c.useMemo(()=>new p.Vector3,[]),l=c.useMemo(()=>new p.Vector3,[]),m=c.useMemo(()=>new p.Vector3(0,1,0),[]),d=c.useMemo(()=>new p.Vector3,[]);return Z.useFrame((A,D)=>{if(!T.current)return;const n=C.current;if(n.elapsed+=D,!R){n.count=0,n.head=0,n.lastPos.set(1/0,1/0,1/0),y.setDrawRange(0,0);return}const f=r.current;if(!f)return;if(n.lastPos.distanceTo(f)>=w){const a=(n.head+n.count)%u;n.positions[a*3]=f.x,n.positions[a*3+1]=f.y,n.positions[a*3+2]=f.z,n.times[a]=n.elapsed,n.count<u?n.count++:n.head=(n.head+1)%u,n.lastPos.copy(f)}for(;n.count>0;){const a=n.head;if(n.elapsed-n.times[a]>t)n.head=(n.head+1)%u,n.count--;else break}if(n.count<2){y.setDrawRange(0,0);return}const x=P.array,b=H.array;let v=null;const E=n.count;for(let a=0;a<E;a++){const M=(n.head+a)%u,j=n.positions[M*3],B=n.positions[M*3+1],U=n.positions[M*3+2],_=1-(n.elapsed-n.times[M])/t;if(a<E-1){const W=(n.head+a+1)%u;i.set(n.positions[W*3]-j,n.positions[W*3+1]-B,n.positions[W*3+2]-U);const N=i.length();N>1e-6?i.divideScalar(N):v&&i.copy(v)}else v&&i.copy(v);l.set(g.position.x-j,g.position.y-B,g.position.z-U),o.crossVectors(i,l);let L=o.length();L<1e-6&&(d.crossVectors(i,m),o.copy(d),L=o.length(),L<1e-6&&(o.set(1,0,0),L=1)),o.divideScalar(L);const F=s*_,G=I*_*_,S=a*2;x[S*3]=j+o.x*F,x[S*3+1]=B+o.y*F,x[S*3+2]=U+o.z*F,x[(S+1)*3]=j-o.x*F,x[(S+1)*3+1]=B-o.y*F,x[(S+1)*3+2]=U-o.z*F,b[S*4]=e[0],b[S*4+1]=e[1],b[S*4+2]=e[2],b[S*4+3]=G,b[(S+1)*4]=e[0],b[(S+1)*4+1]=e[1],b[(S+1)*4+2]=e[2],b[(S+1)*4+3]=G,v=v||new p.Vector3,v.copy(i)}const O=(E-1)*6;y.setDrawRange(0,O),P.needsUpdate=!0,H.needsUpdate=!0}),K.jsx("mesh",{ref:T,geometry:y,material:V,frustumCulled:!1,renderOrder:101,visible:R})}function k(r){return Math.abs(Math.sin(r*12.9898)*43758.5453)%1}function re(r){const t=Math.sin(r*54321.67)*43758.5453%1;return t<0?t+1:t}function ie(r,t,s,e){if(s<=0)return 0;const u=t/s;let w=r.particleSize??.5;if(r.randomSize){const z=r.minSize??.1,R=r.maxSize??.5;w=z+(R-z)*re(s)}const I=Math.max(.01,Math.min(10,r.sizeLifetimeSpeed??1));if(r.fadeSizeEnabled&&(w*=1-Math.pow(u,1/I)),r.increaseSizeEnabled&&(w*=1+Math.pow(u,1/I)),r.pulseEnabled){const z=r.pulseAmplitude??.5,R=r.pulseFrequency??1,T=(r.pulsePhaseRandom??0)*k(e)*Math.PI*2;w*=1+z*Math.sin(t*R*Math.PI*2+T)}return Math.max(0,w)}function oe(r,t,s,e){if(s<=0)return 0;let u=r.opacity??1;const w=t/s;if(r.fadeEnabled&&(u*=Math.max(0,1-w)),r.pulseEnabled&&r.pulseOpacity){const I=r.pulseAmplitude??.5,z=r.pulseFrequency??1,g=(r.pulsePhaseRandom??0)*k(e)*Math.PI*2;u*=Math.max(0,1+I*Math.sin(t*z*Math.PI*2+g))}return Math.max(0,Math.min(1,u))}Object.defineProperty(exports,"fetchPreset",{enumerable:!0,get:()=>X.fetchPreset});exports.HZFaithfulFX=$;exports.HZTrailRibbon=ne;exports.computeParticleOpacity=oe;exports.computeParticleSize=ie;exports.particleHash=k;exports.scalePreset=J;
13
+ `;function ne({positionRef:r,duration:t=1,width:l=.3,color:e=[1,1,1],maxPoints:o=256,minDistance:z=.05,opacity:O=1,blending:w=p.AdditiveBlending,visible:v=!0}){const{camera:S}=N.useThree(),H=d.useRef(null),L=d.useRef({positions:new Float32Array(o*3),times:new Float32Array(o),head:0,count:0,lastPos:new p.Vector3(1/0,1/0,1/0),elapsed:0}),{geometry:A,posAttr:C,colorAttr:P,indexBuf:q}=d.useMemo(()=>{const x=o*2,F=new Float32Array(x*3),n=new Float32Array(x*4),h=new p.BufferGeometry,f=new p.BufferAttribute(F,3);f.setUsage(p.DynamicDrawUsage),h.setAttribute("position",f);const I=new p.BufferAttribute(n,4);I.setUsage(p.DynamicDrawUsage),h.setAttribute("aColor",I);const b=(o-1)*6,R=new Uint32Array(b);for(let T=0;T<o-1;T++){const a=T*2,M=T*6;R[M]=a,R[M+1]=a+1,R[M+2]=a+2,R[M+3]=a+1,R[M+4]=a+3,R[M+5]=a+2}const E=new p.BufferAttribute(R,1);return h.setIndex(E),h.setDrawRange(0,0),{geometry:h,posAttr:f,colorAttr:I,indexBuf:E}},[o]),V=d.useMemo(()=>new p.ShaderMaterial({vertexShader:ee,fragmentShader:te,transparent:!0,depthWrite:!1,side:p.DoubleSide,blending:w}),[w]),i=d.useMemo(()=>new p.Vector3,[]),u=d.useMemo(()=>new p.Vector3,[]),c=d.useMemo(()=>new p.Vector3,[]),m=d.useMemo(()=>new p.Vector3(0,1,0),[]),s=d.useMemo(()=>new p.Vector3,[]);return N.useFrame((x,F)=>{if(!H.current)return;const n=L.current;if(n.elapsed+=F,!v){n.count=0,n.head=0,n.lastPos.set(1/0,1/0,1/0),A.setDrawRange(0,0);return}const h=r.current;if(!h)return;if(n.lastPos.distanceTo(h)>=z){const a=(n.head+n.count)%o;n.positions[a*3]=h.x,n.positions[a*3+1]=h.y,n.positions[a*3+2]=h.z,n.times[a]=n.elapsed,n.count<o?n.count++:n.head=(n.head+1)%o,n.lastPos.copy(h)}for(;n.count>0;){const a=n.head;if(n.elapsed-n.times[a]>t)n.head=(n.head+1)%o,n.count--;else break}if(n.count<2){A.setDrawRange(0,0);return}const I=C.array,b=P.array;let R=null;const E=n.count;for(let a=0;a<E;a++){const M=(n.head+a)%o,B=n.positions[M*3],U=n.positions[M*3+1],W=n.positions[M*3+2],_=1-(n.elapsed-n.times[M])/t;if(a<E-1){const Z=(n.head+a+1)%o;i.set(n.positions[Z*3]-B,n.positions[Z*3+1]-U,n.positions[Z*3+2]-W);const J=i.length();J>1e-6?i.divideScalar(J):R&&i.copy(R)}else R&&i.copy(R);c.set(S.position.x-B,S.position.y-U,S.position.z-W),u.crossVectors(i,c);let j=u.length();j<1e-6&&(s.crossVectors(i,m),u.copy(s),j=u.length(),j<1e-6&&(u.set(1,0,0),j=1)),u.divideScalar(j);const D=l*_,G=O*_*_,g=a*2;I[g*3]=B+u.x*D,I[g*3+1]=U+u.y*D,I[g*3+2]=W+u.z*D,I[(g+1)*3]=B-u.x*D,I[(g+1)*3+1]=U-u.y*D,I[(g+1)*3+2]=W-u.z*D,b[g*4]=e[0],b[g*4+1]=e[1],b[g*4+2]=e[2],b[g*4+3]=G,b[(g+1)*4]=e[0],b[(g+1)*4+1]=e[1],b[(g+1)*4+2]=e[2],b[(g+1)*4+3]=G,R=R||new p.Vector3,R.copy(i)}const T=(E-1)*6;A.setDrawRange(0,T),C.needsUpdate=!0,P.needsUpdate=!0}),Q.jsx("mesh",{ref:H,geometry:A,material:V,frustumCulled:!1,renderOrder:101,visible:v})}function k(r){return Math.abs(Math.sin(r*12.9898)*43758.5453)%1}function re(r){const t=Math.sin(r*54321.67)*43758.5453%1;return t<0?t+1:t}function ie(r,t,l,e){if(l<=0)return 0;const o=t/l;let z=r.particleSize??.5;if(r.randomSize){const w=r.minSize??.1,v=r.maxSize??.5;z=w+(v-w)*re(l)}const O=Math.max(.01,Math.min(10,r.sizeLifetimeSpeed??1));if(r.fadeSizeEnabled&&(z*=1-Math.pow(o,1/O)),r.increaseSizeEnabled&&(z*=1+Math.pow(o,1/O)),r.pulseEnabled){const w=r.pulseAmplitude??.5,v=r.pulseFrequency??1,H=(r.pulsePhaseRandom??0)*k(e)*Math.PI*2;z*=1+w*Math.sin(t*v*Math.PI*2+H)}return Math.max(0,z)}function ue(r,t,l,e){if(l<=0)return 0;let o=r.opacity??1;const z=t/l;if(r.fadeEnabled&&(o*=Math.max(0,1-z)),r.pulseEnabled&&r.pulseOpacity){const O=r.pulseAmplitude??.5,w=r.pulseFrequency??1,S=(r.pulsePhaseRandom??0)*k(e)*Math.PI*2;o*=Math.max(0,1+O*Math.sin(t*w*Math.PI*2+S))}return Math.max(0,Math.min(1,o))}Object.defineProperty(exports,"fetchPreset",{enumerable:!0,get:()=>X.fetchPreset});exports.HZFaithfulFX=y;exports.HZTrailRibbon=ne;exports.computeParticleOpacity=ue;exports.computeParticleSize=ie;exports.particleHash=k;exports.scalePreset=K;
@@ -1,18 +1,18 @@
1
- import { useRef as I, useMemo as b, useEffect as X } from "react";
2
- import { useFrame as J, useThree as N } from "@react-three/fiber";
3
- import { initHzFxOverlay as Q, makeThreeSceneDepth as Y } from "hz-particles";
4
- import { fetchPreset as he } from "hz-particles";
5
- import { jsx as $ } from "react/jsx-runtime";
6
- import * as s from "three";
1
+ import { useRef as A, useMemo as O, useEffect as X } from "react";
2
+ import { useFrame as J, useThree as Q } from "@react-three/fiber";
3
+ import { initHzFxOverlay as Y, makeThreeSceneDepth as $ } from "hz-particles";
4
+ import { fetchPreset as fe } from "hz-particles";
5
+ import { jsx as y } from "react/jsx-runtime";
6
+ import * as c from "three";
7
7
  function ee(r, n) {
8
8
  if (n === 1) return r;
9
- const S = (e, a) => e != null ? e * n : a * n;
9
+ const v = (e, o) => e != null ? e * n : o * n;
10
10
  return {
11
11
  ...r,
12
12
  systems: r.systems.map((e) => ({
13
13
  ...e,
14
14
  // Particle visual size
15
- particleSize: S(e.particleSize, 0.5),
15
+ particleSize: v(e.particleSize, 0.5),
16
16
  minSize: e.minSize != null ? e.minSize * n : void 0,
17
17
  maxSize: e.maxSize != null ? e.maxSize * n : void 0,
18
18
  // Speed
@@ -32,6 +32,33 @@ function ee(r, n) {
32
32
  cylinderInnerRadius: e.cylinderInnerRadius != null ? e.cylinderInnerRadius * n : void 0,
33
33
  cylinderOuterRadius: e.cylinderOuterRadius != null ? e.cylinderOuterRadius * n : void 0,
34
34
  cylinderHeight: e.cylinderHeight != null ? e.cylinderHeight * n : void 0,
35
+ rectangleWidth: e.rectangleWidth != null ? e.rectangleWidth * n : void 0,
36
+ rectangleHeight: e.rectangleHeight != null ? e.rectangleHeight * n : void 0,
37
+ coneOuterRadius: e.coneOuterRadius != null ? e.coneOuterRadius * n : void 0,
38
+ coneInnerRadius: e.coneInnerRadius != null ? e.coneInnerRadius * n : void 0,
39
+ coneHeight: e.coneHeight != null ? e.coneHeight * n : void 0,
40
+ torusMajorRadius: e.torusMajorRadius != null ? e.torusMajorRadius * n : void 0,
41
+ torusMinorRadius: e.torusMinorRadius != null ? e.torusMinorRadius * n : void 0,
42
+ lineLength: e.lineLength != null ? e.lineLength * n : void 0,
43
+ hemisphereOuterRadius: e.hemisphereOuterRadius != null ? e.hemisphereOuterRadius * n : void 0,
44
+ hemisphereInnerRadius: e.hemisphereInnerRadius != null ? e.hemisphereInnerRadius * n : void 0,
45
+ discRadius: e.discRadius != null ? e.discRadius * n : void 0,
46
+ annulusInnerRadius: e.annulusInnerRadius != null ? e.annulusInnerRadius * n : void 0,
47
+ annulusOuterRadius: e.annulusOuterRadius != null ? e.annulusOuterRadius * n : void 0,
48
+ capsuleRadius: e.capsuleRadius != null ? e.capsuleRadius * n : void 0,
49
+ capsuleHeight: e.capsuleHeight != null ? e.capsuleHeight * n : void 0,
50
+ arcInnerRadius: e.arcInnerRadius != null ? e.arcInnerRadius * n : void 0,
51
+ arcOuterRadius: e.arcOuterRadius != null ? e.arcOuterRadius * n : void 0,
52
+ spiralRadiusStart: e.spiralRadiusStart != null ? e.spiralRadiusStart * n : void 0,
53
+ spiralRadiusEnd: e.spiralRadiusEnd != null ? e.spiralRadiusEnd * n : void 0,
54
+ spiralHeight: e.spiralHeight != null ? e.spiralHeight * n : void 0,
55
+ frustumRadiusNear: e.frustumRadiusNear != null ? e.frustumRadiusNear * n : void 0,
56
+ frustumRadiusFar: e.frustumRadiusFar != null ? e.frustumRadiusFar * n : void 0,
57
+ frustumHeight: e.frustumHeight != null ? e.frustumHeight * n : void 0,
58
+ cubeSurfaceSize: e.cubeSurfaceSize != null ? e.cubeSurfaceSize * n : void 0,
59
+ sphereSurfaceRadius: e.sphereSurfaceRadius != null ? e.sphereSurfaceRadius * n : void 0,
60
+ boxFrameSize: e.boxFrameSize != null ? e.boxFrameSize * n : void 0,
61
+ polygonRadius: e.polygonRadius != null ? e.polygonRadius * n : void 0,
35
62
  // Trail
36
63
  emissionTrailWidth: (e.emissionTrailWidth ?? 0.3) * n,
37
64
  emissionTrailDuration: (e.emissionTrailDuration ?? 1) * n,
@@ -40,73 +67,73 @@ function ee(r, n) {
40
67
  }))
41
68
  };
42
69
  }
43
- function de({
70
+ function le({
44
71
  preset: r,
45
72
  positionRef: n,
46
- position: S = [0, 0, 0],
73
+ position: v = [0, 0, 0],
47
74
  scale: e = 1,
48
- active: a = !0,
49
- renderPriority: g = 1,
50
- noOcclusion: T = !1,
51
- respectReducedMotion: x = !0
75
+ active: o = !0,
76
+ renderPriority: z = 1,
77
+ noOcclusion: H = !1,
78
+ respectReducedMotion: I = !0
52
79
  }) {
53
- const h = I(null), R = I(null), D = I(!1), V = I(0), C = I(a);
54
- C.current = a;
55
- const H = I(S);
56
- H.current = S;
57
- const O = I(!1), U = b(
80
+ const f = A(null), g = A(null), b = A(!1), C = A(0), F = A(o);
81
+ F.current = o;
82
+ const V = A(v);
83
+ V.current = v;
84
+ const B = A(!1), W = O(
58
85
  () => e && e !== 1 ? ee(r, e) : r,
59
86
  [r, e]
60
- ), q = (i) => n ? i.addMovingEmitter(U, {
87
+ ), q = (i) => n ? i.addMovingEmitter(W, {
61
88
  getPosition: () => {
62
- const o = n.current;
63
- return C.current && o ? [o.x, o.y, o.z] : null;
89
+ const u = n.current;
90
+ return F.current && u ? [u.x, u.y, u.z] : null;
64
91
  }
65
- }) : i.addEmitter(U, H.current);
92
+ }) : i.addEmitter(W, V.current);
66
93
  return X(() => {
67
- var c, l;
68
- const i = h.current;
94
+ var d, p;
95
+ const i = f.current;
69
96
  if (!i) return;
70
- let o = !1;
71
- return (l = (c = R.current) == null ? void 0 : c.remove) == null || l.call(c), R.current = null, q(i).then((d) => {
72
- var A;
73
- o ? (A = d == null ? void 0 : d.remove) == null || A.call(d) : R.current = d;
97
+ let u = !1;
98
+ return (p = (d = g.current) == null ? void 0 : d.remove) == null || p.call(d), g.current = null, q(i).then((l) => {
99
+ var x;
100
+ u ? (x = l == null ? void 0 : l.remove) == null || x.call(l) : g.current = l;
74
101
  }), () => {
75
- o = !0;
102
+ u = !0;
76
103
  };
77
- }, [U]), X(() => {
78
- var c;
104
+ }, [W]), X(() => {
105
+ var d;
79
106
  if (typeof window > "u" || !window.matchMedia) return;
80
- const i = window.matchMedia("(prefers-reduced-motion: reduce)"), o = () => {
81
- O.current = i.matches;
107
+ const i = window.matchMedia("(prefers-reduced-motion: reduce)"), u = () => {
108
+ B.current = i.matches;
82
109
  };
83
- return o(), (c = i.addEventListener) == null || c.call(i, "change", o), () => {
84
- var l;
85
- return (l = i.removeEventListener) == null ? void 0 : l.call(i, "change", o);
110
+ return u(), (d = i.addEventListener) == null || d.call(i, "change", u), () => {
111
+ var p;
112
+ return (p = i.removeEventListener) == null ? void 0 : p.call(i, "change", u);
86
113
  };
87
114
  }, []), X(() => () => {
88
- var i, o, c, l;
89
- (o = (i = R.current) == null ? void 0 : i.remove) == null || o.call(i), (l = (c = h.current) == null ? void 0 : c.destroy) == null || l.call(c), h.current = null, R.current = null, D.current = !1;
115
+ var i, u, d, p;
116
+ (u = (i = g.current) == null ? void 0 : i.remove) == null || u.call(i), (p = (d = f.current) == null ? void 0 : d.destroy) == null || p.call(d), f.current = null, g.current = null, b.current = !1;
90
117
  }, []), J((i) => {
91
- var t, p;
118
+ var t, s;
92
119
  i.gl.render(i.scene, i.camera);
93
- const o = performance.now(), c = V.current ? Math.min(0.05, (o - V.current) / 1e3) : 0.016;
94
- V.current = o;
95
- const l = i.gl, d = l.backend, A = (d == null ? void 0 : d.context) || ((p = (t = l.domElement) == null ? void 0 : t.getContext) == null ? void 0 : p.call(t, "webgpu"));
96
- !h.current && !D.current && (d != null && d.device) && A && (D.current = !0, Q(
97
- { device: d.device, context: A, canvas: l.domElement },
98
- { getSceneDepth: T ? () => null : Y(l) }
99
- ).then((m) => (h.current = m, q(m))).then((m) => {
100
- R.current = m;
120
+ const u = performance.now(), d = C.current ? Math.min(0.05, (u - C.current) / 1e3) : 0.016;
121
+ C.current = u;
122
+ const p = i.gl, l = p.backend, x = (l == null ? void 0 : l.context) || ((s = (t = p.domElement) == null ? void 0 : t.getContext) == null ? void 0 : s.call(t, "webgpu"));
123
+ !f.current && !b.current && (l != null && l.device) && x && (b.current = !0, Y(
124
+ { device: l.device, context: x, canvas: p.domElement },
125
+ { getSceneDepth: H ? () => null : $(p) }
126
+ ).then((m) => (f.current = m, q(m))).then((m) => {
127
+ g.current = m;
101
128
  }).catch((m) => console.error("[HZFaithfulFX] init failed:", m)));
102
- const E = h.current;
129
+ const E = f.current;
103
130
  if (E) {
104
131
  const m = i.camera;
105
- E.setCamera(m.projectionMatrix.elements, m.matrixWorldInverse.elements, m.position), x && O.current || E.render(c);
132
+ E.setCamera(m.projectionMatrix.elements, m.matrixWorldInverse.elements, m.position), I && B.current || E.render(d);
106
133
  }
107
- }, g), null;
134
+ }, z), null;
108
135
  }
109
- const te = (
136
+ const ne = (
110
137
  /* glsl */
111
138
  `
112
139
  attribute vec4 aColor;
@@ -116,7 +143,7 @@ void main() {
116
143
  gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
117
144
  }
118
145
  `
119
- ), ne = (
146
+ ), te = (
120
147
  /* glsl */
121
148
  `
122
149
  varying vec4 vColor;
@@ -125,104 +152,104 @@ void main() {
125
152
  }
126
153
  `
127
154
  );
128
- function se({
155
+ function ce({
129
156
  positionRef: r,
130
157
  duration: n = 1,
131
- width: S = 0.3,
158
+ width: v = 0.3,
132
159
  color: e = [1, 1, 1],
133
- maxPoints: a = 256,
134
- minDistance: g = 0.05,
135
- opacity: T = 1,
136
- blending: x = s.AdditiveBlending,
137
- visible: h = !0
160
+ maxPoints: o = 256,
161
+ minDistance: z = 0.05,
162
+ opacity: H = 1,
163
+ blending: I = c.AdditiveBlending,
164
+ visible: f = !0
138
165
  }) {
139
- const { camera: R } = N(), D = I(null), V = I({
140
- positions: new Float32Array(a * 3),
141
- times: new Float32Array(a),
166
+ const { camera: g } = Q(), b = A(null), C = A({
167
+ positions: new Float32Array(o * 3),
168
+ times: new Float32Array(o),
142
169
  head: 0,
143
170
  count: 0,
144
- lastPos: new s.Vector3(1 / 0, 1 / 0, 1 / 0),
171
+ lastPos: new c.Vector3(1 / 0, 1 / 0, 1 / 0),
145
172
  elapsed: 0
146
- }), { geometry: C, posAttr: H, colorAttr: O, indexBuf: U } = b(() => {
147
- const A = a * 2, E = new Float32Array(A * 3), t = new Float32Array(A * 4), p = new s.BufferGeometry(), m = new s.BufferAttribute(E, 3);
148
- m.setUsage(s.DynamicDrawUsage), p.setAttribute("position", m);
149
- const z = new s.BufferAttribute(t, 4);
150
- z.setUsage(s.DynamicDrawUsage), p.setAttribute("aColor", z);
151
- const M = (a - 1) * 6, f = new Uint32Array(M);
152
- for (let y = 0; y < a - 1; y++) {
153
- const u = y * 2, w = y * 6;
154
- f[w] = u, f[w + 1] = u + 1, f[w + 2] = u + 2, f[w + 3] = u + 1, f[w + 4] = u + 3, f[w + 5] = u + 2;
173
+ }), { geometry: F, posAttr: V, colorAttr: B, indexBuf: W } = O(() => {
174
+ const x = o * 2, E = new Float32Array(x * 3), t = new Float32Array(x * 4), s = new c.BufferGeometry(), m = new c.BufferAttribute(E, 3);
175
+ m.setUsage(c.DynamicDrawUsage), s.setAttribute("position", m);
176
+ const M = new c.BufferAttribute(t, 4);
177
+ M.setUsage(c.DynamicDrawUsage), s.setAttribute("aColor", M);
178
+ const w = (o - 1) * 6, h = new Uint32Array(w);
179
+ for (let D = 0; D < o - 1; D++) {
180
+ const a = D * 2, S = D * 6;
181
+ h[S] = a, h[S + 1] = a + 1, h[S + 2] = a + 2, h[S + 3] = a + 1, h[S + 4] = a + 3, h[S + 5] = a + 2;
155
182
  }
156
- const F = new s.BufferAttribute(f, 1);
157
- return p.setIndex(F), p.setDrawRange(0, 0), { geometry: p, posAttr: m, colorAttr: z, indexBuf: F };
158
- }, [a]), q = b(() => new s.ShaderMaterial({
159
- vertexShader: te,
160
- fragmentShader: ne,
183
+ const T = new c.BufferAttribute(h, 1);
184
+ return s.setIndex(T), s.setDrawRange(0, 0), { geometry: s, posAttr: m, colorAttr: M, indexBuf: T };
185
+ }, [o]), q = O(() => new c.ShaderMaterial({
186
+ vertexShader: ne,
187
+ fragmentShader: te,
161
188
  transparent: !0,
162
189
  depthWrite: !1,
163
- side: s.DoubleSide,
164
- blending: x
165
- }), [x]), i = b(() => new s.Vector3(), []), o = b(() => new s.Vector3(), []), c = b(() => new s.Vector3(), []), l = b(() => new s.Vector3(0, 1, 0), []), d = b(() => new s.Vector3(), []);
166
- return J((A, E) => {
167
- if (!D.current) return;
168
- const t = V.current;
169
- if (t.elapsed += E, !h) {
170
- t.count = 0, t.head = 0, t.lastPos.set(1 / 0, 1 / 0, 1 / 0), C.setDrawRange(0, 0);
190
+ side: c.DoubleSide,
191
+ blending: I
192
+ }), [I]), i = O(() => new c.Vector3(), []), u = O(() => new c.Vector3(), []), d = O(() => new c.Vector3(), []), p = O(() => new c.Vector3(0, 1, 0), []), l = O(() => new c.Vector3(), []);
193
+ return J((x, E) => {
194
+ if (!b.current) return;
195
+ const t = C.current;
196
+ if (t.elapsed += E, !f) {
197
+ t.count = 0, t.head = 0, t.lastPos.set(1 / 0, 1 / 0, 1 / 0), F.setDrawRange(0, 0);
171
198
  return;
172
199
  }
173
- const p = r.current;
174
- if (!p) return;
175
- if (t.lastPos.distanceTo(p) >= g) {
176
- const u = (t.head + t.count) % a;
177
- t.positions[u * 3] = p.x, t.positions[u * 3 + 1] = p.y, t.positions[u * 3 + 2] = p.z, t.times[u] = t.elapsed, t.count < a ? t.count++ : t.head = (t.head + 1) % a, t.lastPos.copy(p);
200
+ const s = r.current;
201
+ if (!s) return;
202
+ if (t.lastPos.distanceTo(s) >= z) {
203
+ const a = (t.head + t.count) % o;
204
+ t.positions[a * 3] = s.x, t.positions[a * 3 + 1] = s.y, t.positions[a * 3 + 2] = s.z, t.times[a] = t.elapsed, t.count < o ? t.count++ : t.head = (t.head + 1) % o, t.lastPos.copy(s);
178
205
  }
179
206
  for (; t.count > 0; ) {
180
- const u = t.head;
181
- if (t.elapsed - t.times[u] > n)
182
- t.head = (t.head + 1) % a, t.count--;
207
+ const a = t.head;
208
+ if (t.elapsed - t.times[a] > n)
209
+ t.head = (t.head + 1) % o, t.count--;
183
210
  else
184
211
  break;
185
212
  }
186
213
  if (t.count < 2) {
187
- C.setDrawRange(0, 0);
214
+ F.setDrawRange(0, 0);
188
215
  return;
189
216
  }
190
- const z = H.array, M = O.array;
191
- let f = null;
192
- const F = t.count;
193
- for (let u = 0; u < F; u++) {
194
- const w = (t.head + u) % a, P = t.positions[w * 3], W = t.positions[w * 3 + 1], j = t.positions[w * 3 + 2], Z = 1 - (t.elapsed - t.times[w]) / n;
195
- if (u < F - 1) {
196
- const _ = (t.head + u + 1) % a;
217
+ const M = V.array, w = B.array;
218
+ let h = null;
219
+ const T = t.count;
220
+ for (let a = 0; a < T; a++) {
221
+ const S = (t.head + a) % o, j = t.positions[S * 3], P = t.positions[S * 3 + 1], N = t.positions[S * 3 + 2], Z = 1 - (t.elapsed - t.times[S]) / n;
222
+ if (a < T - 1) {
223
+ const _ = (t.head + a + 1) % o;
197
224
  i.set(
198
- t.positions[_ * 3] - P,
199
- t.positions[_ * 3 + 1] - W,
200
- t.positions[_ * 3 + 2] - j
225
+ t.positions[_ * 3] - j,
226
+ t.positions[_ * 3 + 1] - P,
227
+ t.positions[_ * 3 + 2] - N
201
228
  );
202
229
  const k = i.length();
203
- k > 1e-6 ? i.divideScalar(k) : f && i.copy(f);
204
- } else f && i.copy(f);
205
- c.set(
206
- R.position.x - P,
207
- R.position.y - W,
208
- R.position.z - j
209
- ), o.crossVectors(i, c);
210
- let B = o.length();
211
- B < 1e-6 && (d.crossVectors(i, l), o.copy(d), B = o.length(), B < 1e-6 && (o.set(1, 0, 0), B = 1)), o.divideScalar(B);
212
- const L = S * Z, G = T * Z * Z, v = u * 2;
213
- z[v * 3] = P + o.x * L, z[v * 3 + 1] = W + o.y * L, z[v * 3 + 2] = j + o.z * L, z[(v + 1) * 3] = P - o.x * L, z[(v + 1) * 3 + 1] = W - o.y * L, z[(v + 1) * 3 + 2] = j - o.z * L, M[v * 4] = e[0], M[v * 4 + 1] = e[1], M[v * 4 + 2] = e[2], M[v * 4 + 3] = G, M[(v + 1) * 4] = e[0], M[(v + 1) * 4 + 1] = e[1], M[(v + 1) * 4 + 2] = e[2], M[(v + 1) * 4 + 3] = G, f = f || new s.Vector3(), f.copy(i);
230
+ k > 1e-6 ? i.divideScalar(k) : h && i.copy(h);
231
+ } else h && i.copy(h);
232
+ d.set(
233
+ g.position.x - j,
234
+ g.position.y - P,
235
+ g.position.z - N
236
+ ), u.crossVectors(i, d);
237
+ let U = u.length();
238
+ U < 1e-6 && (l.crossVectors(i, p), u.copy(l), U = u.length(), U < 1e-6 && (u.set(1, 0, 0), U = 1)), u.divideScalar(U);
239
+ const L = v * Z, G = H * Z * Z, R = a * 2;
240
+ M[R * 3] = j + u.x * L, M[R * 3 + 1] = P + u.y * L, M[R * 3 + 2] = N + u.z * L, M[(R + 1) * 3] = j - u.x * L, M[(R + 1) * 3 + 1] = P - u.y * L, M[(R + 1) * 3 + 2] = N - u.z * L, w[R * 4] = e[0], w[R * 4 + 1] = e[1], w[R * 4 + 2] = e[2], w[R * 4 + 3] = G, w[(R + 1) * 4] = e[0], w[(R + 1) * 4 + 1] = e[1], w[(R + 1) * 4 + 2] = e[2], w[(R + 1) * 4 + 3] = G, h = h || new c.Vector3(), h.copy(i);
214
241
  }
215
- const y = (F - 1) * 6;
216
- C.setDrawRange(0, y), H.needsUpdate = !0, O.needsUpdate = !0;
217
- }), /* @__PURE__ */ $(
242
+ const D = (T - 1) * 6;
243
+ F.setDrawRange(0, D), V.needsUpdate = !0, B.needsUpdate = !0;
244
+ }), /* @__PURE__ */ y(
218
245
  "mesh",
219
246
  {
220
- ref: D,
221
- geometry: C,
247
+ ref: b,
248
+ geometry: F,
222
249
  material: q,
223
250
  frustumCulled: !1,
224
251
  renderOrder: 101,
225
- visible: h
252
+ visible: f
226
253
  }
227
254
  );
228
255
  }
@@ -233,37 +260,37 @@ function re(r) {
233
260
  const n = Math.sin(r * 54321.67) * 43758.5453 % 1;
234
261
  return n < 0 ? n + 1 : n;
235
262
  }
236
- function le(r, n, S, e) {
237
- if (S <= 0) return 0;
238
- const a = n / S;
239
- let g = r.particleSize ?? 0.5;
263
+ function pe(r, n, v, e) {
264
+ if (v <= 0) return 0;
265
+ const o = n / v;
266
+ let z = r.particleSize ?? 0.5;
240
267
  if (r.randomSize) {
241
- const x = r.minSize ?? 0.1, h = r.maxSize ?? 0.5;
242
- g = x + (h - x) * re(S);
268
+ const I = r.minSize ?? 0.1, f = r.maxSize ?? 0.5;
269
+ z = I + (f - I) * re(v);
243
270
  }
244
- const T = Math.max(0.01, Math.min(10, r.sizeLifetimeSpeed ?? 1));
245
- if (r.fadeSizeEnabled && (g *= 1 - Math.pow(a, 1 / T)), r.increaseSizeEnabled && (g *= 1 + Math.pow(a, 1 / T)), r.pulseEnabled) {
246
- const x = r.pulseAmplitude ?? 0.5, h = r.pulseFrequency ?? 1, D = (r.pulsePhaseRandom ?? 0) * K(e) * Math.PI * 2;
247
- g *= 1 + x * Math.sin(n * h * Math.PI * 2 + D);
271
+ const H = Math.max(0.01, Math.min(10, r.sizeLifetimeSpeed ?? 1));
272
+ if (r.fadeSizeEnabled && (z *= 1 - Math.pow(o, 1 / H)), r.increaseSizeEnabled && (z *= 1 + Math.pow(o, 1 / H)), r.pulseEnabled) {
273
+ const I = r.pulseAmplitude ?? 0.5, f = r.pulseFrequency ?? 1, b = (r.pulsePhaseRandom ?? 0) * K(e) * Math.PI * 2;
274
+ z *= 1 + I * Math.sin(n * f * Math.PI * 2 + b);
248
275
  }
249
- return Math.max(0, g);
276
+ return Math.max(0, z);
250
277
  }
251
- function pe(r, n, S, e) {
252
- if (S <= 0) return 0;
253
- let a = r.opacity ?? 1;
254
- const g = n / S;
255
- if (r.fadeEnabled && (a *= Math.max(0, 1 - g)), r.pulseEnabled && r.pulseOpacity) {
256
- const T = r.pulseAmplitude ?? 0.5, x = r.pulseFrequency ?? 1, R = (r.pulsePhaseRandom ?? 0) * K(e) * Math.PI * 2;
257
- a *= Math.max(0, 1 + T * Math.sin(n * x * Math.PI * 2 + R));
278
+ function se(r, n, v, e) {
279
+ if (v <= 0) return 0;
280
+ let o = r.opacity ?? 1;
281
+ const z = n / v;
282
+ if (r.fadeEnabled && (o *= Math.max(0, 1 - z)), r.pulseEnabled && r.pulseOpacity) {
283
+ const H = r.pulseAmplitude ?? 0.5, I = r.pulseFrequency ?? 1, g = (r.pulsePhaseRandom ?? 0) * K(e) * Math.PI * 2;
284
+ o *= Math.max(0, 1 + H * Math.sin(n * I * Math.PI * 2 + g));
258
285
  }
259
- return Math.max(0, Math.min(1, a));
286
+ return Math.max(0, Math.min(1, o));
260
287
  }
261
288
  export {
262
- de as HZFaithfulFX,
263
- se as HZTrailRibbon,
264
- pe as computeParticleOpacity,
265
- le as computeParticleSize,
266
- he as fetchPreset,
289
+ le as HZFaithfulFX,
290
+ ce as HZTrailRibbon,
291
+ se as computeParticleOpacity,
292
+ pe as computeParticleSize,
293
+ fe as fetchPreset,
267
294
  K as particleHash,
268
295
  ee as scalePreset
269
296
  };