sparcoon 0.1.0 → 0.2.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 (100) hide show
  1. package/dist/{elements → emitter}/FXEmitter.Internal.d.ts +0 -4
  2. package/dist/emitter/FXEmitter.Internal.js +7 -0
  3. package/dist/{elements → emitter}/FXEmitter.d.ts +6 -13
  4. package/dist/{elements → emitter}/FXEmitter.js +15 -22
  5. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorDirectionalGravity.d.ts +2 -2
  6. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorDirectionalGravity.js +2 -2
  7. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorModule.d.ts +1 -1
  8. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorPointGravity.d.ts +2 -2
  9. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorPointGravity.js +2 -2
  10. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorScaleOverLife.d.ts +1 -1
  11. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorScaleOverLife.js +2 -2
  12. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorTorqueDamping.d.ts +1 -1
  13. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorTorqueDamping.js +2 -2
  14. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorTorqueNoise.d.ts +1 -1
  15. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorTorqueNoise.js +3 -3
  16. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorVelocityDamping.d.ts +1 -1
  17. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorVelocityDamping.js +2 -2
  18. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorVelocityNoise.d.ts +1 -1
  19. package/dist/{behaviorModules → emitter/behavior}/FXBehaviorVelocityNoise.js +3 -3
  20. package/dist/{spawnModules → emitter/spawn}/FXSpawnBox.d.ts +2 -2
  21. package/dist/{spawnModules → emitter/spawn}/FXSpawnBox.js +2 -2
  22. package/dist/{spawnModules → emitter/spawn}/FXSpawnModule.d.ts +1 -1
  23. package/dist/{spawnModules → emitter/spawn}/FXSpawnOffset.d.ts +2 -2
  24. package/dist/{spawnModules → emitter/spawn}/FXSpawnOffset.js +2 -2
  25. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomLifetime.d.ts +1 -1
  26. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomLifetime.js +2 -2
  27. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomRotation.d.ts +1 -1
  28. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomRotation.js +2 -2
  29. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomScale.d.ts +1 -1
  30. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomScale.js +2 -2
  31. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomTorque.d.ts +1 -1
  32. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomTorque.js +2 -2
  33. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomVelocity.d.ts +1 -1
  34. package/dist/{spawnModules → emitter/spawn}/FXSpawnRandomVelocity.js +2 -2
  35. package/dist/emitter/spawn/FXSpawnSphere.d.ts +38 -0
  36. package/dist/emitter/spawn/FXSpawnSphere.js +89 -0
  37. package/dist/index.d.ts +24 -20
  38. package/dist/index.js +25 -22
  39. package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +2 -9
  40. package/dist/instancedParticle/FXInstancedParticle.Internal.js +2 -188
  41. package/dist/instancedParticle/FXInstancedParticle.d.ts +3 -5
  42. package/dist/instancedParticle/FXInstancedParticle.js +4 -10
  43. package/dist/instancedParticle/shared.d.ts +1 -1
  44. package/dist/instancedParticle/shared.js +1 -1
  45. package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.d.ts +9 -0
  46. package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.Internal.js +108 -0
  47. package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.d.ts +15 -0
  48. package/dist/materials/FXDiffuseMaterial/FXDiffuseMaterial.js +18 -0
  49. package/dist/materials/FXMaterial.Internal.d.ts +4 -0
  50. package/dist/materials/FXMaterial.Internal.js +106 -0
  51. package/dist/materials/FXMaterial.d.ts +14 -0
  52. package/dist/materials/FXMaterial.js +21 -0
  53. package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.d.ts +4 -0
  54. package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.Internal.js +80 -0
  55. package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.d.ts +11 -0
  56. package/dist/materials/FXUnlitMaterial/FXUnlitMaterial.js +17 -0
  57. package/dist/materials/color-nodes/FXAnimatedTextureNode.d.ts +10 -0
  58. package/dist/materials/color-nodes/FXAnimatedTextureNode.js +41 -0
  59. package/dist/materials/color-nodes/FXColorNode.d.ts +3 -0
  60. package/dist/materials/color-nodes/FXColorNode.js +8 -0
  61. package/dist/materials/color-nodes/FXColorOverLifeNode.d.ts +7 -0
  62. package/dist/materials/color-nodes/FXColorOverLifeNode.js +38 -0
  63. package/dist/materials/color-nodes/FXStaticTextureNode.d.ts +5 -0
  64. package/dist/materials/color-nodes/FXStaticTextureNode.js +23 -0
  65. package/dist/materials/miscellaneous.d.ts +1 -0
  66. package/dist/materials/miscellaneous.js +25 -0
  67. package/dist/{color → miscellaneous/color}/FXColor.js +2 -2
  68. package/dist/miscellaneous/miscellaneous.d.ts +1 -1
  69. package/package.json +1 -1
  70. package/dist/elements/FXEmitter.Internal.js +0 -12
  71. package/dist/instancedParticle/FXParticleDepthMaterial.d.ts +0 -2
  72. package/dist/instancedParticle/FXParticleDepthMaterial.js +0 -52
  73. package/dist/instancedParticle/FXParticleLambertMaterial.d.ts +0 -4
  74. package/dist/instancedParticle/FXParticleLambertMaterial.js +0 -152
  75. package/dist/instancedParticle/FXParticleNormalsMode.d.ts +0 -5
  76. package/dist/instancedParticle/FXParticleNormalsMode.js +0 -8
  77. package/dist/instancedParticle/FXParticleRenderingMode.d.ts +0 -4
  78. package/dist/instancedParticle/FXParticleRenderingMode.js +0 -7
  79. package/dist/miscellaneous/texture/FXTextureView.Internal.js +0 -6
  80. package/dist/miscellaneous/texture/FXTextureView.js +0 -234
  81. package/dist/renderingModules/FXRenderingAnimatedTexture.d.ts +0 -5
  82. package/dist/renderingModules/FXRenderingAnimatedTexture.js +0 -14
  83. package/dist/renderingModules/FXRenderingColorOverLife.d.ts +0 -14
  84. package/dist/renderingModules/FXRenderingColorOverLife.js +0 -32
  85. package/dist/renderingModules/FXRenderingColorOverVelocity.d.ts +0 -15
  86. package/dist/renderingModules/FXRenderingColorOverVelocity.js +0 -37
  87. package/dist/renderingModules/FXRenderingModule.d.ts +0 -8
  88. package/dist/renderingModules/FXRenderingModule.js +0 -9
  89. package/dist/renderingModules/FXRenderingShadow.d.ts +0 -12
  90. package/dist/renderingModules/FXRenderingTexture.d.ts +0 -14
  91. package/dist/renderingModules/FXRenderingTexture.js +0 -26
  92. package/dist/shaders/FXRenderingAnimatedTexture.glsl.js +0 -3
  93. package/dist/shaders/FXRenderingColorOverLife.glsl.js +0 -3
  94. package/dist/shaders/FXRenderingColorOverVelocity.glsl.js +0 -3
  95. package/dist/shaders/FXRenderingTexture.glsl.js +0 -3
  96. /package/dist/{behaviorModules → emitter/behavior}/FXBehaviorModule.js +0 -0
  97. /package/dist/{spawnModules → emitter/spawn}/FXSpawnModule.js +0 -0
  98. /package/dist/{color → miscellaneous/color}/FXColor.Internal.d.ts +0 -0
  99. /package/dist/{color → miscellaneous/color}/FXColor.Internal.js +0 -0
  100. /package/dist/{color → miscellaneous/color}/FXColor.d.ts +0 -0
@@ -1,234 +0,0 @@
1
- import { Ferrsign3 } from 'ferrsign';
2
- import { Matrix3, Vector2, Texture } from 'three';
3
- import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../asserts.js';
4
- import { TEXTURE_DEFAULT_TEXTURE, TEXTURE_DEFAULT_SIZE } from './FXTextureView.Internal.js';
5
-
6
- /** Wrapper for Three.js texture with atlas and trim support. Does not own the underlying texture; user must dispose it. */
7
- class FXTextureView {
8
- /** @param config Texture or atlas configuration */
9
- constructor(config) {
10
- this._private_textureInternal = TEXTURE_DEFAULT_TEXTURE;
11
- this._private_sourceWidth = TEXTURE_DEFAULT_SIZE;
12
- this._private_sourceHeight = TEXTURE_DEFAULT_SIZE;
13
- this._private_frameX = 0;
14
- this._private_frameY = 0;
15
- this._private_frameWidth = TEXTURE_DEFAULT_SIZE;
16
- this._private_frameHeight = TEXTURE_DEFAULT_SIZE;
17
- this._private_rotatedInternal = false;
18
- this._private_scaleInternal = 1;
19
- this._private_trimLeft = 0;
20
- this._private_trimRight = 0;
21
- this._private_trimTop = 0;
22
- this._private_trimBottom = 0;
23
- this._private_textureDirtyInternal = false;
24
- this._private_uvTransformDirtyInternal = false;
25
- this._private_trimDirtyInternal = false;
26
- this._private_signalDiminsionsChangedInternal = new Ferrsign3();
27
- if (config !== undefined) {
28
- this.set(config);
29
- }
30
- }
31
- /** Original width before trimming in world units */
32
- get width() {
33
- return this._private_sourceWidth / this._private_scaleInternal;
34
- }
35
- /** Original height before trimming in world units */
36
- get height() {
37
- return this._private_sourceHeight / this._private_scaleInternal;
38
- }
39
- /** Visible width after trimming in world units */
40
- get trimmedWidth() {
41
- const frameSize = this._private_rotatedInternal ? this._private_frameHeight : this._private_frameWidth;
42
- return frameSize / this._private_scaleInternal;
43
- }
44
- /** Visible height after trimming in world units */
45
- get trimmedHeight() {
46
- const frameSize = this._private_rotatedInternal ? this._private_frameWidth : this._private_frameHeight;
47
- return frameSize / this._private_scaleInternal;
48
- }
49
- /** Underlying Three.js texture */
50
- get texture() {
51
- return this._private_textureInternal;
52
- }
53
- /** Whether sprite is rotated in atlas */
54
- get rotated() {
55
- return this._private_rotatedInternal;
56
- }
57
- /** Scale factor for resolution independence */
58
- get scale() {
59
- return this._private_scaleInternal;
60
- }
61
- /** Transparent padding around visible content */
62
- get trim() {
63
- const scale = this._private_scaleInternal;
64
- return {
65
- left: this._private_trimLeft / scale,
66
- right: this._private_trimRight / scale,
67
- top: this._private_trimTop / scale,
68
- bottom: this._private_trimBottom / scale,
69
- };
70
- }
71
- get textureDirty() {
72
- return this._private_textureDirtyInternal;
73
- }
74
- /** Whether UV transform inputs changed since last check */
75
- get uvTransformDirty() {
76
- return this._private_uvTransformDirtyInternal;
77
- }
78
- /** Whether trim values changed since last check */
79
- get trimDirty() {
80
- return this._private_trimDirtyInternal;
81
- }
82
- get signalDiminsionsChanged() {
83
- return this._private_signalDiminsionsChangedInternal;
84
- }
85
- setTextureDirtyFalse() {
86
- this._private_textureDirtyInternal = false;
87
- }
88
- /** Marks UV transform as clean. @internal */
89
- setUVTransformDirtyFalse() {
90
- this._private_uvTransformDirtyInternal = false;
91
- }
92
- /** Marks trim as clean. @internal */
93
- setTrimDirtyFalse() {
94
- this._private_trimDirtyInternal = false;
95
- }
96
- /**
97
- * Calculates UV transform matrix for shader sampling.
98
- * @param result Matrix to store result in
99
- * @returns UV transform matrix
100
- */
101
- calculateUVTransform(result = new Matrix3()) {
102
- const atlasWidth = this._private_textureInternal.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;
103
- const atlasHeight = this._private_textureInternal.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;
104
- if (this._private_rotatedInternal) {
105
- const physicalWidth = this._private_frameHeight;
106
- const physicalHeight = this._private_frameWidth;
107
- const u0 = this._private_frameX / atlasWidth;
108
- const v0 = (atlasHeight - this._private_frameY - physicalHeight) / atlasHeight;
109
- const uSize = physicalWidth / atlasWidth;
110
- const vSize = physicalHeight / atlasHeight;
111
- result.set(0, uSize, u0, -vSize, 0, v0 + vSize, 0, 0, 1);
112
- }
113
- else {
114
- const u0 = this._private_frameX / atlasWidth;
115
- const v0 = (atlasHeight - this._private_frameY - this._private_frameHeight) / atlasHeight;
116
- const uSize = this._private_frameWidth / atlasWidth;
117
- const vSize = this._private_frameHeight / atlasHeight;
118
- result.set(uSize, 0, u0, 0, vSize, v0, 0, 0, 1);
119
- }
120
- return result;
121
- }
122
- /**
123
- * Gets original dimensions before trimming.
124
- * @param result Vector to store result in
125
- * @returns Width and height in world units
126
- */
127
- getResolution(result = new Vector2()) {
128
- return result.set(this.width, this.height);
129
- }
130
- /**
131
- * Replaces texture with new configuration.
132
- * @param config Texture or atlas configuration
133
- */
134
- set(config) {
135
- const lastWidth = this.width;
136
- const lastHeight = this.height;
137
- if (config instanceof Texture) {
138
- this._private_setFromTexture(config);
139
- }
140
- else {
141
- this._private_setFromAtlasConfig(config);
142
- }
143
- if (this.width !== lastWidth || this.height !== lastHeight) {
144
- this._private_signalDiminsionsChangedInternal.emit(this.width, this.height, this);
145
- }
146
- }
147
- _private_setFromTexture(texture) {
148
- const width = texture.image?.naturalWidth ?? TEXTURE_DEFAULT_SIZE;
149
- const height = texture.image?.naturalHeight ?? TEXTURE_DEFAULT_SIZE;
150
- this._private_sourceWidth = width;
151
- this._private_sourceHeight = height;
152
- if (this.texture !== texture) {
153
- this._private_textureInternal = texture;
154
- this._private_textureDirtyInternal = true;
155
- }
156
- if (this._private_frameX !== 0 ||
157
- this._private_frameY !== 0 ||
158
- this._private_frameWidth !== width ||
159
- this._private_frameHeight !== height ||
160
- this._private_scaleInternal !== 1 || this._private_rotatedInternal) {
161
- this._private_frameX = 0;
162
- this._private_frameY = 0;
163
- this._private_frameWidth = width;
164
- this._private_frameHeight = height;
165
- this._private_rotatedInternal = false;
166
- this._private_scaleInternal = 1;
167
- this._private_uvTransformDirtyInternal = true;
168
- }
169
- if (this._private_trimLeft !== 0 ||
170
- this._private_trimRight !== 0 ||
171
- this._private_trimTop !== 0 ||
172
- this._private_trimBottom !== 0) {
173
- this._private_trimLeft = 0;
174
- this._private_trimRight = 0;
175
- this._private_trimTop = 0;
176
- this._private_trimBottom = 0;
177
- this._private_trimDirtyInternal = true;
178
- }
179
- }
180
- _private_setFromAtlasConfig(config) {
181
- assertValidPositiveNumber(config.sourceSize.w, "FXTextureView.setFromAtlasConfig.config.sourceSize.w");
182
- assertValidPositiveNumber(config.sourceSize.h, "FXTextureView.setFromAtlasConfig.config.sourceSize.h");
183
- assertValidNonNegativeNumber(config.frame.x, "FXTextureView.setFromAtlasConfig.config.frame.x");
184
- assertValidNonNegativeNumber(config.frame.y, "FXTextureView.setFromAtlasConfig.config.frame.y");
185
- assertValidPositiveNumber(config.frame.w, "FXTextureView.setFromAtlasConfig.config.frame.w");
186
- assertValidPositiveNumber(config.frame.h, "FXTextureView.setFromAtlasConfig.config.frame.h");
187
- assertValidNonNegativeNumber(config.spriteSourceSize.x, "FXTextureView.setFromAtlasConfig.config.spriteSourceSize.x");
188
- assertValidNonNegativeNumber(config.spriteSourceSize.y, "FXTextureView.setFromAtlasConfig.config.spriteSourceSize.y");
189
- assertValidPositiveNumber(config.spriteSourceSize.w, "FXTextureView.setFromAtlasConfig.config.spriteSourceSize.w");
190
- assertValidPositiveNumber(config.spriteSourceSize.h, "FXTextureView.setFromAtlasConfig.config.spriteSourceSize.h");
191
- if (config.scale !== undefined) {
192
- assertValidPositiveNumber(config.scale, "FXTextureView.setFromAtlasConfig.config.scale");
193
- }
194
- this._private_sourceWidth = config.sourceSize.w;
195
- this._private_sourceHeight = config.sourceSize.h;
196
- if (this.texture !== config.texture) {
197
- this._private_textureInternal = config.texture;
198
- this._private_textureDirtyInternal = true;
199
- }
200
- const scale = config.scale ?? 1;
201
- const rotated = config.rotated ?? false;
202
- if (this._private_frameX !== 0 ||
203
- this._private_frameY !== 0 ||
204
- this._private_frameWidth !== config.frame.w ||
205
- this._private_frameHeight !== config.frame.h ||
206
- this._private_scaleInternal !== scale ||
207
- this._private_rotatedInternal !== rotated) {
208
- this._private_frameX = config.frame.x;
209
- this._private_frameY = config.frame.y;
210
- this._private_frameWidth = config.frame.w;
211
- this._private_frameHeight = config.frame.h;
212
- this._private_scaleInternal = scale;
213
- this._private_rotatedInternal = rotated;
214
- this._private_uvTransformDirtyInternal = true;
215
- }
216
- const spriteSource = config.spriteSourceSize;
217
- const trimLeft = spriteSource.x;
218
- const trimTop = spriteSource.y;
219
- const trimRight = this._private_sourceWidth - spriteSource.x - spriteSource.w;
220
- const trimBottom = this._private_sourceHeight - spriteSource.y - spriteSource.h;
221
- if (this._private_trimLeft !== trimLeft ||
222
- this._private_trimRight !== trimRight ||
223
- this._private_trimTop !== trimTop ||
224
- this._private_trimBottom !== trimBottom) {
225
- this._private_trimLeft = trimLeft;
226
- this._private_trimRight = trimRight;
227
- this._private_trimTop = trimTop;
228
- this._private_trimBottom = trimBottom;
229
- this._private_trimDirtyInternal = true;
230
- }
231
- }
232
- }
233
-
234
- export { FXTextureView };
@@ -1,5 +0,0 @@
1
- import { type Texture } from "three";
2
- import { FXRenderingModule } from "./FXRenderingModule";
3
- export declare class FXRenderingAnimatedTexture extends FXRenderingModule {
4
- constructor(texture: Texture, horizontalCount: number, verticalCount: number);
5
- }
@@ -1,14 +0,0 @@
1
- import { Vector2 } from 'three';
2
- import source from '../shaders/FXRenderingAnimatedTexture.glsl.js';
3
- import { FXRenderingModule } from './FXRenderingModule.js';
4
-
5
- class FXRenderingAnimatedTexture extends FXRenderingModule {
6
- constructor(texture, horizontalCount, verticalCount) {
7
- super();
8
- /** @internal */
9
- this.source = source;
10
- this.requiredUniforms = { texture, count: new Vector2(horizontalCount, verticalCount) };
11
- }
12
- }
13
-
14
- export { FXRenderingAnimatedTexture };
@@ -1,14 +0,0 @@
1
- import type { FXColor } from "../color/FXColor";
2
- import { FXRenderingModule } from "./FXRenderingModule";
3
- /**
4
- * Colors particles based on lifetime progression.
5
- *
6
- * Interpolates through color gradient as particles age from birth to death.
7
- */
8
- export declare class FXRenderingColorOverLife extends FXRenderingModule {
9
- /**
10
- * @param colors - Color gradient stops from birth to death
11
- */
12
- constructor(colors: FXColor[]);
13
- destroy(): void;
14
- }
@@ -1,32 +0,0 @@
1
- import { buildGradientTexture } from '../miscellaneous/miscellaneous.js';
2
- import source from '../shaders/FXRenderingColorOverLife.glsl.js';
3
- import { FXRenderingModule } from './FXRenderingModule.js';
4
-
5
- /**
6
- * Colors particles based on lifetime progression.
7
- *
8
- * Interpolates through color gradient as particles age from birth to death.
9
- */
10
- class FXRenderingColorOverLife extends FXRenderingModule {
11
- /**
12
- * @param colors - Color gradient stops from birth to death
13
- */
14
- constructor(colors) {
15
- super();
16
- /** @internal */
17
- this.requiredProperties = {
18
- builtin: "Matrix4",
19
- };
20
- /** @internal */
21
- this.source = source;
22
- if (colors.length === 0) {
23
- throw new Error("FXRenderingColorOverLife: colors array cannot be empty");
24
- }
25
- this.requiredUniforms = { colorOverLifeTexture: buildGradientTexture(colors) };
26
- }
27
- destroy() {
28
- this.requiredUniforms.colorOverLifeTexture.dispose();
29
- }
30
- }
31
-
32
- export { FXRenderingColorOverLife };
@@ -1,15 +0,0 @@
1
- import type { FXColor } from "../color/FXColor";
2
- import { FXRenderingModule } from "./FXRenderingModule";
3
- /**
4
- * Colors particles based on velocity magnitude.
5
- *
6
- * Maps velocity from 0 to maxVelocity across the color gradient.
7
- */
8
- export declare class FXRenderingColorOverVelocity extends FXRenderingModule {
9
- /**
10
- * @param colors - Color gradient from slow to fast
11
- * @param maxVelocity - Velocity mapped to final color
12
- */
13
- constructor(colors: FXColor[], maxVelocity: number);
14
- destroy(): void;
15
- }
@@ -1,37 +0,0 @@
1
- import { buildGradientTexture } from '../miscellaneous/miscellaneous.js';
2
- import source from '../shaders/FXRenderingColorOverVelocity.glsl.js';
3
- import { FXRenderingModule } from './FXRenderingModule.js';
4
-
5
- /**
6
- * Colors particles based on velocity magnitude.
7
- *
8
- * Maps velocity from 0 to maxVelocity across the color gradient.
9
- */
10
- class FXRenderingColorOverVelocity extends FXRenderingModule {
11
- /**
12
- * @param colors - Color gradient from slow to fast
13
- * @param maxVelocity - Velocity mapped to final color
14
- */
15
- constructor(colors, maxVelocity) {
16
- super();
17
- /** @internal */
18
- this.requiredProperties = {
19
- builtin: "Matrix4",
20
- };
21
- /** @internal */
22
- this.source = source;
23
- if (colors.length === 0) {
24
- throw new Error("FXRenderingColorOverVelocity: colors array cannot be empty");
25
- }
26
- if (maxVelocity <= 0) {
27
- throw new Error("FXRenderingColorOverVelocity: maxVelocity must be greater than 0");
28
- }
29
- this.source = source.replace("COLOR_OVER_VELOCITY_MAX", `COLOR_OVER_VELOCITY_MAX ${maxVelocity.toFixed(2)}`);
30
- this.requiredUniforms = { colorOverVelocityTexture: buildGradientTexture(colors) };
31
- }
32
- destroy() {
33
- this.requiredUniforms.colorOverVelocityTexture.dispose();
34
- }
35
- }
36
-
37
- export { FXRenderingColorOverVelocity };
@@ -1,8 +0,0 @@
1
- /**
2
- * Base class for particle rendering modules.
3
- *
4
- * Rendering modules provide fragment shader code and uniforms for particle appearance.
5
- */
6
- export declare abstract class FXRenderingModule {
7
- destroy?(): void;
8
- }
@@ -1,9 +0,0 @@
1
- /**
2
- * Base class for particle rendering modules.
3
- *
4
- * Rendering modules provide fragment shader code and uniforms for particle appearance.
5
- */
6
- class FXRenderingModule {
7
- }
8
-
9
- export { FXRenderingModule };
@@ -1,12 +0,0 @@
1
- import { FXRenderingModule } from "./FXRenderingModule";
2
- /**
3
- * Applies directional light shadow attenuation to particles.
4
- *
5
- * Samples the first directional light's shadow map per billboard fragment,
6
- * multiplying the particle color by the shadow factor.
7
- *
8
- * Requires a DirectionalLight with `castShadow = true` in the scene,
9
- * and `receiveShadow = true` on the emitter (or its parent).
10
- */
11
- export declare class FXRenderingShadow extends FXRenderingModule {
12
- }
@@ -1,14 +0,0 @@
1
- import type { FXTextureConfig } from "../miscellaneous/texture/FXTextureView.Internal";
2
- import { FXRenderingModule } from "./FXRenderingModule";
3
- /**
4
- * Renders particles with a texture.
5
- *
6
- * Samples the texture using particle UV coordinates.
7
- */
8
- export declare class FXRenderingTexture extends FXRenderingModule {
9
- private readonly texture;
10
- /**
11
- * @param config - Texture configuration
12
- */
13
- constructor(config: FXTextureConfig);
14
- }
@@ -1,26 +0,0 @@
1
- import { FXTextureView } from '../miscellaneous/texture/FXTextureView.js';
2
- import source from '../shaders/FXRenderingTexture.glsl.js';
3
- import { FXRenderingModule } from './FXRenderingModule.js';
4
-
5
- /**
6
- * Renders particles with a texture.
7
- *
8
- * Samples the texture using particle UV coordinates.
9
- */
10
- class FXRenderingTexture extends FXRenderingModule {
11
- /**
12
- * @param config - Texture configuration
13
- */
14
- constructor(config) {
15
- super();
16
- /** @internal */
17
- this.source = source;
18
- this._private_texture = new FXTextureView(config);
19
- this.requiredUniforms = {
20
- texture: this._private_texture.texture,
21
- textureTransform: this._private_texture.calculateUVTransform(),
22
- };
23
- }
24
- }
25
-
26
- export { FXRenderingTexture };
@@ -1,3 +0,0 @@
1
- var source = "vec4 draw(){\n float totalFrames=p_count.x*p_count.y;\n float frame=floor(PARTICLE_AGE/PARTICLE_LIFETIME*totalFrames);\n frame=clamp(frame,0.0,totalFrames-1.0);\n float col=mod(frame,p_count.x);\n float row=floor(frame/p_count.x);\n vec2 frameSize=vec2(1.0/p_count.x,1.0/p_count.y);\n vec2 uv=(p_uv+vec2(col,(p_count.y-1.0-row)))*frameSize;\n return srgbTexture2D(p_texture,uv);\n}";
2
-
3
- export { source as default };
@@ -1,3 +0,0 @@
1
- var source = "vec4 draw(){\n float t=clamp(PARTICLE_AGE/PARTICLE_LIFETIME,0.0,1.0);\n return srgbTexture2D(p_colorOverLifeTexture,vec2(t,0.5));\n}";
2
-
3
- export { source as default };
@@ -1,3 +0,0 @@
1
- var source = "#define COLOR_OVER_VELOCITY_MAX \nvec4 draw(){\n float t=clamp(length(vec3(PARTICLE_VELOCITY_X,PARTICLE_VELOCITY_Y,PARTICLE_VELOCITY_Z))/COLOR_OVER_VELOCITY_MAX,0.0,1.0);\n return srgbTexture2D(p_colorOverVelocityTexture,vec2(t,0.5));\n}";
2
-
3
- export { source as default };
@@ -1,3 +0,0 @@
1
- var source = "vec4 draw(){\n vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;\n return srgbTexture2D(p_texture,transformedUV);\n}";
2
-
3
- export { source as default };