custom-pixi-particles 2.0.10 → 2.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +45 -45
  3. package/dist/index.d.ts +6 -6
  4. package/dist/index.js +15 -15
  5. package/dist/lib/Particle.d.ts +45 -45
  6. package/dist/lib/Particle.js +68 -68
  7. package/dist/lib/ParticlePool.d.ts +9 -9
  8. package/dist/lib/ParticlePool.js +33 -33
  9. package/dist/lib/behaviour/AngularVelocityBehaviour.d.ts +26 -26
  10. package/dist/lib/behaviour/AngularVelocityBehaviour.js +77 -77
  11. package/dist/lib/behaviour/Behaviour.d.ts +7 -7
  12. package/dist/lib/behaviour/Behaviour.js +26 -26
  13. package/dist/lib/behaviour/BehaviourNames.d.ts +11 -11
  14. package/dist/lib/behaviour/BehaviourNames.js +12 -12
  15. package/dist/lib/behaviour/ColorBehaviour.d.ts +45 -45
  16. package/dist/lib/behaviour/ColorBehaviour.js +103 -103
  17. package/dist/lib/behaviour/EmitDirectionBehaviour.d.ts +22 -22
  18. package/dist/lib/behaviour/EmitDirectionBehaviour.js +83 -83
  19. package/dist/lib/behaviour/EmitterBehaviours.d.ts +12 -12
  20. package/dist/lib/behaviour/EmitterBehaviours.js +59 -59
  21. package/dist/lib/behaviour/LifeBehaviour.d.ts +18 -18
  22. package/dist/lib/behaviour/LifeBehaviour.js +55 -55
  23. package/dist/lib/behaviour/PositionBehaviour.d.ts +62 -62
  24. package/dist/lib/behaviour/PositionBehaviour.js +146 -146
  25. package/dist/lib/behaviour/RotationBehaviour.d.ts +22 -22
  26. package/dist/lib/behaviour/RotationBehaviour.js +77 -77
  27. package/dist/lib/behaviour/SizeBehaviour.d.ts +31 -31
  28. package/dist/lib/behaviour/SizeBehaviour.js +84 -84
  29. package/dist/lib/behaviour/TurbulenceBehaviour.d.ts +69 -69
  30. package/dist/lib/behaviour/TurbulenceBehaviour.js +153 -153
  31. package/dist/lib/behaviour/index.d.ts +12 -12
  32. package/dist/lib/behaviour/index.js +28 -28
  33. package/dist/lib/customPixiParticlesSettingsInterface.d.ts +8 -8
  34. package/dist/lib/customPixiParticlesSettingsInterface.js +2 -2
  35. package/dist/lib/emission/AbstractEmission.d.ts +7 -7
  36. package/dist/lib/emission/AbstractEmission.js +21 -21
  37. package/dist/lib/emission/EmissionTypes.d.ts +6 -6
  38. package/dist/lib/emission/EmissionTypes.js +7 -7
  39. package/dist/lib/emission/RandomEmission.d.ts +11 -11
  40. package/dist/lib/emission/RandomEmission.js +61 -61
  41. package/dist/lib/emission/StandardEmission.d.ts +12 -12
  42. package/dist/lib/emission/StandardEmission.js +65 -65
  43. package/dist/lib/emission/UniformEmission.d.ts +14 -14
  44. package/dist/lib/emission/UniformEmission.js +73 -73
  45. package/dist/lib/emission/index.d.ts +6 -6
  46. package/dist/lib/emission/index.js +16 -16
  47. package/dist/lib/emitter/Duration.d.ts +10 -10
  48. package/dist/lib/emitter/Duration.js +28 -28
  49. package/dist/lib/emitter/Emitter.d.ts +45 -45
  50. package/dist/lib/emitter/Emitter.js +214 -214
  51. package/dist/lib/emitter/index.d.ts +3 -3
  52. package/dist/lib/emitter/index.js +10 -10
  53. package/dist/lib/index.d.ts +20 -20
  54. package/dist/lib/index.js +44 -44
  55. package/dist/lib/parser/BehaviourParser.d.ts +10 -10
  56. package/dist/lib/parser/BehaviourParser.js +48 -48
  57. package/dist/lib/parser/CompatibilityHelper.d.ts +3 -3
  58. package/dist/lib/parser/CompatibilityHelper.js +14 -14
  59. package/dist/lib/parser/EmitControllerParser.d.ts +6 -6
  60. package/dist/lib/parser/EmitControllerParser.js +22 -22
  61. package/dist/lib/parser/EmitterParser.d.ts +12 -12
  62. package/dist/lib/parser/EmitterParser.js +126 -126
  63. package/dist/lib/parser/index.d.ts +5 -5
  64. package/dist/lib/parser/index.js +14 -14
  65. package/dist/lib/pixi/Renderer.d.ts +49 -49
  66. package/dist/lib/pixi/Renderer.js +440 -437
  67. package/dist/lib/pixi/Renderer.js.map +1 -1
  68. package/dist/lib/util/Color.d.ts +32 -32
  69. package/dist/lib/util/Color.js +98 -98
  70. package/dist/lib/util/List.d.ts +9 -9
  71. package/dist/lib/util/List.js +50 -50
  72. package/dist/lib/util/Point.d.ts +13 -13
  73. package/dist/lib/util/Point.js +29 -29
  74. package/dist/lib/util/Random.d.ts +4 -4
  75. package/dist/lib/util/Random.js +14 -14
  76. package/dist/lib/util/index.d.ts +5 -5
  77. package/dist/lib/util/index.js +14 -14
  78. package/dist/lib/util/maths.d.ts +7 -7
  79. package/dist/lib/util/maths.js +16 -16
  80. package/dist/lib/util/turbulencePool.d.ts +5 -5
  81. package/dist/lib/util/turbulencePool.js +9 -9
  82. package/package.json +41 -41
@@ -1,85 +1,85 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
18
- var util_1 = require("../util");
19
- var index_1 = require("./index");
20
- var SizeBehaviour = /** @class */ (function (_super) {
21
- __extends(SizeBehaviour, _super);
22
- function SizeBehaviour() {
23
- var _this = _super !== null && _super.apply(this, arguments) || this;
24
- _this.enabled = true;
25
- _this.priority = 0;
26
- _this.allowNegativeValues = false;
27
- _this.sizeStart = new util_1.Point(1, 1);
28
- _this.sizeEnd = new util_1.Point(1, 1);
29
- _this.startVariance = 0;
30
- _this.endVariance = 0;
31
- _this.init = function (particle) {
32
- if (!_this.enabled)
33
- return;
34
- var variance = _this.varianceFrom(_this.startVariance);
35
- particle.sizeStart.x = _this.sizeStart.x + variance;
36
- particle.sizeStart.y = _this.sizeStart.y + variance;
37
- variance = _this.varianceFrom(_this.endVariance);
38
- particle.sizeEnd.x = _this.sizeEnd.x + variance;
39
- particle.sizeEnd.y = _this.sizeEnd.y + variance;
40
- if (!_this.allowNegativeValues) {
41
- particle.sizeStart.x = Math.max(particle.sizeStart.x, 0);
42
- particle.sizeStart.y = Math.max(particle.sizeStart.y, 0);
43
- particle.sizeEnd.x = Math.max(particle.sizeEnd.x, 0);
44
- particle.sizeEnd.y = Math.max(particle.sizeEnd.y, 0);
45
- }
46
- particle.size.copyFrom(particle.sizeStart);
47
- };
48
- _this.apply = function (particle, deltaTime) {
49
- if (!_this.enabled)
50
- return;
51
- particle.size.copyFrom(particle.sizeStart);
52
- particle.size.x += (particle.sizeEnd.x - particle.sizeStart.x) * particle.lifeProgress;
53
- particle.size.y += (particle.sizeEnd.y - particle.sizeStart.y) * particle.lifeProgress;
54
- if (!_this.allowNegativeValues) {
55
- particle.size.x = Math.max(0, particle.size.x);
56
- particle.size.x = Math.max(0, particle.size.x);
57
- }
58
- };
59
- return _this;
60
- }
61
- SizeBehaviour.prototype.getName = function () {
62
- return index_1.BehaviourNames.SIZE_BEHAVIOUR;
63
- };
64
- SizeBehaviour.prototype.getProps = function () {
65
- return {
66
- enabled: this.enabled,
67
- priority: this.priority,
68
- allowNegativeValues: this.allowNegativeValues,
69
- sizeStart: {
70
- x: this.sizeStart.x,
71
- y: this.sizeStart.y,
72
- },
73
- sizeEnd: {
74
- x: this.sizeStart.x,
75
- y: this.sizeStart.y,
76
- },
77
- startVariance: this.startVariance,
78
- endVariance: this.endVariance,
79
- name: this.getName(),
80
- };
81
- };
82
- return SizeBehaviour;
83
- }(index_1.Behaviour));
84
- exports.default = SizeBehaviour;
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
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ var util_1 = require("../util");
19
+ var index_1 = require("./index");
20
+ var SizeBehaviour = /** @class */ (function (_super) {
21
+ __extends(SizeBehaviour, _super);
22
+ function SizeBehaviour() {
23
+ var _this = _super !== null && _super.apply(this, arguments) || this;
24
+ _this.enabled = true;
25
+ _this.priority = 0;
26
+ _this.allowNegativeValues = false;
27
+ _this.sizeStart = new util_1.Point(1, 1);
28
+ _this.sizeEnd = new util_1.Point(1, 1);
29
+ _this.startVariance = 0;
30
+ _this.endVariance = 0;
31
+ _this.init = function (particle) {
32
+ if (!_this.enabled)
33
+ return;
34
+ var variance = _this.varianceFrom(_this.startVariance);
35
+ particle.sizeStart.x = _this.sizeStart.x + variance;
36
+ particle.sizeStart.y = _this.sizeStart.y + variance;
37
+ variance = _this.varianceFrom(_this.endVariance);
38
+ particle.sizeEnd.x = _this.sizeEnd.x + variance;
39
+ particle.sizeEnd.y = _this.sizeEnd.y + variance;
40
+ if (!_this.allowNegativeValues) {
41
+ particle.sizeStart.x = Math.max(particle.sizeStart.x, 0);
42
+ particle.sizeStart.y = Math.max(particle.sizeStart.y, 0);
43
+ particle.sizeEnd.x = Math.max(particle.sizeEnd.x, 0);
44
+ particle.sizeEnd.y = Math.max(particle.sizeEnd.y, 0);
45
+ }
46
+ particle.size.copyFrom(particle.sizeStart);
47
+ };
48
+ _this.apply = function (particle, deltaTime) {
49
+ if (!_this.enabled)
50
+ return;
51
+ particle.size.copyFrom(particle.sizeStart);
52
+ particle.size.x += (particle.sizeEnd.x - particle.sizeStart.x) * particle.lifeProgress;
53
+ particle.size.y += (particle.sizeEnd.y - particle.sizeStart.y) * particle.lifeProgress;
54
+ if (!_this.allowNegativeValues) {
55
+ particle.size.x = Math.max(0, particle.size.x);
56
+ particle.size.x = Math.max(0, particle.size.x);
57
+ }
58
+ };
59
+ return _this;
60
+ }
61
+ SizeBehaviour.prototype.getName = function () {
62
+ return index_1.BehaviourNames.SIZE_BEHAVIOUR;
63
+ };
64
+ SizeBehaviour.prototype.getProps = function () {
65
+ return {
66
+ enabled: this.enabled,
67
+ priority: this.priority,
68
+ allowNegativeValues: this.allowNegativeValues,
69
+ sizeStart: {
70
+ x: this.sizeStart.x,
71
+ y: this.sizeStart.y,
72
+ },
73
+ sizeEnd: {
74
+ x: this.sizeStart.x,
75
+ y: this.sizeStart.y,
76
+ },
77
+ startVariance: this.startVariance,
78
+ endVariance: this.endVariance,
79
+ name: this.getName(),
80
+ };
81
+ };
82
+ return SizeBehaviour;
83
+ }(index_1.Behaviour));
84
+ exports.default = SizeBehaviour;
85
85
  //# sourceMappingURL=SizeBehaviour.js.map
@@ -1,69 +1,69 @@
1
- import Behaviour from './Behaviour';
2
- import Particle from '../Particle';
3
- import { Point } from '../util';
4
- export default class TurbulenceBehaviour extends Behaviour {
5
- private enabled;
6
- private showVortices;
7
- private effect;
8
- private turbulence;
9
- private vortexOrgSize;
10
- position: Point;
11
- positionVariance: Point;
12
- velocity: Point;
13
- velocityVariance: Point;
14
- acceleration: Point;
15
- accelerationVariance: Point;
16
- sizeStart: Point;
17
- sizeEnd: Point;
18
- startVariance: number;
19
- endVariance: number;
20
- emitPerSecond: number;
21
- duration: number;
22
- maxLifeTime: number;
23
- init: (particle: Particle) => void;
24
- apply: (particle: Particle, deltaTime: number) => void;
25
- getName(): string;
26
- getProps(): {
27
- enabled: boolean;
28
- priority: number;
29
- position: {
30
- x: number;
31
- y: number;
32
- };
33
- positionVariance: {
34
- x: number;
35
- y: number;
36
- };
37
- velocity: {
38
- x: number;
39
- y: number;
40
- };
41
- velocityVariance: {
42
- x: number;
43
- y: number;
44
- };
45
- acceleration: {
46
- x: number;
47
- y: number;
48
- };
49
- accelerationVariance: {
50
- x: number;
51
- y: number;
52
- };
53
- sizeStart: {
54
- x: number;
55
- y: number;
56
- };
57
- sizeEnd: {
58
- x: number;
59
- y: number;
60
- };
61
- startVariance: number;
62
- endVariance: number;
63
- emitPerSecond: number;
64
- duration: number;
65
- maxLifeTime: number;
66
- version: number;
67
- name: string;
68
- };
69
- }
1
+ import Behaviour from './Behaviour';
2
+ import Particle from '../Particle';
3
+ import { Point } from '../util';
4
+ export default class TurbulenceBehaviour extends Behaviour {
5
+ private enabled;
6
+ private showVortices;
7
+ private effect;
8
+ private turbulence;
9
+ private vortexOrgSize;
10
+ position: Point;
11
+ positionVariance: Point;
12
+ velocity: Point;
13
+ velocityVariance: Point;
14
+ acceleration: Point;
15
+ accelerationVariance: Point;
16
+ sizeStart: Point;
17
+ sizeEnd: Point;
18
+ startVariance: number;
19
+ endVariance: number;
20
+ emitPerSecond: number;
21
+ duration: number;
22
+ maxLifeTime: number;
23
+ init: (particle: Particle) => void;
24
+ apply: (particle: Particle, deltaTime: number) => void;
25
+ getName(): string;
26
+ getProps(): {
27
+ enabled: boolean;
28
+ priority: number;
29
+ position: {
30
+ x: number;
31
+ y: number;
32
+ };
33
+ positionVariance: {
34
+ x: number;
35
+ y: number;
36
+ };
37
+ velocity: {
38
+ x: number;
39
+ y: number;
40
+ };
41
+ velocityVariance: {
42
+ x: number;
43
+ y: number;
44
+ };
45
+ acceleration: {
46
+ x: number;
47
+ y: number;
48
+ };
49
+ accelerationVariance: {
50
+ x: number;
51
+ y: number;
52
+ };
53
+ sizeStart: {
54
+ x: number;
55
+ y: number;
56
+ };
57
+ sizeEnd: {
58
+ x: number;
59
+ y: number;
60
+ };
61
+ startVariance: number;
62
+ endVariance: number;
63
+ emitPerSecond: number;
64
+ duration: number;
65
+ maxLifeTime: number;
66
+ version: number;
67
+ name: string;
68
+ };
69
+ }
@@ -1,154 +1,154 @@
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
- var Behaviour_1 = __importDefault(require("./Behaviour"));
22
- var BehaviourNames_1 = __importDefault(require("./BehaviourNames"));
23
- var util_1 = require("../util");
24
- var turbulencePool_1 = __importDefault(require("../util/turbulencePool"));
25
- var TurbulenceBehaviour = /** @class */ (function (_super) {
26
- __extends(TurbulenceBehaviour, _super);
27
- function TurbulenceBehaviour() {
28
- var _this = _super !== null && _super.apply(this, arguments) || this;
29
- _this.enabled = false;
30
- _this.showVortices = false;
31
- _this.effect = 0;
32
- _this.turbulence = false;
33
- _this.vortexOrgSize = 128;
34
- _this.position = new util_1.Point();
35
- _this.positionVariance = new util_1.Point();
36
- _this.velocity = new util_1.Point();
37
- _this.velocityVariance = new util_1.Point();
38
- _this.acceleration = new util_1.Point();
39
- _this.accelerationVariance = new util_1.Point();
40
- _this.sizeStart = new util_1.Point(1, 1);
41
- _this.sizeEnd = new util_1.Point(1, 1);
42
- _this.startVariance = 0;
43
- _this.endVariance = 0;
44
- _this.emitPerSecond = 0;
45
- _this.duration = 0;
46
- _this.maxLifeTime = 0;
47
- _this.init = function (particle) {
48
- if (!_this.enabled)
49
- return;
50
- particle.showVortices = _this.showVortices;
51
- particle.turbulence = _this.turbulence;
52
- };
53
- _this.apply = function (particle, deltaTime) {
54
- if (!_this.enabled)
55
- return;
56
- if (particle.turbulence)
57
- return;
58
- turbulencePool_1.default.list.forEach(function (vortex) {
59
- var vx = 0, vy = 0, factor = 0;
60
- var dx = particle.x - vortex.x;
61
- var dy = particle.y - vortex.y;
62
- if (dx > _this.vortexOrgSize * vortex.size.x)
63
- return;
64
- if (dy > _this.vortexOrgSize * vortex.size.x)
65
- return;
66
- if (_this.effect === 0 || _this.effect === 1) {
67
- if (!_this.effect) {
68
- vx = -dy + vortex.velocity.x;
69
- vy = dx + vortex.velocity.y;
70
- }
71
- else {
72
- vx = dy + vortex.velocity.x;
73
- vy = -dx + vortex.velocity.y;
74
- }
75
- factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
76
- }
77
- else if (_this.effect === 2) {
78
- vx = dx + vortex.velocity.x;
79
- vy = dy + vortex.velocity.y;
80
- factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
81
- }
82
- else if (_this.effect === 3) {
83
- vx = dx - vortex.velocity.x;
84
- vy = dy - vortex.velocity.y;
85
- factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
86
- }
87
- else if (_this.effect === 4) {
88
- vx = -dx + vortex.velocity.x;
89
- vy = -dy + vortex.velocity.y;
90
- factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
91
- }
92
- else if (_this.effect === 5) {
93
- vx = -dx - vortex.velocity.x;
94
- vy = -dy - vortex.velocity.y;
95
- factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
96
- }
97
- particle.velocity.x += (vx - particle.velocity.x) * factor;
98
- particle.velocity.y += (vy - particle.velocity.y) * factor;
99
- });
100
- };
101
- return _this;
102
- }
103
- TurbulenceBehaviour.prototype.getName = function () {
104
- return BehaviourNames_1.default.TURBULENCE_BEHAVIOUR;
105
- };
106
- TurbulenceBehaviour.prototype.getProps = function () {
107
- return {
108
- enabled: this.enabled,
109
- priority: this.priority,
110
- position: {
111
- x: this.position.x,
112
- y: this.position.y,
113
- },
114
- positionVariance: {
115
- x: this.position.x,
116
- y: this.position.y,
117
- },
118
- velocity: {
119
- x: this.position.x,
120
- y: this.position.y,
121
- },
122
- velocityVariance: {
123
- x: this.position.x,
124
- y: this.position.y,
125
- },
126
- acceleration: {
127
- x: this.position.x,
128
- y: this.position.y,
129
- },
130
- accelerationVariance: {
131
- x: this.position.x,
132
- y: this.position.y,
133
- },
134
- sizeStart: {
135
- x: this.sizeStart.x,
136
- y: this.sizeStart.y,
137
- },
138
- sizeEnd: {
139
- x: this.sizeStart.x,
140
- y: this.sizeStart.y,
141
- },
142
- startVariance: this.startVariance,
143
- endVariance: this.endVariance,
144
- emitPerSecond: this.emitPerSecond,
145
- duration: this.duration,
146
- maxLifeTime: this.maxLifeTime,
147
- version: this.effect,
148
- name: this.getName(),
149
- };
150
- };
151
- return TurbulenceBehaviour;
152
- }(Behaviour_1.default));
153
- exports.default = TurbulenceBehaviour;
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
+ var Behaviour_1 = __importDefault(require("./Behaviour"));
22
+ var BehaviourNames_1 = __importDefault(require("./BehaviourNames"));
23
+ var util_1 = require("../util");
24
+ var turbulencePool_1 = __importDefault(require("../util/turbulencePool"));
25
+ var TurbulenceBehaviour = /** @class */ (function (_super) {
26
+ __extends(TurbulenceBehaviour, _super);
27
+ function TurbulenceBehaviour() {
28
+ var _this = _super !== null && _super.apply(this, arguments) || this;
29
+ _this.enabled = false;
30
+ _this.showVortices = false;
31
+ _this.effect = 0;
32
+ _this.turbulence = false;
33
+ _this.vortexOrgSize = 128;
34
+ _this.position = new util_1.Point();
35
+ _this.positionVariance = new util_1.Point();
36
+ _this.velocity = new util_1.Point();
37
+ _this.velocityVariance = new util_1.Point();
38
+ _this.acceleration = new util_1.Point();
39
+ _this.accelerationVariance = new util_1.Point();
40
+ _this.sizeStart = new util_1.Point(1, 1);
41
+ _this.sizeEnd = new util_1.Point(1, 1);
42
+ _this.startVariance = 0;
43
+ _this.endVariance = 0;
44
+ _this.emitPerSecond = 0;
45
+ _this.duration = 0;
46
+ _this.maxLifeTime = 0;
47
+ _this.init = function (particle) {
48
+ if (!_this.enabled)
49
+ return;
50
+ particle.showVortices = _this.showVortices;
51
+ particle.turbulence = _this.turbulence;
52
+ };
53
+ _this.apply = function (particle, deltaTime) {
54
+ if (!_this.enabled)
55
+ return;
56
+ if (particle.turbulence)
57
+ return;
58
+ turbulencePool_1.default.list.forEach(function (vortex) {
59
+ var vx = 0, vy = 0, factor = 0;
60
+ var dx = particle.x - vortex.x;
61
+ var dy = particle.y - vortex.y;
62
+ if (dx > _this.vortexOrgSize * vortex.size.x)
63
+ return;
64
+ if (dy > _this.vortexOrgSize * vortex.size.x)
65
+ return;
66
+ if (_this.effect === 0 || _this.effect === 1) {
67
+ if (!_this.effect) {
68
+ vx = -dy + vortex.velocity.x;
69
+ vy = dx + vortex.velocity.y;
70
+ }
71
+ else {
72
+ vx = dy + vortex.velocity.x;
73
+ vy = -dx + vortex.velocity.y;
74
+ }
75
+ factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
76
+ }
77
+ else if (_this.effect === 2) {
78
+ vx = dx + vortex.velocity.x;
79
+ vy = dy + vortex.velocity.y;
80
+ factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
81
+ }
82
+ else if (_this.effect === 3) {
83
+ vx = dx - vortex.velocity.x;
84
+ vy = dy - vortex.velocity.y;
85
+ factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
86
+ }
87
+ else if (_this.effect === 4) {
88
+ vx = -dx + vortex.velocity.x;
89
+ vy = -dy + vortex.velocity.y;
90
+ factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
91
+ }
92
+ else if (_this.effect === 5) {
93
+ vx = -dx - vortex.velocity.x;
94
+ vy = -dy - vortex.velocity.y;
95
+ factor = 1 / (1 + (dx * dx + dy * dy) / (_this.vortexOrgSize * vortex.size.x));
96
+ }
97
+ particle.velocity.x += (vx - particle.velocity.x) * factor;
98
+ particle.velocity.y += (vy - particle.velocity.y) * factor;
99
+ });
100
+ };
101
+ return _this;
102
+ }
103
+ TurbulenceBehaviour.prototype.getName = function () {
104
+ return BehaviourNames_1.default.TURBULENCE_BEHAVIOUR;
105
+ };
106
+ TurbulenceBehaviour.prototype.getProps = function () {
107
+ return {
108
+ enabled: this.enabled,
109
+ priority: this.priority,
110
+ position: {
111
+ x: this.position.x,
112
+ y: this.position.y,
113
+ },
114
+ positionVariance: {
115
+ x: this.position.x,
116
+ y: this.position.y,
117
+ },
118
+ velocity: {
119
+ x: this.position.x,
120
+ y: this.position.y,
121
+ },
122
+ velocityVariance: {
123
+ x: this.position.x,
124
+ y: this.position.y,
125
+ },
126
+ acceleration: {
127
+ x: this.position.x,
128
+ y: this.position.y,
129
+ },
130
+ accelerationVariance: {
131
+ x: this.position.x,
132
+ y: this.position.y,
133
+ },
134
+ sizeStart: {
135
+ x: this.sizeStart.x,
136
+ y: this.sizeStart.y,
137
+ },
138
+ sizeEnd: {
139
+ x: this.sizeStart.x,
140
+ y: this.sizeStart.y,
141
+ },
142
+ startVariance: this.startVariance,
143
+ endVariance: this.endVariance,
144
+ emitPerSecond: this.emitPerSecond,
145
+ duration: this.duration,
146
+ maxLifeTime: this.maxLifeTime,
147
+ version: this.effect,
148
+ name: this.getName(),
149
+ };
150
+ };
151
+ return TurbulenceBehaviour;
152
+ }(Behaviour_1.default));
153
+ exports.default = TurbulenceBehaviour;
154
154
  //# sourceMappingURL=TurbulenceBehaviour.js.map
@@ -1,12 +1,12 @@
1
- import BehaviourNames from './BehaviourNames';
2
- import EmitterBehaviours from './EmitterBehaviours';
3
- import Behaviour from './Behaviour';
4
- import LifeBehaviour from './LifeBehaviour';
5
- import PositionBehaviour from './PositionBehaviour';
6
- import ColorBehaviour from './ColorBehaviour';
7
- import SizeBehaviour from './SizeBehaviour';
8
- import AngularVelocityBehaviour from './AngularVelocityBehaviour';
9
- import EmitDirectionBehaviour from './EmitDirectionBehaviour';
10
- import RotationBehaviour from './RotationBehaviour';
11
- import TurbulenceBehaviour from './TurbulenceBehaviour';
12
- export { EmitterBehaviours, Behaviour, LifeBehaviour, PositionBehaviour, ColorBehaviour, SizeBehaviour, AngularVelocityBehaviour, EmitDirectionBehaviour, RotationBehaviour, TurbulenceBehaviour, BehaviourNames, };
1
+ import BehaviourNames from './BehaviourNames';
2
+ import EmitterBehaviours from './EmitterBehaviours';
3
+ import Behaviour from './Behaviour';
4
+ import LifeBehaviour from './LifeBehaviour';
5
+ import PositionBehaviour from './PositionBehaviour';
6
+ import ColorBehaviour from './ColorBehaviour';
7
+ import SizeBehaviour from './SizeBehaviour';
8
+ import AngularVelocityBehaviour from './AngularVelocityBehaviour';
9
+ import EmitDirectionBehaviour from './EmitDirectionBehaviour';
10
+ import RotationBehaviour from './RotationBehaviour';
11
+ import TurbulenceBehaviour from './TurbulenceBehaviour';
12
+ export { EmitterBehaviours, Behaviour, LifeBehaviour, PositionBehaviour, ColorBehaviour, SizeBehaviour, AngularVelocityBehaviour, EmitDirectionBehaviour, RotationBehaviour, TurbulenceBehaviour, BehaviourNames, };