@tsparticles/interaction-particles-collisions 4.0.0-beta.9 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,357 +1,289 @@
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.9
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
+ /* Particles Interaction v4.0.0 */
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.interactions = global.__tsParticlesInternals.interactions || {}, global.__tsParticlesInternals.interactions.particlesCollisions = global.__tsParticlesInternals.interactions.particlesCollisions || {}), 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
+ var CollisionMode;
10
+ (function (CollisionMode) {
11
+ CollisionMode["absorb"] = "absorb";
12
+ CollisionMode["bounce"] = "bounce";
13
+ CollisionMode["destroy"] = "destroy";
14
+ })(CollisionMode || (CollisionMode = {}));
36
15
 
37
- module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
16
+ class CollisionsAbsorb {
17
+ speed;
18
+ constructor() {
19
+ this.speed = 2;
20
+ }
21
+ load(data) {
22
+ if (engine.isNull(data)) {
23
+ return;
24
+ }
25
+ if (data.speed !== undefined) {
26
+ this.speed = data.speed;
27
+ }
28
+ }
29
+ }
38
30
 
39
- /***/ },
31
+ class CollisionsOverlap {
32
+ enable;
33
+ retries;
34
+ constructor() {
35
+ this.enable = true;
36
+ this.retries = 0;
37
+ }
38
+ load(data) {
39
+ if (engine.isNull(data)) {
40
+ return;
41
+ }
42
+ if (data.enable !== undefined) {
43
+ this.enable = data.enable;
44
+ }
45
+ if (data.retries !== undefined) {
46
+ this.retries = data.retries;
47
+ }
48
+ }
49
+ }
40
50
 
41
- /***/ "@tsparticles/plugin-interactivity"
42
- /*!***************************************************************************************************************************************************************************!*\
43
- !*** external {"commonjs":"@tsparticles/plugin-interactivity","commonjs2":"@tsparticles/plugin-interactivity","amd":"@tsparticles/plugin-interactivity","root":"window"} ***!
44
- \***************************************************************************************************************************************************************************/
45
- (module) {
51
+ class Collisions {
52
+ absorb;
53
+ bounce;
54
+ enable;
55
+ maxSpeed;
56
+ mode;
57
+ overlap;
58
+ constructor() {
59
+ this.absorb = new CollisionsAbsorb();
60
+ this.bounce = new engine.ParticlesBounce();
61
+ this.enable = false;
62
+ this.maxSpeed = 50;
63
+ this.mode = CollisionMode.bounce;
64
+ this.overlap = new CollisionsOverlap();
65
+ }
66
+ load(data) {
67
+ if (engine.isNull(data)) {
68
+ return;
69
+ }
70
+ this.absorb.load(data.absorb);
71
+ this.bounce.load(data.bounce);
72
+ if (data.enable !== undefined) {
73
+ this.enable = data.enable;
74
+ }
75
+ if (data.maxSpeed !== undefined) {
76
+ this.maxSpeed = engine.setRangeValue(data.maxSpeed);
77
+ }
78
+ if (data.mode !== undefined) {
79
+ this.mode = data.mode;
80
+ }
81
+ this.overlap.load(data.overlap);
82
+ }
83
+ }
46
84
 
47
- module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_interactivity__;
85
+ const minAbsorbAmount = 0;
86
+ function updateAbsorb(p1, r1, p2, r2, delta, pixelRatio) {
87
+ if (!p1.options.collisions || !p2.options.collisions) {
88
+ return;
89
+ }
90
+ const absorbSpeed = p1.options.collisions.absorb.speed, shrinkAmount = engine.clamp(absorbSpeed * delta.factor, minAbsorbAmount, r2);
91
+ p1.size.value = Math.sqrt(r1 * r1 + shrinkAmount * shrinkAmount);
92
+ p2.size.value -= shrinkAmount;
93
+ if (p2.size.value <= pixelRatio) {
94
+ p2.size.value = 0;
95
+ p2.destroy();
96
+ }
97
+ }
98
+ function absorb(p1, p2, delta, pixelRatio) {
99
+ const r1 = p1.getRadius(), r2 = p2.getRadius();
100
+ if (!r1 && r2) {
101
+ p1.destroy();
102
+ }
103
+ else if (r1 && !r2) {
104
+ p2.destroy();
105
+ }
106
+ else if (r1 && r2) {
107
+ if (r1 >= r2) {
108
+ updateAbsorb(p1, r1, p2, r2, delta, pixelRatio);
109
+ }
110
+ else {
111
+ updateAbsorb(p2, r2, p1, r1, delta, pixelRatio);
112
+ }
113
+ }
114
+ }
48
115
 
49
- /***/ },
116
+ const energyCorrectionMinRatio = 1e-6, energyDriftThreshold = 1e-4, correctionFactorNeutral = 1, fixBounceSpeed = (p) => {
117
+ if (!p.options.collisions) {
118
+ return;
119
+ }
120
+ p.collisionMaxSpeed ??= engine.getRangeValue(p.options.collisions.maxSpeed);
121
+ if (p.velocity.length > p.collisionMaxSpeed) {
122
+ p.velocity.length = p.collisionMaxSpeed;
123
+ }
124
+ };
125
+ function bounce(p1, p2) {
126
+ const m1 = p1.getMass(), m2 = p2.getMass(), speed1Before = p1.velocity.length, speed2Before = p2.velocity.length, keBefore = m1 * speed1Before * speed1Before + m2 * speed2Before * speed2Before;
127
+ engine.circleBounce(engine.circleBounceDataFromParticle(p1), engine.circleBounceDataFromParticle(p2));
128
+ const speed1After = p1.velocity.length, speed2After = p2.velocity.length, keAfter = m1 * speed1After * speed1After + m2 * speed2After * speed2After;
129
+ if (keAfter > keBefore * energyCorrectionMinRatio) {
130
+ const correctionFactor = Math.sqrt(keBefore / keAfter);
131
+ if (Math.abs(correctionFactor - correctionFactorNeutral) > energyDriftThreshold) {
132
+ p1.velocity.length = speed1After * correctionFactor;
133
+ p2.velocity.length = speed2After * correctionFactor;
134
+ }
135
+ }
136
+ fixBounceSpeed(p1);
137
+ fixBounceSpeed(p2);
138
+ }
50
139
 
51
- /***/ "./dist/browser/index.js"
52
- /*!*******************************!*\
53
- !*** ./dist/browser/index.js ***!
54
- \*******************************/
55
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
140
+ function destroy(p1, p2) {
141
+ if (!p1.unbreakable && !p2.unbreakable) {
142
+ bounce(p1, p2);
143
+ }
144
+ const p1Radius = p1.getRadius(), p2Radius = p2.getRadius();
145
+ if (!p1Radius && p2Radius) {
146
+ p1.destroy();
147
+ }
148
+ else if (p1Radius && !p2Radius) {
149
+ p2.destroy();
150
+ }
151
+ else if (p1Radius && p2Radius) {
152
+ const deleteP = p1.getRadius() >= p2.getRadius() ? p2 : p1;
153
+ deleteP.destroy();
154
+ }
155
+ }
56
156
 
57
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadParticlesCollisionsInteraction: () => (/* binding */ loadParticlesCollisionsInteraction)\n/* harmony export */ });\nasync function loadParticlesCollisionsInteraction(engine) {\n engine.checkVersion(\"4.0.0-beta.9\");\n await engine.pluginManager.register(async (e)=>{\n const [{ ensureInteractivityPluginLoaded }, { OverlapPlugin }] = 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_OverlapPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./OverlapPlugin.js */ \"./dist/browser/OverlapPlugin.js\"))\n ]);\n ensureInteractivityPluginLoaded(e);\n e.pluginManager.addPlugin(new OverlapPlugin());\n e.pluginManager.addInteractor?.(\"particlesCollisions\", async (container)=>{\n const { Collider } = await __webpack_require__.e(/*! import() */ \"dist_browser_Collider_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./Collider.js */ \"./dist/browser/Collider.js\"));\n return new Collider(container);\n });\n });\n}\n\n\n//# sourceURL=webpack://@tsparticles/interaction-particles-collisions/./dist/browser/index.js?\n}");
157
+ function resolveCollision(p1, p2, delta, pixelRatio) {
158
+ if (!p1.options.collisions || !p2.options.collisions) {
159
+ return;
160
+ }
161
+ switch (p1.options.collisions.mode) {
162
+ case CollisionMode.absorb: {
163
+ absorb(p1, p2, delta, pixelRatio);
164
+ break;
165
+ }
166
+ case CollisionMode.bounce: {
167
+ bounce(p1, p2);
168
+ break;
169
+ }
170
+ case CollisionMode.destroy: {
171
+ destroy(p1, p2);
172
+ break;
173
+ }
174
+ }
175
+ }
58
176
 
59
- /***/ }
177
+ class Collider extends pluginInteractivity.ParticlesInteractorBase {
178
+ maxDistance;
179
+ constructor(container) {
180
+ super(container);
181
+ this.maxDistance = 0;
182
+ }
183
+ clear() {
184
+ }
185
+ init() {
186
+ }
187
+ interact(p1, _interactivityData, delta) {
188
+ if (p1.destroyed || p1.spawning) {
189
+ return;
190
+ }
191
+ const container = this.container, pos1 = p1.getPosition(), radius1 = p1.getRadius(), query = container.particles.grid.queryCircle(pos1, radius1 * engine.double);
192
+ for (const p2 of query) {
193
+ if (p1 === p2 ||
194
+ p1.id >= p2.id ||
195
+ !p1.options.collisions?.enable ||
196
+ !p2.options.collisions?.enable ||
197
+ p1.options.collisions.mode !== p2.options.collisions.mode ||
198
+ p2.destroyed ||
199
+ p2.spawning) {
200
+ continue;
201
+ }
202
+ const pos2 = p2.getPosition(), radius2 = p2.getRadius();
203
+ if (Math.abs(Math.round(pos1.z) - Math.round(pos2.z)) > radius1 + radius2) {
204
+ continue;
205
+ }
206
+ const dist = engine.getDistance(pos1, pos2), distP = radius1 + radius2;
207
+ if (dist > distP) {
208
+ continue;
209
+ }
210
+ resolveCollision(p1, p2, delta, container.retina.pixelRatio);
211
+ }
212
+ }
213
+ isEnabled(particle) {
214
+ return !!particle.options.collisions?.enable;
215
+ }
216
+ loadParticlesOptions(options, ...sources) {
217
+ options.collisions ??= new Collisions();
218
+ for (const source of sources) {
219
+ options.collisions.load(source?.collisions);
220
+ }
221
+ }
222
+ reset() {
223
+ }
224
+ }
60
225
 
61
- /******/ });
62
- /************************************************************************/
63
- /******/ // The module cache
64
- /******/ var __webpack_module_cache__ = {};
65
- /******/
66
- /******/ // The require function
67
- /******/ function __webpack_require__(moduleId) {
68
- /******/ // Check if module is in cache
69
- /******/ var cachedModule = __webpack_module_cache__[moduleId];
70
- /******/ if (cachedModule !== undefined) {
71
- /******/ return cachedModule.exports;
72
- /******/ }
73
- /******/ // Create a new module (and put it into the cache)
74
- /******/ var module = __webpack_module_cache__[moduleId] = {
75
- /******/ // no module.id needed
76
- /******/ // no module.loaded needed
77
- /******/ exports: {}
78
- /******/ };
79
- /******/
80
- /******/ // Execute the module function
81
- /******/ if (!(moduleId in __webpack_modules__)) {
82
- /******/ delete __webpack_module_cache__[moduleId];
83
- /******/ var e = new Error("Cannot find module '" + moduleId + "'");
84
- /******/ e.code = 'MODULE_NOT_FOUND';
85
- /******/ throw e;
86
- /******/ }
87
- /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
88
- /******/
89
- /******/ // Return the exports of the module
90
- /******/ return module.exports;
91
- /******/ }
92
- /******/
93
- /******/ // expose the modules object (__webpack_modules__)
94
- /******/ __webpack_require__.m = __webpack_modules__;
95
- /******/
96
- /************************************************************************/
97
- /******/ /* webpack/runtime/create fake namespace object */
98
- /******/ (() => {
99
- /******/ var getProto = Object.getPrototypeOf ? (obj) => (Object.getPrototypeOf(obj)) : (obj) => (obj.__proto__);
100
- /******/ var leafPrototypes;
101
- /******/ // create a fake namespace object
102
- /******/ // mode & 1: value is a module id, require it
103
- /******/ // mode & 2: merge all properties of value into the ns
104
- /******/ // mode & 4: return value when already ns object
105
- /******/ // mode & 16: return value when it's Promise-like
106
- /******/ // mode & 8|1: behave like require
107
- /******/ __webpack_require__.t = function(value, mode) {
108
- /******/ if(mode & 1) value = this(value);
109
- /******/ if(mode & 8) return value;
110
- /******/ if(typeof value === 'object' && value) {
111
- /******/ if((mode & 4) && value.__esModule) return value;
112
- /******/ if((mode & 16) && typeof value.then === 'function') return value;
113
- /******/ }
114
- /******/ var ns = Object.create(null);
115
- /******/ __webpack_require__.r(ns);
116
- /******/ var def = {};
117
- /******/ leafPrototypes = leafPrototypes || [null, getProto({}), getProto([]), getProto(getProto)];
118
- /******/ for(var current = mode & 2 && value; (typeof current == 'object' || typeof current == 'function') && !~leafPrototypes.indexOf(current); current = getProto(current)) {
119
- /******/ Object.getOwnPropertyNames(current).forEach((key) => (def[key] = () => (value[key])));
120
- /******/ }
121
- /******/ def['default'] = () => (value);
122
- /******/ __webpack_require__.d(ns, def);
123
- /******/ return ns;
124
- /******/ };
125
- /******/ })();
126
- /******/
127
- /******/ /* webpack/runtime/define property getters */
128
- /******/ (() => {
129
- /******/ // define getter functions for harmony exports
130
- /******/ __webpack_require__.d = (exports, definition) => {
131
- /******/ for(var key in definition) {
132
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
133
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
134
- /******/ }
135
- /******/ }
136
- /******/ };
137
- /******/ })();
138
- /******/
139
- /******/ /* webpack/runtime/ensure chunk */
140
- /******/ (() => {
141
- /******/ __webpack_require__.f = {};
142
- /******/ // This file contains only the entry chunk.
143
- /******/ // The chunk loading function for additional chunks
144
- /******/ __webpack_require__.e = (chunkId) => {
145
- /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
146
- /******/ __webpack_require__.f[key](chunkId, promises);
147
- /******/ return promises;
148
- /******/ }, []));
149
- /******/ };
150
- /******/ })();
151
- /******/
152
- /******/ /* webpack/runtime/get javascript chunk filename */
153
- /******/ (() => {
154
- /******/ // This function allow to reference async chunks
155
- /******/ __webpack_require__.u = (chunkId) => {
156
- /******/ // return url for filenames based on template
157
- /******/ return "" + chunkId + ".js";
158
- /******/ };
159
- /******/ })();
160
- /******/
161
- /******/ /* webpack/runtime/global */
162
- /******/ (() => {
163
- /******/ __webpack_require__.g = (function() {
164
- /******/ if (typeof globalThis === 'object') return globalThis;
165
- /******/ try {
166
- /******/ return this || new Function('return this')();
167
- /******/ } catch (e) {
168
- /******/ if (typeof window === 'object') return window;
169
- /******/ }
170
- /******/ })();
171
- /******/ })();
172
- /******/
173
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
174
- /******/ (() => {
175
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
176
- /******/ })();
177
- /******/
178
- /******/ /* webpack/runtime/load script */
179
- /******/ (() => {
180
- /******/ var inProgress = {};
181
- /******/ var dataWebpackPrefix = "@tsparticles/interaction-particles-collisions:";
182
- /******/ // loadScript function to load a script via script tag
183
- /******/ __webpack_require__.l = (url, done, key, chunkId) => {
184
- /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
185
- /******/ var script, needAttach;
186
- /******/ if(key !== undefined) {
187
- /******/ var scripts = document.getElementsByTagName("script");
188
- /******/ for(var i = 0; i < scripts.length; i++) {
189
- /******/ var s = scripts[i];
190
- /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
191
- /******/ }
192
- /******/ }
193
- /******/ if(!script) {
194
- /******/ needAttach = true;
195
- /******/ script = document.createElement('script');
196
- /******/
197
- /******/ script.charset = 'utf-8';
198
- /******/ if (__webpack_require__.nc) {
199
- /******/ script.setAttribute("nonce", __webpack_require__.nc);
200
- /******/ }
201
- /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
202
- /******/
203
- /******/ script.src = url;
204
- /******/ }
205
- /******/ inProgress[url] = [done];
206
- /******/ var onScriptComplete = (prev, event) => {
207
- /******/ // avoid mem leaks in IE.
208
- /******/ script.onerror = script.onload = null;
209
- /******/ clearTimeout(timeout);
210
- /******/ var doneFns = inProgress[url];
211
- /******/ delete inProgress[url];
212
- /******/ script.parentNode && script.parentNode.removeChild(script);
213
- /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
214
- /******/ if(prev) return prev(event);
215
- /******/ }
216
- /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
217
- /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
218
- /******/ script.onload = onScriptComplete.bind(null, script.onload);
219
- /******/ needAttach && document.head.appendChild(script);
220
- /******/ };
221
- /******/ })();
222
- /******/
223
- /******/ /* webpack/runtime/make namespace object */
224
- /******/ (() => {
225
- /******/ // define __esModule on exports
226
- /******/ __webpack_require__.r = (exports) => {
227
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
228
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
229
- /******/ }
230
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
231
- /******/ };
232
- /******/ })();
233
- /******/
234
- /******/ /* webpack/runtime/publicPath */
235
- /******/ (() => {
236
- /******/ var scriptUrl;
237
- /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
238
- /******/ var document = __webpack_require__.g.document;
239
- /******/ if (!scriptUrl && document) {
240
- /******/ if (document.currentScript && document.currentScript.tagName.toUpperCase() === 'SCRIPT')
241
- /******/ scriptUrl = document.currentScript.src;
242
- /******/ if (!scriptUrl) {
243
- /******/ var scripts = document.getElementsByTagName("script");
244
- /******/ if(scripts.length) {
245
- /******/ var i = scripts.length - 1;
246
- /******/ while (i > -1 && (!scriptUrl || !/^http(s?):/.test(scriptUrl))) scriptUrl = scripts[i--].src;
247
- /******/ }
248
- /******/ }
249
- /******/ }
250
- /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
251
- /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
252
- /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
253
- /******/ scriptUrl = scriptUrl.replace(/^blob:/, "").replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
254
- /******/ __webpack_require__.p = scriptUrl;
255
- /******/ })();
256
- /******/
257
- /******/ /* webpack/runtime/jsonp chunk loading */
258
- /******/ (() => {
259
- /******/ // no baseURI
260
- /******/
261
- /******/ // object to store loaded and loading chunks
262
- /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
263
- /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
264
- /******/ var installedChunks = {
265
- /******/ "tsparticles.interaction.particles.collisions": 0
266
- /******/ };
267
- /******/
268
- /******/ __webpack_require__.f.j = (chunkId, promises) => {
269
- /******/ // JSONP chunk loading for javascript
270
- /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
271
- /******/ if(installedChunkData !== 0) { // 0 means "already installed".
272
- /******/
273
- /******/ // a Promise means "currently loading".
274
- /******/ if(installedChunkData) {
275
- /******/ promises.push(installedChunkData[2]);
276
- /******/ } else {
277
- /******/ if(true) { // all chunks have JS
278
- /******/ // setup Promise in chunk cache
279
- /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
280
- /******/ promises.push(installedChunkData[2] = promise);
281
- /******/
282
- /******/ // start chunk loading
283
- /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
284
- /******/ // create error before stack unwound to get useful stacktrace later
285
- /******/ var error = new Error();
286
- /******/ var loadingEnded = (event) => {
287
- /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
288
- /******/ installedChunkData = installedChunks[chunkId];
289
- /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
290
- /******/ if(installedChunkData) {
291
- /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
292
- /******/ var realSrc = event && event.target && event.target.src;
293
- /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
294
- /******/ error.name = 'ChunkLoadError';
295
- /******/ error.type = errorType;
296
- /******/ error.request = realSrc;
297
- /******/ installedChunkData[1](error);
298
- /******/ }
299
- /******/ }
300
- /******/ };
301
- /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
302
- /******/ }
303
- /******/ }
304
- /******/ }
305
- /******/ };
306
- /******/
307
- /******/ // no prefetching
308
- /******/
309
- /******/ // no preloaded
310
- /******/
311
- /******/ // no HMR
312
- /******/
313
- /******/ // no HMR manifest
314
- /******/
315
- /******/ // no on chunks loaded
316
- /******/
317
- /******/ // install a JSONP callback for chunk loading
318
- /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
319
- /******/ var [chunkIds, moreModules, runtime] = data;
320
- /******/ // add "moreModules" to the modules object,
321
- /******/ // then flag all "chunkIds" as loaded and fire callback
322
- /******/ var moduleId, chunkId, i = 0;
323
- /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
324
- /******/ for(moduleId in moreModules) {
325
- /******/ if(__webpack_require__.o(moreModules, moduleId)) {
326
- /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
327
- /******/ }
328
- /******/ }
329
- /******/ if(runtime) var result = runtime(__webpack_require__);
330
- /******/ }
331
- /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
332
- /******/ for(;i < chunkIds.length; i++) {
333
- /******/ chunkId = chunkIds[i];
334
- /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
335
- /******/ installedChunks[chunkId][0]();
336
- /******/ }
337
- /******/ installedChunks[chunkId] = 0;
338
- /******/ }
339
- /******/
340
- /******/ }
341
- /******/
342
- /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_interaction_particles_collisions"] = this["webpackChunk_tsparticles_interaction_particles_collisions"] || [];
343
- /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
344
- /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
345
- /******/ })();
346
- /******/
347
- /************************************************************************/
348
- /******/
349
- /******/ // startup
350
- /******/ // Load entry module and return exports
351
- /******/ // This entry module can't be inlined because the eval devtool is used.
352
- /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
353
- /******/
354
- /******/ return __webpack_exports__;
355
- /******/ })()
356
- ;
357
- });
226
+ class OverlapPlugin {
227
+ id = "overlap";
228
+ async getPlugin(container) {
229
+ const { OverlapPluginInstance } = await Promise.resolve().then(function () { return OverlapPluginInstance$1; });
230
+ return new OverlapPluginInstance(container);
231
+ }
232
+ loadOptions() {
233
+ }
234
+ needsPlugin() {
235
+ return true;
236
+ }
237
+ }
238
+
239
+ async function loadParticlesCollisionsInteraction(engine) {
240
+ engine.checkVersion("4.0.0");
241
+ await engine.pluginManager.register((e) => {
242
+ pluginInteractivity.ensureInteractivityPluginLoaded(e);
243
+ e.pluginManager.addPlugin(new OverlapPlugin());
244
+ e.pluginManager.addInteractor?.("particlesCollisions", container => {
245
+ return Promise.resolve(new Collider(container));
246
+ });
247
+ });
248
+ }
249
+
250
+ const globalObject = globalThis;
251
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
252
+ globalObject.loadParticlesCollisionsInteraction = loadParticlesCollisionsInteraction;
253
+
254
+ const minRetries = 0;
255
+ class OverlapPluginInstance {
256
+ _container;
257
+ constructor(container) {
258
+ this._container = container;
259
+ }
260
+ checkParticlePosition(particle, position, tryCount) {
261
+ return !this._hasOverlaps(particle, position, tryCount);
262
+ }
263
+ _hasOverlaps = (particle, pos, tryCount) => {
264
+ const collisionsOptions = particle.options.collisions;
265
+ if (!collisionsOptions?.enable) {
266
+ return false;
267
+ }
268
+ const overlapOptions = collisionsOptions.overlap;
269
+ if (overlapOptions.enable) {
270
+ return false;
271
+ }
272
+ const retries = overlapOptions.retries;
273
+ if (retries >= minRetries && tryCount > retries) {
274
+ throw new Error(`Particle is overlapping and can't be placed`);
275
+ }
276
+ return !!this._container.particles.find(p => engine.getDistance(pos, p.position) < particle.getRadius() + p.getRadius());
277
+ };
278
+ }
279
+
280
+ var OverlapPluginInstance$1 = /*#__PURE__*/Object.freeze({
281
+ __proto__: null,
282
+ OverlapPluginInstance: OverlapPluginInstance
283
+ });
284
+
285
+ exports.loadParticlesCollisionsInteraction = loadParticlesCollisionsInteraction;
286
+
287
+ }));
288
+ Object.assign(globalThis.window || globalThis, { loadParticlesCollisionsInteraction: (globalThis.__tsParticlesInternals.interactions.particlesCollisions || {}).loadParticlesCollisionsInteraction });
289
+ delete (globalThis.window || globalThis).tsparticlesInternalExports;