sparcoon 0.0.8 → 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 (90) hide show
  1. package/dist/{elements → emitter}/FXEmitter.Internal.d.ts +2 -4
  2. package/dist/{elements → emitter}/FXEmitter.Internal.js +3 -1
  3. package/dist/{elements → emitter}/FXEmitter.d.ts +8 -8
  4. package/dist/{elements → emitter}/FXEmitter.js +21 -18
  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 -20
  39. package/dist/instancedParticle/FXInstancedParticle.Internal.d.ts +2 -9
  40. package/dist/instancedParticle/FXInstancedParticle.Internal.js +2 -187
  41. package/dist/instancedParticle/FXInstancedParticle.d.ts +4 -4
  42. package/dist/instancedParticle/FXInstancedParticle.js +5 -6
  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/miscellaneous/texture/FXTextureView.Internal.js +0 -6
  71. package/dist/miscellaneous/texture/FXTextureView.js +0 -234
  72. package/dist/renderingModules/FXRenderingAnimatedTexture.d.ts +0 -5
  73. package/dist/renderingModules/FXRenderingAnimatedTexture.js +0 -14
  74. package/dist/renderingModules/FXRenderingColorOverLife.d.ts +0 -14
  75. package/dist/renderingModules/FXRenderingColorOverLife.js +0 -32
  76. package/dist/renderingModules/FXRenderingColorOverVelocity.d.ts +0 -15
  77. package/dist/renderingModules/FXRenderingColorOverVelocity.js +0 -37
  78. package/dist/renderingModules/FXRenderingModule.d.ts +0 -8
  79. package/dist/renderingModules/FXRenderingModule.js +0 -9
  80. package/dist/renderingModules/FXRenderingTexture.d.ts +0 -14
  81. package/dist/renderingModules/FXRenderingTexture.js +0 -26
  82. package/dist/shaders/FXRenderingAnimatedTexture.glsl.js +0 -3
  83. package/dist/shaders/FXRenderingColorOverLife.glsl.js +0 -3
  84. package/dist/shaders/FXRenderingColorOverVelocity.glsl.js +0 -3
  85. package/dist/shaders/FXRenderingTexture.glsl.js +0 -3
  86. /package/dist/{behaviorModules → emitter/behavior}/FXBehaviorModule.js +0 -0
  87. /package/dist/{spawnModules → emitter/spawn}/FXSpawnModule.js +0 -0
  88. /package/dist/{color → miscellaneous/color}/FXColor.Internal.d.ts +0 -0
  89. /package/dist/{color → miscellaneous/color}/FXColor.Internal.js +0 -0
  90. /package/dist/{color → miscellaneous/color}/FXColor.d.ts +0 -0
@@ -1,10 +1,8 @@
1
- export interface FXEmitterOptions {
2
- expectedCapacity: number;
3
- capacityStep: number;
4
- }
5
1
  export interface FXEmitterPlayOptions {
6
2
  duration: number;
7
3
  }
8
4
  export declare const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
9
5
  export declare const EMITTER_DEFAULT_CAPACITY_STEP = 32;
10
6
  export declare const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
7
+ export declare const EMITTER_DEFAULT_CAST_SHADOW = false;
8
+ export declare const EMITTER_DEFAULT_RECEIVE_SHADOW = false;
@@ -1,5 +1,7 @@
1
1
  const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
2
2
  const EMITTER_DEFAULT_CAPACITY_STEP = 32;
3
3
  const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
4
+ const EMITTER_DEFAULT_CAST_SHADOW = false;
5
+ const EMITTER_DEFAULT_RECEIVE_SHADOW = false;
4
6
 
5
- export { EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_EXPECTED_CAPACITY };
7
+ export { EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_CAST_SHADOW, EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_RECEIVE_SHADOW };
@@ -1,26 +1,26 @@
1
- import { Object3D, type Blending } from "three";
2
- import type { FXBehaviorModule } from "../behaviorModules/FXBehaviorModule";
3
- import type { FXRenderingModule } from "../renderingModules/FXRenderingModule";
4
- import type { FXSpawnModule } from "../spawnModules/FXSpawnModule";
1
+ import { Object3D } from "three";
2
+ import type { FXMaterial } from "../materials/FXMaterial";
3
+ import type { FXBehaviorModule } from "./behavior/FXBehaviorModule";
5
4
  import type { FXEmitterPlayOptions } from "./FXEmitter.Internal";
5
+ import type { FXSpawnModule } from "./spawn/FXSpawnModule";
6
6
  export interface FXEmitterOptions {
7
7
  expectedCapacity: number;
8
8
  capacityStep: number;
9
9
  automaticallyDestroyModules: boolean;
10
- blending: Blending;
11
- useAlphaHashing: boolean;
10
+ castShadow: boolean;
11
+ receiveShadow: boolean;
12
12
  }
13
13
  export declare class FXEmitter extends Object3D {
14
14
  private readonly spawnSequence;
15
15
  private readonly behaviorSequence;
16
- private readonly renderingSequence;
17
16
  automaticallyDestroyModules: boolean;
18
17
  private readonly mesh;
18
+ private readonly material;
19
19
  private emissionRate;
20
20
  private emissionAccumulator;
21
21
  private emissionDuration;
22
22
  private emissionElapsed;
23
- constructor(spawnSequence: FXSpawnModule[], behaviorSequence: readonly FXBehaviorModule[], renderingSequence: readonly FXRenderingModule[], options?: Partial<FXEmitterOptions>);
23
+ constructor(spawnSequence: FXSpawnModule[], behaviorSequence: readonly FXBehaviorModule[], material: FXMaterial, options?: Partial<FXEmitterOptions>);
24
24
  static onWillRender: (deltaTime: number) => void;
25
25
  destroy(): void;
26
26
  burst(count: number): void;
@@ -1,17 +1,16 @@
1
- import { Object3D, NormalBlending } from 'three';
1
+ import { Object3D } from 'three';
2
2
  import { FXInstancedParticle } from '../instancedParticle/FXInstancedParticle.js';
3
- import { collectProperties, collectUniforms } from '../instancedParticle/FXInstancedParticle.Internal.js';
3
+ import { collectProperties } from '../instancedParticle/FXInstancedParticle.Internal.js';
4
4
  import { resolveGLSLTypeInfo } from '../instancedParticle/shared.js';
5
5
  import { BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_VELOCITY_Z, BUILTIN_OFFSET_ROTATION, BUILTIN_OFFSET_TORQUE, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C } from '../miscellaneous/miscellaneous.js';
6
- import { EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES } from './FXEmitter.Internal.js';
6
+ import { EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_CAST_SHADOW, EMITTER_DEFAULT_RECEIVE_SHADOW, EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES } from './FXEmitter.Internal.js';
7
7
 
8
- const INSTANCES = new Array();
8
+ const EMITTERS = new Array();
9
9
  class FXEmitter extends Object3D {
10
- constructor(_private_spawnSequence, _private_behaviorSequence, _private_renderingSequence, options = {}) {
10
+ constructor(_private_spawnSequence, _private_behaviorSequence, material, options = {}) {
11
11
  super();
12
12
  this._private_spawnSequence = _private_spawnSequence;
13
13
  this._private_behaviorSequence = _private_behaviorSequence;
14
- this._private_renderingSequence = _private_renderingSequence;
15
14
  this._private_emissionRate = 0;
16
15
  this._private_emissionAccumulator = 0;
17
16
  this._private_emissionDuration = Infinity;
@@ -75,21 +74,27 @@ class FXEmitter extends Object3D {
75
74
  const collectedProperties = {
76
75
  builtin: resolveGLSLTypeInfo("Matrix4"),
77
76
  };
78
- collectProperties(collectedProperties, _private_spawnSequence, "FXEmitter.constructor.spawnSequence:");
77
+ collectProperties(collectedProperties, _private_spawnSequence, "FXEmitter.constructor.spawnSequence");
79
78
  collectProperties(collectedProperties, _private_behaviorSequence, "FXEmitter.constructor.behaviorSequence");
80
- collectProperties(collectedProperties, _private_renderingSequence, "FXEmitter.constructor.renderingSequence");
81
- const collectedUniforms = {};
82
- collectUniforms(collectedUniforms, _private_renderingSequence, "FXEmitter.constructor.renderingSequence");
83
- this._private_mesh = new FXInstancedParticle(this._private_renderingSequence.map((module) => module.source), collectedUniforms, collectedProperties, options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY, options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP, options.blending ?? NormalBlending, options.useAlphaHashing ?? false);
79
+ const threeMaterial = material.buildThreeMaterial(collectedProperties);
80
+ this._private_mesh = new FXInstancedParticle(collectedProperties, options.expectedCapacity ?? EMITTER_DEFAULT_EXPECTED_CAPACITY, options.capacityStep ?? EMITTER_DEFAULT_CAPACITY_STEP, threeMaterial);
81
+ if (options.castShadow ?? EMITTER_DEFAULT_CAST_SHADOW) {
82
+ this._private_mesh.castShadow = true;
83
+ this._private_mesh.customDepthMaterial = material.buildDepthMaterial();
84
+ }
85
+ if (options.receiveShadow ?? EMITTER_DEFAULT_RECEIVE_SHADOW) {
86
+ this._private_mesh.receiveShadow = true;
87
+ }
84
88
  this.automaticallyDestroyModules =
85
89
  options.automaticallyDestroyModules ?? EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES;
90
+ this._private_material = material;
86
91
  this.add(this._private_mesh);
87
- INSTANCES.push(this);
92
+ EMITTERS.push(this);
88
93
  }
89
94
  destroy() {
90
- const index = INSTANCES.indexOf(this);
95
+ const index = EMITTERS.indexOf(this);
91
96
  if (index !== -1) {
92
- INSTANCES.splice(index, 1);
97
+ EMITTERS.splice(index, 1);
93
98
  }
94
99
  if (this.automaticallyDestroyModules) {
95
100
  for (const module of this._private_spawnSequence) {
@@ -98,9 +103,7 @@ class FXEmitter extends Object3D {
98
103
  for (const module of this._private_behaviorSequence) {
99
104
  module.destroy?.();
100
105
  }
101
- for (const module of this._private_renderingSequence) {
102
- module.destroy?.();
103
- }
106
+ this._private_material.destroy();
104
107
  }
105
108
  this.removeFromParent();
106
109
  }
@@ -140,7 +143,7 @@ class FXEmitter extends Object3D {
140
143
  }
141
144
  }
142
145
  FXEmitter.onWillRender = (deltaTime) => {
143
- for (const instance of INSTANCES) {
146
+ for (const instance of EMITTERS) {
144
147
  instance._private_onRendering(deltaTime);
145
148
  }
146
149
  };
@@ -1,5 +1,5 @@
1
- import type { Vector3Like } from "../miscellaneous/math";
2
- import { type FXVector3Config } from "../miscellaneous/miscellaneous";
1
+ import type { Vector3Like } from "../../miscellaneous/math";
2
+ import { type FXVector3Config } from "../../miscellaneous/miscellaneous";
3
3
  import { FXBehaviorModule } from "./FXBehaviorModule";
4
4
  /**
5
5
  * Applies constant acceleration to all particles.
@@ -1,5 +1,5 @@
1
- import { assertValidNumber } from '../miscellaneous/asserts.js';
2
- import { resolveFXVector3Config, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../miscellaneous/miscellaneous.js';
1
+ import { assertValidNumber } from '../../miscellaneous/asserts.js';
2
+ import { resolveFXVector3Config, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../../miscellaneous/miscellaneous.js';
3
3
  import { FXBehaviorModule } from './FXBehaviorModule.js';
4
4
 
5
5
  /**
@@ -1,5 +1,5 @@
1
1
  import type { InstancedBufferAttribute } from "three";
2
- import type { FXPropertyName } from "../instancedParticle/shared";
2
+ import type { FXPropertyName } from "../../instancedParticle/shared";
3
3
  /**
4
4
  * Base class for particle behavior modules.
5
5
  *
@@ -1,5 +1,5 @@
1
- import type { Vector3Like } from "../miscellaneous/math";
2
- import { type FXRange, type FXRangeConfig, type FXVector3Config } from "../miscellaneous/miscellaneous";
1
+ import type { Vector3Like } from "../../miscellaneous/math";
2
+ import { type FXRange, type FXRangeConfig, type FXVector3Config } from "../../miscellaneous/miscellaneous";
3
3
  import { FXBehaviorModule } from "./FXBehaviorModule";
4
4
  /**
5
5
  * Applies gravity attraction toward a point.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXVector3Config, resolveFXRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXVector3Config, resolveFXRangeConfig, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXBehaviorModule } from './FXBehaviorModule.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { type FXAspectConfig, type FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import { type FXAspectConfig, type FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXBehaviorModule } from "./FXBehaviorModule";
3
3
  /**
4
4
  * Animates particle scale over lifetime.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidNonNegativeNumber, assertValidPositiveNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXRangeConfig, resolveAspect, BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidNonNegativeNumber, assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, resolveAspect, BUILTIN_OFFSET_AGE, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXBehaviorModule } from './FXBehaviorModule.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import { type FXRange, type FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXBehaviorModule } from "./FXBehaviorModule";
3
3
  /**
4
4
  * Reduces particle angular velocity over time.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_TORQUE } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_TORQUE } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXBehaviorModule } from './FXBehaviorModule.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import type { FXRange, FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXBehaviorModule } from "./FXBehaviorModule";
3
3
  /**
4
4
  * Applies noise-based angular acceleration to particles.
@@ -1,7 +1,7 @@
1
- import { m as modExports } from '../_virtual/mod.js';
1
+ import { m as modExports } from '../../_virtual/mod.js';
2
2
  import { MathUtils } from 'three';
3
- import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
4
- import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_TORQUE } from '../miscellaneous/miscellaneous.js';
3
+ import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
4
+ import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_C, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z, BUILTIN_OFFSET_RANDOM_A, BUILTIN_OFFSET_TORQUE } from '../../miscellaneous/miscellaneous.js';
5
5
  import { FXBehaviorModule } from './FXBehaviorModule.js';
6
6
 
7
7
  const generateNoise3D = modExports.makeNoise3D();
@@ -1,4 +1,4 @@
1
- import { type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import { type FXRange, type FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXBehaviorModule } from "./FXBehaviorModule";
3
3
  /**
4
4
  * Reduces particle velocity over time.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, BUILTIN_OFFSET_RANDOM_B, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXBehaviorModule } from './FXBehaviorModule.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import type { FXRange, FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import type { FXRange, FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXBehaviorModule } from "./FXBehaviorModule";
3
3
  /**
4
4
  * Applies noise-based acceleration to particles.
@@ -1,7 +1,7 @@
1
- import { m as modExports } from '../_virtual/mod.js';
1
+ import { m as modExports } from '../../_virtual/mod.js';
2
2
  import { MathUtils } from 'three';
3
- import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
4
- 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 } from '../miscellaneous/miscellaneous.js';
3
+ import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../../miscellaneous/asserts.js';
4
+ 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 } from '../../miscellaneous/miscellaneous.js';
5
5
  import { FXBehaviorModule } from './FXBehaviorModule.js';
6
6
 
7
7
  const generateNoise3D0 = modExports.makeNoise3D();
@@ -1,5 +1,5 @@
1
- import type { Vector3Like } from "../miscellaneous/math";
2
- import { type FXVector3Config } from "../miscellaneous/miscellaneous";
1
+ import type { Vector3Like } from "../../miscellaneous/math";
2
+ import { type FXVector3Config } from "../../miscellaneous/miscellaneous";
3
3
  import { FXSpawnModule } from "./FXSpawnModule";
4
4
  /**
5
5
  * Spawns particles at random positions within an axis-aligned bounding box.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXSpawnModule } from './FXSpawnModule.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import type { FXPropertyName } from "../instancedParticle/shared";
1
+ import type { FXPropertyName } from "../../instancedParticle/shared";
2
2
  /**
3
3
  * Base class for particle spawn modules.
4
4
  *
@@ -1,5 +1,5 @@
1
- import type { Vector3Like } from "../miscellaneous/math";
2
- import type { FXVector3Config } from "../miscellaneous/miscellaneous";
1
+ import type { Vector3Like } from "../../miscellaneous/math";
2
+ import { type FXVector3Config } from "../../miscellaneous/miscellaneous";
3
3
  import { FXSpawnModule } from "./FXSpawnModule";
4
4
  /**
5
5
  * Sets particle spawn position offset.
@@ -1,5 +1,5 @@
1
- import { assertValidNumber } from '../miscellaneous/asserts.js';
2
- import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../miscellaneous/miscellaneous.js';
1
+ import { assertValidNumber } from '../../miscellaneous/asserts.js';
2
+ import { resolveFXVector3Config, BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../../miscellaneous/miscellaneous.js';
3
3
  import { FXSpawnModule } from './FXSpawnModule.js';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import type { FXRange, FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import { type FXRange, type FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXSpawnModule } from "./FXSpawnModule";
3
3
  /**
4
4
  * Assigns random lifetime to particles.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidPositiveNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXRangeConfig, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_AGE } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, BUILTIN_OFFSET_LIFETIME, BUILTIN_OFFSET_AGE } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXSpawnModule } from './FXSpawnModule.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import { type FXRange, type FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXSpawnModule } from "./FXSpawnModule";
3
3
  /**
4
4
  * Assigns random rotation to particles.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXRangeConfig, BUILTIN_OFFSET_ROTATION } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, BUILTIN_OFFSET_ROTATION } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXSpawnModule } from './FXSpawnModule.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { type FXAspectConfig, type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import { type FXAspectConfig, type FXRange, type FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXSpawnModule } from "./FXSpawnModule";
3
3
  /**
4
4
  * Assigns random scale to particles.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidPositiveNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXRangeConfig, resolveAspect, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidPositiveNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, resolveAspect, BUILTIN_OFFSET_SCALE_X, BUILTIN_OFFSET_SCALE_Y } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXSpawnModule } from './FXSpawnModule.js';
5
5
 
6
6
  /**
@@ -1,4 +1,4 @@
1
- import { type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
1
+ import { type FXRange, type FXRangeConfig } from "../../miscellaneous/miscellaneous";
2
2
  import { FXSpawnModule } from "./FXSpawnModule";
3
3
  /**
4
4
  * Assigns random angular velocity to particles.
@@ -1,6 +1,6 @@
1
1
  import { MathUtils } from 'three';
2
- import { assertValidNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXRangeConfig, BUILTIN_OFFSET_TORQUE } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, BUILTIN_OFFSET_TORQUE } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXSpawnModule } from './FXSpawnModule.js';
5
5
 
6
6
  /**
@@ -1,5 +1,5 @@
1
1
  import { Vector3 } from "three";
2
- import { type FXRange, type FXRangeConfig } from "../miscellaneous/miscellaneous";
2
+ import { type FXRange, type FXRangeConfig } from "../../miscellaneous/miscellaneous";
3
3
  import { FXSpawnModule } from "./FXSpawnModule";
4
4
  export declare class FXSpawnRandomVelocity extends FXSpawnModule<{
5
5
  builtin: "Matrix4";
@@ -1,6 +1,6 @@
1
1
  import { Vector3, MathUtils } from 'three';
2
- import { assertValidNumber } from '../miscellaneous/asserts.js';
3
- import { resolveFXRangeConfig, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../miscellaneous/miscellaneous.js';
2
+ import { assertValidNumber } from '../../miscellaneous/asserts.js';
3
+ import { resolveFXRangeConfig, BUILTIN_OFFSET_VELOCITY_X, BUILTIN_OFFSET_VELOCITY_Y, BUILTIN_OFFSET_VELOCITY_Z } from '../../miscellaneous/miscellaneous.js';
4
4
  import { FXSpawnModule } from './FXSpawnModule.js';
5
5
 
6
6
  const TEMP_TANGENT = new Vector3();
@@ -0,0 +1,38 @@
1
+ import { FXSpawnModule } from "./FXSpawnModule";
2
+ /**
3
+ * Spawns particles at random positions within a spherical shell.
4
+ *
5
+ * The `angle` parameter controls the polar spread from the equatorial plane:
6
+ * - `0` - flat disk (XZ plane only)
7
+ * - `Math.PI / 2` - full sphere
8
+ * - Values in between produce a spherical band/zone
9
+ */
10
+ export declare class FXSpawnSphere extends FXSpawnModule<{
11
+ builtin: "Matrix4";
12
+ }> {
13
+ private innerRadiusInternal;
14
+ private outerRadiusInternal;
15
+ private angleInternal;
16
+ /**
17
+ * @param innerRadius - Minimum spawn radius (0 = spawn from center)
18
+ * @param outerRadius - Maximum spawn radius
19
+ * @param angle - Polar half-angle from equatorial plane: 0 = disk, Math.PI/2 = full sphere
20
+ */
21
+ constructor(innerRadius?: number, outerRadius?: number, angle?: number);
22
+ /**
23
+ * Polar half-angle from the equatorial plane.
24
+ * - `0` — flat disk
25
+ * - `Math.PI / 2` — full sphere
26
+ */
27
+ get angle(): number;
28
+ /** Minimum spawn radius */
29
+ get innerRadius(): number;
30
+ /** Maximum spawn radius */
31
+ get outerRadius(): number;
32
+ /** Minimum spawn radius */
33
+ set innerRadius(value: number);
34
+ /** Maximum spawn radius */
35
+ set outerRadius(value: number);
36
+ /** @see {@link angle} */
37
+ set angle(value: number);
38
+ }
@@ -0,0 +1,89 @@
1
+ import { MathUtils } from 'three';
2
+ import { assertValidNonNegativeNumber, assertValidNumber } from '../../miscellaneous/asserts.js';
3
+ import { BUILTIN_OFFSET_POSITION_X, BUILTIN_OFFSET_POSITION_Y, BUILTIN_OFFSET_POSITION_Z } from '../../miscellaneous/miscellaneous.js';
4
+ import { FXSpawnModule } from './FXSpawnModule.js';
5
+
6
+ /**
7
+ * Spawns particles at random positions within a spherical shell.
8
+ *
9
+ * The `angle` parameter controls the polar spread from the equatorial plane:
10
+ * - `0` - flat disk (XZ plane only)
11
+ * - `Math.PI / 2` - full sphere
12
+ * - Values in between produce a spherical band/zone
13
+ */
14
+ class FXSpawnSphere extends FXSpawnModule {
15
+ /**
16
+ * @param innerRadius - Minimum spawn radius (0 = spawn from center)
17
+ * @param outerRadius - Maximum spawn radius
18
+ * @param angle - Polar half-angle from equatorial plane: 0 = disk, Math.PI/2 = full sphere
19
+ */
20
+ constructor(innerRadius = 0, outerRadius = 1, angle = Math.PI / 2) {
21
+ super();
22
+ /** @internal */
23
+ this.requiredProperties = { builtin: "Matrix4" };
24
+ this._private_innerRadiusInternal = innerRadius;
25
+ this._private_outerRadiusInternal = outerRadius;
26
+ this._private_angleInternal = angle;
27
+ assertValidNonNegativeNumber(innerRadius, "FXSpawnSphere.constructor.innerRadius");
28
+ assertValidNonNegativeNumber(outerRadius, "FXSpawnSphere.constructor.outerRadius");
29
+ assertValidNumber(angle, "FXSpawnSphere.constructor.angle");
30
+ }
31
+ /**
32
+ * Polar half-angle from the equatorial plane.
33
+ * - `0` — flat disk
34
+ * - `Math.PI / 2` — full sphere
35
+ */
36
+ get angle() {
37
+ return this._private_angleInternal;
38
+ }
39
+ /** Minimum spawn radius */
40
+ get innerRadius() {
41
+ return this._private_innerRadiusInternal;
42
+ }
43
+ /** Maximum spawn radius */
44
+ get outerRadius() {
45
+ return this._private_outerRadiusInternal;
46
+ }
47
+ /** Minimum spawn radius */
48
+ set innerRadius(value) {
49
+ assertValidNonNegativeNumber(value, "FXSpawnSphere.innerRadius");
50
+ this._private_innerRadiusInternal = value;
51
+ }
52
+ /** Maximum spawn radius */
53
+ set outerRadius(value) {
54
+ assertValidNonNegativeNumber(value, "FXSpawnSphere.outerRadius");
55
+ this._private_outerRadiusInternal = value;
56
+ }
57
+ /** @see {@link angle} */
58
+ set angle(value) {
59
+ assertValidNumber(value, "FXSpawnSphere.angle");
60
+ this._private_angleInternal = value;
61
+ }
62
+ /** @internal */
63
+ spawn(properties, instanceBegin, instanceEnd) {
64
+ const { builtin } = properties;
65
+ const { array, itemSize } = builtin;
66
+ const inner = this._private_innerRadiusInternal;
67
+ const outer = this._private_outerRadiusInternal;
68
+ const sinAngle = Math.sin(this._private_angleInternal);
69
+ // Volume-uniform radius sampling within the shell
70
+ const inner3 = inner * inner * inner;
71
+ const outer3 = outer * outer * outer;
72
+ for (let i = instanceBegin; i < instanceEnd; i++) {
73
+ // Uniform volume-weighted radius
74
+ const r = Math.cbrt(MathUtils.randFloat(inner3, outer3));
75
+ // Uniform sampling on spherical zone:
76
+ // cosTheta in [-sinAngle, sinAngle] gives latitude range [-angle, +angle]
77
+ const cosTheta = MathUtils.randFloat(-sinAngle, sinAngle);
78
+ const sinTheta = Math.sqrt(1 - cosTheta * cosTheta);
79
+ const phi = MathUtils.randFloat(0, Math.PI * 2);
80
+ const itemOffset = i * itemSize;
81
+ array[itemOffset + BUILTIN_OFFSET_POSITION_X] = r * sinTheta * Math.cos(phi);
82
+ array[itemOffset + BUILTIN_OFFSET_POSITION_Y] = r * cosTheta;
83
+ array[itemOffset + BUILTIN_OFFSET_POSITION_Z] = r * sinTheta * Math.sin(phi);
84
+ }
85
+ builtin.needsUpdate = true;
86
+ }
87
+ }
88
+
89
+ export { FXSpawnSphere };
package/dist/index.d.ts CHANGED
@@ -1,20 +1,24 @@
1
- export { FXBehaviorDirectionalGravity } from "./behaviorModules/FXBehaviorDirectionalGravity";
2
- export { FXBehaviorPointGravity } from "./behaviorModules/FXBehaviorPointGravity";
3
- export { FXBehaviorScaleOverLife } from "./behaviorModules/FXBehaviorScaleOverLife";
4
- export { FXBehaviorTorqueDamping } from "./behaviorModules/FXBehaviorTorqueDamping";
5
- export { FXBehaviorTorqueNoise } from "./behaviorModules/FXBehaviorTorqueNoise";
6
- export { FXBehaviorVelocityDamping } from "./behaviorModules/FXBehaviorVelocityDamping";
7
- export { FXBehaviorVelocityNoise } from "./behaviorModules/FXBehaviorVelocityNoise";
8
- export { FXColor } from "./color/FXColor";
9
- export { FXEmitter } from "./elements/FXEmitter";
10
- export { FXRenderingAnimatedTexture } from "./renderingModules/FXRenderingAnimatedTexture";
11
- export { FXRenderingColorOverLife } from "./renderingModules/FXRenderingColorOverLife";
12
- export { FXRenderingColorOverVelocity } from "./renderingModules/FXRenderingColorOverVelocity";
13
- export { FXRenderingTexture } from "./renderingModules/FXRenderingTexture";
14
- export { FXSpawnBox } from "./spawnModules/FXSpawnBox";
15
- export { FXSpawnOffset } from "./spawnModules/FXSpawnOffset";
16
- export { FXSpawnRandomLifetime } from "./spawnModules/FXSpawnRandomLifetime";
17
- export { FXSpawnRandomRotation } from "./spawnModules/FXSpawnRandomRotation";
18
- export { FXSpawnRandomScale } from "./spawnModules/FXSpawnRandomScale";
19
- export { FXSpawnRandomTorque } from "./spawnModules/FXSpawnRandomTorque";
20
- export { FXSpawnRandomVelocity } from "./spawnModules/FXSpawnRandomVelocity";
1
+ export { FXBehaviorDirectionalGravity } from "./emitter/behavior/FXBehaviorDirectionalGravity";
2
+ export { FXBehaviorPointGravity } from "./emitter/behavior/FXBehaviorPointGravity";
3
+ export { FXBehaviorScaleOverLife } from "./emitter/behavior/FXBehaviorScaleOverLife";
4
+ export { FXBehaviorTorqueDamping } from "./emitter/behavior/FXBehaviorTorqueDamping";
5
+ export { FXBehaviorTorqueNoise } from "./emitter/behavior/FXBehaviorTorqueNoise";
6
+ export { FXBehaviorVelocityDamping } from "./emitter/behavior/FXBehaviorVelocityDamping";
7
+ export { FXBehaviorVelocityNoise } from "./emitter/behavior/FXBehaviorVelocityNoise";
8
+ export { FXEmitter } from "./emitter/FXEmitter";
9
+ export { FXSpawnBox } from "./emitter/spawn/FXSpawnBox";
10
+ export { FXSpawnOffset } from "./emitter/spawn/FXSpawnOffset";
11
+ export { FXSpawnRandomLifetime } from "./emitter/spawn/FXSpawnRandomLifetime";
12
+ export { FXSpawnRandomRotation } from "./emitter/spawn/FXSpawnRandomRotation";
13
+ export { FXSpawnRandomScale } from "./emitter/spawn/FXSpawnRandomScale";
14
+ export { FXSpawnRandomTorque } from "./emitter/spawn/FXSpawnRandomTorque";
15
+ export { FXSpawnRandomVelocity } from "./emitter/spawn/FXSpawnRandomVelocity";
16
+ export { FXSpawnSphere } from "./emitter/spawn/FXSpawnSphere";
17
+ export { FXAnimatedTextureNode } from "./materials/color-nodes/FXAnimatedTextureNode";
18
+ export { FXColorNode } from "./materials/color-nodes/FXColorNode";
19
+ export { FXColorOverLifeNode } from "./materials/color-nodes/FXColorOverLifeNode";
20
+ export { FXStaticTextureNode } from "./materials/color-nodes/FXStaticTextureNode";
21
+ export { FXDiffuseMaterial, FXParticleNormalsMode, } from "./materials/FXDiffuseMaterial/FXDiffuseMaterial";
22
+ export { FXMaterial } from "./materials/FXMaterial";
23
+ export { FXUnlitMaterial } from "./materials/FXUnlitMaterial/FXUnlitMaterial";
24
+ export { FXColor } from "./miscellaneous/color/FXColor";