hz-particles 1.0.13 → 1.0.14

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