tsparticles 1.39.2 → 1.40.2
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/Core/Container.d.ts +3 -1
- package/Core/Container.js +30 -15
- package/Core/Loader.d.ts +12 -9
- package/Core/Loader.js +35 -19
- package/Core/Particle.d.ts +3 -1
- package/Core/Particle.js +17 -2
- package/Core/Particles.d.ts +3 -1
- package/Core/Particles.js +20 -5
- package/Core/Utils/InteractionManager.d.ts +5 -3
- package/Core/Utils/InteractionManager.js +19 -3
- package/Core/Utils/Plugins.d.ts +29 -15
- package/Core/Utils/Plugins.js +58 -46
- package/Options/Classes/Options.d.ts +2 -1
- package/Options/Classes/Options.js +14 -7
- package/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/Plugins/Emitters/EmitterInstance.js +46 -16
- package/Plugins/Emitters/Emitters.d.ts +3 -1
- package/Plugins/Emitters/Emitters.js +17 -2
- package/Plugins/Emitters/{EmittersMain.d.ts → EmittersEngine.d.ts} +3 -1
- package/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +1 -0
- package/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/Plugins/Emitters/ShapeManager.js +16 -4
- package/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/Plugins/Emitters/index.d.ts +3 -3
- package/Plugins/Emitters/index.js +25 -6
- package/README.md +1 -1
- package/browser/Core/Container.d.ts +4 -1
- package/browser/Core/Container.js +32 -16
- package/browser/Core/Loader.d.ts +12 -9
- package/browser/Core/Loader.js +35 -19
- package/browser/Core/Particle.d.ts +3 -1
- package/browser/Core/Particle.js +18 -3
- package/browser/Core/Particles.d.ts +3 -1
- package/browser/Core/Particles.js +21 -6
- package/browser/Core/Utils/InteractionManager.d.ts +5 -3
- package/browser/Core/Utils/InteractionManager.js +19 -3
- package/browser/Core/Utils/Plugins.d.ts +29 -15
- package/browser/Core/Utils/Plugins.js +58 -46
- package/browser/Options/Classes/Options.d.ts +2 -1
- package/browser/Options/Classes/Options.js +14 -7
- package/browser/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/browser/Plugins/Emitters/EmitterInstance.js +46 -16
- package/browser/Plugins/Emitters/Emitters.d.ts +3 -1
- package/browser/Plugins/Emitters/Emitters.js +17 -2
- package/{esm/Plugins/Emitters/EmittersMain.d.ts → browser/Plugins/Emitters/EmittersEngine.d.ts} +3 -1
- package/browser/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/browser/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/browser/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/browser/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +4 -0
- package/browser/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/browser/Plugins/Emitters/ShapeManager.js +16 -4
- package/browser/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/browser/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/browser/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/browser/Plugins/Emitters/index.d.ts +3 -3
- package/browser/Plugins/Emitters/index.js +25 -6
- package/browser/engine.d.ts +5 -1
- package/browser/engine.js +22 -17
- package/engine.d.ts +3 -0
- package/engine.js +20 -16
- package/esm/Core/Container.d.ts +3 -1
- package/esm/Core/Container.js +31 -16
- package/esm/Core/Loader.d.ts +12 -9
- package/esm/Core/Loader.js +35 -19
- package/esm/Core/Particle.d.ts +3 -1
- package/esm/Core/Particle.js +18 -3
- package/esm/Core/Particles.d.ts +3 -1
- package/esm/Core/Particles.js +21 -6
- package/esm/Core/Utils/InteractionManager.d.ts +5 -3
- package/esm/Core/Utils/InteractionManager.js +19 -3
- package/esm/Core/Utils/Plugins.d.ts +29 -15
- package/esm/Core/Utils/Plugins.js +58 -46
- package/esm/Options/Classes/Options.d.ts +2 -1
- package/esm/Options/Classes/Options.js +14 -7
- package/esm/Plugins/Emitters/EmitterInstance.d.ts +6 -3
- package/esm/Plugins/Emitters/EmitterInstance.js +46 -16
- package/esm/Plugins/Emitters/Emitters.d.ts +3 -1
- package/esm/Plugins/Emitters/Emitters.js +17 -2
- package/{browser/Plugins/Emitters/EmittersMain.d.ts → esm/Plugins/Emitters/EmittersEngine.d.ts} +3 -1
- package/esm/Plugins/Emitters/{EmittersMain.js → EmittersEngine.js} +0 -0
- package/esm/Plugins/Emitters/IEmitterShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Options/Classes/Emitter.d.ts +1 -0
- package/esm/Plugins/Emitters/Options/Classes/Emitter.js +1 -0
- package/esm/Plugins/Emitters/Options/Interfaces/IEmitter.d.ts +1 -0
- package/esm/Plugins/Emitters/ShapeManager.d.ts +6 -3
- package/esm/Plugins/Emitters/ShapeManager.js +16 -4
- package/esm/Plugins/Emitters/Shapes/Circle/CircleShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Shapes/Circle/CircleShape.js +2 -2
- package/esm/Plugins/Emitters/Shapes/Square/SquareShape.d.ts +2 -2
- package/esm/Plugins/Emitters/Shapes/Square/SquareShape.js +4 -4
- package/esm/Plugins/Emitters/index.d.ts +3 -3
- package/esm/Plugins/Emitters/index.js +25 -6
- package/esm/engine.d.ts +3 -0
- package/esm/engine.js +20 -16
- package/package.json +11 -6
- package/report.html +2 -2
- package/report.slim.html +2 -2
- package/tsparticles.engine.js +227 -118
- package/tsparticles.engine.min.js +2 -2
- package/tsparticles.interaction.external.attract.js +205 -100
- package/tsparticles.interaction.external.attract.min.js +2 -2
- package/tsparticles.interaction.external.bounce.js +205 -100
- package/tsparticles.interaction.external.bounce.min.js +2 -2
- package/tsparticles.interaction.external.bubble.js +205 -100
- package/tsparticles.interaction.external.bubble.min.js +2 -2
- package/tsparticles.interaction.external.connect.js +205 -100
- package/tsparticles.interaction.external.connect.min.js +2 -2
- package/tsparticles.interaction.external.grab.js +205 -100
- package/tsparticles.interaction.external.grab.min.js +2 -2
- package/tsparticles.interaction.external.repulse.js +205 -100
- package/tsparticles.interaction.external.repulse.min.js +2 -2
- package/tsparticles.interaction.external.trail.js +205 -100
- package/tsparticles.interaction.external.trail.min.js +2 -2
- package/tsparticles.interaction.particles.attract.js +205 -100
- package/tsparticles.interaction.particles.attract.min.js +2 -2
- package/tsparticles.interaction.particles.collisions.js +205 -100
- package/tsparticles.interaction.particles.collisions.min.js +2 -2
- package/tsparticles.interaction.particles.links.js +205 -100
- package/tsparticles.interaction.particles.links.min.js +2 -2
- package/tsparticles.js +347 -156
- package/tsparticles.min.js +2 -2
- package/tsparticles.pathseg.min.js +1 -1
- package/tsparticles.plugins.absorbers.js +205 -100
- package/tsparticles.plugins.absorbers.min.js +2 -2
- package/tsparticles.plugins.emitters.js +330 -143
- package/tsparticles.plugins.emitters.min.js +2 -2
- package/tsparticles.plugins.polygonMask.js +205 -100
- package/tsparticles.plugins.polygonMask.min.js +2 -2
- package/tsparticles.shape.circle.min.js +1 -1
- package/tsparticles.shape.image.js +208 -103
- package/tsparticles.shape.image.min.js +2 -2
- package/tsparticles.shape.line.min.js +1 -1
- package/tsparticles.shape.polygon.min.js +1 -1
- package/tsparticles.shape.square.min.js +1 -1
- package/tsparticles.shape.star.min.js +1 -1
- package/tsparticles.shape.text.js +205 -100
- package/tsparticles.shape.text.min.js +2 -2
- package/tsparticles.slim.js +227 -118
- package/tsparticles.slim.min.js +2 -2
- package/tsparticles.updater.angle.js +205 -100
- package/tsparticles.updater.angle.min.js +2 -2
- package/tsparticles.updater.color.js +205 -100
- package/tsparticles.updater.color.min.js +2 -2
- package/tsparticles.updater.life.js +205 -100
- package/tsparticles.updater.life.min.js +2 -2
- package/tsparticles.updater.opacity.js +205 -100
- package/tsparticles.updater.opacity.min.js +2 -2
- package/tsparticles.updater.outModes.js +205 -100
- package/tsparticles.updater.outModes.min.js +2 -2
- package/tsparticles.updater.roll.js +205 -100
- package/tsparticles.updater.roll.min.js +2 -2
- package/tsparticles.updater.size.js +205 -100
- package/tsparticles.updater.size.min.js +2 -2
- package/tsparticles.updater.strokeColor.js +205 -100
- package/tsparticles.updater.strokeColor.min.js +2 -2
- package/tsparticles.updater.tilt.js +205 -100
- package/tsparticles.updater.tilt.min.js +2 -2
- package/tsparticles.updater.wobble.js +205 -100
- package/tsparticles.updater.wobble.min.js +2 -2
package/Core/Utils/Plugins.js
CHANGED
|
@@ -1,26 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var _Plugins_engine;
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.Plugins = void 0;
|
|
4
|
-
const plugins = [];
|
|
5
|
-
const interactorsInitializers = new Map();
|
|
6
|
-
const updatersInitializers = new Map();
|
|
7
|
-
const interactors = new Map();
|
|
8
|
-
const updaters = new Map();
|
|
9
|
-
const presets = new Map();
|
|
10
|
-
const drawers = new Map();
|
|
11
|
-
const pathGenerators = new Map();
|
|
12
11
|
class Plugins {
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
constructor(engine) {
|
|
13
|
+
_Plugins_engine.set(this, void 0);
|
|
14
|
+
__classPrivateFieldSet(this, _Plugins_engine, engine, "f");
|
|
15
|
+
this.plugins = [];
|
|
16
|
+
this.interactorsInitializers = new Map();
|
|
17
|
+
this.updatersInitializers = new Map();
|
|
18
|
+
this.interactors = new Map();
|
|
19
|
+
this.updaters = new Map();
|
|
20
|
+
this.presets = new Map();
|
|
21
|
+
this.drawers = new Map();
|
|
22
|
+
this.pathGenerators = new Map();
|
|
15
23
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
24
|
+
getPlugin(plugin) {
|
|
25
|
+
return this.plugins.find((t) => t.id === plugin);
|
|
26
|
+
}
|
|
27
|
+
addPlugin(plugin) {
|
|
28
|
+
if (!this.getPlugin(plugin.id)) {
|
|
29
|
+
this.plugins.push(plugin);
|
|
19
30
|
}
|
|
20
31
|
}
|
|
21
|
-
|
|
32
|
+
getAvailablePlugins(container) {
|
|
22
33
|
const res = new Map();
|
|
23
|
-
for (const plugin of plugins) {
|
|
34
|
+
for (const plugin of this.plugins) {
|
|
24
35
|
if (!plugin.needsPlugin(container.actualOptions)) {
|
|
25
36
|
continue;
|
|
26
37
|
}
|
|
@@ -28,59 +39,60 @@ class Plugins {
|
|
|
28
39
|
}
|
|
29
40
|
return res;
|
|
30
41
|
}
|
|
31
|
-
|
|
32
|
-
for (const plugin of plugins) {
|
|
42
|
+
loadOptions(options, sourceOptions) {
|
|
43
|
+
for (const plugin of this.plugins) {
|
|
33
44
|
plugin.loadOptions(options, sourceOptions);
|
|
34
45
|
}
|
|
35
46
|
}
|
|
36
|
-
|
|
37
|
-
return presets.get(preset);
|
|
47
|
+
getPreset(preset) {
|
|
48
|
+
return this.presets.get(preset);
|
|
38
49
|
}
|
|
39
|
-
|
|
40
|
-
if (override || !
|
|
41
|
-
presets.set(presetKey, options);
|
|
50
|
+
addPreset(presetKey, options, override = false) {
|
|
51
|
+
if (override || !this.getPreset(presetKey)) {
|
|
52
|
+
this.presets.set(presetKey, options);
|
|
42
53
|
}
|
|
43
54
|
}
|
|
44
|
-
|
|
45
|
-
if (!
|
|
46
|
-
drawers.set(type, drawer);
|
|
55
|
+
addShapeDrawer(type, drawer) {
|
|
56
|
+
if (!this.getShapeDrawer(type)) {
|
|
57
|
+
this.drawers.set(type, drawer);
|
|
47
58
|
}
|
|
48
59
|
}
|
|
49
|
-
|
|
50
|
-
return drawers.get(type);
|
|
60
|
+
getShapeDrawer(type) {
|
|
61
|
+
return this.drawers.get(type);
|
|
51
62
|
}
|
|
52
|
-
|
|
53
|
-
return drawers.keys();
|
|
63
|
+
getSupportedShapes() {
|
|
64
|
+
return this.drawers.keys();
|
|
54
65
|
}
|
|
55
|
-
|
|
56
|
-
return pathGenerators.get(type);
|
|
66
|
+
getPathGenerator(type) {
|
|
67
|
+
return this.pathGenerators.get(type);
|
|
57
68
|
}
|
|
58
|
-
|
|
59
|
-
if (!
|
|
60
|
-
pathGenerators.set(type, pathGenerator);
|
|
69
|
+
addPathGenerator(type, pathGenerator) {
|
|
70
|
+
if (!this.getPathGenerator(type)) {
|
|
71
|
+
this.pathGenerators.set(type, pathGenerator);
|
|
61
72
|
}
|
|
62
73
|
}
|
|
63
|
-
|
|
64
|
-
let res = interactors.get(container);
|
|
74
|
+
getInteractors(container, force = false) {
|
|
75
|
+
let res = this.interactors.get(container);
|
|
65
76
|
if (!res || force) {
|
|
66
|
-
res = [...interactorsInitializers.values()].map((t) => t(container));
|
|
67
|
-
interactors.set(container, res);
|
|
77
|
+
res = [...this.interactorsInitializers.values()].map((t) => t(container));
|
|
78
|
+
this.interactors.set(container, res);
|
|
68
79
|
}
|
|
69
80
|
return res;
|
|
70
81
|
}
|
|
71
|
-
|
|
72
|
-
interactorsInitializers.set(name, initInteractor);
|
|
82
|
+
addInteractor(name, initInteractor) {
|
|
83
|
+
this.interactorsInitializers.set(name, initInteractor);
|
|
73
84
|
}
|
|
74
|
-
|
|
75
|
-
let res = updaters.get(container);
|
|
85
|
+
getUpdaters(container, force = false) {
|
|
86
|
+
let res = this.updaters.get(container);
|
|
76
87
|
if (!res || force) {
|
|
77
|
-
res = [...updatersInitializers.values()].map((t) => t(container));
|
|
78
|
-
updaters.set(container, res);
|
|
88
|
+
res = [...this.updatersInitializers.values()].map((t) => t(container));
|
|
89
|
+
this.updaters.set(container, res);
|
|
79
90
|
}
|
|
80
91
|
return res;
|
|
81
92
|
}
|
|
82
|
-
|
|
83
|
-
updatersInitializers.set(name, initUpdater);
|
|
93
|
+
addParticleUpdater(name, initUpdater) {
|
|
94
|
+
this.updatersInitializers.set(name, initUpdater);
|
|
84
95
|
}
|
|
85
96
|
}
|
|
86
97
|
exports.Plugins = Plugins;
|
|
98
|
+
_Plugins_engine = new WeakMap();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { RangeValue, RecursivePartial } from "../../Types";
|
|
2
2
|
import { Background } from "./Background/Background";
|
|
3
3
|
import { BackgroundMask } from "./BackgroundMask/BackgroundMask";
|
|
4
|
+
import type { Engine } from "../../engine";
|
|
4
5
|
import { FullScreen } from "./FullScreen/FullScreen";
|
|
5
6
|
import type { IOptionLoader } from "../Interfaces/IOptionLoader";
|
|
6
7
|
import type { IOptions } from "../Interfaces/IOptions";
|
|
@@ -39,7 +40,7 @@ export declare class Options implements IOptions, IOptionLoader<IOptions> {
|
|
|
39
40
|
defaultDarkTheme?: string;
|
|
40
41
|
defaultLightTheme?: string;
|
|
41
42
|
[name: string]: unknown;
|
|
42
|
-
constructor();
|
|
43
|
+
constructor(engine: Engine);
|
|
43
44
|
load(data?: RecursivePartial<IOptions>): void;
|
|
44
45
|
setTheme(name?: string): void;
|
|
45
46
|
setResponsive(width: number, pxRatio: number, defaultOptions: IOptions): number | undefined;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
2
8
|
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
3
9
|
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
4
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
5
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
6
12
|
};
|
|
7
|
-
var _Options_instances, _Options_findDefaultTheme;
|
|
13
|
+
var _Options_instances, _Options_engine, _Options_findDefaultTheme;
|
|
8
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
15
|
exports.Options = void 0;
|
|
10
16
|
const Background_1 = require("./Background/Background");
|
|
@@ -14,20 +20,21 @@ const Interactivity_1 = require("./Interactivity/Interactivity");
|
|
|
14
20
|
const ManualParticle_1 = require("./ManualParticle");
|
|
15
21
|
const Motion_1 = require("./Motion/Motion");
|
|
16
22
|
const ParticlesOptions_1 = require("./Particles/ParticlesOptions");
|
|
17
|
-
const Core_1 = require("../../Core");
|
|
18
23
|
const Responsive_1 = require("./Responsive");
|
|
19
24
|
const Theme_1 = require("./Theme/Theme");
|
|
20
25
|
const Utils_1 = require("../../Utils");
|
|
21
26
|
class Options {
|
|
22
|
-
constructor() {
|
|
27
|
+
constructor(engine) {
|
|
23
28
|
_Options_instances.add(this);
|
|
29
|
+
_Options_engine.set(this, void 0);
|
|
30
|
+
__classPrivateFieldSet(this, _Options_engine, engine, "f");
|
|
24
31
|
this.autoPlay = true;
|
|
25
32
|
this.background = new Background_1.Background();
|
|
26
33
|
this.backgroundMask = new BackgroundMask_1.BackgroundMask();
|
|
27
34
|
this.fullScreen = new FullScreen_1.FullScreen();
|
|
28
35
|
this.detectRetina = true;
|
|
29
36
|
this.duration = 0;
|
|
30
|
-
this.fpsLimit =
|
|
37
|
+
this.fpsLimit = 120;
|
|
31
38
|
this.interactivity = new Interactivity_1.Interactivity();
|
|
32
39
|
this.manualParticles = [];
|
|
33
40
|
this.motion = new Motion_1.Motion();
|
|
@@ -115,7 +122,7 @@ class Options {
|
|
|
115
122
|
this.motion.load(data.motion);
|
|
116
123
|
this.particles.load(data.particles);
|
|
117
124
|
this.style = (0, Utils_1.deepExtend)(this.style, data.style);
|
|
118
|
-
|
|
125
|
+
__classPrivateFieldGet(this, _Options_engine, "f").plugins.loadOptions(this, data);
|
|
119
126
|
if (data.responsive !== undefined) {
|
|
120
127
|
for (const responsive of data.responsive) {
|
|
121
128
|
const optResponsive = new Responsive_1.Responsive();
|
|
@@ -157,11 +164,11 @@ class Options {
|
|
|
157
164
|
return responsiveOptions === null || responsiveOptions === void 0 ? void 0 : responsiveOptions.maxWidth;
|
|
158
165
|
}
|
|
159
166
|
importPreset(preset) {
|
|
160
|
-
this.load(
|
|
167
|
+
this.load(__classPrivateFieldGet(this, _Options_engine, "f").plugins.getPreset(preset));
|
|
161
168
|
}
|
|
162
169
|
}
|
|
163
170
|
exports.Options = Options;
|
|
164
|
-
_Options_instances = new WeakSet(), _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
|
|
171
|
+
_Options_engine = new WeakMap(), _Options_instances = new WeakSet(), _Options_findDefaultTheme = function _Options_findDefaultTheme(mode) {
|
|
165
172
|
var _a;
|
|
166
173
|
return ((_a = this.themes.find((theme) => theme.default.value && theme.default.mode === mode)) !== null && _a !== void 0 ? _a : this.themes.find((theme) => theme.default.value && theme.default.mode === "any"));
|
|
167
174
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { Container, ICoordinates, IDelta, IHsl } from "../../Core";
|
|
1
|
+
import type { Container, ICoordinates, IDelta, IDimension, IHsl } from "../../Core";
|
|
2
2
|
import { Emitter } from "./Options/Classes/Emitter";
|
|
3
3
|
import type { Emitters } from "./Emitters";
|
|
4
|
+
import type { EmittersEngine } from "./EmittersEngine";
|
|
4
5
|
import type { IEmitter } from "./Options/Interfaces/IEmitter";
|
|
5
6
|
import type { IEmitterSize } from "./Options/Interfaces/IEmitterSize";
|
|
6
7
|
import type { RecursivePartial } from "../../Types";
|
|
@@ -8,7 +9,7 @@ export declare class EmitterInstance {
|
|
|
8
9
|
#private;
|
|
9
10
|
private readonly emitters;
|
|
10
11
|
private readonly container;
|
|
11
|
-
position
|
|
12
|
+
position?: ICoordinates;
|
|
12
13
|
size: IEmitterSize;
|
|
13
14
|
options: Emitter;
|
|
14
15
|
spawnColor?: IHsl;
|
|
@@ -26,13 +27,15 @@ export declare class EmitterInstance {
|
|
|
26
27
|
private readonly shape?;
|
|
27
28
|
private readonly initialPosition?;
|
|
28
29
|
private readonly particlesOptions;
|
|
29
|
-
constructor(emitters: Emitters, container: Container, options: RecursivePartial<IEmitter>, position?: ICoordinates);
|
|
30
|
+
constructor(engine: EmittersEngine, emitters: Emitters, container: Container, options: RecursivePartial<IEmitter>, position?: ICoordinates);
|
|
30
31
|
externalPlay(): void;
|
|
31
32
|
externalPause(): void;
|
|
32
33
|
play(): void;
|
|
33
34
|
pause(): void;
|
|
34
35
|
resize(): void;
|
|
35
36
|
update(delta: IDelta): void;
|
|
37
|
+
getPosition(): ICoordinates | undefined;
|
|
38
|
+
getSize(): IDimension;
|
|
36
39
|
private prepareToDie;
|
|
37
40
|
private destroy;
|
|
38
41
|
private calcPosition;
|
|
@@ -10,21 +10,22 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _EmitterInstance_firstSpawn, _EmitterInstance_startParticlesAdded;
|
|
13
|
+
var _EmitterInstance_firstSpawn, _EmitterInstance_startParticlesAdded, _EmitterInstance_engine;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.EmitterInstance = void 0;
|
|
16
16
|
const Utils_1 = require("../../Utils");
|
|
17
17
|
const Emitter_1 = require("./Options/Classes/Emitter");
|
|
18
18
|
const EmitterSize_1 = require("./Options/Classes/EmitterSize");
|
|
19
|
-
const ShapeManager_1 = require("./ShapeManager");
|
|
20
19
|
class EmitterInstance {
|
|
21
|
-
constructor(emitters, container, options, position) {
|
|
20
|
+
constructor(engine, emitters, container, options, position) {
|
|
22
21
|
var _a, _b, _c, _d, _e, _f;
|
|
23
22
|
var _g;
|
|
24
23
|
this.emitters = emitters;
|
|
25
24
|
this.container = container;
|
|
26
25
|
_EmitterInstance_firstSpawn.set(this, void 0);
|
|
27
26
|
_EmitterInstance_startParticlesAdded.set(this, void 0);
|
|
27
|
+
_EmitterInstance_engine.set(this, void 0);
|
|
28
|
+
__classPrivateFieldSet(this, _EmitterInstance_engine, engine, "f");
|
|
28
29
|
this.currentDuration = 0;
|
|
29
30
|
this.currentEmitDelay = 0;
|
|
30
31
|
this.currentSpawnDelay = 0;
|
|
@@ -37,9 +38,8 @@ class EmitterInstance {
|
|
|
37
38
|
this.options.load(options);
|
|
38
39
|
}
|
|
39
40
|
this.spawnDelay = (((_a = this.options.life.delay) !== null && _a !== void 0 ? _a : 0) * 1000) / this.container.retina.reduceFactor;
|
|
40
|
-
this.position = (_b = this.initialPosition) !== null && _b !== void 0 ? _b : this.calcPosition();
|
|
41
41
|
this.name = this.options.name;
|
|
42
|
-
this.shape =
|
|
42
|
+
this.shape = (_b = __classPrivateFieldGet(this, _EmitterInstance_engine, "f").emitterShapeManager) === null || _b === void 0 ? void 0 : _b.getShape(this.options.shape);
|
|
43
43
|
this.fill = this.options.fill;
|
|
44
44
|
__classPrivateFieldSet(this, _EmitterInstance_firstSpawn, !this.options.life.wait, "f");
|
|
45
45
|
__classPrivateFieldSet(this, _EmitterInstance_startParticlesAdded, false, "f");
|
|
@@ -155,6 +155,40 @@ class EmitterInstance {
|
|
|
155
155
|
}
|
|
156
156
|
}
|
|
157
157
|
}
|
|
158
|
+
getPosition() {
|
|
159
|
+
if (this.options.domId) {
|
|
160
|
+
const container = this.container, element = document.getElementById(this.options.domId);
|
|
161
|
+
if (element) {
|
|
162
|
+
const elRect = element.getBoundingClientRect();
|
|
163
|
+
return {
|
|
164
|
+
x: (elRect.x + elRect.width / 2) * container.retina.pixelRatio,
|
|
165
|
+
y: (elRect.y + elRect.height / 2) * container.retina.pixelRatio,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
return this.position;
|
|
170
|
+
}
|
|
171
|
+
getSize() {
|
|
172
|
+
const container = this.container;
|
|
173
|
+
if (this.options.domId) {
|
|
174
|
+
const element = document.getElementById(this.options.domId);
|
|
175
|
+
if (element) {
|
|
176
|
+
const elRect = element.getBoundingClientRect();
|
|
177
|
+
return {
|
|
178
|
+
width: elRect.width * container.retina.pixelRatio,
|
|
179
|
+
height: elRect.height * container.retina.pixelRatio,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
width: this.size.mode === "percent"
|
|
185
|
+
? (container.canvas.size.width * this.size.width) / 100
|
|
186
|
+
: this.size.width,
|
|
187
|
+
height: this.size.mode === "percent"
|
|
188
|
+
? (container.canvas.size.height * this.size.height) / 100
|
|
189
|
+
: this.size.height,
|
|
190
|
+
};
|
|
191
|
+
}
|
|
158
192
|
prepareToDie() {
|
|
159
193
|
var _a;
|
|
160
194
|
if (this.paused) {
|
|
@@ -190,15 +224,8 @@ class EmitterInstance {
|
|
|
190
224
|
emitParticles(quantity) {
|
|
191
225
|
var _a, _b, _c;
|
|
192
226
|
const container = this.container;
|
|
193
|
-
const position = this.
|
|
194
|
-
const
|
|
195
|
-
x: this.size.mode === "percent"
|
|
196
|
-
? (container.canvas.size.width * this.size.width) / 100
|
|
197
|
-
: this.size.width,
|
|
198
|
-
y: this.size.mode === "percent"
|
|
199
|
-
? (container.canvas.size.height * this.size.height) / 100
|
|
200
|
-
: this.size.height,
|
|
201
|
-
};
|
|
227
|
+
const position = this.getPosition();
|
|
228
|
+
const size = this.getSize();
|
|
202
229
|
for (let i = 0; i < quantity; i++) {
|
|
203
230
|
const particlesOptions = (0, Utils_1.deepExtend)({}, this.particlesOptions);
|
|
204
231
|
if (this.spawnColor) {
|
|
@@ -217,7 +244,10 @@ class EmitterInstance {
|
|
|
217
244
|
particlesOptions.color.value = this.spawnColor;
|
|
218
245
|
}
|
|
219
246
|
}
|
|
220
|
-
|
|
247
|
+
if (!position) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
const pPosition = (_c = (_b = this.shape) === null || _b === void 0 ? void 0 : _b.randomPosition(position, size, this.fill)) !== null && _c !== void 0 ? _c : position;
|
|
221
251
|
container.particles.addParticle(pPosition, particlesOptions);
|
|
222
252
|
}
|
|
223
253
|
}
|
|
@@ -235,4 +265,4 @@ class EmitterInstance {
|
|
|
235
265
|
}
|
|
236
266
|
}
|
|
237
267
|
exports.EmitterInstance = EmitterInstance;
|
|
238
|
-
_EmitterInstance_firstSpawn = new WeakMap(), _EmitterInstance_startParticlesAdded = new WeakMap();
|
|
268
|
+
_EmitterInstance_firstSpawn = new WeakMap(), _EmitterInstance_startParticlesAdded = new WeakMap(), _EmitterInstance_engine = new WeakMap();
|
|
@@ -2,15 +2,17 @@ import type { Container, IContainerPlugin, ICoordinates, IDelta } from "../../Co
|
|
|
2
2
|
import type { RecursivePartial, SingleOrMultiple } from "../../Types";
|
|
3
3
|
import { Emitter } from "./Options/Classes/Emitter";
|
|
4
4
|
import { EmitterInstance } from "./EmitterInstance";
|
|
5
|
+
import type { EmittersEngine } from "./EmittersEngine";
|
|
5
6
|
import type { IEmitter } from "./Options/Interfaces/IEmitter";
|
|
6
7
|
import type { IEmitterOptions } from "./Options/Interfaces/IEmitterOptions";
|
|
7
8
|
import type { IOptions } from "../../Options/Interfaces/IOptions";
|
|
8
9
|
export declare class Emitters implements IContainerPlugin {
|
|
10
|
+
#private;
|
|
9
11
|
private readonly container;
|
|
10
12
|
array: EmitterInstance[];
|
|
11
13
|
emitters: SingleOrMultiple<Emitter>;
|
|
12
14
|
interactivityEmitters: SingleOrMultiple<Emitter>;
|
|
13
|
-
constructor(container: Container);
|
|
15
|
+
constructor(engine: EmittersEngine, container: Container);
|
|
14
16
|
init(options?: RecursivePartial<IOptions & IEmitterOptions>): void;
|
|
15
17
|
play(): void;
|
|
16
18
|
pause(): void;
|
|
@@ -1,12 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _Emitters_engine;
|
|
2
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
15
|
exports.Emitters = void 0;
|
|
4
16
|
const Utils_1 = require("../../Utils");
|
|
5
17
|
const Emitter_1 = require("./Options/Classes/Emitter");
|
|
6
18
|
const EmitterInstance_1 = require("./EmitterInstance");
|
|
7
19
|
class Emitters {
|
|
8
|
-
constructor(container) {
|
|
20
|
+
constructor(engine, container) {
|
|
9
21
|
this.container = container;
|
|
22
|
+
_Emitters_engine.set(this, void 0);
|
|
23
|
+
__classPrivateFieldSet(this, _Emitters_engine, engine, "f");
|
|
10
24
|
this.array = [];
|
|
11
25
|
this.emitters = [];
|
|
12
26
|
this.interactivityEmitters = [];
|
|
@@ -124,7 +138,7 @@ class Emitters {
|
|
|
124
138
|
addEmitter(options, position) {
|
|
125
139
|
const emitterOptions = new Emitter_1.Emitter();
|
|
126
140
|
emitterOptions.load(options);
|
|
127
|
-
const emitter = new EmitterInstance_1.EmitterInstance(this, this.container, emitterOptions, position);
|
|
141
|
+
const emitter = new EmitterInstance_1.EmitterInstance(__classPrivateFieldGet(this, _Emitters_engine, "f"), this, this.container, emitterOptions, position);
|
|
128
142
|
this.array.push(emitter);
|
|
129
143
|
return emitter;
|
|
130
144
|
}
|
|
@@ -136,3 +150,4 @@ class Emitters {
|
|
|
136
150
|
}
|
|
137
151
|
}
|
|
138
152
|
exports.Emitters = Emitters;
|
|
153
|
+
_Emitters_engine = new WeakMap();
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Engine } from "../../engine";
|
|
2
2
|
import type { IEmitterShape } from "./IEmitterShape";
|
|
3
|
-
|
|
3
|
+
import type { ShapeManager } from "./ShapeManager";
|
|
4
|
+
export declare type EmittersEngine = Engine & {
|
|
5
|
+
emitterShapeManager?: ShapeManager;
|
|
4
6
|
addEmitterShape?: (name: string, shape: IEmitterShape) => void;
|
|
5
7
|
};
|
|
File without changes
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ICoordinates } from "../../Core";
|
|
1
|
+
import type { ICoordinates, IDimension } from "../../Core";
|
|
2
2
|
export interface IEmitterShape {
|
|
3
|
-
randomPosition(position: ICoordinates,
|
|
3
|
+
randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
|
|
4
4
|
}
|
|
@@ -13,6 +13,7 @@ export declare class Emitter implements IEmitter, IOptionLoader<IEmitter> {
|
|
|
13
13
|
autoPlay: boolean;
|
|
14
14
|
size?: EmitterSize;
|
|
15
15
|
direction?: MoveDirection | keyof typeof MoveDirection | MoveDirectionAlt | number;
|
|
16
|
+
domId?: string;
|
|
16
17
|
fill: boolean;
|
|
17
18
|
life: EmitterLife;
|
|
18
19
|
name?: string;
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import type { Engine } from "../../engine";
|
|
1
2
|
import type { IEmitterShape } from "./IEmitterShape";
|
|
2
3
|
export declare class ShapeManager {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
#private;
|
|
5
|
+
constructor(engine: Engine);
|
|
6
|
+
addShape(name: string, drawer: IEmitterShape): void;
|
|
7
|
+
getShape(name: string): IEmitterShape | undefined;
|
|
8
|
+
getSupportedShapes(): IterableIterator<string>;
|
|
6
9
|
}
|
|
@@ -1,18 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var _ShapeManager_engine;
|
|
2
9
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
10
|
exports.ShapeManager = void 0;
|
|
4
11
|
const shapes = new Map();
|
|
5
12
|
class ShapeManager {
|
|
6
|
-
|
|
7
|
-
|
|
13
|
+
constructor(engine) {
|
|
14
|
+
_ShapeManager_engine.set(this, void 0);
|
|
15
|
+
__classPrivateFieldSet(this, _ShapeManager_engine, engine, "f");
|
|
16
|
+
}
|
|
17
|
+
addShape(name, drawer) {
|
|
18
|
+
if (!this.getShape(name)) {
|
|
8
19
|
shapes.set(name, drawer);
|
|
9
20
|
}
|
|
10
21
|
}
|
|
11
|
-
|
|
22
|
+
getShape(name) {
|
|
12
23
|
return shapes.get(name);
|
|
13
24
|
}
|
|
14
|
-
|
|
25
|
+
getSupportedShapes() {
|
|
15
26
|
return shapes.keys();
|
|
16
27
|
}
|
|
17
28
|
}
|
|
18
29
|
exports.ShapeManager = ShapeManager;
|
|
30
|
+
_ShapeManager_engine = new WeakMap();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICoordinates } from "../../../../Core";
|
|
1
|
+
import type { ICoordinates, IDimension } from "../../../../Core";
|
|
2
2
|
import type { IEmitterShape } from "../../IEmitterShape";
|
|
3
3
|
export declare class CircleShape implements IEmitterShape {
|
|
4
|
-
randomPosition(position: ICoordinates,
|
|
4
|
+
randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
|
|
5
5
|
}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CircleShape = void 0;
|
|
4
4
|
class CircleShape {
|
|
5
|
-
randomPosition(position,
|
|
5
|
+
randomPosition(position, size, fill) {
|
|
6
6
|
const generateTheta = (x, y) => {
|
|
7
7
|
const u = Math.random() / 4.0;
|
|
8
8
|
const theta = Math.atan((y / x) * Math.tan(2 * Math.PI * u));
|
|
@@ -21,7 +21,7 @@ class CircleShape {
|
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
23
|
const radius = (x, y, theta) => (x * y) / Math.sqrt((y * Math.cos(theta)) ** 2 + (x * Math.sin(theta)) ** 2);
|
|
24
|
-
const [a, b] = [
|
|
24
|
+
const [a, b] = [size.width / 2, size.height / 2];
|
|
25
25
|
const randomTheta = generateTheta(a, b), maxRadius = radius(a, b, randomTheta), randomRadius = fill ? maxRadius * Math.sqrt(Math.random()) : maxRadius;
|
|
26
26
|
return {
|
|
27
27
|
x: position.x + randomRadius * Math.cos(randomTheta),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ICoordinates } from "../../../../Core";
|
|
1
|
+
import type { ICoordinates, IDimension } from "../../../../Core";
|
|
2
2
|
import type { IEmitterShape } from "../../IEmitterShape";
|
|
3
3
|
export declare class SquareShape implements IEmitterShape {
|
|
4
|
-
randomPosition(position: ICoordinates,
|
|
4
|
+
randomPosition(position: ICoordinates, size: IDimension, fill: boolean): ICoordinates;
|
|
5
5
|
}
|
|
@@ -5,15 +5,15 @@ function randomSquareCoordinate(position, offset) {
|
|
|
5
5
|
return position + offset * (Math.random() - 0.5);
|
|
6
6
|
}
|
|
7
7
|
class SquareShape {
|
|
8
|
-
randomPosition(position,
|
|
8
|
+
randomPosition(position, size, fill) {
|
|
9
9
|
if (fill) {
|
|
10
10
|
return {
|
|
11
|
-
x: randomSquareCoordinate(position.x,
|
|
12
|
-
y: randomSquareCoordinate(position.y,
|
|
11
|
+
x: randomSquareCoordinate(position.x, size.width),
|
|
12
|
+
y: randomSquareCoordinate(position.y, size.height),
|
|
13
13
|
};
|
|
14
14
|
}
|
|
15
15
|
else {
|
|
16
|
-
const halfW =
|
|
16
|
+
const halfW = size.width / 2, halfH = size.height / 2, side = Math.floor(Math.random() * 4), v = (Math.random() - 0.5) * 2;
|
|
17
17
|
switch (side) {
|
|
18
18
|
case 0:
|
|
19
19
|
return {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare function loadEmittersPlugin(engine:
|
|
3
|
-
export * from "./
|
|
1
|
+
import { EmittersEngine } from "./EmittersEngine";
|
|
2
|
+
export declare function loadEmittersPlugin(engine: EmittersEngine): Promise<void>;
|
|
3
|
+
export * from "./EmittersEngine";
|