@tsparticles/plugin-absorbers 4.0.0-beta.11 → 4.0.0-beta.15

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.
@@ -1,377 +1,620 @@
1
- /*!
2
- * Author : Matteo Bruni
3
- * MIT license: https://opensource.org/licenses/MIT
4
- * Demo / Generator : https://particles.js.org/
5
- * GitHub : https://www.github.com/matteobruni/tsparticles
6
- * How to use? : Check the GitHub README
7
- * v4.0.0-beta.11
8
- */
9
- /*
10
- * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
11
- * This devtool is neither made for production nor for readable output files.
12
- * It uses "eval()" calls to create a separate source file in the browser devtools.
13
- * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
14
- * or disable the default devtool with "devtool: false".
15
- * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
16
- */
17
- (function webpackUniversalModuleDefinition(root, factory) {
18
- if(typeof exports === 'object' && typeof module === 'object')
19
- module.exports = factory(require("@tsparticles/plugin-interactivity"), require("@tsparticles/engine"));
20
- else if(typeof define === 'function' && define.amd)
21
- define(["@tsparticles/plugin-interactivity", "@tsparticles/engine"], factory);
22
- else {
23
- var a = typeof exports === 'object' ? factory(require("@tsparticles/plugin-interactivity"), require("@tsparticles/engine")) : factory(root["window"], root["window"]);
24
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
25
- }
26
- })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__, __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
27
- return /******/ (() => { // webpackBootstrap
28
- /******/ "use strict";
29
- /******/ var __webpack_modules__ = ({
1
+ (function(g){g.__tsParticlesInternals=g.__tsParticlesInternals||{};g.__tsParticlesInternals.bundles=g.__tsParticlesInternals.bundles||{};g.__tsParticlesInternals.effects=g.__tsParticlesInternals.effects||{};g.__tsParticlesInternals.engine=g.__tsParticlesInternals.engine||{};g.__tsParticlesInternals.interactions=g.__tsParticlesInternals.interactions||{};g.__tsParticlesInternals.palettes=g.__tsParticlesInternals.palettes||{};g.__tsParticlesInternals.paths=g.__tsParticlesInternals.paths||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins=g.__tsParticlesInternals.plugins||{};g.__tsParticlesInternals.plugins.emittersShapes=g.__tsParticlesInternals.plugins.emittersShapes||{};g.__tsParticlesInternals.presets=g.__tsParticlesInternals.presets||{};g.__tsParticlesInternals.shapes=g.__tsParticlesInternals.shapes||{};g.__tsParticlesInternals.updaters=g.__tsParticlesInternals.updaters||{};g.__tsParticlesInternals.utils=g.__tsParticlesInternals.utils||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas=g.__tsParticlesInternals.canvas||{};g.__tsParticlesInternals.canvas.utils=g.__tsParticlesInternals.canvas.utils||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path=g.__tsParticlesInternals.path||{};g.__tsParticlesInternals.path.utils=g.__tsParticlesInternals.path.utils||{};var __tsProxyFactory=typeof Proxy!=="undefined"?function(obj){return new Proxy(obj,{get:function(target,key){if(!(key in target)){target[key]={};}return target[key];}});}:function(obj){return obj;};g.__tsParticlesInternals.bundles=__tsProxyFactory(g.__tsParticlesInternals.bundles);g.__tsParticlesInternals.effects=__tsProxyFactory(g.__tsParticlesInternals.effects);g.__tsParticlesInternals.interactions=__tsProxyFactory(g.__tsParticlesInternals.interactions);g.__tsParticlesInternals.palettes=__tsProxyFactory(g.__tsParticlesInternals.palettes);g.__tsParticlesInternals.paths=__tsProxyFactory(g.__tsParticlesInternals.paths);g.__tsParticlesInternals.plugins=__tsProxyFactory(g.__tsParticlesInternals.plugins);g.__tsParticlesInternals.plugins.emittersShapes=__tsProxyFactory(g.__tsParticlesInternals.plugins.emittersShapes);g.__tsParticlesInternals.presets=__tsProxyFactory(g.__tsParticlesInternals.presets);g.__tsParticlesInternals.shapes=__tsProxyFactory(g.__tsParticlesInternals.shapes);g.__tsParticlesInternals.updaters=__tsProxyFactory(g.__tsParticlesInternals.updaters);g.__tsParticlesInternals.utils=__tsProxyFactory(g.__tsParticlesInternals.utils);g.__tsParticlesInternals.canvas=__tsProxyFactory(g.__tsParticlesInternals.canvas);g.__tsParticlesInternals.path=__tsProxyFactory(g.__tsParticlesInternals.path);g.tsparticlesInternalExports=g.tsparticlesInternalExports||{};})(typeof globalThis!=="undefined"?globalThis:typeof window!=="undefined"?window:this);
2
+ /* Plugin v4.0.0-beta.15 */
3
+ (function (global, factory) {
4
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/plugin-interactivity'), require('@tsparticles/engine')) :
5
+ typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/plugin-interactivity', '@tsparticles/engine'], factory) :
6
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.plugins = global.__tsParticlesInternals.plugins || {}, global.__tsParticlesInternals.plugins.absorbers = global.__tsParticlesInternals.plugins.absorbers || {}), global.__tsParticlesInternals.plugins.interactivity, global.__tsParticlesInternals.engine));
7
+ })(this, (function (exports, pluginInteractivity, engine) { 'use strict';
30
8
 
31
- /***/ "@tsparticles/engine"
32
- /*!*********************************************************************************************************************************!*\
33
- !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
34
- \*********************************************************************************************************************************/
35
- (module) {
9
+ class AbsorberLife {
10
+ count;
11
+ delay;
12
+ duration;
13
+ wait;
14
+ constructor() {
15
+ this.wait = false;
16
+ }
17
+ load(data) {
18
+ if (engine.isNull(data)) {
19
+ return;
20
+ }
21
+ if (data.count !== undefined) {
22
+ this.count = data.count;
23
+ }
24
+ if (data.delay !== undefined) {
25
+ this.delay = engine.setRangeValue(data.delay);
26
+ }
27
+ if (data.duration !== undefined) {
28
+ this.duration = engine.setRangeValue(data.duration);
29
+ }
30
+ if (data.wait !== undefined) {
31
+ this.wait = data.wait;
32
+ }
33
+ }
34
+ }
36
35
 
37
- module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
36
+ class AbsorberSizeLimit {
37
+ mass;
38
+ radius;
39
+ constructor() {
40
+ this.radius = 0;
41
+ this.mass = 0;
42
+ }
43
+ load(data) {
44
+ if (engine.isNull(data)) {
45
+ return;
46
+ }
47
+ if (data.mass !== undefined) {
48
+ this.mass = data.mass;
49
+ }
50
+ if (data.radius !== undefined) {
51
+ this.radius = data.radius;
52
+ }
53
+ }
54
+ }
38
55
 
39
- /***/ },
56
+ class AbsorberSize extends engine.ValueWithRandom {
57
+ density;
58
+ limit;
59
+ constructor() {
60
+ super();
61
+ this.density = 5;
62
+ this.value = 50;
63
+ this.limit = new AbsorberSizeLimit();
64
+ }
65
+ load(data) {
66
+ if (engine.isNull(data)) {
67
+ return;
68
+ }
69
+ super.load(data);
70
+ if (data.density !== undefined) {
71
+ this.density = data.density;
72
+ }
73
+ if (engine.isNumber(data.limit)) {
74
+ this.limit.radius = data.limit;
75
+ }
76
+ else {
77
+ this.limit.load(data.limit);
78
+ }
79
+ }
80
+ }
40
81
 
41
- /***/ "@tsparticles/plugin-interactivity"
42
- /*!***************************************************************************************************************************************************************************!*\
43
- !*** external {"commonjs":"@tsparticles/plugin-interactivity","commonjs2":"@tsparticles/plugin-interactivity","amd":"@tsparticles/plugin-interactivity","root":"window"} ***!
44
- \***************************************************************************************************************************************************************************/
45
- (module) {
82
+ class Absorber {
83
+ color;
84
+ destroy;
85
+ draggable;
86
+ life;
87
+ name;
88
+ opacity;
89
+ orbits;
90
+ position;
91
+ size;
92
+ constructor() {
93
+ this.color = new engine.OptionsColor();
94
+ this.color.value = "#000000";
95
+ this.draggable = false;
96
+ this.opacity = 1;
97
+ this.destroy = true;
98
+ this.orbits = false;
99
+ this.life = new AbsorberLife();
100
+ this.size = new AbsorberSize();
101
+ }
102
+ load(data) {
103
+ if (engine.isNull(data)) {
104
+ return;
105
+ }
106
+ if (data.color !== undefined) {
107
+ this.color = engine.OptionsColor.create(this.color, data.color);
108
+ }
109
+ if (data.draggable !== undefined) {
110
+ this.draggable = data.draggable;
111
+ }
112
+ if (data.life !== undefined) {
113
+ this.life.load(data.life);
114
+ }
115
+ this.name = data.name;
116
+ if (data.opacity !== undefined) {
117
+ this.opacity = data.opacity;
118
+ }
119
+ if (data.position !== undefined) {
120
+ this.position = {};
121
+ if (data.position.x !== undefined) {
122
+ this.position.x = engine.setRangeValue(data.position.x);
123
+ }
124
+ if (data.position.y !== undefined) {
125
+ this.position.y = engine.setRangeValue(data.position.y);
126
+ }
127
+ }
128
+ if (data.size !== undefined) {
129
+ this.size.load(data.size);
130
+ }
131
+ if (data.destroy !== undefined) {
132
+ this.destroy = data.destroy;
133
+ }
134
+ if (data.orbits !== undefined) {
135
+ this.orbits = data.orbits;
136
+ }
137
+ }
138
+ }
46
139
 
47
- module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
140
+ const absorbersMode = "absorbers";
141
+ class AbsorbersInteractor extends pluginInteractivity.ExternalInteractorBase {
142
+ handleClickMode;
143
+ maxDistance;
144
+ _dragging = false;
145
+ _draggingAbsorber;
146
+ _instancesManager;
147
+ constructor(container, instancesManager) {
148
+ super(container);
149
+ this.maxDistance = 0;
150
+ this._instancesManager = instancesManager;
151
+ this._instancesManager.initContainer(container);
152
+ this.handleClickMode = (mode, interactivityData) => {
153
+ const container = this.container, options = container.actualOptions, absorbers = options.interactivity.modes.absorbers;
154
+ if (!absorbers || mode !== absorbersMode) {
155
+ return;
156
+ }
157
+ const { clickPosition } = interactivityData.mouse;
158
+ if (clickPosition) {
159
+ const existingAbsorber = instancesManager
160
+ .getArray(this.container)
161
+ .some(t => engine.getDistance(t.position, clickPosition) < t.size);
162
+ if (existingAbsorber) {
163
+ return;
164
+ }
165
+ }
166
+ const absorbersModeOptions = engine.itemFromArray(absorbers) ?? new Absorber();
167
+ void this._instancesManager.addAbsorber(container, absorbersModeOptions, clickPosition);
168
+ };
169
+ }
170
+ clear() {
171
+ }
172
+ init() {
173
+ }
174
+ interact(interactivityData, delta) {
175
+ for (const particle of this.container.particles.filter(p => this.isEnabled(interactivityData, p))) {
176
+ for (const absorber of this._instancesManager.getArray(this.container)) {
177
+ if (absorber.options.draggable) {
178
+ const mouse = interactivityData.mouse;
179
+ if (mouse.clicking && mouse.downPosition) {
180
+ const mouseDist = engine.getDistance(absorber.position, mouse.downPosition);
181
+ if (mouseDist <= absorber.size) {
182
+ this._dragging = true;
183
+ this._draggingAbsorber = absorber;
184
+ }
185
+ }
186
+ else {
187
+ this._dragging = false;
188
+ this._draggingAbsorber = undefined;
189
+ }
190
+ if (this._dragging && this._draggingAbsorber == absorber && mouse.position) {
191
+ absorber.position.x = mouse.position.x;
192
+ absorber.position.y = mouse.position.y;
193
+ }
194
+ }
195
+ absorber.attract(particle, delta);
196
+ if (particle.destroyed) {
197
+ break;
198
+ }
199
+ }
200
+ }
201
+ }
202
+ isEnabled(interactivityData, particle) {
203
+ const container = this.container, options = container.actualOptions, mouse = interactivityData.mouse, events = (particle?.interactivity ?? options.interactivity).events;
204
+ if (!mouse.clickPosition || !events.onClick.enable) {
205
+ return false;
206
+ }
207
+ return engine.isInArray(absorbersMode, events.onClick.mode);
208
+ }
209
+ loadModeOptions(options, ...sources) {
210
+ options.absorbers ??= [];
211
+ for (const source of sources) {
212
+ if (!source) {
213
+ continue;
214
+ }
215
+ if (engine.isArray(source.absorbers)) {
216
+ for (const absorber of source.absorbers) {
217
+ const tmp = new Absorber();
218
+ tmp.load(absorber);
219
+ options.absorbers.push(tmp);
220
+ }
221
+ }
222
+ else {
223
+ const tmp = new Absorber();
224
+ tmp.load(source.absorbers);
225
+ options.absorbers.push(tmp);
226
+ }
227
+ }
228
+ }
229
+ reset() {
230
+ }
231
+ }
48
232
 
49
- /***/ },
233
+ const instancesManagers = new WeakMap();
234
+ function getAbsorbersInstancesManager(e) {
235
+ const pluginManager = e.pluginManager;
236
+ let manager = instancesManagers.get(pluginManager);
237
+ if (!manager) {
238
+ manager = Promise.resolve().then(function () { return AbsorbersInstancesManager$1; })
239
+ .then(({ AbsorbersInstancesManager }) => new AbsorbersInstancesManager(pluginManager))
240
+ .catch((error) => {
241
+ instancesManagers.delete(pluginManager);
242
+ throw error;
243
+ });
244
+ instancesManagers.set(pluginManager, manager);
245
+ }
246
+ return manager;
247
+ }
50
248
 
51
- /***/ "./dist/browser/index.js"
52
- /*!*******************************!*\
53
- !*** ./dist/browser/index.js ***!
54
- \*******************************/
55
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
249
+ async function loadAbsorbersInteraction(engine) {
250
+ engine.checkVersion("4.0.0-beta.15");
251
+ await engine.pluginManager.register(async (e) => {
252
+ const pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);
253
+ pluginInteractivity.ensureInteractivityPluginLoaded(e);
254
+ pluginManager.addInteractor?.("externalAbsorbers", container => {
255
+ return Promise.resolve(new AbsorbersInteractor(container, instancesManager));
256
+ });
257
+ });
258
+ }
56
259
 
57
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadAbsorbersPlugin: () => (/* binding */ loadAbsorbersPlugin)\n/* harmony export */ });\n/* harmony import */ var _interaction_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./interaction.js */ \"./dist/browser/interaction.js\");\n/* harmony import */ var _plugin_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./plugin.js */ \"./dist/browser/plugin.js\");\n\n\nasync function loadAbsorbersPlugin(engine) {\n await (0,_plugin_js__WEBPACK_IMPORTED_MODULE_1__.loadAbsorbersPluginSimple)(engine);\n await (0,_interaction_js__WEBPACK_IMPORTED_MODULE_0__.loadAbsorbersInteraction)(engine);\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-absorbers/./dist/browser/index.js?\n}");
260
+ class AbsorbersPlugin {
261
+ id = "absorbers";
262
+ _instancesManager;
263
+ constructor(instancesManager) {
264
+ this._instancesManager = instancesManager;
265
+ }
266
+ async getPlugin(container) {
267
+ const { AbsorbersPluginInstance } = await Promise.resolve().then(function () { return AbsorbersPluginInstance$1; });
268
+ return new AbsorbersPluginInstance(container, this._instancesManager);
269
+ }
270
+ loadOptions(_container, options, source) {
271
+ if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
272
+ return;
273
+ }
274
+ if (source?.absorbers) {
275
+ options.absorbers = engine.executeOnSingleOrMultiple(source.absorbers, absorber => {
276
+ const tmp = new Absorber();
277
+ tmp.load(absorber);
278
+ return tmp;
279
+ });
280
+ }
281
+ }
282
+ needsPlugin(options) {
283
+ if (!options) {
284
+ return false;
285
+ }
286
+ const absorbers = options.absorbers;
287
+ if (engine.isArray(absorbers)) {
288
+ return !!absorbers.length;
289
+ }
290
+ else if (absorbers) {
291
+ return true;
292
+ }
293
+ return false;
294
+ }
295
+ }
58
296
 
59
- /***/ },
297
+ async function loadAbsorbersPluginSimple(engine) {
298
+ engine.checkVersion("4.0.0-beta.15");
299
+ await engine.pluginManager.register(async (e) => {
300
+ const pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);
301
+ pluginManager.addPlugin(new AbsorbersPlugin(instancesManager));
302
+ });
303
+ }
60
304
 
61
- /***/ "./dist/browser/interaction.js"
62
- /*!*************************************!*\
63
- !*** ./dist/browser/interaction.js ***!
64
- \*************************************/
65
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
305
+ async function loadAbsorbersPlugin(engine) {
306
+ await loadAbsorbersPluginSimple(engine);
307
+ await loadAbsorbersInteraction(engine);
308
+ }
66
309
 
67
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadAbsorbersInteraction: () => (/* binding */ loadAbsorbersInteraction)\n/* harmony export */ });\nasync function loadAbsorbersInteraction(engine) {\n engine.checkVersion(\"4.0.0-beta.11\");\n await engine.pluginManager.register(async (e)=>{\n const [{ ensureInteractivityPluginLoaded }, { getAbsorbersInstancesManager }] = await Promise.all([\n Promise.resolve(/*! import() */).then(__webpack_require__.t.bind(__webpack_require__, /*! @tsparticles/plugin-interactivity */ \"@tsparticles/plugin-interactivity\", 19)),\n __webpack_require__.e(/*! import() */ \"dist_browser_getAbsorbersInstancesManager_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./getAbsorbersInstancesManager.js */ \"./dist/browser/getAbsorbersInstancesManager.js\"))\n ]), pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);\n ensureInteractivityPluginLoaded(e);\n pluginManager.addInteractor?.(\"externalAbsorbers\", async (container)=>{\n const { AbsorbersInteractor } = await __webpack_require__.e(/*! import() */ \"dist_browser_AbsorbersInteractor_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./AbsorbersInteractor.js */ \"./dist/browser/AbsorbersInteractor.js\"));\n return new AbsorbersInteractor(container, instancesManager);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-absorbers/./dist/browser/interaction.js?\n}");
310
+ const globalObject = globalThis;
311
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
312
+ globalObject.loadAbsorbersPlugin = loadAbsorbersPlugin;
68
313
 
69
- /***/ },
314
+ const defaultIndex = 0;
315
+ class AbsorbersInstancesManager {
316
+ _containerArrays;
317
+ _pluginManager;
318
+ constructor(pluginManager) {
319
+ this._pluginManager = pluginManager;
320
+ this._containerArrays = new Map();
321
+ }
322
+ async addAbsorber(container, options, position) {
323
+ const { AbsorberInstance } = await Promise.resolve().then(function () { return AbsorberInstance$1; }), absorber = new AbsorberInstance(this._pluginManager, container, options, position), array = this.getArray(container);
324
+ array.push(absorber);
325
+ return absorber;
326
+ }
327
+ clear(container) {
328
+ this.initContainer(container);
329
+ this._containerArrays.set(container, []);
330
+ }
331
+ getArray(container) {
332
+ this.initContainer(container);
333
+ let array = this._containerArrays.get(container);
334
+ if (!array) {
335
+ array = [];
336
+ this._containerArrays.set(container, array);
337
+ }
338
+ return array;
339
+ }
340
+ initContainer(container) {
341
+ if (this._containerArrays.has(container)) {
342
+ return;
343
+ }
344
+ this._containerArrays.set(container, []);
345
+ container.getAbsorber ??= (idxOrName) => {
346
+ const array = this.getArray(container);
347
+ return idxOrName === undefined || engine.isNumber(idxOrName)
348
+ ? array[idxOrName ?? defaultIndex]
349
+ : array.find(t => t.name === idxOrName);
350
+ };
351
+ container.addAbsorber ??= (options, position) => {
352
+ return this.addAbsorber(container, options, position);
353
+ };
354
+ }
355
+ removeAbsorber(container, absorber) {
356
+ const index = this.getArray(container).indexOf(absorber), deleteCount = 1;
357
+ if (index >= defaultIndex) {
358
+ this.getArray(container).splice(index, deleteCount);
359
+ }
360
+ }
361
+ }
70
362
 
71
- /***/ "./dist/browser/plugin.js"
72
- /*!********************************!*\
73
- !*** ./dist/browser/plugin.js ***!
74
- \********************************/
75
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
363
+ var AbsorbersInstancesManager$1 = /*#__PURE__*/Object.freeze({
364
+ __proto__: null,
365
+ AbsorbersInstancesManager: AbsorbersInstancesManager
366
+ });
76
367
 
77
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadAbsorbersPluginSimple: () => (/* binding */ loadAbsorbersPluginSimple)\n/* harmony export */ });\nasync function loadAbsorbersPluginSimple(engine) {\n engine.checkVersion(\"4.0.0-beta.11\");\n await engine.pluginManager.register(async (e)=>{\n const [{ getAbsorbersInstancesManager }, { AbsorbersPlugin }] = await Promise.all([\n __webpack_require__.e(/*! import() */ \"dist_browser_getAbsorbersInstancesManager_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./getAbsorbersInstancesManager.js */ \"./dist/browser/getAbsorbersInstancesManager.js\")),\n __webpack_require__.e(/*! import() */ \"dist_browser_AbsorbersPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./AbsorbersPlugin.js */ \"./dist/browser/AbsorbersPlugin.js\"))\n ]), pluginManager = e.pluginManager, instancesManager = await getAbsorbersInstancesManager(e);\n pluginManager.addPlugin(new AbsorbersPlugin(instancesManager));\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/plugin-absorbers/./dist/browser/plugin.js?\n}");
368
+ class AbsorbersPluginInstance {
369
+ _container;
370
+ _instancesManager;
371
+ constructor(container, instancesManager) {
372
+ this._container = container;
373
+ this._instancesManager = instancesManager;
374
+ this._instancesManager.initContainer(container);
375
+ }
376
+ draw(context) {
377
+ for (const absorber of this._instancesManager.getArray(this._container)) {
378
+ absorber.draw(context);
379
+ }
380
+ }
381
+ async init() {
382
+ const absorbers = this._container.actualOptions.absorbers, promises = engine.executeOnSingleOrMultiple(absorbers, async (absorber) => {
383
+ await this._instancesManager.addAbsorber(this._container, absorber);
384
+ });
385
+ if (engine.isArray(promises)) {
386
+ await Promise.all(promises);
387
+ }
388
+ else {
389
+ await promises;
390
+ }
391
+ }
392
+ particleUpdate(particle, delta) {
393
+ for (const absorber of this._instancesManager.getArray(this._container)) {
394
+ absorber.attract(particle, delta);
395
+ if (particle.destroyed) {
396
+ break;
397
+ }
398
+ }
399
+ }
400
+ resize() {
401
+ for (const absorber of this._instancesManager.getArray(this._container)) {
402
+ absorber.resize();
403
+ }
404
+ }
405
+ stop() {
406
+ this._instancesManager.clear(this._container);
407
+ }
408
+ }
78
409
 
79
- /***/ }
410
+ var AbsorbersPluginInstance$1 = /*#__PURE__*/Object.freeze({
411
+ __proto__: null,
412
+ AbsorbersPluginInstance: AbsorbersPluginInstance
413
+ });
80
414
 
81
- /******/ });
82
- /************************************************************************/
83
- /******/ // The module cache
84
- /******/ var __webpack_module_cache__ = {};
85
- /******/
86
- /******/ // The require function
87
- /******/ function __webpack_require__(moduleId) {
88
- /******/ // Check if module is in cache
89
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
90
- /******/ if (cachedModule !== undefined) {
91
- /******/ return cachedModule.exports;
92
- /******/ }
93
- /******/ // Create a new module (and put it into the cache)
94
- /******/ var module = __webpack_module_cache__[moduleId] = {
95
- /******/ // no module.id needed
96
- /******/ // no module.loaded needed
97
- /******/ exports: {}
98
- /******/ };
99
- /******/
100
- /******/ // Execute the module function
101
- /******/ if (!(moduleId in __webpack_modules__)) {
102
- /******/ delete __webpack_module_cache__[moduleId];
103
- /******/ var e = new Error("Cannot find module '" + moduleId + "'");
104
- /******/ e.code = 'MODULE_NOT_FOUND';
105
- /******/ throw e;
106
- /******/ }
107
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
108
- /******/
109
- /******/ // Return the exports of the module
110
- /******/ return module.exports;
111
- /******/ }
112
- /******/
113
- /******/ // expose the modules object (__webpack_modules__)
114
- /******/ __webpack_require__.m = __webpack_modules__;
115
- /******/
116
- /************************************************************************/
117
- /******/ /* webpack/runtime/create fake namespace object */
118
- /******/ (() => {
119
- /******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);
120
- /******/ var leafPrototypes;
121
- /******/ // create a fake namespace object
122
- /******/ // mode & 1: value is a module id, require it
123
- /******/ // mode & 2: merge all properties of value into the ns
124
- /******/ // mode & 4: return value when already ns object
125
- /******/ // mode & 16: return value when it's Promise-like
126
- /******/ // mode & 8|1: behave like require
127
- /******/ __webpack_require__.t = function(value, mode) {
128
- /******/ if(mode & 1) value = this(value);
129
- /******/ if(mode & 8) return value;
130
- /******/ if(typeof value === 'object' && value) {
131
- /******/ if((mode & 4) && value.__esModule) return value;
132
- /******/ if((mode & 16) && typeof value.then === 'function') return value;
133
- /******/ }
134
- /******/ var ns = Object.create(null);
135
- /******/ __webpack_require__.r(ns);
136
- /******/ var def = {};
137
- /******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
138
- /******/ for(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {
139
- /******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
140
- /******/ }
141
- /******/ def['default'] = () => (value);
142
- /******/ __webpack_require__.d(ns, def);
143
- /******/ return ns;
144
- /******/ };
145
- /******/ })();
146
- /******/
147
- /******/ /* webpack/runtime/define property getters */
148
- /******/ (() => {
149
- /******/ // define getter functions for harmony exports
150
- /******/ __webpack_require__.d = (exports, definition) => {
151
- /******/ for(var key in definition) {
152
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
153
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
154
- /******/ }
155
- /******/ }
156
- /******/ };
157
- /******/ })();
158
- /******/
159
- /******/ /* webpack/runtime/ensure chunk */
160
- /******/ (() => {
161
- /******/ __webpack_require__.f = {};
162
- /******/ // This file contains only the entry chunk.
163
- /******/ // The chunk loading function for additional chunks
164
- /******/ __webpack_require__.e = (chunkId) => {
165
- /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
166
- /******/ __webpack_require__.f[key](chunkId, promises);
167
- /******/ return promises;
168
- /******/ }, []));
169
- /******/ };
170
- /******/ })();
171
- /******/
172
- /******/ /* webpack/runtime/get javascript chunk filename */
173
- /******/ (() => {
174
- /******/ // This function allow to reference async chunks
175
- /******/ __webpack_require__.u = (chunkId) => {
176
- /******/ // return url for filenames based on template
177
- /******/ return "" + chunkId + ".js";
178
- /******/ };
179
- /******/ })();
180
- /******/
181
- /******/ /* webpack/runtime/global */
182
- /******/ (() => {
183
- /******/ __webpack_require__.g = (function() {
184
- /******/ if (typeof globalThis === 'object') return globalThis;
185
- /******/ try {
186
- /******/ return this || new Function('return this')();
187
- /******/ } catch (e) {
188
- /******/ if (typeof window === 'object') return window;
189
- /******/ }
190
- /******/ })();
191
- /******/ })();
192
- /******/
193
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
194
- /******/ (() => {
195
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
196
- /******/ })();
197
- /******/
198
- /******/ /* webpack/runtime/load script */
199
- /******/ (() => {
200
- /******/ var inProgress = {};
201
- /******/ var dataWebpackPrefix = "@tsparticles/plugin-absorbers:";
202
- /******/ // loadScript function to load a script via script tag
203
- /******/ __webpack_require__.l = (url, done, key, chunkId) => {
204
- /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
205
- /******/ var script, needAttach;
206
- /******/ if(key !== undefined) {
207
- /******/ var scripts = document.getElementsByTagName("script");
208
- /******/ for(var i = 0; i < scripts.length; i++) {
209
- /******/ var s = scripts[i];
210
- /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
211
- /******/ }
212
- /******/ }
213
- /******/ if(!script) {
214
- /******/ needAttach = true;
215
- /******/ script = document.createElement('script');
216
- /******/
217
- /******/ script.charset = 'utf-8';
218
- /******/ if (__webpack_require__.nc) {
219
- /******/ script.setAttribute("nonce", __webpack_require__.nc);
220
- /******/ }
221
- /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
222
- /******/
223
- /******/ script.src = url;
224
- /******/ }
225
- /******/ inProgress[url] = [done];
226
- /******/ var onScriptComplete = (prev, event) => {
227
- /******/ // avoid mem leaks in IE.
228
- /******/ script.onerror = script.onload = null;
229
- /******/ clearTimeout(timeout);
230
- /******/ var doneFns = inProgress[url];
231
- /******/ delete inProgress[url];
232
- /******/ script.parentNode && script.parentNode.removeChild(script);
233
- /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
234
- /******/ if(prev) return prev(event);
235
- /******/ }
236
- /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
237
- /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
238
- /******/ script.onload = onScriptComplete.bind(null, script.onload);
239
- /******/ needAttach && document.head.appendChild(script);
240
- /******/ };
241
- /******/ })();
242
- /******/
243
- /******/ /* webpack/runtime/make namespace object */
244
- /******/ (() => {
245
- /******/ // define __esModule on exports
246
- /******/ __webpack_require__.r = (exports) => {
247
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
248
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
249
- /******/ }
250
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
251
- /******/ };
252
- /******/ })();
253
- /******/
254
- /******/ /* webpack/runtime/publicPath */
255
- /******/ (() => {
256
- /******/ var scriptUrl;
257
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
258
- /******/ var document = __webpack_require__.g.document;
259
- /******/ if (!scriptUrl && document) {
260
- /******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
261
- /******/ scriptUrl = document.currentScript.src;
262
- /******/ if (!scriptUrl) {
263
- /******/ var scripts = document.getElementsByTagName("script");
264
- /******/ if(scripts.length) {
265
- /******/ var i = scripts.length - 1;
266
- /******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
267
- /******/ }
268
- /******/ }
269
- /******/ }
270
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
271
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
272
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
273
- /******/ scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
274
- /******/ __webpack_require__.p = scriptUrl;
275
- /******/ })();
276
- /******/
277
- /******/ /* webpack/runtime/jsonp chunk loading */
278
- /******/ (() => {
279
- /******/ // no baseURI
280
- /******/
281
- /******/ // object to store loaded and loading chunks
282
- /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
283
- /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
284
- /******/ var installedChunks = {
285
- /******/ "tsparticles.plugin.absorbers": 0
286
- /******/ };
287
- /******/
288
- /******/ __webpack_require__.f.j = (chunkId, promises) => {
289
- /******/ // JSONP chunk loading for javascript
290
- /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
291
- /******/ if(installedChunkData !== 0) { // 0 means "already installed".
292
- /******/
293
- /******/ // a Promise means "currently loading".
294
- /******/ if(installedChunkData) {
295
- /******/ promises.push(installedChunkData[2]);
296
- /******/ } else {
297
- /******/ if(true) { // all chunks have JS
298
- /******/ // setup Promise in chunk cache
299
- /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
300
- /******/ promises.push(installedChunkData[2] = promise);
301
- /******/
302
- /******/ // start chunk loading
303
- /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
304
- /******/ // create error before stack unwound to get useful stacktrace later
305
- /******/ var error = new Error();
306
- /******/ var loadingEnded = (event) => {
307
- /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
308
- /******/ installedChunkData = installedChunks[chunkId];
309
- /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
310
- /******/ if(installedChunkData) {
311
- /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
312
- /******/ var realSrc = event && event.target && event.target.src;
313
- /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
314
- /******/ error.name = 'ChunkLoadError';
315
- /******/ error.type = errorType;
316
- /******/ error.request = realSrc;
317
- /******/ installedChunkData[1](error);
318
- /******/ }
319
- /******/ }
320
- /******/ };
321
- /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
322
- /******/ }
323
- /******/ }
324
- /******/ }
325
- /******/ };
326
- /******/
327
- /******/ // no prefetching
328
- /******/
329
- /******/ // no preloaded
330
- /******/
331
- /******/ // no HMR
332
- /******/
333
- /******/ // no HMR manifest
334
- /******/
335
- /******/ // no on chunks loaded
336
- /******/
337
- /******/ // install a JSONP callback for chunk loading
338
- /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
339
- /******/ var [chunkIds, moreModules, runtime] = data;
340
- /******/ // add "moreModules" to the modules object,
341
- /******/ // then flag all "chunkIds" as loaded and fire callback
342
- /******/ var moduleId, chunkId, i = 0;
343
- /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
344
- /******/ for(moduleId in moreModules) {
345
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
346
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
347
- /******/ }
348
- /******/ }
349
- /******/ if(runtime) var result = runtime(__webpack_require__);
350
- /******/ }
351
- /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
352
- /******/ for(;i < chunkIds.length; i++) {
353
- /******/ chunkId = chunkIds[i];
354
- /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
355
- /******/ installedChunks[chunkId][0]();
356
- /******/ }
357
- /******/ installedChunks[chunkId] = 0;
358
- /******/ }
359
- /******/
360
- /******/ }
361
- /******/
362
- /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_absorbers"] = this["webpackChunk_tsparticles_plugin_absorbers"] || [];
363
- /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
364
- /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
365
- /******/ })();
366
- /******/
367
- /************************************************************************/
368
- /******/
369
- /******/ // startup
370
- /******/ // Load entry module and return exports
371
- /******/ // This entry module can't be inlined because the eval devtool is used.
372
- /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
373
- /******/
374
- /******/ return __webpack_exports__;
375
- /******/ })()
376
- ;
377
- });
415
+ const squareExp = 2, absorbFactor = 0.033, minOrbitLength = 0, minRadius = 0, minMass = 0, minAngle = 0, maxAngle = engine.doublePI, maxDegreeAngle = 360, angleIncrementFactor = engine.identity / maxDegreeAngle, minVelocity = 0, defaultLifeDelay = 0, minLifeCount = 0, defaultSpawnDelay = 0, defaultLifeCount = -1;
416
+ class AbsorberInstance {
417
+ color;
418
+ limit;
419
+ mass;
420
+ name;
421
+ opacity;
422
+ options;
423
+ position;
424
+ size;
425
+ _container;
426
+ _currentDuration;
427
+ _currentSpawnDelay;
428
+ _duration;
429
+ _firstSpawn;
430
+ _immortal;
431
+ _lifeCount;
432
+ _pluginManager;
433
+ _spawnDelay;
434
+ initialPosition;
435
+ constructor(pluginManager, container, options, position) {
436
+ this._container = container;
437
+ this._pluginManager = pluginManager;
438
+ this._currentDuration = 0;
439
+ this._currentSpawnDelay = 0;
440
+ this.initialPosition = position ? engine.Vector.create(position.x, position.y) : undefined;
441
+ if (options instanceof Absorber) {
442
+ this.options = options;
443
+ }
444
+ else {
445
+ this.options = new Absorber();
446
+ this.options.load(options);
447
+ }
448
+ this.name = this.options.name;
449
+ this.opacity = this.options.opacity;
450
+ this.size = engine.getRangeValue(this.options.size.value) * container.retina.pixelRatio;
451
+ this.mass = this.size * this.options.size.density * container.retina.reduceFactor;
452
+ const limit = this.options.size.limit;
453
+ this.limit = {
454
+ radius: limit.radius * container.retina.pixelRatio * container.retina.reduceFactor,
455
+ mass: limit.mass,
456
+ };
457
+ this.color = engine.rangeColorToRgb(this._pluginManager, this.options.color) ?? {
458
+ b: 0,
459
+ g: 0,
460
+ r: 0,
461
+ };
462
+ this.position = this.initialPosition?.copy() ?? this._calcPosition();
463
+ this._firstSpawn = !this.options.life.wait;
464
+ this._lifeCount = this.options.life.count ?? defaultLifeCount;
465
+ this._immortal = this._lifeCount <= minLifeCount;
466
+ this._spawnDelay = container.retina.reduceFactor
467
+ ? (engine.getRangeValue(this.options.life.delay ?? defaultLifeDelay) * engine.millisecondsToSeconds) /
468
+ container.retina.reduceFactor
469
+ : Infinity;
470
+ }
471
+ attract(particle, delta) {
472
+ const container = this._container, options = this.options, pos = particle.getPosition(), { dx, dy, distance } = engine.getDistances(this.position, pos), v = engine.Vector.create(dx, dy);
473
+ v.length = (this.mass / Math.pow(distance, squareExp)) * container.retina.reduceFactor;
474
+ if (distance < this.size + particle.getRadius()) {
475
+ const sizeFactor = particle.getRadius() * absorbFactor * container.retina.pixelRatio * delta.factor;
476
+ if ((this.size > particle.getRadius() && distance < this.size - particle.getRadius()) ||
477
+ (particle.absorberOrbit !== undefined && particle.absorberOrbit.length < minOrbitLength)) {
478
+ if (options.destroy) {
479
+ particle.destroy();
480
+ }
481
+ else {
482
+ particle.needsNewPosition = true;
483
+ this._updateParticlePosition(particle, delta, v);
484
+ }
485
+ }
486
+ else {
487
+ if (options.destroy) {
488
+ particle.size.value -= sizeFactor;
489
+ }
490
+ this._updateParticlePosition(particle, delta, v);
491
+ }
492
+ if (this.limit.radius <= minRadius || this.size < this.limit.radius) {
493
+ this.size += sizeFactor;
494
+ }
495
+ if (this.limit.mass <= minMass || this.mass < this.limit.mass) {
496
+ this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
497
+ }
498
+ }
499
+ else {
500
+ this._updateParticlePosition(particle, delta, v);
501
+ }
502
+ }
503
+ draw(context) {
504
+ context.translate(this.position.x, this.position.y);
505
+ context.beginPath();
506
+ context.arc(engine.originPoint.x, engine.originPoint.y, this.size, minAngle, maxAngle, false);
507
+ context.closePath();
508
+ context.fillStyle = engine.getStyleFromRgb(this.color, this._container.hdr, this.opacity);
509
+ context.fill();
510
+ }
511
+ resize() {
512
+ const initialPosition = this.initialPosition;
513
+ this.position =
514
+ initialPosition && engine.isPointInside(initialPosition, this._container.canvas.size, engine.Vector.origin)
515
+ ? initialPosition
516
+ : this._calcPosition();
517
+ }
518
+ update(delta) {
519
+ if (this._firstSpawn) {
520
+ this._firstSpawn = false;
521
+ this._currentSpawnDelay = this._spawnDelay ?? defaultSpawnDelay;
522
+ }
523
+ if (this._duration !== undefined) {
524
+ this._currentDuration += delta.value;
525
+ if (this._currentDuration >= this._duration) {
526
+ if (!this._immortal) {
527
+ this._lifeCount--;
528
+ }
529
+ if (this._lifeCount > minLifeCount || this._immortal) {
530
+ this.position = this._calcPosition();
531
+ this._spawnDelay = this._container.retina.reduceFactor
532
+ ? (engine.getRangeValue(this.options.life.delay ?? defaultLifeDelay) * engine.millisecondsToSeconds) /
533
+ this._container.retina.reduceFactor
534
+ : Infinity;
535
+ }
536
+ this._currentDuration -= this._duration;
537
+ delete this._duration;
538
+ }
539
+ }
540
+ if (this._spawnDelay !== undefined) {
541
+ this._currentSpawnDelay += delta.value;
542
+ if (this._currentSpawnDelay >= this._spawnDelay) {
543
+ this.play();
544
+ this._currentSpawnDelay -= this._spawnDelay;
545
+ delete this._spawnDelay;
546
+ }
547
+ }
548
+ }
549
+ _calcPosition = () => {
550
+ const exactPosition = engine.calcPositionOrRandomFromSizeRanged({
551
+ size: this._container.canvas.size,
552
+ position: this.options.position,
553
+ });
554
+ return engine.Vector.create(exactPosition.x, exactPosition.y);
555
+ };
556
+ _prepareToDie = () => {
557
+ const duration = this.options.life.duration !== undefined ? engine.getRangeValue(this.options.life.duration) : undefined, minDuration = 0;
558
+ if ((this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
559
+ this._duration = duration * engine.millisecondsToSeconds;
560
+ }
561
+ };
562
+ _updateParticlePosition = (particle, delta, v) => {
563
+ if (particle.destroyed) {
564
+ return;
565
+ }
566
+ const container = this._container, canvasSize = container.canvas.size;
567
+ if (particle.needsNewPosition) {
568
+ const newPosition = engine.calcPositionOrRandomFromSize({ size: canvasSize });
569
+ particle.position.setTo(newPosition);
570
+ particle.velocity.setTo(particle.initialVelocity);
571
+ particle.absorberOrbit = undefined;
572
+ particle.needsNewPosition = false;
573
+ }
574
+ if (this.options.orbits) {
575
+ if (particle.absorberOrbit === undefined) {
576
+ particle.absorberOrbit = engine.Vector.origin;
577
+ particle.absorberOrbit.length = engine.getDistance(particle.getPosition(), this.position);
578
+ particle.absorberOrbit.angle = engine.getRandom() * maxAngle;
579
+ }
580
+ if (particle.absorberOrbit.length <= this.size && !this.options.destroy) {
581
+ const minSize = Math.min(canvasSize.width, canvasSize.height), offset = 1, randomOffset = 0.1, randomFactor = 0.2;
582
+ particle.absorberOrbit.length = minSize * (offset + (engine.getRandom() * randomFactor - randomOffset));
583
+ }
584
+ particle.absorberOrbitDirection ??=
585
+ particle.velocity.x >= minVelocity ? engine.RotateDirection.clockwise : engine.RotateDirection.counterClockwise;
586
+ const orbitRadius = particle.absorberOrbit.length, orbitAngle = particle.absorberOrbit.angle, orbitDirection = particle.absorberOrbitDirection;
587
+ particle.velocity.setTo(engine.Vector.origin);
588
+ const maxSize = engine.getRangeMax(particle.options.size.value) * container.retina.pixelRatio, sizeFactor = particle.options.move.size ? particle.getRadius() / maxSize : engine.identity, deltaFactor = delta.factor || engine.identity, baseSpeed = particle.retina.moveSpeed, moveSpeed = baseSpeed * sizeFactor * deltaFactor * engine.half;
589
+ particle.position.x = this.position.x + orbitRadius * Math.cos(orbitAngle);
590
+ particle.position.y =
591
+ this.position.y +
592
+ orbitRadius * (orbitDirection === engine.RotateDirection.clockwise ? engine.identity : -engine.identity) * Math.sin(orbitAngle);
593
+ particle.absorberOrbit.length = Math.max(minOrbitLength, particle.absorberOrbit.length - v.length);
594
+ particle.absorberOrbit.angle += moveSpeed * angleIncrementFactor * container.retina.reduceFactor;
595
+ }
596
+ else {
597
+ particle.velocity.addTo(v);
598
+ }
599
+ };
600
+ play = () => {
601
+ if (!((this._lifeCount > minLifeCount || this._immortal || !this.options.life.count) &&
602
+ (this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? defaultSpawnDelay)))) {
603
+ return;
604
+ }
605
+ if (this._lifeCount > minLifeCount || this._immortal) {
606
+ this._prepareToDie();
607
+ }
608
+ };
609
+ }
610
+
611
+ var AbsorberInstance$1 = /*#__PURE__*/Object.freeze({
612
+ __proto__: null,
613
+ AbsorberInstance: AbsorberInstance
614
+ });
615
+
616
+ exports.loadAbsorbersPlugin = loadAbsorbersPlugin;
617
+
618
+ }));
619
+ Object.assign(globalThis.window || globalThis, { loadAbsorbersPlugin: (globalThis.__tsParticlesInternals.plugins.absorbers || {}).loadAbsorbersPlugin });
620
+ delete (globalThis.window || globalThis).tsparticlesInternalExports;