sparcoon 0.6.0 → 0.6.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.
@@ -17,12 +17,6 @@ export interface FXEmitterOptions {
17
17
  * @defaultValue `32`
18
18
  */
19
19
  capacityStep: number;
20
- /**
21
- * When `true`, {@link FXEmitter.destroy} also calls `destroy()` on all modules and the material
22
- *
23
- * @defaultValue `true`
24
- */
25
- automaticallyDestroyModules: boolean;
26
20
  /**
27
21
  * Enables shadow casting
28
22
  *
@@ -75,7 +69,6 @@ export interface FXEmitterPlayOptions {
75
69
  export declare const EMITTERS: FXEmitter[];
76
70
  export declare const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
77
71
  export declare const EMITTER_DEFAULT_CAPACITY_STEP = 32;
78
- export declare const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
79
72
  export declare const EMITTER_DEFAULT_CAST_SHADOW = false;
80
73
  export declare const EMITTER_DEFAULT_RECEIVE_SHADOW = false;
81
74
  export declare const EMITTER_DEFAULT_SORT_FRACTION: number;
@@ -3,7 +3,6 @@ import { resolveGLSLTypeInfo } from '../instancedParticle/shared.js';
3
3
  const EMITTERS = new Array();
4
4
  const EMITTER_DEFAULT_EXPECTED_CAPACITY = 32;
5
5
  const EMITTER_DEFAULT_CAPACITY_STEP = 32;
6
- const EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES = true;
7
6
  const EMITTER_DEFAULT_CAST_SHADOW = false;
8
7
  const EMITTER_DEFAULT_RECEIVE_SHADOW = false;
9
8
  const EMITTER_DEFAULT_SORT_FRACTION = 1 / 10;
@@ -27,4 +26,4 @@ function collectProperties(keeper, modules, debugContext) {
27
26
  }
28
27
  }
29
28
 
30
- export { EMITTERS, EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_CAST_SHADOW, EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_PREWARM_MAX_STEP_COUNT, EMITTER_DEFAULT_PREWARM_MIN_STEP_DURATION, EMITTER_DEFAULT_RECEIVE_SHADOW, EMITTER_DEFAULT_SORT_FRACTION, collectProperties };
29
+ export { EMITTERS, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_CAST_SHADOW, EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_PREWARM_MAX_STEP_COUNT, EMITTER_DEFAULT_PREWARM_MIN_STEP_DURATION, EMITTER_DEFAULT_RECEIVE_SHADOW, EMITTER_DEFAULT_SORT_FRACTION, collectProperties };
@@ -14,8 +14,6 @@ import type { FXSpawn } from "./spawn/FXSpawn";
14
14
  export declare class FXEmitter extends Object3D {
15
15
  private readonly spawnSequence;
16
16
  private readonly behaviorSequence;
17
- /** When `true`, {@link FXEmitter.destroy} also calls `destroy()` on all modules and the material; defaults to `true` */
18
- automaticallyDestroyModules: boolean;
19
17
  /** Camera used for back-to-front depth sorting; `undefined` disables sorting */
20
18
  sortCamera?: Camera;
21
19
  /** Fraction of frames on which sorting runs (`1` = every frame, `0.1` = ~every 10th frame); defaults to `0.1` */
@@ -40,7 +38,7 @@ export declare class FXEmitter extends Object3D {
40
38
  * @param deltaTime - Elapsed time in seconds since the last frame
41
39
  */
42
40
  static onWillRender: (deltaTime: number) => void;
43
- /** Unregisters the emitter, removes it from the scene, and disposes modules and material when {@link automaticallyDestroyModules} is `true` */
41
+ /** Unregisters the emitter, removes it from the scene, and disposes modules and material */
44
42
  destroy(): void;
45
43
  /**
46
44
  * Spawns `count` particles immediately, or after a delay when `options.delay` is set
@@ -1,9 +1,9 @@
1
1
  import { Object3D, Vector3 } from 'three';
2
- import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../miscellaneous/asserts.js';
3
2
  import { FXInstancedParticle } from '../instancedParticle/FXInstancedParticle.js';
4
3
  import { resolveGLSLTypeInfo } from '../instancedParticle/shared.js';
4
+ import { assertValidPositiveNumber, assertValidNonNegativeNumber } from '../miscellaneous/asserts.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 { EMITTERS, collectProperties, EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_CAST_SHADOW, EMITTER_DEFAULT_RECEIVE_SHADOW, EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES, EMITTER_DEFAULT_SORT_FRACTION, EMITTER_DEFAULT_PREWARM_MIN_STEP_DURATION, EMITTER_DEFAULT_PREWARM_MAX_STEP_COUNT } from './FXEmitter.Internal.js';
6
+ import { EMITTERS, collectProperties, EMITTER_DEFAULT_EXPECTED_CAPACITY, EMITTER_DEFAULT_CAPACITY_STEP, EMITTER_DEFAULT_CAST_SHADOW, EMITTER_DEFAULT_RECEIVE_SHADOW, EMITTER_DEFAULT_SORT_FRACTION, EMITTER_DEFAULT_PREWARM_MIN_STEP_DURATION, EMITTER_DEFAULT_PREWARM_MAX_STEP_COUNT } from './FXEmitter.Internal.js';
7
7
 
8
8
  /**
9
9
  * Particle emitter - add to a scene to make particles visible
@@ -63,29 +63,28 @@ class FXEmitter extends Object3D {
63
63
  if (options.receiveShadow ?? EMITTER_DEFAULT_RECEIVE_SHADOW) {
64
64
  this._private_mesh.receiveShadow = true;
65
65
  }
66
- this.automaticallyDestroyModules =
67
- options.automaticallyDestroyModules ?? EMITTER_DEFAULT_AUTOMATICALLY_DESTROY_MODULES;
68
66
  this.sortCamera = options.sortCamera;
69
67
  this.sortFraction = options.sortFraction ?? EMITTER_DEFAULT_SORT_FRACTION;
70
68
  this._private_material = material;
71
69
  this.add(this._private_mesh);
72
70
  EMITTERS.push(this);
73
71
  }
74
- /** Unregisters the emitter, removes it from the scene, and disposes modules and material when {@link automaticallyDestroyModules} is `true` */
72
+ /** Unregisters the emitter, removes it from the scene, and disposes modules and material */
75
73
  destroy() {
76
74
  const index = EMITTERS.indexOf(this);
77
75
  if (index !== -1) {
78
76
  EMITTERS.splice(index, 1);
79
77
  }
80
- if (this.automaticallyDestroyModules) {
81
- for (const module of this._private_spawnSequence) {
82
- module.destroy?.();
83
- }
84
- for (const module of this._private_behaviorSequence) {
85
- module.destroy?.();
86
- }
87
- this._private_material.destroy();
78
+ for (const module of this._private_spawnSequence) {
79
+ module.destroy?.();
80
+ }
81
+ for (const module of this._private_behaviorSequence) {
82
+ module.destroy?.();
88
83
  }
84
+ this._private_material.destroy();
85
+ this._private_mesh.material?.dispose();
86
+ this._private_mesh.customDepthMaterial?.dispose();
87
+ this._private_mesh.customDistanceMaterial?.dispose();
89
88
  this.removeFromParent();
90
89
  }
91
90
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sparcoon",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Instanced-mesh particle system for Three.js.",
5
5
  "keywords": [
6
6
  "particles",