@tsparticles/plugin-emitters 3.0.0-alpha.1 → 3.0.0-beta.1
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/README.md +15 -11
- package/browser/EmitterInstance.js +101 -113
- package/browser/Emitters.js +31 -27
- package/browser/Options/Classes/Emitter.js +6 -6
- package/browser/Options/Classes/EmitterLife.js +4 -3
- package/browser/index.js +23 -26
- package/browser/package.json +1 -0
- package/cjs/EmitterInstance.js +102 -114
- package/cjs/Emitters.js +41 -48
- package/cjs/Options/Classes/Emitter.js +8 -8
- package/cjs/Options/Classes/EmitterLife.js +4 -3
- package/cjs/Shapes/Circle/CircleShape.js +1 -1
- package/cjs/index.js +38 -52
- package/cjs/package.json +1 -0
- package/esm/EmitterInstance.js +101 -113
- package/esm/Emitters.js +31 -27
- package/esm/Options/Classes/Emitter.js +6 -6
- package/esm/Options/Classes/EmitterLife.js +4 -3
- package/esm/index.js +23 -26
- package/esm/package.json +1 -0
- package/package.json +19 -6
- package/report.html +4 -4
- package/tsparticles.plugin.emitters.js +137 -145
- package/tsparticles.plugin.emitters.min.js +1 -1
- package/tsparticles.plugin.emitters.min.js.LICENSE.txt +1 -8
- package/types/EmitterContainer.d.ts +3 -3
- package/types/EmitterInstance.d.ts +12 -12
- package/types/Emitters.d.ts +7 -7
- package/types/EmittersEngine.d.ts +2 -2
- package/types/Enums/EmitterShapeType.d.ts +3 -1
- package/types/Options/Classes/Emitter.d.ts +6 -7
- package/types/Options/Classes/EmitterLife.d.ts +4 -4
- package/types/Options/Classes/EmitterRate.d.ts +2 -2
- package/types/Options/Classes/EmitterSize.d.ts +3 -4
- package/types/Options/Interfaces/IEmitter.d.ts +4 -4
- package/types/Options/Interfaces/IEmitterLife.d.ts +3 -2
- package/types/Options/Interfaces/IEmitterSize.d.ts +2 -2
- package/types/ShapeManager.d.ts +1 -1
- package/types/Shapes/Circle/CircleShape.d.ts +2 -2
- package/types/Shapes/Square/SquareShape.d.ts +2 -2
- package/types/index.d.ts +6 -6
- package/types/types.d.ts +2 -2
- package/umd/EmitterInstance.js +103 -115
- package/umd/Emitters.js +33 -29
- package/umd/Options/Classes/Emitter.js +9 -9
- package/umd/Options/Classes/EmitterLife.js +5 -4
- package/umd/index.js +32 -35
package/cjs/EmitterInstance.js
CHANGED
|
@@ -2,53 +2,121 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmitterInstance = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
5
|
+
const Emitter_js_1 = require("./Options/Classes/Emitter.js");
|
|
6
|
+
const EmitterSize_js_1 = require("./Options/Classes/EmitterSize.js");
|
|
7
7
|
class EmitterInstance {
|
|
8
8
|
constructor(engine, emitters, container, options, position) {
|
|
9
|
-
var _a, _b, _c, _d, _e, _f, _g;
|
|
10
|
-
var _h;
|
|
11
9
|
this.emitters = emitters;
|
|
12
10
|
this.container = container;
|
|
11
|
+
this._calcPosition = () => {
|
|
12
|
+
return (0, engine_1.calcPositionOrRandomFromSizeRanged)({
|
|
13
|
+
size: this.container.canvas.size,
|
|
14
|
+
position: this.options.position,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
this._destroy = () => {
|
|
18
|
+
this.emitters.removeEmitter(this);
|
|
19
|
+
this._engine.dispatchEvent("emitterDestroyed", {
|
|
20
|
+
container: this.container,
|
|
21
|
+
data: {
|
|
22
|
+
emitter: this,
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
this._emit = () => {
|
|
27
|
+
if (this._paused) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
const quantity = (0, engine_1.getRangeValue)(this.options.rate.quantity);
|
|
31
|
+
this._emitParticles(quantity);
|
|
32
|
+
};
|
|
33
|
+
this._emitParticles = (quantity) => {
|
|
34
|
+
const position = this.getPosition(), size = this.getSize(), singleParticlesOptions = (0, engine_1.itemFromSingleOrMultiple)(this._particlesOptions);
|
|
35
|
+
for (let i = 0; i < quantity; i++) {
|
|
36
|
+
const particlesOptions = (0, engine_1.deepExtend)({}, singleParticlesOptions);
|
|
37
|
+
if (this.spawnColor) {
|
|
38
|
+
const hslAnimation = this.options.spawnColor?.animation;
|
|
39
|
+
if (hslAnimation) {
|
|
40
|
+
this.spawnColor.h = this._setColorAnimation(hslAnimation.h, this.spawnColor.h, 360);
|
|
41
|
+
this.spawnColor.s = this._setColorAnimation(hslAnimation.s, this.spawnColor.s, 100);
|
|
42
|
+
this.spawnColor.l = this._setColorAnimation(hslAnimation.l, this.spawnColor.l, 100);
|
|
43
|
+
}
|
|
44
|
+
if (!particlesOptions.color) {
|
|
45
|
+
particlesOptions.color = {
|
|
46
|
+
value: this.spawnColor,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
particlesOptions.color.value = this.spawnColor;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if (!position) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const pPosition = this._shape?.randomPosition(position, size, this.fill) ?? position;
|
|
57
|
+
this.container.particles.addParticle(pPosition, particlesOptions);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
this._prepareToDie = () => {
|
|
61
|
+
if (this._paused) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const duration = this.options.life?.duration !== undefined ? (0, engine_1.getRangeValue)(this.options.life.duration) : undefined;
|
|
65
|
+
if (this.container.retina.reduceFactor &&
|
|
66
|
+
(this._lifeCount > 0 || this._immortal) &&
|
|
67
|
+
duration !== undefined &&
|
|
68
|
+
duration > 0) {
|
|
69
|
+
this._duration = duration * 1000;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
this._setColorAnimation = (animation, initValue, maxValue) => {
|
|
73
|
+
const container = this.container;
|
|
74
|
+
if (!animation.enable) {
|
|
75
|
+
return initValue;
|
|
76
|
+
}
|
|
77
|
+
const colorOffset = (0, engine_1.randomInRange)(animation.offset), delay = (0, engine_1.getRangeValue)(this.options.rate.delay), emitFactor = (1000 * delay) / container.retina.reduceFactor, colorSpeed = (0, engine_1.getRangeValue)(animation.speed ?? 0);
|
|
78
|
+
return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * 3.6) % maxValue;
|
|
79
|
+
};
|
|
13
80
|
this._engine = engine;
|
|
14
81
|
this._currentDuration = 0;
|
|
15
82
|
this._currentEmitDelay = 0;
|
|
16
83
|
this._currentSpawnDelay = 0;
|
|
17
84
|
this._initialPosition = position;
|
|
18
|
-
if (options instanceof
|
|
85
|
+
if (options instanceof Emitter_js_1.Emitter) {
|
|
19
86
|
this.options = options;
|
|
20
87
|
}
|
|
21
88
|
else {
|
|
22
|
-
this.options = new
|
|
89
|
+
this.options = new Emitter_js_1.Emitter();
|
|
23
90
|
this.options.load(options);
|
|
24
91
|
}
|
|
25
|
-
this._spawnDelay = (((
|
|
26
|
-
this.position =
|
|
92
|
+
this._spawnDelay = ((0, engine_1.getRangeValue)(this.options.life.delay ?? 0) * 1000) / this.container.retina.reduceFactor;
|
|
93
|
+
this.position = this._initialPosition ?? this._calcPosition();
|
|
27
94
|
this.name = this.options.name;
|
|
28
|
-
this._shape =
|
|
95
|
+
this._shape = this._engine.emitterShapeManager?.getShape(this.options.shape);
|
|
29
96
|
this.fill = this.options.fill;
|
|
30
97
|
this._firstSpawn = !this.options.life.wait;
|
|
31
98
|
this._startParticlesAdded = false;
|
|
32
99
|
let particlesOptions = (0, engine_1.deepExtend)({}, this.options.particles);
|
|
33
|
-
particlesOptions
|
|
34
|
-
|
|
35
|
-
|
|
100
|
+
particlesOptions ??= {};
|
|
101
|
+
particlesOptions.move ??= {};
|
|
102
|
+
particlesOptions.move.direction ??= this.options.direction;
|
|
36
103
|
if (this.options.spawnColor) {
|
|
37
104
|
this.spawnColor = (0, engine_1.rangeColorToHsl)(this.options.spawnColor);
|
|
38
105
|
}
|
|
39
106
|
this._paused = !this.options.autoPlay;
|
|
40
107
|
this._particlesOptions = particlesOptions;
|
|
41
108
|
this.size =
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
109
|
+
this.options.size ??
|
|
110
|
+
(() => {
|
|
111
|
+
const size = new EmitterSize_js_1.EmitterSize();
|
|
112
|
+
size.load({
|
|
113
|
+
height: 0,
|
|
114
|
+
mode: "percent",
|
|
115
|
+
width: 0,
|
|
116
|
+
});
|
|
117
|
+
return size;
|
|
118
|
+
})();
|
|
119
|
+
this._lifeCount = this.options.life.count ?? -1;
|
|
52
120
|
this._immortal = this._lifeCount <= 0;
|
|
53
121
|
this._engine.dispatchEvent("emitterCreated", {
|
|
54
122
|
container,
|
|
@@ -91,14 +159,7 @@ class EmitterInstance {
|
|
|
91
159
|
};
|
|
92
160
|
}
|
|
93
161
|
}
|
|
94
|
-
return
|
|
95
|
-
width: this.size.mode === "percent"
|
|
96
|
-
? (container.canvas.size.width * this.size.width) / 100
|
|
97
|
-
: this.size.width,
|
|
98
|
-
height: this.size.mode === "percent"
|
|
99
|
-
? (container.canvas.size.height * this.size.height) / 100
|
|
100
|
-
: this.size.height,
|
|
101
|
-
};
|
|
162
|
+
return (0, engine_1.getSize)(this.size, container.canvas.size);
|
|
102
163
|
}
|
|
103
164
|
pause() {
|
|
104
165
|
if (this._paused) {
|
|
@@ -107,13 +168,12 @@ class EmitterInstance {
|
|
|
107
168
|
delete this._emitDelay;
|
|
108
169
|
}
|
|
109
170
|
play() {
|
|
110
|
-
var _a;
|
|
111
171
|
if (this._paused) {
|
|
112
172
|
return;
|
|
113
173
|
}
|
|
114
174
|
if (!(this.container.retina.reduceFactor &&
|
|
115
175
|
(this._lifeCount > 0 || this._immortal || !this.options.life.count) &&
|
|
116
|
-
(this._firstSpawn || this._currentSpawnDelay >= (
|
|
176
|
+
(this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? 0)))) {
|
|
117
177
|
return;
|
|
118
178
|
}
|
|
119
179
|
if (this._emitDelay === undefined) {
|
|
@@ -121,7 +181,7 @@ class EmitterInstance {
|
|
|
121
181
|
this._emitDelay = (1000 * delay) / this.container.retina.reduceFactor;
|
|
122
182
|
}
|
|
123
183
|
if (this._lifeCount > 0 || this._immortal) {
|
|
124
|
-
this.
|
|
184
|
+
this._prepareToDie();
|
|
125
185
|
}
|
|
126
186
|
}
|
|
127
187
|
resize() {
|
|
@@ -129,21 +189,20 @@ class EmitterInstance {
|
|
|
129
189
|
this.position =
|
|
130
190
|
initialPosition && (0, engine_1.isPointInside)(initialPosition, this.container.canvas.size, engine_1.Vector.origin)
|
|
131
191
|
? initialPosition
|
|
132
|
-
: this.
|
|
192
|
+
: this._calcPosition();
|
|
133
193
|
}
|
|
134
194
|
update(delta) {
|
|
135
|
-
var _a, _b, _c;
|
|
136
195
|
if (this._paused) {
|
|
137
196
|
return;
|
|
138
197
|
}
|
|
139
198
|
if (this._firstSpawn) {
|
|
140
199
|
this._firstSpawn = false;
|
|
141
|
-
this._currentSpawnDelay =
|
|
142
|
-
this._currentEmitDelay =
|
|
200
|
+
this._currentSpawnDelay = this._spawnDelay ?? 0;
|
|
201
|
+
this._currentEmitDelay = this._emitDelay ?? 0;
|
|
143
202
|
}
|
|
144
203
|
if (!this._startParticlesAdded) {
|
|
145
204
|
this._startParticlesAdded = true;
|
|
146
|
-
this.
|
|
205
|
+
this._emitParticles(this.options.startCount);
|
|
147
206
|
}
|
|
148
207
|
if (this._duration !== undefined) {
|
|
149
208
|
this._currentDuration += delta.value;
|
|
@@ -156,11 +215,12 @@ class EmitterInstance {
|
|
|
156
215
|
this._lifeCount--;
|
|
157
216
|
}
|
|
158
217
|
if (this._lifeCount > 0 || this._immortal) {
|
|
159
|
-
this.position = this.
|
|
160
|
-
this._spawnDelay =
|
|
218
|
+
this.position = this._calcPosition();
|
|
219
|
+
this._spawnDelay =
|
|
220
|
+
((0, engine_1.getRangeValue)(this.options.life.delay ?? 0) * 1000) / this.container.retina.reduceFactor;
|
|
161
221
|
}
|
|
162
222
|
else {
|
|
163
|
-
this.
|
|
223
|
+
this._destroy();
|
|
164
224
|
}
|
|
165
225
|
this._currentDuration -= this._duration;
|
|
166
226
|
delete this._duration;
|
|
@@ -180,82 +240,10 @@ class EmitterInstance {
|
|
|
180
240
|
if (this._emitDelay !== undefined) {
|
|
181
241
|
this._currentEmitDelay += delta.value;
|
|
182
242
|
if (this._currentEmitDelay >= this._emitDelay) {
|
|
183
|
-
this.
|
|
243
|
+
this._emit();
|
|
184
244
|
this._currentEmitDelay -= this._emitDelay;
|
|
185
245
|
}
|
|
186
246
|
}
|
|
187
247
|
}
|
|
188
|
-
calcPosition() {
|
|
189
|
-
return (0, engine_1.calcPositionOrRandomFromSizeRanged)({
|
|
190
|
-
size: this.container.canvas.size,
|
|
191
|
-
position: this.options.position,
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
destroy() {
|
|
195
|
-
this.emitters.removeEmitter(this);
|
|
196
|
-
this._engine.dispatchEvent("emitterDestroyed", {
|
|
197
|
-
container: this.container,
|
|
198
|
-
data: {
|
|
199
|
-
emitter: this,
|
|
200
|
-
},
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
emit() {
|
|
204
|
-
if (this._paused) {
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
207
|
-
const quantity = (0, engine_1.getRangeValue)(this.options.rate.quantity);
|
|
208
|
-
this.emitParticles(quantity);
|
|
209
|
-
}
|
|
210
|
-
emitParticles(quantity) {
|
|
211
|
-
var _a, _b, _c;
|
|
212
|
-
const position = this.getPosition(), size = this.getSize(), singleParticlesOptions = (0, engine_1.itemFromSingleOrMultiple)(this._particlesOptions);
|
|
213
|
-
for (let i = 0; i < quantity; i++) {
|
|
214
|
-
const particlesOptions = (0, engine_1.deepExtend)({}, singleParticlesOptions);
|
|
215
|
-
if (this.spawnColor) {
|
|
216
|
-
const hslAnimation = (_a = this.options.spawnColor) === null || _a === void 0 ? void 0 : _a.animation;
|
|
217
|
-
if (hslAnimation) {
|
|
218
|
-
this.spawnColor.h = this.setColorAnimation(hslAnimation.h, this.spawnColor.h, 360);
|
|
219
|
-
this.spawnColor.s = this.setColorAnimation(hslAnimation.s, this.spawnColor.s, 100);
|
|
220
|
-
this.spawnColor.l = this.setColorAnimation(hslAnimation.l, this.spawnColor.l, 100);
|
|
221
|
-
}
|
|
222
|
-
if (!particlesOptions.color) {
|
|
223
|
-
particlesOptions.color = {
|
|
224
|
-
value: this.spawnColor,
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
particlesOptions.color.value = this.spawnColor;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
if (!position) {
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const pPosition = (_c = (_b = this._shape) === null || _b === void 0 ? void 0 : _b.randomPosition(position, size, this.fill)) !== null && _c !== void 0 ? _c : position;
|
|
235
|
-
this.container.particles.addParticle(pPosition, particlesOptions);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
prepareToDie() {
|
|
239
|
-
var _a;
|
|
240
|
-
if (this._paused) {
|
|
241
|
-
return;
|
|
242
|
-
}
|
|
243
|
-
const duration = (_a = this.options.life) === null || _a === void 0 ? void 0 : _a.duration;
|
|
244
|
-
if (this.container.retina.reduceFactor &&
|
|
245
|
-
(this._lifeCount > 0 || this._immortal) &&
|
|
246
|
-
duration !== undefined &&
|
|
247
|
-
duration > 0) {
|
|
248
|
-
this._duration = duration * 1000;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
setColorAnimation(animation, initValue, maxValue) {
|
|
252
|
-
var _a;
|
|
253
|
-
const container = this.container;
|
|
254
|
-
if (!animation.enable) {
|
|
255
|
-
return initValue;
|
|
256
|
-
}
|
|
257
|
-
const colorOffset = (0, engine_1.randomInRange)(animation.offset), delay = (0, engine_1.getRangeValue)(this.options.rate.delay), emitFactor = (1000 * delay) / container.retina.reduceFactor, colorSpeed = (0, engine_1.getRangeValue)((_a = animation.speed) !== null && _a !== void 0 ? _a : 0);
|
|
258
|
-
return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * 3.6) % maxValue;
|
|
259
|
-
}
|
|
260
248
|
}
|
|
261
249
|
exports.EmitterInstance = EmitterInstance;
|
package/cjs/Emitters.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.Emitters = void 0;
|
|
13
4
|
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
5
|
+
const Emitter_js_1 = require("./Options/Classes/Emitter.js");
|
|
6
|
+
const EmitterInstance_js_1 = require("./EmitterInstance.js");
|
|
16
7
|
class Emitters {
|
|
17
8
|
constructor(engine, container) {
|
|
18
9
|
this.container = container;
|
|
@@ -26,7 +17,7 @@ class Emitters {
|
|
|
26
17
|
},
|
|
27
18
|
value: [],
|
|
28
19
|
};
|
|
29
|
-
container.getEmitter = (idxOrName) => idxOrName === undefined ||
|
|
20
|
+
container.getEmitter = (idxOrName) => idxOrName === undefined || (0, engine_1.isNumber)(idxOrName)
|
|
30
21
|
? this.array[idxOrName || 0]
|
|
31
22
|
: this.array.find((t) => t.name === idxOrName);
|
|
32
23
|
container.addEmitter = (options, position) => this.addEmitter(options, position);
|
|
@@ -50,56 +41,58 @@ class Emitters {
|
|
|
50
41
|
};
|
|
51
42
|
}
|
|
52
43
|
addEmitter(options, position) {
|
|
53
|
-
const emitterOptions = new
|
|
44
|
+
const emitterOptions = new Emitter_js_1.Emitter();
|
|
54
45
|
emitterOptions.load(options);
|
|
55
|
-
const emitter = new
|
|
46
|
+
const emitter = new EmitterInstance_js_1.EmitterInstance(this._engine, this, this.container, emitterOptions, position);
|
|
56
47
|
this.array.push(emitter);
|
|
57
48
|
return emitter;
|
|
58
49
|
}
|
|
59
50
|
handleClickMode(mode) {
|
|
60
51
|
const emitterOptions = this.emitters, modeEmitters = this.interactivityEmitters;
|
|
61
|
-
if (mode
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
emittersModeOptions.push((0, engine_1.itemFromArray)(modeEmitters.value, idx));
|
|
52
|
+
if (mode !== "emitter") {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
let emittersModeOptions;
|
|
56
|
+
if (modeEmitters && (0, engine_1.isArray)(modeEmitters.value)) {
|
|
57
|
+
if (modeEmitters.value.length > 0 && modeEmitters.random.enable) {
|
|
58
|
+
emittersModeOptions = [];
|
|
59
|
+
const usedIndexes = [];
|
|
60
|
+
for (let i = 0; i < modeEmitters.random.count; i++) {
|
|
61
|
+
const idx = (0, engine_1.arrayRandomIndex)(modeEmitters.value);
|
|
62
|
+
if (usedIndexes.includes(idx) && usedIndexes.length < modeEmitters.value.length) {
|
|
63
|
+
i--;
|
|
64
|
+
continue;
|
|
75
65
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
emittersModeOptions = modeEmitters.value;
|
|
66
|
+
usedIndexes.push(idx);
|
|
67
|
+
emittersModeOptions.push((0, engine_1.itemFromArray)(modeEmitters.value, idx));
|
|
79
68
|
}
|
|
80
69
|
}
|
|
81
70
|
else {
|
|
82
|
-
emittersModeOptions = modeEmitters
|
|
71
|
+
emittersModeOptions = modeEmitters.value;
|
|
83
72
|
}
|
|
84
|
-
const emittersOptions = emittersModeOptions !== null && emittersModeOptions !== void 0 ? emittersModeOptions : emitterOptions, ePosition = this.container.interactivity.mouse.clickPosition;
|
|
85
|
-
(0, engine_1.executeOnSingleOrMultiple)(emittersOptions, (emitter) => {
|
|
86
|
-
this.addEmitter(emitter, ePosition);
|
|
87
|
-
});
|
|
88
73
|
}
|
|
74
|
+
else {
|
|
75
|
+
emittersModeOptions = modeEmitters?.value;
|
|
76
|
+
}
|
|
77
|
+
const emittersOptions = emittersModeOptions ?? emitterOptions, ePosition = this.container.interactivity.mouse.clickPosition;
|
|
78
|
+
(0, engine_1.executeOnSingleOrMultiple)(emittersOptions, (emitter) => {
|
|
79
|
+
this.addEmitter(emitter, ePosition);
|
|
80
|
+
});
|
|
89
81
|
}
|
|
90
|
-
init() {
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
else {
|
|
100
|
-
this.addEmitter(this.emitters);
|
|
82
|
+
async init() {
|
|
83
|
+
this.emitters = this.container.actualOptions.emitters;
|
|
84
|
+
this.interactivityEmitters = this.container.actualOptions.interactivity.modes.emitters;
|
|
85
|
+
if (!this.emitters) {
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
if ((0, engine_1.isArray)(this.emitters)) {
|
|
89
|
+
for (const emitterOptions of this.emitters) {
|
|
90
|
+
this.addEmitter(emitterOptions);
|
|
101
91
|
}
|
|
102
|
-
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
this.addEmitter(this.emitters);
|
|
95
|
+
}
|
|
103
96
|
}
|
|
104
97
|
pause() {
|
|
105
98
|
for (const emitter of this.array) {
|
|
@@ -2,28 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Emitter = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
5
|
+
const EmitterLife_js_1 = require("./EmitterLife.js");
|
|
6
|
+
const EmitterRate_js_1 = require("./EmitterRate.js");
|
|
7
|
+
const EmitterSize_js_1 = require("./EmitterSize.js");
|
|
8
8
|
class Emitter {
|
|
9
9
|
constructor() {
|
|
10
10
|
this.autoPlay = true;
|
|
11
11
|
this.fill = true;
|
|
12
|
-
this.life = new
|
|
13
|
-
this.rate = new
|
|
12
|
+
this.life = new EmitterLife_js_1.EmitterLife();
|
|
13
|
+
this.rate = new EmitterRate_js_1.EmitterRate();
|
|
14
14
|
this.shape = "square";
|
|
15
15
|
this.startCount = 0;
|
|
16
16
|
}
|
|
17
17
|
load(data) {
|
|
18
|
-
if (data
|
|
18
|
+
if (!data) {
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
21
|
if (data.autoPlay !== undefined) {
|
|
22
22
|
this.autoPlay = data.autoPlay;
|
|
23
23
|
}
|
|
24
24
|
if (data.size !== undefined) {
|
|
25
|
-
if (this.size
|
|
26
|
-
this.size = new
|
|
25
|
+
if (!this.size) {
|
|
26
|
+
this.size = new EmitterSize_js_1.EmitterSize();
|
|
27
27
|
}
|
|
28
28
|
this.size.load(data.size);
|
|
29
29
|
}
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmitterLife = void 0;
|
|
4
|
+
const engine_1 = require("@tsparticles/engine");
|
|
4
5
|
class EmitterLife {
|
|
5
6
|
constructor() {
|
|
6
7
|
this.wait = false;
|
|
7
8
|
}
|
|
8
9
|
load(data) {
|
|
9
|
-
if (data
|
|
10
|
+
if (!data) {
|
|
10
11
|
return;
|
|
11
12
|
}
|
|
12
13
|
if (data.count !== undefined) {
|
|
13
14
|
this.count = data.count;
|
|
14
15
|
}
|
|
15
16
|
if (data.delay !== undefined) {
|
|
16
|
-
this.delay = data.delay;
|
|
17
|
+
this.delay = (0, engine_1.setRangeValue)(data.delay);
|
|
17
18
|
}
|
|
18
19
|
if (data.duration !== undefined) {
|
|
19
|
-
this.duration = data.duration;
|
|
20
|
+
this.duration = (0, engine_1.setRangeValue)(data.duration);
|
|
20
21
|
}
|
|
21
22
|
if (data.wait !== undefined) {
|
|
22
23
|
this.wait = data.wait;
|
|
@@ -18,7 +18,7 @@ class CircleShape {
|
|
|
18
18
|
else {
|
|
19
19
|
return -theta;
|
|
20
20
|
}
|
|
21
|
-
}, radius = (x, y, theta) => (x * y) / Math.sqrt(
|
|
21
|
+
}, radius = (x, y, theta) => (x * y) / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2), [a, b] = [size.width / 2, size.height / 2], randomTheta = generateTheta(a, b), maxRadius = radius(a, b, randomTheta), randomRadius = fill ? maxRadius * Math.sqrt((0, engine_1.getRandom)()) : maxRadius;
|
|
22
22
|
return {
|
|
23
23
|
x: position.x + randomRadius * Math.cos(randomTheta),
|
|
24
24
|
y: position.y + randomRadius * Math.sin(randomTheta),
|