custom-pixi-particles 4.18.0 → 4.18.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.
Files changed (163) hide show
  1. package/package.json +4 -4
  2. package/dist/index.d.ts +0 -15
  3. package/dist/index.js +0 -45
  4. package/dist/index.js.map +0 -1
  5. package/dist/lib/Model.d.ts +0 -32
  6. package/dist/lib/Model.js +0 -44
  7. package/dist/lib/Model.js.map +0 -1
  8. package/dist/lib/Particle.d.ts +0 -234
  9. package/dist/lib/Particle.js +0 -201
  10. package/dist/lib/Particle.js.map +0 -1
  11. package/dist/lib/ParticlePool.d.ts +0 -37
  12. package/dist/lib/ParticlePool.js +0 -56
  13. package/dist/lib/ParticlePool.js.map +0 -1
  14. package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +0 -61
  15. package/dist/lib/behaviour/AngularVelocityBehaviour.js +0 -118
  16. package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +0 -1
  17. package/dist/lib/behaviour/AttractionRepulsionBehaviour.d.ts +0 -42
  18. package/dist/lib/behaviour/AttractionRepulsionBehaviour.js +0 -78
  19. package/dist/lib/behaviour/AttractionRepulsionBehaviour.js.map +0 -1
  20. package/dist/lib/behaviour/Behaviour.d.ts +0 -33
  21. package/dist/lib/behaviour/Behaviour.js +0 -45
  22. package/dist/lib/behaviour/Behaviour.js.map +0 -1
  23. package/dist/lib/behaviour/BehaviourNames.d.ts +0 -22
  24. package/dist/lib/behaviour/BehaviourNames.js +0 -23
  25. package/dist/lib/behaviour/BehaviourNames.js.map +0 -1
  26. package/dist/lib/behaviour/CollisionBehaviour.d.ts +0 -86
  27. package/dist/lib/behaviour/CollisionBehaviour.js +0 -140
  28. package/dist/lib/behaviour/CollisionBehaviour.js.map +0 -1
  29. package/dist/lib/behaviour/ColorBehaviour.d.ts +0 -67
  30. package/dist/lib/behaviour/ColorBehaviour.js +0 -193
  31. package/dist/lib/behaviour/ColorBehaviour.js.map +0 -1
  32. package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +0 -52
  33. package/dist/lib/behaviour/EmitDirectionBehaviour.js +0 -105
  34. package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +0 -1
  35. package/dist/lib/behaviour/EmitterBehaviours.d.ts +0 -69
  36. package/dist/lib/behaviour/EmitterBehaviours.js +0 -116
  37. package/dist/lib/behaviour/EmitterBehaviours.js.map +0 -1
  38. package/dist/lib/behaviour/ForceFieldsBehaviour.d.ts +0 -53
  39. package/dist/lib/behaviour/ForceFieldsBehaviour.js +0 -80
  40. package/dist/lib/behaviour/ForceFieldsBehaviour.js.map +0 -1
  41. package/dist/lib/behaviour/GroupingBehaviour.d.ts +0 -57
  42. package/dist/lib/behaviour/GroupingBehaviour.js +0 -143
  43. package/dist/lib/behaviour/GroupingBehaviour.js.map +0 -1
  44. package/dist/lib/behaviour/LifeBehaviour.d.ts +0 -47
  45. package/dist/lib/behaviour/LifeBehaviour.js +0 -65
  46. package/dist/lib/behaviour/LifeBehaviour.js.map +0 -1
  47. package/dist/lib/behaviour/LightEffectBehaviour.d.ts +0 -59
  48. package/dist/lib/behaviour/LightEffectBehaviour.js +0 -94
  49. package/dist/lib/behaviour/LightEffectBehaviour.js.map +0 -1
  50. package/dist/lib/behaviour/NoiseBasedMotionBehaviour.d.ts +0 -28
  51. package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js +0 -50
  52. package/dist/lib/behaviour/NoiseBasedMotionBehaviour.js.map +0 -1
  53. package/dist/lib/behaviour/PositionBehaviour.d.ts +0 -164
  54. package/dist/lib/behaviour/PositionBehaviour.js +0 -484
  55. package/dist/lib/behaviour/PositionBehaviour.js.map +0 -1
  56. package/dist/lib/behaviour/RotationBehaviour.d.ts +0 -59
  57. package/dist/lib/behaviour/RotationBehaviour.js +0 -100
  58. package/dist/lib/behaviour/RotationBehaviour.js.map +0 -1
  59. package/dist/lib/behaviour/SizeBehaviour.d.ts +0 -61
  60. package/dist/lib/behaviour/SizeBehaviour.js +0 -156
  61. package/dist/lib/behaviour/SizeBehaviour.js.map +0 -1
  62. package/dist/lib/behaviour/SoundReactiveBehaviour.d.ts +0 -58
  63. package/dist/lib/behaviour/SoundReactiveBehaviour.js +0 -132
  64. package/dist/lib/behaviour/SoundReactiveBehaviour.js.map +0 -1
  65. package/dist/lib/behaviour/SpawnBehaviour.d.ts +0 -89
  66. package/dist/lib/behaviour/SpawnBehaviour.js +0 -705
  67. package/dist/lib/behaviour/SpawnBehaviour.js.map +0 -1
  68. package/dist/lib/behaviour/StretchBehaviour.d.ts +0 -30
  69. package/dist/lib/behaviour/StretchBehaviour.js +0 -59
  70. package/dist/lib/behaviour/StretchBehaviour.js.map +0 -1
  71. package/dist/lib/behaviour/TemperatureBehaviour.d.ts +0 -47
  72. package/dist/lib/behaviour/TemperatureBehaviour.js +0 -64
  73. package/dist/lib/behaviour/TemperatureBehaviour.js.map +0 -1
  74. package/dist/lib/behaviour/TimelineBehaviour.d.ts +0 -73
  75. package/dist/lib/behaviour/TimelineBehaviour.js +0 -100
  76. package/dist/lib/behaviour/TimelineBehaviour.js.map +0 -1
  77. package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +0 -73
  78. package/dist/lib/behaviour/TurbulenceBehaviour.js +0 -133
  79. package/dist/lib/behaviour/TurbulenceBehaviour.js.map +0 -1
  80. package/dist/lib/behaviour/index.d.ts +0 -23
  81. package/dist/lib/behaviour/index.js +0 -24
  82. package/dist/lib/behaviour/index.js.map +0 -1
  83. package/dist/lib/customPixiParticlesSettingsInterface.d.ts +0 -19
  84. package/dist/lib/customPixiParticlesSettingsInterface.js +0 -2
  85. package/dist/lib/customPixiParticlesSettingsInterface.js.map +0 -1
  86. package/dist/lib/emission/AbstractEmission.d.ts +0 -30
  87. package/dist/lib/emission/AbstractEmission.js +0 -39
  88. package/dist/lib/emission/AbstractEmission.js.map +0 -1
  89. package/dist/lib/emission/EmissionTypes.d.ts +0 -6
  90. package/dist/lib/emission/EmissionTypes.js +0 -6
  91. package/dist/lib/emission/EmissionTypes.js.map +0 -1
  92. package/dist/lib/emission/RandomEmission.d.ts +0 -44
  93. package/dist/lib/emission/RandomEmission.js +0 -66
  94. package/dist/lib/emission/RandomEmission.js.map +0 -1
  95. package/dist/lib/emission/StandardEmission.d.ts +0 -62
  96. package/dist/lib/emission/StandardEmission.js +0 -87
  97. package/dist/lib/emission/StandardEmission.js.map +0 -1
  98. package/dist/lib/emission/UniformEmission.d.ts +0 -56
  99. package/dist/lib/emission/UniformEmission.js +0 -83
  100. package/dist/lib/emission/UniformEmission.js.map +0 -1
  101. package/dist/lib/emission/index.d.ts +0 -6
  102. package/dist/lib/emission/index.js +0 -7
  103. package/dist/lib/emission/index.js.map +0 -1
  104. package/dist/lib/emitter/Duration.d.ts +0 -27
  105. package/dist/lib/emitter/Duration.js +0 -41
  106. package/dist/lib/emitter/Duration.js.map +0 -1
  107. package/dist/lib/emitter/Emitter.d.ts +0 -116
  108. package/dist/lib/emitter/Emitter.js +0 -240
  109. package/dist/lib/emitter/Emitter.js.map +0 -1
  110. package/dist/lib/emitter/index.d.ts +0 -3
  111. package/dist/lib/emitter/index.js +0 -4
  112. package/dist/lib/emitter/index.js.map +0 -1
  113. package/dist/lib/index.d.ts +0 -20
  114. package/dist/lib/index.js +0 -21
  115. package/dist/lib/index.js.map +0 -1
  116. package/dist/lib/parser/BehaviourParser.d.ts +0 -21
  117. package/dist/lib/parser/BehaviourParser.js +0 -72
  118. package/dist/lib/parser/BehaviourParser.js.map +0 -1
  119. package/dist/lib/parser/CompatibilityHelper.d.ts +0 -12
  120. package/dist/lib/parser/CompatibilityHelper.js +0 -19
  121. package/dist/lib/parser/CompatibilityHelper.js.map +0 -1
  122. package/dist/lib/parser/EmitControllerParser.d.ts +0 -27
  123. package/dist/lib/parser/EmitControllerParser.js +0 -39
  124. package/dist/lib/parser/EmitControllerParser.js.map +0 -1
  125. package/dist/lib/parser/EmitterParser.d.ts +0 -67
  126. package/dist/lib/parser/EmitterParser.js +0 -168
  127. package/dist/lib/parser/EmitterParser.js.map +0 -1
  128. package/dist/lib/parser/index.d.ts +0 -5
  129. package/dist/lib/parser/index.js +0 -6
  130. package/dist/lib/parser/index.js.map +0 -1
  131. package/dist/lib/pixi/Renderer.d.ts +0 -125
  132. package/dist/lib/pixi/Renderer.js +0 -584
  133. package/dist/lib/pixi/Renderer.js.map +0 -1
  134. package/dist/lib/pixi/TestRenderer.d.ts +0 -125
  135. package/dist/lib/pixi/TestRenderer.js +0 -578
  136. package/dist/lib/pixi/TestRenderer.js.map +0 -1
  137. package/dist/lib/util/Color.d.ts +0 -133
  138. package/dist/lib/util/Color.js +0 -173
  139. package/dist/lib/util/Color.js.map +0 -1
  140. package/dist/lib/util/List.d.ts +0 -49
  141. package/dist/lib/util/List.js +0 -87
  142. package/dist/lib/util/List.js.map +0 -1
  143. package/dist/lib/util/MinMax.d.ts +0 -34
  144. package/dist/lib/util/MinMax.js +0 -46
  145. package/dist/lib/util/MinMax.js.map +0 -1
  146. package/dist/lib/util/Point.d.ts +0 -34
  147. package/dist/lib/util/Point.js +0 -46
  148. package/dist/lib/util/Point.js.map +0 -1
  149. package/dist/lib/util/Random.d.ts +0 -24
  150. package/dist/lib/util/Random.js +0 -30
  151. package/dist/lib/util/Random.js.map +0 -1
  152. package/dist/lib/util/ThereBack.d.ts +0 -14
  153. package/dist/lib/util/ThereBack.js +0 -23
  154. package/dist/lib/util/ThereBack.js.map +0 -1
  155. package/dist/lib/util/index.d.ts +0 -5
  156. package/dist/lib/util/index.js +0 -6
  157. package/dist/lib/util/index.js.map +0 -1
  158. package/dist/lib/util/maths.d.ts +0 -10
  159. package/dist/lib/util/maths.js +0 -13
  160. package/dist/lib/util/maths.js.map +0 -1
  161. package/dist/lib/util/turbulencePool.d.ts +0 -4
  162. package/dist/lib/util/turbulencePool.js +0 -7
  163. package/dist/lib/util/turbulencePool.js.map +0 -1
@@ -1,125 +0,0 @@
1
- import { Emitter } from '../emitter';
2
- import { ICustomPixiParticlesSettings } from '../customPixiParticlesSettingsInterface';
3
- import { Container } from 'pixi.js-legacy';
4
- /**
5
- * Renderer is a class used to render particles in the Pixi library.
6
- *
7
- * @class Renderer
8
- */
9
- export default class TestRenderer extends Container {
10
- blendMode: any;
11
- emitter: Emitter;
12
- turbulenceEmitter: Emitter;
13
- private _paused;
14
- private _internalPaused;
15
- private textures;
16
- private zeroPad;
17
- private indexToStart;
18
- private finishingTextureNames;
19
- private unusedSprites;
20
- private emitterParser;
21
- private turbulenceParser;
22
- private config;
23
- private anchor;
24
- private _model;
25
- private _ticker;
26
- private _visibilitychangeBinding;
27
- /**
28
- * Creates an instance of Renderer.
29
- *
30
- * @memberof Renderer
31
- */
32
- constructor(settings: ICustomPixiParticlesSettings);
33
- onComplete: any;
34
- onCompleteFN: any;
35
- /**
36
- * Sets the paused state of the object.
37
- *
38
- * @param {boolean} [isPaused=true] - The new paused state of the object. Defaults to `true`.
39
- * @returns {void}
40
- */
41
- pause(isPaused?: boolean): void;
42
- /**
43
- * Resumes the object's operation by setting its paused state to false.
44
- *
45
- * @returns {void}
46
- */
47
- resume(): void;
48
- /**
49
- * Updates the transform of the ParticleContainer and updates the emitters.
50
- */
51
- _updateTransform(deltaTime: number): void;
52
- /**
53
- *
54
- * @method updateTexture
55
- * @description This method updates the texture of the unused sprites and children to a randomly generated texture.
56
- */
57
- updateTexture(): void;
58
- /**
59
- * This method is used to start the emitter and turbulenceEmitter if available.
60
- * @function start
61
- */
62
- start(): void;
63
- /**
64
- * Resets the particle emitters in this class without removing existing particles and plays them.
65
- * @function play
66
- */
67
- play(): void;
68
- /**
69
- * Immediately stops emitting particles
70
- */
71
- stopImmediately(): void;
72
- /**
73
- * Destroy particles
74
- */
75
- destroy(): void;
76
- /**
77
- * Terminates the emitter and any turbulence emitter it is associated with
78
- */
79
- stop(): void;
80
- /**
81
- * Resets the emitters to their initial state
82
- */
83
- resetEmitter(): void;
84
- /**
85
- * Sets the textures used by the emitter
86
- * @param {string[]} textures - Array of strings containing the textures to be used by the emitter
87
- */
88
- setTextures(textures: string[]): void;
89
- /**
90
- * Updates the configuration of the emitter
91
- * @param {any} config - Configuration object to be used to update the emitter
92
- * @param {boolean} resetDuration - should duration be reset
93
- */
94
- updateConfig(config: any, resetDuration?: boolean): void;
95
- /**
96
- * Updates the position of the emitter
97
- * @param {Object} position - Object containing the x and y coordinates of the new position
98
- * @param {boolean} resetDuration - should duration be reset
99
- */
100
- updatePosition(position: {
101
- x: number;
102
- y: number;
103
- }, resetDuration?: boolean): void;
104
- /**
105
- * Clears the sprite pool, the unused sprites list and the turbulence and particle pools.
106
- */
107
- clearPool(): void;
108
- private getByName;
109
- private getOrCreateSprite;
110
- private createFrameAnimationByName;
111
- private onCreate;
112
- private onCreateTurbulence;
113
- private onUpdate;
114
- private onUpdateTurbulence;
115
- private onFinishing;
116
- private onRemove;
117
- private onRemoveTurbulence;
118
- private getRandomTexture;
119
- private getRandomFinishingTexture;
120
- private getRandomFrameNumber;
121
- private paused;
122
- private internalPause;
123
- private getConfigIndexByName;
124
- private buildTurbulenceConfig;
125
- }
@@ -1,578 +0,0 @@
1
- // tslint:disable:prefer-for-of
2
- import engine from '../index';
3
- import { Emitter } from '../emitter';
4
- import BehaviourNames from '../behaviour/BehaviourNames';
5
- import List from '../util/List';
6
- import ParticlePool from '../ParticlePool';
7
- import { AnimatedSprite, Container, Loader, Sprite, Texture, Ticker } from 'pixi.js-legacy';
8
- import Model from '../Model';
9
- /**
10
- * Renderer is a class used to render particles in the Pixi library.
11
- *
12
- * @class Renderer
13
- */
14
- export default class TestRenderer extends Container {
15
- /**
16
- * Creates an instance of Renderer.
17
- *
18
- * @memberof Renderer
19
- */
20
- constructor(settings) {
21
- const { textures, emitterConfig, finishingTextures, animatedSpriteZeroPad, animatedSpriteIndexToStart, maxFPS, minFPS, tickerSpeed, } = settings;
22
- super();
23
- this._paused = false;
24
- this._internalPaused = false;
25
- this.zeroPad = 2;
26
- this.indexToStart = 0;
27
- this.unusedSprites = [];
28
- this.anchor = { x: 0.5, y: 0.5 };
29
- this._model = new Model();
30
- this.onComplete = () => {
31
- /**/
32
- };
33
- this.onCompleteFN = () => {
34
- /**/
35
- };
36
- this.getByName = (name) => {
37
- for (let i = 0; i < this.config.behaviours.length; ++i) {
38
- if (this.config.behaviours[i].name === name) {
39
- return this.config.behaviours[i];
40
- }
41
- }
42
- return null;
43
- };
44
- this.config = emitterConfig;
45
- this.textures = textures;
46
- this.finishingTextureNames = finishingTextures;
47
- this.zeroPad = animatedSpriteZeroPad;
48
- this.indexToStart = animatedSpriteIndexToStart;
49
- const turbulenceConfigIndex = this.getConfigIndexByName(BehaviourNames.TURBULENCE_BEHAVIOUR, emitterConfig);
50
- if (turbulenceConfigIndex !== -1) {
51
- const turbulenceConfig = emitterConfig.behaviours[turbulenceConfigIndex];
52
- if (turbulenceConfig.enabled === true) {
53
- this.turbulenceEmitter = new engine.Emitter(this._model);
54
- this.turbulenceParser = this.turbulenceEmitter.getParser();
55
- this.turbulenceParser.read(this.buildTurbulenceConfig(turbulenceConfig), this._model);
56
- this.turbulenceEmitter.on(Emitter.CREATE, this.onCreateTurbulence, this);
57
- this.turbulenceEmitter.on(Emitter.UPDATE, this.onUpdateTurbulence, this);
58
- this.turbulenceEmitter.on(Emitter.REMOVE, this.onRemoveTurbulence, this);
59
- }
60
- }
61
- if (typeof emitterConfig.alpha !== 'undefined') {
62
- this.alpha = emitterConfig.alpha;
63
- }
64
- if (typeof emitterConfig.blendMode !== 'undefined') {
65
- this.blendMode = emitterConfig.blendMode;
66
- }
67
- if (typeof emitterConfig.anchor !== 'undefined') {
68
- this.anchor = emitterConfig.anchor;
69
- }
70
- this.emitter = new engine.Emitter(this._model);
71
- this.emitterParser = this.emitter.getParser();
72
- this.emitterParser.read(emitterConfig, this._model);
73
- this.emitter.on(Emitter.CREATE, this.onCreate, this);
74
- this.emitter.on(Emitter.UPDATE, this.onUpdate, this);
75
- this.emitter.on(Emitter.FINISHING, this.onFinishing, this);
76
- this.emitter.on(Emitter.REMOVE, this.onRemove, this);
77
- this.onCompleteFN = () => this.onComplete();
78
- this.emitter.on(Emitter.COMPLETE, this.onCompleteFN, this);
79
- if (this.turbulenceEmitter && this.turbulenceEmitter.list) {
80
- this.emitter.turbulencePool.list = this.turbulenceEmitter.list;
81
- }
82
- this._visibilitychangeBinding = () => this.internalPause(document.hidden);
83
- document.addEventListener('visibilitychange', this._visibilitychangeBinding);
84
- const ticker = new Ticker();
85
- ticker.maxFPS = maxFPS;
86
- ticker.minFPS = minFPS;
87
- ticker.speed = tickerSpeed;
88
- ticker.stop();
89
- // @ts-ignore
90
- ticker.add(this._updateTransform, this);
91
- ticker.start();
92
- this._ticker = ticker;
93
- }
94
- /**
95
- * Sets the paused state of the object.
96
- *
97
- * @param {boolean} [isPaused=true] - The new paused state of the object. Defaults to `true`.
98
- * @returns {void}
99
- */
100
- pause(isPaused = true) {
101
- this.paused(isPaused);
102
- }
103
- /**
104
- * Resumes the object's operation by setting its paused state to false.
105
- *
106
- * @returns {void}
107
- */
108
- resume() {
109
- this.paused(false);
110
- }
111
- /**
112
- * Updates the transform of the ParticleContainer and updates the emitters.
113
- */
114
- _updateTransform(deltaTime) {
115
- var _a;
116
- if (this._paused)
117
- return;
118
- (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.update(deltaTime);
119
- if (this.turbulenceEmitter) {
120
- this.turbulenceEmitter.update(deltaTime);
121
- }
122
- }
123
- /**
124
- *
125
- * @method updateTexture
126
- * @description This method updates the texture of the unused sprites and children to a randomly generated texture.
127
- */
128
- updateTexture() {
129
- for (let i = 0; i < this.unusedSprites.length; ++i) {
130
- this.unusedSprites[i].texture = Texture.from(this.getRandomTexture());
131
- }
132
- for (let i = 0; i < this.children.length; ++i) {
133
- // @ts-ignore
134
- this.children[i].texture = Texture.from(this.getRandomTexture());
135
- }
136
- }
137
- /**
138
- * This method is used to start the emitter and turbulenceEmitter if available.
139
- * @function start
140
- */
141
- start() {
142
- var _a;
143
- (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.resetAndPlay();
144
- if (this.turbulenceEmitter) {
145
- this.turbulenceEmitter.resetAndPlay();
146
- }
147
- }
148
- /**
149
- * Resets the particle emitters in this class without removing existing particles and plays them.
150
- * @function play
151
- */
152
- play() {
153
- var _a;
154
- (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.resetWithoutRemovingAndPlay();
155
- if (this.turbulenceEmitter) {
156
- this.turbulenceEmitter.resetWithoutRemovingAndPlay();
157
- }
158
- }
159
- /**
160
- * Immediately stops emitting particles
161
- */
162
- stopImmediately() {
163
- var _a, _b, _c;
164
- (_a = this._ticker) === null || _a === void 0 ? void 0 : _a.destroy();
165
- this._ticker = undefined;
166
- (_b = this.emitter) === null || _b === void 0 ? void 0 : _b.stop();
167
- if (this.turbulenceEmitter) {
168
- this.turbulenceEmitter.stop();
169
- }
170
- (_c = this.emitter) === null || _c === void 0 ? void 0 : _c.emit(Emitter.COMPLETE);
171
- }
172
- /**
173
- * Destroy particles
174
- */
175
- destroy() {
176
- this.stopImmediately();
177
- super.destroy();
178
- if (this.emitter) {
179
- this.emitter.destroy();
180
- this.emitter.off(Emitter.CREATE, this.onCreate, this);
181
- this.emitter.off(Emitter.UPDATE, this.onUpdate, this);
182
- this.emitter.off(Emitter.FINISHING, this.onFinishing, this);
183
- this.emitter.off(Emitter.REMOVE, this.onRemove, this);
184
- this.emitter.off(Emitter.COMPLETE, this.onCompleteFN, this);
185
- // @ts-ignore
186
- this.emitter = undefined;
187
- }
188
- // @ts-ignore
189
- this.turbulenceEmitter = undefined;
190
- // @ts-ignore
191
- this.turbulenceParser = undefined;
192
- // @ts-ignore
193
- this.unusedSprites = undefined;
194
- // @ts-ignore
195
- this._model = undefined;
196
- this.onComplete = undefined;
197
- this.onCompleteFN = undefined;
198
- this.config = undefined;
199
- // @ts-ignore
200
- this.textures = undefined;
201
- // @ts-ignore
202
- this.finishingTextureNames = undefined;
203
- // @ts-ignore
204
- this.emitterParser = undefined;
205
- // @ts-ignore
206
- this.textures = undefined;
207
- document.removeEventListener('visibilitychange', this._visibilitychangeBinding);
208
- }
209
- /**
210
- * Terminates the emitter and any turbulence emitter it is associated with
211
- */
212
- stop() {
213
- var _a;
214
- (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.stopWithoutKilling();
215
- if (this.turbulenceEmitter) {
216
- this.turbulenceEmitter.stop();
217
- }
218
- }
219
- /**
220
- * Resets the emitters to their initial state
221
- */
222
- resetEmitter() {
223
- var _a;
224
- (_a = this.emitter) === null || _a === void 0 ? void 0 : _a.reset();
225
- if (this.turbulenceEmitter) {
226
- this.turbulenceEmitter.reset();
227
- }
228
- }
229
- /**
230
- * Sets the textures used by the emitter
231
- * @param {string[]} textures - Array of strings containing the textures to be used by the emitter
232
- */
233
- setTextures(textures) {
234
- this.textures = textures;
235
- this.updateTexture();
236
- }
237
- /**
238
- * Updates the configuration of the emitter
239
- * @param {any} config - Configuration object to be used to update the emitter
240
- * @param {boolean} resetDuration - should duration be reset
241
- */
242
- updateConfig(config, resetDuration = false) {
243
- var _a;
244
- (_a = this.emitterParser) === null || _a === void 0 ? void 0 : _a.update(config, this._model, resetDuration);
245
- if (this.turbulenceEmitter) {
246
- const turbulenceConfigIndex = this.getConfigIndexByName(BehaviourNames.TURBULENCE_BEHAVIOUR, config);
247
- if (turbulenceConfigIndex !== -1) {
248
- const turbulenceConfig = config.behaviours[turbulenceConfigIndex];
249
- if (turbulenceConfig.enabled === true) {
250
- this.turbulenceParser.update(this.buildTurbulenceConfig(turbulenceConfig), this._model, resetDuration);
251
- }
252
- }
253
- }
254
- }
255
- /**
256
- * Updates the position of the emitter
257
- * @param {Object} position - Object containing the x and y coordinates of the new position
258
- * @param {boolean} resetDuration - should duration be reset
259
- */
260
- updatePosition(position, resetDuration = true) {
261
- var _a;
262
- const behaviour = this.getByName(BehaviourNames.SPAWN_BEHAVIOUR);
263
- behaviour.customPoints[0].position.x = position.x;
264
- behaviour.customPoints[0].position.y = position.y;
265
- (_a = this.emitterParser) === null || _a === void 0 ? void 0 : _a.update(this.config, this._model, resetDuration);
266
- }
267
- /**
268
- * Clears the sprite pool, the unused sprites list and the turbulence and particle pools.
269
- */
270
- clearPool() {
271
- this.removeChildren();
272
- this.unusedSprites = [];
273
- if (this.turbulenceEmitter && this.turbulenceEmitter.list) {
274
- if (this.emitter) {
275
- this.emitter.turbulencePool.list.reset();
276
- this.emitter.turbulencePool.list = new List();
277
- }
278
- }
279
- if (this.emitter) {
280
- this.emitter.list.reset();
281
- this.emitter.list = new List();
282
- }
283
- ParticlePool.global.reset();
284
- }
285
- getOrCreateSprite() {
286
- var _a, _b, _c;
287
- if (this.unusedSprites.length > 0) {
288
- const sprite = this.unusedSprites.pop();
289
- if (this.finishingTextureNames && this.finishingTextureNames.length) {
290
- sprite.texture = Texture.from(this.getRandomTexture());
291
- }
292
- return sprite;
293
- }
294
- if ((_a = this.emitter) === null || _a === void 0 ? void 0 : _a.animatedSprite) {
295
- const textures = this.createFrameAnimationByName(this.getRandomTexture());
296
- if (textures.length) {
297
- const animation = new AnimatedSprite(textures);
298
- animation.anchor.set(this.anchor.x, this.anchor.y);
299
- // @ts-ignore
300
- animation.loop = (_b = this.emitter) === null || _b === void 0 ? void 0 : _b.animatedSprite.loop;
301
- // @ts-ignore
302
- animation.animationSpeed = (_c = this.emitter) === null || _c === void 0 ? void 0 : _c.animatedSprite.frameRate;
303
- return this.addChild(animation);
304
- }
305
- }
306
- const sprite = new Sprite(Texture.from(this.getRandomTexture()));
307
- sprite.anchor.set(this.anchor.x, this.anchor.y);
308
- return this.addChild(sprite);
309
- }
310
- createFrameAnimationByName(prefix, imageFileExtension = 'png') {
311
- const zeroPad = this.zeroPad;
312
- const textures = [];
313
- let frame = '';
314
- let indexFrame = this.indexToStart;
315
- let padding = 0;
316
- let texture;
317
- const sheets = [];
318
- const resources = Loader.shared.resources;
319
- for (const key in resources) {
320
- if (resources[key].extension === 'json') {
321
- // @ts-ignore
322
- sheets.push(resources[key].spritesheet);
323
- }
324
- }
325
- do {
326
- frame = indexFrame.toString();
327
- padding = zeroPad - frame.length;
328
- if (padding > 0) {
329
- frame = '0'.repeat(padding) + frame;
330
- }
331
- try {
332
- let found = false;
333
- for (const sheet of sheets) {
334
- if (sheet && sheet.textures[`${prefix}${frame}.${imageFileExtension}`]) {
335
- found = true;
336
- }
337
- }
338
- if (found) {
339
- texture = Texture.from(`${prefix}${frame}.${imageFileExtension}`);
340
- textures.push(texture);
341
- indexFrame += 1;
342
- }
343
- else {
344
- texture = null;
345
- for (const key in resources) {
346
- if (key === `${prefix}${frame}.${imageFileExtension}`) {
347
- texture = Texture.from(`${prefix}${frame}.${imageFileExtension}`);
348
- textures.push(texture);
349
- indexFrame += 1;
350
- }
351
- }
352
- }
353
- }
354
- catch (e) {
355
- texture = null;
356
- }
357
- } while (texture);
358
- return textures;
359
- }
360
- onCreate(particle) {
361
- var _a;
362
- const sprite = this.getOrCreateSprite();
363
- sprite.visible = true;
364
- sprite.alpha = 1;
365
- if (this.blendMode) {
366
- sprite.blendMode = this.blendMode;
367
- }
368
- if (sprite instanceof AnimatedSprite) {
369
- if ((_a = this.emitter) === null || _a === void 0 ? void 0 : _a.animatedSprite.randomFrameStart) {
370
- const textures = this.createFrameAnimationByName(this.getRandomTexture());
371
- sprite.gotoAndPlay(this.getRandomFrameNumber(textures.length));
372
- }
373
- else {
374
- sprite.play();
375
- }
376
- }
377
- particle.sprite = sprite;
378
- }
379
- onCreateTurbulence(particle) {
380
- let sprite;
381
- if (particle.showVortices) {
382
- sprite = new Sprite(Texture.from('vortex.png'));
383
- }
384
- else {
385
- sprite = new Sprite();
386
- }
387
- sprite.anchor.set(this.anchor.x, this.anchor.y);
388
- this.addChild(sprite);
389
- sprite.visible = false;
390
- sprite.alpha = 0;
391
- particle.sprite = sprite;
392
- if (particle.showVortices && sprite) {
393
- sprite.visible = true;
394
- sprite.alpha = 1;
395
- }
396
- }
397
- onUpdate(particle) {
398
- const sprite = particle.sprite;
399
- sprite.x = particle.x;
400
- sprite.y = particle.y;
401
- sprite.scale.x = particle.size.x;
402
- sprite.scale.y = particle.size.y;
403
- sprite.tint = particle.color.hex;
404
- sprite.alpha = particle.color.alpha;
405
- sprite.rotation = particle.rotation;
406
- }
407
- onUpdateTurbulence(particle) {
408
- const sprite = particle.sprite;
409
- sprite.x = particle.x;
410
- sprite.y = particle.y;
411
- if (particle.showVortices && sprite) {
412
- sprite.scale.x = particle.size.x;
413
- sprite.scale.y = particle.size.y;
414
- sprite.tint = particle.color.hex;
415
- sprite.alpha = particle.color.alpha;
416
- sprite.rotation = particle.rotation;
417
- }
418
- }
419
- onFinishing(particle) {
420
- if (!this.finishingTextureNames || !this.finishingTextureNames.length)
421
- return;
422
- const sprite = particle.sprite;
423
- if (particle.finishingTexture <= this.finishingTextureNames.length - 1) {
424
- sprite.texture = Texture.from(this.getRandomFinishingTexture());
425
- particle.finishingTexture++;
426
- }
427
- }
428
- onRemove(particle) {
429
- const sprite = particle.sprite;
430
- if (!particle.showVortices && sprite) {
431
- sprite.visible = false;
432
- sprite.alpha = 0;
433
- }
434
- particle.finishingTexture = 0;
435
- this.unusedSprites.push(sprite);
436
- if (sprite instanceof AnimatedSprite) {
437
- sprite.stop();
438
- }
439
- }
440
- onRemoveTurbulence(particle) {
441
- const sprite = particle.sprite;
442
- if (!particle.showVortices && sprite) {
443
- sprite.visible = false;
444
- sprite.alpha = 0;
445
- }
446
- this.removeChild(sprite);
447
- delete particle.sprite;
448
- }
449
- getRandomTexture() {
450
- return this.textures[Math.floor(Math.random() * this.textures.length)];
451
- }
452
- getRandomFinishingTexture() {
453
- return this.finishingTextureNames[Math.floor(Math.random() * this.finishingTextureNames.length)];
454
- }
455
- getRandomFrameNumber(textures) {
456
- return Math.floor(Math.random() * textures);
457
- }
458
- paused(paused) {
459
- var _a, _b, _c, _d;
460
- if (paused === this._paused)
461
- return;
462
- this._paused = paused;
463
- if (paused) {
464
- (_a = this._ticker) === null || _a === void 0 ? void 0 : _a.stop();
465
- (_b = this.emitter) === null || _b === void 0 ? void 0 : _b.pause();
466
- }
467
- else {
468
- (_c = this._ticker) === null || _c === void 0 ? void 0 : _c.start();
469
- (_d = this.emitter) === null || _d === void 0 ? void 0 : _d.resume();
470
- }
471
- }
472
- internalPause(paused) {
473
- if (this._paused)
474
- return;
475
- if (paused === this._internalPaused)
476
- return;
477
- this._internalPaused = paused;
478
- }
479
- getConfigIndexByName(name, config) {
480
- let index = -1;
481
- config.behaviours.forEach((behaviour, i) => {
482
- if (behaviour.name === name) {
483
- index = i;
484
- }
485
- });
486
- return index;
487
- }
488
- buildTurbulenceConfig(turbulenceConfig) {
489
- return {
490
- behaviours: [
491
- {
492
- enabled: true,
493
- priority: 10000,
494
- maxLifeTime: turbulenceConfig.maxLifeTime || 2,
495
- timeVariance: turbulenceConfig.maxLifeTimeVariance || 0,
496
- name: 'LifeBehaviour',
497
- },
498
- {
499
- priority: 100,
500
- customPoints: [
501
- {
502
- spawnType: 'Ring',
503
- radius: 0,
504
- position: {
505
- x: turbulenceConfig.position.x || 0,
506
- y: turbulenceConfig.position.y || 0,
507
- },
508
- positionVariance: {
509
- x: turbulenceConfig.positionVariance.x || 0,
510
- y: turbulenceConfig.positionVariance.y || 0,
511
- },
512
- },
513
- ],
514
- name: 'SpawnBehaviour',
515
- },
516
- {
517
- enabled: true,
518
- priority: 100,
519
- velocity: {
520
- x: turbulenceConfig.velocity.x || 0,
521
- y: turbulenceConfig.velocity.y || 0,
522
- },
523
- velocityVariance: {
524
- x: turbulenceConfig.velocityVariance.x || 0,
525
- y: turbulenceConfig.velocityVariance.y || 0,
526
- },
527
- acceleration: {
528
- x: turbulenceConfig.acceleration.x || 0,
529
- y: turbulenceConfig.acceleration.y || 0,
530
- },
531
- accelerationVariance: {
532
- x: turbulenceConfig.accelerationVariance.x || 0,
533
- y: turbulenceConfig.accelerationVariance.y || 0,
534
- },
535
- name: 'PositionBehaviour',
536
- },
537
- {
538
- enabled: true,
539
- priority: 0,
540
- sizeStart: {
541
- x: turbulenceConfig.sizeStart.x || 1,
542
- y: turbulenceConfig.sizeStart.y || 1,
543
- },
544
- sizeEnd: {
545
- x: turbulenceConfig.sizeEnd.x || 1,
546
- y: turbulenceConfig.sizeEnd.y || 1,
547
- },
548
- startVariance: turbulenceConfig.startVariance || 0,
549
- endVariance: turbulenceConfig.endVariance || 0,
550
- name: 'SizeBehaviour',
551
- },
552
- {
553
- enabled: true,
554
- priority: 0,
555
- rotation: 12,
556
- variance: 0,
557
- name: 'RotationBehaviour',
558
- },
559
- {
560
- enabled: true,
561
- priority: 0,
562
- showVortices: turbulenceConfig.showVortices || false,
563
- turbulence: true,
564
- name: 'TurbulenceBehaviour',
565
- },
566
- ],
567
- emitController: {
568
- _maxParticles: 0,
569
- _maxLife: 1,
570
- _emitPerSecond: turbulenceConfig.emitPerSecond || 2,
571
- _frames: 0,
572
- name: 'UniformEmission',
573
- },
574
- duration: turbulenceConfig.duration || -1,
575
- };
576
- }
577
- }
578
- //# sourceMappingURL=TestRenderer.js.map