custom-pixi-particles 4.0.21 → 4.0.23

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 (94) hide show
  1. package/README.md +10 -2
  2. package/dist/index.d.ts +5 -0
  3. package/dist/index.js +21 -4
  4. package/dist/index.js.map +1 -1
  5. package/dist/lib/Model.d.ts +23 -0
  6. package/dist/lib/Model.js +23 -0
  7. package/dist/lib/Model.js.map +1 -1
  8. package/dist/lib/Particle.d.ts +146 -0
  9. package/dist/lib/Particle.js +61 -0
  10. package/dist/lib/Particle.js.map +1 -1
  11. package/dist/lib/ParticlePool.d.ts +28 -0
  12. package/dist/lib/ParticlePool.js +28 -0
  13. package/dist/lib/ParticlePool.js.map +1 -1
  14. package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +31 -0
  15. package/dist/lib/behaviour/AngularVelocityBehaviour.js +45 -12
  16. package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +1 -1
  17. package/dist/lib/behaviour/Behaviour.d.ts +26 -0
  18. package/dist/lib/behaviour/Behaviour.js +26 -0
  19. package/dist/lib/behaviour/Behaviour.js.map +1 -1
  20. package/dist/lib/behaviour/ColorBehaviour.d.ts +1 -1
  21. package/dist/lib/behaviour/ColorBehaviour.js +8 -11
  22. package/dist/lib/behaviour/ColorBehaviour.js.map +1 -1
  23. package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +29 -5
  24. package/dist/lib/behaviour/EmitDirectionBehaviour.js +32 -20
  25. package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +1 -1
  26. package/dist/lib/behaviour/EmitterBehaviours.d.ts +44 -2
  27. package/dist/lib/behaviour/EmitterBehaviours.js +43 -3
  28. package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -1
  29. package/dist/lib/behaviour/LifeBehaviour.d.ts +49 -0
  30. package/dist/lib/behaviour/LifeBehaviour.js +55 -5
  31. package/dist/lib/behaviour/LifeBehaviour.js.map +1 -1
  32. package/dist/lib/behaviour/PositionBehaviour.d.ts +32 -1
  33. package/dist/lib/behaviour/PositionBehaviour.js +60 -26
  34. package/dist/lib/behaviour/PositionBehaviour.js.map +1 -1
  35. package/dist/lib/behaviour/RotationBehaviour.d.ts +33 -4
  36. package/dist/lib/behaviour/RotationBehaviour.js +33 -17
  37. package/dist/lib/behaviour/RotationBehaviour.js.map +1 -1
  38. package/dist/lib/behaviour/SizeBehaviour.d.ts +1 -1
  39. package/dist/lib/behaviour/SizeBehaviour.js +25 -18
  40. package/dist/lib/behaviour/SizeBehaviour.js.map +1 -1
  41. package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +1 -1
  42. package/dist/lib/behaviour/TurbulenceBehaviour.js +1 -5
  43. package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -1
  44. package/dist/lib/emission/AbstractEmission.d.ts +23 -0
  45. package/dist/lib/emission/AbstractEmission.js +23 -0
  46. package/dist/lib/emission/AbstractEmission.js.map +1 -1
  47. package/dist/lib/emission/RandomEmission.d.ts +33 -0
  48. package/dist/lib/emission/RandomEmission.js +33 -0
  49. package/dist/lib/emission/RandomEmission.js.map +1 -1
  50. package/dist/lib/emission/StandardEmission.d.ts +49 -0
  51. package/dist/lib/emission/StandardEmission.js +49 -0
  52. package/dist/lib/emission/StandardEmission.js.map +1 -1
  53. package/dist/lib/emission/UniformEmission.d.ts +42 -0
  54. package/dist/lib/emission/UniformEmission.js +42 -0
  55. package/dist/lib/emission/UniformEmission.js.map +1 -1
  56. package/dist/lib/emitter/Duration.d.ts +17 -0
  57. package/dist/lib/emitter/Duration.js +17 -0
  58. package/dist/lib/emitter/Duration.js.map +1 -1
  59. package/dist/lib/emitter/Emitter.d.ts +61 -1
  60. package/dist/lib/emitter/Emitter.js +60 -0
  61. package/dist/lib/emitter/Emitter.js.map +1 -1
  62. package/dist/lib/parser/BehaviourParser.d.ts +15 -4
  63. package/dist/lib/parser/BehaviourParser.js +15 -23
  64. package/dist/lib/parser/BehaviourParser.js.map +1 -1
  65. package/dist/lib/parser/CompatibilityHelper.d.ts +9 -0
  66. package/dist/lib/parser/CompatibilityHelper.js +9 -0
  67. package/dist/lib/parser/CompatibilityHelper.js.map +1 -1
  68. package/dist/lib/parser/EmitControllerParser.d.ts +21 -0
  69. package/dist/lib/parser/EmitControllerParser.js +21 -0
  70. package/dist/lib/parser/EmitControllerParser.js.map +1 -1
  71. package/dist/lib/parser/EmitterParser.d.ts +54 -1
  72. package/dist/lib/parser/EmitterParser.js +73 -15
  73. package/dist/lib/parser/EmitterParser.js.map +1 -1
  74. package/dist/lib/pixi/Renderer.d.ts +55 -0
  75. package/dist/lib/pixi/Renderer.js +56 -1
  76. package/dist/lib/pixi/Renderer.js.map +1 -1
  77. package/dist/lib/pixi/TestRenderer.js +1 -1
  78. package/dist/lib/pixi/TestRenderer.js.map +1 -1
  79. package/dist/lib/util/Color.d.ts +101 -0
  80. package/dist/lib/util/Color.js +101 -0
  81. package/dist/lib/util/Color.js.map +1 -1
  82. package/dist/lib/util/List.d.ts +40 -0
  83. package/dist/lib/util/List.js +40 -0
  84. package/dist/lib/util/List.js.map +1 -1
  85. package/dist/lib/util/Point.d.ts +21 -0
  86. package/dist/lib/util/Point.js +21 -0
  87. package/dist/lib/util/Point.js.map +1 -1
  88. package/dist/lib/util/Random.d.ts +20 -0
  89. package/dist/lib/util/Random.js +20 -0
  90. package/dist/lib/util/Random.js.map +1 -1
  91. package/dist/lib/util/maths.d.ts +17 -0
  92. package/dist/lib/util/maths.js +17 -0
  93. package/dist/lib/util/maths.js.map +1 -1
  94. package/package.json +1 -1
@@ -1,14 +1,37 @@
1
1
  import { EmitControllerParser } from '../parser';
2
+ /**
3
+ * Abstract class representing a particle emitter.
4
+ * @abstract
5
+ */
2
6
  export default class AbstractEmission {
7
+ /**
8
+ * Calculate number of particles emitted after given time deltas
9
+ * @param {number} deltaTime - number of seconds passed
10
+ * @param {number} particlesCount - current number of particles
11
+ * @return {number} - the number of particles emitted
12
+ * @abstract
13
+ */
3
14
  howMany(deltaTime, particlesCount) {
4
15
  throw new Error('Abstract method');
5
16
  }
17
+ /**
18
+ * Reset the emission
19
+ */
6
20
  reset() {
7
21
  //
8
22
  }
23
+ /**
24
+ * Get the name of the emission
25
+ * @return {string} - the name of the emission
26
+ * @throws {Error} - when the method is not overridden in subclass
27
+ */
9
28
  getName() {
10
29
  throw new Error('This method has to be overridden in subclass');
11
30
  }
31
+ /**
32
+ * Get the parser for the emitter
33
+ * @return {EmitControllerParser} - parser for the emitter
34
+ */
12
35
  getParser() {
13
36
  return new EmitControllerParser(this);
14
37
  }
@@ -1 +1 @@
1
- {"version":3,"file":"AbstractEmission.js","sourceRoot":"","sources":["../../../src/lib/emission/AbstractEmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,OAAO,CAAC,SAAiB,EAAE,cAAsB;QAC/C,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;IACpC,CAAC;IAED,KAAK;QACH,EAAE;IACJ,CAAC;IAED,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACjE,CAAC;IAED,SAAS;QACP,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;CACF"}
1
+ {"version":3,"file":"AbstractEmission.js","sourceRoot":"","sources":["../../../src/lib/emission/AbstractEmission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAEhD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC;;;;;;OAMG;IACH,OAAO,CAAC,SAAiB,EAAE,cAAsB;QAC/C,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;IACpC,CAAC;IAED;;OAEG;IACH,KAAK;QACH,EAAE;IACJ,CAAC;IAED;;;;OAIG;IACH,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACjE,CAAC;IAED;;;OAGG;IACH,SAAS;QACP,OAAO,IAAI,oBAAoB,CAAC,IAAI,CAAC,CAAA;IACvC,CAAC;CACF"}
@@ -1,11 +1,44 @@
1
1
  import { AbstractEmission } from './index';
2
+ /**
3
+ * RandomEmission class to generate random particles
4
+ * @extends AbstractEmission
5
+ */
2
6
  export default class RandomEmission extends AbstractEmission {
7
+ /**
8
+ * Maximum number of particles
9
+ */
3
10
  _maxParticles: number;
11
+ /**
12
+ * Emission rate
13
+ */
4
14
  _emissionRate: number;
15
+ /**
16
+ * Calculates how many particles to emit
17
+ * @param {number} deltaTime - how much time is passed
18
+ * @param {number} particlesCount - current number of particles
19
+ */
5
20
  howMany(deltaTime: number, particlesCount: number): number;
21
+ /**
22
+ * Gets the emission rate
23
+ */
6
24
  get emissionRate(): number;
25
+ /**
26
+ * Sets the emission rate
27
+ * @param {number} value - the emission rate to set
28
+ */
7
29
  set emissionRate(value: number);
30
+ /**
31
+ * Gets the maximum number of particles
32
+ */
8
33
  get maxParticles(): number;
34
+ /**
35
+ * Sets the maximum number of particles
36
+ * @param {number} value - the maximum number of particles to set
37
+ */
9
38
  set maxParticles(value: number);
39
+ /**
40
+ * Gets the name of the emission type
41
+ * @returns {string} Emission type
42
+ */
10
43
  getName: () => string;
11
44
  }
@@ -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;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,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;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,GAAG,CAAC,CAAA;QACjB,iBAAY,GAAG,CAAC,CAAA;Q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;;;;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"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,a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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"}
@@ -5,7 +5,7 @@ import { EmitterParser } from '../parser';
5
5
  import List from '../util/List';
6
6
  import Particle from '../Particle';
7
7
  import { BLEND_MODES } from 'pixi.js-legacy';
8
- import Model from "../Model";
8
+ import Model from '../Model';
9
9
  export default class Emitter extends eventemitter3 {
10
10
  static PLAY: string;
11
11
  static STOP: string;
@@ -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
  }