custom-pixi-particles 2.0.7 → 2.0.8
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/dist/index.d.ts +6 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/Particle.d.ts +45 -0
- package/dist/lib/Particle.js +69 -0
- package/dist/lib/Particle.js.map +1 -0
- package/dist/lib/ParticlePool.d.ts +9 -0
- package/dist/lib/ParticlePool.js +34 -0
- package/dist/lib/ParticlePool.js.map +1 -0
- package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +26 -0
- package/dist/lib/behaviour/AngularVelocityBehaviour.js +78 -0
- package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +1 -0
- package/dist/lib/behaviour/Behaviour.d.ts +7 -0
- package/dist/lib/behaviour/Behaviour.js +27 -0
- package/dist/lib/behaviour/Behaviour.js.map +1 -0
- package/dist/lib/behaviour/BehaviourNames.d.ts +11 -0
- package/dist/lib/behaviour/BehaviourNames.js +13 -0
- package/dist/lib/behaviour/BehaviourNames.js.map +1 -0
- package/dist/lib/behaviour/ColorBehaviour.d.ts +45 -0
- package/dist/lib/behaviour/ColorBehaviour.js +104 -0
- package/dist/lib/behaviour/ColorBehaviour.js.map +1 -0
- package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +22 -0
- package/dist/lib/behaviour/EmitDirectionBehaviour.js +84 -0
- package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/EmitterBehaviours.d.ts +12 -0
- package/dist/lib/behaviour/EmitterBehaviours.js +60 -0
- package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -0
- package/dist/lib/behaviour/LifeBehaviour.d.ts +18 -0
- package/dist/lib/behaviour/LifeBehaviour.js +56 -0
- package/dist/lib/behaviour/LifeBehaviour.js.map +1 -0
- package/dist/lib/behaviour/PositionBehaviour.d.ts +62 -0
- package/dist/lib/behaviour/PositionBehaviour.js +147 -0
- package/dist/lib/behaviour/PositionBehaviour.js.map +1 -0
- package/dist/lib/behaviour/RotationBehaviour.d.ts +22 -0
- package/dist/lib/behaviour/RotationBehaviour.js +78 -0
- package/dist/lib/behaviour/RotationBehaviour.js.map +1 -0
- package/dist/lib/behaviour/SizeBehaviour.d.ts +31 -0
- package/dist/lib/behaviour/SizeBehaviour.js +85 -0
- package/dist/lib/behaviour/SizeBehaviour.js.map +1 -0
- package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +69 -0
- package/dist/lib/behaviour/TurbulenceBehaviour.js +154 -0
- package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -0
- package/dist/lib/behaviour/index.d.ts +12 -0
- package/dist/lib/behaviour/index.js +29 -0
- package/dist/lib/behaviour/index.js.map +1 -0
- package/dist/lib/customPixiParticlesSettingsInterface.d.ts +8 -0
- package/dist/lib/customPixiParticlesSettingsInterface.js +3 -0
- package/dist/lib/customPixiParticlesSettingsInterface.js.map +1 -0
- package/dist/lib/emission/AbstractEmission.d.ts +7 -0
- package/dist/lib/emission/AbstractEmission.js +22 -0
- package/dist/lib/emission/AbstractEmission.js.map +1 -0
- package/dist/lib/emission/EmissionTypes.d.ts +6 -0
- package/dist/lib/emission/EmissionTypes.js +8 -0
- package/dist/lib/emission/EmissionTypes.js.map +1 -0
- package/dist/lib/emission/RandomEmission.d.ts +11 -0
- package/dist/lib/emission/RandomEmission.js +62 -0
- package/dist/lib/emission/RandomEmission.js.map +1 -0
- package/dist/lib/emission/StandardEmission.d.ts +12 -0
- package/dist/lib/emission/StandardEmission.js +66 -0
- package/dist/lib/emission/StandardEmission.js.map +1 -0
- package/dist/lib/emission/UniformEmission.d.ts +14 -0
- package/dist/lib/emission/UniformEmission.js +74 -0
- package/dist/lib/emission/UniformEmission.js.map +1 -0
- package/dist/lib/emission/index.d.ts +6 -0
- package/dist/lib/emission/index.js +17 -0
- package/dist/lib/emission/index.js.map +1 -0
- package/dist/lib/emitter/Duration.d.ts +10 -0
- package/dist/lib/emitter/Duration.js +29 -0
- package/dist/lib/emitter/Duration.js.map +1 -0
- package/dist/lib/emitter/Emitter.d.ts +45 -0
- package/dist/lib/emitter/Emitter.js +215 -0
- package/dist/lib/emitter/Emitter.js.map +1 -0
- package/dist/lib/emitter/index.d.ts +3 -0
- package/dist/lib/emitter/index.js +11 -0
- package/dist/lib/emitter/index.js.map +1 -0
- package/dist/lib/index.d.ts +20 -0
- package/dist/lib/index.js +45 -0
- package/dist/lib/index.js.map +1 -0
- package/dist/lib/parser/BehaviourParser.d.ts +10 -0
- package/dist/lib/parser/BehaviourParser.js +49 -0
- package/dist/lib/parser/BehaviourParser.js.map +1 -0
- package/dist/lib/parser/CompatibilityHelper.d.ts +3 -0
- package/dist/lib/parser/CompatibilityHelper.js +15 -0
- package/dist/lib/parser/CompatibilityHelper.js.map +1 -0
- package/dist/lib/parser/EmitControllerParser.d.ts +6 -0
- package/dist/lib/parser/EmitControllerParser.js +23 -0
- package/dist/lib/parser/EmitControllerParser.js.map +1 -0
- package/dist/lib/parser/EmitterParser.d.ts +12 -0
- package/dist/lib/parser/EmitterParser.js +127 -0
- package/dist/lib/parser/EmitterParser.js.map +1 -0
- package/dist/lib/parser/index.d.ts +5 -0
- package/dist/lib/parser/index.js +15 -0
- package/dist/lib/parser/index.js.map +1 -0
- package/dist/lib/pixi/Renderer.d.ts +49 -0
- package/dist/lib/pixi/Renderer.js +438 -0
- package/dist/lib/pixi/Renderer.js.map +1 -0
- package/dist/lib/util/Color.d.ts +32 -0
- package/dist/lib/util/Color.js +99 -0
- package/dist/lib/util/Color.js.map +1 -0
- package/dist/lib/util/List.d.ts +9 -0
- package/dist/lib/util/List.js +51 -0
- package/dist/lib/util/List.js.map +1 -0
- package/dist/lib/util/Point.d.ts +13 -0
- package/dist/lib/util/Point.js +30 -0
- package/dist/lib/util/Point.js.map +1 -0
- package/dist/lib/util/Random.d.ts +4 -0
- package/dist/lib/util/Random.js +15 -0
- package/dist/lib/util/Random.js.map +1 -0
- package/dist/lib/util/index.d.ts +5 -0
- package/dist/lib/util/index.js +15 -0
- package/dist/lib/util/index.js.map +1 -0
- package/dist/lib/util/maths.d.ts +7 -0
- package/dist/lib/util/maths.js +17 -0
- package/dist/lib/util/maths.js.map +1 -0
- package/dist/lib/util/turbulencePool.d.ts +5 -0
- package/dist/lib/util/turbulencePool.js +10 -0
- package/dist/lib/util/turbulencePool.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
10
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
11
|
+
}) : function(o, v) {
|
|
12
|
+
o["default"] = v;
|
|
13
|
+
});
|
|
14
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
15
|
+
if (mod && mod.__esModule) return mod;
|
|
16
|
+
var result = {};
|
|
17
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
18
|
+
__setModuleDefault(result, mod);
|
|
19
|
+
return result;
|
|
20
|
+
};
|
|
21
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
22
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
|
+
};
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
// tslint:disable:prefer-for-of
|
|
26
|
+
var CompatibilityHelper_1 = __importDefault(require("./CompatibilityHelper"));
|
|
27
|
+
var emissions = __importStar(require("../emission"));
|
|
28
|
+
var behaviours = __importStar(require("../behaviour"));
|
|
29
|
+
var EmitterParser = /** @class */ (function () {
|
|
30
|
+
function EmitterParser(emitter) {
|
|
31
|
+
var _this = this;
|
|
32
|
+
this.write = function () {
|
|
33
|
+
var config = { behaviours: [] };
|
|
34
|
+
var emitterBehavious = _this.emitter.behaviours.getAll();
|
|
35
|
+
for (var i = 0; i < emitterBehavious.length; i++) {
|
|
36
|
+
var behaviourConfig = emitterBehavious[i].getParser().write();
|
|
37
|
+
config.behaviours.push(behaviourConfig);
|
|
38
|
+
}
|
|
39
|
+
config.emitController = _this.emitter.emitController.getParser().write();
|
|
40
|
+
config.duration = _this.emitter.duration.maxTime;
|
|
41
|
+
if (typeof _this.emitter.alpha !== 'undefined') {
|
|
42
|
+
config.alpha = _this.emitter.alpha;
|
|
43
|
+
}
|
|
44
|
+
if (typeof _this.emitter.blendMode !== 'undefined') {
|
|
45
|
+
config.blendMode = _this.emitter.blendMode;
|
|
46
|
+
}
|
|
47
|
+
if (typeof _this.emitter.animatedSprite !== 'undefined') {
|
|
48
|
+
config.animatedSprite = _this.emitter.animatedSprite;
|
|
49
|
+
}
|
|
50
|
+
return config;
|
|
51
|
+
};
|
|
52
|
+
this.read = function (config) {
|
|
53
|
+
var behavioursConfig = config.behaviours;
|
|
54
|
+
var existingBehaviours = _this.emitter.behaviours.getAll();
|
|
55
|
+
var alwaysCreate = _this.emitter.behaviours.isEmpty();
|
|
56
|
+
_this.emitter.behaviours.clear();
|
|
57
|
+
for (var i = 0; i < behavioursConfig.length; i++) {
|
|
58
|
+
var name_1 = behavioursConfig[i].name;
|
|
59
|
+
var behaviour = alwaysCreate ? _this.createBehaviour(name_1) : _this.getExistingOrCreate(name_1, existingBehaviours);
|
|
60
|
+
behaviour.getParser().read(behavioursConfig[i]);
|
|
61
|
+
_this.emitter.behaviours.add(behaviour);
|
|
62
|
+
}
|
|
63
|
+
_this.emitter.emitController = _this.createEmitController(config.emitController.name || emissions.EmissionTypes.DEFAULT);
|
|
64
|
+
_this.emitter.emitController.getParser().read(config.emitController);
|
|
65
|
+
_this.emitter.duration.maxTime = CompatibilityHelper_1.default.readDuration(config);
|
|
66
|
+
if (typeof config.alpha !== 'undefined') {
|
|
67
|
+
_this.emitter.alpha = config.alpha;
|
|
68
|
+
}
|
|
69
|
+
if (typeof config.blendMode !== 'undefined') {
|
|
70
|
+
_this.emitter.blendMode = config.blendMode;
|
|
71
|
+
}
|
|
72
|
+
if (typeof config.animatedSprite !== 'undefined') {
|
|
73
|
+
_this.emitter.animatedSprite = config.animatedSprite;
|
|
74
|
+
}
|
|
75
|
+
return _this.emitter;
|
|
76
|
+
};
|
|
77
|
+
this.update = function (config) {
|
|
78
|
+
var behavioursConfig = config.behaviours;
|
|
79
|
+
var existingBehaviours = _this.emitter.behaviours.getAll();
|
|
80
|
+
var alwaysCreate = _this.emitter.behaviours.isEmpty();
|
|
81
|
+
_this.emitter.behaviours.clear();
|
|
82
|
+
for (var i = 0; i < behavioursConfig.length; i++) {
|
|
83
|
+
var name_2 = behavioursConfig[i].name;
|
|
84
|
+
var behaviour = alwaysCreate ? _this.createBehaviour(name_2) : _this.getExistingOrCreate(name_2, existingBehaviours);
|
|
85
|
+
behaviour.getParser().read(behavioursConfig[i]);
|
|
86
|
+
_this.emitter.behaviours.add(behaviour);
|
|
87
|
+
}
|
|
88
|
+
_this.emitter.emitController.getParser().read(config.emitController);
|
|
89
|
+
_this.emitter.duration.maxTime = CompatibilityHelper_1.default.readDuration(config);
|
|
90
|
+
_this.emitter.duration.reset();
|
|
91
|
+
if (typeof config.alpha !== 'undefined') {
|
|
92
|
+
_this.emitter.alpha = config.alpha;
|
|
93
|
+
}
|
|
94
|
+
if (typeof config.blendMode !== 'undefined') {
|
|
95
|
+
_this.emitter.blendMode = config.blendMode;
|
|
96
|
+
}
|
|
97
|
+
if (typeof config.animatedSprite !== 'undefined') {
|
|
98
|
+
_this.emitter.animatedSprite = config.animatedSprite;
|
|
99
|
+
}
|
|
100
|
+
return _this.emitter;
|
|
101
|
+
};
|
|
102
|
+
this.getExistingOrCreate = function (name, existingBehaviours) {
|
|
103
|
+
for (var i = 0; i < existingBehaviours.length; i++) {
|
|
104
|
+
if (existingBehaviours[i].getName() === name) {
|
|
105
|
+
return existingBehaviours[i];
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return _this.createBehaviour(name);
|
|
109
|
+
};
|
|
110
|
+
this.createBehaviour = function (name) {
|
|
111
|
+
// @ts-ignore
|
|
112
|
+
return new behaviours[name]();
|
|
113
|
+
};
|
|
114
|
+
this.createBehaviourProps = function (name) {
|
|
115
|
+
// @ts-ignore
|
|
116
|
+
return new behaviours[name]().getProps();
|
|
117
|
+
};
|
|
118
|
+
this.createEmitController = function (name) {
|
|
119
|
+
// @ts-ignore
|
|
120
|
+
return new emissions[name]();
|
|
121
|
+
};
|
|
122
|
+
this.emitter = emitter;
|
|
123
|
+
}
|
|
124
|
+
return EmitterParser;
|
|
125
|
+
}());
|
|
126
|
+
exports.default = EmitterParser;
|
|
127
|
+
//# sourceMappingURL=EmitterParser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EmitterParser.js","sourceRoot":"","sources":["../../../src/lib/parser/EmitterParser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,+BAA+B;AAC/B,8EAAuD;AACvD,qDAAwC;AACxC,uDAA0C;AAG1C;IAGE,uBAAY,OAAY;QAAxB,iBAEC;QAED,UAAK,GAAG;YACN,IAAM,MAAM,GAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,CAAA;YACtC,IAAM,gBAAgB,GAAG,KAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAA;YAEzD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAChD,IAAM,eAAe,GAAG,gBAAgB,CAAC,CAAC,CAAC,CA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K,WAAW,EAAE;gBAChD,KAAI,CAAC,OAAO,CAAC,cAAc,GAAG,MAAM,CAAC,cAAc,CAAA;aACpD;YAED,OAAO,KAAI,CAAC,OAAO,CAAA;QACrB,CAAC,CAAA;QAED,wBAAmB,GAAG,UAAC,IAAY,EAAE,kBAAuB;YAC1D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBAClD,IAAI,kBAAkB,CAAC,CAAC,CAAC,CAAC,OAAO,EAAE,KAAK,IAAI,EAAE;oBAC5C,OAAO,kBAAkB,CAAC,CAAC,CAAC,CAAA;iBAC7B;aACF;YAED,OAAO,KAAI,CAAC,eAAe,CAAC,IAAI,CAAC,CAAA;QACnC,CAAC,CAAA;QAED,oBAAe,GAAG,UAAC,IAAY;YAC7B,aAAa;YACb,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAA;QAC/B,CAAC,CAAA;QAED,yBAAoB,GAAG,UAAC,IAAY;YAClC,aAAa;YACb,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAA;QAC1C,CAAC,CAAA;QAED,yBAAoB,GAAG,UAAC,IAAY;YAClC,aAAa;YACb,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAA;QAC9B,CAAC,CAAA;QA9GC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IA8GH,oBAAC;AAAD,CAAC,AAnHD,IAmHC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import BehaviourParser from './BehaviourParser';
|
|
2
|
+
import CompatibilityHelper from './CompatibilityHelper';
|
|
3
|
+
import EmitControllerParser from './EmitControllerParser';
|
|
4
|
+
import EmitterParser from './EmitterParser';
|
|
5
|
+
export { BehaviourParser, CompatibilityHelper, EmitControllerParser, EmitterParser };
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
exports.EmitterParser = exports.EmitControllerParser = exports.CompatibilityHelper = exports.BehaviourParser = void 0;
|
|
7
|
+
var BehaviourParser_1 = __importDefault(require("./BehaviourParser"));
|
|
8
|
+
exports.BehaviourParser = BehaviourParser_1.default;
|
|
9
|
+
var CompatibilityHelper_1 = __importDefault(require("./CompatibilityHelper"));
|
|
10
|
+
exports.CompatibilityHelper = CompatibilityHelper_1.default;
|
|
11
|
+
var EmitControllerParser_1 = __importDefault(require("./EmitControllerParser"));
|
|
12
|
+
exports.EmitControllerParser = EmitControllerParser_1.default;
|
|
13
|
+
var EmitterParser_1 = __importDefault(require("./EmitterParser"));
|
|
14
|
+
exports.EmitterParser = EmitterParser_1.default;
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/parser/index.ts"],"names":[],"mappings":";;;;;;AAAA,sEAA+C;AAKtC,0BALF,yBAAe,CAKE;AAJxB,8EAAuD;AAI7B,8BAJnB,6BAAmB,CAImB;AAH7C,gFAAyD;AAGV,+BAHxC,8BAAoB,CAGwC;AAFnE,kEAA2C;AAE0B,wBAF9D,uBAAa,CAE8D"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Emitter } from '../emitter';
|
|
2
|
+
import { ICustomPixiParticlesSettings } from '../customPixiParticlesSettingsInterface';
|
|
3
|
+
import { ParticleContainer } from 'pixi.js';
|
|
4
|
+
export default class Renderer extends ParticleContainer {
|
|
5
|
+
blendMode: any;
|
|
6
|
+
emitter: Emitter;
|
|
7
|
+
turbulenceEmitter: Emitter;
|
|
8
|
+
onComplete: any;
|
|
9
|
+
private _paused;
|
|
10
|
+
private currentTime;
|
|
11
|
+
private lastTime;
|
|
12
|
+
private textures;
|
|
13
|
+
private finishingTextureNames;
|
|
14
|
+
private pausedTime;
|
|
15
|
+
private unusedSprites;
|
|
16
|
+
private emitterParser;
|
|
17
|
+
private turbulenceParser;
|
|
18
|
+
private config;
|
|
19
|
+
constructor(settings: ICustomPixiParticlesSettings);
|
|
20
|
+
updateTransform(): void;
|
|
21
|
+
updateTexture(): void;
|
|
22
|
+
start(): void;
|
|
23
|
+
play(): void;
|
|
24
|
+
stopImmediately(): void;
|
|
25
|
+
stop(): void;
|
|
26
|
+
resetEmitter(): void;
|
|
27
|
+
setTextures(textures: string[]): void;
|
|
28
|
+
updateConfig(config: any): void;
|
|
29
|
+
updatePosition(position: {
|
|
30
|
+
x: number;
|
|
31
|
+
y: number;
|
|
32
|
+
}): void;
|
|
33
|
+
clearPool(): void;
|
|
34
|
+
private getByName;
|
|
35
|
+
private getOrCreateSprite;
|
|
36
|
+
private createFrameAnimationByName;
|
|
37
|
+
private onPlay;
|
|
38
|
+
private onCreate;
|
|
39
|
+
private onCreateTurbulence;
|
|
40
|
+
private onUpdate;
|
|
41
|
+
private onUpdateTurbulence;
|
|
42
|
+
private onFinishing;
|
|
43
|
+
private onRemove;
|
|
44
|
+
private onRemoveTurbulence;
|
|
45
|
+
private getRandomTexture;
|
|
46
|
+
private paused;
|
|
47
|
+
private getConfigIndexByName;
|
|
48
|
+
private buildTurbulenceConfig;
|
|
49
|
+
}
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __extends = (this && this.__extends) || (function () {
|
|
3
|
+
var extendStatics = function (d, b) {
|
|
4
|
+
extendStatics = Object.setPrototypeOf ||
|
|
5
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
+
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
+
return extendStatics(d, b);
|
|
8
|
+
};
|
|
9
|
+
return function (d, b) {
|
|
10
|
+
if (typeof b !== "function" && b !== null)
|
|
11
|
+
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
+
extendStatics(d, b);
|
|
13
|
+
function __() { this.constructor = d; }
|
|
14
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
+
};
|
|
16
|
+
})();
|
|
17
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
+
};
|
|
20
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
+
// tslint:disable:prefer-for-of
|
|
22
|
+
var index_1 = __importDefault(require("../index"));
|
|
23
|
+
var emitter_1 = require("../emitter");
|
|
24
|
+
var turbulencePool_1 = __importDefault(require("../util/turbulencePool"));
|
|
25
|
+
var BehaviourNames_1 = __importDefault(require("../behaviour/BehaviourNames"));
|
|
26
|
+
var List_1 = __importDefault(require("../util/List"));
|
|
27
|
+
var ParticlePool_1 = __importDefault(require("../ParticlePool"));
|
|
28
|
+
var pixi_js_1 = require("pixi.js");
|
|
29
|
+
var Renderer = /** @class */ (function (_super) {
|
|
30
|
+
__extends(Renderer, _super);
|
|
31
|
+
function Renderer(settings) {
|
|
32
|
+
var _this = _super.call(this, 100000, {
|
|
33
|
+
vertices: true,
|
|
34
|
+
position: true,
|
|
35
|
+
rotation: true,
|
|
36
|
+
uvs: !!(settings.emitterConfig.animatedSprite ||
|
|
37
|
+
(settings.finishingTextures && settings.finishingTextures.length)),
|
|
38
|
+
tint: true,
|
|
39
|
+
}) || this;
|
|
40
|
+
_this.onComplete = function () { };
|
|
41
|
+
_this._paused = false;
|
|
42
|
+
_this.currentTime = 0;
|
|
43
|
+
_this.lastTime = 0;
|
|
44
|
+
_this.pausedTime = 0;
|
|
45
|
+
_this.unusedSprites = [];
|
|
46
|
+
_this.getByName = function (name) {
|
|
47
|
+
for (var i = 0; i < _this.config.behaviours.length; ++i) {
|
|
48
|
+
if (_this.config.behaviours[i].name === name) {
|
|
49
|
+
return _this.config.behaviours[i];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
};
|
|
54
|
+
var textures = settings.textures, emitterConfig = settings.emitterConfig, finishingTextures = settings.finishingTextures;
|
|
55
|
+
_this.config = emitterConfig;
|
|
56
|
+
_this.textures = textures;
|
|
57
|
+
_this.finishingTextureNames = finishingTextures;
|
|
58
|
+
var turbulenceConfigIndex = _this.getConfigIndexByName(BehaviourNames_1.default.TURBULENCE_BEHAVIOUR, emitterConfig);
|
|
59
|
+
if (turbulenceConfigIndex !== -1) {
|
|
60
|
+
var turbulenceConfig = emitterConfig.behaviours[turbulenceConfigIndex];
|
|
61
|
+
if (turbulenceConfig.enabled === true) {
|
|
62
|
+
_this.turbulenceEmitter = new index_1.default.Emitter();
|
|
63
|
+
_this.turbulenceParser = _this.turbulenceEmitter.getParser();
|
|
64
|
+
_this.turbulenceParser.read(_this.buildTurbulenceConfig(turbulenceConfig));
|
|
65
|
+
_this.turbulenceEmitter.on(emitter_1.Emitter.CREATE, _this.onCreateTurbulence, _this);
|
|
66
|
+
_this.turbulenceEmitter.on(emitter_1.Emitter.UPDATE, _this.onUpdateTurbulence, _this);
|
|
67
|
+
_this.turbulenceEmitter.on(emitter_1.Emitter.REMOVE, _this.onRemoveTurbulence, _this);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
if (typeof emitterConfig.alpha !== 'undefined') {
|
|
71
|
+
_this.alpha = emitterConfig.alpha;
|
|
72
|
+
}
|
|
73
|
+
if (typeof emitterConfig.blendMode !== 'undefined') {
|
|
74
|
+
_this.blendMode = emitterConfig.blendMode;
|
|
75
|
+
}
|
|
76
|
+
_this.emitter = new index_1.default.Emitter();
|
|
77
|
+
_this.emitterParser = _this.emitter.getParser();
|
|
78
|
+
_this.emitterParser.read(emitterConfig);
|
|
79
|
+
_this.emitter.on(emitter_1.Emitter.CREATE, _this.onCreate, _this);
|
|
80
|
+
_this.emitter.on(emitter_1.Emitter.UPDATE, _this.onUpdate, _this);
|
|
81
|
+
_this.emitter.on(emitter_1.Emitter.FINISHING, _this.onFinishing, _this);
|
|
82
|
+
_this.emitter.on(emitter_1.Emitter.REMOVE, _this.onRemove, _this);
|
|
83
|
+
_this.emitter.on(emitter_1.Emitter.PLAY, _this.onPlay, _this);
|
|
84
|
+
_this.emitter.on(emitter_1.Emitter.COMPLETE, function () {
|
|
85
|
+
_this.onComplete();
|
|
86
|
+
});
|
|
87
|
+
if (_this.turbulenceEmitter && _this.turbulenceEmitter.list) {
|
|
88
|
+
turbulencePool_1.default.list = _this.turbulenceEmitter.list;
|
|
89
|
+
}
|
|
90
|
+
document.addEventListener('visibilitychange', function () { return _this.paused(document.hidden); });
|
|
91
|
+
return _this;
|
|
92
|
+
}
|
|
93
|
+
Renderer.prototype.updateTransform = function () {
|
|
94
|
+
if (this._paused)
|
|
95
|
+
return;
|
|
96
|
+
this.currentTime = performance.now();
|
|
97
|
+
if (this.lastTime === 0) {
|
|
98
|
+
this.lastTime = this.currentTime;
|
|
99
|
+
}
|
|
100
|
+
this.emitter.update((this.currentTime - this.lastTime) / 1000);
|
|
101
|
+
if (this.turbulenceEmitter) {
|
|
102
|
+
this.turbulenceEmitter.update((this.currentTime - this.lastTime) / 1000);
|
|
103
|
+
}
|
|
104
|
+
pixi_js_1.ParticleContainer.prototype.updateTransform.call(this);
|
|
105
|
+
this.lastTime = this.currentTime;
|
|
106
|
+
};
|
|
107
|
+
Renderer.prototype.updateTexture = function () {
|
|
108
|
+
for (var i = 0; i < this.unusedSprites.length; ++i) {
|
|
109
|
+
this.unusedSprites[i].texture = pixi_js_1.Texture.from(this.getRandomTexture());
|
|
110
|
+
}
|
|
111
|
+
for (var i = 0; i < this.children.length; ++i) {
|
|
112
|
+
// @ts-ignore
|
|
113
|
+
this.children[i].texture = pixi_js_1.Texture.from(this.getRandomTexture());
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
Renderer.prototype.start = function () {
|
|
117
|
+
this.emitter.resetAndPlay();
|
|
118
|
+
if (this.turbulenceEmitter) {
|
|
119
|
+
this.turbulenceEmitter.resetAndPlay();
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
Renderer.prototype.play = function () {
|
|
123
|
+
this.emitter.resetWithoutRemovingAndPlay();
|
|
124
|
+
if (this.turbulenceEmitter) {
|
|
125
|
+
this.turbulenceEmitter.resetWithoutRemovingAndPlay();
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
Renderer.prototype.stopImmediately = function () {
|
|
129
|
+
this.emitter.stop();
|
|
130
|
+
if (this.turbulenceEmitter) {
|
|
131
|
+
this.turbulenceEmitter.stop();
|
|
132
|
+
}
|
|
133
|
+
this.emitter.emit(emitter_1.Emitter.COMPLETE);
|
|
134
|
+
};
|
|
135
|
+
Renderer.prototype.stop = function () {
|
|
136
|
+
this.emitter.stopWithoutKilling();
|
|
137
|
+
if (this.turbulenceEmitter) {
|
|
138
|
+
this.turbulenceEmitter.stop();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
Renderer.prototype.resetEmitter = function () {
|
|
142
|
+
this.emitter.reset();
|
|
143
|
+
if (this.turbulenceEmitter) {
|
|
144
|
+
this.turbulenceEmitter.reset();
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
Renderer.prototype.setTextures = function (textures) {
|
|
148
|
+
this.textures = textures;
|
|
149
|
+
this.updateTexture();
|
|
150
|
+
};
|
|
151
|
+
Renderer.prototype.updateConfig = function (config) {
|
|
152
|
+
this.emitterParser.update(config);
|
|
153
|
+
if (this.turbulenceEmitter) {
|
|
154
|
+
var turbulenceConfigIndex = this.getConfigIndexByName(BehaviourNames_1.default.TURBULENCE_BEHAVIOUR, config);
|
|
155
|
+
if (turbulenceConfigIndex !== -1) {
|
|
156
|
+
var turbulenceConfig = config.behaviours[turbulenceConfigIndex];
|
|
157
|
+
if (turbulenceConfig.enabled === true) {
|
|
158
|
+
this.turbulenceParser.update(this.buildTurbulenceConfig(turbulenceConfig));
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
Renderer.prototype.updatePosition = function (position) {
|
|
164
|
+
var positionBehaviour = this.getByName(BehaviourNames_1.default.POSITION_BEHAVIOUR);
|
|
165
|
+
positionBehaviour.position.x = position.x;
|
|
166
|
+
positionBehaviour.position.y = position.y;
|
|
167
|
+
this.emitterParser.update(this.config);
|
|
168
|
+
};
|
|
169
|
+
Renderer.prototype.clearPool = function () {
|
|
170
|
+
this.removeChildren();
|
|
171
|
+
this.unusedSprites = [];
|
|
172
|
+
if (this.turbulenceEmitter && this.turbulenceEmitter.list) {
|
|
173
|
+
turbulencePool_1.default.list.reset();
|
|
174
|
+
turbulencePool_1.default.list = new List_1.default();
|
|
175
|
+
}
|
|
176
|
+
this.emitter.list.reset();
|
|
177
|
+
this.emitter.list = new List_1.default();
|
|
178
|
+
ParticlePool_1.default.global.reset();
|
|
179
|
+
};
|
|
180
|
+
Renderer.prototype.getOrCreateSprite = function () {
|
|
181
|
+
if (this.unusedSprites.length > 0) {
|
|
182
|
+
var sprite_1 = this.unusedSprites.pop();
|
|
183
|
+
if (this.finishingTextureNames && this.finishingTextureNames.length) {
|
|
184
|
+
sprite_1.texture = pixi_js_1.Texture.from(this.getRandomTexture());
|
|
185
|
+
}
|
|
186
|
+
return sprite_1;
|
|
187
|
+
}
|
|
188
|
+
if (this.emitter.animatedSprite) {
|
|
189
|
+
var textures = this.createFrameAnimationByName(this.getRandomTexture(), 2);
|
|
190
|
+
if (textures.length) {
|
|
191
|
+
var animation = new pixi_js_1.AnimatedSprite(textures);
|
|
192
|
+
animation.anchor.set(0.5);
|
|
193
|
+
animation.loop = this.emitter.animatedSprite.loop;
|
|
194
|
+
animation.play();
|
|
195
|
+
animation.animationSpeed = this.emitter.animatedSprite.frameRate;
|
|
196
|
+
return this.addChild(animation);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
var sprite = new pixi_js_1.Sprite(pixi_js_1.Texture.from(this.getRandomTexture()));
|
|
200
|
+
sprite.anchor.set(0.5);
|
|
201
|
+
return this.addChild(sprite);
|
|
202
|
+
};
|
|
203
|
+
Renderer.prototype.createFrameAnimationByName = function (prefix, zeroPad, imageFileExtension) {
|
|
204
|
+
if (zeroPad === void 0) { zeroPad = 0; }
|
|
205
|
+
if (imageFileExtension === void 0) { imageFileExtension = 'png'; }
|
|
206
|
+
var textures = [];
|
|
207
|
+
var frame = '';
|
|
208
|
+
var indexFrame = 0;
|
|
209
|
+
var padding = 0;
|
|
210
|
+
var texture;
|
|
211
|
+
var sheets = [];
|
|
212
|
+
var resources = pixi_js_1.Loader.shared.resources;
|
|
213
|
+
for (var key in resources) {
|
|
214
|
+
if (resources[key].extension === 'json') {
|
|
215
|
+
// @ts-ignore
|
|
216
|
+
sheets.push(resources[key].spritesheet);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
do {
|
|
220
|
+
frame = indexFrame.toString();
|
|
221
|
+
padding = zeroPad - frame.length;
|
|
222
|
+
if (padding > 0) {
|
|
223
|
+
frame = '0'.repeat(padding) + frame;
|
|
224
|
+
}
|
|
225
|
+
try {
|
|
226
|
+
var found = false;
|
|
227
|
+
for (var _i = 0, sheets_1 = sheets; _i < sheets_1.length; _i++) {
|
|
228
|
+
var sheet = sheets_1[_i];
|
|
229
|
+
if (sheet && sheet.textures[prefix + "_" + frame + "." + imageFileExtension]) {
|
|
230
|
+
found = true;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
if (found) {
|
|
234
|
+
texture = pixi_js_1.Texture.from(prefix + "_" + frame + "." + imageFileExtension);
|
|
235
|
+
textures.push(texture);
|
|
236
|
+
indexFrame += 1;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
texture = null;
|
|
240
|
+
for (var key in resources) {
|
|
241
|
+
if (key === prefix + "_" + frame + "." + imageFileExtension) {
|
|
242
|
+
texture = pixi_js_1.Texture.from(prefix + "_" + frame + "." + imageFileExtension);
|
|
243
|
+
textures.push(texture);
|
|
244
|
+
indexFrame += 1;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
catch (e) {
|
|
250
|
+
texture = null;
|
|
251
|
+
}
|
|
252
|
+
} while (texture);
|
|
253
|
+
return textures;
|
|
254
|
+
};
|
|
255
|
+
Renderer.prototype.onPlay = function () {
|
|
256
|
+
this.currentTime = 0;
|
|
257
|
+
this.lastTime = 0;
|
|
258
|
+
};
|
|
259
|
+
Renderer.prototype.onCreate = function (particle) {
|
|
260
|
+
var sprite = this.getOrCreateSprite();
|
|
261
|
+
sprite.visible = true;
|
|
262
|
+
sprite.alpha = 1;
|
|
263
|
+
if (this.blendMode) {
|
|
264
|
+
sprite.blendMode = this.blendMode;
|
|
265
|
+
}
|
|
266
|
+
particle.sprite = sprite;
|
|
267
|
+
};
|
|
268
|
+
Renderer.prototype.onCreateTurbulence = function (particle) {
|
|
269
|
+
var sprite = new pixi_js_1.Sprite(pixi_js_1.Texture.from('vortex.png'));
|
|
270
|
+
sprite.anchor.set(0.5);
|
|
271
|
+
this.addChild(sprite);
|
|
272
|
+
sprite.visible = false;
|
|
273
|
+
sprite.alpha = 0;
|
|
274
|
+
particle.sprite = sprite;
|
|
275
|
+
if (particle.showVortices && sprite) {
|
|
276
|
+
sprite.visible = true;
|
|
277
|
+
sprite.alpha = 1;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
Renderer.prototype.onUpdate = function (particle) {
|
|
281
|
+
var sprite = particle.sprite;
|
|
282
|
+
sprite.x = particle.x;
|
|
283
|
+
sprite.y = particle.y;
|
|
284
|
+
sprite.scale.x = particle.size.x;
|
|
285
|
+
sprite.scale.y = particle.size.y;
|
|
286
|
+
sprite.tint = particle.color.hex;
|
|
287
|
+
sprite.alpha = particle.color.alpha;
|
|
288
|
+
sprite.rotation = particle.rotation;
|
|
289
|
+
};
|
|
290
|
+
Renderer.prototype.onUpdateTurbulence = function (particle) {
|
|
291
|
+
var sprite = particle.sprite;
|
|
292
|
+
sprite.x = particle.x;
|
|
293
|
+
sprite.y = particle.y;
|
|
294
|
+
if (particle.showVortices && sprite) {
|
|
295
|
+
sprite.scale.x = particle.size.x;
|
|
296
|
+
sprite.scale.y = particle.size.y;
|
|
297
|
+
sprite.tint = particle.color.hex;
|
|
298
|
+
sprite.alpha = particle.color.alpha;
|
|
299
|
+
sprite.rotation = particle.rotation;
|
|
300
|
+
}
|
|
301
|
+
};
|
|
302
|
+
Renderer.prototype.onFinishing = function (particle) {
|
|
303
|
+
if (!this.finishingTextureNames || !this.finishingTextureNames.length)
|
|
304
|
+
return;
|
|
305
|
+
var sprite = particle.sprite;
|
|
306
|
+
if (particle.finishingTexture <= this.finishingTextureNames.length - 1) {
|
|
307
|
+
sprite.texture = pixi_js_1.Texture.from(this.finishingTextureNames[particle.finishingTexture]);
|
|
308
|
+
particle.finishingTexture++;
|
|
309
|
+
}
|
|
310
|
+
};
|
|
311
|
+
Renderer.prototype.onRemove = function (particle) {
|
|
312
|
+
var sprite = particle.sprite;
|
|
313
|
+
if (!particle.showVortices && sprite) {
|
|
314
|
+
sprite.visible = false;
|
|
315
|
+
sprite.alpha = 0;
|
|
316
|
+
}
|
|
317
|
+
particle.finishingTexture = 0;
|
|
318
|
+
this.unusedSprites.push(sprite);
|
|
319
|
+
// this.removeChild(sprite)
|
|
320
|
+
// delete particle.sprite
|
|
321
|
+
};
|
|
322
|
+
Renderer.prototype.onRemoveTurbulence = function (particle) {
|
|
323
|
+
var sprite = particle.sprite;
|
|
324
|
+
if (!particle.showVortices && sprite) {
|
|
325
|
+
sprite.visible = false;
|
|
326
|
+
sprite.alpha = 0;
|
|
327
|
+
}
|
|
328
|
+
this.removeChild(sprite);
|
|
329
|
+
delete particle.sprite;
|
|
330
|
+
};
|
|
331
|
+
Renderer.prototype.getRandomTexture = function () {
|
|
332
|
+
return this.textures[Math.floor(Math.random() * this.textures.length)];
|
|
333
|
+
};
|
|
334
|
+
Renderer.prototype.paused = function (paused) {
|
|
335
|
+
if (paused === this._paused)
|
|
336
|
+
return;
|
|
337
|
+
if (paused) {
|
|
338
|
+
this.pausedTime = performance.now();
|
|
339
|
+
}
|
|
340
|
+
else {
|
|
341
|
+
this.pausedTime = 0;
|
|
342
|
+
this.lastTime = performance.now() - this.pausedTime;
|
|
343
|
+
}
|
|
344
|
+
this._paused = paused;
|
|
345
|
+
};
|
|
346
|
+
Renderer.prototype.getConfigIndexByName = function (name, config) {
|
|
347
|
+
var index = -1;
|
|
348
|
+
config.behaviours.forEach(function (behaviour, i) {
|
|
349
|
+
if (behaviour.name === name) {
|
|
350
|
+
index = i;
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
return index;
|
|
354
|
+
};
|
|
355
|
+
Renderer.prototype.buildTurbulenceConfig = function (turbulenceConfig) {
|
|
356
|
+
var config = {
|
|
357
|
+
behaviours: [
|
|
358
|
+
{
|
|
359
|
+
enabled: true,
|
|
360
|
+
priority: 10000,
|
|
361
|
+
maxLifeTime: turbulenceConfig.maxLifeTime || 2,
|
|
362
|
+
timeVariance: turbulenceConfig.maxLifeTimeVariance || 0,
|
|
363
|
+
name: 'LifeBehaviour',
|
|
364
|
+
},
|
|
365
|
+
{
|
|
366
|
+
enabled: true,
|
|
367
|
+
priority: 100,
|
|
368
|
+
position: {
|
|
369
|
+
x: turbulenceConfig.position.x || 0,
|
|
370
|
+
y: turbulenceConfig.position.y || 0,
|
|
371
|
+
},
|
|
372
|
+
positionVariance: {
|
|
373
|
+
x: turbulenceConfig.positionVariance.x || 0,
|
|
374
|
+
y: turbulenceConfig.positionVariance.y || 0,
|
|
375
|
+
},
|
|
376
|
+
velocity: {
|
|
377
|
+
x: turbulenceConfig.velocity.x || 0,
|
|
378
|
+
y: turbulenceConfig.velocity.y || 0,
|
|
379
|
+
},
|
|
380
|
+
velocityVariance: {
|
|
381
|
+
x: turbulenceConfig.velocityVariance.x || 0,
|
|
382
|
+
y: turbulenceConfig.velocityVariance.y || 0,
|
|
383
|
+
},
|
|
384
|
+
acceleration: {
|
|
385
|
+
x: turbulenceConfig.acceleration.x || 0,
|
|
386
|
+
y: turbulenceConfig.acceleration.y || 0,
|
|
387
|
+
},
|
|
388
|
+
accelerationVariance: {
|
|
389
|
+
x: turbulenceConfig.accelerationVariance.x || 0,
|
|
390
|
+
y: turbulenceConfig.accelerationVariance.y || 0,
|
|
391
|
+
},
|
|
392
|
+
name: 'PositionBehaviour',
|
|
393
|
+
},
|
|
394
|
+
{
|
|
395
|
+
enabled: true,
|
|
396
|
+
priority: 0,
|
|
397
|
+
sizeStart: {
|
|
398
|
+
x: turbulenceConfig.sizeStart.x || 1,
|
|
399
|
+
y: turbulenceConfig.sizeStart.y || 1,
|
|
400
|
+
},
|
|
401
|
+
sizeEnd: {
|
|
402
|
+
x: turbulenceConfig.sizeEnd.x || 1,
|
|
403
|
+
y: turbulenceConfig.sizeEnd.y || 1,
|
|
404
|
+
},
|
|
405
|
+
startVariance: turbulenceConfig.startVariance || 0,
|
|
406
|
+
endVariance: turbulenceConfig.endVariance || 0,
|
|
407
|
+
name: 'SizeBehaviour',
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
enabled: true,
|
|
411
|
+
priority: 0,
|
|
412
|
+
rotation: 12,
|
|
413
|
+
variance: 0,
|
|
414
|
+
name: 'RotationBehaviour',
|
|
415
|
+
},
|
|
416
|
+
{
|
|
417
|
+
enabled: true,
|
|
418
|
+
priority: 0,
|
|
419
|
+
showVortices: turbulenceConfig.showVortices || false,
|
|
420
|
+
turbulence: true,
|
|
421
|
+
name: 'TurbulenceBehaviour',
|
|
422
|
+
},
|
|
423
|
+
],
|
|
424
|
+
emitController: {
|
|
425
|
+
_maxParticles: 0,
|
|
426
|
+
_maxLife: 1,
|
|
427
|
+
_emitPerSecond: turbulenceConfig.emitPerSecond || 2,
|
|
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;
|
|
438
|
+
//# sourceMappingURL=Renderer.js.map
|