@vfx-js/effects 1.0.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.
Files changed (71) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +58 -0
  3. package/lib/cjs/_curl-noise.d.ts +3 -0
  4. package/lib/cjs/_curl-noise.js +115 -0
  5. package/lib/cjs/_curl-noise.js.map +1 -0
  6. package/lib/cjs/_particle-common.d.ts +10 -0
  7. package/lib/cjs/_particle-common.js +98 -0
  8. package/lib/cjs/_particle-common.js.map +1 -0
  9. package/lib/cjs/bloom.d.ts +50 -0
  10. package/lib/cjs/bloom.js +452 -0
  11. package/lib/cjs/bloom.js.map +1 -0
  12. package/lib/cjs/fluid.d.ts +35 -0
  13. package/lib/cjs/fluid.js +407 -0
  14. package/lib/cjs/fluid.js.map +1 -0
  15. package/lib/cjs/halftone.d.ts +65 -0
  16. package/lib/cjs/halftone.js +272 -0
  17. package/lib/cjs/halftone.js.map +1 -0
  18. package/lib/cjs/index.d.ts +8 -0
  19. package/lib/cjs/index.js +20 -0
  20. package/lib/cjs/index.js.map +1 -0
  21. package/lib/cjs/package.json +57 -0
  22. package/lib/cjs/particle-explode.d.ts +48 -0
  23. package/lib/cjs/particle-explode.js +466 -0
  24. package/lib/cjs/particle-explode.js.map +1 -0
  25. package/lib/cjs/particle.d.ts +78 -0
  26. package/lib/cjs/particle.js +710 -0
  27. package/lib/cjs/particle.js.map +1 -0
  28. package/lib/cjs/pixelate.d.ts +11 -0
  29. package/lib/cjs/pixelate.js +48 -0
  30. package/lib/cjs/pixelate.js.map +1 -0
  31. package/lib/cjs/scanline.d.ts +11 -0
  32. package/lib/cjs/scanline.js +48 -0
  33. package/lib/cjs/scanline.js.map +1 -0
  34. package/lib/cjs/voronoi.d.ts +35 -0
  35. package/lib/cjs/voronoi.js +266 -0
  36. package/lib/cjs/voronoi.js.map +1 -0
  37. package/lib/esm/_curl-noise.d.ts +3 -0
  38. package/lib/esm/_curl-noise.js +112 -0
  39. package/lib/esm/_curl-noise.js.map +1 -0
  40. package/lib/esm/_particle-common.d.ts +10 -0
  41. package/lib/esm/_particle-common.js +91 -0
  42. package/lib/esm/_particle-common.js.map +1 -0
  43. package/lib/esm/bloom.d.ts +50 -0
  44. package/lib/esm/bloom.js +448 -0
  45. package/lib/esm/bloom.js.map +1 -0
  46. package/lib/esm/fluid.d.ts +35 -0
  47. package/lib/esm/fluid.js +403 -0
  48. package/lib/esm/fluid.js.map +1 -0
  49. package/lib/esm/halftone.d.ts +65 -0
  50. package/lib/esm/halftone.js +268 -0
  51. package/lib/esm/halftone.js.map +1 -0
  52. package/lib/esm/index.d.ts +8 -0
  53. package/lib/esm/index.js +9 -0
  54. package/lib/esm/index.js.map +1 -0
  55. package/lib/esm/package.json +57 -0
  56. package/lib/esm/particle-explode.d.ts +48 -0
  57. package/lib/esm/particle-explode.js +462 -0
  58. package/lib/esm/particle-explode.js.map +1 -0
  59. package/lib/esm/particle.d.ts +78 -0
  60. package/lib/esm/particle.js +706 -0
  61. package/lib/esm/particle.js.map +1 -0
  62. package/lib/esm/pixelate.d.ts +11 -0
  63. package/lib/esm/pixelate.js +44 -0
  64. package/lib/esm/pixelate.js.map +1 -0
  65. package/lib/esm/scanline.d.ts +11 -0
  66. package/lib/esm/scanline.js +44 -0
  67. package/lib/esm/scanline.js.map +1 -0
  68. package/lib/esm/voronoi.d.ts +35 -0
  69. package/lib/esm/voronoi.js +262 -0
  70. package/lib/esm/voronoi.js.map +1 -0
  71. package/package.json +69 -0
@@ -0,0 +1,710 @@
1
+ "use strict";
2
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
+ };
7
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
8
+ if (kind === "m") throw new TypeError("Private method is not writable");
9
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
10
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
11
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
12
+ };
13
+ var _ParticleEffect_instances, _ParticleEffect_params, _ParticleEffect_posTex, _ParticleEffect_colorTex, _ParticleEffect_velTex, _ParticleEffect_stampTex, _ParticleEffect_trail, _ParticleEffect_initialized, _ParticleEffect_stateSize, _ParticleEffect_stateCapacity, _ParticleEffect_spawnUniform, _ParticleEffect_spawnRawTex, _ParticleEffect_spawnTexHandle, _ParticleEffect_spawnGeometry, _ParticleEffect_particleGeometry, _ParticleEffect_gl, _ParticleEffect_contextRestoredUnsub, _ParticleEffect_nextSlot, _ParticleEffect_birthAccumulator, _ParticleEffect_screenBirthAccumulator, _ParticleEffect_lastMouseUv, _ParticleEffect_lastMoveTime, _ParticleEffect_allocStateRTs, _ParticleEffect_disposeStateRTs, _ParticleEffect_createSpawnTex, _ParticleEffect_allocSpawnTextures, _ParticleEffect_uploadSpawnTextures, _ParticleEffect_scheduleSpawns, _ParticleEffect_cap;
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ParticleEffect = void 0;
16
+ const _curl_noise_1 = require("./_curl-noise");
17
+ const _particle_common_1 = require("./_particle-common");
18
+ // State texture footprint: 4 internal buffers total (pos persistent =
19
+ // 2 internal, color + vel single = 1 each) × stateSize² × 16 B =
20
+ // 64 MB at 1024 (RGBA32F) / 32 MB at RGBA16F fallback at the 1M cap.
21
+ // color/vel can be single-buffer because only the spawn pass writes
22
+ // to them and the other texels persist naturally.
23
+ // Per-frame spawn budget. Spawn entries are uploaded to a square data
24
+ // texture (vec4 per entry: slotId, uvX, uvY, dirAngle) sampled by the
25
+ // gl.POINTS spawn pass. dirAngle = theta in [0, 2π) for mouse spawns,
26
+ // -1 sentinel for screen spawns (no radial impulse). lifeJitter is
27
+ // derived on the GPU via hash. 64×64 = 4096 spawns/frame ≈ 245k
28
+ // spawns/sec at 60 fps.
29
+ const SPAWN_TEX_SIZE = 64;
30
+ const MAX_SPAWNS_PER_FRAME = SPAWN_TEX_SIZE * SPAWN_TEX_SIZE;
31
+ // Active mouse if it moved within this window (sec) — otherwise spawn
32
+ // only when `params.spawnOnIdle` is set.
33
+ const IDLE_THRESHOLD = 0.1;
34
+ const SPAWN_TEX_SIZE_VEC = [SPAWN_TEX_SIZE, SPAWN_TEX_SIZE];
35
+ // Vertex index per spawn slot. Read in VERT_SPAWN as `int(position)` to
36
+ // pick the right entry in uSpawnTex without depending on gl_VertexID,
37
+ // and to give EffectGeometry a `position` attribute it can count.
38
+ const SPAWN_VERTEX_INDICES = new Float32Array(MAX_SPAWNS_PER_FRAME);
39
+ for (let i = 0; i < MAX_SPAWNS_PER_FRAME; i++) {
40
+ SPAWN_VERTEX_INDICES[i] = i;
41
+ }
42
+ // age = 2.0 keeps every slot dead until UPDATE writes a fresh particle.
43
+ const FRAG_INIT_POS = `#version 300 es
44
+ precision highp float;
45
+ out vec4 outColor;
46
+ void main() {
47
+ outColor = vec4(0.0, 0.0, 0.0, 2.0);
48
+ }
49
+ `;
50
+ const FRAG_INIT_COLOR = `#version 300 es
51
+ precision highp float;
52
+ out vec4 outColor;
53
+ void main() {
54
+ outColor = vec4(0.0);
55
+ }
56
+ `;
57
+ const VERT_PARTICLE = `#version 300 es
58
+ precision highp float;
59
+ in vec2 position;
60
+
61
+ uniform sampler2D posTex;
62
+ uniform sampler2D colorTex;
63
+ uniform vec2 stateSize;
64
+ uniform float pointSize;
65
+ uniform vec2 elementPixel;
66
+ uniform int particleCount;
67
+ uniform float alpha;
68
+ uniform float alphaDecay;
69
+ uniform float fadeIn;
70
+ uniform float fog;
71
+ uniform vec4 contentRectUv;
72
+
73
+ out vec2 vCorner;
74
+ out vec4 vColor;
75
+
76
+ void main() {
77
+ int id = gl_InstanceID;
78
+ if (id >= particleCount) {
79
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
80
+ vCorner = vec2(0.0);
81
+ vColor = vec4(0.0);
82
+ return;
83
+ }
84
+ int sx = id % int(stateSize.x);
85
+ int sy = id / int(stateSize.x);
86
+ vec2 stateUv = (vec2(float(sx), float(sy)) + 0.5) / stateSize;
87
+ vec4 s = texture(posTex, stateUv);
88
+ vec4 c = texture(colorTex, stateUv);
89
+
90
+ float age = s.w;
91
+ // smoothstep rise to ~1 at age=fadeIn, then pow-shaped decay to 0
92
+ // at age=1. Small fadeIn keeps the radial-emit phase visible;
93
+ // larger values restore the slow fade-in look.
94
+ float rise = fadeIn > 0.0 ? smoothstep(0.0, fadeIn, age) : 1.0;
95
+ float fall = pow(max(1.0 - age, 0.0), alphaDecay);
96
+ float lifeAlpha = rise * fall;
97
+ if (lifeAlpha <= 0.0) {
98
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
99
+ vCorner = vec2(0.0);
100
+ vColor = vec4(0.0);
101
+ return;
102
+ }
103
+
104
+ float fogFactor = fog > 0.0
105
+ ? mix(1.0, smoothstep(1.0, -0.5, s.z), fog)
106
+ : 1.0;
107
+
108
+ vec2 bufferUv = contentRectUv.xy + s.xy * contentRectUv.zw;
109
+ vec2 ndcPos = bufferUv * 2.0 - 1.0;
110
+
111
+ vec2 bufferPixel = elementPixel / max(contentRectUv.zw, vec2(1e-6));
112
+ vec2 ndcOffset = position * pointSize * 2.0 / bufferPixel;
113
+ gl_Position = vec4(ndcPos + ndcOffset, 0.0, 1.0);
114
+
115
+ vCorner = position;
116
+ vColor = vec4(c.rgb, lifeAlpha * alpha * fogFactor);
117
+ }
118
+ `;
119
+ const FRAG_OUTPUT = `#version 300 es
120
+ precision highp float;
121
+ in vec2 uv;
122
+ in vec2 uvSrc;
123
+ out vec4 outColor;
124
+
125
+ uniform sampler2D src;
126
+ uniform sampler2D trail;
127
+ uniform float srcOpacity;
128
+
129
+ void main() {
130
+ // src is element-sized; the trail buffer extends to the canvas, so
131
+ // mask src outside [0,1].
132
+ vec2 inside = step(vec2(0.0), uvSrc) * step(uvSrc, vec2(1.0));
133
+ float srcMask = inside.x * inside.y;
134
+ vec4 base = texture(src, clamp(uvSrc, 0.0, 1.0))
135
+ * srcOpacity * srcMask;
136
+ vec4 t = texture(trail, uv);
137
+ outColor = vec4(base.rgb * (1.0 - t.a) + t.rgb, max(base.a, t.a));
138
+ }
139
+ `;
140
+ // Full-screen advect pass. Reads posTex (and colorTex.w for life
141
+ // jitter), blends a radial impulse (from velTex, set at spawn) with the
142
+ // curl-noise field as the particle ages. Spawns are written separately
143
+ // by the gl.POINTS spawn pass below.
144
+ const FRAG_ADVECT_POS = `#version 300 es
145
+ precision highp float;
146
+ in vec2 uv;
147
+ out vec4 outColor;
148
+
149
+ uniform sampler2D posTex;
150
+ uniform sampler2D colorTex;
151
+ uniform sampler2D velTex;
152
+ uniform vec2 elementPixel;
153
+ uniform float time;
154
+ uniform float dt;
155
+ uniform float noiseSpeed;
156
+ uniform float emitSpeed;
157
+ uniform float noiseDelay;
158
+ uniform float noiseScale;
159
+ uniform float noiseAnimation;
160
+ uniform float speedDecay;
161
+ uniform float life;
162
+ ${_curl_noise_1.GLSL_CURL_NOISE}
163
+
164
+ void main() {
165
+ vec4 s = texture(posTex, uv);
166
+ float age = s.w;
167
+ if (age >= 1.0) {
168
+ outColor = s;
169
+ return;
170
+ }
171
+
172
+ vec3 curlV = sampleCurl(s.xyz, elementPixel, noiseScale, time * noiseAnimation);
173
+
174
+ // velTex.xy is a unit direction in pixel space (0 for screen
175
+ // spawns). Multiplying by shortAxis/elementPixel converts to a
176
+ // uv-space velocity that's isotropic in screen px (circular blast
177
+ // on non-square elements) and short-axis-normalized so emitSpeed
178
+ // and noiseSpeed share the same uv/sec scale.
179
+ vec2 radialDirPx = texture(velTex, uv).xy;
180
+ float shortAxis = min(elementPixel.x, elementPixel.y);
181
+ vec3 radialV = vec3(
182
+ radialDirPx * shortAxis / max(elementPixel, vec2(1.0)),
183
+ 0.0
184
+ );
185
+
186
+ float blend = noiseDelay > 0.0 ? smoothstep(0.0, noiseDelay, age) : 1.0;
187
+ vec3 v = mix(radialV * emitSpeed, curlV * noiseSpeed, blend);
188
+
189
+ float taper = pow(clamp(1.0 - age, 0.0, 1.0), speedDecay);
190
+ vec3 pos = s.xyz + v * dt * taper;
191
+
192
+ float lifeMul = max(texture(colorTex, uv).w, 1e-3);
193
+ age += dt / (max(life, 1e-3) * lifeMul);
194
+
195
+ outColor = vec4(pos, age);
196
+ }
197
+ `;
198
+ // Spawn pass: gl.POINTS, one point per spawn entry. Each vertex pulls
199
+ // (slotId, uvX, uvY, dirAngle) from uSpawnTex, computes the target
200
+ // state texel center as gl_Position, and writes a single texel of the
201
+ // pos / color / vel RT. The `position` attribute carries the spawn-slot
202
+ // index (0..MAX-1) and gives EffectGeometry its vertex count.
203
+ const VERT_SPAWN = `#version 300 es
204
+ precision highp float;
205
+ in float position;
206
+
207
+ uniform sampler2D uSpawnTex;
208
+ uniform vec2 uSpawnTexSize;
209
+ uniform int uSpawnCount;
210
+ uniform vec2 stateSize;
211
+
212
+ out vec4 vSpawn;
213
+
214
+ void main() {
215
+ int idx = int(position);
216
+ if (idx >= uSpawnCount) {
217
+ gl_Position = vec4(2.0, 2.0, 2.0, 1.0);
218
+ gl_PointSize = 0.0;
219
+ vSpawn = vec4(0.0);
220
+ return;
221
+ }
222
+ int sx = idx % int(uSpawnTexSize.x);
223
+ int sy = idx / int(uSpawnTexSize.x);
224
+ vec4 s = texelFetch(uSpawnTex, ivec2(sx, sy), 0);
225
+ int slot = int(s.x);
226
+ int tx = slot % int(stateSize.x);
227
+ int ty = slot / int(stateSize.x);
228
+ vec2 ndc = (vec2(float(tx), float(ty)) + 0.5) / stateSize * 2.0 - 1.0;
229
+ gl_Position = vec4(ndc, 0.0, 1.0);
230
+ gl_PointSize = 1.0;
231
+ vSpawn = s;
232
+ }
233
+ `;
234
+ const FRAG_SPAWN_POS = `#version 300 es
235
+ precision highp float;
236
+ in vec4 vSpawn;
237
+ out vec4 outColor;
238
+
239
+ uniform sampler2D src;
240
+ uniform float alphaThreshold;
241
+
242
+ void main() {
243
+ vec2 spawnUv = vSpawn.yz;
244
+ vec2 inside = step(vec2(0.0), spawnUv) * step(spawnUv, vec2(1.0));
245
+ float visible = inside.x * inside.y;
246
+ float a = texture(src, clamp(spawnUv, 0.0, 1.0)).a * visible;
247
+ if (a < alphaThreshold) {
248
+ outColor = vec4(0.0, 0.0, 0.0, 2.0); // born dead
249
+ return;
250
+ }
251
+ outColor = vec4(spawnUv, 0.0, 0.0);
252
+ }
253
+ `;
254
+ // lifeJitter is hashed from the spawn entry (slot id + uv) to keep
255
+ // every spawn varied without a CPU-side random.
256
+ const FRAG_SPAWN_COLOR = `#version 300 es
257
+ precision highp float;
258
+ in vec4 vSpawn;
259
+ out vec4 outColor;
260
+
261
+ uniform sampler2D src;
262
+ uniform vec3 color;
263
+ uniform float colorMix;
264
+ uniform vec2 lifeJitterRange;
265
+ ${_particle_common_1.GLSL_HASH}
266
+
267
+ void main() {
268
+ vec4 c = texture(src, clamp(vSpawn.yz, 0.0, 1.0));
269
+ float h = hash21(vSpawn.yz + vec2(vSpawn.x) * 1.7);
270
+ float lifeJitter = mix(lifeJitterRange.x, lifeJitterRange.y, h);
271
+ outColor = vec4(mix(c.rgb, color, colorMix), lifeJitter);
272
+ }
273
+ `;
274
+ // Writes the radial direction (unit vector in pixel space) per spawn
275
+ // slot from vSpawn.w (theta). Screen spawns carry -1 sentinel and get
276
+ // zero velocity so they receive only curl-noise advection.
277
+ const FRAG_SPAWN_VEL = `#version 300 es
278
+ precision highp float;
279
+ in vec4 vSpawn;
280
+ out vec4 outColor;
281
+ void main() {
282
+ float theta = vSpawn.w;
283
+ vec2 dir = theta >= 0.0 ? vec2(cos(theta), sin(theta)) : vec2(0.0);
284
+ outColor = vec4(dir, 0.0, 0.0);
285
+ }
286
+ `;
287
+ const DEFAULT_PARAMS = {
288
+ count: 1024 * 1024,
289
+ birthRate: 30000,
290
+ screenBirthRate: 10000,
291
+ life: 1.0,
292
+ noiseSpeed: 0.3,
293
+ emitSpeed: 1.0,
294
+ noiseDelay: 0.15,
295
+ noiseScale: 1,
296
+ noiseAnimation: 0.3,
297
+ pointSize: 10.0,
298
+ alpha: 1,
299
+ radius: 300,
300
+ speedDecay: 1.0,
301
+ alphaDecay: 5.0,
302
+ fadeIn: 0.05,
303
+ alphaThreshold: 0.05,
304
+ spawnOnIdle: true,
305
+ srcOpacity: 0.0,
306
+ trailFade: 0.75,
307
+ fog: 0.5,
308
+ color: 0xffffff,
309
+ colorMix: 0.0,
310
+ blend: "add",
311
+ };
312
+ class ParticleEffect {
313
+ /** Read-only view of the current params. Use `setParam(key, value)`
314
+ * to mutate so values like `count` are sanitized. (External tools
315
+ * such as tweakpane bind directly to the underlying object and
316
+ * skip the validation; the type marker is for programmatic use.) */
317
+ get params() {
318
+ return __classPrivateFieldGet(this, _ParticleEffect_params, "f");
319
+ }
320
+ constructor(initial = {}) {
321
+ _ParticleEffect_instances.add(this);
322
+ _ParticleEffect_params.set(this, void 0);
323
+ _ParticleEffect_posTex.set(this, null);
324
+ _ParticleEffect_colorTex.set(this, null);
325
+ _ParticleEffect_velTex.set(this, null);
326
+ _ParticleEffect_stampTex.set(this, null);
327
+ _ParticleEffect_trail.set(this, null);
328
+ _ParticleEffect_initialized.set(this, false);
329
+ _ParticleEffect_stateSize.set(this, void 0);
330
+ _ParticleEffect_stateCapacity.set(this, void 0);
331
+ _ParticleEffect_spawnUniform.set(this, new Float32Array(MAX_SPAWNS_PER_FRAME * 4));
332
+ _ParticleEffect_spawnRawTex.set(this, null);
333
+ _ParticleEffect_spawnTexHandle.set(this, null);
334
+ _ParticleEffect_spawnGeometry.set(this, null);
335
+ _ParticleEffect_particleGeometry.set(this, null);
336
+ _ParticleEffect_gl.set(this, null);
337
+ _ParticleEffect_contextRestoredUnsub.set(this, null);
338
+ _ParticleEffect_nextSlot.set(this, 0);
339
+ _ParticleEffect_birthAccumulator.set(this, 0);
340
+ _ParticleEffect_screenBirthAccumulator.set(this, 0);
341
+ _ParticleEffect_lastMouseUv.set(this, null);
342
+ _ParticleEffect_lastMoveTime.set(this, -Infinity);
343
+ __classPrivateFieldSet(this, _ParticleEffect_params, { ...DEFAULT_PARAMS, ...initial }, "f");
344
+ __classPrivateFieldGet(this, _ParticleEffect_params, "f").count = (0, _particle_common_1.sanitizeCount)(__classPrivateFieldGet(this, _ParticleEffect_params, "f").count);
345
+ __classPrivateFieldSet(this, _ParticleEffect_stateSize, (0, _particle_common_1.stateSizeFromCount)(__classPrivateFieldGet(this, _ParticleEffect_params, "f").count), "f");
346
+ __classPrivateFieldSet(this, _ParticleEffect_stateCapacity, __classPrivateFieldGet(this, _ParticleEffect_stateSize, "f") * __classPrivateFieldGet(this, _ParticleEffect_stateSize, "f"), "f");
347
+ }
348
+ get maxCount() {
349
+ return __classPrivateFieldGet(this, _ParticleEffect_stateCapacity, "f");
350
+ }
351
+ /** Validated bulk setter. Pass any subset of params; bad inputs
352
+ * (NaN / negative `count`, etc) are coerced to valid values
353
+ * before applying. */
354
+ setParam(updates) {
355
+ const target = __classPrivateFieldGet(this, _ParticleEffect_params, "f");
356
+ for (const [k, v] of Object.entries(updates)) {
357
+ if (v === undefined) {
358
+ continue;
359
+ }
360
+ target[k] = k === "count" ? (0, _particle_common_1.sanitizeCount)(v) : v;
361
+ }
362
+ }
363
+ init(ctx) {
364
+ __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_allocStateRTs).call(this, ctx);
365
+ __classPrivateFieldSet(this, _ParticleEffect_stampTex, ctx.createRenderTarget({
366
+ float: false,
367
+ wrap: "clamp",
368
+ filter: "linear",
369
+ }), "f");
370
+ __classPrivateFieldSet(this, _ParticleEffect_trail, ctx.createRenderTarget({
371
+ float: false,
372
+ persistent: true,
373
+ wrap: "clamp",
374
+ filter: "linear",
375
+ }), "f");
376
+ __classPrivateFieldSet(this, _ParticleEffect_particleGeometry, {
377
+ attributes: { position: _particle_common_1.QUAD_VERTS },
378
+ }, "f");
379
+ __classPrivateFieldSet(this, _ParticleEffect_spawnGeometry, {
380
+ mode: "points",
381
+ attributes: {
382
+ position: { data: SPAWN_VERTEX_INDICES, itemSize: 1 },
383
+ },
384
+ }, "f");
385
+ __classPrivateFieldSet(this, _ParticleEffect_gl, ctx.gl, "f");
386
+ __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_allocSpawnTextures).call(this, ctx);
387
+ __classPrivateFieldSet(this, _ParticleEffect_contextRestoredUnsub, ctx.onContextRestored(() => {
388
+ __classPrivateFieldSet(this, _ParticleEffect_gl, ctx.gl, "f");
389
+ __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_allocSpawnTextures).call(this, ctx);
390
+ __classPrivateFieldSet(this, _ParticleEffect_initialized, false, "f");
391
+ }), "f");
392
+ }
393
+ render(ctx) {
394
+ if (!__classPrivateFieldGet(this, _ParticleEffect_posTex, "f") ||
395
+ !__classPrivateFieldGet(this, _ParticleEffect_colorTex, "f") ||
396
+ !__classPrivateFieldGet(this, _ParticleEffect_velTex, "f") ||
397
+ !__classPrivateFieldGet(this, _ParticleEffect_stampTex, "f") ||
398
+ !__classPrivateFieldGet(this, _ParticleEffect_trail, "f") ||
399
+ !__classPrivateFieldGet(this, _ParticleEffect_particleGeometry, "f") ||
400
+ !__classPrivateFieldGet(this, _ParticleEffect_spawnGeometry, "f") ||
401
+ !__classPrivateFieldGet(this, _ParticleEffect_spawnTexHandle, "f") ||
402
+ !__classPrivateFieldGet(this, _ParticleEffect_spawnRawTex, "f")) {
403
+ return;
404
+ }
405
+ // Resize state RTs if `params.count` crossed a power-of-two
406
+ // boundary. dispose-then-create keeps peak GPU memory minimal;
407
+ // the FRAG_INIT pass below seeds the fresh RTs.
408
+ const newSize = (0, _particle_common_1.stateSizeFromCount)(this.params.count);
409
+ if (newSize !== __classPrivateFieldGet(this, _ParticleEffect_stateSize, "f")) {
410
+ __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_disposeStateRTs).call(this);
411
+ __classPrivateFieldSet(this, _ParticleEffect_stateSize, newSize, "f");
412
+ __classPrivateFieldSet(this, _ParticleEffect_stateCapacity, newSize * newSize, "f");
413
+ __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_allocStateRTs).call(this, ctx);
414
+ __classPrivateFieldSet(this, _ParticleEffect_nextSlot, 0, "f");
415
+ __classPrivateFieldSet(this, _ParticleEffect_initialized, false, "f");
416
+ }
417
+ if (!__classPrivateFieldGet(this, _ParticleEffect_initialized, "f")) {
418
+ // posTex's "stale" half gets overwritten on the first
419
+ // advect+swap, so a single init draw is enough. color/vel
420
+ // are single-buffer; one clear gives every dead slot known
421
+ // contents until the spawn pass writes it.
422
+ ctx.draw({ frag: FRAG_INIT_POS, target: __classPrivateFieldGet(this, _ParticleEffect_posTex, "f") });
423
+ ctx.draw({ frag: FRAG_INIT_COLOR, target: __classPrivateFieldGet(this, _ParticleEffect_colorTex, "f") });
424
+ ctx.draw({ frag: FRAG_INIT_COLOR, target: __classPrivateFieldGet(this, _ParticleEffect_velTex, "f") });
425
+ __classPrivateFieldSet(this, _ParticleEffect_initialized, true, "f");
426
+ }
427
+ const dt = (0, _particle_common_1.clampDt)(ctx.deltaTime);
428
+ const elementPixel = [
429
+ ctx.dims.elementPixel[0],
430
+ ctx.dims.elementPixel[1],
431
+ ];
432
+ const stateSizeVec = [
433
+ __classPrivateFieldGet(this, _ParticleEffect_stateSize, "f"),
434
+ __classPrivateFieldGet(this, _ParticleEffect_stateSize, "f"),
435
+ ];
436
+ const nSpawn = __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_scheduleSpawns).call(this, ctx, dt, elementPixel);
437
+ if (nSpawn > 0) {
438
+ __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_uploadSpawnTextures).call(this, ctx);
439
+ }
440
+ // advect skips its swap when a spawn pass follows, so both
441
+ // passes write into the same internal buffer of the persistent
442
+ // posTex. The spawn pass (or advect itself when nSpawn === 0)
443
+ // triggers the per-frame swap.
444
+ const advectSwap = nSpawn === 0;
445
+ ctx.draw({
446
+ frag: FRAG_ADVECT_POS,
447
+ uniforms: {
448
+ posTex: __classPrivateFieldGet(this, _ParticleEffect_posTex, "f"),
449
+ colorTex: __classPrivateFieldGet(this, _ParticleEffect_colorTex, "f"),
450
+ velTex: __classPrivateFieldGet(this, _ParticleEffect_velTex, "f"),
451
+ elementPixel,
452
+ time: ctx.time,
453
+ dt,
454
+ noiseSpeed: this.params.noiseSpeed,
455
+ emitSpeed: this.params.emitSpeed,
456
+ noiseDelay: this.params.noiseDelay,
457
+ noiseScale: this.params.noiseScale,
458
+ noiseAnimation: this.params.noiseAnimation,
459
+ speedDecay: this.params.speedDecay,
460
+ life: this.params.life,
461
+ },
462
+ target: __classPrivateFieldGet(this, _ParticleEffect_posTex, "f"),
463
+ swap: advectSwap,
464
+ });
465
+ if (nSpawn > 0) {
466
+ const spawnUniforms = {
467
+ uSpawnTex: __classPrivateFieldGet(this, _ParticleEffect_spawnTexHandle, "f"),
468
+ uSpawnTexSize: SPAWN_TEX_SIZE_VEC,
469
+ uSpawnCount: nSpawn,
470
+ stateSize: stateSizeVec,
471
+ };
472
+ ctx.draw({
473
+ vert: VERT_SPAWN,
474
+ frag: FRAG_SPAWN_POS,
475
+ geometry: __classPrivateFieldGet(this, _ParticleEffect_spawnGeometry, "f"),
476
+ uniforms: {
477
+ ...spawnUniforms,
478
+ src: ctx.src,
479
+ alphaThreshold: this.params.alphaThreshold,
480
+ },
481
+ target: __classPrivateFieldGet(this, _ParticleEffect_posTex, "f"),
482
+ blend: "none",
483
+ });
484
+ ctx.draw({
485
+ vert: VERT_SPAWN,
486
+ frag: FRAG_SPAWN_COLOR,
487
+ geometry: __classPrivateFieldGet(this, _ParticleEffect_spawnGeometry, "f"),
488
+ uniforms: {
489
+ ...spawnUniforms,
490
+ src: ctx.src,
491
+ color: (0, _particle_common_1.hexToRgb)(this.params.color),
492
+ colorMix: this.params.colorMix,
493
+ lifeJitterRange: [_curl_noise_1.LIFE_JITTER_MIN, _curl_noise_1.LIFE_JITTER_MAX],
494
+ },
495
+ target: __classPrivateFieldGet(this, _ParticleEffect_colorTex, "f"),
496
+ blend: "none",
497
+ });
498
+ ctx.draw({
499
+ vert: VERT_SPAWN,
500
+ frag: FRAG_SPAWN_VEL,
501
+ geometry: __classPrivateFieldGet(this, _ParticleEffect_spawnGeometry, "f"),
502
+ uniforms: spawnUniforms,
503
+ target: __classPrivateFieldGet(this, _ParticleEffect_velTex, "f"),
504
+ blend: "none",
505
+ });
506
+ }
507
+ const cap = __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_cap).call(this);
508
+ __classPrivateFieldGet(this, _ParticleEffect_particleGeometry, "f").instanceCount = cap;
509
+ ctx.draw({ frag: _particle_common_1.FRAG_CLEAR, target: __classPrivateFieldGet(this, _ParticleEffect_stampTex, "f") });
510
+ ctx.draw({
511
+ vert: VERT_PARTICLE,
512
+ frag: _particle_common_1.FRAG_PARTICLE,
513
+ uniforms: {
514
+ posTex: __classPrivateFieldGet(this, _ParticleEffect_posTex, "f"),
515
+ colorTex: __classPrivateFieldGet(this, _ParticleEffect_colorTex, "f"),
516
+ stateSize: stateSizeVec,
517
+ pointSize: this.params.pointSize,
518
+ elementPixel,
519
+ particleCount: cap,
520
+ alpha: this.params.alpha,
521
+ alphaDecay: this.params.alphaDecay,
522
+ fadeIn: this.params.fadeIn,
523
+ fog: this.params.fog,
524
+ },
525
+ geometry: __classPrivateFieldGet(this, _ParticleEffect_particleGeometry, "f"),
526
+ target: __classPrivateFieldGet(this, _ParticleEffect_stampTex, "f"),
527
+ blend: this.params.blend === "normal" ? "premultiplied" : "additive",
528
+ });
529
+ ctx.draw({
530
+ frag: _particle_common_1.FRAG_TRAIL_COMPOSITE,
531
+ uniforms: {
532
+ trailPrev: __classPrivateFieldGet(this, _ParticleEffect_trail, "f"),
533
+ particleStamp: __classPrivateFieldGet(this, _ParticleEffect_stampTex, "f"),
534
+ trailFade: this.params.trailFade,
535
+ blendMode: this.params.blend === "normal" ? 1 : 0,
536
+ },
537
+ target: __classPrivateFieldGet(this, _ParticleEffect_trail, "f"),
538
+ });
539
+ ctx.draw({
540
+ frag: FRAG_OUTPUT,
541
+ uniforms: {
542
+ src: ctx.src,
543
+ trail: __classPrivateFieldGet(this, _ParticleEffect_trail, "f"),
544
+ srcOpacity: this.params.srcOpacity,
545
+ },
546
+ target: ctx.target,
547
+ });
548
+ }
549
+ dispose() {
550
+ __classPrivateFieldGet(this, _ParticleEffect_contextRestoredUnsub, "f")?.call(this);
551
+ __classPrivateFieldSet(this, _ParticleEffect_contextRestoredUnsub, null, "f");
552
+ if (__classPrivateFieldGet(this, _ParticleEffect_gl, "f") && __classPrivateFieldGet(this, _ParticleEffect_spawnRawTex, "f")) {
553
+ __classPrivateFieldGet(this, _ParticleEffect_gl, "f").deleteTexture(__classPrivateFieldGet(this, _ParticleEffect_spawnRawTex, "f"));
554
+ }
555
+ __classPrivateFieldSet(this, _ParticleEffect_spawnRawTex, null, "f");
556
+ __classPrivateFieldSet(this, _ParticleEffect_spawnTexHandle, null, "f");
557
+ __classPrivateFieldSet(this, _ParticleEffect_spawnGeometry, null, "f");
558
+ __classPrivateFieldSet(this, _ParticleEffect_gl, null, "f");
559
+ __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_disposeStateRTs).call(this);
560
+ __classPrivateFieldGet(this, _ParticleEffect_stampTex, "f")?.dispose();
561
+ __classPrivateFieldGet(this, _ParticleEffect_trail, "f")?.dispose();
562
+ __classPrivateFieldSet(this, _ParticleEffect_stampTex, null, "f");
563
+ __classPrivateFieldSet(this, _ParticleEffect_trail, null, "f");
564
+ __classPrivateFieldSet(this, _ParticleEffect_particleGeometry, null, "f");
565
+ __classPrivateFieldSet(this, _ParticleEffect_initialized, false, "f");
566
+ }
567
+ outputRect(dims) {
568
+ return dims.canvasRect;
569
+ }
570
+ }
571
+ exports.ParticleEffect = ParticleEffect;
572
+ _ParticleEffect_params = new WeakMap(), _ParticleEffect_posTex = new WeakMap(), _ParticleEffect_colorTex = new WeakMap(), _ParticleEffect_velTex = new WeakMap(), _ParticleEffect_stampTex = new WeakMap(), _ParticleEffect_trail = new WeakMap(), _ParticleEffect_initialized = new WeakMap(), _ParticleEffect_stateSize = new WeakMap(), _ParticleEffect_stateCapacity = new WeakMap(), _ParticleEffect_spawnUniform = new WeakMap(), _ParticleEffect_spawnRawTex = new WeakMap(), _ParticleEffect_spawnTexHandle = new WeakMap(), _ParticleEffect_spawnGeometry = new WeakMap(), _ParticleEffect_particleGeometry = new WeakMap(), _ParticleEffect_gl = new WeakMap(), _ParticleEffect_contextRestoredUnsub = new WeakMap(), _ParticleEffect_nextSlot = new WeakMap(), _ParticleEffect_birthAccumulator = new WeakMap(), _ParticleEffect_screenBirthAccumulator = new WeakMap(), _ParticleEffect_lastMouseUv = new WeakMap(), _ParticleEffect_lastMoveTime = new WeakMap(), _ParticleEffect_instances = new WeakSet(), _ParticleEffect_allocStateRTs = function _ParticleEffect_allocStateRTs(ctx) {
573
+ const stateOpts = {
574
+ size: [__classPrivateFieldGet(this, _ParticleEffect_stateSize, "f"), __classPrivateFieldGet(this, _ParticleEffect_stateSize, "f")],
575
+ float: true,
576
+ wrap: "clamp",
577
+ filter: "nearest",
578
+ };
579
+ // pos uses auto-ping-pong (`persistent: true`); advect runs
580
+ // with `swap: false` so the subsequent spawn pass lands in the
581
+ // same internal buffer. color/vel are single-buffer — only the
582
+ // spawn pass writes them, other texels persist naturally.
583
+ __classPrivateFieldSet(this, _ParticleEffect_posTex, ctx.createRenderTarget({
584
+ ...stateOpts,
585
+ persistent: true,
586
+ }), "f");
587
+ __classPrivateFieldSet(this, _ParticleEffect_colorTex, ctx.createRenderTarget(stateOpts), "f");
588
+ __classPrivateFieldSet(this, _ParticleEffect_velTex, ctx.createRenderTarget(stateOpts), "f");
589
+ }, _ParticleEffect_disposeStateRTs = function _ParticleEffect_disposeStateRTs() {
590
+ __classPrivateFieldGet(this, _ParticleEffect_posTex, "f")?.dispose();
591
+ __classPrivateFieldGet(this, _ParticleEffect_colorTex, "f")?.dispose();
592
+ __classPrivateFieldGet(this, _ParticleEffect_velTex, "f")?.dispose();
593
+ __classPrivateFieldSet(this, _ParticleEffect_posTex, null, "f");
594
+ __classPrivateFieldSet(this, _ParticleEffect_colorTex, null, "f");
595
+ __classPrivateFieldSet(this, _ParticleEffect_velTex, null, "f");
596
+ }, _ParticleEffect_createSpawnTex = function _ParticleEffect_createSpawnTex(ctx) {
597
+ const gl = ctx.gl;
598
+ const tex = gl.createTexture();
599
+ if (!tex) {
600
+ throw new Error("[ParticleEffect] Failed to create spawn texture");
601
+ }
602
+ gl.bindTexture(gl.TEXTURE_2D, tex);
603
+ // Counteract the global UNPACK_FLIP_Y_WEBGL=true that the
604
+ // framework sets for DOM source uploads — our spawn data is a
605
+ // raw float buffer with row 0 at the top, no flip wanted.
606
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
607
+ gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA32F, SPAWN_TEX_SIZE, SPAWN_TEX_SIZE, 0, gl.RGBA, gl.FLOAT, null);
608
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
609
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
610
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
611
+ gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
612
+ gl.bindTexture(gl.TEXTURE_2D, null);
613
+ const handle = ctx.wrapTexture(tex, {
614
+ size: [SPAWN_TEX_SIZE, SPAWN_TEX_SIZE],
615
+ filter: "nearest",
616
+ wrap: "clamp",
617
+ });
618
+ return { raw: tex, handle };
619
+ }, _ParticleEffect_allocSpawnTextures = function _ParticleEffect_allocSpawnTextures(ctx) {
620
+ const a = __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_createSpawnTex).call(this, ctx);
621
+ __classPrivateFieldSet(this, _ParticleEffect_spawnRawTex, a.raw, "f");
622
+ __classPrivateFieldSet(this, _ParticleEffect_spawnTexHandle, a.handle, "f");
623
+ }, _ParticleEffect_uploadSpawnTextures = function _ParticleEffect_uploadSpawnTextures(ctx) {
624
+ if (!__classPrivateFieldGet(this, _ParticleEffect_spawnRawTex, "f")) {
625
+ return;
626
+ }
627
+ const gl = ctx.gl;
628
+ // Reset framework's global UNPACK_FLIP_Y_WEBGL=true (set for
629
+ // DOM source uploads) so row 0 of our raw float buffer maps to
630
+ // row 0 of the texture.
631
+ gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, false);
632
+ gl.bindTexture(gl.TEXTURE_2D, __classPrivateFieldGet(this, _ParticleEffect_spawnRawTex, "f"));
633
+ gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, SPAWN_TEX_SIZE, SPAWN_TEX_SIZE, gl.RGBA, gl.FLOAT, __classPrivateFieldGet(this, _ParticleEffect_spawnUniform, "f"));
634
+ gl.bindTexture(gl.TEXTURE_2D, null);
635
+ }, _ParticleEffect_scheduleSpawns = function _ParticleEffect_scheduleSpawns(ctx, dt, elementPixel) {
636
+ const mouseUv = [
637
+ ctx.mouse[0] / Math.max(1, elementPixel[0]),
638
+ ctx.mouse[1] / Math.max(1, elementPixel[1]),
639
+ ];
640
+ const moved = !__classPrivateFieldGet(this, _ParticleEffect_lastMouseUv, "f") ||
641
+ Math.abs(mouseUv[0] - __classPrivateFieldGet(this, _ParticleEffect_lastMouseUv, "f")[0]) > 1e-6 ||
642
+ Math.abs(mouseUv[1] - __classPrivateFieldGet(this, _ParticleEffect_lastMouseUv, "f")[1]) > 1e-6;
643
+ if (moved) {
644
+ __classPrivateFieldSet(this, _ParticleEffect_lastMoveTime, ctx.time, "f");
645
+ }
646
+ __classPrivateFieldSet(this, _ParticleEffect_lastMouseUv, mouseUv, "f");
647
+ const visible = ctx.intersection > 0;
648
+ const recent = ctx.time - __classPrivateFieldGet(this, _ParticleEffect_lastMoveTime, "f") < IDLE_THRESHOLD;
649
+ const mouseActive = visible && (recent || this.params.spawnOnIdle);
650
+ // Cap accumulators at the per-frame budget so a birthRate that
651
+ // exceeds MAX_SPAWNS_PER_FRAME × fps doesn't queue indefinitely
652
+ // and bleed spawns past when the user expects (e.g., still
653
+ // emitting after the cursor stops on a high birthRate setting).
654
+ if (mouseActive) {
655
+ __classPrivateFieldSet(this, _ParticleEffect_birthAccumulator, Math.min(__classPrivateFieldGet(this, _ParticleEffect_birthAccumulator, "f") + this.params.birthRate * dt, MAX_SPAWNS_PER_FRAME), "f");
656
+ }
657
+ else {
658
+ __classPrivateFieldSet(this, _ParticleEffect_birthAccumulator, 0, "f");
659
+ }
660
+ if (visible) {
661
+ __classPrivateFieldSet(this, _ParticleEffect_screenBirthAccumulator, Math.min(__classPrivateFieldGet(this, _ParticleEffect_screenBirthAccumulator, "f") + this.params.screenBirthRate * dt, MAX_SPAWNS_PER_FRAME), "f");
662
+ }
663
+ else {
664
+ __classPrivateFieldSet(this, _ParticleEffect_screenBirthAccumulator, 0, "f");
665
+ }
666
+ // Mouse takes priority for the per-frame slot budget — when the
667
+ // user is dragging fast we'd rather show that than the ambient.
668
+ const nMouse = Math.min(MAX_SPAWNS_PER_FRAME, Math.floor(__classPrivateFieldGet(this, _ParticleEffect_birthAccumulator, "f")));
669
+ const nScreen = Math.min(MAX_SPAWNS_PER_FRAME - nMouse, Math.floor(__classPrivateFieldGet(this, _ParticleEffect_screenBirthAccumulator, "f")));
670
+ __classPrivateFieldSet(this, _ParticleEffect_birthAccumulator, __classPrivateFieldGet(this, _ParticleEffect_birthAccumulator, "f") - nMouse, "f");
671
+ __classPrivateFieldSet(this, _ParticleEffect_screenBirthAccumulator, __classPrivateFieldGet(this, _ParticleEffect_screenBirthAccumulator, "f") - nScreen, "f");
672
+ const total = nMouse + nScreen;
673
+ if (total === 0) {
674
+ return 0;
675
+ }
676
+ const cap = __classPrivateFieldGet(this, _ParticleEffect_instances, "m", _ParticleEffect_cap).call(this);
677
+ const elemPxX = Math.max(1, elementPixel[0]);
678
+ const elemPxY = Math.max(1, elementPixel[1]);
679
+ const buf = __classPrivateFieldGet(this, _ParticleEffect_spawnUniform, "f");
680
+ let i = 0;
681
+ // .w = theta in [0, 2π) for mouse spawns. FRAG_SPAWN_VEL turns
682
+ // it into a unit (cosθ, sinθ) in pixel space; FRAG_ADVECT_POS
683
+ // divides by elementPixel for circular symmetry on non-square
684
+ // elements.
685
+ for (; i < nMouse; i++) {
686
+ const r = Math.sqrt(Math.random()) * this.params.radius;
687
+ const theta = Math.random() * Math.PI * 2;
688
+ const dx = Math.cos(theta) * r;
689
+ const dy = Math.sin(theta) * r;
690
+ const o = i * 4;
691
+ buf[o + 0] = __classPrivateFieldGet(this, _ParticleEffect_nextSlot, "f");
692
+ buf[o + 1] = mouseUv[0] + dx / elemPxX;
693
+ buf[o + 2] = mouseUv[1] + dy / elemPxY;
694
+ buf[o + 3] = theta;
695
+ __classPrivateFieldSet(this, _ParticleEffect_nextSlot, (__classPrivateFieldGet(this, _ParticleEffect_nextSlot, "f") + 1) % cap, "f");
696
+ }
697
+ // .w = -1 sentinel: no radial impulse (curl-noise only).
698
+ for (let j = 0; j < nScreen; j++, i++) {
699
+ const o = i * 4;
700
+ buf[o + 0] = __classPrivateFieldGet(this, _ParticleEffect_nextSlot, "f");
701
+ buf[o + 1] = Math.random();
702
+ buf[o + 2] = Math.random();
703
+ buf[o + 3] = -1;
704
+ __classPrivateFieldSet(this, _ParticleEffect_nextSlot, (__classPrivateFieldGet(this, _ParticleEffect_nextSlot, "f") + 1) % cap, "f");
705
+ }
706
+ return total;
707
+ }, _ParticleEffect_cap = function _ParticleEffect_cap() {
708
+ return Math.max(1, Math.min(__classPrivateFieldGet(this, _ParticleEffect_stateCapacity, "f"), Math.floor(this.params.count)));
709
+ };
710
+ //# sourceMappingURL=particle.js.map