@tsparticles/noise-field 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,132 +1,186 @@
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/engine"));
20
- else if(typeof define === 'function' && define.amd)
21
- define(["@tsparticles/engine"], factory);
22
- else {
23
- var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
24
- for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
25
- }
26
- })(this, (__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
+ /* Utility v4.0.0 */
3
+ (function (global, factory) {
4
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tsparticles/engine')) :
5
+ typeof define === 'function' && define.amd ? define(['exports', '@tsparticles/engine'], factory) :
6
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.__tsParticlesInternals = global.__tsParticlesInternals || {}, global.__tsParticlesInternals.noise = global.__tsParticlesInternals.noise || {}, global.__tsParticlesInternals.noise.field = global.__tsParticlesInternals.noise.field || {}), global.__tsParticlesInternals.engine));
7
+ })(this, (function (exports, 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
+ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
10
+ a: 1,
11
+ b: 0,
12
+ c: 0,
13
+ d: 1,
14
+ e: 0,
15
+ f: 0,
16
+ }, defaultOptions = {
17
+ draw: false,
18
+ size: 20,
19
+ increment: 0.004,
20
+ columns: 0,
21
+ rows: 0,
22
+ layers: 0,
23
+ width: 0,
24
+ height: 0,
25
+ factor: {
26
+ angle: 0.02,
27
+ length: 0.01,
28
+ },
29
+ offset: {
30
+ x: 40000,
31
+ y: 40000,
32
+ z: 40000,
33
+ },
34
+ };
35
+ class NoiseFieldGenerator {
36
+ container;
37
+ field;
38
+ noiseGen;
39
+ noiseW;
40
+ options;
41
+ _res;
42
+ constructor(container, noiseGen) {
43
+ this.container = container;
44
+ this.noiseGen = noiseGen;
45
+ this.field = [];
46
+ this.noiseW = 0;
47
+ this._res = engine.Vector.origin;
48
+ this.options = engine.deepExtend({}, defaultOptions);
49
+ }
50
+ generate(particle) {
51
+ const pos = particle.getPosition(), { size } = this.options, sizeFactor = engine.identity / size, point = {
52
+ x: Math.max(Math.floor(pos.x * sizeFactor), originCoordinate),
53
+ y: Math.max(Math.floor(pos.y * sizeFactor), originCoordinate),
54
+ z: Math.max(Math.floor(pos.z * sizeFactor), originCoordinate),
55
+ }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
56
+ if (fieldPoint) {
57
+ this._res.x = fieldPoint.x;
58
+ this._res.y = fieldPoint.y;
59
+ }
60
+ else {
61
+ this._res.x = 0;
62
+ this._res.y = 0;
63
+ }
64
+ return this._res;
65
+ }
66
+ init() {
67
+ this._setup();
68
+ }
69
+ reset() {
70
+ }
71
+ update() {
72
+ this._calculateField();
73
+ this.noiseW += this.options.increment;
74
+ if (!this.options.draw) {
75
+ return;
76
+ }
77
+ this.container.canvas.render.draw(ctx => {
78
+ this._drawField(ctx);
79
+ });
80
+ }
81
+ _calculateField() {
82
+ const { field, noiseGen, options, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
83
+ for (let x = 0; x < options.columns; x++) {
84
+ const xColumn = field[x];
85
+ if (!xColumn) {
86
+ continue;
87
+ }
88
+ for (let y = 0; y < options.rows; y++) {
89
+ const yColumn = xColumn[y];
90
+ if (!yColumn) {
91
+ continue;
92
+ }
93
+ for (let z = 0; z < options.layers; z++) {
94
+ const cell = yColumn[z];
95
+ if (!cell) {
96
+ continue;
97
+ }
98
+ cell.length = noiseGen.noise4d(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
99
+ cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * engine.doublePI;
100
+ }
101
+ }
102
+ }
103
+ }
104
+ _drawField(ctx) {
105
+ const { field, options } = this;
106
+ for (let x = 0; x < options.columns; x++) {
107
+ const xColumn = field[x];
108
+ if (!xColumn) {
109
+ continue;
110
+ }
111
+ for (let y = 0; y < options.rows; y++) {
112
+ const yColumn = xColumn[y];
113
+ if (!yColumn) {
114
+ continue;
115
+ }
116
+ const cell = yColumn[firstIndex];
117
+ if (!cell) {
118
+ continue;
119
+ }
120
+ const { angle, length } = cell;
121
+ ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, x * this.options.size, y * this.options.size);
122
+ ctx.rotate(angle);
123
+ ctx.strokeStyle = "white";
124
+ ctx.beginPath();
125
+ ctx.moveTo(originCoordinate, originCoordinate);
126
+ ctx.lineTo(originCoordinate, this.options.size * length);
127
+ ctx.stroke();
128
+ ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, transformDefaultValues.e, transformDefaultValues.f);
129
+ }
130
+ }
131
+ }
132
+ _initField() {
133
+ const { columns, rows, layers } = this.options;
134
+ this.field = new Array(columns);
135
+ for (let x = 0; x < columns; x++) {
136
+ const newX = new Array(rows);
137
+ for (let y = 0; y < rows; y++) {
138
+ const newY = new Array(layers);
139
+ for (let z = 0; z < layers; z++) {
140
+ newY[z] = engine.Vector.origin;
141
+ }
142
+ newX[y] = newY;
143
+ }
144
+ this.field[x] = newX;
145
+ }
146
+ }
147
+ _resetField() {
148
+ const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
149
+ options.width = container.canvas.size.width;
150
+ options.height = container.canvas.size.height;
151
+ options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
152
+ options.increment =
153
+ sourceOptions["increment"] > empty
154
+ ? sourceOptions["increment"]
155
+ : defaultOptions.increment;
156
+ options.draw = !!sourceOptions["draw"];
157
+ const offset = sourceOptions["offset"];
158
+ options.offset.x = offset?.x ?? defaultOptions.offset.x;
159
+ options.offset.y = offset?.y ?? defaultOptions.offset.y;
160
+ options.offset.z = offset?.z ?? defaultOptions.offset.z;
161
+ const factor = sourceOptions["factor"];
162
+ options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
163
+ options.factor.length = factor?.length ?? defaultOptions.factor.length;
164
+ options.seed = sourceOptions["seed"];
165
+ this.noiseGen.seed(options.seed ?? engine.getRandom());
166
+ options.columns = Math.floor(options.width / options.size) + optionsSizeOffset;
167
+ options.rows = Math.floor(options.height / options.size) + optionsSizeOffset;
168
+ options.layers = Math.floor(container.zLayers / options.size) + optionsSizeOffset;
169
+ this._initField();
170
+ }
171
+ _setup() {
172
+ this.noiseW = 0;
173
+ this._resetField();
174
+ addEventListener("resize", () => {
175
+ this._resetField();
176
+ });
177
+ }
178
+ }
36
179
 
37
- module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
180
+ const globalObject = globalThis;
181
+ globalObject.__tsParticlesInternals = globalObject.__tsParticlesInternals ?? {};
38
182
 
39
- /***/ },
183
+ exports.NoiseFieldGenerator = NoiseFieldGenerator;
40
184
 
41
- /***/ "./dist/browser/NoiseFieldGenerator.js"
42
- /*!*********************************************!*\
43
- !*** ./dist/browser/NoiseFieldGenerator.js ***!
44
- \*********************************************/
45
- (__unused_webpack___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 */ NoiseFieldGenerator: () => (/* binding */ NoiseFieldGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n\nconst originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {\n a: 1,\n b: 0,\n c: 0,\n d: 1,\n e: 0,\n f: 0\n}, defaultOptions = {\n draw: false,\n size: 20,\n increment: 0.004,\n columns: 0,\n rows: 0,\n layers: 0,\n width: 0,\n height: 0,\n factor: {\n angle: 0.02,\n length: 0.01\n },\n offset: {\n x: 40000,\n y: 40000,\n z: 40000\n }\n};\nclass NoiseFieldGenerator {\n container;\n field;\n noiseGen;\n noiseW;\n options;\n _res;\n constructor(container, noiseGen){\n this.container = container;\n this.noiseGen = noiseGen;\n this.field = [];\n this.noiseW = 0;\n this._res = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle) {\n const pos = particle.getPosition(), { size } = this.options, sizeFactor = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.identity / size, point = {\n x: Math.max(Math.floor(pos.x * sizeFactor), originCoordinate),\n y: Math.max(Math.floor(pos.y * sizeFactor), originCoordinate),\n z: Math.max(Math.floor(pos.z * sizeFactor), originCoordinate)\n }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];\n if (fieldPoint) {\n this._res.x = fieldPoint.x;\n this._res.y = fieldPoint.y;\n } else {\n this._res.x = 0;\n this._res.y = 0;\n }\n return this._res;\n }\n init() {\n this._setup();\n }\n reset() {}\n update() {\n this._calculateField();\n this.noiseW += this.options.increment;\n if (!this.options.draw) {\n return;\n }\n this.container.canvas.render.draw((ctx)=>{\n this._drawField(ctx);\n });\n }\n _calculateField() {\n const { field, noiseGen, options, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;\n for(let x = 0; x < options.columns; x++){\n const xColumn = field[x];\n if (!xColumn) {\n continue;\n }\n for(let y = 0; y < options.rows; y++){\n const yColumn = xColumn[y];\n if (!yColumn) {\n continue;\n }\n for(let z = 0; z < options.layers; z++){\n const cell = yColumn[z];\n if (!cell) {\n continue;\n }\n cell.length = noiseGen.noise4d(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);\n cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.doublePI;\n }\n }\n }\n }\n _drawField(ctx) {\n const { field, options } = this;\n for(let x = 0; x < options.columns; x++){\n const xColumn = field[x];\n if (!xColumn) {\n continue;\n }\n for(let y = 0; y < options.rows; y++){\n const yColumn = xColumn[y];\n if (!yColumn) {\n continue;\n }\n const cell = yColumn[firstIndex];\n if (!cell) {\n continue;\n }\n const { angle, length } = cell;\n ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, x * this.options.size, y * this.options.size);\n ctx.rotate(angle);\n ctx.strokeStyle = \"white\";\n ctx.beginPath();\n ctx.moveTo(originCoordinate, originCoordinate);\n ctx.lineTo(originCoordinate, this.options.size * length);\n ctx.stroke();\n ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, transformDefaultValues.e, transformDefaultValues.f);\n }\n }\n }\n _initField() {\n const { columns, rows, layers } = this.options;\n this.field = new Array(columns);\n for(let x = 0; x < columns; x++){\n const newX = new Array(rows);\n for(let y = 0; y < rows; y++){\n const newY = new Array(layers);\n for(let z = 0; z < layers; z++){\n newY[z] = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n }\n newX[y] = newY;\n }\n this.field[x] = newX;\n }\n }\n _resetField() {\n const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;\n options.width = container.canvas.size.width;\n options.height = container.canvas.size.height;\n options.size = sourceOptions[\"size\"] > empty ? sourceOptions[\"size\"] : defaultOptions.size;\n options.increment = sourceOptions[\"increment\"] > empty ? sourceOptions[\"increment\"] : defaultOptions.increment;\n options.draw = !!sourceOptions[\"draw\"];\n const offset = sourceOptions[\"offset\"];\n options.offset.x = offset?.x ?? defaultOptions.offset.x;\n options.offset.y = offset?.y ?? defaultOptions.offset.y;\n options.offset.z = offset?.z ?? defaultOptions.offset.z;\n const factor = sourceOptions[\"factor\"];\n options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;\n options.factor.length = factor?.length ?? defaultOptions.factor.length;\n options.seed = sourceOptions[\"seed\"];\n this.noiseGen.seed(options.seed ?? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)());\n options.columns = Math.floor(options.width / options.size) + optionsSizeOffset;\n options.rows = Math.floor(options.height / options.size) + optionsSizeOffset;\n options.layers = Math.floor(container.zLayers / options.size) + optionsSizeOffset;\n this._initField();\n }\n _setup() {\n this.noiseW = 0;\n this._resetField();\n addEventListener(\"resize\", ()=>{\n this._resetField();\n });\n }\n}\n\n\n//# sourceURL=webpack://@tsparticles/noise-field/./dist/browser/NoiseFieldGenerator.js?\n}");
48
-
49
- /***/ },
50
-
51
- /***/ "./dist/browser/index.js"
52
- /*!*******************************!*\
53
- !*** ./dist/browser/index.js ***!
54
- \*******************************/
55
- (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
56
-
57
- eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ NoiseFieldGenerator: () => (/* reexport safe */ _NoiseFieldGenerator_js__WEBPACK_IMPORTED_MODULE_0__.NoiseFieldGenerator)\n/* harmony export */ });\n/* harmony import */ var _NoiseFieldGenerator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./NoiseFieldGenerator.js */ \"./dist/browser/NoiseFieldGenerator.js\");\n\n\n\n//# sourceURL=webpack://@tsparticles/noise-field/./dist/browser/index.js?\n}");
58
-
59
- /***/ }
60
-
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
- /************************************************************************/
94
- /******/ /* webpack/runtime/define property getters */
95
- /******/ (() => {
96
- /******/ // define getter functions for harmony exports
97
- /******/ __webpack_require__.d = (exports, definition) => {
98
- /******/ for(var key in definition) {
99
- /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
100
- /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
101
- /******/ }
102
- /******/ }
103
- /******/ };
104
- /******/ })();
105
- /******/
106
- /******/ /* webpack/runtime/hasOwnProperty shorthand */
107
- /******/ (() => {
108
- /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
109
- /******/ })();
110
- /******/
111
- /******/ /* webpack/runtime/make namespace object */
112
- /******/ (() => {
113
- /******/ // define __esModule on exports
114
- /******/ __webpack_require__.r = (exports) => {
115
- /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
116
- /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
117
- /******/ }
118
- /******/ Object.defineProperty(exports, '__esModule', { value: true });
119
- /******/ };
120
- /******/ })();
121
- /******/
122
- /************************************************************************/
123
- /******/
124
- /******/ // startup
125
- /******/ // Load entry module and return exports
126
- /******/ // This entry module can't be inlined because the eval devtool is used.
127
- /******/ var __webpack_exports__ = __webpack_require__("./dist/browser/index.js");
128
- /******/
129
- /******/ return __webpack_exports__;
130
- /******/ })()
131
- ;
132
- });
185
+ }));
186
+ delete (globalThis.window || globalThis).tsparticlesInternalExports;
@@ -1 +1 @@
1
- !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var o in i)("object"==typeof exports?exports:e)[o]=i[o]}}(this,e=>(()=>{"use strict";var t={303(t){t.exports=e}},i={};function o(e){var s=i[e];if(void 0!==s)return s.exports;var r=i[e]={exports:{}};return t[e](r,r.exports,o),r.exports}o.d=(e,t)=>{for(var i in t)o.o(t,i)&&!o.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};o.r(s),o.d(s,{NoiseFieldGenerator:()=>l});var r=o(303);let n={draw:!1,size:20,increment:.004,columns:0,rows:0,layers:0,width:0,height:0,factor:{angle:.02,length:.01},offset:{x:4e4,y:4e4,z:4e4}};class l{container;field;noiseGen;noiseW;options;_res;constructor(e,t){this.container=e,this.noiseGen=t,this.field=[],this.noiseW=0,this._res=r.Vector.origin,this.options=(0,r.deepExtend)({},n)}generate(e){let t=e.getPosition(),{size:i}=this.options,o=r.identity/i,s={x:Math.max(Math.floor(t.x*o),0),y:Math.max(Math.floor(t.y*o),0),z:Math.max(Math.floor(t.z*o),0)},{field:n}=this,l=n[s.x]?.[s.y]?.[s.z];return l?(this._res.x=l.x,this._res.y=l.y):(this._res.x=0,this._res.y=0),this._res}init(){this._setup()}reset(){}update(){this._calculateField(),this.noiseW+=this.options.increment,this.options.draw&&this.container.canvas.render.draw(e=>{this._drawField(e)})}_calculateField(){let{field:e,noiseGen:t,options:i,noiseW:o}=this,s=i.factor.length,n=i.factor.angle;for(let l=0;l<i.columns;l++){let a=e[l];if(a)for(let e=0;e<i.rows;e++){let f=a[e];if(f)for(let a=0;a<i.layers;a++){let h=f[a];h&&(h.length=t.noise4d(l*s+i.offset.x,e*s+i.offset.y,a*s+i.offset.z,o),h.angle=t.noise4d(l*n,e*n,a*n,o)*r.doublePI)}}}}_drawField(e){let{field:t,options:i}=this;for(let o=0;o<i.columns;o++){let s=t[o];if(s)for(let t=0;t<i.rows;t++){let i=s[t];if(!i)continue;let r=i[0];if(!r)continue;let{angle:n,length:l}=r;e.setTransform(1,0,0,1,o*this.options.size,t*this.options.size),e.rotate(n),e.strokeStyle="white",e.beginPath(),e.moveTo(0,0),e.lineTo(0,this.options.size*l),e.stroke(),e.setTransform(1,0,0,1,0,0)}}}_initField(){let{columns:e,rows:t,layers:i}=this.options;this.field=Array(e);for(let o=0;o<e;o++){let e=Array(t);for(let o=0;o<t;o++){let t=Array(i);for(let e=0;e<i;e++)t[e]=r.Vector.origin;e[o]=t}this.field[o]=e}}_resetField(){let e=this.container,t=e.actualOptions.particles.move.path.options,{options:i}=this;i.width=e.canvas.size.width,i.height=e.canvas.size.height,i.size=t.size>0?t.size:n.size,i.increment=t.increment>0?t.increment:n.increment,i.draw=!!t.draw;let o=t.offset;i.offset.x=o?.x??n.offset.x,i.offset.y=o?.y??n.offset.y,i.offset.z=o?.z??n.offset.z;let s=t.factor;i.factor.angle=s?.angle??n.factor.angle,i.factor.length=s?.length??n.factor.length,i.seed=t.seed,this.noiseGen.seed(i.seed??(0,r.getRandom)()),i.columns=Math.floor(i.width/i.size)+1,i.rows=Math.floor(i.height/i.size)+1,i.layers=Math.floor(e.zLayers/i.size)+1,this._initField()}_setup(){this.noiseW=0,this._resetField(),addEventListener("resize",()=>{this._resetField()})}}return s})());
1
+ !function(t){t.__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.bundles=t.__tsParticlesInternals.bundles||{},t.__tsParticlesInternals.effects=t.__tsParticlesInternals.effects||{},t.__tsParticlesInternals.engine=t.__tsParticlesInternals.engine||{},t.__tsParticlesInternals.interactions=t.__tsParticlesInternals.interactions||{},t.__tsParticlesInternals.palettes=t.__tsParticlesInternals.palettes||{},t.__tsParticlesInternals.paths=t.__tsParticlesInternals.paths||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins=t.__tsParticlesInternals.plugins||{},t.__tsParticlesInternals.plugins.emittersShapes=t.__tsParticlesInternals.plugins.emittersShapes||{},t.__tsParticlesInternals.presets=t.__tsParticlesInternals.presets||{},t.__tsParticlesInternals.shapes=t.__tsParticlesInternals.shapes||{},t.__tsParticlesInternals.updaters=t.__tsParticlesInternals.updaters||{},t.__tsParticlesInternals.utils=t.__tsParticlesInternals.utils||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas=t.__tsParticlesInternals.canvas||{},t.__tsParticlesInternals.canvas.utils=t.__tsParticlesInternals.canvas.utils||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path=t.__tsParticlesInternals.path||{},t.__tsParticlesInternals.path.utils=t.__tsParticlesInternals.path.utils||{};var s="undefined"!=typeof Proxy?function(t){return new Proxy(t,{get:function(t,s){return s in t||(t[s]={}),t[s]}})}:function(t){return t};t.__tsParticlesInternals.bundles=s(t.__tsParticlesInternals.bundles),t.__tsParticlesInternals.effects=s(t.__tsParticlesInternals.effects),t.__tsParticlesInternals.interactions=s(t.__tsParticlesInternals.interactions),t.__tsParticlesInternals.palettes=s(t.__tsParticlesInternals.palettes),t.__tsParticlesInternals.paths=s(t.__tsParticlesInternals.paths),t.__tsParticlesInternals.plugins=s(t.__tsParticlesInternals.plugins),t.__tsParticlesInternals.plugins.emittersShapes=s(t.__tsParticlesInternals.plugins.emittersShapes),t.__tsParticlesInternals.presets=s(t.__tsParticlesInternals.presets),t.__tsParticlesInternals.shapes=s(t.__tsParticlesInternals.shapes),t.__tsParticlesInternals.updaters=s(t.__tsParticlesInternals.updaters),t.__tsParticlesInternals.utils=s(t.__tsParticlesInternals.utils),t.__tsParticlesInternals.canvas=s(t.__tsParticlesInternals.canvas),t.__tsParticlesInternals.path=s(t.__tsParticlesInternals.path),t.tsparticlesInternalExports=t.tsparticlesInternalExports||{}}("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:this),function(t,s){"object"==typeof exports&&"undefined"!=typeof module?s(exports,require("@tsparticles/engine")):"function"==typeof define&&define.amd?define(["exports","@tsparticles/engine"],s):s(((t="undefined"!=typeof globalThis?globalThis:t||self).__tsParticlesInternals=t.__tsParticlesInternals||{},t.__tsParticlesInternals.noise=t.__tsParticlesInternals.noise||{},t.__tsParticlesInternals.noise.field=t.__tsParticlesInternals.noise.field||{}),t.__tsParticlesInternals.engine)}(this,function(t,s){"use strict";const e=1,n=0,i=0,a=1,r=0,l=0,o={draw:!1,size:20,increment:.004,columns:0,rows:0,layers:0,width:0,height:0,factor:{angle:.02,length:.01},offset:{x:4e4,y:4e4,z:4e4}};const _=globalThis;_.__tsParticlesInternals=_.__tsParticlesInternals??{},t.NoiseFieldGenerator=class{container;field;noiseGen;noiseW;options;_res;constructor(t,e){this.container=t,this.noiseGen=e,this.field=[],this.noiseW=0,this._res=s.Vector.origin,this.options=s.deepExtend({},o)}generate(t){const e=t.getPosition(),{size:n}=this.options,i=s.identity/n,a=Math.max(Math.floor(e.x*i),0),r=Math.max(Math.floor(e.y*i),0),l=Math.max(Math.floor(e.z*i),0),{field:o}=this,_=o[a]?.[r]?.[l];return _?(this._res.x=_.x,this._res.y=_.y):(this._res.x=0,this._res.y=0),this._res}init(){this._setup()}reset(){}update(){this._calculateField(),this.noiseW+=this.options.increment,this.options.draw&&this.container.canvas.render.draw(t=>{this._drawField(t)})}_calculateField(){const{field:t,noiseGen:e,options:n,noiseW:i}=this,a=n.factor.length,r=n.factor.angle;for(let l=0;l<n.columns;l++){const o=t[l];if(o)for(let t=0;t<n.rows;t++){const _=o[t];if(_)for(let o=0;o<n.layers;o++){const c=_[o];c&&(c.length=e.noise4d(l*a+n.offset.x,t*a+n.offset.y,o*a+n.offset.z,i),c.angle=e.noise4d(l*r,t*r,o*r,i)*s.doublePI)}}}}_drawField(t){const{field:s,options:o}=this;for(let _=0;_<o.columns;_++){const c=s[_];if(c)for(let s=0;s<o.rows;s++){const o=c[s];if(!o)continue;const h=o[0];if(!h)continue;const{angle:f,length:p}=h;t.setTransform(e,n,i,a,_*this.options.size,s*this.options.size),t.rotate(f),t.strokeStyle="white",t.beginPath(),t.moveTo(0,0),t.lineTo(0,this.options.size*p),t.stroke(),t.setTransform(e,n,i,a,r,l)}}}_initField(){const{columns:t,rows:e,layers:n}=this.options;this.field=new Array(t);for(let i=0;i<t;i++){const t=new Array(e);for(let i=0;i<e;i++){const e=new Array(n);for(let t=0;t<n;t++)e[t]=s.Vector.origin;t[i]=e}this.field[i]=t}}_resetField(){const t=this.container,e=t.actualOptions.particles.move.path.options,{options:n}=this;n.width=t.canvas.size.width,n.height=t.canvas.size.height,n.size=e.size>0?e.size:o.size,n.increment=e.increment>0?e.increment:o.increment,n.draw=!!e.draw;const i=e.offset;n.offset.x=i?.x??o.offset.x,n.offset.y=i?.y??o.offset.y,n.offset.z=i?.z??o.offset.z;const a=e.factor;n.factor.angle=a?.angle??o.factor.angle,n.factor.length=a?.length??o.factor.length,n.seed=e.seed,this.noiseGen.seed(n.seed??s.getRandom()),n.columns=Math.floor(n.width/n.size)+1,n.rows=Math.floor(n.height/n.size)+1,n.layers=Math.floor(t.zLayers/n.size)+1,this._initField()}_setup(){this.noiseW=0,this._resetField(),addEventListener("resize",()=>{this._resetField()})}}}),delete(globalThis.window||globalThis).tsparticlesInternalExports;
@@ -0,0 +1 @@
1
+ export * from "./index.js";
@@ -0,0 +1,4 @@
1
+ export type { IFactorValues, IOffsetValues } from "./IFactorOffsetValues.js";
2
+ export type { INoiseFieldOptions } from "./INoiseFieldOptions.js";
3
+ export type { INoiseGenerator } from "./INoiseGenerator.js";
4
+ export { NoiseFieldGenerator } from "./NoiseFieldGenerator.js";