@tsparticles/plugin-emitters 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.
@@ -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.0
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,38 @@
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, (__WEBPACK_EXTERNAL_MODULE__533__) => {
26
+ })(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
19
27
  return /******/ (() => { // webpackBootstrap
20
28
  /******/ "use strict";
21
29
  /******/ var __webpack_modules__ = ({
22
30
 
23
- /***/ 533:
31
+ /***/ "./dist/browser/EmitterShapeBase.js":
32
+ /*!******************************************!*\
33
+ !*** ./dist/browser/EmitterShapeBase.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 */ EmitterShapeBase: () => (/* binding */ EmitterShapeBase)\n/* harmony export */ });\nclass EmitterShapeBase {\n constructor(position, size, fill, options) {\n this.position = position;\n this.size = size;\n this.fill = fill;\n this.options = options;\n }\n resize(position, size) {\n this.position = position;\n this.size = size;\n }\n}\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters/./dist/browser/EmitterShapeBase.js?");
38
+
39
+ /***/ }),
40
+
41
+ /***/ "./dist/browser/index.js":
42
+ /*!*******************************!*\
43
+ !*** ./dist/browser/index.js ***!
44
+ \*******************************/
45
+ /***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
46
+
47
+ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ EmitterShapeBase: () => (/* reexport safe */ _EmitterShapeBase_js__WEBPACK_IMPORTED_MODULE_0__.EmitterShapeBase),\n/* harmony export */ loadEmittersPlugin: () => (/* binding */ loadEmittersPlugin)\n/* harmony export */ });\n/* harmony import */ var _EmitterShapeBase_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./EmitterShapeBase.js */ \"./dist/browser/EmitterShapeBase.js\");\nasync function loadEmittersPlugin(engine, refresh = true) {\n if (!engine.emitterShapeManager) {\n const {\n ShapeManager\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_ShapeManager_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./ShapeManager.js */ \"./dist/browser/ShapeManager.js\"));\n engine.emitterShapeManager = new ShapeManager(engine);\n }\n if (!engine.addEmitterShapeGenerator) {\n engine.addEmitterShapeGenerator = (name, generator) => {\n engine.emitterShapeManager?.addShapeGenerator(name, generator);\n };\n }\n const {\n EmittersPlugin\n } = await __webpack_require__.e(/*! import() */ \"dist_browser_EmittersPlugin_js\").then(__webpack_require__.bind(__webpack_require__, /*! ./EmittersPlugin.js */ \"./dist/browser/EmittersPlugin.js\")),\n plugin = new EmittersPlugin(engine);\n await engine.addPlugin(plugin, refresh);\n}\n\n\n\n\n\n\n\n\n//# sourceURL=webpack://@tsparticles/plugin-emitters/./dist/browser/index.js?");
48
+
49
+ /***/ }),
50
+
51
+ /***/ "@tsparticles/engine":
52
+ /*!*********************************************************************************************************************************!*\
53
+ !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
54
+ \*********************************************************************************************************************************/
24
55
  /***/ ((module) => {
25
56
 
26
- module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
57
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
27
58
 
28
59
  /***/ })
29
60
 
@@ -53,7 +84,22 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
53
84
  /******/ return module.exports;
54
85
  /******/ }
55
86
  /******/
87
+ /******/ // expose the modules object (__webpack_modules__)
88
+ /******/ __webpack_require__.m = __webpack_modules__;
89
+ /******/
56
90
  /************************************************************************/
91
+ /******/ /* webpack/runtime/compat get default export */
92
+ /******/ (() => {
93
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
94
+ /******/ __webpack_require__.n = (module) => {
95
+ /******/ var getter = module && module.__esModule ?
96
+ /******/ () => (module['default']) :
97
+ /******/ () => (module);
98
+ /******/ __webpack_require__.d(getter, { a: getter });
99
+ /******/ return getter;
100
+ /******/ };
101
+ /******/ })();
102
+ /******/
57
103
  /******/ /* webpack/runtime/define property getters */
58
104
  /******/ (() => {
59
105
  /******/ // define getter functions for harmony exports
@@ -66,11 +112,91 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
66
112
  /******/ };
67
113
  /******/ })();
68
114
  /******/
115
+ /******/ /* webpack/runtime/ensure chunk */
116
+ /******/ (() => {
117
+ /******/ __webpack_require__.f = {};
118
+ /******/ // This file contains only the entry chunk.
119
+ /******/ // The chunk loading function for additional chunks
120
+ /******/ __webpack_require__.e = (chunkId) => {
121
+ /******/ return Promise.all(Object.keys(__webpack_require__.f).reduce((promises, key) => {
122
+ /******/ __webpack_require__.f[key](chunkId, promises);
123
+ /******/ return promises;
124
+ /******/ }, []));
125
+ /******/ };
126
+ /******/ })();
127
+ /******/
128
+ /******/ /* webpack/runtime/get javascript chunk filename */
129
+ /******/ (() => {
130
+ /******/ // This function allow to reference async chunks
131
+ /******/ __webpack_require__.u = (chunkId) => {
132
+ /******/ // return url for filenames based on template
133
+ /******/ return "" + chunkId + ".js";
134
+ /******/ };
135
+ /******/ })();
136
+ /******/
137
+ /******/ /* webpack/runtime/global */
138
+ /******/ (() => {
139
+ /******/ __webpack_require__.g = (function() {
140
+ /******/ if (typeof globalThis === 'object') return globalThis;
141
+ /******/ try {
142
+ /******/ return this || new Function('return this')();
143
+ /******/ } catch (e) {
144
+ /******/ if (typeof window === 'object') return window;
145
+ /******/ }
146
+ /******/ })();
147
+ /******/ })();
148
+ /******/
69
149
  /******/ /* webpack/runtime/hasOwnProperty shorthand */
70
150
  /******/ (() => {
71
151
  /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
72
152
  /******/ })();
73
153
  /******/
154
+ /******/ /* webpack/runtime/load script */
155
+ /******/ (() => {
156
+ /******/ var inProgress = {};
157
+ /******/ var dataWebpackPrefix = "@tsparticles/plugin-emitters:";
158
+ /******/ // loadScript function to load a script via script tag
159
+ /******/ __webpack_require__.l = (url, done, key, chunkId) => {
160
+ /******/ if(inProgress[url]) { inProgress[url].push(done); return; }
161
+ /******/ var script, needAttach;
162
+ /******/ if(key !== undefined) {
163
+ /******/ var scripts = document.getElementsByTagName("script");
164
+ /******/ for(var i = 0; i < scripts.length; i++) {
165
+ /******/ var s = scripts[i];
166
+ /******/ if(s.getAttribute("src") == url || s.getAttribute("data-webpack") == dataWebpackPrefix + key) { script = s; break; }
167
+ /******/ }
168
+ /******/ }
169
+ /******/ if(!script) {
170
+ /******/ needAttach = true;
171
+ /******/ script = document.createElement('script');
172
+ /******/
173
+ /******/ script.charset = 'utf-8';
174
+ /******/ script.timeout = 120;
175
+ /******/ if (__webpack_require__.nc) {
176
+ /******/ script.setAttribute("nonce", __webpack_require__.nc);
177
+ /******/ }
178
+ /******/ script.setAttribute("data-webpack", dataWebpackPrefix + key);
179
+ /******/
180
+ /******/ script.src = url;
181
+ /******/ }
182
+ /******/ inProgress[url] = [done];
183
+ /******/ var onScriptComplete = (prev, event) => {
184
+ /******/ // avoid mem leaks in IE.
185
+ /******/ script.onerror = script.onload = null;
186
+ /******/ clearTimeout(timeout);
187
+ /******/ var doneFns = inProgress[url];
188
+ /******/ delete inProgress[url];
189
+ /******/ script.parentNode && script.parentNode.removeChild(script);
190
+ /******/ doneFns && doneFns.forEach((fn) => (fn(event)));
191
+ /******/ if(prev) return prev(event);
192
+ /******/ }
193
+ /******/ var timeout = setTimeout(onScriptComplete.bind(null, undefined, { type: 'timeout', target: script }), 120000);
194
+ /******/ script.onerror = onScriptComplete.bind(null, script.onerror);
195
+ /******/ script.onload = onScriptComplete.bind(null, script.onload);
196
+ /******/ needAttach && document.head.appendChild(script);
197
+ /******/ };
198
+ /******/ })();
199
+ /******/
74
200
  /******/ /* webpack/runtime/make namespace object */
75
201
  /******/ (() => {
76
202
  /******/ // define __esModule on exports
@@ -82,758 +208,128 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__533__;
82
208
  /******/ };
83
209
  /******/ })();
84
210
  /******/
211
+ /******/ /* webpack/runtime/publicPath */
212
+ /******/ (() => {
213
+ /******/ var scriptUrl;
214
+ /******/ if (__webpack_require__.g.importScripts) scriptUrl = __webpack_require__.g.location + "";
215
+ /******/ var document = __webpack_require__.g.document;
216
+ /******/ if (!scriptUrl && document) {
217
+ /******/ if (document.currentScript)
218
+ /******/ scriptUrl = document.currentScript.src;
219
+ /******/ if (!scriptUrl) {
220
+ /******/ var scripts = document.getElementsByTagName("script");
221
+ /******/ if(scripts.length) {
222
+ /******/ var i = scripts.length - 1;
223
+ /******/ while (i > -1 && !scriptUrl) scriptUrl = scripts[i--].src;
224
+ /******/ }
225
+ /******/ }
226
+ /******/ }
227
+ /******/ // When supporting browsers where an automatic publicPath is not supported you must specify an output.publicPath manually via configuration
228
+ /******/ // or pass an empty string ("") and set the __webpack_public_path__ variable from your code to use your own logic.
229
+ /******/ if (!scriptUrl) throw new Error("Automatic publicPath is not supported in this browser");
230
+ /******/ scriptUrl = scriptUrl.replace(/#.*$/, "").replace(/\?.*$/, "").replace(/\/[^\/]+$/, "/");
231
+ /******/ __webpack_require__.p = scriptUrl;
232
+ /******/ })();
233
+ /******/
234
+ /******/ /* webpack/runtime/jsonp chunk loading */
235
+ /******/ (() => {
236
+ /******/ // no baseURI
237
+ /******/
238
+ /******/ // object to store loaded and loading chunks
239
+ /******/ // undefined = chunk not loaded, null = chunk preloaded/prefetched
240
+ /******/ // [resolve, reject, Promise] = chunk loading, 0 = chunk loaded
241
+ /******/ var installedChunks = {
242
+ /******/ "tsparticles.plugin.emitters": 0
243
+ /******/ };
244
+ /******/
245
+ /******/ __webpack_require__.f.j = (chunkId, promises) => {
246
+ /******/ // JSONP chunk loading for javascript
247
+ /******/ var installedChunkData = __webpack_require__.o(installedChunks, chunkId) ? installedChunks[chunkId] : undefined;
248
+ /******/ if(installedChunkData !== 0) { // 0 means "already installed".
249
+ /******/
250
+ /******/ // a Promise means "currently loading".
251
+ /******/ if(installedChunkData) {
252
+ /******/ promises.push(installedChunkData[2]);
253
+ /******/ } else {
254
+ /******/ if(true) { // all chunks have JS
255
+ /******/ // setup Promise in chunk cache
256
+ /******/ var promise = new Promise((resolve, reject) => (installedChunkData = installedChunks[chunkId] = [resolve, reject]));
257
+ /******/ promises.push(installedChunkData[2] = promise);
258
+ /******/
259
+ /******/ // start chunk loading
260
+ /******/ var url = __webpack_require__.p + __webpack_require__.u(chunkId);
261
+ /******/ // create error before stack unwound to get useful stacktrace later
262
+ /******/ var error = new Error();
263
+ /******/ var loadingEnded = (event) => {
264
+ /******/ if(__webpack_require__.o(installedChunks, chunkId)) {
265
+ /******/ installedChunkData = installedChunks[chunkId];
266
+ /******/ if(installedChunkData !== 0) installedChunks[chunkId] = undefined;
267
+ /******/ if(installedChunkData) {
268
+ /******/ var errorType = event && (event.type === 'load' ? 'missing' : event.type);
269
+ /******/ var realSrc = event && event.target && event.target.src;
270
+ /******/ error.message = 'Loading chunk ' + chunkId + ' failed.\n(' + errorType + ': ' + realSrc + ')';
271
+ /******/ error.name = 'ChunkLoadError';
272
+ /******/ error.type = errorType;
273
+ /******/ error.request = realSrc;
274
+ /******/ installedChunkData[1](error);
275
+ /******/ }
276
+ /******/ }
277
+ /******/ };
278
+ /******/ __webpack_require__.l(url, loadingEnded, "chunk-" + chunkId, chunkId);
279
+ /******/ }
280
+ /******/ }
281
+ /******/ }
282
+ /******/ };
283
+ /******/
284
+ /******/ // no prefetching
285
+ /******/
286
+ /******/ // no preloaded
287
+ /******/
288
+ /******/ // no HMR
289
+ /******/
290
+ /******/ // no HMR manifest
291
+ /******/
292
+ /******/ // no on chunks loaded
293
+ /******/
294
+ /******/ // install a JSONP callback for chunk loading
295
+ /******/ var webpackJsonpCallback = (parentChunkLoadingFunction, data) => {
296
+ /******/ var chunkIds = data[0];
297
+ /******/ var moreModules = data[1];
298
+ /******/ var runtime = data[2];
299
+ /******/ // add "moreModules" to the modules object,
300
+ /******/ // then flag all "chunkIds" as loaded and fire callback
301
+ /******/ var moduleId, chunkId, i = 0;
302
+ /******/ if(chunkIds.some((id) => (installedChunks[id] !== 0))) {
303
+ /******/ for(moduleId in moreModules) {
304
+ /******/ if(__webpack_require__.o(moreModules, moduleId)) {
305
+ /******/ __webpack_require__.m[moduleId] = moreModules[moduleId];
306
+ /******/ }
307
+ /******/ }
308
+ /******/ if(runtime) var result = runtime(__webpack_require__);
309
+ /******/ }
310
+ /******/ if(parentChunkLoadingFunction) parentChunkLoadingFunction(data);
311
+ /******/ for(;i < chunkIds.length; i++) {
312
+ /******/ chunkId = chunkIds[i];
313
+ /******/ if(__webpack_require__.o(installedChunks, chunkId) && installedChunks[chunkId]) {
314
+ /******/ installedChunks[chunkId][0]();
315
+ /******/ }
316
+ /******/ installedChunks[chunkId] = 0;
317
+ /******/ }
318
+ /******/
319
+ /******/ }
320
+ /******/
321
+ /******/ var chunkLoadingGlobal = this["webpackChunk_tsparticles_plugin_emitters"] = this["webpackChunk_tsparticles_plugin_emitters"] || [];
322
+ /******/ chunkLoadingGlobal.forEach(webpackJsonpCallback.bind(null, 0));
323
+ /******/ chunkLoadingGlobal.push = webpackJsonpCallback.bind(null, chunkLoadingGlobal.push.bind(chunkLoadingGlobal));
324
+ /******/ })();
325
+ /******/
85
326
  /************************************************************************/
86
- var __webpack_exports__ = {};
87
- // This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
88
- (() => {
89
- // ESM COMPAT FLAG
90
- __webpack_require__.r(__webpack_exports__);
91
-
92
- // EXPORTS
93
- __webpack_require__.d(__webpack_exports__, {
94
- EmitterShapeBase: () => (/* reexport */ EmitterShapeBase),
95
- loadEmittersPlugin: () => (/* binding */ loadEmittersPlugin)
96
- });
97
-
98
- // EXTERNAL MODULE: external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"}
99
- var engine_root_window_ = __webpack_require__(533);
100
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/EmitterLife.js
101
-
102
- class EmitterLife {
103
- constructor() {
104
- this.wait = false;
105
- }
106
- load(data) {
107
- if (!data) {
108
- return;
109
- }
110
- if (data.count !== undefined) {
111
- this.count = data.count;
112
- }
113
- if (data.delay !== undefined) {
114
- this.delay = (0,engine_root_window_.setRangeValue)(data.delay);
115
- }
116
- if (data.duration !== undefined) {
117
- this.duration = (0,engine_root_window_.setRangeValue)(data.duration);
118
- }
119
- if (data.wait !== undefined) {
120
- this.wait = data.wait;
121
- }
122
- }
123
- }
124
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/EmitterRate.js
125
-
126
- class EmitterRate {
127
- constructor() {
128
- this.quantity = 1;
129
- this.delay = 0.1;
130
- }
131
- load(data) {
132
- if (data === undefined) {
133
- return;
134
- }
135
- if (data.quantity !== undefined) {
136
- this.quantity = (0,engine_root_window_.setRangeValue)(data.quantity);
137
- }
138
- if (data.delay !== undefined) {
139
- this.delay = (0,engine_root_window_.setRangeValue)(data.delay);
140
- }
141
- }
142
- }
143
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/EmitterShapeReplace.js
144
- class EmitterShapeReplace {
145
- constructor() {
146
- this.color = false;
147
- this.opacity = false;
148
- }
149
- load(data) {
150
- if (!data) {
151
- return;
152
- }
153
- if (data.color !== undefined) {
154
- this.color = data.color;
155
- }
156
- if (data.opacity !== undefined) {
157
- this.opacity = data.opacity;
158
- }
159
- }
160
- }
161
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/EmitterShape.js
162
-
163
-
164
- class EmitterShape {
165
- constructor() {
166
- this.options = {};
167
- this.replace = new EmitterShapeReplace();
168
- this.type = "square";
169
- }
170
- load(data) {
171
- if (!data) {
172
- return;
173
- }
174
- if (data.options !== undefined) {
175
- this.options = (0,engine_root_window_.deepExtend)({}, data.options ?? {});
176
- }
177
- this.replace.load(data.replace);
178
- if (data.type !== undefined) {
179
- this.type = data.type;
180
- }
181
- }
182
- }
183
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/EmitterSize.js
184
- class EmitterSize {
185
- constructor() {
186
- this.mode = "percent";
187
- this.height = 0;
188
- this.width = 0;
189
- }
190
- load(data) {
191
- if (data === undefined) {
192
- return;
193
- }
194
- if (data.mode !== undefined) {
195
- this.mode = data.mode;
196
- }
197
- if (data.height !== undefined) {
198
- this.height = data.height;
199
- }
200
- if (data.width !== undefined) {
201
- this.width = data.width;
202
- }
203
- }
204
- }
205
- ;// CONCATENATED MODULE: ./dist/browser/Options/Classes/Emitter.js
206
-
207
-
208
-
209
-
210
-
211
- class Emitter {
212
- constructor() {
213
- this.autoPlay = true;
214
- this.fill = true;
215
- this.life = new EmitterLife();
216
- this.rate = new EmitterRate();
217
- this.shape = new EmitterShape();
218
- this.startCount = 0;
219
- }
220
- load(data) {
221
- if (!data) {
222
- return;
223
- }
224
- if (data.autoPlay !== undefined) {
225
- this.autoPlay = data.autoPlay;
226
- }
227
- if (data.size !== undefined) {
228
- if (!this.size) {
229
- this.size = new EmitterSize();
230
- }
231
- this.size.load(data.size);
232
- }
233
- if (data.direction !== undefined) {
234
- this.direction = data.direction;
235
- }
236
- this.domId = data.domId;
237
- if (data.fill !== undefined) {
238
- this.fill = data.fill;
239
- }
240
- this.life.load(data.life);
241
- this.name = data.name;
242
- this.particles = (0,engine_root_window_.executeOnSingleOrMultiple)(data.particles, particles => {
243
- return (0,engine_root_window_.deepExtend)({}, particles);
244
- });
245
- this.rate.load(data.rate);
246
- this.shape.load(data.shape);
247
- if (data.position !== undefined) {
248
- this.position = {};
249
- if (data.position.x !== undefined) {
250
- this.position.x = (0,engine_root_window_.setRangeValue)(data.position.x);
251
- }
252
- if (data.position.y !== undefined) {
253
- this.position.y = (0,engine_root_window_.setRangeValue)(data.position.y);
254
- }
255
- }
256
- if (data.spawnColor !== undefined) {
257
- if (this.spawnColor === undefined) {
258
- this.spawnColor = new engine_root_window_.AnimatableColor();
259
- }
260
- this.spawnColor.load(data.spawnColor);
261
- }
262
- if (data.startCount !== undefined) {
263
- this.startCount = data.startCount;
264
- }
265
- }
266
- }
267
- ;// CONCATENATED MODULE: ./dist/browser/EmitterInstance.js
268
-
269
-
270
-
271
- const half = 0.5,
272
- defaultLifeDelay = 0,
273
- minLifeCount = 0,
274
- defaultSpawnDelay = 0,
275
- defaultEmitDelay = 0,
276
- defaultLifeCount = -1;
277
- function setParticlesOptionsColor(particlesOptions, color) {
278
- if (particlesOptions.color) {
279
- particlesOptions.color.value = color;
280
- } else {
281
- particlesOptions.color = {
282
- value: color
283
- };
284
- }
285
- }
286
- class EmitterInstance {
287
- constructor(engine, emitters, container, options, position) {
288
- this.emitters = emitters;
289
- this.container = container;
290
- this._destroy = () => {
291
- this._mutationObserver?.disconnect();
292
- this._mutationObserver = undefined;
293
- this._resizeObserver?.disconnect();
294
- this._resizeObserver = undefined;
295
- this.emitters.removeEmitter(this);
296
- this._engine.dispatchEvent("emitterDestroyed", {
297
- container: this.container,
298
- data: {
299
- emitter: this
300
- }
301
- });
302
- };
303
- this._prepareToDie = () => {
304
- if (this._paused) {
305
- return;
306
- }
307
- const duration = this.options.life?.duration !== undefined ? (0,engine_root_window_.getRangeValue)(this.options.life.duration) : undefined,
308
- minDuration = 0,
309
- minLifeCount = 0;
310
- if (this.container.retina.reduceFactor && (this._lifeCount > minLifeCount || this._immortal) && duration !== undefined && duration > minDuration) {
311
- this._duration = duration * engine_root_window_.millisecondsToSeconds;
312
- }
313
- };
314
- this._setColorAnimation = (animation, initValue, maxValue) => {
315
- const container = this.container;
316
- if (!animation.enable) {
317
- return initValue;
318
- }
319
- const colorOffset = (0,engine_root_window_.randomInRange)(animation.offset),
320
- delay = (0,engine_root_window_.getRangeValue)(this.options.rate.delay),
321
- emitFactor = delay * engine_root_window_.millisecondsToSeconds / container.retina.reduceFactor,
322
- defaultColorSpeed = 0,
323
- colorFactor = 3.6,
324
- colorSpeed = (0,engine_root_window_.getRangeValue)(animation.speed ?? defaultColorSpeed);
325
- return (initValue + colorSpeed * container.fpsLimit / emitFactor + colorOffset * colorFactor) % maxValue;
326
- };
327
- this._engine = engine;
328
- this._currentDuration = 0;
329
- this._currentEmitDelay = 0;
330
- this._currentSpawnDelay = 0;
331
- this._initialPosition = position;
332
- if (options instanceof Emitter) {
333
- this.options = options;
334
- } else {
335
- this.options = new Emitter();
336
- this.options.load(options);
337
- }
338
- this._spawnDelay = (0,engine_root_window_.getRangeValue)(this.options.life.delay ?? defaultLifeDelay) * engine_root_window_.millisecondsToSeconds / this.container.retina.reduceFactor;
339
- this.position = this._initialPosition ?? this._calcPosition();
340
- this.name = this.options.name;
341
- this.fill = this.options.fill;
342
- this._firstSpawn = !this.options.life.wait;
343
- this._startParticlesAdded = false;
344
- let particlesOptions = (0,engine_root_window_.deepExtend)({}, this.options.particles);
345
- particlesOptions ??= {};
346
- particlesOptions.move ??= {};
347
- particlesOptions.move.direction ??= this.options.direction;
348
- if (this.options.spawnColor) {
349
- this.spawnColor = (0,engine_root_window_.rangeColorToHsl)(this.options.spawnColor);
350
- }
351
- this._paused = !this.options.autoPlay;
352
- this._particlesOptions = particlesOptions;
353
- this._size = this._calcSize();
354
- this.size = (0,engine_root_window_.getSize)(this._size, this.container.canvas.size);
355
- this._lifeCount = this.options.life.count ?? defaultLifeCount;
356
- this._immortal = this._lifeCount <= minLifeCount;
357
- if (this.options.domId) {
358
- const element = document.getElementById(this.options.domId);
359
- if (element) {
360
- this._mutationObserver = new MutationObserver(() => {
361
- this.resize();
362
- });
363
- this._resizeObserver = new ResizeObserver(() => {
364
- this.resize();
365
- });
366
- this._mutationObserver.observe(element, {
367
- attributes: true,
368
- attributeFilter: ["style", "width", "height"]
369
- });
370
- this._resizeObserver.observe(element);
371
- }
372
- }
373
- const shapeOptions = this.options.shape,
374
- shapeGenerator = this._engine.emitterShapeManager?.getShapeGenerator(shapeOptions.type);
375
- if (shapeGenerator) {
376
- this._shape = shapeGenerator.generate(this.position, this.size, this.fill, shapeOptions.options);
377
- }
378
- this._engine.dispatchEvent("emitterCreated", {
379
- container,
380
- data: {
381
- emitter: this
382
- }
383
- });
384
- this.play();
385
- }
386
- externalPause() {
387
- this._paused = true;
388
- this.pause();
389
- }
390
- externalPlay() {
391
- this._paused = false;
392
- this.play();
393
- }
394
- async init() {
395
- await this._shape?.init();
396
- }
397
- pause() {
398
- if (this._paused) {
399
- return;
400
- }
401
- delete this._emitDelay;
402
- }
403
- play() {
404
- if (this._paused) {
405
- return;
406
- }
407
- if (!(this.container.retina.reduceFactor && (this._lifeCount > minLifeCount || this._immortal || !this.options.life.count) && (this._firstSpawn || this._currentSpawnDelay >= (this._spawnDelay ?? defaultSpawnDelay)))) {
408
- return;
409
- }
410
- if (this._emitDelay === undefined) {
411
- const delay = (0,engine_root_window_.getRangeValue)(this.options.rate.delay);
412
- this._emitDelay = delay * engine_root_window_.millisecondsToSeconds / this.container.retina.reduceFactor;
413
- }
414
- if (this._lifeCount > minLifeCount || this._immortal) {
415
- this._prepareToDie();
416
- }
417
- }
418
- resize() {
419
- const initialPosition = this._initialPosition;
420
- this.position = initialPosition && (0,engine_root_window_.isPointInside)(initialPosition, this.container.canvas.size, engine_root_window_.Vector.origin) ? initialPosition : this._calcPosition();
421
- this._size = this._calcSize();
422
- this.size = (0,engine_root_window_.getSize)(this._size, this.container.canvas.size);
423
- this._shape?.resize(this.position, this.size);
424
- }
425
- async update(delta) {
426
- if (this._paused) {
427
- return;
428
- }
429
- if (this._firstSpawn) {
430
- this._firstSpawn = false;
431
- this._currentSpawnDelay = this._spawnDelay ?? defaultSpawnDelay;
432
- this._currentEmitDelay = this._emitDelay ?? defaultEmitDelay;
433
- }
434
- if (!this._startParticlesAdded) {
435
- this._startParticlesAdded = true;
436
- await this._emitParticles(this.options.startCount);
437
- }
438
- if (this._duration !== undefined) {
439
- this._currentDuration += delta.value;
440
- if (this._currentDuration >= this._duration) {
441
- this.pause();
442
- if (this._spawnDelay !== undefined) {
443
- delete this._spawnDelay;
444
- }
445
- if (!this._immortal) {
446
- this._lifeCount--;
447
- }
448
- if (this._lifeCount > minLifeCount || this._immortal) {
449
- this.position = this._calcPosition();
450
- this._shape?.resize(this.position, this.size);
451
- this._spawnDelay = (0,engine_root_window_.getRangeValue)(this.options.life.delay ?? defaultLifeDelay) * engine_root_window_.millisecondsToSeconds / this.container.retina.reduceFactor;
452
- } else {
453
- this._destroy();
454
- }
455
- this._currentDuration -= this._duration;
456
- delete this._duration;
457
- }
458
- }
459
- if (this._spawnDelay !== undefined) {
460
- this._currentSpawnDelay += delta.value;
461
- if (this._currentSpawnDelay >= this._spawnDelay) {
462
- this._engine.dispatchEvent("emitterPlay", {
463
- container: this.container
464
- });
465
- this.play();
466
- this._currentSpawnDelay -= this._currentSpawnDelay;
467
- delete this._spawnDelay;
468
- }
469
- }
470
- if (this._emitDelay !== undefined) {
471
- this._currentEmitDelay += delta.value;
472
- if (this._currentEmitDelay >= this._emitDelay) {
473
- await this._emit();
474
- this._currentEmitDelay -= this._emitDelay;
475
- }
476
- }
477
- }
478
- _calcPosition() {
479
- if (this.options.domId) {
480
- const container = this.container,
481
- element = document.getElementById(this.options.domId);
482
- if (element) {
483
- const elRect = element.getBoundingClientRect(),
484
- pxRatio = container.retina.pixelRatio;
485
- return {
486
- x: (elRect.x + elRect.width * half) * pxRatio,
487
- y: (elRect.y + elRect.height * half) * pxRatio
488
- };
489
- }
490
- }
491
- return (0,engine_root_window_.calcPositionOrRandomFromSizeRanged)({
492
- size: this.container.canvas.size,
493
- position: this.options.position
494
- });
495
- }
496
- _calcSize() {
497
- const container = this.container;
498
- if (this.options.domId) {
499
- const element = document.getElementById(this.options.domId);
500
- if (element) {
501
- const elRect = element.getBoundingClientRect();
502
- return {
503
- width: elRect.width * container.retina.pixelRatio,
504
- height: elRect.height * container.retina.pixelRatio,
505
- mode: "precise"
506
- };
507
- }
508
- }
509
- return this.options.size ?? (() => {
510
- const size = new EmitterSize();
511
- size.load({
512
- height: 0,
513
- mode: "percent",
514
- width: 0
515
- });
516
- return size;
517
- })();
518
- }
519
- async _emit() {
520
- if (this._paused) {
521
- return;
522
- }
523
- const quantity = (0,engine_root_window_.getRangeValue)(this.options.rate.quantity);
524
- await this._emitParticles(quantity);
525
- }
526
- async _emitParticles(quantity) {
527
- const singleParticlesOptions = (0,engine_root_window_.itemFromSingleOrMultiple)(this._particlesOptions);
528
- for (let i = 0; i < quantity; i++) {
529
- const particlesOptions = (0,engine_root_window_.deepExtend)({}, singleParticlesOptions);
530
- if (this.spawnColor) {
531
- const hslAnimation = this.options.spawnColor?.animation;
532
- if (hslAnimation) {
533
- const maxValues = {
534
- h: 360,
535
- s: 100,
536
- l: 100
537
- };
538
- this.spawnColor.h = this._setColorAnimation(hslAnimation.h, this.spawnColor.h, maxValues.h);
539
- this.spawnColor.s = this._setColorAnimation(hslAnimation.s, this.spawnColor.s, maxValues.s);
540
- this.spawnColor.l = this._setColorAnimation(hslAnimation.l, this.spawnColor.l, maxValues.l);
541
- }
542
- setParticlesOptionsColor(particlesOptions, this.spawnColor);
543
- }
544
- const shapeOptions = this.options.shape;
545
- let position = this.position;
546
- if (this._shape) {
547
- const shapePosData = await this._shape.randomPosition();
548
- if (shapePosData) {
549
- position = shapePosData.position;
550
- const replaceData = shapeOptions.replace;
551
- if (replaceData.color && shapePosData.color) {
552
- setParticlesOptionsColor(particlesOptions, shapePosData.color);
553
- }
554
- if (replaceData.opacity) {
555
- if (particlesOptions.opacity) {
556
- particlesOptions.opacity.value = shapePosData.opacity;
557
- } else {
558
- particlesOptions.opacity = {
559
- value: shapePosData.opacity
560
- };
561
- }
562
- }
563
- } else {
564
- position = null;
565
- }
566
- }
567
- if (position) {
568
- this.container.particles.addParticle(position, particlesOptions);
569
- }
570
- }
571
- }
572
- }
573
- ;// CONCATENATED MODULE: ./dist/browser/Emitters.js
574
-
575
-
576
-
577
- class Emitters {
578
- constructor(engine, container) {
579
- this.container = container;
580
- this._engine = engine;
581
- this.array = [];
582
- this.emitters = [];
583
- this.interactivityEmitters = {
584
- random: {
585
- count: 1,
586
- enable: false
587
- },
588
- value: []
589
- };
590
- const defaultIndex = 0;
591
- container.getEmitter = idxOrName => idxOrName === undefined || (0,engine_root_window_.isNumber)(idxOrName) ? this.array[idxOrName ?? defaultIndex] : this.array.find(t => t.name === idxOrName);
592
- container.addEmitter = async (options, position) => this.addEmitter(options, position);
593
- container.removeEmitter = idxOrName => {
594
- const emitter = container.getEmitter(idxOrName);
595
- if (emitter) {
596
- this.removeEmitter(emitter);
597
- }
598
- };
599
- container.playEmitter = idxOrName => {
600
- const emitter = container.getEmitter(idxOrName);
601
- if (emitter) {
602
- emitter.externalPlay();
603
- }
604
- };
605
- container.pauseEmitter = idxOrName => {
606
- const emitter = container.getEmitter(idxOrName);
607
- if (emitter) {
608
- emitter.externalPause();
609
- }
610
- };
611
- }
612
- async addEmitter(options, position) {
613
- const emitterOptions = new Emitter();
614
- emitterOptions.load(options);
615
- const emitter = new EmitterInstance(this._engine, this, this.container, emitterOptions, position);
616
- await emitter.init();
617
- this.array.push(emitter);
618
- return emitter;
619
- }
620
- handleClickMode(mode) {
621
- const emitterOptions = this.emitters,
622
- modeEmitters = this.interactivityEmitters;
623
- if (mode !== "emitter") {
624
- return;
625
- }
626
- let emittersModeOptions;
627
- if (modeEmitters && (0,engine_root_window_.isArray)(modeEmitters.value)) {
628
- const minLength = 0;
629
- if (modeEmitters.value.length > minLength && modeEmitters.random.enable) {
630
- emittersModeOptions = [];
631
- const usedIndexes = [];
632
- for (let i = 0; i < modeEmitters.random.count; i++) {
633
- const idx = (0,engine_root_window_.arrayRandomIndex)(modeEmitters.value);
634
- if (usedIndexes.includes(idx) && usedIndexes.length < modeEmitters.value.length) {
635
- i--;
636
- continue;
637
- }
638
- usedIndexes.push(idx);
639
- emittersModeOptions.push((0,engine_root_window_.itemFromArray)(modeEmitters.value, idx));
640
- }
641
- } else {
642
- emittersModeOptions = modeEmitters.value;
643
- }
644
- } else {
645
- emittersModeOptions = modeEmitters?.value;
646
- }
647
- const emittersOptions = emittersModeOptions ?? emitterOptions,
648
- ePosition = this.container.interactivity.mouse.clickPosition;
649
- void (0,engine_root_window_.executeOnSingleOrMultiple)(emittersOptions, async emitter => {
650
- await this.addEmitter(emitter, ePosition);
651
- });
652
- }
653
- async init() {
654
- this.emitters = this.container.actualOptions.emitters;
655
- this.interactivityEmitters = this.container.actualOptions.interactivity.modes.emitters;
656
- if (!this.emitters) {
657
- return;
658
- }
659
- if ((0,engine_root_window_.isArray)(this.emitters)) {
660
- for (const emitterOptions of this.emitters) {
661
- await this.addEmitter(emitterOptions);
662
- }
663
- } else {
664
- await this.addEmitter(this.emitters);
665
- }
666
- }
667
- pause() {
668
- for (const emitter of this.array) {
669
- emitter.pause();
670
- }
671
- }
672
- play() {
673
- for (const emitter of this.array) {
674
- emitter.play();
675
- }
676
- }
677
- removeEmitter(emitter) {
678
- const index = this.array.indexOf(emitter),
679
- minIndex = 0,
680
- deleteCount = 1;
681
- if (index >= minIndex) {
682
- this.array.splice(index, deleteCount);
683
- }
684
- }
685
- resize() {
686
- for (const emitter of this.array) {
687
- emitter.resize();
688
- }
689
- }
690
- stop() {
691
- this.array = [];
692
- }
693
- async update(delta) {
694
- for (const emitter of this.array) {
695
- await emitter.update(delta);
696
- }
697
- }
698
- }
699
- ;// CONCATENATED MODULE: ./dist/browser/ShapeManager.js
700
- const shapeGeneratorss = new Map();
701
- class ShapeManager {
702
- constructor(engine) {
703
- this._engine = engine;
704
- }
705
- addShapeGenerator(name, generator) {
706
- if (!this.getShapeGenerator(name)) {
707
- shapeGeneratorss.set(name, generator);
708
- }
709
- }
710
- getShapeGenerator(name) {
711
- return shapeGeneratorss.get(name);
712
- }
713
- getSupportedShapeGenerators() {
714
- return shapeGeneratorss.keys();
715
- }
716
- }
717
- ;// CONCATENATED MODULE: ./dist/browser/EmitterShapeBase.js
718
- class EmitterShapeBase {
719
- constructor(position, size, fill, options) {
720
- this.position = position;
721
- this.size = size;
722
- this.fill = fill;
723
- this.options = options;
724
- }
725
- resize(position, size) {
726
- this.position = position;
727
- this.size = size;
728
- }
729
- }
730
- ;// CONCATENATED MODULE: ./dist/browser/index.js
731
-
732
-
733
-
734
-
735
- class EmittersPlugin {
736
- constructor(engine) {
737
- this._engine = engine;
738
- this.id = "emitters";
739
- }
740
- getPlugin(container) {
741
- return new Emitters(this._engine, container);
742
- }
743
- loadOptions(options, source) {
744
- if (!this.needsPlugin(options) && !this.needsPlugin(source)) {
745
- return;
746
- }
747
- if (source?.emitters) {
748
- options.emitters = (0,engine_root_window_.executeOnSingleOrMultiple)(source.emitters, emitter => {
749
- const tmp = new Emitter();
750
- tmp.load(emitter);
751
- return tmp;
752
- });
753
- }
754
- const interactivityEmitters = source?.interactivity?.modes?.emitters;
755
- if (interactivityEmitters) {
756
- if ((0,engine_root_window_.isArray)(interactivityEmitters)) {
757
- options.interactivity.modes.emitters = {
758
- random: {
759
- count: 1,
760
- enable: true
761
- },
762
- value: interactivityEmitters.map(s => {
763
- const tmp = new Emitter();
764
- tmp.load(s);
765
- return tmp;
766
- })
767
- };
768
- } else {
769
- const emitterMode = interactivityEmitters;
770
- if (emitterMode.value !== undefined) {
771
- const defaultCount = 1;
772
- if ((0,engine_root_window_.isArray)(emitterMode.value)) {
773
- options.interactivity.modes.emitters = {
774
- random: {
775
- count: emitterMode.random.count ?? defaultCount,
776
- enable: emitterMode.random.enable ?? false
777
- },
778
- value: emitterMode.value.map(s => {
779
- const tmp = new Emitter();
780
- tmp.load(s);
781
- return tmp;
782
- })
783
- };
784
- } else {
785
- const tmp = new Emitter();
786
- tmp.load(emitterMode.value);
787
- options.interactivity.modes.emitters = {
788
- random: {
789
- count: emitterMode.random.count ?? defaultCount,
790
- enable: emitterMode.random.enable ?? false
791
- },
792
- value: tmp
793
- };
794
- }
795
- } else {
796
- const emitterOptions = options.interactivity.modes.emitters = {
797
- random: {
798
- count: 1,
799
- enable: false
800
- },
801
- value: new Emitter()
802
- };
803
- emitterOptions.value.load(interactivityEmitters);
804
- }
805
- }
806
- }
807
- }
808
- needsPlugin(options) {
809
- if (!options) {
810
- return false;
811
- }
812
- const emitters = options.emitters;
813
- return (0,engine_root_window_.isArray)(emitters) && !!emitters.length || emitters !== undefined || !!options.interactivity?.events?.onClick?.mode && (0,engine_root_window_.isInArray)("emitter", options.interactivity.events.onClick.mode);
814
- }
815
- }
816
- async function loadEmittersPlugin(engine, refresh = true) {
817
- if (!engine.emitterShapeManager) {
818
- engine.emitterShapeManager = new ShapeManager(engine);
819
- }
820
- if (!engine.addEmitterShapeGenerator) {
821
- engine.addEmitterShapeGenerator = (name, generator) => {
822
- engine.emitterShapeManager?.addShapeGenerator(name, generator);
823
- };
824
- }
825
- const plugin = new EmittersPlugin(engine);
826
- await engine.addPlugin(plugin, refresh);
827
- }
828
-
829
-
830
-
831
-
832
-
833
-
834
-
835
- })();
836
-
327
+ /******/
328
+ /******/ // startup
329
+ /******/ // Load entry module and return exports
330
+ /******/ // This entry module can't be inlined because the eval devtool is used.
331
+ /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
332
+ /******/
837
333
  /******/ return __webpack_exports__;
838
334
  /******/ })()
839
335
  ;