custom-pixi-particles 4.0.20 → 4.0.22

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 (91) hide show
  1. package/dist/index.d.ts +5 -0
  2. package/dist/index.js +5 -0
  3. package/dist/index.js.map +1 -1
  4. package/dist/lib/Model.d.ts +23 -0
  5. package/dist/lib/Model.js +23 -0
  6. package/dist/lib/Model.js.map +1 -1
  7. package/dist/lib/Particle.d.ts +146 -0
  8. package/dist/lib/Particle.js +61 -0
  9. package/dist/lib/Particle.js.map +1 -1
  10. package/dist/lib/ParticlePool.d.ts +28 -0
  11. package/dist/lib/ParticlePool.js +28 -0
  12. package/dist/lib/ParticlePool.js.map +1 -1
  13. package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +31 -0
  14. package/dist/lib/behaviour/AngularVelocityBehaviour.js +45 -12
  15. package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +1 -1
  16. package/dist/lib/behaviour/Behaviour.d.ts +26 -0
  17. package/dist/lib/behaviour/Behaviour.js +26 -0
  18. package/dist/lib/behaviour/Behaviour.js.map +1 -1
  19. package/dist/lib/behaviour/ColorBehaviour.d.ts +1 -1
  20. package/dist/lib/behaviour/ColorBehaviour.js +8 -11
  21. package/dist/lib/behaviour/ColorBehaviour.js.map +1 -1
  22. package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +29 -5
  23. package/dist/lib/behaviour/EmitDirectionBehaviour.js +32 -20
  24. package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +1 -1
  25. package/dist/lib/behaviour/EmitterBehaviours.d.ts +44 -2
  26. package/dist/lib/behaviour/EmitterBehaviours.js +43 -3
  27. package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -1
  28. package/dist/lib/behaviour/LifeBehaviour.d.ts +49 -0
  29. package/dist/lib/behaviour/LifeBehaviour.js +55 -5
  30. package/dist/lib/behaviour/LifeBehaviour.js.map +1 -1
  31. package/dist/lib/behaviour/PositionBehaviour.d.ts +34 -1
  32. package/dist/lib/behaviour/PositionBehaviour.js +70 -28
  33. package/dist/lib/behaviour/PositionBehaviour.js.map +1 -1
  34. package/dist/lib/behaviour/RotationBehaviour.d.ts +33 -4
  35. package/dist/lib/behaviour/RotationBehaviour.js +33 -17
  36. package/dist/lib/behaviour/RotationBehaviour.js.map +1 -1
  37. package/dist/lib/behaviour/SizeBehaviour.d.ts +1 -1
  38. package/dist/lib/behaviour/SizeBehaviour.js +25 -18
  39. package/dist/lib/behaviour/SizeBehaviour.js.map +1 -1
  40. package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +1 -1
  41. package/dist/lib/behaviour/TurbulenceBehaviour.js +1 -5
  42. package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -1
  43. package/dist/lib/emission/AbstractEmission.d.ts +23 -0
  44. package/dist/lib/emission/AbstractEmission.js +23 -0
  45. package/dist/lib/emission/AbstractEmission.js.map +1 -1
  46. package/dist/lib/emission/RandomEmission.d.ts +33 -0
  47. package/dist/lib/emission/RandomEmission.js +33 -0
  48. package/dist/lib/emission/RandomEmission.js.map +1 -1
  49. package/dist/lib/emission/StandardEmission.d.ts +49 -0
  50. package/dist/lib/emission/StandardEmission.js +49 -0
  51. package/dist/lib/emission/StandardEmission.js.map +1 -1
  52. package/dist/lib/emission/UniformEmission.d.ts +42 -0
  53. package/dist/lib/emission/UniformEmission.js +42 -0
  54. package/dist/lib/emission/UniformEmission.js.map +1 -1
  55. package/dist/lib/emitter/Duration.d.ts +17 -0
  56. package/dist/lib/emitter/Duration.js +17 -0
  57. package/dist/lib/emitter/Duration.js.map +1 -1
  58. package/dist/lib/emitter/Emitter.d.ts +60 -0
  59. package/dist/lib/emitter/Emitter.js +60 -0
  60. package/dist/lib/emitter/Emitter.js.map +1 -1
  61. package/dist/lib/parser/BehaviourParser.d.ts +15 -4
  62. package/dist/lib/parser/BehaviourParser.js +15 -23
  63. package/dist/lib/parser/BehaviourParser.js.map +1 -1
  64. package/dist/lib/parser/CompatibilityHelper.d.ts +9 -0
  65. package/dist/lib/parser/CompatibilityHelper.js +9 -0
  66. package/dist/lib/parser/CompatibilityHelper.js.map +1 -1
  67. package/dist/lib/parser/EmitControllerParser.d.ts +21 -0
  68. package/dist/lib/parser/EmitControllerParser.js +21 -0
  69. package/dist/lib/parser/EmitControllerParser.js.map +1 -1
  70. package/dist/lib/parser/EmitterParser.d.ts +54 -1
  71. package/dist/lib/parser/EmitterParser.js +72 -15
  72. package/dist/lib/parser/EmitterParser.js.map +1 -1
  73. package/dist/lib/pixi/Renderer.d.ts +55 -0
  74. package/dist/lib/pixi/Renderer.js +55 -0
  75. package/dist/lib/pixi/Renderer.js.map +1 -1
  76. package/dist/lib/util/Color.d.ts +101 -0
  77. package/dist/lib/util/Color.js +101 -0
  78. package/dist/lib/util/Color.js.map +1 -1
  79. package/dist/lib/util/List.d.ts +40 -0
  80. package/dist/lib/util/List.js +40 -0
  81. package/dist/lib/util/List.js.map +1 -1
  82. package/dist/lib/util/Point.d.ts +21 -0
  83. package/dist/lib/util/Point.js +21 -0
  84. package/dist/lib/util/Point.js.map +1 -1
  85. package/dist/lib/util/Random.d.ts +20 -0
  86. package/dist/lib/util/Random.js +20 -0
  87. package/dist/lib/util/Random.js.map +1 -1
  88. package/dist/lib/util/maths.d.ts +17 -0
  89. package/dist/lib/util/maths.js +17 -0
  90. package/dist/lib/util/maths.js.map +1 -1
  91. package/package.json +1 -1
@@ -1,14 +1,33 @@
1
1
  import { AbstractEmission, EmissionTypes } from './index';
2
2
  import { Random } from '../util';
3
+ /**
4
+ * RandomEmission class to generate random particles
5
+ * @extends AbstractEmission
6
+ */
3
7
  export default class RandomEmission extends AbstractEmission {
4
8
  constructor() {
5
9
  super(...arguments);
10
+ /**
11
+ * Maximum number of particles
12
+ */
6
13
  this._maxParticles = 0;
14
+ /**
15
+ * Emission rate
16
+ */
7
17
  this._emissionRate = 0;
18
+ /**
19
+ * Gets the name of the emission type
20
+ * @returns {string} Emission type
21
+ */
8
22
  this.getName = () => {
9
23
  return EmissionTypes.RANDOM;
10
24
  };
11
25
  }
26
+ /**
27
+ * Calculates how many particles to emit
28
+ * @param {number} deltaTime - how much time is passed
29
+ * @param {number} particlesCount - current number of particles
30
+ */
12
31
  howMany(deltaTime, particlesCount) {
13
32
  if (particlesCount < this.maxParticles) {
14
33
  const count = Math.round(Random.uniform(0, Math.ceil(this.emissionRate * deltaTime)));
@@ -17,15 +36,29 @@ export default class RandomEmission extends AbstractEmission {
17
36
  }
18
37
  return 0;
19
38
  }
39
+ /**
40
+ * Gets the emission rate
41
+ */
20
42
  get emissionRate() {
21
43
  return this._emissionRate;
22
44
  }
45
+ /**
46
+ * Sets the emission rate
47
+ * @param {number} value - the emission rate to set
48
+ */
23
49
  set emissionRate(value) {
24
50
  this._emissionRate = Math.max(0, value);
25
51
  }
52
+ /**
53
+ * Gets the maximum number of particles
54
+ */
26
55
  get maxParticles() {
27
56
  return this._maxParticles;
28
57
  }
58
+ /**
59
+ * Sets the maximum number of particles
60
+ * @param {number} value - the maximum number of particles to set
61
+ */
29
62
  set maxParticles(value) {
30
63
  this._maxParticles = Math.max(0, value);
31
64
  }
@@ -1 +1 @@
1
- {"version":3,"file":"RandomEmission.js","sourceRoot":"","sources":["../../../src/lib/emission/RandomEmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,cAAe,SAAQ,gBAAgB;IAA5D;;QACE,kBAAa,GAAG,CAAC,CAAA;QACjB,kBAAa,GAAG,CAAC,CAAA;QA4BjB,YAAO,GAAG,GAAG,EAAE;YACb,OAAO,aAAa,CAAC,MAAM,CAAA;QAC7B,CAAC,CAAA;IACH,CAAC;IA7BC,OAAO,CAAC,SAAiB,EAAE,cAAsB;QAC/C,IAAI,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE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DC;;;;OAIG;IACH,OAAO,CAAC,SAAiB,EAAE,cAAsB;QAC/C,IAAI,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC,CAAC,CAAA;YACrF,MAAM,KAAK,GAAG,cAAc,GAAG,KAAK,CAAA;YACpC,OAAO,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC,CAAC,CAAC,KAAK,CAAA;SAC/E;QAED,OAAO,CAAC,CAAA;IACV,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,YAAY,CAAC,KAAa;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACzC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,YAAY,CAAC,KAAa;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACzC,CAAC;CASF"}
@@ -1,12 +1,61 @@
1
1
  import { AbstractEmission } from './index';
2
+ /**
3
+ * The StandardEmission class is an abstract class extending from AbstractEmission.
4
+ *
5
+ * It provides methods for calculating the number of particles emitted in an interval of time and setting/getting the emission rate and maximum number of particles.
6
+ *
7
+ * @abstract
8
+ */
2
9
  export default class StandardEmission extends AbstractEmission {
10
+ /**
11
+ * The maxParticles field stores the maximum number of particles allowed to be emitted.
12
+ * @private
13
+ * @type {number}
14
+ */
3
15
  _maxParticles: number;
16
+ /**
17
+ * The emissionRate field stores the current rate of emission.
18
+ * @private
19
+ * @type {number}
20
+ */
4
21
  _emissionRate: number;
22
+ /**
23
+ * The emitCounter field stores the counter for emission rate.
24
+ * @private
25
+ * @type {number}
26
+ */
5
27
  _emitCounter: number;
28
+ /**
29
+ * howMany() calculates how many particles should be emitted in the given interval of time.
30
+ *
31
+ * @param {number} deltaTime - The amount of time elapsed since the last emission.
32
+ * @param {number} particlesCount - The current number of particles.
33
+ * @return {number} - The number of particles to be emitted.
34
+ */
6
35
  howMany(deltaTime: number, particlesCount: number): number;
36
+ /**
37
+ * Getter for the emissionRate field.
38
+ * @return {number} - The current emission rate.
39
+ */
7
40
  get emissionRate(): number;
41
+ /**
42
+ * Setter for the emissionRate field.
43
+ * @param {number} value - The new emission rate.
44
+ */
8
45
  set emissionRate(value: number);
46
+ /**
47
+ * Getter for the maxParticles field.
48
+ * @return {number} - The maximum number of particles allowed to be emitted.
49
+ */
9
50
  get maxParticles(): number;
51
+ /**
52
+ * Setter for the maxParticles field.
53
+ * @param {number} value - The new maximum number of particles allowed to be emitted.
54
+ */
10
55
  set maxParticles(value: number);
56
+ /**
57
+ * GetName() returns the type of the emission.
58
+ * @return {EmissionTypes} - The type of the emission.
59
+ */
11
60
  getName: () => string;
12
61
  }
@@ -1,14 +1,47 @@
1
1
  import { AbstractEmission, EmissionTypes } from './index';
2
+ /**
3
+ * The StandardEmission class is an abstract class extending from AbstractEmission.
4
+ *
5
+ * It provides methods for calculating the number of particles emitted in an interval of time and setting/getting the emission rate and maximum number of particles.
6
+ *
7
+ * @abstract
8
+ */
2
9
  export default class StandardEmission extends AbstractEmission {
3
10
  constructor() {
4
11
  super(...arguments);
12
+ /**
13
+ * The maxParticles field stores the maximum number of particles allowed to be emitted.
14
+ * @private
15
+ * @type {number}
16
+ */
5
17
  this._maxParticles = 0;
18
+ /**
19
+ * The emissionRate field stores the current rate of emission.
20
+ * @private
21
+ * @type {number}
22
+ */
6
23
  this._emissionRate = 0;
24
+ /**
25
+ * The emitCounter field stores the counter for emission rate.
26
+ * @private
27
+ * @type {number}
28
+ */
7
29
  this._emitCounter = 0;
30
+ /**
31
+ * GetName() returns the type of the emission.
32
+ * @return {EmissionTypes} - The type of the emission.
33
+ */
8
34
  this.getName = () => {
9
35
  return EmissionTypes.UNIFORM;
10
36
  };
11
37
  }
38
+ /**
39
+ * howMany() calculates how many particles should be emitted in the given interval of time.
40
+ *
41
+ * @param {number} deltaTime - The amount of time elapsed since the last emission.
42
+ * @param {number} particlesCount - The current number of particles.
43
+ * @return {number} - The number of particles to be emitted.
44
+ */
12
45
  howMany(deltaTime, particlesCount) {
13
46
  const rate = 1.0 / this.emissionRate;
14
47
  let count = 0;
@@ -21,15 +54,31 @@ export default class StandardEmission extends AbstractEmission {
21
54
  }
22
55
  return count;
23
56
  }
57
+ /**
58
+ * Getter for the emissionRate field.
59
+ * @return {number} - The current emission rate.
60
+ */
24
61
  get emissionRate() {
25
62
  return this._emissionRate;
26
63
  }
64
+ /**
65
+ * Setter for the emissionRate field.
66
+ * @param {number} value - The new emission rate.
67
+ */
27
68
  set emissionRate(value) {
28
69
  this._emissionRate = Math.max(0, value);
29
70
  }
71
+ /**
72
+ * Getter for the maxParticles field.
73
+ * @return {number} - The maximum number of particles allowed to be emitted.
74
+ */
30
75
  get maxParticles() {
31
76
  return this._maxParticles;
32
77
  }
78
+ /**
79
+ * Setter for the maxParticles field.
80
+ * @param {number} value - The new maximum number of particles allowed to be emitted.
81
+ */
33
82
  set maxParticles(value) {
34
83
  this._maxParticles = Math.max(0, value);
35
84
  }
@@ -1 +1 @@
1
- {"version":3,"file":"StandardEmission.js","sourceRoot":"","sources":["../../../src/lib/emission/StandardEmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,SAAS,CAAA;AAEzD,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,gBAAgB;IAA9D;;QACE,kBAAa,GAAG,CAAC,CAAA;QACjB,kBAAa,G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jB;;;;WAIG;QACH,kBAAa,GAAG,CAAC,CAAA;QAEjB;;;;WAIG;QACH,iBAAY,GAAG,CAAC,CAAA;QAwDhB;;;WAGG;QACH,YAAO,GAAG,GAAG,EAAE;YACb,OAAO,aAAa,CAAC,OAAO,CAAA;QAC9B,CAAC,CAAA;IACH,CAAC;IA7DC;;;;;;OAMG;IACH,OAAO,CAAC,SAAiB,EAAE,cAAsB;QAC/C,MAAM,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,YAAY,CAAA;QACpC,IAAI,KAAK,GAAG,CAAC,CAAA;QACb,IAAI,cAAc,GAAG,IAAI,CAAC,YAAY,EAAE;YACtC,IAAI,CAAC,YAAY,IAAI,SAAS,CAAA;SAC/B;QAED,OAAO,cAAc,GAAG,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,YAAY,GAAG,IAAI,EAAE;YACrE,KAAK,EAAE,CAAA;YACP,IAAI,CAAC,YAAY,IAAI,IAAI,CAAA;SAC1B;QAED,OAAO,KAAK,CAAA;IACd,CAAC;IAED;;;OAGG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,YAAY,CAAC,KAAa;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACzC,CAAC;IAED;;;OAGG;IACH,IAAI,YAAY;QACd,OAAO,IAAI,CAAC,aAAa,CAAA;IAC3B,CAAC;IAED;;;OAGG;IACH,IAAI,YAAY,CAAC,KAAa;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;IACzC,CAAC;CASF"}
@@ -1,14 +1,56 @@
1
1
  import { AbstractEmission } from './index';
2
+ /**
3
+ * UniformEmission class is the implementation of the abstract class AbstractEmission.
4
+ * It implements the method howMany and has other methods to set and get the related data.
5
+ *
6
+ * @class UniformEmission
7
+ * @extends AbstractEmission
8
+ */
2
9
  export default class UniformEmission extends AbstractEmission {
3
10
  _maxParticles: number;
4
11
  _maxLife: number;
5
12
  _emitPerSecond: number;
6
13
  _frames: number;
14
+ /**
15
+ * Calculates the number of particles to emit.
16
+ *
17
+ * @param {number} deltaTime - The elapsed time between frames.
18
+ * @param {number} particlesCount - The current number of particles on the screen.
19
+ * @returns {number} The number of particles to emit in the current frame.
20
+ */
7
21
  howMany(deltaTime: number, particlesCount: number): number;
22
+ /**
23
+ * Recalculates the emitPerSecond value based on the maxParticles and maxLife values.
24
+ */
8
25
  refresh(): void;
26
+ /**
27
+ * Sets the maxLife value and calls refresh() to recalculate the emitPerSecond.
28
+ *
29
+ * @param {number} value - The new maxLife value.
30
+ */
9
31
  set maxLife(value: number);
32
+ /**
33
+ * Sets the maxParticles value and calls refresh() to recalculate the emitPerSecond.
34
+ *
35
+ * @param {number} value - The new maxParticles value.
36
+ */
10
37
  set maxParticles(value: number);
38
+ /**
39
+ * Returns the emitPerSecond value.
40
+ *
41
+ * @returns {number} The emitPerSecond value.
42
+ */
11
43
  get emitPerSecond(): number;
44
+ /**
45
+ * Sets the emitPerSecond value.
46
+ *
47
+ * @param {number} value - The new emitPerSecond value.
48
+ */
12
49
  set emitPerSecond(value: number);
50
+ /**
51
+ * Returns EmissionTypes.DEFAULT.
52
+ *
53
+ * @returns {string} EmissionTypes.DEFAULT.
54
+ */
13
55
  getName: () => string;
14
56
  }
@@ -1,4 +1,11 @@
1
1
  import { AbstractEmission, EmissionTypes } from './index';
2
+ /**
3
+ * UniformEmission class is the implementation of the abstract class AbstractEmission.
4
+ * It implements the method howMany and has other methods to set and get the related data.
5
+ *
6
+ * @class UniformEmission
7
+ * @extends AbstractEmission
8
+ */
2
9
  export default class UniformEmission extends AbstractEmission {
3
10
  constructor() {
4
11
  super(...arguments);
@@ -6,10 +13,22 @@ export default class UniformEmission extends AbstractEmission {
6
13
  this._maxLife = 1;
7
14
  this._emitPerSecond = 0;
8
15
  this._frames = 0;
16
+ /**
17
+ * Returns EmissionTypes.DEFAULT.
18
+ *
19
+ * @returns {string} EmissionTypes.DEFAULT.
20
+ */
9
21
  this.getName = () => {
10
22
  return EmissionTypes.DEFAULT;
11
23
  };
12
24
  }
25
+ /**
26
+ * Calculates the number of particles to emit.
27
+ *
28
+ * @param {number} deltaTime - The elapsed time between frames.
29
+ * @param {number} particlesCount - The current number of particles on the screen.
30
+ * @returns {number} The number of particles to emit in the current frame.
31
+ */
13
32
  howMany(deltaTime, particlesCount) {
14
33
  const ratio = this._emitPerSecond * deltaTime;
15
34
  this._frames += ratio;
@@ -20,20 +39,43 @@ export default class UniformEmission extends AbstractEmission {
20
39
  }
21
40
  return numberToEmit;
22
41
  }
42
+ /**
43
+ * Recalculates the emitPerSecond value based on the maxParticles and maxLife values.
44
+ */
23
45
  refresh() {
24
46
  this.emitPerSecond = this._maxParticles / this._maxLife;
25
47
  }
48
+ /**
49
+ * Sets the maxLife value and calls refresh() to recalculate the emitPerSecond.
50
+ *
51
+ * @param {number} value - The new maxLife value.
52
+ */
26
53
  set maxLife(value) {
27
54
  this._maxLife = Math.max(value, 1);
28
55
  this.refresh();
29
56
  }
57
+ /**
58
+ * Sets the maxParticles value and calls refresh() to recalculate the emitPerSecond.
59
+ *
60
+ * @param {number} value - The new maxParticles value.
61
+ */
30
62
  set maxParticles(value) {
31
63
  this._maxParticles = Math.max(value, 0);
32
64
  this.refresh();
33
65
  }
66
+ /**
67
+ * Returns the emitPerSecond value.
68
+ *
69
+ * @returns {number} The emitPerSecond value.
70
+ */
34
71
  get emitPerSecond() {
35
72
  return this._emitPerSecond;
36
73
  }
74
+ /**
75
+ * Sets the emitPerSecond value.
76
+ *
77
+ * @param {number} value - The new emitPerSecond value.
78
+ */
37
79
  set emitPerSecond(value) {
38
80
  this._emitPerSecond = Math.max(value, 0);
39
81
  }
@@ -1 +1 @@
1
- {"version":3,"file":"UniformEmission.js","sourceRoot":"","sources":["../../../src/lib/emission/UniformEmission.ts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,CAAA;QAClC,IAAI,CAAC,OAAO,EAAE,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACH,IAAI,YAAY,CAAC,KAAa;QAC5B,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QACvC,IAAI,CAAC,OAAO,EAAE,CAAA;IAChB,CAAC;IAED;;;;OAIG;IACH,IAAI,aAAa;QACf,OAAO,IAAI,CAAC,cAAc,CAAA;IAC5B,CAAC;IAED;;;;OAIG;IACH,IAAI,aAAa,CAAC,KAAa;QAC7B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;IAC1C,CAAC;CAUF"}
@@ -2,9 +2,26 @@ export default class Duration {
2
2
  maxTime: number;
3
3
  private _stop;
4
4
  private _elapsedTime;
5
+ /**
6
+ * Checks if the time has elapsed.
7
+ * @returns {boolean} Returns true if the time is elapsed, false otherwise.
8
+ */
5
9
  isTimeElapsed: () => boolean;
10
+ /**
11
+ * Updates the elapsed time.
12
+ * @param {number} deltaTime - The amount of time that has passed since the last update.
13
+ */
6
14
  update: (deltaTime: number) => void;
15
+ /**
16
+ * Resets the elapsed time.
17
+ */
7
18
  reset: () => void;
19
+ /**
20
+ * Stops the elapsed time.
21
+ */
8
22
  stop: () => void;
23
+ /**
24
+ * Starts the elapsed time.
25
+ */
9
26
  start: () => void;
10
27
  }
@@ -3,19 +3,36 @@ export default class Duration {
3
3
  this.maxTime = -1;
4
4
  this._stop = false;
5
5
  this._elapsedTime = 0;
6
+ /**
7
+ * Checks if the time has elapsed.
8
+ * @returns {boolean} Returns true if the time is elapsed, false otherwise.
9
+ */
6
10
  this.isTimeElapsed = () => {
7
11
  return this._stop || (this.maxTime > 0 && this._elapsedTime >= this.maxTime);
8
12
  };
13
+ /**
14
+ * Updates the elapsed time.
15
+ * @param {number} deltaTime - The amount of time that has passed since the last update.
16
+ */
9
17
  this.update = (deltaTime) => {
10
18
  this._elapsedTime += deltaTime;
11
19
  };
20
+ /**
21
+ * Resets the elapsed time.
22
+ */
12
23
  this.reset = () => {
13
24
  this._stop = false;
14
25
  this._elapsedTime = 0;
15
26
  };
27
+ /**
28
+ * Stops the elapsed time.
29
+ */
16
30
  this.stop = () => {
17
31
  this._stop = true;
18
32
  };
33
+ /**
34
+ * Starts the elapsed time.
35
+ */
19
36
  this.start = () => {
20
37
  this._stop = false;
21
38
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Duration.js","sourceRoot":"","sources":["../../../src/lib/emitter/Duration.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,QAAQ;IAA7B;QACE,YAAO,GAAW,CAAC,CAAC,CAAA;QACZ,UAAK,GAAY,KAAK,CAAA;QACtB,iBAAY,GAAW,CAAC,CAAA;QAEhC,kBAAa,GAAG,GAAG,EAAE;YACnB,OAAO,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9E,CAAC,CAAA;QAED,WAAM,GAAG,CAAC,SAAiB,EAAE,EAAE;YAC7B,IAAI,CAAC,YAAY,IAAI,SAAS,CAAA;QAChC,CAAC,CAAA;QAED,UAAK,GAAG,GAAG,EAAE;YACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;YAClB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAA;QACvB,CAAC,CAAA;QAED,SAAI,GAAG,GAAG,EAAE;YACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,CAAC,CAAA;QAED,UAAK,GAAG,GAAG,EAAE;YACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,CAAC,CAAA;IACH,CAAC;CAAA"}
1
+ {"version":3,"file":"Duration.js","sourceRoot":"","sources":["../../../src/lib/emitter/Duration.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,QAAQ;IAA7B;QACE,YAAO,GAAW,CAAC,CAAC,CAAA;QACZ,UAAK,GAAY,KAAK,CAAA;QACtB,iBAAY,GAAW,CAAC,CAAA;QAEhC;;;WAGG;QACH,kBAAa,GAAG,GAAG,EAAE;YACnB,OAAO,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,CAAC,IAAI,IAAI,CAAC,YAAY,IAAI,IAAI,CAAC,OAAO,CAAC,CAAA;QAC9E,CAAC,CAAA;QAED;;;WAGG;QACH,WAAM,GAAG,CAAC,SAAiB,EAAE,EAAE;YAC7B,IAAI,CAAC,YAAY,IAAI,SAAS,CAAA;QAChC,CAAC,CAAA;QAED;;WAEG;QACH,UAAK,GAAG,GAAG,EAAE;YACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;YAClB,IAAI,CAAC,YAAY,GAAG,CAAC,CAAA;QACvB,CAAC,CAAA;QAED;;WAEG;QACH,SAAI,GAAG,GAAG,EAAE;YACV,IAAI,CAAC,KAAK,GAAG,IAAI,CAAA;QACnB,CAAC,CAAA;QAED;;WAEG;QACH,UAAK,GAAG,GAAG,EAAE;YACX,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QACpB,CAAC,CAAA;IACH,CAAC;CAAA"}
@@ -33,20 +33,80 @@ export default class Emitter extends eventemitter3 {
33
33
  private _play;
34
34
  private _model;
35
35
  constructor(model: Model);
36
+ /**
37
+ * Updates the emitter, emits particles and updates the particles.
38
+ * Triggers the COMPLETE event when the duration is elapsed and the list is empty.
39
+ * @param {number} deltaTime - Time elapsed since the last update
40
+ */
36
41
  update(deltaTime: number): Promise<void>;
42
+ /**
43
+ * Emits particles if the duration is not elapsed.
44
+ * @param {number} deltaTime - Time elapsed since the last update
45
+ */
37
46
  emitParticles(deltaTime: number): void;
47
+ /**
48
+ * Creates the particles to be emitted.
49
+ * Triggers the CREATE event when a particle is created.
50
+ * @param {number} deltaTime - Time elapsed since the last update
51
+ */
38
52
  createParticles(deltaTime: number): void;
53
+ /**
54
+ * Updates the list of particles
55
+ * @param {number} deltaTime - The amount of time that has passed since the last update
56
+ */
39
57
  updateParticles(deltaTime: number): void;
58
+ /**
59
+ * Updates a single particle
60
+ * @param {Particle} particle - The particle to update
61
+ * @param {number} deltaTime - The amount of time that has passed since the last update
62
+ */
40
63
  updateParticle(particle: Particle, deltaTime: number): void;
64
+ /**
65
+ * Removes a particle from the list and reset it
66
+ * @param {Particle} particle - The particle to remove
67
+ */
41
68
  removeParticle(particle: Particle): void;
69
+ /**
70
+ * Gets a parser to parse the emitter and it's particles
71
+ * @returns {EmitterParser} - The parser for this emitter
72
+ */
42
73
  getParser(): EmitterParser;
74
+ /**
75
+ * Creates props for a behaviour
76
+ * @param {string} name - The name of the behaviour
77
+ * @returns {Object} - The props for the behaviour
78
+ */
43
79
  createBehaviourProps(name: string): any;
80
+ /**
81
+ * Starts the emitter playing
82
+ */
44
83
  play(): void;
84
+ /**
85
+ * Resets the emitter and starts playing
86
+ */
45
87
  resetAndPlay(): void;
88
+ /**
89
+ * Resets the emitter without removing the particles and starts playing
90
+ */
46
91
  resetWithoutRemovingAndPlay(): void;
92
+ /**
93
+ * Resets the emitter and removes all the particles
94
+ */
47
95
  reset(): void;
96
+ /**
97
+ * Resets the emitter without removing the particles
98
+ */
48
99
  resetWithoutRemoving(): void;
100
+ /**
101
+ * Stops the emitter and removes all the particles
102
+ */
49
103
  stop(): void;
104
+ /**
105
+ * Stops the emitter without killing the particles
106
+ */
50
107
  stopWithoutKilling(): void;
108
+ /**
109
+ * Removes all the particles from the list
110
+ */
51
111
  removeParticles(): void;
52
112
  }
@@ -29,6 +29,11 @@ export default class Emitter extends eventemitter3 {
29
29
  // @ts-ignore
30
30
  this.emitController = new emission[emission.EmissionTypes.DEFAULT]();
31
31
  }
32
+ /**
33
+ * Updates the emitter, emits particles and updates the particles.
34
+ * Triggers the COMPLETE event when the duration is elapsed and the list is empty.
35
+ * @param {number} deltaTime - Time elapsed since the last update
36
+ */
32
37
  update(deltaTime) {
33
38
  return __awaiter(this, void 0, void 0, function* () {
34
39
  if (!this._play)
@@ -44,11 +49,20 @@ export default class Emitter extends eventemitter3 {
44
49
  }
45
50
  });
46
51
  }
52
+ /**
53
+ * Emits particles if the duration is not elapsed.
54
+ * @param {number} deltaTime - Time elapsed since the last update
55
+ */
47
56
  emitParticles(deltaTime) {
48
57
  if (!this.duration.isTimeElapsed()) {
49
58
  this.createParticles(deltaTime);
50
59
  }
51
60
  }
61
+ /**
62
+ * Creates the particles to be emitted.
63
+ * Triggers the CREATE event when a particle is created.
64
+ * @param {number} deltaTime - Time elapsed since the last update
65
+ */
52
66
  createParticles(deltaTime) {
53
67
  const particlesToEmit = this.emitController.howMany(deltaTime, this.list.length);
54
68
  for (let i = 0; i < particlesToEmit; ++i) {
@@ -57,11 +71,20 @@ export default class Emitter extends eventemitter3 {
57
71
  this.emit(Emitter.CREATE, particle);
58
72
  }
59
73
  }
74
+ /**
75
+ * Updates the list of particles
76
+ * @param {number} deltaTime - The amount of time that has passed since the last update
77
+ */
60
78
  updateParticles(deltaTime) {
61
79
  this.list.forEach((particle) => {
62
80
  this.updateParticle(particle, deltaTime);
63
81
  });
64
82
  }
83
+ /**
84
+ * Updates a single particle
85
+ * @param {Particle} particle - The particle to update
86
+ * @param {number} deltaTime - The amount of time that has passed since the last update
87
+ */
65
88
  updateParticle(particle, deltaTime) {
66
89
  if (particle.isDead()) {
67
90
  this.removeParticle(particle);
@@ -76,6 +99,10 @@ export default class Emitter extends eventemitter3 {
76
99
  this.emit(Emitter.UPDATE, particle);
77
100
  }
78
101
  }
102
+ /**
103
+ * Removes a particle from the list and reset it
104
+ * @param {Particle} particle - The particle to remove
105
+ */
79
106
  removeParticle(particle) {
80
107
  this.emit(Emitter.REMOVE, particle);
81
108
  this.list.remove(particle);
@@ -83,44 +110,77 @@ export default class Emitter extends eventemitter3 {
83
110
  ParticlePool.global.push(particle);
84
111
  turbulencePool.list.remove(particle);
85
112
  }
113
+ /**
114
+ * Gets a parser to parse the emitter and it's particles
115
+ * @returns {EmitterParser} - The parser for this emitter
116
+ */
86
117
  getParser() {
87
118
  return new EmitterParser(this);
88
119
  }
120
+ /**
121
+ * Creates props for a behaviour
122
+ * @param {string} name - The name of the behaviour
123
+ * @returns {Object} - The props for the behaviour
124
+ */
89
125
  createBehaviourProps(name) {
90
126
  return this.getParser().createBehaviourProps(name);
91
127
  }
128
+ /**
129
+ * Starts the emitter playing
130
+ */
92
131
  play() {
93
132
  this.duration.start();
94
133
  this._play = true;
95
134
  this.emit(Emitter.PLAY);
96
135
  }
136
+ /**
137
+ * Resets the emitter and starts playing
138
+ */
97
139
  resetAndPlay() {
98
140
  this.reset();
99
141
  this.play();
100
142
  }
143
+ /**
144
+ * Resets the emitter without removing the particles and starts playing
145
+ */
101
146
  resetWithoutRemovingAndPlay() {
102
147
  this.resetWithoutRemoving();
103
148
  this.play();
104
149
  }
150
+ /**
151
+ * Resets the emitter and removes all the particles
152
+ */
105
153
  reset() {
106
154
  this.emitController.reset();
107
155
  this.duration.reset();
108
156
  this.removeParticles();
109
157
  this.emit(Emitter.RESET);
110
158
  }
159
+ /**
160
+ * Resets the emitter without removing the particles
161
+ */
111
162
  resetWithoutRemoving() {
112
163
  this.emitController.reset();
113
164
  this.duration.reset();
114
165
  this.emit(Emitter.RESET);
115
166
  }
167
+ /**
168
+ * Stops the emitter and removes all the particles
169
+ */
116
170
  stop() {
117
171
  this._play = false;
118
172
  this.removeParticles();
119
173
  this.emit(Emitter.STOP);
120
174
  }
175
+ /**
176
+ * Stops the emitter without killing the particles
177
+ */
121
178
  stopWithoutKilling() {
122
179
  this.duration.stop();
123
180
  }
181
+ /**
182
+ * Removes all the particles from the list
183
+ */
124
184
  removeParticles() {
125
185
  this.list.forEach((particle) => {
126
186
  this.removeParticle(particle);