@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.
- package/browser/browser.js +5 -0
- package/browser/index.lazy.js +6 -0
- package/browser/interaction.js +7 -8
- package/browser/interaction.lazy.js +14 -0
- package/browser/plugin.js +4 -5
- package/browser/plugin.lazy.js +10 -0
- package/cjs/browser.js +5 -0
- package/cjs/index.lazy.js +6 -0
- package/cjs/interaction.js +7 -8
- package/cjs/interaction.lazy.js +14 -0
- package/cjs/plugin.js +4 -5
- package/cjs/plugin.lazy.js +10 -0
- package/esm/browser.js +5 -0
- package/esm/index.lazy.js +6 -0
- package/esm/interaction.js +7 -8
- package/esm/interaction.lazy.js +14 -0
- package/esm/plugin.js +4 -5
- package/esm/plugin.lazy.js +10 -0
- package/package.json +24 -3
- package/report.html +4949 -94
- package/tsparticles.plugin.absorbers.js +604 -361
- package/tsparticles.plugin.absorbers.min.js +1 -2
- package/types/browser.d.ts +1 -0
- package/types/getAbsorbersInstancesManager.d.ts +1 -1
- package/types/index.lazy.d.ts +3 -0
- package/types/interaction.lazy.d.ts +3 -0
- package/types/plugin.lazy.d.ts +3 -0
- package/523.min.js +0 -1
- package/547.min.js +0 -1
- package/555.min.js +0 -1
- package/564.min.js +0 -1
- package/63.min.js +0 -1
- package/986.min.js +0 -1
- package/dist_browser_AbsorberInstance_js.js +0 -70
- package/dist_browser_AbsorbersInstancesManager_js.js +0 -30
- package/dist_browser_AbsorbersInteractor_js.js +0 -70
- package/dist_browser_AbsorbersPluginInstance_js.js +0 -30
- package/dist_browser_AbsorbersPlugin_js.js +0 -70
- package/dist_browser_getAbsorbersInstancesManager_js.js +0 -30
|
@@ -1,377 +1,620 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
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
|
-
|
|
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
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
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
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
(
|
|
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
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
-
|
|
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
|
-
|
|
72
|
-
|
|
73
|
-
|
|
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
|
-
|
|
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
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
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;
|