hz-particles 1.2.0 → 1.3.0
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 +278 -234
- package/dist-lib/hz-particles-r3f.cjs +2 -2
- package/dist-lib/hz-particles-r3f.d.ts +2 -0
- package/dist-lib/hz-particles-r3f.mjs +136 -125
- package/dist-lib/hz-particles.cjs +22 -22
- package/dist-lib/hz-particles.mjs +3719 -3603
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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(n){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const s in n)if(s!=="default"){const e=Object.getOwnPropertyDescriptor(n,s);Object.defineProperty(t,s,e.get?e:{enumerable:!0,get:()=>n[s]})}}return t.default=n,Object.freeze(t)}const p=Y(Q);function J(n,t){if(t===1)return n;const s=(e,u)=>e!=null?e*t:u*t;return{...n,systems:n.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:n,positionRef:t,position:s=[0,0,0],scale:e=1,active:u=!0,renderPriority:w=1,noOcclusion:I=!1,respectReducedMotion:z=!0}){const f=c.useRef(null),S=c.useRef(null),T=c.useRef(!1),F=c.useRef(0),y=c.useRef(u);y.current=u;const P=c.useRef(s);P.current=s;const C=c.useRef(!1),L=c.useMemo(()=>e&&e!==1?J(n,e):n,[n,e]),q=i=>t?i.addMovingEmitter(L,{getPosition:()=>{const o=t.current;return y.current&&o?[o.x,o.y,o.z]:null}}):i.addEmitter(L,P.current);return c.useEffect(()=>{var d,h;const i=f.current;if(!i)return;let o=!1;return(h=(d=S.current)==null?void 0:d.remove)==null||h.call(d),S.current=null,q(i).then(l=>{var x;o?(x=l==null?void 0:l.remove)==null||x.call(l):S.current=l}),()=>{o=!0}},[L]),c.useEffect(()=>{var d;if(typeof window>"u"||!window.matchMedia)return;const i=window.matchMedia("(prefers-reduced-motion: reduce)"),o=()=>{C.current=i.matches};return o(),(d=i.addEventListener)==null||d.call(i,"change",o),()=>{var h;return(h=i.removeEventListener)==null?void 0:h.call(i,"change",o)}},[]),c.useEffect(()=>()=>{var i,o,d,h;(o=(i=S.current)==null?void 0:i.remove)==null||o.call(i),(h=(d=f.current)==null?void 0:d.destroy)==null||h.call(d),f.current=null,S.current=null,T.current=!1},[]),Z.useFrame(i=>{i.gl.render(i.scene,i.camera);const o=performance.now(),d=F.current?Math.min(.05,(o-F.current)/1e3):.016;F.current=o;const h=i.gl,l=h.backend;!f.current&&!T.current&&(l!=null&&l.device)&&(l!=null&&l.context)&&(T.current=!0,X.initHzFxOverlay({device:l.device,context:l.context,canvas:h.domElement},{getSceneDepth:I?()=>null:X.makeThreeSceneDepth(h)}).then(v=>(f.current=v,q(v))).then(v=>{S.current=v}).catch(v=>console.error("[HZFaithfulFX] init failed:",v)));const x=f.current;if(x){const v=i.camera;x.setCamera(v.projectionMatrix.elements,v.matrixWorldInverse.elements,v.position),z&&C.current||x.render(d)}},w),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:n,duration:t=1,width:
|
|
13
|
+
`;function ne({positionRef:n,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:f=!0}){const{camera:S}=Z.useThree(),T=c.useRef(null),F=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:C,indexBuf:L}=c.useMemo(()=>{const x=u*2,v=new Float32Array(x*3),r=new Float32Array(x*4),M=new p.BufferGeometry,V=new p.BufferAttribute(v,3);V.setUsage(p.DynamicDrawUsage),M.setAttribute("position",V);const b=new p.BufferAttribute(r,4);b.setUsage(p.DynamicDrawUsage),M.setAttribute("aColor",b);const A=(u-1)*6,m=new Uint32Array(A);for(let E=0;E<u-1;E++){const a=E*2,g=E*6;m[g]=a,m[g+1]=a+1,m[g+2]=a+2,m[g+3]=a+1,m[g+4]=a+3,m[g+5]=a+2}const D=new p.BufferAttribute(m,1);return M.setIndex(D),M.setDrawRange(0,0),{geometry:M,posAttr:V,colorAttr:b,indexBuf:D}},[u]),q=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,[]),d=c.useMemo(()=>new p.Vector3,[]),h=c.useMemo(()=>new p.Vector3(0,1,0),[]),l=c.useMemo(()=>new p.Vector3,[]);return Z.useFrame((x,v)=>{if(!T.current)return;const r=F.current;if(r.elapsed+=v,!f){r.count=0,r.head=0,r.lastPos.set(1/0,1/0,1/0),y.setDrawRange(0,0);return}const M=n.current;if(!M)return;if(r.lastPos.distanceTo(M)>=w){const a=(r.head+r.count)%u;r.positions[a*3]=M.x,r.positions[a*3+1]=M.y,r.positions[a*3+2]=M.z,r.times[a]=r.elapsed,r.count<u?r.count++:r.head=(r.head+1)%u,r.lastPos.copy(M)}for(;r.count>0;){const a=r.head;if(r.elapsed-r.times[a]>t)r.head=(r.head+1)%u,r.count--;else break}if(r.count<2){y.setDrawRange(0,0);return}const b=P.array,A=C.array;let m=null;const D=r.count;for(let a=0;a<D;a++){const g=(r.head+a)%u,j=r.positions[g*3],B=r.positions[g*3+1],U=r.positions[g*3+2],_=1-(r.elapsed-r.times[g])/t;if(a<D-1){const W=(r.head+a+1)%u;i.set(r.positions[W*3]-j,r.positions[W*3+1]-B,r.positions[W*3+2]-U);const N=i.length();N>1e-6?i.divideScalar(N):m&&i.copy(m)}else m&&i.copy(m);d.set(S.position.x-j,S.position.y-B,S.position.z-U),o.crossVectors(i,d);let H=o.length();H<1e-6&&(l.crossVectors(i,h),o.copy(l),H=o.length(),H<1e-6&&(o.set(1,0,0),H=1)),o.divideScalar(H);const O=s*_,G=I*_*_,R=a*2;b[R*3]=j+o.x*O,b[R*3+1]=B+o.y*O,b[R*3+2]=U+o.z*O,b[(R+1)*3]=j-o.x*O,b[(R+1)*3+1]=B-o.y*O,b[(R+1)*3+2]=U-o.z*O,A[R*4]=e[0],A[R*4+1]=e[1],A[R*4+2]=e[2],A[R*4+3]=G,A[(R+1)*4]=e[0],A[(R+1)*4+1]=e[1],A[(R+1)*4+2]=e[2],A[(R+1)*4+3]=G,m=m||new p.Vector3,m.copy(i)}const E=(D-1)*6;y.setDrawRange(0,E),P.needsUpdate=!0,C.needsUpdate=!0}),K.jsx("mesh",{ref:T,geometry:y,material:q,frustumCulled:!1,renderOrder:101,visible:f})}function k(n){return Math.abs(Math.sin(n*12.9898)*43758.5453)%1}function re(n){const t=Math.sin(n*54321.67)*43758.5453%1;return t<0?t+1:t}function ie(n,t,s,e){if(s<=0)return 0;const u=t/s;let w=n.particleSize??.5;if(n.randomSize){const z=n.minSize??.1,f=n.maxSize??.5;w=z+(f-z)*re(s)}const I=Math.max(.01,Math.min(10,n.sizeLifetimeSpeed??1));if(n.fadeSizeEnabled&&(w*=1-Math.pow(u,1/I)),n.increaseSizeEnabled&&(w*=1+Math.pow(u,1/I)),n.pulseEnabled){const z=n.pulseAmplitude??.5,f=n.pulseFrequency??1,T=(n.pulsePhaseRandom??0)*k(e)*Math.PI*2;w*=1+z*Math.sin(t*f*Math.PI*2+T)}return Math.max(0,w)}function oe(n,t,s,e){if(s<=0)return 0;let u=n.opacity??1;const w=t/s;if(n.fadeEnabled&&(u*=Math.max(0,1-w)),n.pulseEnabled&&n.pulseOpacity){const I=n.pulseAmplitude??.5,z=n.pulseFrequency??1,S=(n.pulsePhaseRandom??0)*k(e)*Math.PI*2;u*=Math.max(0,1+I*Math.sin(t*z*Math.PI*2+S))}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;
|
|
@@ -17,6 +17,8 @@ export interface HZFaithfulFXProps {
|
|
|
17
17
|
renderPriority?: number;
|
|
18
18
|
/** Skip scene-depth occlusion (particles never hidden behind geometry). */
|
|
19
19
|
noOcclusion?: boolean;
|
|
20
|
+
/** Respect the user's `prefers-reduced-motion` setting by freezing the FX. Default true. */
|
|
21
|
+
respectReducedMotion?: boolean;
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useRef as
|
|
1
|
+
import { useRef as I, useMemo as b, useEffect as X } from "react";
|
|
2
2
|
import { useFrame as J, useThree as N } from "@react-three/fiber";
|
|
3
3
|
import { initHzFxOverlay as Q, makeThreeSceneDepth as Y } from "hz-particles";
|
|
4
4
|
import { fetchPreset as he } from "hz-particles";
|
|
@@ -6,13 +6,13 @@ import { jsx as $ } from "react/jsx-runtime";
|
|
|
6
6
|
import * as s from "three";
|
|
7
7
|
function ee(r, t) {
|
|
8
8
|
if (t === 1) return r;
|
|
9
|
-
const
|
|
9
|
+
const v = (e, a) => e != null ? e * t : a * t;
|
|
10
10
|
return {
|
|
11
11
|
...r,
|
|
12
12
|
systems: r.systems.map((e) => ({
|
|
13
13
|
...e,
|
|
14
14
|
// Particle visual size
|
|
15
|
-
particleSize:
|
|
15
|
+
particleSize: v(e.particleSize, 0.5),
|
|
16
16
|
minSize: e.minSize != null ? e.minSize * t : void 0,
|
|
17
17
|
maxSize: e.maxSize != null ? e.maxSize * t : void 0,
|
|
18
18
|
// Speed
|
|
@@ -40,59 +40,70 @@ function ee(r, t) {
|
|
|
40
40
|
}))
|
|
41
41
|
};
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function de({
|
|
44
44
|
preset: r,
|
|
45
45
|
positionRef: t,
|
|
46
|
-
position:
|
|
46
|
+
position: v = [0, 0, 0],
|
|
47
47
|
scale: e = 1,
|
|
48
|
-
active:
|
|
49
|
-
renderPriority:
|
|
50
|
-
noOcclusion:
|
|
48
|
+
active: a = !0,
|
|
49
|
+
renderPriority: x = 1,
|
|
50
|
+
noOcclusion: T = !1,
|
|
51
|
+
respectReducedMotion: z = !0
|
|
51
52
|
}) {
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const
|
|
53
|
+
const p = I(null), S = I(null), D = I(!1), L = I(0), C = I(a);
|
|
54
|
+
C.current = a;
|
|
55
|
+
const V = I(v);
|
|
56
|
+
V.current = v;
|
|
57
|
+
const H = I(!1), B = b(
|
|
57
58
|
() => e && e !== 1 ? ee(r, e) : r,
|
|
58
59
|
[r, e]
|
|
59
|
-
),
|
|
60
|
+
), U = (i) => t ? i.addMovingEmitter(B, {
|
|
60
61
|
getPosition: () => {
|
|
61
|
-
const
|
|
62
|
-
return
|
|
62
|
+
const o = t.current;
|
|
63
|
+
return C.current && o ? [o.x, o.y, o.z] : null;
|
|
63
64
|
}
|
|
64
|
-
}) :
|
|
65
|
-
return
|
|
66
|
-
var
|
|
67
|
-
const
|
|
68
|
-
if (!
|
|
69
|
-
let
|
|
70
|
-
return (
|
|
71
|
-
var
|
|
72
|
-
|
|
65
|
+
}) : i.addEmitter(B, V.current);
|
|
66
|
+
return X(() => {
|
|
67
|
+
var d, m;
|
|
68
|
+
const i = p.current;
|
|
69
|
+
if (!i) return;
|
|
70
|
+
let o = !1;
|
|
71
|
+
return (m = (d = S.current) == null ? void 0 : d.remove) == null || m.call(d), S.current = null, U(i).then((c) => {
|
|
72
|
+
var M;
|
|
73
|
+
o ? (M = c == null ? void 0 : c.remove) == null || M.call(c) : S.current = c;
|
|
73
74
|
}), () => {
|
|
74
|
-
|
|
75
|
+
o = !0;
|
|
75
76
|
};
|
|
76
|
-
}, [
|
|
77
|
-
var
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
77
|
+
}, [B]), X(() => {
|
|
78
|
+
var d;
|
|
79
|
+
if (typeof window > "u" || !window.matchMedia) return;
|
|
80
|
+
const i = window.matchMedia("(prefers-reduced-motion: reduce)"), o = () => {
|
|
81
|
+
H.current = i.matches;
|
|
82
|
+
};
|
|
83
|
+
return o(), (d = i.addEventListener) == null || d.call(i, "change", o), () => {
|
|
84
|
+
var m;
|
|
85
|
+
return (m = i.removeEventListener) == null ? void 0 : m.call(i, "change", o);
|
|
86
|
+
};
|
|
87
|
+
}, []), X(() => () => {
|
|
88
|
+
var i, o, d, m;
|
|
89
|
+
(o = (i = S.current) == null ? void 0 : i.remove) == null || o.call(i), (m = (d = p.current) == null ? void 0 : d.destroy) == null || m.call(d), p.current = null, S.current = null, D.current = !1;
|
|
90
|
+
}, []), J((i) => {
|
|
91
|
+
i.gl.render(i.scene, i.camera);
|
|
92
|
+
const o = performance.now(), d = L.current ? Math.min(0.05, (o - L.current) / 1e3) : 0.016;
|
|
93
|
+
L.current = o;
|
|
94
|
+
const m = i.gl, c = m.backend;
|
|
95
|
+
!p.current && !D.current && (c != null && c.device) && (c != null && c.context) && (D.current = !0, Q(
|
|
96
|
+
{ device: c.device, context: c.context, canvas: m.domElement },
|
|
97
|
+
{ getSceneDepth: T ? () => null : Y(m) }
|
|
98
|
+
).then((f) => (p.current = f, U(f))).then((f) => {
|
|
99
|
+
S.current = f;
|
|
100
|
+
}).catch((f) => console.error("[HZFaithfulFX] init failed:", f)));
|
|
101
|
+
const M = p.current;
|
|
102
|
+
if (M) {
|
|
103
|
+
const f = i.camera;
|
|
104
|
+
M.setCamera(f.projectionMatrix.elements, f.matrixWorldInverse.elements, f.position), z && H.current || M.render(d);
|
|
94
105
|
}
|
|
95
|
-
},
|
|
106
|
+
}, x), null;
|
|
96
107
|
}
|
|
97
108
|
const te = (
|
|
98
109
|
/* glsl */
|
|
@@ -116,58 +127,58 @@ void main() {
|
|
|
116
127
|
function se({
|
|
117
128
|
positionRef: r,
|
|
118
129
|
duration: t = 1,
|
|
119
|
-
width:
|
|
130
|
+
width: v = 0.3,
|
|
120
131
|
color: e = [1, 1, 1],
|
|
121
|
-
maxPoints:
|
|
122
|
-
minDistance:
|
|
123
|
-
opacity:
|
|
124
|
-
blending:
|
|
125
|
-
visible:
|
|
132
|
+
maxPoints: a = 256,
|
|
133
|
+
minDistance: x = 0.05,
|
|
134
|
+
opacity: T = 1,
|
|
135
|
+
blending: z = s.AdditiveBlending,
|
|
136
|
+
visible: p = !0
|
|
126
137
|
}) {
|
|
127
|
-
const { camera:
|
|
128
|
-
positions: new Float32Array(
|
|
129
|
-
times: new Float32Array(
|
|
138
|
+
const { camera: S } = N(), D = I(null), L = I({
|
|
139
|
+
positions: new Float32Array(a * 3),
|
|
140
|
+
times: new Float32Array(a),
|
|
130
141
|
head: 0,
|
|
131
142
|
count: 0,
|
|
132
143
|
lastPos: new s.Vector3(1 / 0, 1 / 0, 1 / 0),
|
|
133
144
|
elapsed: 0
|
|
134
|
-
}), { geometry: C, posAttr:
|
|
135
|
-
const
|
|
136
|
-
|
|
145
|
+
}), { geometry: C, posAttr: V, colorAttr: H, indexBuf: B } = b(() => {
|
|
146
|
+
const M = a * 2, f = new Float32Array(M * 3), n = new Float32Array(M * 4), R = new s.BufferGeometry(), q = new s.BufferAttribute(f, 3);
|
|
147
|
+
q.setUsage(s.DynamicDrawUsage), R.setAttribute("position", q);
|
|
137
148
|
const g = new s.BufferAttribute(n, 4);
|
|
138
149
|
g.setUsage(s.DynamicDrawUsage), R.setAttribute("aColor", g);
|
|
139
|
-
const
|
|
140
|
-
for (let
|
|
141
|
-
const
|
|
142
|
-
|
|
150
|
+
const A = (a - 1) * 6, l = new Uint32Array(A);
|
|
151
|
+
for (let F = 0; F < a - 1; F++) {
|
|
152
|
+
const u = F * 2, w = F * 6;
|
|
153
|
+
l[w] = u, l[w + 1] = u + 1, l[w + 2] = u + 2, l[w + 3] = u + 1, l[w + 4] = u + 3, l[w + 5] = u + 2;
|
|
143
154
|
}
|
|
144
|
-
const
|
|
145
|
-
return R.setIndex(
|
|
146
|
-
}, [
|
|
155
|
+
const E = new s.BufferAttribute(l, 1);
|
|
156
|
+
return R.setIndex(E), R.setDrawRange(0, 0), { geometry: R, posAttr: q, colorAttr: g, indexBuf: E };
|
|
157
|
+
}, [a]), U = b(() => new s.ShaderMaterial({
|
|
147
158
|
vertexShader: te,
|
|
148
159
|
fragmentShader: ne,
|
|
149
160
|
transparent: !0,
|
|
150
161
|
depthWrite: !1,
|
|
151
162
|
side: s.DoubleSide,
|
|
152
|
-
blending:
|
|
153
|
-
}), [
|
|
154
|
-
return J((
|
|
155
|
-
if (!
|
|
156
|
-
const n =
|
|
157
|
-
if (n.elapsed +=
|
|
163
|
+
blending: z
|
|
164
|
+
}), [z]), i = b(() => new s.Vector3(), []), o = b(() => new s.Vector3(), []), d = b(() => new s.Vector3(), []), m = b(() => new s.Vector3(0, 1, 0), []), c = b(() => new s.Vector3(), []);
|
|
165
|
+
return J((M, f) => {
|
|
166
|
+
if (!D.current) return;
|
|
167
|
+
const n = L.current;
|
|
168
|
+
if (n.elapsed += f, !p) {
|
|
158
169
|
n.count = 0, n.head = 0, n.lastPos.set(1 / 0, 1 / 0, 1 / 0), C.setDrawRange(0, 0);
|
|
159
170
|
return;
|
|
160
171
|
}
|
|
161
172
|
const R = r.current;
|
|
162
173
|
if (!R) return;
|
|
163
|
-
if (n.lastPos.distanceTo(R) >=
|
|
164
|
-
const
|
|
165
|
-
n.positions[
|
|
174
|
+
if (n.lastPos.distanceTo(R) >= x) {
|
|
175
|
+
const u = (n.head + n.count) % a;
|
|
176
|
+
n.positions[u * 3] = R.x, n.positions[u * 3 + 1] = R.y, n.positions[u * 3 + 2] = R.z, n.times[u] = n.elapsed, n.count < a ? n.count++ : n.head = (n.head + 1) % a, n.lastPos.copy(R);
|
|
166
177
|
}
|
|
167
178
|
for (; n.count > 0; ) {
|
|
168
|
-
const
|
|
169
|
-
if (n.elapsed - n.times[
|
|
170
|
-
n.head = (n.head + 1) %
|
|
179
|
+
const u = n.head;
|
|
180
|
+
if (n.elapsed - n.times[u] > t)
|
|
181
|
+
n.head = (n.head + 1) % a, n.count--;
|
|
171
182
|
else
|
|
172
183
|
break;
|
|
173
184
|
}
|
|
@@ -175,42 +186,42 @@ function se({
|
|
|
175
186
|
C.setDrawRange(0, 0);
|
|
176
187
|
return;
|
|
177
188
|
}
|
|
178
|
-
const g =
|
|
179
|
-
let
|
|
180
|
-
const
|
|
181
|
-
for (let
|
|
182
|
-
const
|
|
183
|
-
if (
|
|
184
|
-
const _ = (n.head +
|
|
185
|
-
|
|
186
|
-
n.positions[_ * 3] -
|
|
187
|
-
n.positions[_ * 3 + 1] -
|
|
188
|
-
n.positions[_ * 3 + 2] -
|
|
189
|
+
const g = V.array, A = H.array;
|
|
190
|
+
let l = null;
|
|
191
|
+
const E = n.count;
|
|
192
|
+
for (let u = 0; u < E; u++) {
|
|
193
|
+
const w = (n.head + u) % a, P = n.positions[w * 3], W = n.positions[w * 3 + 1], j = n.positions[w * 3 + 2], Z = 1 - (n.elapsed - n.times[w]) / t;
|
|
194
|
+
if (u < E - 1) {
|
|
195
|
+
const _ = (n.head + u + 1) % a;
|
|
196
|
+
i.set(
|
|
197
|
+
n.positions[_ * 3] - P,
|
|
198
|
+
n.positions[_ * 3 + 1] - W,
|
|
199
|
+
n.positions[_ * 3 + 2] - j
|
|
189
200
|
);
|
|
190
|
-
const
|
|
191
|
-
|
|
192
|
-
} else
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
),
|
|
198
|
-
let
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
g[
|
|
201
|
+
const k = i.length();
|
|
202
|
+
k > 1e-6 ? i.divideScalar(k) : l && i.copy(l);
|
|
203
|
+
} else l && i.copy(l);
|
|
204
|
+
d.set(
|
|
205
|
+
S.position.x - P,
|
|
206
|
+
S.position.y - W,
|
|
207
|
+
S.position.z - j
|
|
208
|
+
), o.crossVectors(i, d);
|
|
209
|
+
let O = o.length();
|
|
210
|
+
O < 1e-6 && (c.crossVectors(i, m), o.copy(c), O = o.length(), O < 1e-6 && (o.set(1, 0, 0), O = 1)), o.divideScalar(O);
|
|
211
|
+
const y = v * Z, G = T * Z * Z, h = u * 2;
|
|
212
|
+
g[h * 3] = P + o.x * y, g[h * 3 + 1] = W + o.y * y, g[h * 3 + 2] = j + o.z * y, g[(h + 1) * 3] = P - o.x * y, g[(h + 1) * 3 + 1] = W - o.y * y, g[(h + 1) * 3 + 2] = j - o.z * y, A[h * 4] = e[0], A[h * 4 + 1] = e[1], A[h * 4 + 2] = e[2], A[h * 4 + 3] = G, A[(h + 1) * 4] = e[0], A[(h + 1) * 4 + 1] = e[1], A[(h + 1) * 4 + 2] = e[2], A[(h + 1) * 4 + 3] = G, l = l || new s.Vector3(), l.copy(i);
|
|
202
213
|
}
|
|
203
|
-
const
|
|
204
|
-
C.setDrawRange(0,
|
|
214
|
+
const F = (E - 1) * 6;
|
|
215
|
+
C.setDrawRange(0, F), V.needsUpdate = !0, H.needsUpdate = !0;
|
|
205
216
|
}), /* @__PURE__ */ $(
|
|
206
217
|
"mesh",
|
|
207
218
|
{
|
|
208
|
-
ref:
|
|
219
|
+
ref: D,
|
|
209
220
|
geometry: C,
|
|
210
|
-
material:
|
|
221
|
+
material: U,
|
|
211
222
|
frustumCulled: !1,
|
|
212
223
|
renderOrder: 101,
|
|
213
|
-
visible:
|
|
224
|
+
visible: p
|
|
214
225
|
}
|
|
215
226
|
);
|
|
216
227
|
}
|
|
@@ -221,36 +232,36 @@ function re(r) {
|
|
|
221
232
|
const t = Math.sin(r * 54321.67) * 43758.5453 % 1;
|
|
222
233
|
return t < 0 ? t + 1 : t;
|
|
223
234
|
}
|
|
224
|
-
function
|
|
225
|
-
if (
|
|
226
|
-
const
|
|
227
|
-
let
|
|
235
|
+
function le(r, t, v, e) {
|
|
236
|
+
if (v <= 0) return 0;
|
|
237
|
+
const a = t / v;
|
|
238
|
+
let x = r.particleSize ?? 0.5;
|
|
228
239
|
if (r.randomSize) {
|
|
229
|
-
const
|
|
230
|
-
|
|
240
|
+
const z = r.minSize ?? 0.1, p = r.maxSize ?? 0.5;
|
|
241
|
+
x = z + (p - z) * re(v);
|
|
231
242
|
}
|
|
232
|
-
const
|
|
233
|
-
if (r.fadeSizeEnabled && (
|
|
234
|
-
const
|
|
235
|
-
|
|
243
|
+
const T = Math.max(0.01, Math.min(10, r.sizeLifetimeSpeed ?? 1));
|
|
244
|
+
if (r.fadeSizeEnabled && (x *= 1 - Math.pow(a, 1 / T)), r.increaseSizeEnabled && (x *= 1 + Math.pow(a, 1 / T)), r.pulseEnabled) {
|
|
245
|
+
const z = r.pulseAmplitude ?? 0.5, p = r.pulseFrequency ?? 1, D = (r.pulsePhaseRandom ?? 0) * K(e) * Math.PI * 2;
|
|
246
|
+
x *= 1 + z * Math.sin(t * p * Math.PI * 2 + D);
|
|
236
247
|
}
|
|
237
|
-
return Math.max(0,
|
|
248
|
+
return Math.max(0, x);
|
|
238
249
|
}
|
|
239
|
-
function pe(r, t,
|
|
240
|
-
if (
|
|
241
|
-
let
|
|
242
|
-
const
|
|
243
|
-
if (r.fadeEnabled && (
|
|
244
|
-
const
|
|
245
|
-
|
|
250
|
+
function pe(r, t, v, e) {
|
|
251
|
+
if (v <= 0) return 0;
|
|
252
|
+
let a = r.opacity ?? 1;
|
|
253
|
+
const x = t / v;
|
|
254
|
+
if (r.fadeEnabled && (a *= Math.max(0, 1 - x)), r.pulseEnabled && r.pulseOpacity) {
|
|
255
|
+
const T = r.pulseAmplitude ?? 0.5, z = r.pulseFrequency ?? 1, S = (r.pulsePhaseRandom ?? 0) * K(e) * Math.PI * 2;
|
|
256
|
+
a *= Math.max(0, 1 + T * Math.sin(t * z * Math.PI * 2 + S));
|
|
246
257
|
}
|
|
247
|
-
return Math.max(0, Math.min(1,
|
|
258
|
+
return Math.max(0, Math.min(1, a));
|
|
248
259
|
}
|
|
249
260
|
export {
|
|
250
|
-
|
|
261
|
+
de as HZFaithfulFX,
|
|
251
262
|
se as HZTrailRibbon,
|
|
252
263
|
pe as computeParticleOpacity,
|
|
253
|
-
|
|
264
|
+
le as computeParticleSize,
|
|
254
265
|
he as fetchPreset,
|
|
255
266
|
K as particleHash,
|
|
256
267
|
ee as scalePreset
|