@tsparticles/plugin-emitters 3.9.0 → 4.0.0-alpha.0
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/214.min.js +2 -0
- package/214.min.js.LICENSE.txt +1 -0
- package/921.min.js +2 -0
- package/921.min.js.LICENSE.txt +1 -0
- package/browser/EmitterInstance.js +12 -13
- package/browser/Emitters.js +9 -8
- package/browser/EmittersPlugin.js +19 -32
- package/browser/Options/Classes/Emitter.js +2 -6
- package/browser/ShapeManager.js +0 -3
- package/browser/index.js +10 -18
- package/cjs/EmitterContainer.js +1 -2
- package/cjs/EmitterInstance.js +34 -39
- package/cjs/EmitterShapeBase.js +1 -5
- package/cjs/Emitters.js +21 -24
- package/cjs/EmittersEngine.js +1 -2
- package/cjs/EmittersPlugin.js +31 -48
- package/cjs/Enums/EmitterClickMode.js +2 -5
- package/cjs/IEmitterShape.js +1 -2
- package/cjs/IEmitterShapeGenerator.js +1 -2
- package/cjs/IRandomPositionData.js +1 -2
- package/cjs/Options/Classes/Emitter.js +16 -24
- package/cjs/Options/Classes/EmitterLife.js +5 -9
- package/cjs/Options/Classes/EmitterRate.js +5 -9
- package/cjs/Options/Classes/EmitterShape.js +6 -10
- package/cjs/Options/Classes/EmitterShapeReplace.js +3 -7
- package/cjs/Options/Classes/EmitterSize.js +4 -8
- package/cjs/Options/Interfaces/IEmitter.js +1 -2
- package/cjs/Options/Interfaces/IEmitterLife.js +1 -2
- package/cjs/Options/Interfaces/IEmitterRate.js +1 -2
- package/cjs/Options/Interfaces/IEmitterShape.js +1 -2
- package/cjs/Options/Interfaces/IEmitterShapeReplace.js +1 -2
- package/cjs/Options/Interfaces/IEmitterSize.js +1 -2
- package/cjs/ShapeManager.js +1 -8
- package/cjs/index.js +12 -37
- package/cjs/types.js +1 -2
- package/dist_browser_EmittersPlugin_js.js +110 -0
- package/dist_browser_ShapeManager_js.js +30 -0
- package/esm/EmitterInstance.js +12 -13
- package/esm/Emitters.js +9 -8
- package/esm/EmittersPlugin.js +19 -32
- package/esm/Options/Classes/Emitter.js +2 -6
- package/esm/ShapeManager.js +0 -3
- package/esm/index.js +10 -18
- package/package.json +4 -3
- package/report.html +5 -4
- package/tsparticles.plugin.emitters.js +215 -126
- package/tsparticles.plugin.emitters.min.js +1 -1
- package/tsparticles.plugin.emitters.min.js.LICENSE.txt +1 -1
- package/types/Options/Classes/EmitterShape.d.ts +1 -1
- package/types/Options/Classes/EmitterShapeReplace.d.ts +1 -1
- package/types/ShapeManager.d.ts +0 -3
- package/types/index.d.ts +7 -7
- package/umd/EmitterInstance.js +13 -14
- package/umd/Emitters.js +9 -8
- package/umd/EmittersPlugin.js +19 -32
- package/umd/Options/Classes/Emitter.js +2 -6
- package/umd/ShapeManager.js +0 -3
- package/umd/index.js +34 -19
package/umd/EmitterInstance.js
CHANGED
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const Emitter_js_1 = require("./Options/Classes/Emitter.js");
|
|
15
15
|
const EmitterSize_js_1 = require("./Options/Classes/EmitterSize.js");
|
|
16
|
-
const
|
|
16
|
+
const defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1;
|
|
17
17
|
function setParticlesOptionsColor(particlesOptions, color) {
|
|
18
18
|
if (particlesOptions.color) {
|
|
19
19
|
particlesOptions.color.value = color;
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
if (this._paused) {
|
|
46
46
|
return;
|
|
47
47
|
}
|
|
48
|
-
const duration = this.options.life
|
|
48
|
+
const duration = this.options.life.duration !== undefined ? (0, engine_1.getRangeValue)(this.options.life.duration) : undefined, minDuration = 0, minLifeCount = 0;
|
|
49
49
|
if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
|
|
50
50
|
this._duration = duration * engine_1.millisecondsToSeconds;
|
|
51
51
|
}
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
if (!animation.enable) {
|
|
56
56
|
return initValue;
|
|
57
57
|
}
|
|
58
|
-
const colorOffset = (0, engine_1.
|
|
58
|
+
const colorOffset = (0, engine_1.randomInRangeValue)(animation.offset), delay = (0, engine_1.getRangeValue)(this.options.rate.delay), emitFactor = container.retina.reduceFactor
|
|
59
59
|
? (delay * engine_1.millisecondsToSeconds) / container.retina.reduceFactor
|
|
60
|
-
: Infinity,
|
|
60
|
+
: Infinity, colorSpeed = (0, engine_1.getRangeValue)(animation.speed);
|
|
61
61
|
return (initValue + (colorSpeed * container.fpsLimit) / emitFactor + colorOffset * factor) % maxValue;
|
|
62
62
|
};
|
|
63
63
|
this._engine = engine;
|
|
@@ -81,8 +81,7 @@
|
|
|
81
81
|
this.fill = this.options.fill;
|
|
82
82
|
this._firstSpawn = !this.options.life.wait;
|
|
83
83
|
this._startParticlesAdded = false;
|
|
84
|
-
|
|
85
|
-
particlesOptions ??= {};
|
|
84
|
+
const particlesOptions = (0, engine_1.deepExtend)({}, this.options.particles);
|
|
86
85
|
particlesOptions.move ??= {};
|
|
87
86
|
particlesOptions.move.direction ??= this.options.direction;
|
|
88
87
|
if (this.options.spawnColor) {
|
|
@@ -95,7 +94,7 @@
|
|
|
95
94
|
this._lifeCount = this.options.life.count ?? defaultLifeCount;
|
|
96
95
|
this._immortal = this._lifeCount <= minLifeCount;
|
|
97
96
|
if (this.options.domId) {
|
|
98
|
-
const element =
|
|
97
|
+
const element = (0, engine_1.safeDocument)().getElementById(this.options.domId);
|
|
99
98
|
if (element) {
|
|
100
99
|
this._mutationObserver = new MutationObserver(() => {
|
|
101
100
|
this.resize();
|
|
@@ -229,12 +228,12 @@
|
|
|
229
228
|
_calcPosition() {
|
|
230
229
|
const container = this.container;
|
|
231
230
|
if (this.options.domId) {
|
|
232
|
-
const element =
|
|
231
|
+
const element = (0, engine_1.safeDocument)().getElementById(this.options.domId);
|
|
233
232
|
if (element) {
|
|
234
233
|
const elRect = element.getBoundingClientRect(), pxRatio = container.retina.pixelRatio;
|
|
235
234
|
return {
|
|
236
|
-
x: (elRect.x + elRect.width * half) * pxRatio,
|
|
237
|
-
y: (elRect.y + elRect.height * half) * pxRatio,
|
|
235
|
+
x: (elRect.x + elRect.width * engine_1.half) * pxRatio,
|
|
236
|
+
y: (elRect.y + elRect.height * engine_1.half) * pxRatio,
|
|
238
237
|
};
|
|
239
238
|
}
|
|
240
239
|
}
|
|
@@ -246,7 +245,7 @@
|
|
|
246
245
|
_calcSize() {
|
|
247
246
|
const container = this.container;
|
|
248
247
|
if (this.options.domId) {
|
|
249
|
-
const element =
|
|
248
|
+
const element = (0, engine_1.safeDocument)().getElementById(this.options.domId);
|
|
250
249
|
if (element) {
|
|
251
250
|
const elRect = element.getBoundingClientRect();
|
|
252
251
|
return {
|
|
@@ -282,9 +281,9 @@
|
|
|
282
281
|
const hslAnimation = this.options.spawnColor?.animation;
|
|
283
282
|
if (hslAnimation) {
|
|
284
283
|
const maxValues = {
|
|
285
|
-
h:
|
|
286
|
-
s:
|
|
287
|
-
l:
|
|
284
|
+
h: engine_1.hMax,
|
|
285
|
+
s: engine_1.sMax,
|
|
286
|
+
l: engine_1.lMax,
|
|
288
287
|
}, colorFactor = 3.6;
|
|
289
288
|
this.spawnColor.h = this._setColorAnimation(hslAnimation.h, this.spawnColor.h, maxValues.h, colorFactor);
|
|
290
289
|
this.spawnColor.s = this._setColorAnimation(hslAnimation.s, this.spawnColor.s, maxValues.s);
|
package/umd/Emitters.js
CHANGED
|
@@ -60,12 +60,12 @@
|
|
|
60
60
|
return emitter;
|
|
61
61
|
}
|
|
62
62
|
handleClickMode(mode) {
|
|
63
|
-
const
|
|
63
|
+
const modeEmitters = this.interactivityEmitters;
|
|
64
64
|
if (mode !== EmitterClickMode_js_1.EmitterClickMode.emitter) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
let emittersModeOptions;
|
|
68
|
-
if (
|
|
68
|
+
if ((0, engine_1.isArray)(modeEmitters.value)) {
|
|
69
69
|
const minLength = 0;
|
|
70
70
|
if (modeEmitters.value.length > minLength && modeEmitters.random.enable) {
|
|
71
71
|
emittersModeOptions = [];
|
|
@@ -77,7 +77,11 @@
|
|
|
77
77
|
continue;
|
|
78
78
|
}
|
|
79
79
|
usedIndexes.push(idx);
|
|
80
|
-
|
|
80
|
+
const selectedOptions = (0, engine_1.itemFromArray)(modeEmitters.value, idx);
|
|
81
|
+
if (!selectedOptions) {
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
emittersModeOptions.push(selectedOptions);
|
|
81
85
|
}
|
|
82
86
|
}
|
|
83
87
|
else {
|
|
@@ -85,9 +89,9 @@
|
|
|
85
89
|
}
|
|
86
90
|
}
|
|
87
91
|
else {
|
|
88
|
-
emittersModeOptions = modeEmitters
|
|
92
|
+
emittersModeOptions = modeEmitters.value;
|
|
89
93
|
}
|
|
90
|
-
const emittersOptions = emittersModeOptions
|
|
94
|
+
const emittersOptions = emittersModeOptions, ePosition = this.container.interactivity.mouse.clickPosition;
|
|
91
95
|
void (0, engine_1.executeOnSingleOrMultiple)(emittersOptions, async (emitter) => {
|
|
92
96
|
await this.addEmitter(emitter, ePosition);
|
|
93
97
|
});
|
|
@@ -95,9 +99,6 @@
|
|
|
95
99
|
async init() {
|
|
96
100
|
this.emitters = this.container.actualOptions.emitters;
|
|
97
101
|
this.interactivityEmitters = this.container.actualOptions.interactivity.modes.emitters;
|
|
98
|
-
if (!this.emitters) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
102
|
if ((0, engine_1.isArray)(this.emitters)) {
|
|
102
103
|
for (const emitterOptions of this.emitters) {
|
|
103
104
|
await this.addEmitter(emitterOptions);
|
package/umd/EmittersPlugin.js
CHANGED
|
@@ -50,42 +50,29 @@
|
|
|
50
50
|
}
|
|
51
51
|
else {
|
|
52
52
|
const emitterMode = interactivityEmitters;
|
|
53
|
-
if (emitterMode.value
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}),
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
const tmp = new Emitter_js_1.Emitter();
|
|
70
|
-
tmp.load(emitterMode.value);
|
|
71
|
-
options.interactivity.modes.emitters = {
|
|
72
|
-
random: {
|
|
73
|
-
count: emitterMode.random.count ?? defaultCount,
|
|
74
|
-
enable: emitterMode.random.enable ?? false,
|
|
75
|
-
},
|
|
76
|
-
value: tmp,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
53
|
+
if ((0, engine_1.isArray)(emitterMode.value)) {
|
|
54
|
+
options.interactivity.modes.emitters = {
|
|
55
|
+
random: {
|
|
56
|
+
count: emitterMode.random.count,
|
|
57
|
+
enable: emitterMode.random.enable,
|
|
58
|
+
},
|
|
59
|
+
value: emitterMode.value.map(s => {
|
|
60
|
+
const tmp = new Emitter_js_1.Emitter();
|
|
61
|
+
tmp.load(s);
|
|
62
|
+
return tmp;
|
|
63
|
+
}),
|
|
64
|
+
};
|
|
79
65
|
}
|
|
80
66
|
else {
|
|
81
|
-
const
|
|
67
|
+
const tmp = new Emitter_js_1.Emitter();
|
|
68
|
+
tmp.load(emitterMode.value);
|
|
69
|
+
options.interactivity.modes.emitters = {
|
|
82
70
|
random: {
|
|
83
|
-
count:
|
|
84
|
-
enable:
|
|
71
|
+
count: emitterMode.random.count,
|
|
72
|
+
enable: emitterMode.random.enable,
|
|
85
73
|
},
|
|
86
|
-
value:
|
|
87
|
-
}
|
|
88
|
-
emitterOptions.value.load(interactivityEmitters);
|
|
74
|
+
value: tmp,
|
|
75
|
+
};
|
|
89
76
|
}
|
|
90
77
|
}
|
|
91
78
|
}
|
|
@@ -32,9 +32,7 @@
|
|
|
32
32
|
this.autoPlay = data.autoPlay;
|
|
33
33
|
}
|
|
34
34
|
if (data.size !== undefined) {
|
|
35
|
-
|
|
36
|
-
this.size = new EmitterSize_js_1.EmitterSize();
|
|
37
|
-
}
|
|
35
|
+
this.size ??= new EmitterSize_js_1.EmitterSize();
|
|
38
36
|
this.size.load(data.size);
|
|
39
37
|
}
|
|
40
38
|
if (data.direction !== undefined) {
|
|
@@ -61,9 +59,7 @@
|
|
|
61
59
|
}
|
|
62
60
|
}
|
|
63
61
|
if (data.spawnColor !== undefined) {
|
|
64
|
-
|
|
65
|
-
this.spawnColor = new engine_1.AnimatableColor();
|
|
66
|
-
}
|
|
62
|
+
this.spawnColor ??= new engine_1.AnimatableColor();
|
|
67
63
|
this.spawnColor.load(data.spawnColor);
|
|
68
64
|
}
|
|
69
65
|
if (data.startCount !== undefined) {
|
package/umd/ShapeManager.js
CHANGED
|
@@ -12,9 +12,6 @@
|
|
|
12
12
|
exports.ShapeManager = void 0;
|
|
13
13
|
const shapeGeneratorss = new Map();
|
|
14
14
|
class ShapeManager {
|
|
15
|
-
constructor(engine) {
|
|
16
|
-
this._engine = engine;
|
|
17
|
-
}
|
|
18
15
|
addShapeGenerator(name, generator) {
|
|
19
16
|
if (!this.getShapeGenerator(name)) {
|
|
20
17
|
shapeGeneratorss.set(name, generator);
|
package/umd/index.js
CHANGED
|
@@ -9,6 +9,28 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
9
9
|
if (k2 === undefined) k2 = k;
|
|
10
10
|
o[k2] = m[k];
|
|
11
11
|
}));
|
|
12
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
13
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
14
|
+
}) : function(o, v) {
|
|
15
|
+
o["default"] = v;
|
|
16
|
+
});
|
|
17
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
18
|
+
var ownKeys = function(o) {
|
|
19
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
20
|
+
var ar = [];
|
|
21
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
22
|
+
return ar;
|
|
23
|
+
};
|
|
24
|
+
return ownKeys(o);
|
|
25
|
+
};
|
|
26
|
+
return function (mod) {
|
|
27
|
+
if (mod && mod.__esModule) return mod;
|
|
28
|
+
var result = {};
|
|
29
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
30
|
+
__setModuleDefault(result, mod);
|
|
31
|
+
return result;
|
|
32
|
+
};
|
|
33
|
+
})();
|
|
12
34
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
13
35
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
14
36
|
};
|
|
@@ -18,32 +40,25 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
18
40
|
if (v !== undefined) module.exports = v;
|
|
19
41
|
}
|
|
20
42
|
else if (typeof define === "function" && define.amd) {
|
|
21
|
-
define(["require", "exports", "./
|
|
43
|
+
define(["require", "exports", "./EmitterShapeBase.js", "./Enums/EmitterClickMode.js"], factory);
|
|
22
44
|
}
|
|
23
45
|
})(function (require, exports) {
|
|
24
46
|
"use strict";
|
|
47
|
+
var __syncRequire = typeof module === "object" && typeof module.exports === "object";
|
|
25
48
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
49
|
exports.loadEmittersPlugin = loadEmittersPlugin;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (!engine.addEmitterShapeGenerator) {
|
|
35
|
-
engine.addEmitterShapeGenerator = (name, generator) => {
|
|
36
|
-
engine.emitterShapeManager?.addShapeGenerator(name, generator);
|
|
50
|
+
function loadEmittersPlugin(engine) {
|
|
51
|
+
engine.checkVersion("4.0.0-alpha.0");
|
|
52
|
+
engine.register(async (e) => {
|
|
53
|
+
const { ShapeManager } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./ShapeManager.js"))) : new Promise((resolve_1, reject_1) => { require(["./ShapeManager.js"], resolve_1, reject_1); }).then(__importStar)), { EmittersPlugin } = await (__syncRequire ? Promise.resolve().then(() => __importStar(require("./EmittersPlugin.js"))) : new Promise((resolve_2, reject_2) => { require(["./EmittersPlugin.js"], resolve_2, reject_2); }).then(__importStar));
|
|
54
|
+
e.emitterShapeManager ??= new ShapeManager();
|
|
55
|
+
e.addEmitterShapeGenerator ??= (name, generator) => {
|
|
56
|
+
e.emitterShapeManager?.addShapeGenerator(name, generator);
|
|
37
57
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
58
|
+
const plugin = new EmittersPlugin(e);
|
|
59
|
+
e.addPlugin(plugin);
|
|
60
|
+
});
|
|
41
61
|
}
|
|
42
|
-
__exportStar(require("./EmitterContainer.js"), exports);
|
|
43
62
|
__exportStar(require("./EmitterShapeBase.js"), exports);
|
|
44
|
-
__exportStar(require("./EmittersEngine.js"), exports);
|
|
45
|
-
__exportStar(require("./IEmitterShape.js"), exports);
|
|
46
|
-
__exportStar(require("./IEmitterShapeGenerator.js"), exports);
|
|
47
63
|
__exportStar(require("./Enums/EmitterClickMode.js"), exports);
|
|
48
|
-
__exportStar(require("./IRandomPositionData.js"), exports);
|
|
49
64
|
});
|