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
|
@@ -9,6 +9,18 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
9
9
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
10
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
11
|
};
|
|
12
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
13
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
14
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
15
|
+
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");
|
|
16
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
17
|
+
};
|
|
18
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
19
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
20
|
+
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");
|
|
21
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
22
|
+
};
|
|
23
|
+
var _EmittersPlugin_engine;
|
|
12
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
25
|
exports.loadEmittersPlugin = void 0;
|
|
14
26
|
const CircleShape_1 = require("./Shapes/Circle/CircleShape");
|
|
@@ -18,11 +30,13 @@ const ShapeManager_1 = require("./ShapeManager");
|
|
|
18
30
|
const SquareShape_1 = require("./Shapes/Square/SquareShape");
|
|
19
31
|
const Utils_1 = require("../../Utils");
|
|
20
32
|
class EmittersPlugin {
|
|
21
|
-
constructor() {
|
|
33
|
+
constructor(engine) {
|
|
34
|
+
_EmittersPlugin_engine.set(this, void 0);
|
|
35
|
+
__classPrivateFieldSet(this, _EmittersPlugin_engine, engine, "f");
|
|
22
36
|
this.id = "emitters";
|
|
23
37
|
}
|
|
24
38
|
getPlugin(container) {
|
|
25
|
-
return new Emitters_1.Emitters(container);
|
|
39
|
+
return new Emitters_1.Emitters(__classPrivateFieldGet(this, _EmittersPlugin_engine, "f"), container);
|
|
26
40
|
}
|
|
27
41
|
needsPlugin(options) {
|
|
28
42
|
var _a, _b, _c;
|
|
@@ -76,16 +90,21 @@ class EmittersPlugin {
|
|
|
76
90
|
}
|
|
77
91
|
}
|
|
78
92
|
}
|
|
93
|
+
_EmittersPlugin_engine = new WeakMap();
|
|
79
94
|
async function loadEmittersPlugin(engine) {
|
|
80
|
-
|
|
81
|
-
|
|
95
|
+
if (!engine.emitterShapeManager) {
|
|
96
|
+
engine.emitterShapeManager = new ShapeManager_1.ShapeManager(engine);
|
|
97
|
+
}
|
|
82
98
|
if (!engine.addEmitterShape) {
|
|
83
99
|
engine.addEmitterShape = (name, shape) => {
|
|
84
|
-
|
|
100
|
+
var _a;
|
|
101
|
+
(_a = engine.emitterShapeManager) === null || _a === void 0 ? void 0 : _a.addShape(name, shape);
|
|
85
102
|
};
|
|
86
103
|
}
|
|
104
|
+
const plugin = new EmittersPlugin(engine);
|
|
105
|
+
await engine.addPlugin(plugin);
|
|
87
106
|
engine.addEmitterShape("circle", new CircleShape_1.CircleShape());
|
|
88
107
|
engine.addEmitterShape("square", new SquareShape_1.SquareShape());
|
|
89
108
|
}
|
|
90
109
|
exports.loadEmittersPlugin = loadEmittersPlugin;
|
|
91
|
-
__exportStar(require("./
|
|
110
|
+
__exportStar(require("./EmittersEngine"), exports);
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ React.js, Vue.js (2.x and 3.x), Angular, Svelte, jQuery, Preact, Inferno, Riot.j
|
|
|
9
9
|
|
|
10
10
|
[](https://join.slack.com/t/tsparticles/shared_invite/enQtOTcxNTQxNjQ4NzkxLWE2MTZhZWExMWRmOWI5MTMxNjczOGE1Yjk0MjViYjdkYTUzODM3OTc5MGQ5MjFlODc4MzE0N2Q1OWQxZDc1YzI) [](https://discord.gg/hACwv45Hme) [](https://t.me/tsparticles)
|
|
11
11
|
|
|
12
|
-
[](https://www.producthunt.com/posts/tsparticles?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-tsparticles")
|
|
12
|
+
[](https://www.producthunt.com/posts/tsparticles?utm_source=badge-featured&utm_medium=badge&utm_souce=badge-tsparticles") <a href="https://www.buymeacoffee.com/matteobruni"><img src="https://img.buymeacoffee.com/button-api/?text=Buy me a beer&emoji=🍺&slug=matteobruni&button_colour=5F7FFF&font_colour=ffffff&font_family=Arial&outline_colour=000000&coffee_colour=FFDD00"></a>
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import { FrameManager, Vector } from "./Utils";
|
|
6
6
|
import type { IAttract, IBubble, IContainerInteractivity, IContainerPlugin, IMovePathGenerator, IRepulse, IShapeDrawer } from "./Interfaces";
|
|
7
7
|
import { Canvas } from "./Canvas";
|
|
8
|
+
import type { Engine } from "../engine";
|
|
8
9
|
import type { IOptions } from "../Options/Interfaces/IOptions";
|
|
9
10
|
import { Options } from "../Options/Classes/Options";
|
|
10
11
|
import { Particle } from "./Particle";
|
|
@@ -17,6 +18,7 @@ import { Retina } from "./Retina";
|
|
|
17
18
|
* @category Core
|
|
18
19
|
*/
|
|
19
20
|
export declare class Container {
|
|
21
|
+
#private;
|
|
20
22
|
readonly id: string;
|
|
21
23
|
/**
|
|
22
24
|
* Check if the particles container is started
|
|
@@ -76,11 +78,12 @@ export declare class Container {
|
|
|
76
78
|
/**
|
|
77
79
|
* This is the core class, create an instance to have a new working particles manager
|
|
78
80
|
* @constructor
|
|
81
|
+
* @param engine the engine used by container
|
|
79
82
|
* @param id the id to identify this instance
|
|
80
83
|
* @param sourceOptions the options to load
|
|
81
84
|
* @param presets all the presets to load with options
|
|
82
85
|
*/
|
|
83
|
-
constructor(id: string, sourceOptions?: RecursivePartial<IOptions>, ...presets: string[]);
|
|
86
|
+
constructor(engine: Engine, id: string, sourceOptions?: RecursivePartial<IOptions>, ...presets: string[]);
|
|
84
87
|
/**
|
|
85
88
|
* Starts animations and resume from pause
|
|
86
89
|
* @param force
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
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");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Container_engine;
|
|
1
13
|
/**
|
|
2
14
|
* [[include:Container.md]]
|
|
3
15
|
* @packageDocumentation
|
|
4
16
|
*/
|
|
5
|
-
import { EventListeners, FrameManager,
|
|
17
|
+
import { EventListeners, FrameManager, Vector } from "./Utils";
|
|
6
18
|
import { animate, cancelAnimation, getRangeValue } from "../Utils";
|
|
7
19
|
import { Canvas } from "./Canvas";
|
|
8
20
|
import { Options } from "../Options/Classes/Options";
|
|
@@ -17,13 +29,16 @@ export class Container {
|
|
|
17
29
|
/**
|
|
18
30
|
* This is the core class, create an instance to have a new working particles manager
|
|
19
31
|
* @constructor
|
|
32
|
+
* @param engine the engine used by container
|
|
20
33
|
* @param id the id to identify this instance
|
|
21
34
|
* @param sourceOptions the options to load
|
|
22
35
|
* @param presets all the presets to load with options
|
|
23
36
|
*/
|
|
24
|
-
constructor(id, sourceOptions, ...presets) {
|
|
37
|
+
constructor(engine, id, sourceOptions, ...presets) {
|
|
25
38
|
this.id = id;
|
|
26
|
-
this
|
|
39
|
+
_Container_engine.set(this, void 0);
|
|
40
|
+
__classPrivateFieldSet(this, _Container_engine, engine, "f");
|
|
41
|
+
this.fpsLimit = 120;
|
|
27
42
|
this.duration = 0;
|
|
28
43
|
this.lifeTime = 0;
|
|
29
44
|
this.firstStart = true;
|
|
@@ -37,7 +52,7 @@ export class Container {
|
|
|
37
52
|
this._initialSourceOptions = sourceOptions;
|
|
38
53
|
this.retina = new Retina(this);
|
|
39
54
|
this.canvas = new Canvas(this);
|
|
40
|
-
this.particles = new Particles(this);
|
|
55
|
+
this.particles = new Particles(__classPrivateFieldGet(this, _Container_engine, "f"), this);
|
|
41
56
|
this.drawer = new FrameManager(this);
|
|
42
57
|
this.presets = presets;
|
|
43
58
|
this.pathGenerator = {
|
|
@@ -67,8 +82,8 @@ export class Container {
|
|
|
67
82
|
this.drawers = new Map();
|
|
68
83
|
this.density = 1;
|
|
69
84
|
/* tsParticles variables with default values */
|
|
70
|
-
this._options = new Options();
|
|
71
|
-
this.actualOptions = new Options();
|
|
85
|
+
this._options = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
86
|
+
this.actualOptions = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
72
87
|
/* ---------- tsParticles - start ------------ */
|
|
73
88
|
this.eventListeners = new EventListeners(this);
|
|
74
89
|
if (typeof IntersectionObserver !== "undefined" && IntersectionObserver) {
|
|
@@ -236,7 +251,7 @@ export class Container {
|
|
|
236
251
|
return this.start();
|
|
237
252
|
}
|
|
238
253
|
reset() {
|
|
239
|
-
this._options = new Options();
|
|
254
|
+
this._options = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
240
255
|
return this.refresh();
|
|
241
256
|
}
|
|
242
257
|
/**
|
|
@@ -253,7 +268,7 @@ export class Container {
|
|
|
253
268
|
this.particles.clear();
|
|
254
269
|
this.canvas.clear();
|
|
255
270
|
if (this.interactivity.element instanceof HTMLElement && this.intersectionObserver) {
|
|
256
|
-
this.intersectionObserver.
|
|
271
|
+
this.intersectionObserver.unobserve(this.interactivity.element);
|
|
257
272
|
}
|
|
258
273
|
for (const [, plugin] of this.plugins) {
|
|
259
274
|
if (plugin.stop) {
|
|
@@ -388,13 +403,13 @@ export class Container {
|
|
|
388
403
|
return false;
|
|
389
404
|
}
|
|
390
405
|
async init() {
|
|
391
|
-
this._options = new Options();
|
|
406
|
+
this._options = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
392
407
|
for (const preset of this.presets) {
|
|
393
|
-
this._options.load(
|
|
408
|
+
this._options.load(__classPrivateFieldGet(this, _Container_engine, "f").plugins.getPreset(preset));
|
|
394
409
|
}
|
|
395
|
-
const shapes =
|
|
410
|
+
const shapes = __classPrivateFieldGet(this, _Container_engine, "f").plugins.getSupportedShapes();
|
|
396
411
|
for (const type of shapes) {
|
|
397
|
-
const drawer =
|
|
412
|
+
const drawer = __classPrivateFieldGet(this, _Container_engine, "f").plugins.getShapeDrawer(type);
|
|
398
413
|
if (drawer) {
|
|
399
414
|
this.drawers.set(type, drawer);
|
|
400
415
|
}
|
|
@@ -402,7 +417,7 @@ export class Container {
|
|
|
402
417
|
/* options settings */
|
|
403
418
|
this._options.load(this._initialSourceOptions);
|
|
404
419
|
this._options.load(this._sourceOptions);
|
|
405
|
-
this.actualOptions = new Options();
|
|
420
|
+
this.actualOptions = new Options(__classPrivateFieldGet(this, _Container_engine, "f"));
|
|
406
421
|
this.actualOptions.load(this._options);
|
|
407
422
|
/* init canvas + particles */
|
|
408
423
|
this.retina.init();
|
|
@@ -413,8 +428,8 @@ export class Container {
|
|
|
413
428
|
this.zLayers = this.actualOptions.zLayers;
|
|
414
429
|
this.duration = getRangeValue(this.actualOptions.duration);
|
|
415
430
|
this.lifeTime = 0;
|
|
416
|
-
this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit :
|
|
417
|
-
const availablePlugins =
|
|
431
|
+
this.fpsLimit = this.actualOptions.fpsLimit > 0 ? this.actualOptions.fpsLimit : 120;
|
|
432
|
+
const availablePlugins = __classPrivateFieldGet(this, _Container_engine, "f").plugins.getAvailablePlugins(this);
|
|
418
433
|
for (const [id, plugin] of availablePlugins) {
|
|
419
434
|
this.plugins.set(id, plugin);
|
|
420
435
|
}
|
|
@@ -433,7 +448,7 @@ export class Container {
|
|
|
433
448
|
}
|
|
434
449
|
const pathOptions = this.actualOptions.particles.move.path;
|
|
435
450
|
if (pathOptions.generator) {
|
|
436
|
-
const customGenerator =
|
|
451
|
+
const customGenerator = __classPrivateFieldGet(this, _Container_engine, "f").plugins.getPathGenerator(pathOptions.generator);
|
|
437
452
|
if (customGenerator) {
|
|
438
453
|
if (customGenerator.init) {
|
|
439
454
|
this.pathGenerator.init = customGenerator.init;
|
|
@@ -471,3 +486,4 @@ export class Container {
|
|
|
471
486
|
}
|
|
472
487
|
}
|
|
473
488
|
}
|
|
489
|
+
_Container_engine = new WeakMap();
|
package/browser/Core/Loader.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Container } from "./Container";
|
|
2
|
+
import type { Engine } from "../engine";
|
|
2
3
|
import type { IOptions } from "../Options/Interfaces/IOptions";
|
|
3
4
|
import type { Particle } from "./Particle";
|
|
4
5
|
import type { RecursivePartial } from "../Types";
|
|
@@ -20,24 +21,26 @@ interface RemoteLoaderParams {
|
|
|
20
21
|
* @category Core
|
|
21
22
|
*/
|
|
22
23
|
export declare class Loader {
|
|
24
|
+
#private;
|
|
25
|
+
constructor(engine: Engine);
|
|
23
26
|
/**
|
|
24
27
|
* All the [[Container]] objects loaded
|
|
25
28
|
*/
|
|
26
|
-
|
|
29
|
+
dom(): Container[];
|
|
27
30
|
/**
|
|
28
31
|
* Retrieves a [[Container]] from all the objects loaded
|
|
29
32
|
* @param index the object index
|
|
30
33
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
+
domItem(index: number): Container | undefined;
|
|
35
|
+
loadOptions(params: LoaderParams): Promise<Container | undefined>;
|
|
36
|
+
loadRemoteOptions(params: RemoteLoaderParams): Promise<Container | undefined>;
|
|
34
37
|
/**
|
|
35
38
|
* Loads the provided options to create a [[Container]] object.
|
|
36
39
|
* @param tagId the particles container element id
|
|
37
40
|
* @param options the options object to initialize the [[Container]]
|
|
38
41
|
* @param index if an options array is provided, this will retrieve the exact index of that array
|
|
39
42
|
*/
|
|
40
|
-
|
|
43
|
+
load(tagId: string | SingleOrMultiple<RecursivePartial<IOptions>>, options?: SingleOrMultiple<RecursivePartial<IOptions>> | number, index?: number): Promise<Container | undefined>;
|
|
41
44
|
/**
|
|
42
45
|
* Loads the provided options to create a [[Container]] object.
|
|
43
46
|
* @param id the particles container element id
|
|
@@ -45,7 +48,7 @@ export declare class Loader {
|
|
|
45
48
|
* @param options the options object to initialize the [[Container]]
|
|
46
49
|
* @param index if an options array is provided, this will retrieve the exact index of that array
|
|
47
50
|
*/
|
|
48
|
-
|
|
51
|
+
set(id: string | HTMLElement, domContainer: HTMLElement | SingleOrMultiple<RecursivePartial<IOptions>>, options?: SingleOrMultiple<RecursivePartial<IOptions>> | number, index?: number): Promise<Container | undefined>;
|
|
49
52
|
/**
|
|
50
53
|
* Loads the provided json with a GET request. The content will be used to create a [[Container]] object.
|
|
51
54
|
* This method is async, so if you need a callback refer to JavaScript function `fetch`
|
|
@@ -54,7 +57,7 @@ export declare class Loader {
|
|
|
54
57
|
* @param index the index of the paths array, if a single path is passed this value is ignored
|
|
55
58
|
* @returns A Promise with the [[Container]] object created
|
|
56
59
|
*/
|
|
57
|
-
|
|
60
|
+
loadJSON(tagId: string | SingleOrMultiple<string>, jsonUrl?: SingleOrMultiple<string> | number, index?: number): Promise<Container | undefined>;
|
|
58
61
|
/**
|
|
59
62
|
* Loads the provided json with a GET request. The content will be used to create a [[Container]] object.
|
|
60
63
|
* This method is async, so if you need a callback refer to JavaScript function `fetch`
|
|
@@ -64,11 +67,11 @@ export declare class Loader {
|
|
|
64
67
|
* @param index the index of the paths array, if a single path is passed this value is ignored
|
|
65
68
|
* @returns A Promise with the [[Container]] object created
|
|
66
69
|
*/
|
|
67
|
-
|
|
70
|
+
setJSON(id: string | HTMLElement, domContainer: HTMLElement | SingleOrMultiple<string>, jsonUrl: SingleOrMultiple<string> | (number | undefined), index?: number): Promise<Container | undefined>;
|
|
68
71
|
/**
|
|
69
72
|
* Adds an additional click handler to all the loaded [[Container]] objects.
|
|
70
73
|
* @param callback the function called after the click event is fired
|
|
71
74
|
*/
|
|
72
|
-
|
|
75
|
+
setOnClickHandler(callback: (evt: Event, particles?: Particle[]) => void): void;
|
|
73
76
|
}
|
|
74
77
|
export {};
|
package/browser/Core/Loader.js
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
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");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Loader_engine;
|
|
1
13
|
import { Constants } from "./Utils";
|
|
2
14
|
import { Container } from "./Container";
|
|
3
15
|
import { itemFromArray } from "../Utils";
|
|
4
|
-
const tsParticlesDom = [];
|
|
5
16
|
function fetchError(statusCode) {
|
|
6
17
|
console.error(`Error tsParticles - fetch status: ${statusCode}`);
|
|
7
18
|
console.error("Error tsParticles - File config not found");
|
|
@@ -11,25 +22,29 @@ function fetchError(statusCode) {
|
|
|
11
22
|
* @category Core
|
|
12
23
|
*/
|
|
13
24
|
export class Loader {
|
|
25
|
+
constructor(engine) {
|
|
26
|
+
_Loader_engine.set(this, void 0);
|
|
27
|
+
__classPrivateFieldSet(this, _Loader_engine, engine, "f");
|
|
28
|
+
}
|
|
14
29
|
/**
|
|
15
30
|
* All the [[Container]] objects loaded
|
|
16
31
|
*/
|
|
17
|
-
|
|
18
|
-
return
|
|
32
|
+
dom() {
|
|
33
|
+
return __classPrivateFieldGet(this, _Loader_engine, "f").domArray;
|
|
19
34
|
}
|
|
20
35
|
/**
|
|
21
36
|
* Retrieves a [[Container]] from all the objects loaded
|
|
22
37
|
* @param index the object index
|
|
23
38
|
*/
|
|
24
|
-
|
|
25
|
-
const dom =
|
|
39
|
+
domItem(index) {
|
|
40
|
+
const dom = this.dom();
|
|
26
41
|
const item = dom[index];
|
|
27
42
|
if (item && !item.destroyed) {
|
|
28
43
|
return item;
|
|
29
44
|
}
|
|
30
45
|
dom.splice(index, 1);
|
|
31
46
|
}
|
|
32
|
-
|
|
47
|
+
async loadOptions(params) {
|
|
33
48
|
var _a, _b, _c;
|
|
34
49
|
const tagId = (_a = params.tagId) !== null && _a !== void 0 ? _a : `tsparticles${Math.floor(Math.random() * 10000)}`;
|
|
35
50
|
const { options, index } = params;
|
|
@@ -41,10 +56,10 @@ export class Loader {
|
|
|
41
56
|
(_c = document.querySelector("body")) === null || _c === void 0 ? void 0 : _c.append(domContainer);
|
|
42
57
|
}
|
|
43
58
|
const currentOptions = options instanceof Array ? itemFromArray(options, index) : options;
|
|
44
|
-
const dom =
|
|
59
|
+
const dom = this.dom();
|
|
45
60
|
const oldIndex = dom.findIndex((v) => v.id === tagId);
|
|
46
61
|
if (oldIndex >= 0) {
|
|
47
|
-
const old =
|
|
62
|
+
const old = this.domItem(oldIndex);
|
|
48
63
|
if (old && !old.destroyed) {
|
|
49
64
|
old.destroy();
|
|
50
65
|
dom.splice(oldIndex, 1);
|
|
@@ -74,7 +89,7 @@ export class Loader {
|
|
|
74
89
|
}
|
|
75
90
|
}
|
|
76
91
|
/* launch tsParticles */
|
|
77
|
-
const newItem = new Container(tagId, currentOptions);
|
|
92
|
+
const newItem = new Container(__classPrivateFieldGet(this, _Loader_engine, "f"), tagId, currentOptions);
|
|
78
93
|
if (oldIndex >= 0) {
|
|
79
94
|
dom.splice(oldIndex, 0, newItem);
|
|
80
95
|
}
|
|
@@ -85,7 +100,7 @@ export class Loader {
|
|
|
85
100
|
await newItem.start();
|
|
86
101
|
return newItem;
|
|
87
102
|
}
|
|
88
|
-
|
|
103
|
+
async loadRemoteOptions(params) {
|
|
89
104
|
const { url: jsonUrl, index } = params;
|
|
90
105
|
const url = jsonUrl instanceof Array ? itemFromArray(jsonUrl, index) : jsonUrl;
|
|
91
106
|
if (!url) {
|
|
@@ -97,7 +112,7 @@ export class Loader {
|
|
|
97
112
|
return;
|
|
98
113
|
}
|
|
99
114
|
const data = await response.json();
|
|
100
|
-
return
|
|
115
|
+
return this.loadOptions({
|
|
101
116
|
tagId: params.tagId,
|
|
102
117
|
element: params.element,
|
|
103
118
|
index,
|
|
@@ -110,7 +125,7 @@ export class Loader {
|
|
|
110
125
|
* @param options the options object to initialize the [[Container]]
|
|
111
126
|
* @param index if an options array is provided, this will retrieve the exact index of that array
|
|
112
127
|
*/
|
|
113
|
-
|
|
128
|
+
load(tagId, options, index) {
|
|
114
129
|
const params = { index };
|
|
115
130
|
if (typeof tagId === "string") {
|
|
116
131
|
params.tagId = tagId;
|
|
@@ -133,7 +148,7 @@ export class Loader {
|
|
|
133
148
|
* @param options the options object to initialize the [[Container]]
|
|
134
149
|
* @param index if an options array is provided, this will retrieve the exact index of that array
|
|
135
150
|
*/
|
|
136
|
-
|
|
151
|
+
async set(id, domContainer, options, index) {
|
|
137
152
|
const params = { index };
|
|
138
153
|
if (typeof id === "string") {
|
|
139
154
|
params.tagId = id;
|
|
@@ -163,7 +178,7 @@ export class Loader {
|
|
|
163
178
|
* @param index the index of the paths array, if a single path is passed this value is ignored
|
|
164
179
|
* @returns A Promise with the [[Container]] object created
|
|
165
180
|
*/
|
|
166
|
-
|
|
181
|
+
async loadJSON(tagId, jsonUrl, index) {
|
|
167
182
|
let url, id;
|
|
168
183
|
if (typeof jsonUrl === "number" || jsonUrl === undefined) {
|
|
169
184
|
url = tagId;
|
|
@@ -172,7 +187,7 @@ export class Loader {
|
|
|
172
187
|
id = tagId;
|
|
173
188
|
url = jsonUrl;
|
|
174
189
|
}
|
|
175
|
-
return
|
|
190
|
+
return this.loadRemoteOptions({ tagId: id, url, index });
|
|
176
191
|
}
|
|
177
192
|
/**
|
|
178
193
|
* Loads the provided json with a GET request. The content will be used to create a [[Container]] object.
|
|
@@ -183,7 +198,7 @@ export class Loader {
|
|
|
183
198
|
* @param index the index of the paths array, if a single path is passed this value is ignored
|
|
184
199
|
* @returns A Promise with the [[Container]] object created
|
|
185
200
|
*/
|
|
186
|
-
|
|
201
|
+
async setJSON(id, domContainer, jsonUrl, index) {
|
|
187
202
|
let url, newId, newIndex, element;
|
|
188
203
|
if (id instanceof HTMLElement) {
|
|
189
204
|
element = id;
|
|
@@ -196,14 +211,14 @@ export class Loader {
|
|
|
196
211
|
url = jsonUrl;
|
|
197
212
|
newIndex = index;
|
|
198
213
|
}
|
|
199
|
-
return
|
|
214
|
+
return this.loadRemoteOptions({ tagId: newId, url, index: newIndex, element });
|
|
200
215
|
}
|
|
201
216
|
/**
|
|
202
217
|
* Adds an additional click handler to all the loaded [[Container]] objects.
|
|
203
218
|
* @param callback the function called after the click event is fired
|
|
204
219
|
*/
|
|
205
|
-
|
|
206
|
-
const dom =
|
|
220
|
+
setOnClickHandler(callback) {
|
|
221
|
+
const dom = this.dom();
|
|
207
222
|
if (dom.length === 0) {
|
|
208
223
|
throw new Error("Can only set click handlers after calling tsParticles.load() or tsParticles.loadJSON()");
|
|
209
224
|
}
|
|
@@ -212,3 +227,4 @@ export class Loader {
|
|
|
212
227
|
}
|
|
213
228
|
}
|
|
214
229
|
}
|
|
230
|
+
_Loader_engine = new WeakMap();
|
|
@@ -2,6 +2,7 @@ import { ShapeType } from "../Enums";
|
|
|
2
2
|
import type { IBubbleParticleData, ICoordinates, ICoordinates3d, IDelta, IHsl, IParticle, IParticleGradientAnimation, IParticleHslAnimation, IParticleLife, IParticleNumericValueAnimation, IParticleRetinaProps, IParticleRoll, IParticleSpin, IParticleTiltValueAnimation, IParticleValueAnimation, IParticleWobble, IRgb, IShapeValues } from "./Interfaces";
|
|
3
3
|
import { Vector, Vector3d } from "./Utils";
|
|
4
4
|
import type { Container } from "./Container";
|
|
5
|
+
import type { Engine } from "../engine";
|
|
5
6
|
import type { IParticles } from "../Options/Interfaces/Particles/IParticles";
|
|
6
7
|
import { ParticlesOptions } from "../Options/Classes/Particles/ParticlesOptions";
|
|
7
8
|
import type { RecursivePartial } from "../Types";
|
|
@@ -11,6 +12,7 @@ import type { Stroke } from "../Options/Classes/Particles/Stroke";
|
|
|
11
12
|
* @category Core
|
|
12
13
|
*/
|
|
13
14
|
export declare class Particle implements IParticle {
|
|
15
|
+
#private;
|
|
14
16
|
readonly id: number;
|
|
15
17
|
readonly container: Container;
|
|
16
18
|
readonly group?: string | undefined;
|
|
@@ -53,7 +55,7 @@ export declare class Particle implements IParticle {
|
|
|
53
55
|
readonly bubble: IBubbleParticleData;
|
|
54
56
|
readonly zIndexFactor: number;
|
|
55
57
|
readonly retina: IParticleRetinaProps;
|
|
56
|
-
constructor(id: number, container: Container, position?: ICoordinates, overrideOptions?: RecursivePartial<IParticles>, group?: string | undefined);
|
|
58
|
+
constructor(engine: Engine, id: number, container: Container, position?: ICoordinates, overrideOptions?: RecursivePartial<IParticles>, group?: string | undefined);
|
|
57
59
|
isVisible(): boolean;
|
|
58
60
|
isInsideCanvas(): boolean;
|
|
59
61
|
draw(delta: IDelta): void;
|
package/browser/Core/Particle.js
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
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");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Particle_engine;
|
|
13
|
+
import { Vector, Vector3d } from "./Utils";
|
|
2
14
|
import { alterHsl, clamp, colorToRgb, deepExtend, getDistance, getHslFromAnimation, getParticleBaseVelocity, getParticleDirectionAngle, getRangeMax, getRangeMin, getRangeValue, getValue, isInArray, itemFromArray, randomInRange, setRangeValue, } from "../Utils";
|
|
3
15
|
import { ParticlesOptions } from "../Options/Classes/Particles/ParticlesOptions";
|
|
4
16
|
import { Shape } from "../Options/Classes/Particles/Shape/Shape";
|
|
@@ -17,11 +29,13 @@ const fixOutMode = (data) => {
|
|
|
17
29
|
* @category Core
|
|
18
30
|
*/
|
|
19
31
|
export class Particle {
|
|
20
|
-
constructor(id, container, position, overrideOptions, group) {
|
|
32
|
+
constructor(engine, id, container, position, overrideOptions, group) {
|
|
21
33
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
22
34
|
this.id = id;
|
|
23
35
|
this.container = container;
|
|
24
36
|
this.group = group;
|
|
37
|
+
_Particle_engine.set(this, void 0);
|
|
38
|
+
__classPrivateFieldSet(this, _Particle_engine, engine, "f");
|
|
25
39
|
this.fill = true;
|
|
26
40
|
this.close = true;
|
|
27
41
|
this.lastPathTime = 0;
|
|
@@ -124,7 +138,7 @@ export class Particle {
|
|
|
124
138
|
this.sides = 24;
|
|
125
139
|
let drawer = container.drawers.get(this.shape);
|
|
126
140
|
if (!drawer) {
|
|
127
|
-
drawer =
|
|
141
|
+
drawer = __classPrivateFieldGet(this, _Particle_engine, "f").plugins.getShapeDrawer(this.shape);
|
|
128
142
|
if (drawer) {
|
|
129
143
|
container.drawers.set(this.shape, drawer);
|
|
130
144
|
}
|
|
@@ -376,3 +390,4 @@ export class Particle {
|
|
|
376
390
|
return life;
|
|
377
391
|
}
|
|
378
392
|
}
|
|
393
|
+
_Particle_engine = new WeakMap();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ICoordinates, IDelta, IMouseData, IParticle, IRgb } from "./Interfaces";
|
|
2
2
|
import { QuadTree } from "./Utils";
|
|
3
3
|
import type { Container } from "./Container";
|
|
4
|
+
import type { Engine } from "../engine";
|
|
4
5
|
import type { IParticles } from "../Options/Interfaces/Particles/IParticles";
|
|
5
6
|
import { Particle } from "./Particle";
|
|
6
7
|
import type { RecursivePartial } from "../Types";
|
|
@@ -9,6 +10,7 @@ import type { RecursivePartial } from "../Types";
|
|
|
9
10
|
* @category Core
|
|
10
11
|
*/
|
|
11
12
|
export declare class Particles {
|
|
13
|
+
#private;
|
|
12
14
|
private readonly container;
|
|
13
15
|
get count(): number;
|
|
14
16
|
/**
|
|
@@ -32,7 +34,7 @@ export declare class Particles {
|
|
|
32
34
|
private nextId;
|
|
33
35
|
private readonly freqs;
|
|
34
36
|
private readonly mover;
|
|
35
|
-
constructor(container: Container);
|
|
37
|
+
constructor(engine: Engine, container: Container);
|
|
36
38
|
init(): void;
|
|
37
39
|
redraw(): void;
|
|
38
40
|
removeAt(index: number, quantity?: number, group?: string, override?: boolean): void;
|
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
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");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
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");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _Particles_engine;
|
|
13
|
+
import { InteractionManager, ParticlesMover, Point, QuadTree, Rectangle } from "./Utils";
|
|
2
14
|
import { getRangeMax, getRangeMin, getRangeValue, randomInRange, setRangeValue } from "../Utils";
|
|
3
15
|
import { Particle } from "./Particle";
|
|
4
16
|
import { ParticlesOptions } from "../Options/Classes/Particles/ParticlesOptions";
|
|
@@ -7,8 +19,10 @@ import { ParticlesOptions } from "../Options/Classes/Particles/ParticlesOptions"
|
|
|
7
19
|
* @category Core
|
|
8
20
|
*/
|
|
9
21
|
export class Particles {
|
|
10
|
-
constructor(container) {
|
|
22
|
+
constructor(engine, container) {
|
|
11
23
|
this.container = container;
|
|
24
|
+
_Particles_engine.set(this, void 0);
|
|
25
|
+
__classPrivateFieldSet(this, _Particles_engine, engine, "f");
|
|
12
26
|
this.nextId = 0;
|
|
13
27
|
this.array = [];
|
|
14
28
|
this.zArray = [];
|
|
@@ -20,11 +34,11 @@ export class Particles {
|
|
|
20
34
|
links: new Map(),
|
|
21
35
|
triangles: new Map(),
|
|
22
36
|
};
|
|
23
|
-
this.interactionManager = new InteractionManager(container);
|
|
37
|
+
this.interactionManager = new InteractionManager(__classPrivateFieldGet(this, _Particles_engine, "f"), container);
|
|
24
38
|
const canvasSize = this.container.canvas.size;
|
|
25
39
|
this.linksColors = new Map();
|
|
26
40
|
this.quadTree = new QuadTree(new Rectangle(-canvasSize.width / 4, -canvasSize.height / 4, (canvasSize.width * 3) / 2, (canvasSize.height * 3) / 2), 4);
|
|
27
|
-
this.updaters =
|
|
41
|
+
this.updaters = __classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
|
|
28
42
|
}
|
|
29
43
|
get count() {
|
|
30
44
|
return this.array.length;
|
|
@@ -39,7 +53,7 @@ export class Particles {
|
|
|
39
53
|
this.freqs.links = new Map();
|
|
40
54
|
this.freqs.triangles = new Map();
|
|
41
55
|
let handled = false;
|
|
42
|
-
this.updaters =
|
|
56
|
+
this.updaters = __classPrivateFieldGet(this, _Particles_engine, "f").plugins.getUpdaters(container, true);
|
|
43
57
|
this.interactionManager.init();
|
|
44
58
|
for (const [, plugin] of container.plugins) {
|
|
45
59
|
if (plugin.particlesInitialization !== undefined) {
|
|
@@ -306,7 +320,7 @@ export class Particles {
|
|
|
306
320
|
}
|
|
307
321
|
pushParticle(position, overrideOptions, group, initializer) {
|
|
308
322
|
try {
|
|
309
|
-
const particle = new Particle(this.nextId, this.container, position, overrideOptions, group);
|
|
323
|
+
const particle = new Particle(__classPrivateFieldGet(this, _Particles_engine, "f"), this.nextId, this.container, position, overrideOptions, group);
|
|
310
324
|
let canAdd = true;
|
|
311
325
|
if (initializer) {
|
|
312
326
|
canAdd = initializer(particle);
|
|
@@ -325,3 +339,4 @@ export class Particles {
|
|
|
325
339
|
}
|
|
326
340
|
}
|
|
327
341
|
}
|
|
342
|
+
_Particles_engine = new WeakMap();
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { IDelta } from "../Interfaces";
|
|
2
2
|
import type { Container } from "../Container";
|
|
3
|
+
import type { Engine } from "../../engine";
|
|
3
4
|
import type { Particle } from "../Particle";
|
|
4
5
|
/**
|
|
5
6
|
* @category Core
|
|
6
7
|
*/
|
|
7
8
|
export declare class InteractionManager {
|
|
9
|
+
#private;
|
|
8
10
|
private readonly container;
|
|
9
|
-
private
|
|
10
|
-
private
|
|
11
|
-
constructor(container: Container);
|
|
11
|
+
private externalInteractors;
|
|
12
|
+
private particleInteractors;
|
|
13
|
+
constructor(engine: Engine, container: Container);
|
|
12
14
|
init(): void;
|
|
13
15
|
externalInteract(delta: IDelta): void;
|
|
14
16
|
particlesInteract(particle: Particle, delta: IDelta): void;
|