custom-pixi-particles 2.0.10 → 3.0.2
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.
- package/LICENSE +21 -21
- package/README.md +45 -45
- package/dist/index.d.ts +6 -6
- package/dist/index.js +15 -15
- package/dist/index.js.map +1 -1
- package/dist/lib/Particle.d.ts +44 -45
- package/dist/lib/Particle.js +68 -68
- package/dist/lib/Particle.js.map +1 -1
- package/dist/lib/ParticlePool.d.ts +9 -9
- package/dist/lib/ParticlePool.js +33 -33
- package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +26 -26
- package/dist/lib/behaviour/AngularVelocityBehaviour.js +77 -77
- package/dist/lib/behaviour/Behaviour.d.ts +7 -7
- package/dist/lib/behaviour/Behaviour.js +26 -26
- package/dist/lib/behaviour/BehaviourNames.d.ts +11 -11
- package/dist/lib/behaviour/BehaviourNames.js +12 -12
- package/dist/lib/behaviour/ColorBehaviour.d.ts +45 -45
- package/dist/lib/behaviour/ColorBehaviour.js +103 -103
- package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +22 -22
- package/dist/lib/behaviour/EmitDirectionBehaviour.js +83 -83
- package/dist/lib/behaviour/EmitterBehaviours.d.ts +12 -12
- package/dist/lib/behaviour/EmitterBehaviours.js +59 -59
- package/dist/lib/behaviour/LifeBehaviour.d.ts +18 -18
- package/dist/lib/behaviour/LifeBehaviour.js +55 -55
- package/dist/lib/behaviour/PositionBehaviour.d.ts +62 -62
- package/dist/lib/behaviour/PositionBehaviour.js +146 -146
- package/dist/lib/behaviour/RotationBehaviour.d.ts +22 -22
- package/dist/lib/behaviour/RotationBehaviour.js +77 -77
- package/dist/lib/behaviour/SizeBehaviour.d.ts +31 -31
- package/dist/lib/behaviour/SizeBehaviour.js +84 -84
- package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +69 -69
- package/dist/lib/behaviour/TurbulenceBehaviour.js +153 -153
- package/dist/lib/behaviour/index.d.ts +12 -12
- package/dist/lib/behaviour/index.js +28 -28
- package/dist/lib/customPixiParticlesSettingsInterface.d.ts +9 -8
- package/dist/lib/customPixiParticlesSettingsInterface.js +2 -2
- package/dist/lib/emission/AbstractEmission.d.ts +7 -7
- package/dist/lib/emission/AbstractEmission.js +21 -21
- package/dist/lib/emission/EmissionTypes.d.ts +6 -6
- package/dist/lib/emission/EmissionTypes.js +7 -7
- package/dist/lib/emission/RandomEmission.d.ts +11 -11
- package/dist/lib/emission/RandomEmission.js +61 -61
- package/dist/lib/emission/StandardEmission.d.ts +12 -12
- package/dist/lib/emission/StandardEmission.js +65 -65
- package/dist/lib/emission/UniformEmission.d.ts +14 -14
- package/dist/lib/emission/UniformEmission.js +73 -73
- package/dist/lib/emission/index.d.ts +6 -6
- package/dist/lib/emission/index.js +16 -16
- package/dist/lib/emitter/Duration.d.ts +10 -10
- package/dist/lib/emitter/Duration.js +28 -28
- package/dist/lib/emitter/Emitter.d.ts +43 -45
- package/dist/lib/emitter/Emitter.js +213 -214
- package/dist/lib/emitter/Emitter.js.map +1 -1
- package/dist/lib/emitter/index.d.ts +3 -3
- package/dist/lib/emitter/index.js +10 -10
- package/dist/lib/index.d.ts +20 -20
- package/dist/lib/index.js +44 -44
- package/dist/lib/parser/BehaviourParser.d.ts +10 -10
- package/dist/lib/parser/BehaviourParser.js +48 -48
- package/dist/lib/parser/CompatibilityHelper.d.ts +3 -3
- package/dist/lib/parser/CompatibilityHelper.js +14 -14
- package/dist/lib/parser/EmitControllerParser.d.ts +6 -6
- package/dist/lib/parser/EmitControllerParser.js +22 -22
- package/dist/lib/parser/EmitterParser.d.ts +12 -12
- package/dist/lib/parser/EmitterParser.js +126 -126
- package/dist/lib/parser/EmitterParser.js.map +1 -1
- package/dist/lib/parser/index.d.ts +5 -5
- package/dist/lib/parser/index.js +14 -14
- package/dist/lib/pixi/Renderer.d.ts +50 -49
- package/dist/lib/pixi/Renderer.js +427 -437
- package/dist/lib/pixi/Renderer.js.map +1 -1
- package/dist/lib/util/Color.d.ts +32 -32
- package/dist/lib/util/Color.js +98 -98
- package/dist/lib/util/List.d.ts +9 -9
- package/dist/lib/util/List.js +50 -50
- package/dist/lib/util/Point.d.ts +13 -13
- package/dist/lib/util/Point.js +29 -29
- package/dist/lib/util/Random.d.ts +4 -4
- package/dist/lib/util/Random.js +14 -14
- package/dist/lib/util/index.d.ts +5 -5
- package/dist/lib/util/index.js +14 -14
- package/dist/lib/util/maths.d.ts +7 -7
- package/dist/lib/util/maths.js +16 -16
- package/dist/lib/util/turbulencePool.d.ts +5 -5
- package/dist/lib/util/turbulencePool.js +9 -9
- package/package.json +40 -41
|
@@ -1,438 +1,428 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
var
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
this.
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
};
|
|
122
|
-
Renderer.prototype.
|
|
123
|
-
this.emitter.
|
|
124
|
-
if (this.turbulenceEmitter) {
|
|
125
|
-
this.turbulenceEmitter.
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
Renderer.prototype.
|
|
129
|
-
this.emitter.
|
|
130
|
-
if (this.turbulenceEmitter) {
|
|
131
|
-
this.turbulenceEmitter.
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
this.
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
var
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
};
|
|
255
|
-
Renderer.prototype.
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
sprite
|
|
262
|
-
sprite.
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
sprite.
|
|
273
|
-
sprite.
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
};
|
|
280
|
-
Renderer.prototype.
|
|
281
|
-
var sprite = particle.sprite;
|
|
282
|
-
sprite.x = particle.x;
|
|
283
|
-
sprite.y = particle.y;
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
sprite.
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
if (!
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
sprite.
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
this.
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
_frames: 0,
|
|
429
|
-
name: 'UniformEmission',
|
|
430
|
-
},
|
|
431
|
-
duration: turbulenceConfig.duration || -1,
|
|
432
|
-
};
|
|
433
|
-
return config;
|
|
434
|
-
};
|
|
435
|
-
return Renderer;
|
|
436
|
-
}(pixi_js_1.ParticleContainer));
|
|
437
|
-
exports.default = Renderer;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
// tslint:disable:prefer-for-of
|
|
7
|
+
var index_1 = __importDefault(require("../index"));
|
|
8
|
+
var emitter_1 = require("../emitter");
|
|
9
|
+
var turbulencePool_1 = __importDefault(require("../util/turbulencePool"));
|
|
10
|
+
var BehaviourNames_1 = __importDefault(require("../behaviour/BehaviourNames"));
|
|
11
|
+
var List_1 = __importDefault(require("../util/List"));
|
|
12
|
+
var ParticlePool_1 = __importDefault(require("../ParticlePool"));
|
|
13
|
+
var Renderer = /** @class */ (function () {
|
|
14
|
+
function Renderer(settings) {
|
|
15
|
+
var _this = this;
|
|
16
|
+
this.onComplete = function () { };
|
|
17
|
+
this._paused = false;
|
|
18
|
+
this.currentTime = 0;
|
|
19
|
+
this.lastTime = 0;
|
|
20
|
+
this.pausedTime = 0;
|
|
21
|
+
this.unusedSprites = [];
|
|
22
|
+
this.getByName = function (name) {
|
|
23
|
+
for (var i = 0; i < _this.config.behaviours.length; ++i) {
|
|
24
|
+
if (_this.config.behaviours[i].name === name) {
|
|
25
|
+
return _this.config.behaviours[i];
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return null;
|
|
29
|
+
};
|
|
30
|
+
var textures = settings.textures, emitterConfig = settings.emitterConfig, finishingTextures = settings.finishingTextures, PIXI = settings.PIXI;
|
|
31
|
+
this.particlesContainer = new PIXI.ParticleContainer(100000, {
|
|
32
|
+
vertices: true,
|
|
33
|
+
position: true,
|
|
34
|
+
rotation: true,
|
|
35
|
+
uvs: !!(settings.emitterConfig.animatedSprite ||
|
|
36
|
+
(settings.finishingTextures && settings.finishingTextures.length)),
|
|
37
|
+
tint: true,
|
|
38
|
+
});
|
|
39
|
+
this.PIXI = PIXI;
|
|
40
|
+
this.config = emitterConfig;
|
|
41
|
+
this.textures = textures;
|
|
42
|
+
this.finishingTextureNames = finishingTextures;
|
|
43
|
+
var turbulenceConfigIndex = this.getConfigIndexByName(BehaviourNames_1.default.TURBULENCE_BEHAVIOUR, emitterConfig);
|
|
44
|
+
if (turbulenceConfigIndex !== -1) {
|
|
45
|
+
var turbulenceConfig = emitterConfig.behaviours[turbulenceConfigIndex];
|
|
46
|
+
if (turbulenceConfig.enabled === true) {
|
|
47
|
+
this.turbulenceEmitter = new index_1.default.Emitter();
|
|
48
|
+
this.turbulenceParser = this.turbulenceEmitter.getParser();
|
|
49
|
+
this.turbulenceParser.read(this.buildTurbulenceConfig(turbulenceConfig));
|
|
50
|
+
this.turbulenceEmitter.on(emitter_1.Emitter.CREATE, this.onCreateTurbulence, this);
|
|
51
|
+
this.turbulenceEmitter.on(emitter_1.Emitter.UPDATE, this.onUpdateTurbulence, this);
|
|
52
|
+
this.turbulenceEmitter.on(emitter_1.Emitter.REMOVE, this.onRemoveTurbulence, this);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
if (typeof emitterConfig.alpha !== 'undefined') {
|
|
56
|
+
this.particlesContainer.alpha = emitterConfig.alpha;
|
|
57
|
+
}
|
|
58
|
+
if (typeof emitterConfig.blendMode !== 'undefined') {
|
|
59
|
+
this.blendMode = emitterConfig.blendMode;
|
|
60
|
+
}
|
|
61
|
+
this.emitter = new index_1.default.Emitter();
|
|
62
|
+
this.emitterParser = this.emitter.getParser();
|
|
63
|
+
this.emitterParser.read(emitterConfig);
|
|
64
|
+
this.emitter.on(emitter_1.Emitter.CREATE, this.onCreate, this);
|
|
65
|
+
this.emitter.on(emitter_1.Emitter.UPDATE, this.onUpdate, this);
|
|
66
|
+
this.emitter.on(emitter_1.Emitter.FINISHING, this.onFinishing, this);
|
|
67
|
+
this.emitter.on(emitter_1.Emitter.REMOVE, this.onRemove, this);
|
|
68
|
+
this.emitter.on(emitter_1.Emitter.PLAY, this.onPlay, this);
|
|
69
|
+
this.emitter.on(emitter_1.Emitter.COMPLETE, function () {
|
|
70
|
+
_this.onComplete();
|
|
71
|
+
});
|
|
72
|
+
if (this.turbulenceEmitter && this.turbulenceEmitter.list) {
|
|
73
|
+
turbulencePool_1.default.list = this.turbulenceEmitter.list;
|
|
74
|
+
}
|
|
75
|
+
document.addEventListener('visibilitychange', function () { return _this.paused(document.hidden); });
|
|
76
|
+
var ticker = this.PIXI.Ticker.shared;
|
|
77
|
+
ticker.add(function () {
|
|
78
|
+
_this.updateTransform();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
Renderer.prototype.updateTransform = function () {
|
|
82
|
+
if (this._paused)
|
|
83
|
+
return;
|
|
84
|
+
this.currentTime = performance.now();
|
|
85
|
+
if (this.lastTime === 0) {
|
|
86
|
+
this.lastTime = this.currentTime;
|
|
87
|
+
}
|
|
88
|
+
this.emitter.update((this.currentTime - this.lastTime) / 1000);
|
|
89
|
+
if (this.turbulenceEmitter) {
|
|
90
|
+
this.turbulenceEmitter.update((this.currentTime - this.lastTime) / 1000);
|
|
91
|
+
}
|
|
92
|
+
this.lastTime = this.currentTime;
|
|
93
|
+
};
|
|
94
|
+
Renderer.prototype.updateTexture = function () {
|
|
95
|
+
for (var i = 0; i < this.unusedSprites.length; ++i) {
|
|
96
|
+
this.unusedSprites[i].texture = this.PIXI.Texture.from(this.getRandomTexture());
|
|
97
|
+
}
|
|
98
|
+
for (var i = 0; i < this.particlesContainer.children.length; ++i) {
|
|
99
|
+
// @ts-ignore
|
|
100
|
+
this.children[i].texture = this.PIXI.Texture.from(this.getRandomTexture());
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
Renderer.prototype.start = function () {
|
|
104
|
+
this.emitter.resetAndPlay();
|
|
105
|
+
if (this.turbulenceEmitter) {
|
|
106
|
+
this.turbulenceEmitter.resetAndPlay();
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
Renderer.prototype.play = function () {
|
|
110
|
+
this.emitter.resetWithoutRemovingAndPlay();
|
|
111
|
+
if (this.turbulenceEmitter) {
|
|
112
|
+
this.turbulenceEmitter.resetWithoutRemovingAndPlay();
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
Renderer.prototype.stopImmediately = function () {
|
|
116
|
+
this.emitter.stop();
|
|
117
|
+
if (this.turbulenceEmitter) {
|
|
118
|
+
this.turbulenceEmitter.stop();
|
|
119
|
+
}
|
|
120
|
+
this.emitter.emit(emitter_1.Emitter.COMPLETE);
|
|
121
|
+
};
|
|
122
|
+
Renderer.prototype.stop = function () {
|
|
123
|
+
this.emitter.stopWithoutKilling();
|
|
124
|
+
if (this.turbulenceEmitter) {
|
|
125
|
+
this.turbulenceEmitter.stop();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
Renderer.prototype.resetEmitter = function () {
|
|
129
|
+
this.emitter.reset();
|
|
130
|
+
if (this.turbulenceEmitter) {
|
|
131
|
+
this.turbulenceEmitter.reset();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
Renderer.prototype.setTextures = function (textures) {
|
|
135
|
+
this.textures = textures;
|
|
136
|
+
this.updateTexture();
|
|
137
|
+
};
|
|
138
|
+
Renderer.prototype.updateConfig = function (config) {
|
|
139
|
+
this.emitterParser.update(config);
|
|
140
|
+
if (this.turbulenceEmitter) {
|
|
141
|
+
var turbulenceConfigIndex = this.getConfigIndexByName(BehaviourNames_1.default.TURBULENCE_BEHAVIOUR, config);
|
|
142
|
+
if (turbulenceConfigIndex !== -1) {
|
|
143
|
+
var turbulenceConfig = config.behaviours[turbulenceConfigIndex];
|
|
144
|
+
if (turbulenceConfig.enabled === true) {
|
|
145
|
+
this.turbulenceParser.update(this.buildTurbulenceConfig(turbulenceConfig));
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
Renderer.prototype.updatePosition = function (position) {
|
|
151
|
+
var positionBehaviour = this.getByName(BehaviourNames_1.default.POSITION_BEHAVIOUR);
|
|
152
|
+
positionBehaviour.position.x = position.x;
|
|
153
|
+
positionBehaviour.position.y = position.y;
|
|
154
|
+
this.emitterParser.update(this.config);
|
|
155
|
+
};
|
|
156
|
+
Renderer.prototype.clearPool = function () {
|
|
157
|
+
this.particlesContainer.removeChildren();
|
|
158
|
+
this.unusedSprites = [];
|
|
159
|
+
if (this.turbulenceEmitter && this.turbulenceEmitter.list) {
|
|
160
|
+
turbulencePool_1.default.list.reset();
|
|
161
|
+
turbulencePool_1.default.list = new List_1.default();
|
|
162
|
+
}
|
|
163
|
+
this.emitter.list.reset();
|
|
164
|
+
this.emitter.list = new List_1.default();
|
|
165
|
+
ParticlePool_1.default.global.reset();
|
|
166
|
+
};
|
|
167
|
+
Renderer.prototype.getOrCreateSprite = function () {
|
|
168
|
+
if (this.unusedSprites.length > 0) {
|
|
169
|
+
var sprite_1 = this.unusedSprites.pop();
|
|
170
|
+
if (this.finishingTextureNames && this.finishingTextureNames.length) {
|
|
171
|
+
sprite_1.texture = this.PIXI.Texture.from(this.getRandomTexture());
|
|
172
|
+
}
|
|
173
|
+
return sprite_1;
|
|
174
|
+
}
|
|
175
|
+
if (this.emitter.animatedSprite) {
|
|
176
|
+
var textures = this.createFrameAnimationByName(this.getRandomTexture(), 2);
|
|
177
|
+
if (textures.length) {
|
|
178
|
+
var animation = new this.PIXI.AnimatedSprite(textures);
|
|
179
|
+
animation.anchor.set(0.5);
|
|
180
|
+
animation.loop = this.emitter.animatedSprite.loop;
|
|
181
|
+
animation.play();
|
|
182
|
+
animation.animationSpeed = this.emitter.animatedSprite.frameRate;
|
|
183
|
+
return this.particlesContainer.addChild(animation);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
var sprite = new this.PIXI.Sprite(this.PIXI.Texture.from(this.getRandomTexture()));
|
|
187
|
+
sprite.anchor.set(0.5);
|
|
188
|
+
return this.particlesContainer.addChild(sprite);
|
|
189
|
+
};
|
|
190
|
+
Renderer.prototype.createFrameAnimationByName = function (prefix, zeroPad, imageFileExtension) {
|
|
191
|
+
if (zeroPad === void 0) { zeroPad = 0; }
|
|
192
|
+
if (imageFileExtension === void 0) { imageFileExtension = 'png'; }
|
|
193
|
+
var textures = [];
|
|
194
|
+
var frame = '';
|
|
195
|
+
var indexFrame = 0;
|
|
196
|
+
var padding = 0;
|
|
197
|
+
var texture;
|
|
198
|
+
var sheets = [];
|
|
199
|
+
var resources = this.PIXI.Loader.shared.resources;
|
|
200
|
+
for (var key in resources) {
|
|
201
|
+
if (resources[key].extension === 'json') {
|
|
202
|
+
// @ts-ignore
|
|
203
|
+
sheets.push(resources[key].spritesheet);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
do {
|
|
207
|
+
frame = indexFrame.toString();
|
|
208
|
+
padding = zeroPad - frame.length;
|
|
209
|
+
if (padding > 0) {
|
|
210
|
+
frame = '0'.repeat(padding) + frame;
|
|
211
|
+
}
|
|
212
|
+
try {
|
|
213
|
+
var found = false;
|
|
214
|
+
for (var _i = 0, sheets_1 = sheets; _i < sheets_1.length; _i++) {
|
|
215
|
+
var sheet = sheets_1[_i];
|
|
216
|
+
if (sheet && sheet.textures[prefix + "_" + frame + "." + imageFileExtension]) {
|
|
217
|
+
found = true;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
if (found) {
|
|
221
|
+
texture = this.PIXI.Texture.from(prefix + "_" + frame + "." + imageFileExtension);
|
|
222
|
+
textures.push(texture);
|
|
223
|
+
indexFrame += 1;
|
|
224
|
+
}
|
|
225
|
+
else {
|
|
226
|
+
texture = null;
|
|
227
|
+
for (var key in resources) {
|
|
228
|
+
if (key === prefix + "_" + frame + "." + imageFileExtension) {
|
|
229
|
+
texture = this.PIXI.Texture.from(prefix + "_" + frame + "." + imageFileExtension);
|
|
230
|
+
textures.push(texture);
|
|
231
|
+
indexFrame += 1;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
catch (e) {
|
|
237
|
+
texture = null;
|
|
238
|
+
}
|
|
239
|
+
} while (texture);
|
|
240
|
+
return textures;
|
|
241
|
+
};
|
|
242
|
+
Renderer.prototype.onPlay = function () {
|
|
243
|
+
this.currentTime = 0;
|
|
244
|
+
this.lastTime = 0;
|
|
245
|
+
};
|
|
246
|
+
Renderer.prototype.onCreate = function (particle) {
|
|
247
|
+
var sprite = this.getOrCreateSprite();
|
|
248
|
+
sprite.visible = true;
|
|
249
|
+
sprite.alpha = 1;
|
|
250
|
+
if (this.blendMode) {
|
|
251
|
+
sprite.blendMode = this.blendMode;
|
|
252
|
+
}
|
|
253
|
+
particle.sprite = sprite;
|
|
254
|
+
};
|
|
255
|
+
Renderer.prototype.onCreateTurbulence = function (particle) {
|
|
256
|
+
var vortexTexture = this.PIXI.Texture.from('vortex.png');
|
|
257
|
+
if (!vortexTexture)
|
|
258
|
+
return;
|
|
259
|
+
var sprite = new this.PIXI.Sprite(vortexTexture);
|
|
260
|
+
sprite.anchor.set(0.5);
|
|
261
|
+
this.particlesContainer.addChild(sprite);
|
|
262
|
+
sprite.visible = false;
|
|
263
|
+
sprite.alpha = 0;
|
|
264
|
+
particle.sprite = sprite;
|
|
265
|
+
if (particle.showVortices && sprite) {
|
|
266
|
+
sprite.visible = true;
|
|
267
|
+
sprite.alpha = 1;
|
|
268
|
+
}
|
|
269
|
+
};
|
|
270
|
+
Renderer.prototype.onUpdate = function (particle) {
|
|
271
|
+
var sprite = particle.sprite;
|
|
272
|
+
sprite.x = particle.x;
|
|
273
|
+
sprite.y = particle.y;
|
|
274
|
+
sprite.scale.x = particle.size.x;
|
|
275
|
+
sprite.scale.y = particle.size.y;
|
|
276
|
+
sprite.tint = particle.color.hex;
|
|
277
|
+
sprite.alpha = particle.color.alpha;
|
|
278
|
+
sprite.rotation = particle.rotation;
|
|
279
|
+
};
|
|
280
|
+
Renderer.prototype.onUpdateTurbulence = function (particle) {
|
|
281
|
+
var sprite = particle.sprite;
|
|
282
|
+
sprite.x = particle.x;
|
|
283
|
+
sprite.y = particle.y;
|
|
284
|
+
if (particle.showVortices && sprite) {
|
|
285
|
+
sprite.scale.x = particle.size.x;
|
|
286
|
+
sprite.scale.y = particle.size.y;
|
|
287
|
+
sprite.tint = particle.color.hex;
|
|
288
|
+
sprite.alpha = particle.color.alpha;
|
|
289
|
+
sprite.rotation = particle.rotation;
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
Renderer.prototype.onFinishing = function (particle) {
|
|
293
|
+
if (!this.finishingTextureNames || !this.finishingTextureNames.length)
|
|
294
|
+
return;
|
|
295
|
+
var sprite = particle.sprite;
|
|
296
|
+
if (particle.finishingTexture <= this.finishingTextureNames.length - 1) {
|
|
297
|
+
sprite.texture = this.PIXI.Texture.from(this.finishingTextureNames[particle.finishingTexture]);
|
|
298
|
+
particle.finishingTexture++;
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
Renderer.prototype.onRemove = function (particle) {
|
|
302
|
+
var sprite = particle.sprite;
|
|
303
|
+
if (!particle.showVortices && sprite) {
|
|
304
|
+
sprite.visible = false;
|
|
305
|
+
sprite.alpha = 0;
|
|
306
|
+
}
|
|
307
|
+
particle.finishingTexture = 0;
|
|
308
|
+
this.unusedSprites.push(sprite);
|
|
309
|
+
// this.removeChild(sprite)
|
|
310
|
+
// delete particle.sprite
|
|
311
|
+
};
|
|
312
|
+
Renderer.prototype.onRemoveTurbulence = function (particle) {
|
|
313
|
+
var sprite = particle.sprite;
|
|
314
|
+
if (!particle.showVortices && sprite) {
|
|
315
|
+
sprite.visible = false;
|
|
316
|
+
sprite.alpha = 0;
|
|
317
|
+
}
|
|
318
|
+
this.particlesContainer.removeChild(sprite);
|
|
319
|
+
delete particle.sprite;
|
|
320
|
+
};
|
|
321
|
+
Renderer.prototype.getRandomTexture = function () {
|
|
322
|
+
return this.textures[Math.floor(Math.random() * this.textures.length)];
|
|
323
|
+
};
|
|
324
|
+
Renderer.prototype.paused = function (paused) {
|
|
325
|
+
if (paused === this._paused)
|
|
326
|
+
return;
|
|
327
|
+
if (paused) {
|
|
328
|
+
this.pausedTime = performance.now();
|
|
329
|
+
}
|
|
330
|
+
else {
|
|
331
|
+
this.pausedTime = 0;
|
|
332
|
+
this.lastTime = performance.now() - this.pausedTime;
|
|
333
|
+
}
|
|
334
|
+
this._paused = paused;
|
|
335
|
+
};
|
|
336
|
+
Renderer.prototype.getConfigIndexByName = function (name, config) {
|
|
337
|
+
var index = -1;
|
|
338
|
+
config.behaviours.forEach(function (behaviour, i) {
|
|
339
|
+
if (behaviour.name === name) {
|
|
340
|
+
index = i;
|
|
341
|
+
}
|
|
342
|
+
});
|
|
343
|
+
return index;
|
|
344
|
+
};
|
|
345
|
+
Renderer.prototype.buildTurbulenceConfig = function (turbulenceConfig) {
|
|
346
|
+
var config = {
|
|
347
|
+
behaviours: [
|
|
348
|
+
{
|
|
349
|
+
enabled: true,
|
|
350
|
+
priority: 10000,
|
|
351
|
+
maxLifeTime: turbulenceConfig.maxLifeTime || 2,
|
|
352
|
+
timeVariance: turbulenceConfig.maxLifeTimeVariance || 0,
|
|
353
|
+
name: 'LifeBehaviour',
|
|
354
|
+
},
|
|
355
|
+
{
|
|
356
|
+
enabled: true,
|
|
357
|
+
priority: 100,
|
|
358
|
+
position: {
|
|
359
|
+
x: turbulenceConfig.position.x || 0,
|
|
360
|
+
y: turbulenceConfig.position.y || 0,
|
|
361
|
+
},
|
|
362
|
+
positionVariance: {
|
|
363
|
+
x: turbulenceConfig.positionVariance.x || 0,
|
|
364
|
+
y: turbulenceConfig.positionVariance.y || 0,
|
|
365
|
+
},
|
|
366
|
+
velocity: {
|
|
367
|
+
x: turbulenceConfig.velocity.x || 0,
|
|
368
|
+
y: turbulenceConfig.velocity.y || 0,
|
|
369
|
+
},
|
|
370
|
+
velocityVariance: {
|
|
371
|
+
x: turbulenceConfig.velocityVariance.x || 0,
|
|
372
|
+
y: turbulenceConfig.velocityVariance.y || 0,
|
|
373
|
+
},
|
|
374
|
+
acceleration: {
|
|
375
|
+
x: turbulenceConfig.acceleration.x || 0,
|
|
376
|
+
y: turbulenceConfig.acceleration.y || 0,
|
|
377
|
+
},
|
|
378
|
+
accelerationVariance: {
|
|
379
|
+
x: turbulenceConfig.accelerationVariance.x || 0,
|
|
380
|
+
y: turbulenceConfig.accelerationVariance.y || 0,
|
|
381
|
+
},
|
|
382
|
+
name: 'PositionBehaviour',
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
enabled: true,
|
|
386
|
+
priority: 0,
|
|
387
|
+
sizeStart: {
|
|
388
|
+
x: turbulenceConfig.sizeStart.x || 1,
|
|
389
|
+
y: turbulenceConfig.sizeStart.y || 1,
|
|
390
|
+
},
|
|
391
|
+
sizeEnd: {
|
|
392
|
+
x: turbulenceConfig.sizeEnd.x || 1,
|
|
393
|
+
y: turbulenceConfig.sizeEnd.y || 1,
|
|
394
|
+
},
|
|
395
|
+
startVariance: turbulenceConfig.startVariance || 0,
|
|
396
|
+
endVariance: turbulenceConfig.endVariance || 0,
|
|
397
|
+
name: 'SizeBehaviour',
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
enabled: true,
|
|
401
|
+
priority: 0,
|
|
402
|
+
rotation: 12,
|
|
403
|
+
variance: 0,
|
|
404
|
+
name: 'RotationBehaviour',
|
|
405
|
+
},
|
|
406
|
+
{
|
|
407
|
+
enabled: true,
|
|
408
|
+
priority: 0,
|
|
409
|
+
showVortices: turbulenceConfig.showVortices || false,
|
|
410
|
+
turbulence: true,
|
|
411
|
+
name: 'TurbulenceBehaviour',
|
|
412
|
+
},
|
|
413
|
+
],
|
|
414
|
+
emitController: {
|
|
415
|
+
_maxParticles: 0,
|
|
416
|
+
_maxLife: 1,
|
|
417
|
+
_emitPerSecond: turbulenceConfig.emitPerSecond || 2,
|
|
418
|
+
_frames: 0,
|
|
419
|
+
name: 'UniformEmission',
|
|
420
|
+
},
|
|
421
|
+
duration: turbulenceConfig.duration || -1,
|
|
422
|
+
};
|
|
423
|
+
return config;
|
|
424
|
+
};
|
|
425
|
+
return Renderer;
|
|
426
|
+
}());
|
|
427
|
+
exports.default = Renderer;
|
|
438
428
|
//# sourceMappingURL=Renderer.js.map
|