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,73 @@
1
+ import { MathUtils } from 'three';
2
+ import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z, generateNoise3D } from '../miscellaneous/miscellaneous.js';
4
+ import { FXBehaviorModule } from './FXBehaviorModule.js';
5
+
6
+ /**
7
+ * Applies noise-based acceleration to particles.
8
+ *
9
+ * Uses 2D noise based on particle position. Higher scale means finer noise detail.
10
+ */
11
+ class FXBehaviorVelocityNoise extends FXBehaviorModule {
12
+ /**
13
+ * @param scale - Noise frequency range. Accepts number, tuple, or range object
14
+ * @param strength - Force multiplier range. Accepts number, tuple, or range object
15
+ */
16
+ constructor(scale = 100, strength = 500) {
17
+ super();
18
+ /** @internal */
19
+ this.requiredProperties = { builtin: "Matrix4" };
20
+ this._private_scaleInternal = resolveFXRangeConfig(scale);
21
+ assertValidPositiveNumber(this._private_scaleInternal.min, `UIBehaviorVelocityNoise.constructor.scale.min`);
22
+ assertValidPositiveNumber(this._private_scaleInternal.max, `UIBehaviorVelocityNoise.constructor.scale.max`);
23
+ this._private_strengthInternal = resolveFXRangeConfig(strength);
24
+ assertValidNonNegativeNumber(this._private_strengthInternal.min, `UIBehaviorVelocityNoise.constructor.strength.min`);
25
+ assertValidNonNegativeNumber(this._private_strengthInternal.max, `UIBehaviorVelocityNoise.constructor.strength.max`);
26
+ }
27
+ /** Noise frequency range */
28
+ get scale() {
29
+ return this._private_scaleInternal;
30
+ }
31
+ /** Force multiplier range */
32
+ get strength() {
33
+ return this._private_strengthInternal;
34
+ }
35
+ /** Noise frequency range */
36
+ set scale(value) {
37
+ this._private_scaleInternal = resolveFXRangeConfig(value);
38
+ assertValidPositiveNumber(this._private_scaleInternal.min, `UIBehaviorVelocityNoise.scale.min`);
39
+ assertValidPositiveNumber(this._private_scaleInternal.max, `UIBehaviorVelocityNoise.scale.max`);
40
+ }
41
+ /** Force multiplier range */
42
+ set strength(value) {
43
+ this._private_strengthInternal = resolveFXRangeConfig(value);
44
+ assertValidNonNegativeNumber(this._private_strengthInternal.min, `UIBehaviorVelocityNoise.strength.min`);
45
+ assertValidNonNegativeNumber(this._private_strengthInternal.max, `UIBehaviorVelocityNoise.strength.max`);
46
+ }
47
+ /** @internal */
48
+ update(properties, instanceCount, deltaTime) {
49
+ const { builtin } = properties;
50
+ const { array, itemSize } = builtin;
51
+ for (let i = 0; i < instanceCount; i++) {
52
+ const itemOffset = i * itemSize;
53
+ const x = array[itemOffset + BUILTIN_OFFSET_POSITION_X];
54
+ const y = array[itemOffset + BUILTIN_OFFSET_POSITION_Y];
55
+ const z = array[itemOffset + BUILTIN_OFFSET_POSITION_Z];
56
+ // Constant over the life of a particle but different for each particle
57
+ const scaleT = array[itemOffset + BUILTIN_OFFSET_RANDOM_C];
58
+ const scale = MathUtils.lerp(this._private_scaleInternal.min, this._private_scaleInternal.max, scaleT);
59
+ const noiseX = generateNoise3D(x * scale, y * scale, z * scale);
60
+ const noiseY = generateNoise3D((x + 100) * scale, (y + 100) * scale, (z + 100) * scale);
61
+ const noiseZ = generateNoise3D((x - 200) * scale, (y - 200) * scale, (z - 200) * scale);
62
+ // Constant over the life of a particle but different for each particle
63
+ const strengthT = array[itemOffset + BUILTIN_OFFSET_RANDOM_A];
64
+ const strength = MathUtils.lerp(this._private_strengthInternal.min, this._private_strengthInternal.max, strengthT);
65
+ array[itemOffset + BUILTIN_OFFSET_VELOCITY_X] += noiseX * strength * deltaTime;
66
+ array[itemOffset + BUILTIN_OFFSET_VELOCITY_Y] += noiseY * strength * deltaTime;
67
+ array[itemOffset + BUILTIN_OFFSET_VELOCITY_Z] += noiseZ * strength * deltaTime;
68
+ }
69
+ builtin.needsUpdate = true;
70
+ }
71
+ }
72
+
73
+ export { FXBehaviorVelocityNoise };
@@ -0,0 +1,7 @@
1
+ import type { Color } from "three";
2
+ import type { FXColor } from "./FXColor";
3
+ /** Color configuration as Three.js Color, hex number, hex string, or FXColor */
4
+ export type FXColorConfig = Color | number | string | FXColor;
5
+ /** Predefined color names */
6
+ export type FXColorName = "black" | "white" | "red" | "green" | "blue" | "yellow" | "cyan" | "magenta" | "gray" | "grey" | "silver" | "maroon" | "olive" | "lime" | "aqua" | "teal" | "navy" | "fuchsia" | "purple" | "orange" | "pink" | "brown" | "gold" | "violet" | "indigo" | "coral" | "salmon" | "khaki" | "plum" | "orchid" | "tan" | "beige" | "mint" | "lavender" | "crimson" | "azure" | "ivory" | "snow";
7
+ export declare const COLORS: Record<string, number | undefined>;
@@ -0,0 +1,42 @@
1
+ const COLORS = {
2
+ black: 0x000000,
3
+ white: 0xffffff,
4
+ red: 0xff0000,
5
+ green: 0x008000,
6
+ blue: 0x0000ff,
7
+ yellow: 0xffff00,
8
+ cyan: 0x00ffff,
9
+ magenta: 0xff00ff,
10
+ gray: 0x808080,
11
+ grey: 0x808080,
12
+ silver: 0xc0c0c0,
13
+ maroon: 0x800000,
14
+ olive: 0x808000,
15
+ lime: 0x00ff00,
16
+ aqua: 0x00ffff,
17
+ teal: 0x008080,
18
+ navy: 0x000080,
19
+ fuchsia: 0xff00ff,
20
+ purple: 0x800080,
21
+ orange: 0xffa500,
22
+ pink: 0xffc0cb,
23
+ brown: 0xa52a2a,
24
+ gold: 0xffd700,
25
+ violet: 0xee82ee,
26
+ indigo: 0x4b0082,
27
+ coral: 0xff7f50,
28
+ salmon: 0xfa8072,
29
+ khaki: 0xf0e68c,
30
+ plum: 0xdda0dd,
31
+ orchid: 0xda70d6,
32
+ tan: 0xd2b48c,
33
+ beige: 0xf5f5dc,
34
+ mint: 0x98fb98,
35
+ lavender: 0xe6e6fa,
36
+ crimson: 0xdc143c,
37
+ azure: 0xf0ffff,
38
+ ivory: 0xfffff0,
39
+ snow: 0xfffafa,
40
+ };
41
+
42
+ export { COLORS };
@@ -0,0 +1,234 @@
1
+ import { Color, Vector4 } from "three";
2
+ import type { FXColorConfig, FXColorName } from "./FXColor.Internal";
3
+ /** RGBA color with RGB, HSL, hex, and named color support */
4
+ export declare class FXColor {
5
+ private rInternal;
6
+ private gInternal;
7
+ private bInternal;
8
+ private aInternal;
9
+ private hInternal;
10
+ private sInternal;
11
+ private lInternal;
12
+ private dirtyInternal;
13
+ private rgbDirty;
14
+ private hslDirty;
15
+ constructor();
16
+ /**
17
+ * @param r - Red (0-1)
18
+ * @param g - Green (0-1)
19
+ * @param b - Blue (0-1)
20
+ * @param a - Alpha (0-1)
21
+ */
22
+ constructor(r: number, g: number, b: number, a?: number);
23
+ /**
24
+ * @param colorName - Named color
25
+ * @param a - Alpha (0-1)
26
+ */
27
+ constructor(colorName: FXColorName, a?: number);
28
+ /**
29
+ * @param threeColor - Three.js Color object
30
+ * @param a - Alpha (0-1)
31
+ */
32
+ constructor(threeColor: Color, a?: number);
33
+ /**
34
+ * @param hexRGB - Hex RGB value (e.g., 0xff0000)
35
+ * @param a - Alpha (0-1)
36
+ */
37
+ constructor(hexRGB: number, a?: number);
38
+ /**
39
+ * @param hexString - Hex string (e.g., "#ffffff" or "#ffffffff")
40
+ */
41
+ constructor(hexString?: string);
42
+ /**
43
+ * @param uiColor - FXColor object to copy from
44
+ */
45
+ constructor(uiColor?: FXColor);
46
+ /**
47
+ * @param uiColorConfig - FXColorConfig object
48
+ */
49
+ constructor(uiColorConfig?: FXColorConfig);
50
+ /** Black (0x000000) */
51
+ static get black(): FXColor;
52
+ /** White (0xffffff) */
53
+ static get white(): FXColor;
54
+ /** Red (0xff0000) */
55
+ static get red(): FXColor;
56
+ /** Green (0x008000) */
57
+ static get green(): FXColor;
58
+ /** Blue (0x0000ff) */
59
+ static get blue(): FXColor;
60
+ /** Yellow (0xffff00) */
61
+ static get yellow(): FXColor;
62
+ /** Cyan (0x00ffff) */
63
+ static get cyan(): FXColor;
64
+ /** Magenta (0xff00ff) */
65
+ static get magenta(): FXColor;
66
+ /** Gray (0x808080) */
67
+ static get gray(): FXColor;
68
+ /** Grey (0x808080) */
69
+ static get grey(): FXColor;
70
+ /** Silver (0xc0c0c0) */
71
+ static get silver(): FXColor;
72
+ /** Maroon (0x800000) */
73
+ static get maroon(): FXColor;
74
+ /** Olive (0x808000) */
75
+ static get olive(): FXColor;
76
+ /** Lime (0x00ff00) */
77
+ static get lime(): FXColor;
78
+ /** Aqua (0x00ffff) */
79
+ static get aqua(): FXColor;
80
+ /** Teal (0x008080) */
81
+ static get teal(): FXColor;
82
+ /** Navy (0x000080) */
83
+ static get navy(): FXColor;
84
+ /** Fuchsia (0xff00ff) */
85
+ static get fuchsia(): FXColor;
86
+ /** Purple (0x800080) */
87
+ static get purple(): FXColor;
88
+ /** Orange (0xffa500) */
89
+ static get orange(): FXColor;
90
+ /** Pink (0xffc0cb) */
91
+ static get pink(): FXColor;
92
+ /** Brown (0xa52a2a) */
93
+ static get brown(): FXColor;
94
+ /** Gold (0xffd700) */
95
+ static get gold(): FXColor;
96
+ /** Violet (0xee82ee) */
97
+ static get violet(): FXColor;
98
+ /** Indigo (0x4b0082) */
99
+ static get indigo(): FXColor;
100
+ /** Coral (0xff7f50) */
101
+ static get coral(): FXColor;
102
+ /** Salmon (0xfa8072) */
103
+ static get salmon(): FXColor;
104
+ /** Khaki (0xf0e68c) */
105
+ static get khaki(): FXColor;
106
+ /** Plum (0xdda0dd) */
107
+ static get plum(): FXColor;
108
+ /** Orchid (0xda70d6) */
109
+ static get orchid(): FXColor;
110
+ /** Tan (0xd2b48c) */
111
+ static get tan(): FXColor;
112
+ /** Beige (0xf5f5dc) */
113
+ static get beige(): FXColor;
114
+ /** Mint (0x98fb98) */
115
+ static get mint(): FXColor;
116
+ /** Lavender (0xe6e6fa) */
117
+ static get lavender(): FXColor;
118
+ /** Crimson (0xdc143c) */
119
+ static get crimson(): FXColor;
120
+ /** Azure (0xf0ffff) */
121
+ static get azure(): FXColor;
122
+ /** Ivory (0xfffff0) */
123
+ static get ivory(): FXColor;
124
+ /** Snow (0xfffafa) */
125
+ static get snow(): FXColor;
126
+ /** Red component (0 to 1) */
127
+ get r(): number;
128
+ /** Green component (0 to 1) */
129
+ get g(): number;
130
+ /** Blue component (0 to 1) */
131
+ get b(): number;
132
+ /** Alpha component (0 to 1) */
133
+ get a(): number;
134
+ /** Hue component (0 to 360) */
135
+ get hue(): number;
136
+ /** Saturation component (0 to 1) */
137
+ get saturation(): number;
138
+ /** Lightness component (0 to 1) */
139
+ get lightness(): number;
140
+ /** Red component (0 to 1) */
141
+ set r(value: number);
142
+ /** Green component (0 to 1) */
143
+ set g(value: number);
144
+ /** Blue component (0 to 1) */
145
+ set b(value: number);
146
+ /** Alpha component (0 to 1) */
147
+ set a(value: number);
148
+ /** Hue component (0 to 360) */
149
+ set hue(value: number);
150
+ /** Saturation component (0 to 1) */
151
+ set saturation(value: number);
152
+ /** Lightness component (0 to 1) */
153
+ set lightness(value: number);
154
+ /** Sets to white (default) */
155
+ set(): this;
156
+ /**
157
+ * @param r - Red (0-1)
158
+ * @param g - Green (0-1)
159
+ * @param b - Blue (0-1)
160
+ * @param a - Alpha (0-1)
161
+ */
162
+ set(r: number, g: number, b: number, a?: number): this;
163
+ /**
164
+ * @param colorName - Named color
165
+ * @param a - Alpha (0-1)
166
+ */
167
+ set(colorName: FXColorName, a?: number): this;
168
+ /**
169
+ * @param threeColor - Three.js Color object
170
+ * @param a - Alpha (0-1)
171
+ */
172
+ set(threeColor: Color, a?: number): this;
173
+ /**
174
+ * @param hexRGB - Hex RGB value (e.g., 0xff0000)
175
+ * @param a - Alpha (0-1)
176
+ */
177
+ set(hexRGB: number, a?: number): this;
178
+ /**
179
+ * @param hexString - Hex string (e.g., "#ffffff" or "#ffffffff")
180
+ */
181
+ set(hexString: string): this;
182
+ /**
183
+ * @param uiColor - FXColor object to copy from
184
+ */
185
+ set(uiColor: FXColor): this;
186
+ /**
187
+ * @param uiColorConfig - FXColorConfig object
188
+ */
189
+ set(uiColorConfig?: FXColorConfig): this;
190
+ /** Sets RGBA components directly */
191
+ setRGBA(r: number, g: number, b: number, a?: number): this;
192
+ /** Returns RGBA as 32-bit hex (RRGGBBAA) */
193
+ getHexRGBA(): number;
194
+ /** Returns RGB as 24-bit hex (RRGGBB) */
195
+ getHexRGB(): number;
196
+ /** Returns RGB as hex string ("#ffffff") */
197
+ getHexStringRGB(): string;
198
+ /** Returns RGBA as hex string ("#ffffffff") */
199
+ getHexStringRGBA(): string;
200
+ /** Sets from 32-bit hex RGBA (RRGGBBAA) */
201
+ setHexRGBA(hex: number): this;
202
+ /** Sets from 24-bit hex RGB (RRGGBB) */
203
+ setHexRGB(hex: number, a?: number): this;
204
+ /**
205
+ * Sets from hex string.
206
+ *
207
+ * @param hexString - Format: "#ffffff" or "#ffffffff"
208
+ * @throws If format invalid
209
+ */
210
+ setHexString(hexString: string): this;
211
+ /** Sets from HSL values */
212
+ setHSL(h: number, s: number, l: number, a?: number): this;
213
+ /**
214
+ * Sets from predefined name.
215
+ *
216
+ * @throws If color name unknown
217
+ */
218
+ setColorName(colorName: FXColorName, a?: number): this;
219
+ /** Sets from linear (GLSL) color space */
220
+ setGLSLColor(r: number, g: number, b: number, a?: number): this;
221
+ /** Sets from Three.js Color */
222
+ setThreeColor(threeColor: Color, a?: number): this;
223
+ /** Returns CSS color string ("rgba(255, 0, 0, 1)") */
224
+ toCSSColor(): string;
225
+ /** Converts to linear (GLSL) color space */
226
+ toGLSLColor(result?: Vector4): Vector4;
227
+ /** Converts to Three.js Color (without alpha) */
228
+ toThreeColor(result?: Color): Color;
229
+ /** Copies from another color */
230
+ copy(color: FXColor | Color): this;
231
+ /** Returns copy of this color */
232
+ clone(): FXColor;
233
+ private ensureHSLUpdatedFromRGB;
234
+ }