custom-pixi-particles 4.0.20 → 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 +34 -1
- package/dist/lib/behaviour/PositionBehaviour.js +70 -28
- 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,7 +1,33 @@
|
|
|
1
1
|
import BehaviourParser from '../parser/BehaviourParser';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a new Behaviour
|
|
4
|
+
*
|
|
5
|
+
* @class
|
|
6
|
+
*/
|
|
2
7
|
export default class Behaviour {
|
|
8
|
+
/**
|
|
9
|
+
* A protected property used to store the priority of the behaviour
|
|
10
|
+
*
|
|
11
|
+
* @protected
|
|
12
|
+
*/
|
|
3
13
|
protected priority: number;
|
|
14
|
+
/**
|
|
15
|
+
* Calculates the variance from a given value
|
|
16
|
+
*
|
|
17
|
+
* @param {number} value - a given value
|
|
18
|
+
* @returns {number} the variance based on the given value
|
|
19
|
+
*/
|
|
4
20
|
varianceFrom: (value: number) => number;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the name of the behaviour
|
|
23
|
+
*
|
|
24
|
+
* @returns {string} The name of the behaviour
|
|
25
|
+
*/
|
|
5
26
|
getName(): void;
|
|
27
|
+
/**
|
|
28
|
+
* Gets the parser for the behaviour
|
|
29
|
+
*
|
|
30
|
+
* @returns {BehaviourParser} The parser for the behaviour
|
|
31
|
+
*/
|
|
6
32
|
getParser: () => BehaviourParser;
|
|
7
33
|
}
|
|
@@ -1,17 +1,43 @@
|
|
|
1
1
|
import BehaviourParser from '../parser/BehaviourParser';
|
|
2
2
|
import { Random } from '../util';
|
|
3
|
+
/**
|
|
4
|
+
* Creates a new Behaviour
|
|
5
|
+
*
|
|
6
|
+
* @class
|
|
7
|
+
*/
|
|
3
8
|
export default class Behaviour {
|
|
4
9
|
constructor() {
|
|
10
|
+
/**
|
|
11
|
+
* A protected property used to store the priority of the behaviour
|
|
12
|
+
*
|
|
13
|
+
* @protected
|
|
14
|
+
*/
|
|
5
15
|
this.priority = 0;
|
|
16
|
+
/**
|
|
17
|
+
* Calculates the variance from a given value
|
|
18
|
+
*
|
|
19
|
+
* @param {number} value - a given value
|
|
20
|
+
* @returns {number} the variance based on the given value
|
|
21
|
+
*/
|
|
6
22
|
this.varianceFrom = (value) => {
|
|
7
23
|
if (value === 0)
|
|
8
24
|
return 0;
|
|
9
25
|
return Random.uniform(-1.0, 1.0) * value;
|
|
10
26
|
};
|
|
27
|
+
/**
|
|
28
|
+
* Gets the parser for the behaviour
|
|
29
|
+
*
|
|
30
|
+
* @returns {BehaviourParser} The parser for the behaviour
|
|
31
|
+
*/
|
|
11
32
|
this.getParser = () => {
|
|
12
33
|
return new BehaviourParser(this);
|
|
13
34
|
};
|
|
14
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Gets the name of the behaviour
|
|
38
|
+
*
|
|
39
|
+
* @returns {string} The name of the behaviour
|
|
40
|
+
*/
|
|
15
41
|
getName() {
|
|
16
42
|
throw new Error('This method has to be overridden in subclass');
|
|
17
43
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Behaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/Behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC,MAAM,CAAC,OAAO,OAAO,SAAS;IAA9B;
|
|
1
|
+
{"version":3,"file":"Behaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/Behaviour.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,MAAM,2BAA2B,CAAA;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAEhC;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,SAAS;IAA9B;QACE;;;;WAIG;QACO,aAAQ,GAAG,CAAC,CAAA;QAEtB;;;;;WAKG;QACH,iBAAY,GAAG,CAAC,KAAa,EAAE,EAAE;YAC/B,IAAI,KAAK,KAAK,CAAC;gBAAE,OAAO,CAAC,CAAA;YACzB,OAAO,MAAM,CAAC,OAAO,CAAC,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,KAAK,CAAA;QAC1C,CAAC,CAAA;QAWD;;;;WAIG;QACH,cAAS,GAAG,GAAG,EAAE;YACf,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAA;QAClC,CAAC,CAAA;IACH,CAAC;IAjBC;;;;OAIG;IACH,OAAO;QACL,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAA;IACjE,CAAC;CAUF"}
|
|
@@ -10,7 +10,7 @@ export default class ColorBehaviour extends Behaviour {
|
|
|
10
10
|
endVariance: Color;
|
|
11
11
|
sinus: boolean;
|
|
12
12
|
init: (particle: Particle) => void;
|
|
13
|
-
apply: (particle: Particle
|
|
13
|
+
apply: (particle: Particle) => void;
|
|
14
14
|
getName(): string;
|
|
15
15
|
getProps(): {
|
|
16
16
|
enabled: boolean;
|
|
@@ -12,8 +12,6 @@ export default class ColorBehaviour extends Behaviour {
|
|
|
12
12
|
this.endVariance = new Color(0, 0, 0, 0);
|
|
13
13
|
this.sinus = false;
|
|
14
14
|
this.init = (particle) => {
|
|
15
|
-
if (!this.enabled)
|
|
16
|
-
return;
|
|
17
15
|
particle.colorStart.copyFrom(this.start);
|
|
18
16
|
particle.colorStart.r += this.varianceFrom(this.startVariance.r);
|
|
19
17
|
particle.colorStart.g += this.varianceFrom(this.startVariance.g);
|
|
@@ -26,18 +24,17 @@ export default class ColorBehaviour extends Behaviour {
|
|
|
26
24
|
particle.colorEnd.alpha += this.varianceFrom(this.endVariance.alpha);
|
|
27
25
|
particle.color.copyFrom(particle.colorStart);
|
|
28
26
|
};
|
|
29
|
-
this.apply = (particle
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
particle.color.
|
|
33
|
-
particle.color.
|
|
34
|
-
particle.color.
|
|
35
|
-
particle.color.b += (particle.colorEnd.b - particle.colorStart.b) * particle.lifeProgress;
|
|
27
|
+
this.apply = (particle) => {
|
|
28
|
+
const { colorStart, lifeProgress, colorEnd } = particle;
|
|
29
|
+
particle.color.copyFrom(colorStart);
|
|
30
|
+
particle.color.r += (colorEnd.r - colorStart.r) * lifeProgress;
|
|
31
|
+
particle.color.g += (colorEnd.g - colorStart.g) * lifeProgress;
|
|
32
|
+
particle.color.b += (colorEnd.b - colorStart.b) * lifeProgress;
|
|
36
33
|
if (!this.sinus) {
|
|
37
|
-
particle.color.alpha += (
|
|
34
|
+
particle.color.alpha += (colorEnd.alpha - colorStart.alpha) * lifeProgress;
|
|
38
35
|
}
|
|
39
36
|
else {
|
|
40
|
-
particle.color.alpha = Math.sin(
|
|
37
|
+
particle.color.alpha = Math.sin(lifeProgress * 3.1);
|
|
41
38
|
}
|
|
42
39
|
};
|
|
43
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColorBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/ColorBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAA;AAC/B,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,cAA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AAE,IAAI,CAAC,KAAK,CAAC,KAAK;aACzB;YACD,aAAa,EAAE;gBACb,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAChB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAChB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAChB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;aACzB;YACD,WAAW,EAAE;gBACX,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAChB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAChB,EAAE,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;gBAChB,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK;aACzB;YACD,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,17 +1,41 @@
|
|
|
1
1
|
import Behaviour from './Behaviour';
|
|
2
2
|
import Particle from '../Particle';
|
|
3
|
+
/**
|
|
4
|
+
* The EmitDirectionBehaviour class that inherits from the Behaviour class.
|
|
5
|
+
* This class is used to set the direction of a particle when it is emitted.
|
|
6
|
+
* @export
|
|
7
|
+
* @class EmitDirectionBehaviour
|
|
8
|
+
* @extends {Behaviour}
|
|
9
|
+
*/
|
|
3
10
|
export default class EmitDirectionBehaviour extends Behaviour {
|
|
4
11
|
enabled: boolean;
|
|
5
12
|
priority: number;
|
|
6
13
|
angle: number;
|
|
7
14
|
variance: number;
|
|
15
|
+
/**
|
|
16
|
+
* Initializes the particle's direction.
|
|
17
|
+
* @param {Particle} particle - The particle that is being initialized.
|
|
18
|
+
* @memberof EmitDirectionBehaviour
|
|
19
|
+
*/
|
|
8
20
|
init: (particle: Particle) => void;
|
|
9
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Applies the behavior to the particle.
|
|
23
|
+
* @param {Particle} particle - The particle to which the behavior is being applied.
|
|
24
|
+
* @param {number} deltaTime - The amount of time since the behavior was last applied.
|
|
25
|
+
* @memberof EmitDirectionBehaviour
|
|
26
|
+
*/
|
|
27
|
+
apply: (particle: Particle) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Gets the name of the behavior.
|
|
30
|
+
* @returns {BehaviourNames.EMIT_DIRECTION}
|
|
31
|
+
* @memberof EmitDirectionBehaviour
|
|
32
|
+
*/
|
|
10
33
|
getName(): string;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Gets the properties of the behavior.
|
|
36
|
+
* @returns {object} - The properties of the behavior.
|
|
37
|
+
* @memberof EmitDirectionBehaviour
|
|
38
|
+
*/
|
|
15
39
|
getProps(): {
|
|
16
40
|
enabled: boolean;
|
|
17
41
|
priority: number;
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import Behaviour from './Behaviour';
|
|
2
2
|
import BehaviourNames from './BehaviourNames';
|
|
3
|
-
import math from '../util/maths';
|
|
4
3
|
let _tmp = 0;
|
|
4
|
+
/**
|
|
5
|
+
* The EmitDirectionBehaviour class that inherits from the Behaviour class.
|
|
6
|
+
* This class is used to set the direction of a particle when it is emitted.
|
|
7
|
+
* @export
|
|
8
|
+
* @class EmitDirectionBehaviour
|
|
9
|
+
* @extends {Behaviour}
|
|
10
|
+
*/
|
|
5
11
|
export default class EmitDirectionBehaviour extends Behaviour {
|
|
6
12
|
constructor() {
|
|
7
13
|
super(...arguments);
|
|
@@ -9,36 +15,42 @@ export default class EmitDirectionBehaviour extends Behaviour {
|
|
|
9
15
|
this.priority = 0;
|
|
10
16
|
this.angle = 0;
|
|
11
17
|
this.variance = 0;
|
|
18
|
+
/**
|
|
19
|
+
* Initializes the particle's direction.
|
|
20
|
+
* @param {Particle} particle - The particle that is being initialized.
|
|
21
|
+
* @memberof EmitDirectionBehaviour
|
|
22
|
+
*/
|
|
12
23
|
this.init = (particle) => {
|
|
13
|
-
if (!this.enabled)
|
|
14
|
-
return;
|
|
15
24
|
const directionAngle = this.angle + this.varianceFrom(this.variance);
|
|
16
25
|
particle.directionCos = Math.cos(directionAngle);
|
|
17
26
|
particle.directionSin = Math.sin(directionAngle);
|
|
18
27
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Applies the behavior to the particle.
|
|
30
|
+
* @param {Particle} particle - The particle to which the behavior is being applied.
|
|
31
|
+
* @param {number} deltaTime - The amount of time since the behavior was last applied.
|
|
32
|
+
* @memberof EmitDirectionBehaviour
|
|
33
|
+
*/
|
|
34
|
+
this.apply = (particle) => {
|
|
35
|
+
const { x, y, directionSin, directionCos } = particle;
|
|
36
|
+
_tmp = directionCos * x - directionSin * y;
|
|
37
|
+
particle.y = directionSin * x + directionCos * y;
|
|
24
38
|
particle.x = _tmp;
|
|
25
39
|
};
|
|
26
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Gets the name of the behavior.
|
|
43
|
+
* @returns {BehaviourNames.EMIT_DIRECTION}
|
|
44
|
+
* @memberof EmitDirectionBehaviour
|
|
45
|
+
*/
|
|
27
46
|
getName() {
|
|
28
47
|
return BehaviourNames.EMIT_DIRECTION;
|
|
29
48
|
}
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
get varianceInDegrees() {
|
|
37
|
-
return math.radiansToDegrees(this.variance);
|
|
38
|
-
}
|
|
39
|
-
set varianceInDegrees(value) {
|
|
40
|
-
this.variance = math.degreesToRadians(value);
|
|
41
|
-
}
|
|
49
|
+
/**
|
|
50
|
+
* Gets the properties of the behavior.
|
|
51
|
+
* @returns {object} - The properties of the behavior.
|
|
52
|
+
* @memberof EmitDirectionBehaviour
|
|
53
|
+
*/
|
|
42
54
|
getProps() {
|
|
43
55
|
return {
|
|
44
56
|
enabled: this.enabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmitDirectionBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/EmitDirectionBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,cAAc,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"EmitDirectionBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/EmitDirectionBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,aAAa,CAAA;AACnC,OAAO,cAAc,MAAM,kBAAkB,CAAA;AAG7C,IAAI,IAAI,GAAG,CAAC,CAAA;AAEZ;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,sBAAuB,SAAQ,SAAS;IAA7D;;QACE,YAAO,GAAG,IAAI,CAAA;QACd,aAAQ,GAAG,CAAC,CAAA;QACZ,UAAK,GAAG,CAAC,CAAA;QACT,aAAQ,GAAG,CAAC,CAAA;QAEZ;;;;WAIG;QACH,SAAI,GAAG,CAAC,QAAkB,EAAE,EAAE;YAC5B,MAAM,cAAc,GAAG,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;YACpE,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;YAChD,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,CAAA;QAClD,CAAC,CAAA;QAED;;;;;WAKG;QACH,UAAK,GAAG,CAAC,QAAkB,EAAE,EAAE;YAC7B,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,YAAY,EAAE,YAAY,EAAE,GAAG,QAAQ,CAAA;YAErD,IAAI,GAAG,YAAY,GAAG,CAAC,GAAG,YAAY,GAAG,CAAC,CAAA;YAC1C,QAAQ,CAAC,CAAC,GAAG,YAAY,GAAG,CAAC,GAAG,YAAY,GAAG,CAAC,CAAA;YAChD,QAAQ,CAAC,CAAC,GAAG,IAAI,CAAA;QACnB,CAAC,CAAA;IAyBH,CAAC;IAvBC;;;;OAIG;IACH,OAAO;QACL,OAAO,cAAc,CAAC,cAAc,CAAA;IACtC,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,13 +1,55 @@
|
|
|
1
1
|
import Particle from '../Particle';
|
|
2
|
-
import Model from
|
|
2
|
+
import Model from '../Model';
|
|
3
|
+
/**
|
|
4
|
+
* EmitterBehaviours class manages the behaviour of particles
|
|
5
|
+
*/
|
|
3
6
|
export default class EmitterBehaviours {
|
|
4
7
|
behaviours: any;
|
|
8
|
+
/**
|
|
9
|
+
* Gets all the enabled behaviours
|
|
10
|
+
*
|
|
11
|
+
* @return {any[]} The enabled behaviours
|
|
12
|
+
*/
|
|
5
13
|
getAll: () => any;
|
|
6
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Clears all the stored behaviours
|
|
16
|
+
*/
|
|
7
17
|
clear: () => void;
|
|
18
|
+
/**
|
|
19
|
+
* Adds a behaviour
|
|
20
|
+
*
|
|
21
|
+
* @param {any} behaviour The behaviour to add
|
|
22
|
+
*
|
|
23
|
+
* @return {any} The added behaviour
|
|
24
|
+
*/
|
|
8
25
|
add: (behaviour: any) => any;
|
|
26
|
+
/**
|
|
27
|
+
* Gets a behaviour by name
|
|
28
|
+
*
|
|
29
|
+
* @param {string} name The name of the behaviour to get
|
|
30
|
+
*
|
|
31
|
+
* @return {any | null} The behaviour with the given name or null if not found
|
|
32
|
+
*/
|
|
9
33
|
getByName: (name: string) => any;
|
|
34
|
+
/**
|
|
35
|
+
* Removes a behaviour by name
|
|
36
|
+
*
|
|
37
|
+
* @param {string} name The name of the behaviour to remove
|
|
38
|
+
*/
|
|
10
39
|
removeByName: (name: string) => void;
|
|
40
|
+
/**
|
|
41
|
+
* Initialises the behaviours
|
|
42
|
+
*
|
|
43
|
+
* @param {Particle} particle The particle
|
|
44
|
+
* @param {Model} model The model
|
|
45
|
+
*/
|
|
11
46
|
init: (particle: Particle, model: Model) => void;
|
|
47
|
+
/**
|
|
48
|
+
* Applies the behaviours
|
|
49
|
+
*
|
|
50
|
+
* @param {Particle} particle The particle
|
|
51
|
+
* @param {number} deltaTime The delta time
|
|
52
|
+
* @param {Model} model The model
|
|
53
|
+
*/
|
|
12
54
|
apply: (particle: Particle, deltaTime: number, model: Model) => void;
|
|
13
55
|
}
|
|
@@ -1,18 +1,33 @@
|
|
|
1
1
|
// tslint:disable:prefer-for-of
|
|
2
|
+
/**
|
|
3
|
+
* EmitterBehaviours class manages the behaviour of particles
|
|
4
|
+
*/
|
|
2
5
|
export default class EmitterBehaviours {
|
|
3
6
|
constructor() {
|
|
4
7
|
this.behaviours = [];
|
|
8
|
+
/**
|
|
9
|
+
* Gets all the enabled behaviours
|
|
10
|
+
*
|
|
11
|
+
* @return {any[]} The enabled behaviours
|
|
12
|
+
*/
|
|
5
13
|
this.getAll = () => {
|
|
6
14
|
return this.behaviours.filter((behaviour) => {
|
|
7
15
|
return behaviour.enabled;
|
|
8
16
|
});
|
|
9
17
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Clears all the stored behaviours
|
|
20
|
+
*/
|
|
13
21
|
this.clear = () => {
|
|
14
22
|
this.behaviours = [];
|
|
15
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Adds a behaviour
|
|
26
|
+
*
|
|
27
|
+
* @param {any} behaviour The behaviour to add
|
|
28
|
+
*
|
|
29
|
+
* @return {any} The added behaviour
|
|
30
|
+
*/
|
|
16
31
|
this.add = (behaviour) => {
|
|
17
32
|
if (this.getByName(behaviour.getName()) !== null) {
|
|
18
33
|
throw new Error('Emitter duplicate');
|
|
@@ -23,6 +38,13 @@ export default class EmitterBehaviours {
|
|
|
23
38
|
});
|
|
24
39
|
return behaviour;
|
|
25
40
|
};
|
|
41
|
+
/**
|
|
42
|
+
* Gets a behaviour by name
|
|
43
|
+
*
|
|
44
|
+
* @param {string} name The name of the behaviour to get
|
|
45
|
+
*
|
|
46
|
+
* @return {any | null} The behaviour with the given name or null if not found
|
|
47
|
+
*/
|
|
26
48
|
this.getByName = (name) => {
|
|
27
49
|
for (let i = 0; i < this.behaviours.length; ++i) {
|
|
28
50
|
if (this.behaviours[i].getName() === name) {
|
|
@@ -31,6 +53,11 @@ export default class EmitterBehaviours {
|
|
|
31
53
|
}
|
|
32
54
|
return null;
|
|
33
55
|
};
|
|
56
|
+
/**
|
|
57
|
+
* Removes a behaviour by name
|
|
58
|
+
*
|
|
59
|
+
* @param {string} name The name of the behaviour to remove
|
|
60
|
+
*/
|
|
34
61
|
this.removeByName = (name) => {
|
|
35
62
|
const behaviours = [];
|
|
36
63
|
for (let i = 0; i < this.behaviours.length; ++i) {
|
|
@@ -40,11 +67,24 @@ export default class EmitterBehaviours {
|
|
|
40
67
|
}
|
|
41
68
|
this.behaviours = behaviours;
|
|
42
69
|
};
|
|
70
|
+
/**
|
|
71
|
+
* Initialises the behaviours
|
|
72
|
+
*
|
|
73
|
+
* @param {Particle} particle The particle
|
|
74
|
+
* @param {Model} model The model
|
|
75
|
+
*/
|
|
43
76
|
this.init = (particle, model) => {
|
|
44
77
|
for (let i = 0; i < this.behaviours.length; ++i) {
|
|
45
78
|
this.behaviours[i].init(particle, model);
|
|
46
79
|
}
|
|
47
80
|
};
|
|
81
|
+
/**
|
|
82
|
+
* Applies the behaviours
|
|
83
|
+
*
|
|
84
|
+
* @param {Particle} particle The particle
|
|
85
|
+
* @param {number} deltaTime The delta time
|
|
86
|
+
* @param {Model} model The model
|
|
87
|
+
*/
|
|
48
88
|
this.apply = (particle, deltaTime, model) => {
|
|
49
89
|
for (let i = 0; i < this.behaviours.length; ++i) {
|
|
50
90
|
model.updateCamera(deltaTime);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmitterBehaviours.js","sourceRoot":"","sources":["../../../src/lib/behaviour/EmitterBehaviours.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAK/B,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAAtC;QACE,eAAU,GAAQ,EAAE,CAAA;QAEpB,WAAM,GAAG,GAAG,EAAE;YACZ,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,SAAc,EAAE,EAAE;gBAC/C,OAAO,SAAS,CAAC,OAAO,CAAA;YAC1B,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;QAED
|
|
1
|
+
{"version":3,"file":"EmitterBehaviours.js","sourceRoot":"","sources":["../../../src/lib/behaviour/EmitterBehaviours.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAK/B;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAiB;IAAtC;QACE,eAAU,GAAQ,EAAE,CAAA;QAEpB;;;;WAIG;QACH,WAAM,GAAG,GAAG,EAAE;YACZ,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,SAAc,EAAE,EAAE;gBAC/C,OAAO,SAAS,CAAC,OAAO,CAAA;YAC1B,CAAC,CAAC,CAAA;QACJ,CAAC,CAAA;QAED;;WAEG;QACH,UAAK,GAAG,GAAG,EAAE;YACX,IAAI,CAAC,UAAU,GAAG,EAAE,CAAA;QACtB,CAAC,CAAA;QAED;;;;;;WAMG;QACH,QAAG,GAAG,CAAC,SAAc,EAAE,EAAE;YACvB,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC,KAAK,IAAI,EAAE;gBAChD,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;aACrC;YAED,IAAI,CAAC,UAAU,C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C,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAA;aACzC;QACH,CAAC,CAAA;QAED;;;;;;WAMG;QACH,UAAK,GAAG,CAAC,QAAkB,EAAE,SAAiB,EAAE,KAAY,EAAE,EAAE;YAC9D,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE;gBAC/C,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAA;gBAC7B,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;aACrD;QACH,CAAC,CAAA;IACH,CAAC;CAAA"}
|
|
@@ -1,13 +1,62 @@
|
|
|
1
1
|
import { Behaviour } from './index';
|
|
2
2
|
import Particle from '../Particle';
|
|
3
|
+
/**
|
|
4
|
+
* This class is responsible for managing the lifetimes of particles.
|
|
5
|
+
* It sets the maximum lifetime of the particle and updates its progress.
|
|
6
|
+
*
|
|
7
|
+
* @extends Behaviour
|
|
8
|
+
*/
|
|
3
9
|
export default class LifeBehaviour extends Behaviour {
|
|
10
|
+
/**
|
|
11
|
+
* Whether or not this behaviour is enabled.
|
|
12
|
+
*
|
|
13
|
+
* @type {boolean}
|
|
14
|
+
*/
|
|
4
15
|
enabled: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* The priority of this behaviour.
|
|
18
|
+
*
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
5
21
|
priority: number;
|
|
22
|
+
/**
|
|
23
|
+
* The maximum life time of the particle that this behaviour will set.
|
|
24
|
+
*
|
|
25
|
+
* @type {number}
|
|
26
|
+
*/
|
|
6
27
|
maxLifeTime: number;
|
|
28
|
+
/**
|
|
29
|
+
* The variance of the particle's life time.
|
|
30
|
+
*
|
|
31
|
+
* @type {number}
|
|
32
|
+
*/
|
|
7
33
|
timeVariance: number;
|
|
34
|
+
/**
|
|
35
|
+
* Sets the particle's life time and maximum life time.
|
|
36
|
+
*
|
|
37
|
+
* @param {Particle} particle - The particle to set the life time of.
|
|
38
|
+
* @returns {void}
|
|
39
|
+
*/
|
|
8
40
|
init: (particle: Particle) => void;
|
|
41
|
+
/**
|
|
42
|
+
* Updates the particle's life time and progress.
|
|
43
|
+
*
|
|
44
|
+
* @param {Particle} particle - The particle to update.
|
|
45
|
+
* @param {number} deltaTime - The time since the last update.
|
|
46
|
+
* @returns {void}
|
|
47
|
+
*/
|
|
9
48
|
apply: (particle: Particle, deltaTime: number) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Returns the name of this behaviour.
|
|
51
|
+
*
|
|
52
|
+
* @returns {string} - The name of the behaviour.
|
|
53
|
+
*/
|
|
10
54
|
getName(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Returns the properties of the behaviour.
|
|
57
|
+
*
|
|
58
|
+
* @returns {Object} - The properties of the behaviour.
|
|
59
|
+
*/
|
|
11
60
|
getProps(): {
|
|
12
61
|
enabled: boolean;
|
|
13
62
|
priority: number;
|
|
@@ -1,27 +1,77 @@
|
|
|
1
1
|
import { Behaviour, BehaviourNames } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* This class is responsible for managing the lifetimes of particles.
|
|
4
|
+
* It sets the maximum lifetime of the particle and updates its progress.
|
|
5
|
+
*
|
|
6
|
+
* @extends Behaviour
|
|
7
|
+
*/
|
|
2
8
|
export default class LifeBehaviour extends Behaviour {
|
|
3
9
|
constructor() {
|
|
4
10
|
super(...arguments);
|
|
11
|
+
/**
|
|
12
|
+
* Whether or not this behaviour is enabled.
|
|
13
|
+
*
|
|
14
|
+
* @type {boolean}
|
|
15
|
+
*/
|
|
5
16
|
this.enabled = true;
|
|
17
|
+
/**
|
|
18
|
+
* The priority of this behaviour.
|
|
19
|
+
*
|
|
20
|
+
* @type {number}
|
|
21
|
+
*/
|
|
6
22
|
this.priority = 10000;
|
|
23
|
+
/**
|
|
24
|
+
* The maximum life time of the particle that this behaviour will set.
|
|
25
|
+
*
|
|
26
|
+
* @type {number}
|
|
27
|
+
*/
|
|
7
28
|
this.maxLifeTime = 0;
|
|
29
|
+
/**
|
|
30
|
+
* The variance of the particle's life time.
|
|
31
|
+
*
|
|
32
|
+
* @type {number}
|
|
33
|
+
*/
|
|
8
34
|
this.timeVariance = 0;
|
|
35
|
+
/**
|
|
36
|
+
* Sets the particle's life time and maximum life time.
|
|
37
|
+
*
|
|
38
|
+
* @param {Particle} particle - The particle to set the life time of.
|
|
39
|
+
* @returns {void}
|
|
40
|
+
*/
|
|
9
41
|
this.init = (particle) => {
|
|
10
42
|
particle.lifeTime = 0;
|
|
11
43
|
particle.lifeProgress = 0;
|
|
12
|
-
particle.maxLifeTime = this.maxLifeTime + this.varianceFrom(this.timeVariance);
|
|
13
|
-
particle.maxLifeTime = Math.max(particle.maxLifeTime, 0.0);
|
|
44
|
+
particle.maxLifeTime = Math.max(this.maxLifeTime + this.varianceFrom(this.timeVariance), 0.0);
|
|
14
45
|
};
|
|
46
|
+
/**
|
|
47
|
+
* Updates the particle's life time and progress.
|
|
48
|
+
*
|
|
49
|
+
* @param {Particle} particle - The particle to update.
|
|
50
|
+
* @param {number} deltaTime - The time since the last update.
|
|
51
|
+
* @returns {void}
|
|
52
|
+
*/
|
|
15
53
|
this.apply = (particle, deltaTime) => {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
54
|
+
const { maxLifeTime } = particle;
|
|
55
|
+
const lifeTime = particle.lifeTime + deltaTime;
|
|
56
|
+
particle.lifeTime = lifeTime;
|
|
57
|
+
if (maxLifeTime > 0) {
|
|
58
|
+
particle.lifeProgress = Math.min(1.0, lifeTime / maxLifeTime);
|
|
19
59
|
}
|
|
20
60
|
};
|
|
21
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Returns the name of this behaviour.
|
|
64
|
+
*
|
|
65
|
+
* @returns {string} - The name of the behaviour.
|
|
66
|
+
*/
|
|
22
67
|
getName() {
|
|
23
68
|
return BehaviourNames.LIFE_BEHAVIOUR;
|
|
24
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* Returns the properties of the behaviour.
|
|
72
|
+
*
|
|
73
|
+
* @returns {Object} - The properties of the behaviour.
|
|
74
|
+
*/
|
|
25
75
|
getProps() {
|
|
26
76
|
return {
|
|
27
77
|
enabled: this.enabled,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LifeBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/LifeBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGnD,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS;IAApD;;QACE,YAAO,GAAG,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"LifeBehaviour.js","sourceRoot":"","sources":["../../../src/lib/behaviour/LifeBehaviour.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAGnD;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,SAAS;IAApD;;QACE;;;;WAIG;QACH,YAAO,GAAG,IAAI,CAAA;QAEd;;;;WAIG;QACH,aAAQ,GAAG,KAAK,CAAA;QAEhB;;;;WAIG;QACH,gBAAW,GAAG,CAAC,CAAA;QAEf;;;;WAIG;QACH,iBAAY,GAAG,CAAC,CAAA;QAEhB;;;;;WAKG;QACH,SAAI,GAAG,CAAC,QAAkB,EAAE,EAAE;YAC5B,QAAQ,CAAC,QAAQ,GAAG,CAAC,CAAA;YACrB,QAAQ,CAAC,YAAY,GAAG,CAAC,CAAA;YACzB,QAAQ,CAAC,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,GAAG,CAAC,CAAA;QAC/F,CAAC,CAAA;QAED;;;;;;WAMG;QACH,UAAK,GAAG,CAAC,QAAkB,EAAE,SAAiB,EAAE,EAAE;YAChD,MAAM,EAAE,WAAW,EAAE,GAAG,QAAQ,CAAA;YAChC,MAAM,QAAQ,GAAG,QAAQ,CAAC,QAAQ,GAAG,SAAS,CAAA;YAE9C,QAAQ,CAAC,QAAQ,GAAG,QAAQ,CAAA;YAE5B,IAAI,WAAW,GAAG,CAAC,EAAE;gBACnB,QAAQ,CAAC,YAAY,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,GAAG,WAAW,CAAC,CAAA;aAC9D;QACH,CAAC,CAAA;IAyBH,CAAC;IAvBC;;;;OAIG;IACH,OAAO;QACL,OAAO,cAAc,CAAC,cAAc,CAAA;IACtC,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,IAAI,EAAE,IAAI,CAAC,OAAO,EAAE;SACrB,CAAA;IACH,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Point } from '../util';
|
|
2
2
|
import { Behaviour } from './index';
|
|
3
3
|
import Particle from '../Particle';
|
|
4
|
-
import Model from
|
|
4
|
+
import Model from '../Model';
|
|
5
5
|
export default class PositionBehaviour extends Behaviour {
|
|
6
6
|
enabled: boolean;
|
|
7
7
|
priority: number;
|
|
@@ -26,11 +26,43 @@ export default class PositionBehaviour extends Behaviour {
|
|
|
26
26
|
warpFov: number;
|
|
27
27
|
warpStretch: number;
|
|
28
28
|
warpDistanceScaleConverter: number;
|
|
29
|
+
warpDistanceToCenter: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Function that initializes a particle
|
|
32
|
+
* @param {Particle} particle - The particle to be initialized
|
|
33
|
+
* @param {Model} model - The model of the particle
|
|
34
|
+
*/
|
|
29
35
|
init: (particle: Particle, model: Model) => void;
|
|
36
|
+
/**
|
|
37
|
+
* Restarts the warp of a particle
|
|
38
|
+
* @param {Particle} particle - The particle to restart the warp on
|
|
39
|
+
* @param {boolean} initial - True if this is the initial warp, false if it is a subsequent one
|
|
40
|
+
* @param {Model} model - The model containing the camera Z property
|
|
41
|
+
*/
|
|
30
42
|
restartWarp: (particle: Particle, initial: boolean, model: Model) => void;
|
|
43
|
+
/**
|
|
44
|
+
* Adds a random variance to the given value
|
|
45
|
+
* @param {number} value - The value to calculate
|
|
46
|
+
* @param {number} variance - The random variance to add
|
|
47
|
+
* @returns {number} The calculated value
|
|
48
|
+
*/
|
|
31
49
|
calculate: (value: number, variance: number) => number;
|
|
50
|
+
/**
|
|
51
|
+
* Applies the particle's velocity and acceleration to move it and calculate its size, rotation, and position.
|
|
52
|
+
* @param {Particle} particle - The particle to be moved
|
|
53
|
+
* @param {number} deltaTime - The time delta for the movement calculation
|
|
54
|
+
* @param {Model} model - The model containing information about the particle's movement
|
|
55
|
+
*/
|
|
32
56
|
apply: (particle: Particle, deltaTime: number, model: Model) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Gets the name of the behaviour
|
|
59
|
+
* @return {BehaviourNames} The name of the behaviour
|
|
60
|
+
*/
|
|
33
61
|
getName(): string;
|
|
62
|
+
/**
|
|
63
|
+
* @description Retrieves the properties of the object.
|
|
64
|
+
* @returns {Object} The properties of the object.
|
|
65
|
+
*/
|
|
34
66
|
getProps(): {
|
|
35
67
|
enabled: boolean;
|
|
36
68
|
priority: number;
|
|
@@ -73,6 +105,7 @@ export default class PositionBehaviour extends Behaviour {
|
|
|
73
105
|
warpFov: number;
|
|
74
106
|
warpStretch: number;
|
|
75
107
|
warpDistanceScaleConverter: number;
|
|
108
|
+
warpDistanceToCenter: boolean;
|
|
76
109
|
name: string;
|
|
77
110
|
};
|
|
78
111
|
}
|