@tsparticles/plugin-absorbers 3.1.0 → 3.2.1
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/142.min.js +2 -0
- package/142.min.js.LICENSE.txt +1 -0
- package/28.min.js +2 -0
- package/28.min.js.LICENSE.txt +1 -0
- package/327.min.js +2 -0
- package/327.min.js.LICENSE.txt +1 -0
- package/browser/AbsorberInstance.js +2 -1
- package/browser/Absorbers.js +14 -10
- package/browser/AbsorbersPlugin.js +45 -0
- package/browser/index.js +1 -45
- package/cjs/AbsorberInstance.js +2 -1
- package/cjs/Absorbers.js +37 -10
- package/cjs/AbsorbersPlugin.js +72 -0
- package/cjs/index.js +13 -45
- package/dist_browser_AbsorberInstance_js.js +30 -0
- package/dist_browser_AbsorbersPlugin_js.js +60 -0
- package/dist_browser_Absorbers_js.js +30 -0
- package/esm/AbsorberInstance.js +2 -1
- package/esm/Absorbers.js +14 -10
- package/esm/AbsorbersPlugin.js +45 -0
- package/esm/index.js +1 -45
- package/package.json +2 -2
- package/report.html +3 -3
- package/tsparticles.plugin.absorbers.js +241 -387
- package/tsparticles.plugin.absorbers.min.js +1 -1
- package/tsparticles.plugin.absorbers.min.js.LICENSE.txt +1 -1
- package/types/AbsorberContainer.d.ts +1 -1
- package/types/AbsorberInstance.d.ts +1 -1
- package/types/Absorbers.d.ts +3 -3
- package/types/AbsorbersPlugin.d.ts +11 -0
- package/umd/AbsorberInstance.js +2 -1
- package/umd/Absorbers.js +39 -11
- package/umd/AbsorbersPlugin.js +83 -0
- package/umd/index.js +15 -46
|
@@ -4,7 +4,15 @@
|
|
|
4
4
|
* Demo / Generator : https://particles.js.org/
|
|
5
5
|
* GitHub : https://www.github.com/matteobruni/tsparticles
|
|
6
6
|
* How to use? : Check the GitHub README
|
|
7
|
-
* v3.1
|
|
7
|
+
* v3.2.1
|
|
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/).
|
|
8
16
|
*/
|
|
9
17
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
10
18
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
@@ -15,15 +23,28 @@
|
|
|
15
23
|
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
16
24
|
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
17
25
|
}
|
|
18
|
-
})(this, (
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
19
27
|
return /******/ (() => { // webpackBootstrap
|
|
20
28
|
/******/ "use strict";
|
|
21
29
|
/******/ var __webpack_modules__ = ({
|
|
22
30
|
|
|
23
|
-
/***/
|
|
31
|
+
/***/ "./dist/browser/index.js":
|
|
32
|
+
/*!*******************************!*\
|
|
33
|
+
!*** ./dist/browser/index.js ***!
|
|
34
|
+
\*******************************/
|
|
35
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
36
|
+
|
|
37
|
+
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadAbsorbersPlugin: () => (/* binding */ loadAbsorbersPlugin)\n/* harmony export */ });\nasync function loadAbsorbersPlugin(engine, refresh = true) {\n const {\n AbsorbersPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_AbsorbersPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./AbsorbersPlugin.js */ \"./dist/browser/AbsorbersPlugin.js\"));\n await engine.addPlugin(new AbsorbersPlugin(), refresh);\n}\n\n\n\n//# sourceURL=webpack://@tsparticles/plugin-absorbers/./dist/browser/index.js?");
|
|
38
|
+
|
|
39
|
+
/***/ }),
|
|
40
|
+
|
|
41
|
+
/***/ "@tsparticles/engine":
|
|
42
|
+
/*!*********************************************************************************************************************************!*\
|
|
43
|
+
!*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
|
|
44
|
+
\*********************************************************************************************************************************/
|
|
24
45
|
/***/ ((module) => {
|
|
25
46
|
|
|
26
|
-
module.exports =
|
|
47
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
27
48
|
|
|
28
49
|
/***/ })
|
|
29
50
|
|
|
@@ -53,7 +74,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
53
74
|
/******/ return module.exports;
|
|
54
75
|
/******/ }
|
|
55
76
|
/******/
|
|
77
|
+
/******/ // expose the modules object (__webpack_modules__)
|
|
78
|
+
/******/ __webpack_require__.m = __webpack_modules__;
|
|
79
|
+
/******/
|
|
56
80
|
/************************************************************************/
|
|
81
|
+
/******/ /* webpack/runtime/compat get default export */
|
|
82
|
+
/******/ (() => {
|
|
83
|
+
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
84
|
+
/******/ __webpack_require__.n = (module) => {
|
|
85
|
+
/******/ var getter = module && module.__esModule ?
|
|
86
|
+
/******/ () => (module['default']) :
|
|
87
|
+
/******/ () => (module);
|
|
88
|
+
/******/ __webpack_require__.d(getter, { a: getter });
|
|
89
|
+
/******/ return getter;
|
|
90
|
+
/******/ };
|
|
91
|
+
/******/ })();
|
|
92
|
+
/******/
|
|
57
93
|
/******/ /* webpack/runtime/define property getters */
|
|
58
94
|
/******/ (() => {
|
|
59
95
|
/******/ // define getter functions for harmony exports
|
|
@@ -66,11 +102,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
66
102
|
/******/ };
|
|
67
103
|
/******/ })();
|
|
68
104
|
/******/
|
|
105
|
+
/******/ /* webpack/runtime/ensure chunk */
|
|
106
|
+
/******/ (() => {
|
|
107
|
+
/******/ __webpack_require__.f = {};
|
|
108
|
+
/******/ // This file contains only the entry chunk.
|
|
109
|
+
/******/ // The chunk loading function for additional chunks
|
|
110
|
+
/******/ __webpack_require__.e = (chunkId) => {
|
|
111
|
+
/******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
|
|
112
|
+
/******/ __webpack_require__.f[key](chunkId, promises);
|
|
113
|
+
/******/ return promises;
|
|
114
|
+
/******/ }, []));
|
|
115
|
+
/******/ };
|
|
116
|
+
/******/ })();
|
|
117
|
+
/******/
|
|
118
|
+
/******/ /* webpack/runtime/get javascript chunk filename */
|
|
119
|
+
/******/ (() => {
|
|
120
|
+
/******/ // This function allow to reference async chunks
|
|
121
|
+
/******/ __webpack_require__.u = (chunkId) => {
|
|
122
|
+
/******/ // return url for filenames based on template
|
|
123
|
+
/******/ return "" + chunkId + ".js";
|
|
124
|
+
/******/ };
|
|
125
|
+
/******/ })();
|
|
126
|
+
/******/
|
|
127
|
+
/******/ /* webpack/runtime/global */
|
|
128
|
+
/******/ (() => {
|
|
129
|
+
/******/ __webpack_require__.g = (function() {
|
|
130
|
+
/******/ if (typeof globalThis === 'object') return globalThis;
|
|
131
|
+
/******/ try {
|
|
132
|
+
/******/ return this || new Function('return this')();
|
|
133
|
+
/******/ } catch (e) {
|
|
134
|
+
/******/ if (typeof window === 'object') return window;
|
|
135
|
+
/******/ }
|
|
136
|
+
/******/ })();
|
|
137
|
+
/******/ })();
|
|
138
|
+
/******/
|
|
69
139
|
/******/ /* webpack/runtime/hasOwnProperty shorthand */
|
|
70
140
|
/******/ (() => {
|
|
71
141
|
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
72
142
|
/******/ })();
|
|
73
143
|
/******/
|
|
144
|
+
/******/ /* webpack/runtime/load script */
|
|
145
|
+
/******/ (() => {
|
|
146
|
+
/******/ var inProgress = {};
|
|
147
|
+
/******/ var dataWebpackPrefix = "@tsparticles/plugin-absorbers:";
|
|
148
|
+
/******/ // loadScript function to load a script via script tag
|
|
149
|
+
/******/ __webpack_require__.l = (url, done, key, chunkId) => {
|
|
150
|
+
/******/ if(inProgress[url]) { inProgress[url].push(done); return; }
|
|
151
|
+
/******/ var script, needAttach;
|
|
152
|
+
/******/ if(key !== undefined) {
|
|
153
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
154
|
+
/******/ for(var i = 0; i < scripts.length; i++) {
|
|
155
|
+
/******/ var s = scripts[i];
|
|
156
|
+
/******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
|
|
157
|
+
/******/ }
|
|
158
|
+
/******/ }
|
|
159
|
+
/******/ if(!script) {
|
|
160
|
+
/******/ needAttach = true;
|
|
161
|
+
/******/ script = document.createElement('script');
|
|
162
|
+
/******/
|
|
163
|
+
/******/ script.charset = 'utf-8';
|
|
164
|
+
/******/ script.timeout = 120;
|
|
165
|
+
/******/ if (__webpack_require__.nc) {
|
|
166
|
+
/******/ script.setAttribute("nonce", __webpack_require__.nc);
|
|
167
|
+
/******/ }
|
|
168
|
+
/******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
|
|
169
|
+
/******/
|
|
170
|
+
/******/ script.src = url;
|
|
171
|
+
/******/ }
|
|
172
|
+
/******/ inProgress[url] = [done];
|
|
173
|
+
/******/ var onScriptComplete = (prev, event) => {
|
|
174
|
+
/******/ // avoid mem leaks in IE.
|
|
175
|
+
/******/ script.onerror = script.onload = null;
|
|
176
|
+
/******/ clearTimeout(timeout);
|
|
177
|
+
/******/ var doneFns = inProgress[url];
|
|
178
|
+
/******/ delete inProgress[url];
|
|
179
|
+
/******/ script.parentNode && script.parentNode.removeChild(script);
|
|
180
|
+
/******/ doneFns && doneFns.forEach((fn) => (fn(event)));
|
|
181
|
+
/******/ if(prev) return prev(event);
|
|
182
|
+
/******/ }
|
|
183
|
+
/******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
|
|
184
|
+
/******/ script.onerror = onScriptComplete.bind(null, script.onerror);
|
|
185
|
+
/******/ script.onload = onScriptComplete.bind(null, script.onload);
|
|
186
|
+
/******/ needAttach && document.head.appendChild(script);
|
|
187
|
+
/******/ };
|
|
188
|
+
/******/ })();
|
|
189
|
+
/******/
|
|
74
190
|
/******/ /* webpack/runtime/make namespace object */
|
|
75
191
|
/******/ (() => {
|
|
76
192
|
/******/ // define __esModule on exports
|
|
@@ -82,390 +198,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
|
|
|
82
198
|
/******/ };
|
|
83
199
|
/******/ })();
|
|
84
200
|
/******/
|
|
201
|
+
/******/ /* webpack/runtime/publicPath */
|
|
202
|
+
/******/ (() => {
|
|
203
|
+
/******/ var scriptUrl;
|
|
204
|
+
/******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
|
|
205
|
+
/******/ var document = __webpack_require__.g.document;
|
|
206
|
+
/******/ if (!scriptUrl && document) {
|
|
207
|
+
/******/ if (document.currentScript)
|
|
208
|
+
/******/ scriptUrl = document.currentScript.src;
|
|
209
|
+
/******/ if (!scriptUrl) {
|
|
210
|
+
/******/ var scripts = document.getElementsByTagName("script");
|
|
211
|
+
/******/ if(scripts.length) {
|
|
212
|
+
/******/ var i = scripts.length - 1;
|
|
213
|
+
/******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
|
|
214
|
+
/******/ }
|
|
215
|
+
/******/ }
|
|
216
|
+
/******/ }
|
|
217
|
+
/******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
|
|
218
|
+
/******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
|
|
219
|
+
/******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
|
|
220
|
+
/******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
|
|
221
|
+
/******/ __webpack_require__.p = scriptUrl;
|
|
222
|
+
/******/ })();
|
|
223
|
+
/******/
|
|
224
|
+
/******/ /* webpack/runtime/jsonp chunk loading */
|
|
225
|
+
/******/ (() => {
|
|
226
|
+
/******/ // no baseURI
|
|
227
|
+
/******/
|
|
228
|
+
/******/ // object to store loaded and loading chunks
|
|
229
|
+
/******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
|
|
230
|
+
/******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
|
|
231
|
+
/******/ var installedChunks = {
|
|
232
|
+
/******/ "tsparticles.plugin.absorbers": 0
|
|
233
|
+
/******/ };
|
|
234
|
+
/******/
|
|
235
|
+
/******/ __webpack_require__.f.j = (chunkId, promises) => {
|
|
236
|
+
/******/ // JSONP chunk loading for javascript
|
|
237
|
+
/******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
|
|
238
|
+
/******/ if(installedChunkData !== 0) { // 0 means "already installed".
|
|
239
|
+
/******/
|
|
240
|
+
/******/ // a Promise means "currently loading".
|
|
241
|
+
/******/ if(installedChunkData) {
|
|
242
|
+
/******/ promises.push(installedChunkData[2]);
|
|
243
|
+
/******/ } else {
|
|
244
|
+
/******/ if(true) { // all chunks have JS
|
|
245
|
+
/******/ // setup Promise in chunk cache
|
|
246
|
+
/******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
|
|
247
|
+
/******/ promises.push(installedChunkData[2] = promise);
|
|
248
|
+
/******/
|
|
249
|
+
/******/ // start chunk loading
|
|
250
|
+
/******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
|
|
251
|
+
/******/ // create error before stack unwound to get useful stacktrace later
|
|
252
|
+
/******/ var error = new Error();
|
|
253
|
+
/******/ var loadingEnded = (event) => {
|
|
254
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId)) {
|
|
255
|
+
/******/ installedChunkData = installedChunks[chunkId];
|
|
256
|
+
/******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
|
|
257
|
+
/******/ if(installedChunkData) {
|
|
258
|
+
/******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
|
|
259
|
+
/******/ var realSrc = event && event.target && event.target.src;
|
|
260
|
+
/******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
|
|
261
|
+
/******/ error.name = 'ChunkLoadError';
|
|
262
|
+
/******/ error.type = errorType;
|
|
263
|
+
/******/ error.request = realSrc;
|
|
264
|
+
/******/ installedChunkData[1](error);
|
|
265
|
+
/******/ }
|
|
266
|
+
/******/ }
|
|
267
|
+
/******/ };
|
|
268
|
+
/******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
|
|
269
|
+
/******/ }
|
|
270
|
+
/******/ }
|
|
271
|
+
/******/ }
|
|
272
|
+
/******/ };
|
|
273
|
+
/******/
|
|
274
|
+
/******/ // no prefetching
|
|
275
|
+
/******/
|
|
276
|
+
/******/ // no preloaded
|
|
277
|
+
/******/
|
|
278
|
+
/******/ // no HMR
|
|
279
|
+
/******/
|
|
280
|
+
/******/ // no HMR manifest
|
|
281
|
+
/******/
|
|
282
|
+
/******/ // no on chunks loaded
|
|
283
|
+
/******/
|
|
284
|
+
/******/ // install a JSONP callback for chunk loading
|
|
285
|
+
/******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
|
|
286
|
+
/******/ var chunkIds = data[0];
|
|
287
|
+
/******/ var moreModules = data[1];
|
|
288
|
+
/******/ var runtime = data[2];
|
|
289
|
+
/******/ // add "moreModules" to the modules object,
|
|
290
|
+
/******/ // then flag all "chunkIds" as loaded and fire callback
|
|
291
|
+
/******/ var moduleId, chunkId, i = 0;
|
|
292
|
+
/******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
|
|
293
|
+
/******/ for(moduleId in moreModules) {
|
|
294
|
+
/******/ if(__webpack_require__.o(moreModules, moduleId)) {
|
|
295
|
+
/******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
|
|
296
|
+
/******/ }
|
|
297
|
+
/******/ }
|
|
298
|
+
/******/ if(runtime) var result = runtime(__webpack_require__);
|
|
299
|
+
/******/ }
|
|
300
|
+
/******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
|
|
301
|
+
/******/ for(;i < chunkIds.length; i++) {
|
|
302
|
+
/******/ chunkId = chunkIds[i];
|
|
303
|
+
/******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
|
|
304
|
+
/******/ installedChunks[chunkId][0]();
|
|
305
|
+
/******/ }
|
|
306
|
+
/******/ installedChunks[chunkId] = 0;
|
|
307
|
+
/******/ }
|
|
308
|
+
/******/
|
|
309
|
+
/******/ }
|
|
310
|
+
/******/
|
|
311
|
+
/******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_absorbers"] = this["webpackChunk_tsparticles_plugin_absorbers"] || [];
|
|
312
|
+
/******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
|
|
313
|
+
/******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
|
|
314
|
+
/******/ })();
|
|
315
|
+
/******/
|
|
85
316
|
/************************************************************************/
|
|
86
|
-
|
|
87
|
-
//
|
|
88
|
-
|
|
89
|
-
//
|
|
90
|
-
__webpack_require__.
|
|
91
|
-
|
|
92
|
-
// EXPORTS
|
|
93
|
-
__webpack_require__.d(__webpack_exports__, {
|
|
94
|
-
loadAbsorbersPlugin: () => (/* binding */ loadAbsorbersPlugin)
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
// EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
|
|
98
|
-
var engine_root_window_ = __webpack_require__(533);
|
|
99
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/AbsorberSizeLimit.js
|
|
100
|
-
class AbsorberSizeLimit {
|
|
101
|
-
constructor() {
|
|
102
|
-
this.radius = 0;
|
|
103
|
-
this.mass = 0;
|
|
104
|
-
}
|
|
105
|
-
load(data) {
|
|
106
|
-
if (!data) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (data.mass !== undefined) {
|
|
110
|
-
this.mass = data.mass;
|
|
111
|
-
}
|
|
112
|
-
if (data.radius !== undefined) {
|
|
113
|
-
this.radius = data.radius;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/AbsorberSize.js
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
class AbsorberSize extends engine_root_window_.ValueWithRandom {
|
|
121
|
-
constructor() {
|
|
122
|
-
super();
|
|
123
|
-
this.density = 5;
|
|
124
|
-
this.value = 50;
|
|
125
|
-
this.limit = new AbsorberSizeLimit();
|
|
126
|
-
}
|
|
127
|
-
load(data) {
|
|
128
|
-
if (!data) {
|
|
129
|
-
return;
|
|
130
|
-
}
|
|
131
|
-
super.load(data);
|
|
132
|
-
if (data.density !== undefined) {
|
|
133
|
-
this.density = data.density;
|
|
134
|
-
}
|
|
135
|
-
if ((0,engine_root_window_.isNumber)(data.limit)) {
|
|
136
|
-
this.limit.radius = data.limit;
|
|
137
|
-
} else {
|
|
138
|
-
this.limit.load(data.limit);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Absorber.js
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
class Absorber {
|
|
146
|
-
constructor() {
|
|
147
|
-
this.color = new engine_root_window_.OptionsColor();
|
|
148
|
-
this.color.value = "#000000";
|
|
149
|
-
this.draggable = false;
|
|
150
|
-
this.opacity = 1;
|
|
151
|
-
this.destroy = true;
|
|
152
|
-
this.orbits = false;
|
|
153
|
-
this.size = new AbsorberSize();
|
|
154
|
-
}
|
|
155
|
-
load(data) {
|
|
156
|
-
if (data === undefined) {
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
if (data.color !== undefined) {
|
|
160
|
-
this.color = engine_root_window_.OptionsColor.create(this.color, data.color);
|
|
161
|
-
}
|
|
162
|
-
if (data.draggable !== undefined) {
|
|
163
|
-
this.draggable = data.draggable;
|
|
164
|
-
}
|
|
165
|
-
this.name = data.name;
|
|
166
|
-
if (data.opacity !== undefined) {
|
|
167
|
-
this.opacity = data.opacity;
|
|
168
|
-
}
|
|
169
|
-
if (data.position !== undefined) {
|
|
170
|
-
this.position = {};
|
|
171
|
-
if (data.position.x !== undefined) {
|
|
172
|
-
this.position.x = (0,engine_root_window_.setRangeValue)(data.position.x);
|
|
173
|
-
}
|
|
174
|
-
if (data.position.y !== undefined) {
|
|
175
|
-
this.position.y = (0,engine_root_window_.setRangeValue)(data.position.y);
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
if (data.size !== undefined) {
|
|
179
|
-
this.size.load(data.size);
|
|
180
|
-
}
|
|
181
|
-
if (data.destroy !== undefined) {
|
|
182
|
-
this.destroy = data.destroy;
|
|
183
|
-
}
|
|
184
|
-
if (data.orbits !== undefined) {
|
|
185
|
-
this.orbits = data.orbits;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
;// CONCATENATED MODULE: ./dist/browser/AbsorberInstance.js
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
const squareExp = 2,
|
|
193
|
-
absorbFactor = 0.033,
|
|
194
|
-
minOrbitLength = 0,
|
|
195
|
-
minRadius = 0,
|
|
196
|
-
minMass = 0,
|
|
197
|
-
origin = {
|
|
198
|
-
x: 0,
|
|
199
|
-
y: 0
|
|
200
|
-
},
|
|
201
|
-
minAngle = 0,
|
|
202
|
-
AbsorberInstance_double = 2,
|
|
203
|
-
maxAngle = Math.PI * AbsorberInstance_double,
|
|
204
|
-
minVelocity = 0;
|
|
205
|
-
class AbsorberInstance {
|
|
206
|
-
constructor(absorbers, container, options, position) {
|
|
207
|
-
this.absorbers = absorbers;
|
|
208
|
-
this.container = container;
|
|
209
|
-
this._calcPosition = () => {
|
|
210
|
-
const exactPosition = (0,engine_root_window_.calcPositionOrRandomFromSizeRanged)({
|
|
211
|
-
size: this.container.canvas.size,
|
|
212
|
-
position: this.options.position
|
|
213
|
-
});
|
|
214
|
-
return engine_root_window_.Vector.create(exactPosition.x, exactPosition.y);
|
|
215
|
-
};
|
|
216
|
-
this._updateParticlePosition = (particle, v) => {
|
|
217
|
-
if (particle.destroyed) {
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
const container = this.container,
|
|
221
|
-
canvasSize = container.canvas.size;
|
|
222
|
-
if (particle.needsNewPosition) {
|
|
223
|
-
const newPosition = (0,engine_root_window_.calcPositionOrRandomFromSize)({
|
|
224
|
-
size: canvasSize
|
|
225
|
-
});
|
|
226
|
-
particle.position.setTo(newPosition);
|
|
227
|
-
particle.velocity.setTo(particle.initialVelocity);
|
|
228
|
-
particle.absorberOrbit = undefined;
|
|
229
|
-
particle.needsNewPosition = false;
|
|
230
|
-
}
|
|
231
|
-
if (this.options.orbits) {
|
|
232
|
-
if (particle.absorberOrbit === undefined) {
|
|
233
|
-
particle.absorberOrbit = engine_root_window_.Vector.origin;
|
|
234
|
-
particle.absorberOrbit.length = (0,engine_root_window_.getDistance)(particle.getPosition(), this.position);
|
|
235
|
-
particle.absorberOrbit.angle = (0,engine_root_window_.getRandom)() * maxAngle;
|
|
236
|
-
}
|
|
237
|
-
if (particle.absorberOrbit.length <= this.size && !this.options.destroy) {
|
|
238
|
-
const minSize = Math.min(canvasSize.width, canvasSize.height),
|
|
239
|
-
offset = 1,
|
|
240
|
-
randomOffset = 0.1,
|
|
241
|
-
randomFactor = 0.2;
|
|
242
|
-
particle.absorberOrbit.length = minSize * (offset + ((0,engine_root_window_.getRandom)() * randomFactor - randomOffset));
|
|
243
|
-
}
|
|
244
|
-
if (particle.absorberOrbitDirection === undefined) {
|
|
245
|
-
particle.absorberOrbitDirection = particle.velocity.x >= minVelocity ? "clockwise" : "counter-clockwise";
|
|
246
|
-
}
|
|
247
|
-
const orbitRadius = particle.absorberOrbit.length,
|
|
248
|
-
orbitAngle = particle.absorberOrbit.angle,
|
|
249
|
-
orbitDirection = particle.absorberOrbitDirection;
|
|
250
|
-
particle.velocity.setTo(engine_root_window_.Vector.origin);
|
|
251
|
-
const updateFunc = {
|
|
252
|
-
x: orbitDirection === "clockwise" ? Math.cos : Math.sin,
|
|
253
|
-
y: orbitDirection === "clockwise" ? Math.sin : Math.cos
|
|
254
|
-
};
|
|
255
|
-
particle.position.x = this.position.x + orbitRadius * updateFunc.x(orbitAngle);
|
|
256
|
-
particle.position.y = this.position.y + orbitRadius * updateFunc.y(orbitAngle);
|
|
257
|
-
particle.absorberOrbit.length -= v.length;
|
|
258
|
-
particle.absorberOrbit.angle += (particle.retina.moveSpeed ?? minVelocity) * container.retina.pixelRatio / engine_root_window_.percentDenominator * container.retina.reduceFactor;
|
|
259
|
-
} else {
|
|
260
|
-
const addV = engine_root_window_.Vector.origin;
|
|
261
|
-
addV.length = v.length;
|
|
262
|
-
addV.angle = v.angle;
|
|
263
|
-
particle.velocity.addTo(addV);
|
|
264
|
-
}
|
|
265
|
-
};
|
|
266
|
-
this.initialPosition = position ? engine_root_window_.Vector.create(position.x, position.y) : undefined;
|
|
267
|
-
if (options instanceof Absorber) {
|
|
268
|
-
this.options = options;
|
|
269
|
-
} else {
|
|
270
|
-
this.options = new Absorber();
|
|
271
|
-
this.options.load(options);
|
|
272
|
-
}
|
|
273
|
-
this.dragging = false;
|
|
274
|
-
this.name = this.options.name;
|
|
275
|
-
this.opacity = this.options.opacity;
|
|
276
|
-
this.size = (0,engine_root_window_.getRangeValue)(this.options.size.value) * container.retina.pixelRatio;
|
|
277
|
-
this.mass = this.size * this.options.size.density * container.retina.reduceFactor;
|
|
278
|
-
const limit = this.options.size.limit;
|
|
279
|
-
this.limit = {
|
|
280
|
-
radius: limit.radius * container.retina.pixelRatio * container.retina.reduceFactor,
|
|
281
|
-
mass: limit.mass
|
|
282
|
-
};
|
|
283
|
-
this.color = (0,engine_root_window_.rangeColorToRgb)(this.options.color) ?? {
|
|
284
|
-
b: 0,
|
|
285
|
-
g: 0,
|
|
286
|
-
r: 0
|
|
287
|
-
};
|
|
288
|
-
this.position = this.initialPosition?.copy() ?? this._calcPosition();
|
|
289
|
-
}
|
|
290
|
-
attract(particle) {
|
|
291
|
-
const container = this.container,
|
|
292
|
-
options = this.options;
|
|
293
|
-
if (options.draggable) {
|
|
294
|
-
const mouse = container.interactivity.mouse;
|
|
295
|
-
if (mouse.clicking && mouse.downPosition) {
|
|
296
|
-
const mouseDist = (0,engine_root_window_.getDistance)(this.position, mouse.downPosition);
|
|
297
|
-
if (mouseDist <= this.size) {
|
|
298
|
-
this.dragging = true;
|
|
299
|
-
}
|
|
300
|
-
} else {
|
|
301
|
-
this.dragging = false;
|
|
302
|
-
}
|
|
303
|
-
if (this.dragging && mouse.position) {
|
|
304
|
-
this.position.x = mouse.position.x;
|
|
305
|
-
this.position.y = mouse.position.y;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
const pos = particle.getPosition(),
|
|
309
|
-
{
|
|
310
|
-
dx,
|
|
311
|
-
dy,
|
|
312
|
-
distance
|
|
313
|
-
} = (0,engine_root_window_.getDistances)(this.position, pos),
|
|
314
|
-
v = engine_root_window_.Vector.create(dx, dy);
|
|
315
|
-
v.length = this.mass / Math.pow(distance, squareExp) * container.retina.reduceFactor;
|
|
316
|
-
if (distance < this.size + particle.getRadius()) {
|
|
317
|
-
const sizeFactor = particle.getRadius() * absorbFactor * container.retina.pixelRatio;
|
|
318
|
-
if (this.size > particle.getRadius() && distance < this.size - particle.getRadius() || particle.absorberOrbit !== undefined && particle.absorberOrbit.length < minOrbitLength) {
|
|
319
|
-
if (options.destroy) {
|
|
320
|
-
particle.destroy();
|
|
321
|
-
} else {
|
|
322
|
-
particle.needsNewPosition = true;
|
|
323
|
-
this._updateParticlePosition(particle, v);
|
|
324
|
-
}
|
|
325
|
-
} else {
|
|
326
|
-
if (options.destroy) {
|
|
327
|
-
particle.size.value -= sizeFactor;
|
|
328
|
-
}
|
|
329
|
-
this._updateParticlePosition(particle, v);
|
|
330
|
-
}
|
|
331
|
-
if (this.limit.radius <= minRadius || this.size < this.limit.radius) {
|
|
332
|
-
this.size += sizeFactor;
|
|
333
|
-
}
|
|
334
|
-
if (this.limit.mass <= minMass || this.mass < this.limit.mass) {
|
|
335
|
-
this.mass += sizeFactor * this.options.size.density * container.retina.reduceFactor;
|
|
336
|
-
}
|
|
337
|
-
} else {
|
|
338
|
-
this._updateParticlePosition(particle, v);
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
draw(context) {
|
|
342
|
-
context.translate(this.position.x, this.position.y);
|
|
343
|
-
context.beginPath();
|
|
344
|
-
context.arc(origin.x, origin.y, this.size, minAngle, maxAngle, false);
|
|
345
|
-
context.closePath();
|
|
346
|
-
context.fillStyle = (0,engine_root_window_.getStyleFromRgb)(this.color, this.opacity);
|
|
347
|
-
context.fill();
|
|
348
|
-
}
|
|
349
|
-
resize() {
|
|
350
|
-
const initialPosition = this.initialPosition;
|
|
351
|
-
this.position = initialPosition && (0,engine_root_window_.isPointInside)(initialPosition, this.container.canvas.size, engine_root_window_.Vector.origin) ? initialPosition : this._calcPosition();
|
|
352
|
-
}
|
|
353
|
-
}
|
|
354
|
-
;// CONCATENATED MODULE: ./dist/browser/Absorbers.js
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
const defaultIndex = 0;
|
|
358
|
-
class Absorbers {
|
|
359
|
-
constructor(container) {
|
|
360
|
-
this.container = container;
|
|
361
|
-
this.array = [];
|
|
362
|
-
this.absorbers = [];
|
|
363
|
-
this.interactivityAbsorbers = [];
|
|
364
|
-
container.getAbsorber = idxOrName => idxOrName === undefined || (0,engine_root_window_.isNumber)(idxOrName) ? this.array[idxOrName ?? defaultIndex] : this.array.find(t => t.name === idxOrName);
|
|
365
|
-
container.addAbsorber = (options, position) => this.addAbsorber(options, position);
|
|
366
|
-
}
|
|
367
|
-
addAbsorber(options, position) {
|
|
368
|
-
const absorber = new AbsorberInstance(this, this.container, options, position);
|
|
369
|
-
this.array.push(absorber);
|
|
370
|
-
return absorber;
|
|
371
|
-
}
|
|
372
|
-
draw(context) {
|
|
373
|
-
for (const absorber of this.array) {
|
|
374
|
-
absorber.draw(context);
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
handleClickMode(mode) {
|
|
378
|
-
const absorberOptions = this.absorbers,
|
|
379
|
-
modeAbsorbers = this.interactivityAbsorbers;
|
|
380
|
-
if (mode === "absorber") {
|
|
381
|
-
const absorbersModeOptions = (0,engine_root_window_.itemFromSingleOrMultiple)(modeAbsorbers),
|
|
382
|
-
absorbersOptions = absorbersModeOptions ?? (0,engine_root_window_.itemFromSingleOrMultiple)(absorberOptions),
|
|
383
|
-
aPosition = this.container.interactivity.mouse.clickPosition;
|
|
384
|
-
this.addAbsorber(absorbersOptions, aPosition);
|
|
385
|
-
}
|
|
386
|
-
}
|
|
387
|
-
async init() {
|
|
388
|
-
this.absorbers = this.container.actualOptions.absorbers;
|
|
389
|
-
this.interactivityAbsorbers = this.container.actualOptions.interactivity.modes.absorbers;
|
|
390
|
-
(0,engine_root_window_.executeOnSingleOrMultiple)(this.absorbers, absorber => {
|
|
391
|
-
this.addAbsorber(absorber);
|
|
392
|
-
});
|
|
393
|
-
await Promise.resolve();
|
|
394
|
-
}
|
|
395
|
-
particleUpdate(particle) {
|
|
396
|
-
for (const absorber of this.array) {
|
|
397
|
-
absorber.attract(particle);
|
|
398
|
-
if (particle.destroyed) {
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
removeAbsorber(absorber) {
|
|
404
|
-
const index = this.array.indexOf(absorber),
|
|
405
|
-
deleteCount = 1;
|
|
406
|
-
if (index >= defaultIndex) {
|
|
407
|
-
this.array.splice(index, deleteCount);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
resize() {
|
|
411
|
-
for (const absorber of this.array) {
|
|
412
|
-
absorber.resize();
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
stop() {
|
|
416
|
-
this.array = [];
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
;// CONCATENATED MODULE: ./dist/browser/index.js
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
class AbsorbersPlugin {
|
|
424
|
-
constructor() {
|
|
425
|
-
this.id = "absorbers";
|
|
426
|
-
}
|
|
427
|
-
getPlugin(container) {
|
|
428
|
-
return new Absorbers(container);
|
|
429
|
-
}
|
|
430
|
-
loadOptions(options, source) {
|
|
431
|
-
if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
if (source?.absorbers) {
|
|
435
|
-
options.absorbers = (0,engine_root_window_.executeOnSingleOrMultiple)(source.absorbers, absorber => {
|
|
436
|
-
const tmp = new Absorber();
|
|
437
|
-
tmp.load(absorber);
|
|
438
|
-
return tmp;
|
|
439
|
-
});
|
|
440
|
-
}
|
|
441
|
-
options.interactivity.modes.absorbers = (0,engine_root_window_.executeOnSingleOrMultiple)(source?.interactivity?.modes?.absorbers, absorber => {
|
|
442
|
-
const tmp = new Absorber();
|
|
443
|
-
tmp.load(absorber);
|
|
444
|
-
return tmp;
|
|
445
|
-
});
|
|
446
|
-
}
|
|
447
|
-
needsPlugin(options) {
|
|
448
|
-
if (!options) {
|
|
449
|
-
return false;
|
|
450
|
-
}
|
|
451
|
-
const absorbers = options.absorbers;
|
|
452
|
-
if ((0,engine_root_window_.isArray)(absorbers)) {
|
|
453
|
-
return !!absorbers.length;
|
|
454
|
-
} else if (absorbers) {
|
|
455
|
-
return true;
|
|
456
|
-
} else if (options.interactivity?.events?.onClick?.mode && (0,engine_root_window_.isInArray)("absorber", options.interactivity.events.onClick.mode)) {
|
|
457
|
-
return true;
|
|
458
|
-
}
|
|
459
|
-
return false;
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
async function loadAbsorbersPlugin(engine, refresh = true) {
|
|
463
|
-
await engine.addPlugin(new AbsorbersPlugin(), refresh);
|
|
464
|
-
}
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
})();
|
|
468
|
-
|
|
317
|
+
/******/
|
|
318
|
+
/******/ // startup
|
|
319
|
+
/******/ // Load entry module and return exports
|
|
320
|
+
/******/ // This entry module can't be inlined because the eval devtool is used.
|
|
321
|
+
/******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
|
|
322
|
+
/******/
|
|
469
323
|
/******/ return __webpack_exports__;
|
|
470
324
|
/******/ })()
|
|
471
325
|
;
|