sparcoon 0.0.1

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 (74) hide show
  1. package/LICENSE +21 -0
  2. package/dist/behaviorModules/FXBehaviorDirectionalGravity.d.ts +21 -0
  3. package/dist/behaviorModules/FXBehaviorDirectionalGravity.js +47 -0
  4. package/dist/behaviorModules/FXBehaviorModule.d.ts +14 -0
  5. package/dist/behaviorModules/FXBehaviorModule.js +9 -0
  6. package/dist/behaviorModules/FXBehaviorPointGravity.d.ts +39 -0
  7. package/dist/behaviorModules/FXBehaviorPointGravity.js +110 -0
  8. package/dist/behaviorModules/FXBehaviorScaleOverLife.d.ts +22 -0
  9. package/dist/behaviorModules/FXBehaviorScaleOverLife.js +66 -0
  10. package/dist/behaviorModules/FXBehaviorTorqueDamping.d.ts +20 -0
  11. package/dist/behaviorModules/FXBehaviorTorqueDamping.js +48 -0
  12. package/dist/behaviorModules/FXBehaviorTorqueNoise.d.ts +26 -0
  13. package/dist/behaviorModules/FXBehaviorTorqueNoise.js +66 -0
  14. package/dist/behaviorModules/FXBehaviorVelocityDamping.d.ts +20 -0
  15. package/dist/behaviorModules/FXBehaviorVelocityDamping.js +49 -0
  16. package/dist/behaviorModules/FXBehaviorVelocityNoise.d.ts +26 -0
  17. package/dist/behaviorModules/FXBehaviorVelocityNoise.js +73 -0
  18. package/dist/color/FXColor.Internal.d.ts +7 -0
  19. package/dist/color/FXColor.Internal.js +42 -0
  20. package/dist/color/FXColor.d.ts +234 -0
  21. package/dist/color/FXColor.js +636 -0
  22. package/dist/elements/FXEmitter.Internal.d.ts +10 -0
  23. package/dist/elements/FXEmitter.Internal.js +5 -0
  24. package/dist/elements/FXEmitter.d.ts +29 -0
  25. package/dist/elements/FXEmitter.js +154 -0
  26. package/dist/index.d.ts +18 -0
  27. package/dist/index.js +18 -0
  28. package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +13 -0
  29. package/dist/instancedParticle/FXInstancedParticle.Internal.js +216 -0
  30. package/dist/instancedParticle/FXInstancedParticle.d.ts +17 -0
  31. package/dist/instancedParticle/FXInstancedParticle.js +93 -0
  32. package/dist/instancedParticle/shared.d.ts +27 -0
  33. package/dist/instancedParticle/shared.js +123 -0
  34. package/dist/miscellaneous/FXTransparencyMode.d.ts +7 -0
  35. package/dist/miscellaneous/asserts.d.ts +21 -0
  36. package/dist/miscellaneous/asserts.js +48 -0
  37. package/dist/miscellaneous/math.d.ts +8 -0
  38. package/dist/miscellaneous/math.js +11 -0
  39. package/dist/miscellaneous/miscellaneous.d.ts +33 -0
  40. package/dist/miscellaneous/miscellaneous.js +66 -0
  41. package/dist/miscellaneous/texture/FXTextureView.Internal.d.ts +49 -0
  42. package/dist/miscellaneous/texture/FXTextureView.Internal.js +6 -0
  43. package/dist/miscellaneous/texture/FXTextureView.d.ts +72 -0
  44. package/dist/miscellaneous/texture/FXTextureView.js +234 -0
  45. package/dist/miscellaneous/webglCapabilities.d.ts +1 -0
  46. package/dist/miscellaneous/webglCapabilities.js +45 -0
  47. package/dist/renderingModules/FXRenderingColorOverLife.d.ts +14 -0
  48. package/dist/renderingModules/FXRenderingColorOverLife.js +32 -0
  49. package/dist/renderingModules/FXRenderingColorOverVelocity.d.ts +15 -0
  50. package/dist/renderingModules/FXRenderingColorOverVelocity.js +37 -0
  51. package/dist/renderingModules/FXRenderingModule.d.ts +8 -0
  52. package/dist/renderingModules/FXRenderingModule.js +9 -0
  53. package/dist/renderingModules/FXRenderingTexture.d.ts +14 -0
  54. package/dist/renderingModules/FXRenderingTexture.js +26 -0
  55. package/dist/shaders/FXRenderingColorOverLife.glsl.js +3 -0
  56. package/dist/shaders/FXRenderingColorOverVelocity.glsl.js +3 -0
  57. package/dist/shaders/FXRenderingTexture.glsl.js +3 -0
  58. package/dist/spawnModules/FXSpawnBox.d.ts +27 -0
  59. package/dist/spawnModules/FXSpawnBox.js +67 -0
  60. package/dist/spawnModules/FXSpawnModule.d.ts +9 -0
  61. package/dist/spawnModules/FXSpawnModule.js +9 -0
  62. package/dist/spawnModules/FXSpawnOffset.d.ts +21 -0
  63. package/dist/spawnModules/FXSpawnOffset.js +49 -0
  64. package/dist/spawnModules/FXSpawnRandomLifetime.d.ts +20 -0
  65. package/dist/spawnModules/FXSpawnRandomLifetime.js +47 -0
  66. package/dist/spawnModules/FXSpawnRandomRotation.d.ts +20 -0
  67. package/dist/spawnModules/FXSpawnRandomRotation.js +45 -0
  68. package/dist/spawnModules/FXSpawnRandomScale.d.ts +26 -0
  69. package/dist/spawnModules/FXSpawnRandomScale.js +60 -0
  70. package/dist/spawnModules/FXSpawnRandomTorque.d.ts +20 -0
  71. package/dist/spawnModules/FXSpawnRandomTorque.js +45 -0
  72. package/dist/spawnModules/FXSpawnRandomVelocity.d.ts +26 -0
  73. package/dist/spawnModules/FXSpawnRandomVelocity.js +64 -0
  74. package/package.json +55 -0
@@ -0,0 +1,636 @@
1
+ import { MathUtils, Color, Vector4 } from 'three';
2
+ import { assertValidNumber } from '../miscellaneous/asserts.js';
3
+ import { srgbToLinear, linearToSRGB } from '../miscellaneous/math.js';
4
+ import { COLORS } from './FXColor.Internal.js';
5
+
6
+ /** RGBA color with RGB, HSL, hex, and named color support */
7
+ class FXColor {
8
+ constructor(...args) {
9
+ this._private_rInternal = 1;
10
+ this._private_gInternal = 1;
11
+ this._private_bInternal = 1;
12
+ this._private_aInternal = 1;
13
+ this._private_hInternal = 0;
14
+ this._private_sInternal = 0;
15
+ this._private_lInternal = 1;
16
+ this._private_dirtyInternal = false;
17
+ this._private_rgbDirty = false;
18
+ this._private_hslDirty = false;
19
+ if (args.length > 0) {
20
+ this.set(...args);
21
+ }
22
+ }
23
+ /** Black (0x000000) */
24
+ static get black() {
25
+ return new FXColor("black");
26
+ }
27
+ /** White (0xffffff) */
28
+ static get white() {
29
+ return new FXColor("white");
30
+ }
31
+ /** Red (0xff0000) */
32
+ static get red() {
33
+ return new FXColor("red");
34
+ }
35
+ /** Green (0x008000) */
36
+ static get green() {
37
+ return new FXColor("green");
38
+ }
39
+ /** Blue (0x0000ff) */
40
+ static get blue() {
41
+ return new FXColor("blue");
42
+ }
43
+ /** Yellow (0xffff00) */
44
+ static get yellow() {
45
+ return new FXColor("yellow");
46
+ }
47
+ /** Cyan (0x00ffff) */
48
+ static get cyan() {
49
+ return new FXColor("cyan");
50
+ }
51
+ /** Magenta (0xff00ff) */
52
+ static get magenta() {
53
+ return new FXColor("magenta");
54
+ }
55
+ /** Gray (0x808080) */
56
+ static get gray() {
57
+ return new FXColor("gray");
58
+ }
59
+ /** Grey (0x808080) */
60
+ static get grey() {
61
+ return new FXColor("grey");
62
+ }
63
+ /** Silver (0xc0c0c0) */
64
+ static get silver() {
65
+ return new FXColor("silver");
66
+ }
67
+ /** Maroon (0x800000) */
68
+ static get maroon() {
69
+ return new FXColor("maroon");
70
+ }
71
+ /** Olive (0x808000) */
72
+ static get olive() {
73
+ return new FXColor("olive");
74
+ }
75
+ /** Lime (0x00ff00) */
76
+ static get lime() {
77
+ return new FXColor("lime");
78
+ }
79
+ /** Aqua (0x00ffff) */
80
+ static get aqua() {
81
+ return new FXColor("aqua");
82
+ }
83
+ /** Teal (0x008080) */
84
+ static get teal() {
85
+ return new FXColor("teal");
86
+ }
87
+ /** Navy (0x000080) */
88
+ static get navy() {
89
+ return new FXColor("navy");
90
+ }
91
+ /** Fuchsia (0xff00ff) */
92
+ static get fuchsia() {
93
+ return new FXColor("fuchsia");
94
+ }
95
+ /** Purple (0x800080) */
96
+ static get purple() {
97
+ return new FXColor("purple");
98
+ }
99
+ /** Orange (0xffa500) */
100
+ static get orange() {
101
+ return new FXColor("orange");
102
+ }
103
+ /** Pink (0xffc0cb) */
104
+ static get pink() {
105
+ return new FXColor("pink");
106
+ }
107
+ /** Brown (0xa52a2a) */
108
+ static get brown() {
109
+ return new FXColor("brown");
110
+ }
111
+ /** Gold (0xffd700) */
112
+ static get gold() {
113
+ return new FXColor("gold");
114
+ }
115
+ /** Violet (0xee82ee) */
116
+ static get violet() {
117
+ return new FXColor("violet");
118
+ }
119
+ /** Indigo (0x4b0082) */
120
+ static get indigo() {
121
+ return new FXColor("indigo");
122
+ }
123
+ /** Coral (0xff7f50) */
124
+ static get coral() {
125
+ return new FXColor("coral");
126
+ }
127
+ /** Salmon (0xfa8072) */
128
+ static get salmon() {
129
+ return new FXColor("salmon");
130
+ }
131
+ /** Khaki (0xf0e68c) */
132
+ static get khaki() {
133
+ return new FXColor("khaki");
134
+ }
135
+ /** Plum (0xdda0dd) */
136
+ static get plum() {
137
+ return new FXColor("plum");
138
+ }
139
+ /** Orchid (0xda70d6) */
140
+ static get orchid() {
141
+ return new FXColor("orchid");
142
+ }
143
+ /** Tan (0xd2b48c) */
144
+ static get tan() {
145
+ return new FXColor("tan");
146
+ }
147
+ /** Beige (0xf5f5dc) */
148
+ static get beige() {
149
+ return new FXColor("beige");
150
+ }
151
+ /** Mint (0x98fb98) */
152
+ static get mint() {
153
+ return new FXColor("mint");
154
+ }
155
+ /** Lavender (0xe6e6fa) */
156
+ static get lavender() {
157
+ return new FXColor("lavender");
158
+ }
159
+ /** Crimson (0xdc143c) */
160
+ static get crimson() {
161
+ return new FXColor("crimson");
162
+ }
163
+ /** Azure (0xf0ffff) */
164
+ static get azure() {
165
+ return new FXColor("azure");
166
+ }
167
+ /** Ivory (0xfffff0) */
168
+ static get ivory() {
169
+ return new FXColor("ivory");
170
+ }
171
+ /** Snow (0xfffafa) */
172
+ static get snow() {
173
+ return new FXColor("snow");
174
+ }
175
+ /** Red component (0 to 1) */
176
+ get r() {
177
+ this._private_ensureRGBUpdatedFromHSL();
178
+ return this._private_rInternal;
179
+ }
180
+ /** Green component (0 to 1) */
181
+ get g() {
182
+ this._private_ensureRGBUpdatedFromHSL();
183
+ return this._private_gInternal;
184
+ }
185
+ /** Blue component (0 to 1) */
186
+ get b() {
187
+ this._private_ensureRGBUpdatedFromHSL();
188
+ return this._private_bInternal;
189
+ }
190
+ /** Alpha component (0 to 1) */
191
+ get a() {
192
+ return this._private_aInternal;
193
+ }
194
+ /** Hue component (0 to 360) */
195
+ get hue() {
196
+ this._private_ensureHSLUpdatedFromRGB();
197
+ return this._private_hInternal;
198
+ }
199
+ /** Saturation component (0 to 1) */
200
+ get saturation() {
201
+ this._private_ensureHSLUpdatedFromRGB();
202
+ return this._private_sInternal;
203
+ }
204
+ /** Lightness component (0 to 1) */
205
+ get lightness() {
206
+ this._private_ensureHSLUpdatedFromRGB();
207
+ return this._private_lInternal;
208
+ }
209
+ /** @internal */
210
+ get dirty() {
211
+ return this._private_dirtyInternal;
212
+ }
213
+ /** Red component (0 to 1) */
214
+ set r(value) {
215
+ assertValidNumber(value, "UIColor.r");
216
+ value = MathUtils.clamp(value, 0, 1);
217
+ this._private_ensureRGBUpdatedFromHSL();
218
+ if (value !== this._private_rInternal) {
219
+ this._private_rInternal = value;
220
+ this._private_hslDirty = true;
221
+ this._private_dirtyInternal = true;
222
+ }
223
+ }
224
+ /** Green component (0 to 1) */
225
+ set g(value) {
226
+ assertValidNumber(value, "UIColor.g");
227
+ value = MathUtils.clamp(value, 0, 1);
228
+ this._private_ensureRGBUpdatedFromHSL();
229
+ if (value !== this._private_gInternal) {
230
+ this._private_gInternal = value;
231
+ this._private_hslDirty = true;
232
+ this._private_dirtyInternal = true;
233
+ }
234
+ }
235
+ /** Blue component (0 to 1) */
236
+ set b(value) {
237
+ assertValidNumber(value, "UIColor.b");
238
+ value = MathUtils.clamp(value, 0, 1);
239
+ this._private_ensureRGBUpdatedFromHSL();
240
+ if (value !== this._private_bInternal) {
241
+ this._private_bInternal = value;
242
+ this._private_hslDirty = true;
243
+ this._private_dirtyInternal = true;
244
+ }
245
+ }
246
+ /** Alpha component (0 to 1) */
247
+ set a(value) {
248
+ assertValidNumber(value, "UIColor.a");
249
+ value = MathUtils.clamp(value, 0, 1);
250
+ if (value !== this._private_aInternal) {
251
+ this._private_aInternal = value;
252
+ this._private_dirtyInternal = true;
253
+ }
254
+ }
255
+ /** Hue component (0 to 360) */
256
+ set hue(value) {
257
+ assertValidNumber(value, "UIColor.hue");
258
+ value = MathUtils.clamp(value, 0, 360);
259
+ this._private_ensureHSLUpdatedFromRGB();
260
+ if (value !== this._private_hInternal) {
261
+ this._private_hInternal = value;
262
+ this._private_rgbDirty = true;
263
+ this._private_dirtyInternal = true;
264
+ }
265
+ }
266
+ /** Saturation component (0 to 1) */
267
+ set saturation(value) {
268
+ assertValidNumber(value, "UIColor.saturation");
269
+ value = MathUtils.clamp(value, 0, 1);
270
+ this._private_ensureHSLUpdatedFromRGB();
271
+ if (value !== this._private_sInternal) {
272
+ this._private_sInternal = value;
273
+ this._private_rgbDirty = true;
274
+ this._private_dirtyInternal = true;
275
+ }
276
+ }
277
+ /** Lightness component (0 to 1) */
278
+ set lightness(value) {
279
+ assertValidNumber(value, "UIColor.lightness");
280
+ value = MathUtils.clamp(value, 0, 1);
281
+ this._private_ensureHSLUpdatedFromRGB();
282
+ if (value !== this._private_lInternal) {
283
+ this._private_lInternal = value;
284
+ this._private_rgbDirty = true;
285
+ this._private_dirtyInternal = true;
286
+ }
287
+ }
288
+ /** @internal */
289
+ setDirtyFalse() {
290
+ this._private_dirtyInternal = false;
291
+ }
292
+ set(...args) {
293
+ if (args.length === 0 || args[0] === undefined) {
294
+ return this.setRGBA(1, 1, 1, 1);
295
+ }
296
+ if (args.length >= 3 && typeof args[0] === "number") {
297
+ const [r, g, b, a = 1] = args;
298
+ return this.setRGBA(r, g, b, a);
299
+ }
300
+ const [firstArgument, a = 1] = args;
301
+ if (typeof firstArgument === "string") {
302
+ return firstArgument.startsWith("#")
303
+ ? this.setHexString(firstArgument)
304
+ : this.setColorName(firstArgument, a);
305
+ }
306
+ if (firstArgument instanceof FXColor) {
307
+ return this.copy(firstArgument);
308
+ }
309
+ if (firstArgument instanceof Color) {
310
+ return this.setThreeColor(firstArgument, a);
311
+ }
312
+ if (typeof firstArgument === "number") {
313
+ return this.setHexRGB(firstArgument, a);
314
+ }
315
+ throw new Error("UIColor.set: cannot create color from provided arguments");
316
+ }
317
+ /** Sets RGBA components directly */
318
+ setRGBA(r, g, b, a = this._private_aInternal) {
319
+ assertValidNumber(r, "UIColor.setRGBA.r");
320
+ assertValidNumber(g, "UIColor.setRGBA.g");
321
+ assertValidNumber(b, "UIColor.setRGBA.b");
322
+ assertValidNumber(a, "UIColor.setRGBA.a");
323
+ r = MathUtils.clamp(r, 0, 1);
324
+ g = MathUtils.clamp(g, 0, 1);
325
+ b = MathUtils.clamp(b, 0, 1);
326
+ a = MathUtils.clamp(a, 0, 1);
327
+ this._private_ensureRGBUpdatedFromHSL();
328
+ if (r !== this._private_rInternal ||
329
+ g !== this._private_gInternal ||
330
+ b !== this._private_bInternal ||
331
+ a !== this._private_aInternal) {
332
+ this._private_rInternal = r;
333
+ this._private_gInternal = g;
334
+ this._private_bInternal = b;
335
+ this._private_aInternal = a;
336
+ this._private_hslDirty = true;
337
+ this._private_dirtyInternal = true;
338
+ }
339
+ return this;
340
+ }
341
+ /** Returns RGBA as 32-bit hex (RRGGBBAA) */
342
+ getHexRGBA() {
343
+ this._private_ensureRGBUpdatedFromHSL();
344
+ return ((Math.round(this._private_rInternal * 255) << 24) |
345
+ (Math.round(this._private_gInternal * 255) << 16) |
346
+ (Math.round(this._private_bInternal * 255) << 8) |
347
+ Math.round(this._private_aInternal * 255));
348
+ }
349
+ /** Returns RGB as 24-bit hex (RRGGBB) */
350
+ getHexRGB() {
351
+ this._private_ensureRGBUpdatedFromHSL();
352
+ return ((Math.round(this._private_rInternal * 255) << 16) |
353
+ (Math.round(this._private_gInternal * 255) << 8) |
354
+ Math.round(this._private_bInternal * 255));
355
+ }
356
+ /** Returns RGB as hex string ("#ffffff") */
357
+ getHexStringRGB() {
358
+ const hex = this.getHexRGB();
359
+ return `#${hex.toString(16).padStart(6, "0")}`;
360
+ }
361
+ /** Returns RGBA as hex string ("#ffffffff") */
362
+ getHexStringRGBA() {
363
+ const hex = this.getHexRGBA();
364
+ return `#${hex.toString(16).padStart(8, "0")}`;
365
+ }
366
+ /** Sets from 32-bit hex RGBA (RRGGBBAA) */
367
+ setHexRGBA(hex) {
368
+ assertValidNumber(hex, "UIColor.setHexRGBA.hex");
369
+ this._private_ensureRGBUpdatedFromHSL();
370
+ const r = ((hex >> 16) & 0xff) / 255;
371
+ const g = ((hex >> 8) & 0xff) / 255;
372
+ const b = (hex & 0xff) / 255;
373
+ const a = ((hex >> 24) & 0xff) / 255;
374
+ if (r !== this._private_rInternal ||
375
+ g !== this._private_gInternal ||
376
+ b !== this._private_bInternal ||
377
+ a !== this._private_aInternal) {
378
+ this._private_rInternal = r;
379
+ this._private_gInternal = g;
380
+ this._private_bInternal = b;
381
+ this._private_aInternal = a;
382
+ this._private_hslDirty = true;
383
+ this._private_dirtyInternal = true;
384
+ }
385
+ return this;
386
+ }
387
+ /** Sets from 24-bit hex RGB (RRGGBB) */
388
+ setHexRGB(hex, a = this._private_aInternal) {
389
+ assertValidNumber(hex, "UIColor.setHexRGB.hex");
390
+ assertValidNumber(a, "UIColor.setHexRGB.a");
391
+ a = MathUtils.clamp(a, 0, 1);
392
+ this._private_ensureRGBUpdatedFromHSL();
393
+ const r = ((hex >> 16) & 0xff) / 255;
394
+ const g = ((hex >> 8) & 0xff) / 255;
395
+ const b = (hex & 0xff) / 255;
396
+ if (r !== this._private_rInternal ||
397
+ g !== this._private_gInternal ||
398
+ b !== this._private_bInternal ||
399
+ a !== this._private_aInternal) {
400
+ this._private_rInternal = r;
401
+ this._private_gInternal = g;
402
+ this._private_bInternal = b;
403
+ this._private_aInternal = a;
404
+ this._private_hslDirty = true;
405
+ this._private_dirtyInternal = true;
406
+ }
407
+ return this;
408
+ }
409
+ /**
410
+ * Sets from hex string.
411
+ *
412
+ * @param hexString - Format: "#ffffff" or "#ffffffff"
413
+ * @throws If format invalid
414
+ */
415
+ setHexString(hexString) {
416
+ if (!hexString.startsWith("#")) {
417
+ throw new Error(`UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"`);
418
+ }
419
+ const hex = hexString.slice(1);
420
+ if (hex.length === 6) {
421
+ const hexNumber = parseInt(hex, 16);
422
+ if (isNaN(hexNumber)) {
423
+ throw new Error(`UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"`);
424
+ }
425
+ return this.setHexRGB(hexNumber);
426
+ }
427
+ else if (hex.length === 8) {
428
+ const hexNumber = parseInt(hex, 16);
429
+ if (isNaN(hexNumber)) {
430
+ throw new Error(`UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"`);
431
+ }
432
+ return this.setHexRGBA(hexNumber);
433
+ }
434
+ else {
435
+ throw new Error(`UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"`);
436
+ }
437
+ }
438
+ /** Sets from HSL values */
439
+ setHSL(h, s, l, a = this._private_aInternal) {
440
+ assertValidNumber(h, "UIColor.setHSL.h");
441
+ assertValidNumber(s, "UIColor.setHSL.s");
442
+ assertValidNumber(l, "UIColor.setHSL.l");
443
+ assertValidNumber(a, "UIColor.setHSL.a");
444
+ h = MathUtils.clamp(h, 0, 360);
445
+ s = MathUtils.clamp(s, 0, 1);
446
+ l = MathUtils.clamp(l, 0, 1);
447
+ a = MathUtils.clamp(a, 0, 1);
448
+ this._private_ensureHSLUpdatedFromRGB();
449
+ if (h !== this._private_hInternal ||
450
+ s !== this._private_sInternal ||
451
+ l !== this._private_lInternal ||
452
+ a !== this._private_aInternal) {
453
+ this._private_hInternal = h;
454
+ this._private_sInternal = s;
455
+ this._private_lInternal = l;
456
+ this._private_aInternal = a;
457
+ this._private_rgbDirty = true;
458
+ this._private_dirtyInternal = true;
459
+ }
460
+ return this;
461
+ }
462
+ /**
463
+ * Sets from predefined name.
464
+ *
465
+ * @throws If color name unknown
466
+ */
467
+ setColorName(colorName, a = this._private_aInternal) {
468
+ assertValidNumber(a, "UIColor.setColorName.a");
469
+ a = MathUtils.clamp(a, 0, 1);
470
+ const normalizedName = colorName.toLowerCase().trim();
471
+ const hex = COLORS[normalizedName];
472
+ if (hex === undefined) {
473
+ throw new Error(`UIColor.setColorName.colorName: unknown color name`);
474
+ }
475
+ return this.setHexRGB(hex, a);
476
+ }
477
+ /** Sets from linear (GLSL) color space */
478
+ setGLSLColor(r, g, b, a = this._private_aInternal) {
479
+ assertValidNumber(r, "UIColor.setGLSLColor.r");
480
+ assertValidNumber(g, "UIColor.setGLSLColor.g");
481
+ assertValidNumber(b, "UIColor.setGLSLColor.b");
482
+ assertValidNumber(a, "UIColor.setGLSLColor.a");
483
+ a = MathUtils.clamp(a, 0, 1);
484
+ this._private_ensureRGBUpdatedFromHSL();
485
+ const sRGBR = linearToSRGB(r);
486
+ const sRGBG = linearToSRGB(g);
487
+ const sRGBB = linearToSRGB(b);
488
+ if (sRGBR !== this._private_rInternal ||
489
+ sRGBG !== this._private_gInternal ||
490
+ sRGBB !== this._private_bInternal ||
491
+ a !== this._private_aInternal) {
492
+ this._private_rInternal = sRGBR;
493
+ this._private_gInternal = sRGBG;
494
+ this._private_bInternal = sRGBB;
495
+ this._private_aInternal = a;
496
+ this._private_hslDirty = true;
497
+ this._private_dirtyInternal = true;
498
+ }
499
+ return this;
500
+ }
501
+ /** Sets from Three.js Color */
502
+ setThreeColor(threeColor, a = this._private_aInternal) {
503
+ assertValidNumber(a, "UIColor.setThreeColor.a");
504
+ a = MathUtils.clamp(a, 0, 1);
505
+ this._private_ensureRGBUpdatedFromHSL();
506
+ if (threeColor.r !== this._private_rInternal ||
507
+ threeColor.g !== this._private_gInternal ||
508
+ threeColor.b !== this._private_bInternal ||
509
+ a !== this._private_aInternal) {
510
+ this._private_rInternal = threeColor.r;
511
+ this._private_gInternal = threeColor.g;
512
+ this._private_bInternal = threeColor.b;
513
+ this._private_aInternal = a;
514
+ this._private_hslDirty = true;
515
+ this._private_dirtyInternal = true;
516
+ }
517
+ return this;
518
+ }
519
+ /** Returns CSS color string ("rgba(255, 0, 0, 1)") */
520
+ toCSSColor() {
521
+ this._private_ensureRGBUpdatedFromHSL();
522
+ const r = Math.round(this._private_rInternal * 255);
523
+ const g = Math.round(this._private_gInternal * 255);
524
+ const b = Math.round(this._private_bInternal * 255);
525
+ return `rgba(${r}, ${g}, ${b}, ${this._private_aInternal})`;
526
+ }
527
+ /** Converts to linear (GLSL) color space */
528
+ toGLSLColor(result = new Vector4()) {
529
+ this._private_ensureRGBUpdatedFromHSL();
530
+ result.x = srgbToLinear(this._private_rInternal);
531
+ result.y = srgbToLinear(this._private_gInternal);
532
+ result.z = srgbToLinear(this._private_bInternal);
533
+ result.w = this._private_aInternal;
534
+ return result;
535
+ }
536
+ /** Converts to Three.js Color (without alpha) */
537
+ toThreeColor(result = new Color()) {
538
+ this._private_ensureRGBUpdatedFromHSL();
539
+ result.r = this._private_rInternal;
540
+ result.g = this._private_gInternal;
541
+ result.b = this._private_bInternal;
542
+ return result;
543
+ }
544
+ /** Copies from another color */
545
+ copy(color) {
546
+ if (color instanceof FXColor) {
547
+ this._private_ensureRGBUpdatedFromHSL();
548
+ color._private_ensureRGBUpdatedFromHSL();
549
+ if (this._private_rInternal !== color._private_rInternal ||
550
+ this._private_gInternal !== color._private_gInternal ||
551
+ this._private_bInternal !== color._private_bInternal ||
552
+ this._private_aInternal !== color._private_aInternal) {
553
+ this._private_rInternal = color._private_rInternal;
554
+ this._private_gInternal = color._private_gInternal;
555
+ this._private_bInternal = color._private_bInternal;
556
+ this._private_aInternal = color._private_aInternal;
557
+ this._private_hslDirty = true;
558
+ this._private_dirtyInternal = true;
559
+ }
560
+ }
561
+ else {
562
+ this._private_ensureRGBUpdatedFromHSL();
563
+ if (this._private_rInternal !== color.r ||
564
+ this._private_gInternal !== color.g ||
565
+ this._private_bInternal !== color.b ||
566
+ this._private_aInternal !== 1) {
567
+ this._private_rInternal = color.r;
568
+ this._private_gInternal = color.g;
569
+ this._private_bInternal = color.b;
570
+ this._private_aInternal = 1;
571
+ this._private_hslDirty = true;
572
+ this._private_dirtyInternal = true;
573
+ }
574
+ }
575
+ return this;
576
+ }
577
+ /** Returns copy of this color */
578
+ clone() {
579
+ this._private_ensureRGBUpdatedFromHSL();
580
+ return new FXColor(this._private_rInternal, this._private_gInternal, this._private_bInternal, this._private_aInternal);
581
+ }
582
+ /** @internal */
583
+ _private_ensureRGBUpdatedFromHSL() {
584
+ if (this._private_rgbDirty) {
585
+ const { _private_hInternal: h, _private_sInternal: s, _private_lInternal: l } = this;
586
+ const c = (1 - Math.abs(2 * l - 1)) * s;
587
+ const hp = h / 60;
588
+ const x = c * (1 - Math.abs((hp % 2) - 1));
589
+ let [r, g, b] = hp < 1
590
+ ? [c, x, 0]
591
+ : hp < 2
592
+ ? [x, c, 0]
593
+ : hp < 3
594
+ ? [0, c, x]
595
+ : hp < 4
596
+ ? [0, x, c]
597
+ : hp < 5
598
+ ? [x, 0, c]
599
+ : [c, 0, x];
600
+ const m = l - c / 2;
601
+ this._private_rInternal = r + m;
602
+ this._private_gInternal = g + m;
603
+ this._private_bInternal = b + m;
604
+ this._private_rgbDirty = false;
605
+ }
606
+ }
607
+ _private_ensureHSLUpdatedFromRGB() {
608
+ if (this._private_hslDirty) {
609
+ const { _private_rInternal: r, _private_gInternal: g, _private_bInternal: b } = this;
610
+ const max = Math.max(r, g, b);
611
+ const min = Math.min(r, g, b);
612
+ const d = max - min;
613
+ const l = (max + min) / 2;
614
+ let h = 0;
615
+ if (d !== 0) {
616
+ if (max === r) {
617
+ h = (g - b) / d + (g < b ? 6 : 0);
618
+ }
619
+ else if (max === g) {
620
+ h = (b - r) / d + 2;
621
+ }
622
+ else {
623
+ h = (r - g) / d + 4;
624
+ }
625
+ h *= 60;
626
+ }
627
+ const s = d === 0 ? 0 : d / (1 - Math.abs(2 * l - 1));
628
+ this._private_hInternal = h;
629
+ this._private_sInternal = s;
630
+ this._private_lInternal = l;
631
+ this._private_hslDirty = false;
632
+ }
633
+ }
634
+ }
635
+
636
+ export { FXColor };
@@ -0,0 +1,10 @@
1
+ export interface FXEmitterOptions {
2
+ expectedCapacity: number;
3
+ capacityStep: number;
4
+ }
5
+ export interface FXEmitterPlayOptions {
6
+ duration: number;
7
+ }
8
+ export declare const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
9
+ export declare const EMITTER_DEFAULT_CAPACITY_STEP = 32;
10
+ export declare const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
@@ -0,0 +1,5 @@
1
+ const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
2
+ const EMITTER_DEFAULT_CAPACITY_STEP = 32;
3
+ const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
4
+
5
+ export { EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_EXPECTED_CAPACITY };
@@ -0,0 +1,29 @@
1
+ import { Object3D } from "three";
2
+ import type { FXBehaviorModule } from "../behaviorModules/FXBehaviorModule";
3
+ import type { FXRenderingModule } from "../renderingModules/FXRenderingModule";
4
+ import type { FXSpawnModule } from "../spawnModules/FXSpawnModule";
5
+ import type { FXEmitterPlayOptions } from "./FXEmitter.Internal";
6
+ export interface FXEmitterOptions {
7
+ expectedCapacity: number;
8
+ capacityStep: number;
9
+ automaticallyDestroyModules: boolean;
10
+ }
11
+ export declare class FXEmitter extends Object3D {
12
+ private readonly spawnSequence;
13
+ private readonly behaviorSequence;
14
+ private readonly renderingSequence;
15
+ automaticallyDestroyModules: boolean;
16
+ private readonly mesh;
17
+ private emissionRate;
18
+ private emissionAccumulator;
19
+ private emissionDuration;
20
+ private emissionElapsed;
21
+ constructor(spawnSequence: FXSpawnModule[], behaviorSequence: readonly FXBehaviorModule[], renderingSequence: readonly FXRenderingModule[], options?: Partial<FXEmitterOptions>);
22
+ static onWillRender: (deltaTime: number) => void;
23
+ destroy(): void;
24
+ burst(count: number): void;
25
+ reset(): void;
26
+ play(rate: number, options?: Partial<FXEmitterPlayOptions>): void;
27
+ stop(): void;
28
+ private readonly onRendering;
29
+ }