@tsparticles/plugin-emitters 3.3.0 → 3.5.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/browser/EmitterInstance.js +3 -3
- package/browser/Emitters.js +6 -3
- package/browser/EmittersPlugin.js +8 -7
- package/browser/Enums/EmitterClickMode.js +4 -1
- package/browser/Options/Classes/Emitter.js +1 -1
- package/browser/Options/Classes/EmitterSize.js +2 -1
- package/browser/index.js +3 -2
- package/cjs/EmitterInstance.js +2 -2
- package/cjs/Emitters.js +7 -4
- package/cjs/EmittersPlugin.js +8 -7
- package/cjs/Enums/EmitterClickMode.js +5 -0
- package/cjs/Options/Classes/Emitter.js +1 -1
- package/cjs/Options/Classes/EmitterSize.js +2 -1
- package/cjs/index.js +5 -5
- package/esm/EmitterInstance.js +3 -3
- package/esm/Emitters.js +6 -3
- package/esm/EmittersPlugin.js +8 -7
- package/esm/Enums/EmitterClickMode.js +4 -1
- package/esm/Options/Classes/Emitter.js +1 -1
- package/esm/Options/Classes/EmitterSize.js +2 -1
- package/esm/index.js +3 -2
- package/package.json +2 -2
- package/report.html +1 -1
- package/tsparticles.plugin.emitters.js +112 -200
- package/tsparticles.plugin.emitters.min.js +1 -1
- package/tsparticles.plugin.emitters.min.js.LICENSE.txt +1 -1
- package/types/Emitters.d.ts +2 -2
- package/types/EmittersPlugin.d.ts +1 -1
- package/types/Enums/EmitterClickMode.d.ts +1 -1
- package/umd/EmitterInstance.js +2 -2
- package/umd/Emitters.js +8 -29
- package/umd/EmittersPlugin.js +9 -32
- package/umd/Enums/EmitterClickMode.js +5 -0
- package/umd/Options/Classes/Emitter.js +1 -1
- package/umd/Options/Classes/EmitterSize.js +3 -2
- package/umd/index.js +6 -19
- package/121.min.js +0 -2
- package/121.min.js.LICENSE.txt +0 -1
- package/737.min.js +0 -2
- package/737.min.js.LICENSE.txt +0 -1
- package/800.min.js +0 -2
- package/800.min.js.LICENSE.txt +0 -1
- package/922.min.js +0 -2
- package/922.min.js.LICENSE.txt +0 -1
- package/dist_browser_EmitterInstance_js.js +0 -30
- package/dist_browser_EmittersPlugin_js.js +0 -90
- package/dist_browser_Emitters_js.js +0 -30
- package/dist_browser_ShapeManager_js.js +0 -30
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector, calcPositionOrRandomFromSizeRanged, deepExtend, getRangeValue, getSize, isPointInside, itemFromSingleOrMultiple, millisecondsToSeconds, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
|
|
1
|
+
import { PixelMode, Vector, calcPositionOrRandomFromSizeRanged, deepExtend, getRangeValue, getSize, isPointInside, itemFromSingleOrMultiple, millisecondsToSeconds, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
|
|
2
2
|
import { Emitter } from "./Options/Classes/Emitter.js";
|
|
3
3
|
import { EmitterSize } from "./Options/Classes/EmitterSize.js";
|
|
4
4
|
const half = 0.5, defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1;
|
|
@@ -235,7 +235,7 @@ export class EmitterInstance {
|
|
|
235
235
|
return {
|
|
236
236
|
width: elRect.width * container.retina.pixelRatio,
|
|
237
237
|
height: elRect.height * container.retina.pixelRatio,
|
|
238
|
-
mode:
|
|
238
|
+
mode: PixelMode.precise,
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -244,7 +244,7 @@ export class EmitterInstance {
|
|
|
244
244
|
const size = new EmitterSize();
|
|
245
245
|
size.load({
|
|
246
246
|
height: 0,
|
|
247
|
-
mode:
|
|
247
|
+
mode: PixelMode.percent,
|
|
248
248
|
width: 0,
|
|
249
249
|
});
|
|
250
250
|
return size;
|
package/browser/Emitters.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { arrayRandomIndex, executeOnSingleOrMultiple, isArray, isNumber, itemFromArray, } from "@tsparticles/engine";
|
|
2
|
+
import { Emitter } from "./Options/Classes/Emitter.js";
|
|
3
|
+
import { EmitterClickMode } from "./Enums/EmitterClickMode.js";
|
|
4
|
+
import { EmitterInstance } from "./EmitterInstance.js";
|
|
2
5
|
export class Emitters {
|
|
3
6
|
constructor(engine, container) {
|
|
4
7
|
this.container = container;
|
|
@@ -15,7 +18,7 @@ export class Emitters {
|
|
|
15
18
|
const defaultIndex = 0;
|
|
16
19
|
container.getEmitter = (idxOrName) => idxOrName === undefined || isNumber(idxOrName)
|
|
17
20
|
? this.array[idxOrName ?? defaultIndex]
|
|
18
|
-
: this.array.find(
|
|
21
|
+
: this.array.find(t => t.name === idxOrName);
|
|
19
22
|
container.addEmitter = async (options, position) => this.addEmitter(options, position);
|
|
20
23
|
container.removeEmitter = (idxOrName) => {
|
|
21
24
|
const emitter = container.getEmitter(idxOrName);
|
|
@@ -37,7 +40,7 @@ export class Emitters {
|
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
42
|
async addEmitter(options, position) {
|
|
40
|
-
const
|
|
43
|
+
const emitterOptions = new Emitter();
|
|
41
44
|
emitterOptions.load(options);
|
|
42
45
|
const emitter = new EmitterInstance(this._engine, this, this.container, emitterOptions, position);
|
|
43
46
|
await emitter.init();
|
|
@@ -46,7 +49,7 @@ export class Emitters {
|
|
|
46
49
|
}
|
|
47
50
|
handleClickMode(mode) {
|
|
48
51
|
const emitterOptions = this.emitters, modeEmitters = this.interactivityEmitters;
|
|
49
|
-
if (mode !==
|
|
52
|
+
if (mode !== EmitterClickMode.emitter) {
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
55
|
let emittersModeOptions;
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { executeOnSingleOrMultiple, isArray, isInArray, } from "@tsparticles/engine";
|
|
2
2
|
import { Emitter } from "./Options/Classes/Emitter.js";
|
|
3
|
+
import { EmitterClickMode } from "./Enums/EmitterClickMode.js";
|
|
4
|
+
import { Emitters } from "./Emitters.js";
|
|
3
5
|
export class EmittersPlugin {
|
|
4
6
|
constructor(engine) {
|
|
5
7
|
this._engine = engine;
|
|
6
8
|
this.id = "emitters";
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return new Emitters(this._engine, container);
|
|
10
|
+
getPlugin(container) {
|
|
11
|
+
return Promise.resolve(new Emitters(this._engine, container));
|
|
11
12
|
}
|
|
12
13
|
loadOptions(options, source) {
|
|
13
14
|
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
if (source?.emitters) {
|
|
17
|
-
options.emitters = executeOnSingleOrMultiple(source.emitters,
|
|
18
|
+
options.emitters = executeOnSingleOrMultiple(source.emitters, emitter => {
|
|
18
19
|
const tmp = new Emitter();
|
|
19
20
|
tmp.load(emitter);
|
|
20
21
|
return tmp;
|
|
@@ -28,7 +29,7 @@ export class EmittersPlugin {
|
|
|
28
29
|
count: 1,
|
|
29
30
|
enable: true,
|
|
30
31
|
},
|
|
31
|
-
value: interactivityEmitters.map(
|
|
32
|
+
value: interactivityEmitters.map(s => {
|
|
32
33
|
const tmp = new Emitter();
|
|
33
34
|
tmp.load(s);
|
|
34
35
|
return tmp;
|
|
@@ -45,7 +46,7 @@ export class EmittersPlugin {
|
|
|
45
46
|
count: emitterMode.random.count ?? defaultCount,
|
|
46
47
|
enable: emitterMode.random.enable ?? false,
|
|
47
48
|
},
|
|
48
|
-
value: emitterMode.value.map(
|
|
49
|
+
value: emitterMode.value.map(s => {
|
|
49
50
|
const tmp = new Emitter();
|
|
50
51
|
tmp.load(s);
|
|
51
52
|
return tmp;
|
|
@@ -85,6 +86,6 @@ export class EmittersPlugin {
|
|
|
85
86
|
return ((isArray(emitters) && !!emitters.length) ||
|
|
86
87
|
emitters !== undefined ||
|
|
87
88
|
(!!options.interactivity?.events?.onClick?.mode &&
|
|
88
|
-
isInArray(
|
|
89
|
+
isInArray(EmitterClickMode.emitter, options.interactivity.events.onClick.mode)));
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -34,7 +34,7 @@ export class Emitter {
|
|
|
34
34
|
}
|
|
35
35
|
this.life.load(data.life);
|
|
36
36
|
this.name = data.name;
|
|
37
|
-
this.particles = executeOnSingleOrMultiple(data.particles,
|
|
37
|
+
this.particles = executeOnSingleOrMultiple(data.particles, particles => {
|
|
38
38
|
return deepExtend({}, particles);
|
|
39
39
|
});
|
|
40
40
|
this.rate.load(data.rate);
|
package/browser/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { EmittersPlugin } from "./EmittersPlugin.js";
|
|
2
|
+
import { ShapeManager } from "./ShapeManager.js";
|
|
1
3
|
export async function loadEmittersPlugin(engine, refresh = true) {
|
|
2
4
|
if (!engine.emitterShapeManager) {
|
|
3
|
-
const { ShapeManager } = await import("./ShapeManager.js");
|
|
4
5
|
engine.emitterShapeManager = new ShapeManager(engine);
|
|
5
6
|
}
|
|
6
7
|
if (!engine.addEmitterShapeGenerator) {
|
|
@@ -8,7 +9,7 @@ export async function loadEmittersPlugin(engine, refresh = true) {
|
|
|
8
9
|
engine.emitterShapeManager?.addShapeGenerator(name, generator);
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
|
-
const
|
|
12
|
+
const plugin = new EmittersPlugin(engine);
|
|
12
13
|
await engine.addPlugin(plugin, refresh);
|
|
13
14
|
}
|
|
14
15
|
export * from "./EmitterContainer.js";
|
package/cjs/EmitterInstance.js
CHANGED
|
@@ -238,7 +238,7 @@ class EmitterInstance {
|
|
|
238
238
|
return {
|
|
239
239
|
width: elRect.width * container.retina.pixelRatio,
|
|
240
240
|
height: elRect.height * container.retina.pixelRatio,
|
|
241
|
-
mode:
|
|
241
|
+
mode: engine_1.PixelMode.precise,
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
244
|
}
|
|
@@ -247,7 +247,7 @@ class EmitterInstance {
|
|
|
247
247
|
const size = new EmitterSize_js_1.EmitterSize();
|
|
248
248
|
size.load({
|
|
249
249
|
height: 0,
|
|
250
|
-
mode:
|
|
250
|
+
mode: engine_1.PixelMode.percent,
|
|
251
251
|
width: 0,
|
|
252
252
|
});
|
|
253
253
|
return size;
|
package/cjs/Emitters.js
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Emitters = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
+
const Emitter_js_1 = require("./Options/Classes/Emitter.js");
|
|
6
|
+
const EmitterClickMode_js_1 = require("./Enums/EmitterClickMode.js");
|
|
7
|
+
const EmitterInstance_js_1 = require("./EmitterInstance.js");
|
|
5
8
|
class Emitters {
|
|
6
9
|
constructor(engine, container) {
|
|
7
10
|
this.container = container;
|
|
@@ -18,7 +21,7 @@ class Emitters {
|
|
|
18
21
|
const defaultIndex = 0;
|
|
19
22
|
container.getEmitter = (idxOrName) => idxOrName === undefined || (0, engine_1.isNumber)(idxOrName)
|
|
20
23
|
? this.array[idxOrName ?? defaultIndex]
|
|
21
|
-
: this.array.find(
|
|
24
|
+
: this.array.find(t => t.name === idxOrName);
|
|
22
25
|
container.addEmitter = async (options, position) => this.addEmitter(options, position);
|
|
23
26
|
container.removeEmitter = (idxOrName) => {
|
|
24
27
|
const emitter = container.getEmitter(idxOrName);
|
|
@@ -40,16 +43,16 @@ class Emitters {
|
|
|
40
43
|
};
|
|
41
44
|
}
|
|
42
45
|
async addEmitter(options, position) {
|
|
43
|
-
const
|
|
46
|
+
const emitterOptions = new Emitter_js_1.Emitter();
|
|
44
47
|
emitterOptions.load(options);
|
|
45
|
-
const emitter = new EmitterInstance(this._engine, this, this.container, emitterOptions, position);
|
|
48
|
+
const emitter = new EmitterInstance_js_1.EmitterInstance(this._engine, this, this.container, emitterOptions, position);
|
|
46
49
|
await emitter.init();
|
|
47
50
|
this.array.push(emitter);
|
|
48
51
|
return emitter;
|
|
49
52
|
}
|
|
50
53
|
handleClickMode(mode) {
|
|
51
54
|
const emitterOptions = this.emitters, modeEmitters = this.interactivityEmitters;
|
|
52
|
-
if (mode !==
|
|
55
|
+
if (mode !== EmitterClickMode_js_1.EmitterClickMode.emitter) {
|
|
53
56
|
return;
|
|
54
57
|
}
|
|
55
58
|
let emittersModeOptions;
|
package/cjs/EmittersPlugin.js
CHANGED
|
@@ -3,21 +3,22 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EmittersPlugin = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
5
|
const Emitter_js_1 = require("./Options/Classes/Emitter.js");
|
|
6
|
+
const EmitterClickMode_js_1 = require("./Enums/EmitterClickMode.js");
|
|
7
|
+
const Emitters_js_1 = require("./Emitters.js");
|
|
6
8
|
class EmittersPlugin {
|
|
7
9
|
constructor(engine) {
|
|
8
10
|
this._engine = engine;
|
|
9
11
|
this.id = "emitters";
|
|
10
12
|
}
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return new Emitters(this._engine, container);
|
|
13
|
+
getPlugin(container) {
|
|
14
|
+
return Promise.resolve(new Emitters_js_1.Emitters(this._engine, container));
|
|
14
15
|
}
|
|
15
16
|
loadOptions(options, source) {
|
|
16
17
|
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
17
18
|
return;
|
|
18
19
|
}
|
|
19
20
|
if (source?.emitters) {
|
|
20
|
-
options.emitters = (0, engine_1.executeOnSingleOrMultiple)(source.emitters,
|
|
21
|
+
options.emitters = (0, engine_1.executeOnSingleOrMultiple)(source.emitters, emitter => {
|
|
21
22
|
const tmp = new Emitter_js_1.Emitter();
|
|
22
23
|
tmp.load(emitter);
|
|
23
24
|
return tmp;
|
|
@@ -31,7 +32,7 @@ class EmittersPlugin {
|
|
|
31
32
|
count: 1,
|
|
32
33
|
enable: true,
|
|
33
34
|
},
|
|
34
|
-
value: interactivityEmitters.map(
|
|
35
|
+
value: interactivityEmitters.map(s => {
|
|
35
36
|
const tmp = new Emitter_js_1.Emitter();
|
|
36
37
|
tmp.load(s);
|
|
37
38
|
return tmp;
|
|
@@ -48,7 +49,7 @@ class EmittersPlugin {
|
|
|
48
49
|
count: emitterMode.random.count ?? defaultCount,
|
|
49
50
|
enable: emitterMode.random.enable ?? false,
|
|
50
51
|
},
|
|
51
|
-
value: emitterMode.value.map(
|
|
52
|
+
value: emitterMode.value.map(s => {
|
|
52
53
|
const tmp = new Emitter_js_1.Emitter();
|
|
53
54
|
tmp.load(s);
|
|
54
55
|
return tmp;
|
|
@@ -88,7 +89,7 @@ class EmittersPlugin {
|
|
|
88
89
|
return (((0, engine_1.isArray)(emitters) && !!emitters.length) ||
|
|
89
90
|
emitters !== undefined ||
|
|
90
91
|
(!!options.interactivity?.events?.onClick?.mode &&
|
|
91
|
-
(0, engine_1.isInArray)(
|
|
92
|
+
(0, engine_1.isInArray)(EmitterClickMode_js_1.EmitterClickMode.emitter, options.interactivity.events.onClick.mode)));
|
|
92
93
|
}
|
|
93
94
|
}
|
|
94
95
|
exports.EmittersPlugin = EmittersPlugin;
|
|
@@ -1,2 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EmitterClickMode = void 0;
|
|
4
|
+
var EmitterClickMode;
|
|
5
|
+
(function (EmitterClickMode) {
|
|
6
|
+
EmitterClickMode["emitter"] = "emitter";
|
|
7
|
+
})(EmitterClickMode || (exports.EmitterClickMode = EmitterClickMode = {}));
|
|
@@ -37,7 +37,7 @@ class Emitter {
|
|
|
37
37
|
}
|
|
38
38
|
this.life.load(data.life);
|
|
39
39
|
this.name = data.name;
|
|
40
|
-
this.particles = (0, engine_1.executeOnSingleOrMultiple)(data.particles,
|
|
40
|
+
this.particles = (0, engine_1.executeOnSingleOrMultiple)(data.particles, particles => {
|
|
41
41
|
return (0, engine_1.deepExtend)({}, particles);
|
|
42
42
|
});
|
|
43
43
|
this.rate.load(data.rate);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EmitterSize = void 0;
|
|
4
|
+
const engine_1 = require("@tsparticles/engine");
|
|
4
5
|
class EmitterSize {
|
|
5
6
|
constructor() {
|
|
6
|
-
this.mode =
|
|
7
|
+
this.mode = engine_1.PixelMode.percent;
|
|
7
8
|
this.height = 0;
|
|
8
9
|
this.width = 0;
|
|
9
10
|
}
|
package/cjs/index.js
CHANGED
|
@@ -14,21 +14,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.loadEmittersPlugin =
|
|
17
|
+
exports.loadEmittersPlugin = loadEmittersPlugin;
|
|
18
|
+
const EmittersPlugin_js_1 = require("./EmittersPlugin.js");
|
|
19
|
+
const ShapeManager_js_1 = require("./ShapeManager.js");
|
|
18
20
|
async function loadEmittersPlugin(engine, refresh = true) {
|
|
19
21
|
if (!engine.emitterShapeManager) {
|
|
20
|
-
|
|
21
|
-
engine.emitterShapeManager = new ShapeManager(engine);
|
|
22
|
+
engine.emitterShapeManager = new ShapeManager_js_1.ShapeManager(engine);
|
|
22
23
|
}
|
|
23
24
|
if (!engine.addEmitterShapeGenerator) {
|
|
24
25
|
engine.addEmitterShapeGenerator = (name, generator) => {
|
|
25
26
|
engine.emitterShapeManager?.addShapeGenerator(name, generator);
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
|
-
const
|
|
29
|
+
const plugin = new EmittersPlugin_js_1.EmittersPlugin(engine);
|
|
29
30
|
await engine.addPlugin(plugin, refresh);
|
|
30
31
|
}
|
|
31
|
-
exports.loadEmittersPlugin = loadEmittersPlugin;
|
|
32
32
|
__exportStar(require("./EmitterContainer.js"), exports);
|
|
33
33
|
__exportStar(require("./EmitterShapeBase.js"), exports);
|
|
34
34
|
__exportStar(require("./EmittersEngine.js"), exports);
|
package/esm/EmitterInstance.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector, calcPositionOrRandomFromSizeRanged, deepExtend, getRangeValue, getSize, isPointInside, itemFromSingleOrMultiple, millisecondsToSeconds, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
|
|
1
|
+
import { PixelMode, Vector, calcPositionOrRandomFromSizeRanged, deepExtend, getRangeValue, getSize, isPointInside, itemFromSingleOrMultiple, millisecondsToSeconds, randomInRange, rangeColorToHsl, } from "@tsparticles/engine";
|
|
2
2
|
import { Emitter } from "./Options/Classes/Emitter.js";
|
|
3
3
|
import { EmitterSize } from "./Options/Classes/EmitterSize.js";
|
|
4
4
|
const half = 0.5, defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultEmitDelay = 0, defaultLifeCount = -1, defaultColorAnimationFactor = 1;
|
|
@@ -235,7 +235,7 @@ export class EmitterInstance {
|
|
|
235
235
|
return {
|
|
236
236
|
width: elRect.width * container.retina.pixelRatio,
|
|
237
237
|
height: elRect.height * container.retina.pixelRatio,
|
|
238
|
-
mode:
|
|
238
|
+
mode: PixelMode.precise,
|
|
239
239
|
};
|
|
240
240
|
}
|
|
241
241
|
}
|
|
@@ -244,7 +244,7 @@ export class EmitterInstance {
|
|
|
244
244
|
const size = new EmitterSize();
|
|
245
245
|
size.load({
|
|
246
246
|
height: 0,
|
|
247
|
-
mode:
|
|
247
|
+
mode: PixelMode.percent,
|
|
248
248
|
width: 0,
|
|
249
249
|
});
|
|
250
250
|
return size;
|
package/esm/Emitters.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { arrayRandomIndex, executeOnSingleOrMultiple, isArray, isNumber, itemFromArray, } from "@tsparticles/engine";
|
|
2
|
+
import { Emitter } from "./Options/Classes/Emitter.js";
|
|
3
|
+
import { EmitterClickMode } from "./Enums/EmitterClickMode.js";
|
|
4
|
+
import { EmitterInstance } from "./EmitterInstance.js";
|
|
2
5
|
export class Emitters {
|
|
3
6
|
constructor(engine, container) {
|
|
4
7
|
this.container = container;
|
|
@@ -15,7 +18,7 @@ export class Emitters {
|
|
|
15
18
|
const defaultIndex = 0;
|
|
16
19
|
container.getEmitter = (idxOrName) => idxOrName === undefined || isNumber(idxOrName)
|
|
17
20
|
? this.array[idxOrName ?? defaultIndex]
|
|
18
|
-
: this.array.find(
|
|
21
|
+
: this.array.find(t => t.name === idxOrName);
|
|
19
22
|
container.addEmitter = async (options, position) => this.addEmitter(options, position);
|
|
20
23
|
container.removeEmitter = (idxOrName) => {
|
|
21
24
|
const emitter = container.getEmitter(idxOrName);
|
|
@@ -37,7 +40,7 @@ export class Emitters {
|
|
|
37
40
|
};
|
|
38
41
|
}
|
|
39
42
|
async addEmitter(options, position) {
|
|
40
|
-
const
|
|
43
|
+
const emitterOptions = new Emitter();
|
|
41
44
|
emitterOptions.load(options);
|
|
42
45
|
const emitter = new EmitterInstance(this._engine, this, this.container, emitterOptions, position);
|
|
43
46
|
await emitter.init();
|
|
@@ -46,7 +49,7 @@ export class Emitters {
|
|
|
46
49
|
}
|
|
47
50
|
handleClickMode(mode) {
|
|
48
51
|
const emitterOptions = this.emitters, modeEmitters = this.interactivityEmitters;
|
|
49
|
-
if (mode !==
|
|
52
|
+
if (mode !== EmitterClickMode.emitter) {
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
55
|
let emittersModeOptions;
|
package/esm/EmittersPlugin.js
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { executeOnSingleOrMultiple, isArray, isInArray, } from "@tsparticles/engine";
|
|
2
2
|
import { Emitter } from "./Options/Classes/Emitter.js";
|
|
3
|
+
import { EmitterClickMode } from "./Enums/EmitterClickMode.js";
|
|
4
|
+
import { Emitters } from "./Emitters.js";
|
|
3
5
|
export class EmittersPlugin {
|
|
4
6
|
constructor(engine) {
|
|
5
7
|
this._engine = engine;
|
|
6
8
|
this.id = "emitters";
|
|
7
9
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return new Emitters(this._engine, container);
|
|
10
|
+
getPlugin(container) {
|
|
11
|
+
return Promise.resolve(new Emitters(this._engine, container));
|
|
11
12
|
}
|
|
12
13
|
loadOptions(options, source) {
|
|
13
14
|
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
14
15
|
return;
|
|
15
16
|
}
|
|
16
17
|
if (source?.emitters) {
|
|
17
|
-
options.emitters = executeOnSingleOrMultiple(source.emitters,
|
|
18
|
+
options.emitters = executeOnSingleOrMultiple(source.emitters, emitter => {
|
|
18
19
|
const tmp = new Emitter();
|
|
19
20
|
tmp.load(emitter);
|
|
20
21
|
return tmp;
|
|
@@ -28,7 +29,7 @@ export class EmittersPlugin {
|
|
|
28
29
|
count: 1,
|
|
29
30
|
enable: true,
|
|
30
31
|
},
|
|
31
|
-
value: interactivityEmitters.map(
|
|
32
|
+
value: interactivityEmitters.map(s => {
|
|
32
33
|
const tmp = new Emitter();
|
|
33
34
|
tmp.load(s);
|
|
34
35
|
return tmp;
|
|
@@ -45,7 +46,7 @@ export class EmittersPlugin {
|
|
|
45
46
|
count: emitterMode.random.count ?? defaultCount,
|
|
46
47
|
enable: emitterMode.random.enable ?? false,
|
|
47
48
|
},
|
|
48
|
-
value: emitterMode.value.map(
|
|
49
|
+
value: emitterMode.value.map(s => {
|
|
49
50
|
const tmp = new Emitter();
|
|
50
51
|
tmp.load(s);
|
|
51
52
|
return tmp;
|
|
@@ -85,6 +86,6 @@ export class EmittersPlugin {
|
|
|
85
86
|
return ((isArray(emitters) && !!emitters.length) ||
|
|
86
87
|
emitters !== undefined ||
|
|
87
88
|
(!!options.interactivity?.events?.onClick?.mode &&
|
|
88
|
-
isInArray(
|
|
89
|
+
isInArray(EmitterClickMode.emitter, options.interactivity.events.onClick.mode)));
|
|
89
90
|
}
|
|
90
91
|
}
|
|
@@ -34,7 +34,7 @@ export class Emitter {
|
|
|
34
34
|
}
|
|
35
35
|
this.life.load(data.life);
|
|
36
36
|
this.name = data.name;
|
|
37
|
-
this.particles = executeOnSingleOrMultiple(data.particles,
|
|
37
|
+
this.particles = executeOnSingleOrMultiple(data.particles, particles => {
|
|
38
38
|
return deepExtend({}, particles);
|
|
39
39
|
});
|
|
40
40
|
this.rate.load(data.rate);
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { EmittersPlugin } from "./EmittersPlugin.js";
|
|
2
|
+
import { ShapeManager } from "./ShapeManager.js";
|
|
1
3
|
export async function loadEmittersPlugin(engine, refresh = true) {
|
|
2
4
|
if (!engine.emitterShapeManager) {
|
|
3
|
-
const { ShapeManager } = await import("./ShapeManager.js");
|
|
4
5
|
engine.emitterShapeManager = new ShapeManager(engine);
|
|
5
6
|
}
|
|
6
7
|
if (!engine.addEmitterShapeGenerator) {
|
|
@@ -8,7 +9,7 @@ export async function loadEmittersPlugin(engine, refresh = true) {
|
|
|
8
9
|
engine.emitterShapeManager?.addShapeGenerator(name, generator);
|
|
9
10
|
};
|
|
10
11
|
}
|
|
11
|
-
const
|
|
12
|
+
const plugin = new EmittersPlugin(engine);
|
|
12
13
|
await engine.addPlugin(plugin, refresh);
|
|
13
14
|
}
|
|
14
15
|
export * from "./EmitterContainer.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/plugin-emitters",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "tsParticles emitters plugin",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -86,7 +86,7 @@
|
|
|
86
86
|
"./package.json": "./package.json"
|
|
87
87
|
},
|
|
88
88
|
"dependencies": {
|
|
89
|
-
"@tsparticles/engine": "^3.
|
|
89
|
+
"@tsparticles/engine": "^3.5.0"
|
|
90
90
|
},
|
|
91
91
|
"publishConfig": {
|
|
92
92
|
"access": "public"
|
package/report.html
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8"/>
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1"/>
|
|
6
|
-
<title>@tsparticles/plugin-emitters [
|
|
6
|
+
<title>@tsparticles/plugin-emitters [1 Jul 2024 at 09:20]</title>
|
|
7
7
|
<link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
|
|
8
8
|
|
|
9
9
|
<script>
|