custom-pixi-particles 4.0.21 → 4.0.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/lib/Model.d.ts +23 -0
- package/dist/lib/Model.js +23 -0
- package/dist/lib/Model.js.map +1 -1
- package/dist/lib/Particle.d.ts +146 -0
- package/dist/lib/Particle.js +61 -0
- package/dist/lib/Particle.js.map +1 -1
- package/dist/lib/ParticlePool.d.ts +28 -0
- package/dist/lib/ParticlePool.js +28 -0
- package/dist/lib/ParticlePool.js.map +1 -1
- package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +31 -0
- package/dist/lib/behaviour/AngularVelocityBehaviour.js +45 -12
- package/dist/lib/behaviour/AngularVelocityBehaviour.js.map +1 -1
- package/dist/lib/behaviour/Behaviour.d.ts +26 -0
- package/dist/lib/behaviour/Behaviour.js +26 -0
- package/dist/lib/behaviour/Behaviour.js.map +1 -1
- package/dist/lib/behaviour/ColorBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/ColorBehaviour.js +8 -11
- package/dist/lib/behaviour/ColorBehaviour.js.map +1 -1
- package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +29 -5
- package/dist/lib/behaviour/EmitDirectionBehaviour.js +32 -20
- package/dist/lib/behaviour/EmitDirectionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/EmitterBehaviours.d.ts +44 -2
- package/dist/lib/behaviour/EmitterBehaviours.js +43 -3
- package/dist/lib/behaviour/EmitterBehaviours.js.map +1 -1
- package/dist/lib/behaviour/LifeBehaviour.d.ts +49 -0
- package/dist/lib/behaviour/LifeBehaviour.js +55 -5
- package/dist/lib/behaviour/LifeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/PositionBehaviour.d.ts +32 -1
- package/dist/lib/behaviour/PositionBehaviour.js +60 -26
- package/dist/lib/behaviour/PositionBehaviour.js.map +1 -1
- package/dist/lib/behaviour/RotationBehaviour.d.ts +33 -4
- package/dist/lib/behaviour/RotationBehaviour.js +33 -17
- package/dist/lib/behaviour/RotationBehaviour.js.map +1 -1
- package/dist/lib/behaviour/SizeBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/SizeBehaviour.js +25 -18
- package/dist/lib/behaviour/SizeBehaviour.js.map +1 -1
- package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +1 -1
- package/dist/lib/behaviour/TurbulenceBehaviour.js +1 -5
- package/dist/lib/behaviour/TurbulenceBehaviour.js.map +1 -1
- package/dist/lib/emission/AbstractEmission.d.ts +23 -0
- package/dist/lib/emission/AbstractEmission.js +23 -0
- package/dist/lib/emission/AbstractEmission.js.map +1 -1
- package/dist/lib/emission/RandomEmission.d.ts +33 -0
- package/dist/lib/emission/RandomEmission.js +33 -0
- package/dist/lib/emission/RandomEmission.js.map +1 -1
- package/dist/lib/emission/StandardEmission.d.ts +49 -0
- package/dist/lib/emission/StandardEmission.js +49 -0
- package/dist/lib/emission/StandardEmission.js.map +1 -1
- package/dist/lib/emission/UniformEmission.d.ts +42 -0
- package/dist/lib/emission/UniformEmission.js +42 -0
- package/dist/lib/emission/UniformEmission.js.map +1 -1
- package/dist/lib/emitter/Duration.d.ts +17 -0
- package/dist/lib/emitter/Duration.js +17 -0
- package/dist/lib/emitter/Duration.js.map +1 -1
- package/dist/lib/emitter/Emitter.d.ts +60 -0
- package/dist/lib/emitter/Emitter.js +60 -0
- package/dist/lib/emitter/Emitter.js.map +1 -1
- package/dist/lib/parser/BehaviourParser.d.ts +15 -4
- package/dist/lib/parser/BehaviourParser.js +15 -23
- package/dist/lib/parser/BehaviourParser.js.map +1 -1
- package/dist/lib/parser/CompatibilityHelper.d.ts +9 -0
- package/dist/lib/parser/CompatibilityHelper.js +9 -0
- package/dist/lib/parser/CompatibilityHelper.js.map +1 -1
- package/dist/lib/parser/EmitControllerParser.d.ts +21 -0
- package/dist/lib/parser/EmitControllerParser.js +21 -0
- package/dist/lib/parser/EmitControllerParser.js.map +1 -1
- package/dist/lib/parser/EmitterParser.d.ts +54 -1
- package/dist/lib/parser/EmitterParser.js +72 -15
- package/dist/lib/parser/EmitterParser.js.map +1 -1
- package/dist/lib/pixi/Renderer.d.ts +55 -0
- package/dist/lib/pixi/Renderer.js +55 -0
- package/dist/lib/pixi/Renderer.js.map +1 -1
- package/dist/lib/util/Color.d.ts +101 -0
- package/dist/lib/util/Color.js +101 -0
- package/dist/lib/util/Color.js.map +1 -1
- package/dist/lib/util/List.d.ts +40 -0
- package/dist/lib/util/List.js +40 -0
- package/dist/lib/util/List.js.map +1 -1
- package/dist/lib/util/Point.d.ts +21 -0
- package/dist/lib/util/Point.js +21 -0
- package/dist/lib/util/Point.js.map +1 -1
- package/dist/lib/util/Random.d.ts +20 -0
- package/dist/lib/util/Random.js +20 -0
- package/dist/lib/util/Random.js.map +1 -1
- package/dist/lib/util/maths.d.ts +17 -0
- package/dist/lib/util/maths.js +17 -0
- package/dist/lib/util/maths.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,25 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Class used to parse a behaviour object into a JSON config object and vice versa
|
|
3
|
+
*/
|
|
2
4
|
export default class BehaviourParser {
|
|
5
|
+
/**
|
|
6
|
+
* Constructs a BehaviourParser object.
|
|
7
|
+
* @param {any} behaviour The behaviour to be parsed.
|
|
8
|
+
*/
|
|
3
9
|
constructor(behaviour) {
|
|
10
|
+
/**
|
|
11
|
+
* Writes the behaviour to a config object.
|
|
12
|
+
* @returns {object} The config object.
|
|
13
|
+
*/
|
|
4
14
|
this.write = () => {
|
|
5
15
|
const config = JSON.parse(JSON.stringify(this._behaviour));
|
|
6
16
|
config.name = this._behaviour.getName();
|
|
7
17
|
return config;
|
|
8
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Reads a config object and sets the behaviour appropriately.
|
|
21
|
+
* @param {object} config The config object to be read.
|
|
22
|
+
*/
|
|
9
23
|
this.read = (config) => {
|
|
10
24
|
for (const key in config) {
|
|
11
25
|
if (this._behaviour[key] instanceof Object) {
|
|
@@ -16,28 +30,6 @@ export default class BehaviourParser {
|
|
|
16
30
|
}
|
|
17
31
|
}
|
|
18
32
|
};
|
|
19
|
-
this.writePoint = (point) => {
|
|
20
|
-
return { x: point.x, y: point.y };
|
|
21
|
-
};
|
|
22
|
-
this.readPoint = (rawData) => {
|
|
23
|
-
const point = new Point();
|
|
24
|
-
if (rawData) {
|
|
25
|
-
point.x = rawData.x || 0;
|
|
26
|
-
point.y = rawData.y || 0;
|
|
27
|
-
}
|
|
28
|
-
return point;
|
|
29
|
-
};
|
|
30
|
-
this.writeColor = (color) => {
|
|
31
|
-
return { hex: color.hex, alpha: color.alpha };
|
|
32
|
-
};
|
|
33
|
-
this.readColor = (rawData) => {
|
|
34
|
-
const color = new Color();
|
|
35
|
-
if (rawData) {
|
|
36
|
-
color.hex = rawData.hex || 0;
|
|
37
|
-
color.alpha = rawData.alpha || 0;
|
|
38
|
-
}
|
|
39
|
-
return color;
|
|
40
|
-
};
|
|
41
33
|
this._behaviour = behaviour;
|
|
42
34
|
}
|
|
43
35
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BehaviourParser.js","sourceRoot":"","sources":["../../../src/lib/parser/BehaviourParser.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"BehaviourParser.js","sourceRoot":"","sources":["../../../src/lib/parser/BehaviourParser.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAGlC;;;OAGG;IACH,YAAY,SAAc;QAI1B;;;WAGG;QACH,UAAK,GAAG,GAAG,EAAE;YACX,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAA;YAC1D,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAA;YACvC,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;QAED;;;WAGG;QACH,SAAI,GAAG,CAAC,MAAW,EAAE,EAAE;YACrB,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;gBACxB,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,YAAY,MAAM,EAAE;oBAC1C,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAA;iBAClD;qBAAM;oBACL,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;iBACnC;aACF;QACH,CAAC,CAAA;QAzBC,IAAI,CAAC,UAAU,GAAG,SAAS,CAAA;IAC7B,CAAC;CAyBF"}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class that provides helper methods for checking compatibility.
|
|
3
|
+
*/
|
|
1
4
|
export default class CompatibilityHelper {
|
|
5
|
+
/**
|
|
6
|
+
* Reads the duration from the given configuration.
|
|
7
|
+
*
|
|
8
|
+
* @param {Object} config - The configuration object.
|
|
9
|
+
* @return {Number} The duration from the given configuration, or -1 if not found.
|
|
10
|
+
*/
|
|
2
11
|
static readDuration: (config: any) => any;
|
|
3
12
|
}
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class that provides helper methods for checking compatibility.
|
|
3
|
+
*/
|
|
1
4
|
export default class CompatibilityHelper {
|
|
2
5
|
}
|
|
6
|
+
/**
|
|
7
|
+
* Reads the duration from the given configuration.
|
|
8
|
+
*
|
|
9
|
+
* @param {Object} config - The configuration object.
|
|
10
|
+
* @return {Number} The duration from the given configuration, or -1 if not found.
|
|
11
|
+
*/
|
|
3
12
|
CompatibilityHelper.readDuration = (config) => {
|
|
4
13
|
if (config.duration) {
|
|
5
14
|
return config.duration;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompatibilityHelper.js","sourceRoot":"","sources":["../../../src/lib/parser/CompatibilityHelper.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,mBAAmB;;
|
|
1
|
+
{"version":3,"file":"CompatibilityHelper.js","sourceRoot":"","sources":["../../../src/lib/parser/CompatibilityHelper.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;;AACtC;;;;;GAKG;AACI,gCAAY,GAAG,CAAC,MAAW,EAAE,EAAE;IACpC,IAAI,MAAM,CAAC,QAAQ,EAAE;QACnB,OAAO,MAAM,CAAC,QAAQ,CAAA;KACvB;IAED,OAAO,CAAC,CAAC,CAAA;AACX,CAAC,CAAA"}
|
|
@@ -1,6 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmitControllerParser is used to write and read configuration data.
|
|
3
|
+
*
|
|
4
|
+
* @class EmitControllerParser
|
|
5
|
+
*/
|
|
1
6
|
export default class EmitControllerParser {
|
|
2
7
|
private readonly _controller;
|
|
8
|
+
/**
|
|
9
|
+
* The constructor of the class.
|
|
10
|
+
*
|
|
11
|
+
* @constructor
|
|
12
|
+
* @param {any} controller The controller object.
|
|
13
|
+
*/
|
|
3
14
|
constructor(controller: any);
|
|
15
|
+
/**
|
|
16
|
+
* Writes the configuration data to a JSON format.
|
|
17
|
+
*
|
|
18
|
+
* @returns {object} The configuration object.
|
|
19
|
+
*/
|
|
4
20
|
write: () => any;
|
|
21
|
+
/**
|
|
22
|
+
* Reads the configuration data from a JSON format.
|
|
23
|
+
*
|
|
24
|
+
* @param {object} config The configuration object.
|
|
25
|
+
*/
|
|
5
26
|
read: (config: any) => void;
|
|
6
27
|
}
|
|
@@ -1,10 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EmitControllerParser is used to write and read configuration data.
|
|
3
|
+
*
|
|
4
|
+
* @class EmitControllerParser
|
|
5
|
+
*/
|
|
1
6
|
export default class EmitControllerParser {
|
|
7
|
+
/**
|
|
8
|
+
* The constructor of the class.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
* @param {any} controller The controller object.
|
|
12
|
+
*/
|
|
2
13
|
constructor(controller) {
|
|
14
|
+
/**
|
|
15
|
+
* Writes the configuration data to a JSON format.
|
|
16
|
+
*
|
|
17
|
+
* @returns {object} The configuration object.
|
|
18
|
+
*/
|
|
3
19
|
this.write = () => {
|
|
4
20
|
const config = JSON.parse(JSON.stringify(this._controller));
|
|
5
21
|
config.name = this._controller.getName();
|
|
6
22
|
return config;
|
|
7
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Reads the configuration data from a JSON format.
|
|
26
|
+
*
|
|
27
|
+
* @param {object} config The configuration object.
|
|
28
|
+
*/
|
|
8
29
|
this.read = (config) => {
|
|
9
30
|
for (const key in config) {
|
|
10
31
|
if (!(this._controller[key] instanceof Object)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmitControllerParser.js","sourceRoot":"","sources":["../../../src/lib/parser/EmitControllerParser.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,OAAO,oBAAoB;IAGvC,YAAY,UAAe;QAI3B,UAAK,GAAG,GAAG,EAAE;YACX,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;YAC3D,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;YACxC,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;QAED,SAAI,GAAG,CAAC,MAAW,EAAE,EAAE;YACrB,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;gBACxB,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,EAAE;oBAC9C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;iBACpC;aACF;QACH,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"EmitControllerParser.js","sourceRoot":"","sources":["../../../src/lib/parser/EmitControllerParser.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAoB;IAGvC;;;;;OAKG;IACH,YAAY,UAAe;QAI3B;;;;WAIG;QACH,UAAK,GAAG,GAAG,EAAE;YACX,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAA;YAC3D,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAA;YACxC,OAAO,MAAM,CAAA;QACf,CAAC,CAAA;QAED;;;;WAIG;QACH,SAAI,GAAG,CAAC,MAAW,EAAE,EAAE;YACrB,KAAK,MAAM,GAAG,IAAI,MAAM,EAAE;gBACxB,IAAI,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,MAAM,CAAC,EAAE;oBAC9C,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;iBACpC;aACF;QACH,CAAC,CAAA;QAzBC,IAAI,CAAC,WAAW,GAAG,UAAU,CAAA;IAC/B,CAAC;CAyBF"}
|
|
@@ -1,13 +1,66 @@
|
|
|
1
1
|
import { Emitter } from '../emitter';
|
|
2
|
-
import Model from
|
|
2
|
+
import Model from '../Model';
|
|
3
|
+
/**
|
|
4
|
+
* @class EmitterParser
|
|
5
|
+
* @description This class parses an Emitter object
|
|
6
|
+
* @param {Emitter} emitter - the emitter object to be parsed
|
|
7
|
+
*/
|
|
3
8
|
export default class EmitterParser {
|
|
9
|
+
/**
|
|
10
|
+
* @memberof EmitterParser
|
|
11
|
+
* @property {Emitter} emitter - the emitter object to be parsed
|
|
12
|
+
*/
|
|
4
13
|
private readonly emitter;
|
|
14
|
+
/**
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {Emitter} emitter - the emitter object to be parsed
|
|
17
|
+
*/
|
|
5
18
|
constructor(emitter: any);
|
|
19
|
+
/**
|
|
20
|
+
* @function write
|
|
21
|
+
* @description Writes the emitter configuration to a json object
|
|
22
|
+
* @returns {Object} - the emitter configuration
|
|
23
|
+
*/
|
|
6
24
|
write: () => any;
|
|
25
|
+
/**
|
|
26
|
+
* @function read
|
|
27
|
+
* @description Reads the emitter configuration from a json object
|
|
28
|
+
* @param {Object} config - the emitter configuration
|
|
29
|
+
* @param {Model} model - the model to be updated
|
|
30
|
+
* @returns {Emitter} - the emitter
|
|
31
|
+
*/
|
|
7
32
|
read: (config: any, model: Model) => Emitter;
|
|
33
|
+
/**
|
|
34
|
+
* @function update
|
|
35
|
+
* @description Updates the emitter configuration from a json object
|
|
36
|
+
* @param {Object} config - the emitter configuration
|
|
37
|
+
* @param {Model} model - the model to be updated
|
|
38
|
+
* @returns {Emitter} - the emitter
|
|
39
|
+
*/
|
|
8
40
|
update: (config: any, model: Model) => Emitter;
|
|
41
|
+
/**
|
|
42
|
+
* Retrieves an existing behaviour or creates a new behaviour
|
|
43
|
+
* @param {string} name - The name of the behaviour to retreive or create
|
|
44
|
+
* @param {any[]} existingBehaviours - An array of existing behaviours
|
|
45
|
+
* @return {any} The existing behaviour or a new behaviour
|
|
46
|
+
*/
|
|
9
47
|
getExistingOrCreate: (name: string, existingBehaviours: any) => any;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a new behaviour
|
|
50
|
+
* @param {string} name - The name of the behaviour to create
|
|
51
|
+
* @return {any} The new behaviour
|
|
52
|
+
*/
|
|
10
53
|
createBehaviour: (name: string) => any;
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new behaviour properties
|
|
56
|
+
* @param {string} name - The name of the behaviour to create
|
|
57
|
+
* @return {any} The new behaviour properties
|
|
58
|
+
*/
|
|
11
59
|
createBehaviourProps: (name: string) => any;
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new emission controller
|
|
62
|
+
* @param {string} name - The name of the emission controller to create
|
|
63
|
+
* @return {any} The new emission controller
|
|
64
|
+
*/
|
|
12
65
|
createEmitController: (name: string) => any;
|
|
13
66
|
}
|
|
@@ -2,13 +2,27 @@
|
|
|
2
2
|
import CompatibilityHelper from './CompatibilityHelper';
|
|
3
3
|
import * as emissions from '../emission';
|
|
4
4
|
import * as behaviours from '../behaviour';
|
|
5
|
+
/**
|
|
6
|
+
* @class EmitterParser
|
|
7
|
+
* @description This class parses an Emitter object
|
|
8
|
+
* @param {Emitter} emitter - the emitter object to be parsed
|
|
9
|
+
*/
|
|
5
10
|
export default class EmitterParser {
|
|
11
|
+
/**
|
|
12
|
+
* @constructor
|
|
13
|
+
* @param {Emitter} emitter - the emitter object to be parsed
|
|
14
|
+
*/
|
|
6
15
|
constructor(emitter) {
|
|
16
|
+
/**
|
|
17
|
+
* @function write
|
|
18
|
+
* @description Writes the emitter configuration to a json object
|
|
19
|
+
* @returns {Object} - the emitter configuration
|
|
20
|
+
*/
|
|
7
21
|
this.write = () => {
|
|
8
22
|
const config = { behaviours: [] };
|
|
9
|
-
const
|
|
10
|
-
for (let i = 0; i <
|
|
11
|
-
const behaviourConfig =
|
|
23
|
+
const emitterBehaviours = this.emitter.behaviours.getAll();
|
|
24
|
+
for (let i = 0; i < emitterBehaviours.length; i++) {
|
|
25
|
+
const behaviourConfig = emitterBehaviours[i].getParser().write();
|
|
12
26
|
config.behaviours.push(behaviourConfig);
|
|
13
27
|
}
|
|
14
28
|
config.emitController = this.emitter.emitController.getParser().write();
|
|
@@ -27,18 +41,29 @@ export default class EmitterParser {
|
|
|
27
41
|
}
|
|
28
42
|
return config;
|
|
29
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* @function read
|
|
46
|
+
* @description Reads the emitter configuration from a json object
|
|
47
|
+
* @param {Object} config - the emitter configuration
|
|
48
|
+
* @param {Model} model - the model to be updated
|
|
49
|
+
* @returns {Emitter} - the emitter
|
|
50
|
+
*/
|
|
30
51
|
this.read = (config, model) => {
|
|
31
52
|
const behavioursConfig = config.behaviours;
|
|
32
53
|
const existingBehaviours = this.emitter.behaviours.getAll();
|
|
33
|
-
const alwaysCreate = this.emitter.behaviours.isEmpty();
|
|
34
54
|
this.emitter.behaviours.clear();
|
|
35
55
|
for (let i = 0; i < behavioursConfig.length; i++) {
|
|
36
56
|
const name = behavioursConfig[i].name;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
57
|
+
if (!behavioursConfig[i].enabled) {
|
|
58
|
+
this.emitter.behaviours.removeByName(name);
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
const behaviour = this.getExistingOrCreate(name, existingBehaviours);
|
|
62
|
+
behaviour.getParser().read(behavioursConfig[i]);
|
|
63
|
+
this.emitter.behaviours.add(behaviour);
|
|
64
|
+
if (behaviour.name === 'PositionBehaviour') {
|
|
65
|
+
model.update(behaviour);
|
|
66
|
+
}
|
|
42
67
|
}
|
|
43
68
|
}
|
|
44
69
|
this.emitter.emitController = this.createEmitController(config.emitController.name || emissions.EmissionTypes.DEFAULT);
|
|
@@ -58,18 +83,29 @@ export default class EmitterParser {
|
|
|
58
83
|
}
|
|
59
84
|
return this.emitter;
|
|
60
85
|
};
|
|
86
|
+
/**
|
|
87
|
+
* @function update
|
|
88
|
+
* @description Updates the emitter configuration from a json object
|
|
89
|
+
* @param {Object} config - the emitter configuration
|
|
90
|
+
* @param {Model} model - the model to be updated
|
|
91
|
+
* @returns {Emitter} - the emitter
|
|
92
|
+
*/
|
|
61
93
|
this.update = (config, model) => {
|
|
62
94
|
const behavioursConfig = config.behaviours;
|
|
63
95
|
const existingBehaviours = this.emitter.behaviours.getAll();
|
|
64
|
-
const alwaysCreate = this.emitter.behaviours.isEmpty();
|
|
65
96
|
this.emitter.behaviours.clear();
|
|
66
97
|
for (let i = 0; i < behavioursConfig.length; i++) {
|
|
67
98
|
const name = behavioursConfig[i].name;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
99
|
+
if (!behavioursConfig[i].enabled) {
|
|
100
|
+
this.emitter.behaviours.removeByName(name);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
const behaviour = this.getExistingOrCreate(name, existingBehaviours);
|
|
104
|
+
behaviour.getParser().read(behavioursConfig[i]);
|
|
105
|
+
this.emitter.behaviours.add(behaviour);
|
|
106
|
+
if (behaviour.name === 'PositionBehaviour') {
|
|
107
|
+
model.update(behaviour);
|
|
108
|
+
}
|
|
73
109
|
}
|
|
74
110
|
}
|
|
75
111
|
this.emitter.emitController.getParser().read(config.emitController);
|
|
@@ -89,6 +125,12 @@ export default class EmitterParser {
|
|
|
89
125
|
}
|
|
90
126
|
return this.emitter;
|
|
91
127
|
};
|
|
128
|
+
/**
|
|
129
|
+
* Retrieves an existing behaviour or creates a new behaviour
|
|
130
|
+
* @param {string} name - The name of the behaviour to retreive or create
|
|
131
|
+
* @param {any[]} existingBehaviours - An array of existing behaviours
|
|
132
|
+
* @return {any} The existing behaviour or a new behaviour
|
|
133
|
+
*/
|
|
92
134
|
this.getExistingOrCreate = (name, existingBehaviours) => {
|
|
93
135
|
for (let i = 0; i < existingBehaviours.length; i++) {
|
|
94
136
|
if (existingBehaviours[i].getName() === name) {
|
|
@@ -97,14 +139,29 @@ export default class EmitterParser {
|
|
|
97
139
|
}
|
|
98
140
|
return this.createBehaviour(name);
|
|
99
141
|
};
|
|
142
|
+
/**
|
|
143
|
+
* Creates a new behaviour
|
|
144
|
+
* @param {string} name - The name of the behaviour to create
|
|
145
|
+
* @return {any} The new behaviour
|
|
146
|
+
*/
|
|
100
147
|
this.createBehaviour = (name) => {
|
|
101
148
|
// @ts-ignore
|
|
102
149
|
return new behaviours[name]();
|
|
103
150
|
};
|
|
151
|
+
/**
|
|
152
|
+
* Creates a new behaviour properties
|
|
153
|
+
* @param {string} name - The name of the behaviour to create
|
|
154
|
+
* @return {any} The new behaviour properties
|
|
155
|
+
*/
|
|
104
156
|
this.createBehaviourProps = (name) => {
|
|
105
157
|
// @ts-ignore
|
|
106
158
|
return new behaviours[name]().getProps();
|
|
107
159
|
};
|
|
160
|
+
/**
|
|
161
|
+
* Creates a new emission controller
|
|
162
|
+
* @param {string} name - The name of the emission controller to create
|
|
163
|
+
* @return {any} The new emission controller
|
|
164
|
+
*/
|
|
108
165
|
this.createEmitController = (name) => {
|
|
109
166
|
// @ts-ignore
|
|
110
167
|
return new emissions[name]();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmitterParser.js","sourceRoot":"","sources":["../../../src/lib/parser/EmitterParser.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAA;AAI1C,MAAM,CAAC,OAAO,OAAO,aAAa;
|
|
1
|
+
{"version":3,"file":"EmitterParser.js","sourceRoot":"","sources":["../../../src/lib/parser/EmitterParser.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,OAAO,mBAAmB,MAAM,uBAAuB,CAAA;AACvD,OAAO,KAAK,SAAS,MAAM,aAAa,CAAA;AACxC,OAAO,KAAK,UAAU,MAAM,cAAc,CAAA;AAI1C;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAOhC;;;OAGG;IACH,YAAY,OAAY;QAIxB;;;;WAIG;QACH,UAAK,GAAG,GAAG,EAAE;YACX,MAAM,MAAM,GAAQ,EAAE,UAAU,EAAE,EAAE,EAAE,CAAA;YACtC,MAAM,iBAAiB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAA;YAE1D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,iBAAiB,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;gBACjD,MAAM,eAAe,GAA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AAC,CAAA;QAED;;;;WAIG;QACH,oBAAe,GAAG,CAAC,IAAY,EAAE,EAAE;YACjC,aAAa;YACb,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAA;QAC/B,CAAC,CAAA;QAED;;;;WAIG;QACH,yBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE;YACtC,aAAa;YACb,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAA;QAC1C,CAAC,CAAA;QAED;;;;WAIG;QACH,yBAAoB,GAAG,CAAC,IAAY,EAAE,EAAE;YACtC,aAAa;YACb,OAAO,IAAI,SAAS,CAAC,IAAI,CAAC,EAAE,CAAA;QAC9B,CAAC,CAAA;QA5KC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;CA4KF"}
|
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { Emitter } from '../emitter';
|
|
2
2
|
import { ICustomPixiParticlesSettings } from '../customPixiParticlesSettingsInterface';
|
|
3
3
|
import { ParticleContainer } from 'pixi.js-legacy';
|
|
4
|
+
/**
|
|
5
|
+
* Renderer is a class used to render particles in the Pixi library.
|
|
6
|
+
*
|
|
7
|
+
* @class Renderer
|
|
8
|
+
*/
|
|
4
9
|
export default class Renderer extends ParticleContainer {
|
|
5
10
|
blendMode: any;
|
|
6
11
|
emitter: Emitter;
|
|
@@ -21,21 +26,71 @@ export default class Renderer extends ParticleContainer {
|
|
|
21
26
|
private config;
|
|
22
27
|
private anchor;
|
|
23
28
|
private _model;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of Renderer.
|
|
31
|
+
*
|
|
32
|
+
* @memberof Renderer
|
|
33
|
+
*/
|
|
24
34
|
constructor(settings: ICustomPixiParticlesSettings);
|
|
35
|
+
/**
|
|
36
|
+
* Sets the paused state of the object.
|
|
37
|
+
* @param {boolean} isPaused - The new paused state of the object.
|
|
38
|
+
* @return {void}
|
|
39
|
+
*/
|
|
25
40
|
pause(isPaused: boolean): void;
|
|
41
|
+
/**
|
|
42
|
+
* Updates the transform of the ParticleContainer and updates the emitters.
|
|
43
|
+
*/
|
|
26
44
|
updateTransform(): void;
|
|
45
|
+
/**
|
|
46
|
+
*
|
|
47
|
+
* @method updateTexture
|
|
48
|
+
* @description This method updates the texture of the unused sprites and children to a randomly generated texture.
|
|
49
|
+
*/
|
|
27
50
|
updateTexture(): void;
|
|
51
|
+
/**
|
|
52
|
+
* This method is used to start the emitter and turbulenceEmitter if available.
|
|
53
|
+
* @function start
|
|
54
|
+
*/
|
|
28
55
|
start(): void;
|
|
56
|
+
/**
|
|
57
|
+
* Resets the particle emitters in this class without removing existing particles and plays them.
|
|
58
|
+
* @function play
|
|
59
|
+
*/
|
|
29
60
|
play(): void;
|
|
61
|
+
/**
|
|
62
|
+
* Immediately stops emitting particles
|
|
63
|
+
*/
|
|
30
64
|
stopImmediately(): void;
|
|
65
|
+
/**
|
|
66
|
+
* Terminates the emitter and any turbulence emitter it is associated with
|
|
67
|
+
*/
|
|
31
68
|
stop(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Resets the emitters to their initial state
|
|
71
|
+
*/
|
|
32
72
|
resetEmitter(): void;
|
|
73
|
+
/**
|
|
74
|
+
* Sets the textures used by the emitter
|
|
75
|
+
* @param {string[]} textures - Array of strings containing the textures to be used by the emitter
|
|
76
|
+
*/
|
|
33
77
|
setTextures(textures: string[]): void;
|
|
78
|
+
/**
|
|
79
|
+
* Updates the configuration of the emitter
|
|
80
|
+
* @param {any} config - Configuration object to be used to update the emitter
|
|
81
|
+
*/
|
|
34
82
|
updateConfig(config: any): void;
|
|
83
|
+
/**
|
|
84
|
+
* Updates the position of the emitter
|
|
85
|
+
* @param {Object} position - Object containing the x and y coordinates of the new position
|
|
86
|
+
*/
|
|
35
87
|
updatePosition(position: {
|
|
36
88
|
x: number;
|
|
37
89
|
y: number;
|
|
38
90
|
}): void;
|
|
91
|
+
/**
|
|
92
|
+
* Clears the sprite pool, the unused sprites list and the turbulence and particle pools.
|
|
93
|
+
*/
|
|
39
94
|
clearPool(): void;
|
|
40
95
|
private getByName;
|
|
41
96
|
private getOrCreateSprite;
|
|
@@ -7,7 +7,17 @@ import List from '../util/List';
|
|
|
7
7
|
import ParticlePool from '../ParticlePool';
|
|
8
8
|
import { AnimatedSprite, Loader, ParticleContainer, Sprite, Texture } from 'pixi.js-legacy';
|
|
9
9
|
import Model from "../Model";
|
|
10
|
+
/**
|
|
11
|
+
* Renderer is a class used to render particles in the Pixi library.
|
|
12
|
+
*
|
|
13
|
+
* @class Renderer
|
|
14
|
+
*/
|
|
10
15
|
export default class Renderer extends ParticleContainer {
|
|
16
|
+
/**
|
|
17
|
+
* Creates an instance of Renderer.
|
|
18
|
+
*
|
|
19
|
+
* @memberof Renderer
|
|
20
|
+
*/
|
|
11
21
|
constructor(settings) {
|
|
12
22
|
super(100000, {
|
|
13
23
|
vertices: true,
|
|
@@ -79,9 +89,17 @@ export default class Renderer extends ParticleContainer {
|
|
|
79
89
|
}
|
|
80
90
|
document.addEventListener('visibilitychange', () => this.internalPause(document.hidden));
|
|
81
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Sets the paused state of the object.
|
|
94
|
+
* @param {boolean} isPaused - The new paused state of the object.
|
|
95
|
+
* @return {void}
|
|
96
|
+
*/
|
|
82
97
|
pause(isPaused) {
|
|
83
98
|
this.paused(isPaused);
|
|
84
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Updates the transform of the ParticleContainer and updates the emitters.
|
|
102
|
+
*/
|
|
85
103
|
updateTransform() {
|
|
86
104
|
if (this._paused)
|
|
87
105
|
return;
|
|
@@ -96,6 +114,11 @@ export default class Renderer extends ParticleContainer {
|
|
|
96
114
|
ParticleContainer.prototype.updateTransform.call(this);
|
|
97
115
|
this.lastTime = this.currentTime;
|
|
98
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
*
|
|
119
|
+
* @method updateTexture
|
|
120
|
+
* @description This method updates the texture of the unused sprites and children to a randomly generated texture.
|
|
121
|
+
*/
|
|
99
122
|
updateTexture() {
|
|
100
123
|
for (let i = 0; i < this.unusedSprites.length; ++i) {
|
|
101
124
|
this.unusedSprites[i].texture = Texture.from(this.getRandomTexture());
|
|
@@ -105,18 +128,29 @@ export default class Renderer extends ParticleContainer {
|
|
|
105
128
|
this.children[i].texture = Texture.from(this.getRandomTexture());
|
|
106
129
|
}
|
|
107
130
|
}
|
|
131
|
+
/**
|
|
132
|
+
* This method is used to start the emitter and turbulenceEmitter if available.
|
|
133
|
+
* @function start
|
|
134
|
+
*/
|
|
108
135
|
start() {
|
|
109
136
|
this.emitter.resetAndPlay();
|
|
110
137
|
if (this.turbulenceEmitter) {
|
|
111
138
|
this.turbulenceEmitter.resetAndPlay();
|
|
112
139
|
}
|
|
113
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Resets the particle emitters in this class without removing existing particles and plays them.
|
|
143
|
+
* @function play
|
|
144
|
+
*/
|
|
114
145
|
play() {
|
|
115
146
|
this.emitter.resetWithoutRemovingAndPlay();
|
|
116
147
|
if (this.turbulenceEmitter) {
|
|
117
148
|
this.turbulenceEmitter.resetWithoutRemovingAndPlay();
|
|
118
149
|
}
|
|
119
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Immediately stops emitting particles
|
|
153
|
+
*/
|
|
120
154
|
stopImmediately() {
|
|
121
155
|
this.emitter.stop();
|
|
122
156
|
if (this.turbulenceEmitter) {
|
|
@@ -124,22 +158,36 @@ export default class Renderer extends ParticleContainer {
|
|
|
124
158
|
}
|
|
125
159
|
this.emitter.emit(Emitter.COMPLETE);
|
|
126
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Terminates the emitter and any turbulence emitter it is associated with
|
|
163
|
+
*/
|
|
127
164
|
stop() {
|
|
128
165
|
this.emitter.stopWithoutKilling();
|
|
129
166
|
if (this.turbulenceEmitter) {
|
|
130
167
|
this.turbulenceEmitter.stop();
|
|
131
168
|
}
|
|
132
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Resets the emitters to their initial state
|
|
172
|
+
*/
|
|
133
173
|
resetEmitter() {
|
|
134
174
|
this.emitter.reset();
|
|
135
175
|
if (this.turbulenceEmitter) {
|
|
136
176
|
this.turbulenceEmitter.reset();
|
|
137
177
|
}
|
|
138
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Sets the textures used by the emitter
|
|
181
|
+
* @param {string[]} textures - Array of strings containing the textures to be used by the emitter
|
|
182
|
+
*/
|
|
139
183
|
setTextures(textures) {
|
|
140
184
|
this.textures = textures;
|
|
141
185
|
this.updateTexture();
|
|
142
186
|
}
|
|
187
|
+
/**
|
|
188
|
+
* Updates the configuration of the emitter
|
|
189
|
+
* @param {any} config - Configuration object to be used to update the emitter
|
|
190
|
+
*/
|
|
143
191
|
updateConfig(config) {
|
|
144
192
|
this.emitterParser.update(config, this._model);
|
|
145
193
|
if (this.turbulenceEmitter) {
|
|
@@ -152,12 +200,19 @@ export default class Renderer extends ParticleContainer {
|
|
|
152
200
|
}
|
|
153
201
|
}
|
|
154
202
|
}
|
|
203
|
+
/**
|
|
204
|
+
* Updates the position of the emitter
|
|
205
|
+
* @param {Object} position - Object containing the x and y coordinates of the new position
|
|
206
|
+
*/
|
|
155
207
|
updatePosition(position) {
|
|
156
208
|
const positionBehaviour = this.getByName(BehaviourNames.POSITION_BEHAVIOUR);
|
|
157
209
|
positionBehaviour.position.x = position.x;
|
|
158
210
|
positionBehaviour.position.y = position.y;
|
|
159
211
|
this.emitterParser.update(this.config, this._model);
|
|
160
212
|
}
|
|
213
|
+
/**
|
|
214
|
+
* Clears the sprite pool, the unused sprites list and the turbulence and particle pools.
|
|
215
|
+
*/
|
|
161
216
|
clearPool() {
|
|
162
217
|
this.removeChildren();
|
|
163
218
|
this.unusedSprites = [];
|