@wave3d/core 0.7.0 → 0.8.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.
@@ -25,15 +25,28 @@ declare class ParticleField {
25
25
  private readonly material;
26
26
  /** Layout signature — only these rebuild the seeded buffers; the rest are live uniforms. */
27
27
  private sig;
28
- constructor();
28
+ /** Rasterized user artwork for shape "sprite", and the url it came from (so a repeat sync is a
29
+ * no-op). `spriteFailedUrl` latches a broken image so a bad url is not retried every frame. */
30
+ private sprite?;
31
+ private spriteUrl;
32
+ private spriteFailedUrl;
33
+ private disposed;
34
+ /** Defines this field owns (currently just PARTICLE_SPRITE), merged over the wave's in configure().
35
+ * Set only once a texture is actually bound, so the sampler never compiles without one. */
36
+ private ownDefines;
37
+ /** Called when a sprite finishes rasterizing, so a paused/settled renderer redraws with it. */
38
+ private readonly onReady?;
39
+ constructor(onReady?: () => void);
29
40
  /** Reconcile to `cfg`: rebuild the seeded buffers if the layout signature changed, then push the
30
41
  * frame-independent uniforms. `loopSeconds` is scene-level (passed in). Called from refresh(). */
31
42
  sync(cfg: ParticlesConfig, loopSeconds: number): void;
32
43
  /** Push the per-frame frame basis (the camera can move, so this runs every frame). */
33
44
  frame(f: ParticleFrame, pixelRatio: number): void;
34
- /** Bind the OWNING wave's shape: mirror its shape #defines + shape uniforms + world matrix so the
35
- * dust rides the SAME deform as the ribbon. Recompiles the point program only when the define set
36
- * changes. Called from refresh() each frame with the wave's live state. */
45
+ /** Bind the OWNING wave's shape AND cursor state: mirror its #defines + shape uniforms + pointer
46
+ * uniforms + world matrix, so the dust rides the same deform as the ribbon and reacts to the same
47
+ * pointer field. Recompiles the point program only when the define set changes — which is why the
48
+ * defines must come from CONFIG only (shapeDefines), never from live input. Called from refresh()
49
+ * each frame with the wave's live state. */
37
50
  configure(shape: {
38
51
  defines: Record<string, string>;
39
52
  uniforms: Record<string, THREE.IUniform>;
@@ -41,6 +54,24 @@ declare class ParticleField {
41
54
  speed: number;
42
55
  seed: number;
43
56
  }): void;
57
+ /** Reconcile the sprite texture to `url` ("" = none). Cheap and idempotent: a repeat call with the
58
+ * same url does nothing, and a url that already failed is never retried. */
59
+ private syncSprite;
60
+ /** Drop the current sprite and fall back to the procedural shapes (which is what `uShape` still
61
+ * holds, so a field mid-load or with a broken image draws "glitter" rather than nothing). */
62
+ private clearSprite;
63
+ /**
64
+ * Rasterize `url` into a square {@link SPRITE_PX} texture and bind it.
65
+ *
66
+ * Deliberately the BACKGROUND-image pattern (load → apply → ask for a redraw) rather than
67
+ * loadPaletteImage's fire-and-forget TextureLoader: a thumbnail or poster snapshotted while the
68
+ * texture was still in flight would capture blank dust — the same class of bug that made
69
+ * image-driven preset thumbnails render empty.
70
+ */
71
+ private loadSprite;
72
+ /** Copy one uniform across from the owning wave: numbers by value, vectors/matrices in place, and
73
+ * arrays (the ripple slots) by reference — the wave owns those and mutates them in place. */
74
+ private mirror;
44
75
  /** Advance the field to scene time `t` (= the same `t` the waves get). */
45
76
  setTime(t: number): void;
46
77
  dispose(): void;
@@ -19,6 +19,17 @@ function setLinear(target, hex) {
19
19
  target.set(c.r, c.g, c.b);
20
20
  }
21
21
  const DEFAULT_COLOR = "#ffcf8a";
22
+ /**
23
+ * Edge of the square canvas a {@link ParticlesConfig.spriteUrl} is rasterized into. SVG has no
24
+ * intrinsic pixel size, so something has to choose one — this is it.
25
+ *
26
+ * 256² RGBA is ~256 KB (~350 KB with mipmaps), which is LESS than the per-particle attribute
27
+ * buffers a 20k field already uploads (~800 KB): one texture serves every particle in the field, so
28
+ * sprite artwork is not what makes a dust field expensive. 256 also covers the largest sprite the
29
+ * hardware will draw — gl.ALIASED_POINT_SIZE_RANGE tops out around 511 px, and `size` clamps to 200
30
+ * before the pixel-ratio multiply.
31
+ */
32
+ const SPRITE_PX = 256;
22
33
  /** Sprite-shape name → the int the fragment shader branches on (see particleFragmentShader). */
23
34
  const SHAPE_INDEX = {
24
35
  glitter: 0,
@@ -51,6 +62,28 @@ const SHAPE_UNIFORMS = [
51
62
  "uRadialRadius",
52
63
  "uRadialCenter"
53
64
  ];
65
+ /** The owning wave's POINTER-FIELD uniforms, mirrored the same way so the dust reads the exact
66
+ * cursor state the ribbon does (see pointerFieldChunk). Only uploaded under POINTER_FX — configure()
67
+ * copies them regardless, which is a handful of scalars. The ripple entries are ARRAYS: those are
68
+ * shared by reference (the wave owns them and applyPointerField mutates them in place), so a click
69
+ * costs no per-frame copy. Mirroring rather than a second CPU write also keeps capture determinism
70
+ * for free — applyInteractionRest zeroes the wave's uPointerActive / uRippleAmp, and the dust
71
+ * inherits that rest state on the same frame (updateSceneFx runs after applyInteraction). */
72
+ const POINTER_UNIFORMS = [
73
+ "uPointer",
74
+ "uPointerActive",
75
+ "uPointerRadius",
76
+ "uPointerAspect",
77
+ "uPointerAgitate",
78
+ "uPointerPush",
79
+ "uPointerWake",
80
+ "uPointerVel",
81
+ "uShapeFlow",
82
+ "uRippleOrigin",
83
+ "uRippleAge",
84
+ "uRippleAmp",
85
+ "uPointerRipple"
86
+ ];
54
87
  /** Build the seeded per-particle attribute buffers. Pure function of `(count, seed, edgeBias, bias)` —
55
88
  * exported so a unit test can assert reproducibility without a GPU. */
56
89
  function buildParticleAttributes(count, seed, edgeBias = 1, bias = 0) {
@@ -88,7 +121,19 @@ var ParticleField = class {
88
121
  material;
89
122
  /** Layout signature — only these rebuild the seeded buffers; the rest are live uniforms. */
90
123
  sig = "";
91
- constructor() {
124
+ /** Rasterized user artwork for shape "sprite", and the url it came from (so a repeat sync is a
125
+ * no-op). `spriteFailedUrl` latches a broken image so a bad url is not retried every frame. */
126
+ sprite;
127
+ spriteUrl = "";
128
+ spriteFailedUrl = "";
129
+ disposed = false;
130
+ /** Defines this field owns (currently just PARTICLE_SPRITE), merged over the wave's in configure().
131
+ * Set only once a texture is actually bound, so the sampler never compiles without one. */
132
+ ownDefines = {};
133
+ /** Called when a sprite finishes rasterizing, so a paused/settled renderer redraws with it. */
134
+ onReady;
135
+ constructor(onReady) {
136
+ this.onReady = onReady;
92
137
  this.material = new THREE.ShaderMaterial({
93
138
  uniforms: {
94
139
  uTime: { value: 0 },
@@ -131,7 +176,22 @@ var ParticleField = class {
131
176
  uRadialCenter: { value: 0 },
132
177
  uShedModel: { value: new THREE.Matrix4() },
133
178
  uShedSpeed: { value: 0 },
134
- uShedSeed: { value: 0 }
179
+ uShedSeed: { value: 0 },
180
+ uPointer: { value: new THREE.Vector2() },
181
+ uPointerActive: { value: 0 },
182
+ uPointerRadius: { value: .6 },
183
+ uPointerAspect: { value: 1 },
184
+ uPointerAgitate: { value: 0 },
185
+ uPointerPush: { value: 0 },
186
+ uPointerWake: { value: 0 },
187
+ uPointerVel: { value: new THREE.Vector2() },
188
+ uShapeFlow: { value: 0 },
189
+ uRippleOrigin: { value: Array.from({ length: 4 }, () => new THREE.Vector2()) },
190
+ uRippleAge: { value: Array.from({ length: 4 }, () => 0) },
191
+ uRippleAmp: { value: Array.from({ length: 4 }, () => 0) },
192
+ uPointerRipple: { value: 0 },
193
+ uPartShove: { value: 1 },
194
+ uSprite: { value: null }
135
195
  },
136
196
  vertexShader: particleVertexShader,
137
197
  fragmentShader: particleFragmentShader,
@@ -172,6 +232,8 @@ var ParticleField = class {
172
232
  u.uSwirl.value = cfg.swirl ?? 0;
173
233
  u.uWander.value = cfg.wander ?? 0;
174
234
  u.uShape.value = SHAPE_INDEX[cfg.shape ?? "glitter"] ?? 0;
235
+ u.uPartShove.value = cfg.pointerShove ?? 1;
236
+ this.syncSprite(cfg.shape === "sprite" ? cfg.spriteUrl ?? "" : "");
175
237
  setLinear(u.uColor.value, cfg.color ?? DEFAULT_COLOR);
176
238
  setLinear(u.uColor2.value, cfg.color2 ?? cfg.color ?? DEFAULT_COLOR);
177
239
  }
@@ -183,33 +245,108 @@ var ParticleField = class {
183
245
  u.uUp.value.copy(f.up);
184
246
  u.uPixelRatio.value = pixelRatio;
185
247
  }
186
- /** Bind the OWNING wave's shape: mirror its shape #defines + shape uniforms + world matrix so the
187
- * dust rides the SAME deform as the ribbon. Recompiles the point program only when the define set
188
- * changes. Called from refresh() each frame with the wave's live state. */
248
+ /** Bind the OWNING wave's shape AND cursor state: mirror its #defines + shape uniforms + pointer
249
+ * uniforms + world matrix, so the dust rides the same deform as the ribbon and reacts to the same
250
+ * pointer field. Recompiles the point program only when the define set changes — which is why the
251
+ * defines must come from CONFIG only (shapeDefines), never from live input. Called from refresh()
252
+ * each frame with the wave's live state. */
189
253
  configure(shape) {
190
- const want = shape.defines;
254
+ const want = {
255
+ ...shape.defines,
256
+ ...this.ownDefines
257
+ };
191
258
  const cur = this.material.defines ?? {};
192
259
  if (Object.keys(want).sort().join(",") !== Object.keys(cur).sort().join(",")) {
193
260
  this.material.defines = { ...want };
194
261
  this.material.needsUpdate = true;
195
262
  }
196
263
  const u = this.material.uniforms;
197
- for (const name of SHAPE_UNIFORMS) {
198
- const src = shape.uniforms[name];
199
- if (!src || u[name] === void 0) continue;
200
- const dst = u[name].value;
201
- if (typeof src.value === "number") u[name].value = src.value;
202
- else if (dst && typeof dst.copy === "function") dst.copy(src.value);
203
- }
264
+ for (const name of SHAPE_UNIFORMS) this.mirror(shape.uniforms, name);
265
+ for (const name of POINTER_UNIFORMS) this.mirror(shape.uniforms, name);
204
266
  u.uShedModel.value.copy(shape.matrixWorld);
205
267
  u.uShedSpeed.value = shape.speed;
206
268
  u.uShedSeed.value = shape.seed;
207
269
  }
270
+ /** Reconcile the sprite texture to `url` ("" = none). Cheap and idempotent: a repeat call with the
271
+ * same url does nothing, and a url that already failed is never retried. */
272
+ syncSprite(url) {
273
+ if (url === this.spriteUrl) return;
274
+ this.spriteUrl = url;
275
+ this.clearSprite();
276
+ if (url && url !== this.spriteFailedUrl) this.loadSprite(url);
277
+ }
278
+ /** Drop the current sprite and fall back to the procedural shapes (which is what `uShape` still
279
+ * holds, so a field mid-load or with a broken image draws "glitter" rather than nothing). */
280
+ clearSprite() {
281
+ if (!this.sprite) return;
282
+ this.sprite.dispose();
283
+ this.sprite = void 0;
284
+ this.material.uniforms.uSprite.value = null;
285
+ if (this.ownDefines.PARTICLE_SPRITE !== void 0) {
286
+ this.ownDefines = {};
287
+ this.material.needsUpdate = true;
288
+ }
289
+ }
290
+ /**
291
+ * Rasterize `url` into a square {@link SPRITE_PX} texture and bind it.
292
+ *
293
+ * Deliberately the BACKGROUND-image pattern (load → apply → ask for a redraw) rather than
294
+ * loadPaletteImage's fire-and-forget TextureLoader: a thumbnail or poster snapshotted while the
295
+ * texture was still in flight would capture blank dust — the same class of bug that made
296
+ * image-driven preset thumbnails render empty.
297
+ */
298
+ loadSprite(url) {
299
+ const img = new Image();
300
+ img.decoding = "async";
301
+ if (!url.startsWith("data:") && !url.startsWith("blob:")) img.crossOrigin = "anonymous";
302
+ img.addEventListener("load", () => {
303
+ if (this.disposed || this.spriteUrl !== url) return;
304
+ const canvas = document.createElement("canvas");
305
+ canvas.width = SPRITE_PX;
306
+ canvas.height = SPRITE_PX;
307
+ const ctx = canvas.getContext("2d");
308
+ if (!ctx) return;
309
+ const iw = img.naturalWidth || SPRITE_PX;
310
+ const ih = img.naturalHeight || SPRITE_PX;
311
+ const fit = Math.min(SPRITE_PX / iw, SPRITE_PX / ih);
312
+ const w = iw * fit;
313
+ const h = ih * fit;
314
+ ctx.drawImage(img, (SPRITE_PX - w) / 2, (SPRITE_PX - h) / 2, w, h);
315
+ const tex = new THREE.CanvasTexture(canvas);
316
+ tex.colorSpace = THREE.SRGBColorSpace;
317
+ tex.generateMipmaps = true;
318
+ tex.minFilter = THREE.LinearMipmapLinearFilter;
319
+ tex.magFilter = THREE.LinearFilter;
320
+ tex.wrapS = THREE.ClampToEdgeWrapping;
321
+ tex.wrapT = THREE.ClampToEdgeWrapping;
322
+ this.sprite = tex;
323
+ this.material.uniforms.uSprite.value = tex;
324
+ this.ownDefines = { PARTICLE_SPRITE: "" };
325
+ this.material.needsUpdate = true;
326
+ this.onReady?.();
327
+ }, { once: true });
328
+ img.addEventListener("error", () => {
329
+ this.spriteFailedUrl = url;
330
+ }, { once: true });
331
+ img.src = url;
332
+ }
333
+ /** Copy one uniform across from the owning wave: numbers by value, vectors/matrices in place, and
334
+ * arrays (the ripple slots) by reference — the wave owns those and mutates them in place. */
335
+ mirror(src, name) {
336
+ const from = src[name];
337
+ const to = this.material.uniforms[name];
338
+ if (!from || !to) return;
339
+ const dst = to.value;
340
+ if (typeof from.value === "number" || Array.isArray(from.value)) to.value = from.value;
341
+ else if (dst && typeof dst.copy === "function") dst.copy(from.value);
342
+ }
208
343
  /** Advance the field to scene time `t` (= the same `t` the waves get). */
209
344
  setTime(t) {
210
345
  this.material.uniforms.uTime.value = t;
211
346
  }
212
347
  dispose() {
348
+ this.disposed = true;
349
+ this.sprite?.dispose();
213
350
  this.geometry.dispose();
214
351
  this.material.dispose();
215
352
  }
@@ -1 +1 @@
1
- {"version":3,"file":"particleField.js","names":[],"sources":["../../src/renderer/particleField.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport type { ParticlesConfig } from \"../config/model\";\nimport { particleFragmentShader, particleVertexShader } from \"./shaders\";\n\n/**\n * A WAVE's additive particle / dust field: a single {@link THREE.Points} whose every particle is placed\n * and animated ENTIRELY in the vertex shader from `uTime` + baked per-particle attributes, so the field\n * is deterministic — the same `(count, seed, edgeBias, bias)` yields byte-identical buffers, and all\n * motion is a pure function of the scene time `t` (so timeOffset scrub / loopSeconds / paused reproduce).\n *\n * One field belongs to ONE wave (created/disposed alongside it, like {@link WavePalette}). Every particle\n * spawns on that wave's DEFORMED surface / edge (via the shared waveShape chunk, riding the exact deform\n * the ribbon uses) and drifts outward from the wave centre. Byte-identical when off: absent\n * `wave.particles` ⇒ the renderer never creates a field.\n */\nexport interface ParticleFrame {\n /** The owning wave's world-space centre — drift radiates from here. */\n center: THREE.Vector3;\n /** Screen-right / screen-up unit vectors (world space) for screen-relative motion. */\n right: THREE.Vector3;\n up: THREE.Vector3;\n}\n\n/** Deterministic PRNG (mulberry32): a pure function of the seed, so a `(count, seed)` layout\n * reproduces exactly. NEVER Math.random — that would desync timeOffset scrub / loop / paused. */\nfunction mulberry32(seed: number): () => number {\n let a = seed >>> 0;\n return () => {\n a |= 0;\n a = (a + 0x6d2b79f5) | 0;\n let t = Math.imul(a ^ (a >>> 15), 1 | a);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n// sRGB hex → linear RGB. Replicates WaveRenderer.hexToLinearVec3 locally to avoid a circular import\n// (the renderer imports this module): three's ColorManagement linearizes on parse, so read .r/.g/.b\n// directly — a second convertSRGBToLinear() would double-linearize.\nconst HEX_SCRATCH = new THREE.Color();\nfunction setLinear(target: THREE.Vector3, hex: string): void {\n const c = HEX_SCRATCH.set(hex);\n target.set(c.r, c.g, c.b);\n}\n\nconst DEFAULT_COLOR = \"#ffcf8a\"; // warm gold\n\n/** Sprite-shape name → the int the fragment shader branches on (see particleFragmentShader). */\nconst SHAPE_INDEX: Record<string, number> = { glitter: 0, soft: 1, ring: 2, star: 3, streak: 4 };\n\n/** The owning wave's shape uniforms mirrored onto the particle material so the dust rides the same\n * deform as the ribbon. Names match the wave material's uniforms 1:1 (copied by value in configure). */\nconst SHAPE_UNIFORMS = [\n \"uDispFreqX\",\n \"uDispFreqZ\",\n \"uDispAmount\",\n \"uDetailFreq\",\n \"uDetailAmount\",\n \"uTwFreqX\",\n \"uTwFreqY\",\n \"uTwFreqZ\",\n \"uTwPowX\",\n \"uTwPowY\",\n \"uTwPowZ\",\n \"uHelixTurns\",\n \"uHelixRadius\",\n \"uHelixRoll\",\n \"uHelixPhase\",\n \"uRadialAmount\",\n \"uRadialArc\",\n \"uRadialSpread\",\n \"uRadialRadius\",\n \"uRadialCenter\",\n] as const;\n\n/** Build the seeded per-particle attribute buffers. Pure function of `(count, seed, edgeBias, bias)` —\n * exported so a unit test can assert reproducibility without a GPU. */\nexport function buildParticleAttributes(\n count: number,\n seed: number,\n edgeBias = 1,\n bias = 0,\n): {\n position: Float32Array;\n aSeed: Float32Array;\n aRnd: Float32Array;\n aUv: Float32Array;\n} {\n const rand = mulberry32(seed >>> 0 || 1);\n const position = new Float32Array(count * 3); // dummy — the vertex shader computes real positions\n const aSeed = new Float32Array(count);\n const aRnd = new Float32Array(count * 4);\n const aUv = new Float32Array(count * 2);\n for (let i = 0; i < count; i++) {\n aSeed[i] = rand();\n aRnd[i * 4 + 0] = rand();\n aRnd[i * 4 + 1] = rand();\n aRnd[i * 4 + 2] = rand();\n aRnd[i * 4 + 3] = rand();\n }\n // aUv in a SEPARATE pass so adding/changing it never shifts the aSeed/aRnd RNG sequence above. aUv.x\n // = the flank position across the ribbon width; `bias` skews it toward one side (`u^p`, p<1 crowds\n // →1, p>1 crowds →0; p=1 / bias 0 leaves it untouched). aUv.y = WHERE ALONG the ribbon the particle\n // spawns, interpolated by `edgeBias`: 0 → uniform across the whole SURFACE, 1 → crowded to the outer\n // rim/EDGE (`1 − rand²·0.45`, the silk-dissolving-into-glitter look).\n const pexp = bias === 0 ? 1 : Math.exp(-bias * 2);\n const eb = Math.min(Math.max(edgeBias, 0), 1);\n for (let i = 0; i < count; i++) {\n const ux = rand();\n aUv[i * 2 + 0] = bias === 0 ? ux : Math.pow(ux, pexp);\n const e = rand();\n const rim = 1.0 - e * e * 0.45; // outer-rim biased\n aUv[i * 2 + 1] = e + (rim - e) * eb; // mix(surface, edge) by edgeBias\n }\n return { position, aSeed, aRnd, aUv };\n}\n\nexport class ParticleField {\n readonly points: THREE.Points;\n private readonly geometry = new THREE.BufferGeometry();\n private readonly material: THREE.ShaderMaterial;\n /** Layout signature — only these rebuild the seeded buffers; the rest are live uniforms. */\n private sig = \"\";\n\n constructor() {\n this.material = new THREE.ShaderMaterial({\n uniforms: {\n uTime: { value: 0 },\n uLoopSeconds: { value: 0 },\n uLife: { value: 6 },\n uPartSpeed: { value: 1 },\n uSize: { value: 2 },\n uSizeJitter: { value: 0 },\n uTwinkle: { value: 0 },\n uPixelRatio: { value: 1 },\n uColor: { value: new THREE.Vector3(1, 0.81, 0.54) },\n uColor2: { value: new THREE.Vector3(1, 0.81, 0.54) },\n uCenter: { value: new THREE.Vector3() },\n uRight: { value: new THREE.Vector3(1, 0, 0) },\n uUp: { value: new THREE.Vector3(0, 1, 0) },\n uDrift: { value: 0 },\n uRise: { value: 0 },\n uSwirl: { value: 0 },\n uWander: { value: 0 },\n uShape: { value: 0 },\n // The owning wave's shape uniforms + world matrix, mirrored in configure() so the dust rides\n // the same deform as the ribbon. The nested HELIX/RADIAL uniforms are only declared (and\n // uploaded) when the matching #define is set — the byte-identity precedent from the wave material.\n uDispFreqX: { value: 0 },\n uDispFreqZ: { value: 0 },\n uDispAmount: { value: 0 },\n uDetailFreq: { value: 0 },\n uDetailAmount: { value: 0 },\n uTwFreqX: { value: 0 },\n uTwFreqY: { value: 0 },\n uTwFreqZ: { value: 0 },\n uTwPowX: { value: 0 },\n uTwPowY: { value: 0 },\n uTwPowZ: { value: 0 },\n uHelixTurns: { value: 0 },\n uHelixRadius: { value: 0 },\n uHelixRoll: { value: 0 },\n uHelixPhase: { value: 0 },\n uRadialAmount: { value: 0 },\n uRadialArc: { value: 0 },\n uRadialSpread: { value: 0 },\n uRadialRadius: { value: 0 },\n uRadialCenter: { value: 0 },\n uShedModel: { value: new THREE.Matrix4() },\n uShedSpeed: { value: 0 },\n uShedSeed: { value: 0 },\n },\n vertexShader: particleVertexShader,\n fragmentShader: particleFragmentShader,\n transparent: true,\n depthTest: false, // always composite OVER the waves...\n depthWrite: false, // ...and never occlude anything (additive glints)\n blending: THREE.AdditiveBlending,\n });\n this.points = new THREE.Points(this.geometry, this.material);\n this.points.frustumCulled = false; // positions are shader-computed; the base geometry is dummy\n this.points.renderOrder = 10; // after the waves (0..5)\n }\n\n /** Reconcile to `cfg`: rebuild the seeded buffers if the layout signature changed, then push the\n * frame-independent uniforms. `loopSeconds` is scene-level (passed in). Called from refresh(). */\n sync(cfg: ParticlesConfig, loopSeconds: number): void {\n const count = Math.max(0, Math.floor(cfg.count));\n const edgeBias = cfg.edgeBias ?? 1;\n const bias = cfg.bias ?? 0;\n const sig = `${count}|${cfg.seed}|${edgeBias}|${bias}`;\n if (sig !== this.sig) {\n this.sig = sig;\n const { position, aSeed, aRnd, aUv } = buildParticleAttributes(\n count,\n cfg.seed,\n edgeBias,\n bias,\n );\n this.geometry.setAttribute(\"position\", new THREE.BufferAttribute(position, 3));\n this.geometry.setAttribute(\"aSeed\", new THREE.BufferAttribute(aSeed, 1));\n this.geometry.setAttribute(\"aRnd\", new THREE.BufferAttribute(aRnd, 4));\n this.geometry.setAttribute(\"aUv\", new THREE.BufferAttribute(aUv, 2));\n this.geometry.setDrawRange(0, count);\n }\n const u = this.material.uniforms;\n u.uLoopSeconds.value = loopSeconds;\n u.uLife.value = cfg.life ?? 6;\n u.uPartSpeed.value = cfg.speed ?? 1;\n u.uSize.value = cfg.size;\n u.uSizeJitter.value = cfg.sizeJitter ?? 0;\n u.uTwinkle.value = cfg.twinkle ?? 0;\n u.uDrift.value = cfg.drift ?? 0;\n u.uRise.value = cfg.rise ?? 0;\n u.uSwirl.value = cfg.swirl ?? 0;\n u.uWander.value = cfg.wander ?? 0;\n u.uShape.value = SHAPE_INDEX[cfg.shape ?? \"glitter\"] ?? 0;\n setLinear(u.uColor.value as THREE.Vector3, cfg.color ?? DEFAULT_COLOR);\n setLinear(u.uColor2.value as THREE.Vector3, cfg.color2 ?? cfg.color ?? DEFAULT_COLOR);\n }\n\n /** Push the per-frame frame basis (the camera can move, so this runs every frame). */\n frame(f: ParticleFrame, pixelRatio: number): void {\n const u = this.material.uniforms;\n (u.uCenter.value as THREE.Vector3).copy(f.center);\n (u.uRight.value as THREE.Vector3).copy(f.right);\n (u.uUp.value as THREE.Vector3).copy(f.up);\n u.uPixelRatio.value = pixelRatio;\n }\n\n /** Bind the OWNING wave's shape: mirror its shape #defines + shape uniforms + world matrix so the\n * dust rides the SAME deform as the ribbon. Recompiles the point program only when the define set\n * changes. Called from refresh() each frame with the wave's live state. */\n configure(shape: {\n defines: Record<string, string>;\n uniforms: Record<string, THREE.IUniform>;\n matrixWorld: THREE.Matrix4;\n speed: number;\n seed: number;\n }): void {\n const want = shape.defines;\n const cur = (this.material.defines ?? {}) as Record<string, string>;\n if (Object.keys(want).sort().join(\",\") !== Object.keys(cur).sort().join(\",\")) {\n this.material.defines = { ...want };\n this.material.needsUpdate = true; // define set changed → recompile the point program\n }\n const u = this.material.uniforms;\n for (const name of SHAPE_UNIFORMS) {\n const src = shape.uniforms[name];\n if (!src || u[name] === undefined) continue;\n const dst = u[name].value;\n if (typeof src.value === \"number\") u[name].value = src.value;\n else if (dst && typeof (dst as { copy?: unknown }).copy === \"function\") {\n (dst as THREE.Vector3).copy(src.value as THREE.Vector3);\n }\n }\n (u.uShedModel.value as THREE.Matrix4).copy(shape.matrixWorld);\n u.uShedSpeed.value = shape.speed;\n u.uShedSeed.value = shape.seed;\n }\n\n /** Advance the field to scene time `t` (= the same `t` the waves get). */\n setTime(t: number): void {\n this.material.uniforms.uTime.value = t;\n }\n\n dispose(): void {\n this.geometry.dispose();\n this.material.dispose();\n }\n}\n"],"mappings":";;;;;AAyBA,SAAS,WAAW,MAA4B;CAC9C,IAAI,IAAI,SAAS;CACjB,aAAa;EACX,KAAK;EACL,IAAK,IAAI,aAAc;EACvB,IAAI,IAAI,KAAK,KAAK,IAAK,MAAM,IAAK,IAAI,CAAC;EACvC,IAAK,IAAI,KAAK,KAAK,IAAK,MAAM,GAAI,KAAK,CAAC,IAAK;EAC7C,SAAS,IAAK,MAAM,QAAS,KAAK;CACpC;AACF;AAKA,MAAM,cAAc,IAAI,MAAM,MAAM;AACpC,SAAS,UAAU,QAAuB,KAAmB;CAC3D,MAAM,IAAI,YAAY,IAAI,GAAG;CAC7B,OAAO,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1B;AAEA,MAAM,gBAAgB;;AAGtB,MAAM,cAAsC;CAAE,SAAS;CAAG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AS,YAC1D,IAAuB,KAAK,IAAI,KAAsB;EAE1D;EACA,EAAG,WAAW,MAAwB,KAAK,MAAM,WAAW;EAC5D,EAAE,WAAW,QAAQ,MAAM;EAC3B,EAAE,UAAU,QAAQ,MAAM;CAC5B;;CAGA,QAAQ,GAAiB;EACvB,KAAK,SAAS,SAAS,MAAM,QAAQ;CACvC;CAEA,UAAgB;EACd,KAAK,SAAS,QAAQ;EACtB,KAAK,SAAS,QAAQ;CACxB;AACF"}
1
+ {"version":3,"file":"particleField.js","names":[],"sources":["../../src/renderer/particleField.ts"],"sourcesContent":["import * as THREE from \"three\";\nimport type { ParticlesConfig } from \"../config/model\";\nimport { RIPPLE_SLOTS } from \"./interaction\";\nimport { particleFragmentShader, particleVertexShader } from \"./shaders\";\n\n/**\n * A WAVE's additive particle / dust field: a single {@link THREE.Points} whose every particle is placed\n * and animated ENTIRELY in the vertex shader from `uTime` + baked per-particle attributes, so the field\n * is deterministic — the same `(count, seed, edgeBias, bias)` yields byte-identical buffers, and all\n * motion is a pure function of the scene time `t` (so timeOffset scrub / loopSeconds / paused reproduce).\n *\n * One field belongs to ONE wave (created/disposed alongside it, like {@link WavePalette}). Every particle\n * spawns on that wave's DEFORMED surface / edge (via the shared waveShape chunk, riding the exact deform\n * the ribbon uses) and drifts outward from the wave centre. Byte-identical when off: absent\n * `wave.particles` ⇒ the renderer never creates a field.\n */\nexport interface ParticleFrame {\n /** The owning wave's world-space centre — drift radiates from here. */\n center: THREE.Vector3;\n /** Screen-right / screen-up unit vectors (world space) for screen-relative motion. */\n right: THREE.Vector3;\n up: THREE.Vector3;\n}\n\n/** Deterministic PRNG (mulberry32): a pure function of the seed, so a `(count, seed)` layout\n * reproduces exactly. NEVER Math.random — that would desync timeOffset scrub / loop / paused. */\nfunction mulberry32(seed: number): () => number {\n let a = seed >>> 0;\n return () => {\n a |= 0;\n a = (a + 0x6d2b79f5) | 0;\n let t = Math.imul(a ^ (a >>> 15), 1 | a);\n t = (t + Math.imul(t ^ (t >>> 7), 61 | t)) ^ t;\n return ((t ^ (t >>> 14)) >>> 0) / 4294967296;\n };\n}\n\n// sRGB hex → linear RGB. Replicates WaveRenderer.hexToLinearVec3 locally to avoid a circular import\n// (the renderer imports this module): three's ColorManagement linearizes on parse, so read .r/.g/.b\n// directly — a second convertSRGBToLinear() would double-linearize.\nconst HEX_SCRATCH = new THREE.Color();\nfunction setLinear(target: THREE.Vector3, hex: string): void {\n const c = HEX_SCRATCH.set(hex);\n target.set(c.r, c.g, c.b);\n}\n\nconst DEFAULT_COLOR = \"#ffcf8a\"; // warm gold\n\n/**\n * Edge of the square canvas a {@link ParticlesConfig.spriteUrl} is rasterized into. SVG has no\n * intrinsic pixel size, so something has to choose one — this is it.\n *\n * 256² RGBA is ~256 KB (~350 KB with mipmaps), which is LESS than the per-particle attribute\n * buffers a 20k field already uploads (~800 KB): one texture serves every particle in the field, so\n * sprite artwork is not what makes a dust field expensive. 256 also covers the largest sprite the\n * hardware will draw — gl.ALIASED_POINT_SIZE_RANGE tops out around 511 px, and `size` clamps to 200\n * before the pixel-ratio multiply.\n */\nconst SPRITE_PX = 256;\n\n/** Sprite-shape name → the int the fragment shader branches on (see particleFragmentShader). */\nconst SHAPE_INDEX: Record<string, number> = { glitter: 0, soft: 1, ring: 2, star: 3, streak: 4 };\n\n/** The owning wave's shape uniforms mirrored onto the particle material so the dust rides the same\n * deform as the ribbon. Names match the wave material's uniforms 1:1 (copied by value in configure). */\nconst SHAPE_UNIFORMS = [\n \"uDispFreqX\",\n \"uDispFreqZ\",\n \"uDispAmount\",\n \"uDetailFreq\",\n \"uDetailAmount\",\n \"uTwFreqX\",\n \"uTwFreqY\",\n \"uTwFreqZ\",\n \"uTwPowX\",\n \"uTwPowY\",\n \"uTwPowZ\",\n \"uHelixTurns\",\n \"uHelixRadius\",\n \"uHelixRoll\",\n \"uHelixPhase\",\n \"uRadialAmount\",\n \"uRadialArc\",\n \"uRadialSpread\",\n \"uRadialRadius\",\n \"uRadialCenter\",\n] as const;\n\n/** The owning wave's POINTER-FIELD uniforms, mirrored the same way so the dust reads the exact\n * cursor state the ribbon does (see pointerFieldChunk). Only uploaded under POINTER_FX — configure()\n * copies them regardless, which is a handful of scalars. The ripple entries are ARRAYS: those are\n * shared by reference (the wave owns them and applyPointerField mutates them in place), so a click\n * costs no per-frame copy. Mirroring rather than a second CPU write also keeps capture determinism\n * for free — applyInteractionRest zeroes the wave's uPointerActive / uRippleAmp, and the dust\n * inherits that rest state on the same frame (updateSceneFx runs after applyInteraction). */\nconst POINTER_UNIFORMS = [\n \"uPointer\",\n \"uPointerActive\",\n \"uPointerRadius\",\n \"uPointerAspect\",\n \"uPointerAgitate\",\n \"uPointerPush\",\n \"uPointerWake\",\n \"uPointerVel\",\n \"uShapeFlow\",\n \"uRippleOrigin\",\n \"uRippleAge\",\n \"uRippleAmp\",\n \"uPointerRipple\",\n] as const;\n\n/** Build the seeded per-particle attribute buffers. Pure function of `(count, seed, edgeBias, bias)` —\n * exported so a unit test can assert reproducibility without a GPU. */\nexport function buildParticleAttributes(\n count: number,\n seed: number,\n edgeBias = 1,\n bias = 0,\n): {\n position: Float32Array;\n aSeed: Float32Array;\n aRnd: Float32Array;\n aUv: Float32Array;\n} {\n const rand = mulberry32(seed >>> 0 || 1);\n const position = new Float32Array(count * 3); // dummy — the vertex shader computes real positions\n const aSeed = new Float32Array(count);\n const aRnd = new Float32Array(count * 4);\n const aUv = new Float32Array(count * 2);\n for (let i = 0; i < count; i++) {\n aSeed[i] = rand();\n aRnd[i * 4 + 0] = rand();\n aRnd[i * 4 + 1] = rand();\n aRnd[i * 4 + 2] = rand();\n aRnd[i * 4 + 3] = rand();\n }\n // aUv in a SEPARATE pass so adding/changing it never shifts the aSeed/aRnd RNG sequence above. aUv.x\n // = the flank position across the ribbon width; `bias` skews it toward one side (`u^p`, p<1 crowds\n // →1, p>1 crowds →0; p=1 / bias 0 leaves it untouched). aUv.y = WHERE ALONG the ribbon the particle\n // spawns, interpolated by `edgeBias`: 0 → uniform across the whole SURFACE, 1 → crowded to the outer\n // rim/EDGE (`1 − rand²·0.45`, the silk-dissolving-into-glitter look).\n const pexp = bias === 0 ? 1 : Math.exp(-bias * 2);\n const eb = Math.min(Math.max(edgeBias, 0), 1);\n for (let i = 0; i < count; i++) {\n const ux = rand();\n aUv[i * 2 + 0] = bias === 0 ? ux : Math.pow(ux, pexp);\n const e = rand();\n const rim = 1.0 - e * e * 0.45; // outer-rim biased\n aUv[i * 2 + 1] = e + (rim - e) * eb; // mix(surface, edge) by edgeBias\n }\n return { position, aSeed, aRnd, aUv };\n}\n\nexport class ParticleField {\n readonly points: THREE.Points;\n private readonly geometry = new THREE.BufferGeometry();\n private readonly material: THREE.ShaderMaterial;\n /** Layout signature — only these rebuild the seeded buffers; the rest are live uniforms. */\n private sig = \"\";\n /** Rasterized user artwork for shape \"sprite\", and the url it came from (so a repeat sync is a\n * no-op). `spriteFailedUrl` latches a broken image so a bad url is not retried every frame. */\n private sprite?: THREE.CanvasTexture;\n private spriteUrl = \"\";\n private spriteFailedUrl = \"\";\n private disposed = false;\n /** Defines this field owns (currently just PARTICLE_SPRITE), merged over the wave's in configure().\n * Set only once a texture is actually bound, so the sampler never compiles without one. */\n private ownDefines: Record<string, string> = {};\n /** Called when a sprite finishes rasterizing, so a paused/settled renderer redraws with it. */\n private readonly onReady?: () => void;\n\n constructor(onReady?: () => void) {\n this.onReady = onReady;\n this.material = new THREE.ShaderMaterial({\n uniforms: {\n uTime: { value: 0 },\n uLoopSeconds: { value: 0 },\n uLife: { value: 6 },\n uPartSpeed: { value: 1 },\n uSize: { value: 2 },\n uSizeJitter: { value: 0 },\n uTwinkle: { value: 0 },\n uPixelRatio: { value: 1 },\n uColor: { value: new THREE.Vector3(1, 0.81, 0.54) },\n uColor2: { value: new THREE.Vector3(1, 0.81, 0.54) },\n uCenter: { value: new THREE.Vector3() },\n uRight: { value: new THREE.Vector3(1, 0, 0) },\n uUp: { value: new THREE.Vector3(0, 1, 0) },\n uDrift: { value: 0 },\n uRise: { value: 0 },\n uSwirl: { value: 0 },\n uWander: { value: 0 },\n uShape: { value: 0 },\n // The owning wave's shape uniforms + world matrix, mirrored in configure() so the dust rides\n // the same deform as the ribbon. The nested HELIX/RADIAL uniforms are only declared (and\n // uploaded) when the matching #define is set — the byte-identity precedent from the wave material.\n uDispFreqX: { value: 0 },\n uDispFreqZ: { value: 0 },\n uDispAmount: { value: 0 },\n uDetailFreq: { value: 0 },\n uDetailAmount: { value: 0 },\n uTwFreqX: { value: 0 },\n uTwFreqY: { value: 0 },\n uTwFreqZ: { value: 0 },\n uTwPowX: { value: 0 },\n uTwPowY: { value: 0 },\n uTwPowZ: { value: 0 },\n uHelixTurns: { value: 0 },\n uHelixRadius: { value: 0 },\n uHelixRoll: { value: 0 },\n uHelixPhase: { value: 0 },\n uRadialAmount: { value: 0 },\n uRadialArc: { value: 0 },\n uRadialSpread: { value: 0 },\n uRadialRadius: { value: 0 },\n uRadialCenter: { value: 0 },\n uShedModel: { value: new THREE.Matrix4() },\n uShedSpeed: { value: 0 },\n uShedSeed: { value: 0 },\n // Pointer field, mirrored from the owning wave in configure() (read only under POINTER_FX).\n // The ripple arrays are sized to RIPPLE_SLOTS so the material is valid before the first\n // configure(); configure() then swaps in the wave's own arrays by reference.\n uPointer: { value: new THREE.Vector2() },\n uPointerActive: { value: 0 },\n uPointerRadius: { value: 0.6 },\n uPointerAspect: { value: 1 },\n uPointerAgitate: { value: 0 },\n uPointerPush: { value: 0 },\n uPointerWake: { value: 0 },\n uPointerVel: { value: new THREE.Vector2() },\n uShapeFlow: { value: 0 },\n uRippleOrigin: { value: Array.from({ length: RIPPLE_SLOTS }, () => new THREE.Vector2()) },\n uRippleAge: { value: Array.from({ length: RIPPLE_SLOTS }, () => 0) },\n uRippleAmp: { value: Array.from({ length: RIPPLE_SLOTS }, () => 0) },\n uPointerRipple: { value: 0 },\n uPartShove: { value: 1 },\n // User artwork (read only under PARTICLE_SPRITE, which is set only once this is non-null).\n uSprite: { value: null as THREE.Texture | null },\n },\n vertexShader: particleVertexShader,\n fragmentShader: particleFragmentShader,\n transparent: true,\n depthTest: false, // always composite OVER the waves...\n depthWrite: false, // ...and never occlude anything (additive glints)\n blending: THREE.AdditiveBlending,\n });\n this.points = new THREE.Points(this.geometry, this.material);\n this.points.frustumCulled = false; // positions are shader-computed; the base geometry is dummy\n this.points.renderOrder = 10; // after the waves (0..5)\n }\n\n /** Reconcile to `cfg`: rebuild the seeded buffers if the layout signature changed, then push the\n * frame-independent uniforms. `loopSeconds` is scene-level (passed in). Called from refresh(). */\n sync(cfg: ParticlesConfig, loopSeconds: number): void {\n const count = Math.max(0, Math.floor(cfg.count));\n const edgeBias = cfg.edgeBias ?? 1;\n const bias = cfg.bias ?? 0;\n const sig = `${count}|${cfg.seed}|${edgeBias}|${bias}`;\n if (sig !== this.sig) {\n this.sig = sig;\n const { position, aSeed, aRnd, aUv } = buildParticleAttributes(\n count,\n cfg.seed,\n edgeBias,\n bias,\n );\n this.geometry.setAttribute(\"position\", new THREE.BufferAttribute(position, 3));\n this.geometry.setAttribute(\"aSeed\", new THREE.BufferAttribute(aSeed, 1));\n this.geometry.setAttribute(\"aRnd\", new THREE.BufferAttribute(aRnd, 4));\n this.geometry.setAttribute(\"aUv\", new THREE.BufferAttribute(aUv, 2));\n this.geometry.setDrawRange(0, count);\n }\n const u = this.material.uniforms;\n u.uLoopSeconds.value = loopSeconds;\n u.uLife.value = cfg.life ?? 6;\n u.uPartSpeed.value = cfg.speed ?? 1;\n u.uSize.value = cfg.size;\n u.uSizeJitter.value = cfg.sizeJitter ?? 0;\n u.uTwinkle.value = cfg.twinkle ?? 0;\n u.uDrift.value = cfg.drift ?? 0;\n u.uRise.value = cfg.rise ?? 0;\n u.uSwirl.value = cfg.swirl ?? 0;\n u.uWander.value = cfg.wander ?? 0;\n u.uShape.value = SHAPE_INDEX[cfg.shape ?? \"glitter\"] ?? 0;\n u.uPartShove.value = cfg.pointerShove ?? 1;\n this.syncSprite(cfg.shape === \"sprite\" ? (cfg.spriteUrl ?? \"\") : \"\");\n setLinear(u.uColor.value as THREE.Vector3, cfg.color ?? DEFAULT_COLOR);\n setLinear(u.uColor2.value as THREE.Vector3, cfg.color2 ?? cfg.color ?? DEFAULT_COLOR);\n }\n\n /** Push the per-frame frame basis (the camera can move, so this runs every frame). */\n frame(f: ParticleFrame, pixelRatio: number): void {\n const u = this.material.uniforms;\n (u.uCenter.value as THREE.Vector3).copy(f.center);\n (u.uRight.value as THREE.Vector3).copy(f.right);\n (u.uUp.value as THREE.Vector3).copy(f.up);\n u.uPixelRatio.value = pixelRatio;\n }\n\n /** Bind the OWNING wave's shape AND cursor state: mirror its #defines + shape uniforms + pointer\n * uniforms + world matrix, so the dust rides the same deform as the ribbon and reacts to the same\n * pointer field. Recompiles the point program only when the define set changes — which is why the\n * defines must come from CONFIG only (shapeDefines), never from live input. Called from refresh()\n * each frame with the wave's live state. */\n configure(shape: {\n defines: Record<string, string>;\n uniforms: Record<string, THREE.IUniform>;\n matrixWorld: THREE.Matrix4;\n speed: number;\n seed: number;\n }): void {\n const want = { ...shape.defines, ...this.ownDefines };\n const cur = (this.material.defines ?? {}) as Record<string, string>;\n if (Object.keys(want).sort().join(\",\") !== Object.keys(cur).sort().join(\",\")) {\n this.material.defines = { ...want };\n this.material.needsUpdate = true; // define set changed → recompile the point program\n }\n const u = this.material.uniforms;\n for (const name of SHAPE_UNIFORMS) this.mirror(shape.uniforms, name);\n for (const name of POINTER_UNIFORMS) this.mirror(shape.uniforms, name);\n (u.uShedModel.value as THREE.Matrix4).copy(shape.matrixWorld);\n u.uShedSpeed.value = shape.speed;\n u.uShedSeed.value = shape.seed;\n }\n\n /** Reconcile the sprite texture to `url` (\"\" = none). Cheap and idempotent: a repeat call with the\n * same url does nothing, and a url that already failed is never retried. */\n private syncSprite(url: string): void {\n if (url === this.spriteUrl) return;\n this.spriteUrl = url;\n this.clearSprite();\n if (url && url !== this.spriteFailedUrl) this.loadSprite(url);\n }\n\n /** Drop the current sprite and fall back to the procedural shapes (which is what `uShape` still\n * holds, so a field mid-load or with a broken image draws \"glitter\" rather than nothing). */\n private clearSprite(): void {\n if (!this.sprite) return;\n this.sprite.dispose();\n this.sprite = undefined;\n this.material.uniforms.uSprite.value = null;\n if (this.ownDefines.PARTICLE_SPRITE !== undefined) {\n this.ownDefines = {};\n this.material.needsUpdate = true; // configure() will also notice, but a paused field may not tick\n }\n }\n\n /**\n * Rasterize `url` into a square {@link SPRITE_PX} texture and bind it.\n *\n * Deliberately the BACKGROUND-image pattern (load → apply → ask for a redraw) rather than\n * loadPaletteImage's fire-and-forget TextureLoader: a thumbnail or poster snapshotted while the\n * texture was still in flight would capture blank dust — the same class of bug that made\n * image-driven preset thumbnails render empty.\n */\n private loadSprite(url: string): void {\n const img = new Image();\n img.decoding = \"async\";\n // data:/blob: are same-origin already; anything else must be CORS-clean or the canvas taints\n // and readback (thumbnails, posters, captureImage) throws.\n if (!url.startsWith(\"data:\") && !url.startsWith(\"blob:\")) img.crossOrigin = \"anonymous\";\n img.addEventListener(\n \"load\",\n () => {\n // The config may have moved on (or the field been disposed) while this was decoding.\n if (this.disposed || this.spriteUrl !== url) return;\n const canvas = document.createElement(\"canvas\");\n canvas.width = SPRITE_PX;\n canvas.height = SPRITE_PX;\n const ctx = canvas.getContext(\"2d\");\n if (!ctx) return;\n // CONTAIN the artwork: a point sprite is always square (gl_PointCoord spans 0..1 on both\n // axes), so non-square art has to be letterboxed or it draws stretched. An SVG with no\n // intrinsic size reports 0 in some browsers — fall back to filling the square.\n const iw = img.naturalWidth || SPRITE_PX;\n const ih = img.naturalHeight || SPRITE_PX;\n const fit = Math.min(SPRITE_PX / iw, SPRITE_PX / ih);\n const w = iw * fit;\n const h = ih * fit;\n ctx.drawImage(img, (SPRITE_PX - w) / 2, (SPRITE_PX - h) / 2, w, h);\n const tex = new THREE.CanvasTexture(canvas);\n tex.colorSpace = THREE.SRGBColorSpace;\n // Mipmaps matter here in a way they do not for the palette: `sizeJitter` and the birth/death\n // fade draw the SAME texture at wildly different pixel sizes, and gl_PointCoord's\n // derivatives across a point sprite are well defined, so the GPU picks a sane level.\n tex.generateMipmaps = true;\n tex.minFilter = THREE.LinearMipmapLinearFilter;\n tex.magFilter = THREE.LinearFilter;\n tex.wrapS = THREE.ClampToEdgeWrapping;\n tex.wrapT = THREE.ClampToEdgeWrapping;\n this.sprite = tex;\n this.material.uniforms.uSprite.value = tex;\n this.ownDefines = { PARTICLE_SPRITE: \"\" };\n this.material.needsUpdate = true; // sampler appears → recompile the point program\n this.onReady?.(); // a paused / settled renderer would otherwise never draw it\n },\n { once: true },\n );\n // Latch the failure so a broken url is not re-requested on every sync.\n img.addEventListener(\n \"error\",\n () => {\n this.spriteFailedUrl = url;\n },\n { once: true },\n );\n img.src = url;\n }\n\n /** Copy one uniform across from the owning wave: numbers by value, vectors/matrices in place, and\n * arrays (the ripple slots) by reference — the wave owns those and mutates them in place. */\n private mirror(src: Record<string, THREE.IUniform>, name: string): void {\n const from = src[name];\n const to = this.material.uniforms[name];\n if (!from || !to) return;\n const dst = to.value;\n if (typeof from.value === \"number\" || Array.isArray(from.value)) to.value = from.value;\n else if (dst && typeof (dst as { copy?: unknown }).copy === \"function\") {\n (dst as THREE.Vector3).copy(from.value as THREE.Vector3);\n }\n }\n\n /** Advance the field to scene time `t` (= the same `t` the waves get). */\n setTime(t: number): void {\n this.material.uniforms.uTime.value = t;\n }\n\n dispose(): void {\n this.disposed = true;\n this.sprite?.dispose();\n this.geometry.dispose();\n this.material.dispose();\n }\n}\n"],"mappings":";;;;;AA0BA,SAAS,WAAW,MAA4B;CAC9C,IAAI,IAAI,SAAS;CACjB,aAAa;EACX,KAAK;EACL,IAAK,IAAI,aAAc;EACvB,IAAI,IAAI,KAAK,KAAK,IAAK,MAAM,IAAK,IAAI,CAAC;EACvC,IAAK,IAAI,KAAK,KAAK,IAAK,MAAM,GAAI,KAAK,CAAC,IAAK;EAC7C,SAAS,IAAK,MAAM,QAAS,K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