@tsparticles/noise-field 4.0.0-alpha.2 → 4.0.0-alpha.20

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,7 @@
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
- * v4.0.0-alpha.2
7
+ * v4.0.0-alpha.20
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -28,13 +28,23 @@ return /******/ (() => { // webpackBootstrap
28
28
  /******/ "use strict";
29
29
  /******/ var __webpack_modules__ = ({
30
30
 
31
+ /***/ "@tsparticles/engine"
32
+ /*!*********************************************************************************************************************************!*\
33
+ !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
34
+ \*********************************************************************************************************************************/
35
+ (module) {
36
+
37
+ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
38
+
39
+ /***/ },
40
+
31
41
  /***/ "./dist/browser/NoiseFieldGenerator.js"
32
42
  /*!*********************************************!*\
33
43
  !*** ./dist/browser/NoiseFieldGenerator.js ***!
34
44
  \*********************************************/
35
45
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
36
46
 
37
- 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,\n firstIndex = 0,\n empty = 0,\n optionsSizeOffset = 1,\n transformDefaultValues = {\n a: 1,\n b: 0,\n c: 0,\n d: 1,\n e: 0,\n f: 0\n },\n double = 2,\n doublePI = Math.PI * double,\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 constructor(noiseGen) {\n this.noiseGen = noiseGen;\n this.field = [];\n this.noiseW = 0;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle) {\n const pos = particle.getPosition(),\n {\n size\n } = this.options,\n point = {\n x: Math.max(Math.floor(pos.x / size), originCoordinate),\n y: Math.max(Math.floor(pos.y / size), originCoordinate),\n z: Math.max(Math.floor(pos.z / size), originCoordinate)\n },\n {\n field\n } = this,\n fieldPoint = field[point.x]?.[point.y]?.[point.z];\n return fieldPoint ? fieldPoint.copy() : _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n }\n init(container) {\n this.container = container;\n this._setup();\n }\n reset() {}\n update() {\n if (!this.container) {\n return;\n }\n this._calculateField();\n this.noiseW += this.options.increment;\n if (!this.options.draw) {\n return;\n }\n this.container.canvas.draw(ctx => {\n this._drawField(ctx);\n });\n }\n _calculateField() {\n const {\n field,\n noiseGen,\n options,\n noiseW\n } = this,\n lengthFactor = options.factor.length,\n 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) * doublePI;\n }\n }\n }\n }\n _drawField(ctx) {\n const {\n field,\n options\n } = 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 {\n angle,\n length\n } = 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 {\n columns,\n rows,\n layers\n } = 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;\n if (!container) {\n return;\n }\n const sourceOptions = container.actualOptions.particles.move.path.options,\n {\n options\n } = 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//# sourceURL=webpack://@tsparticles/noise-field/./dist/browser/NoiseFieldGenerator.js?\n}");
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 constructor(container, noiseGen){\n this.container = container;\n this.noiseGen = noiseGen;\n this.field = [];\n this.noiseW = 0;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle) {\n const pos = particle.getPosition(), { size } = this.options, point = {\n x: Math.max(Math.floor(pos.x / size), originCoordinate),\n y: Math.max(Math.floor(pos.y / size), originCoordinate),\n z: Math.max(Math.floor(pos.z / size), originCoordinate)\n }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];\n return fieldPoint ? fieldPoint.copy() : _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\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.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}");
38
48
 
39
49
  /***/ },
40
50
 
@@ -44,17 +54,7 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
44
54
  \*******************************/
45
55
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
46
56
 
47
- 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//# sourceURL=webpack://@tsparticles/noise-field/./dist/browser/index.js?\n}");
48
-
49
- /***/ },
50
-
51
- /***/ "@tsparticles/engine"
52
- /*!*********************************************************************************************************************************!*\
53
- !*** external {"commonjs":"@tsparticles/engine","commonjs2":"@tsparticles/engine","amd":"@tsparticles/engine","root":"window"} ***!
54
- \*********************************************************************************************************************************/
55
- (module) {
56
-
57
- module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
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
58
 
59
59
  /***/ }
60
60
 
@@ -1,2 +1 @@
1
- /*! For license information please see tsparticles.noise.field.min.js.LICENSE.txt */
2
- !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 o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var s in o)("object"==typeof exports?exports:e)[s]=o[s]}}(this,(e=>(()=>{var t={303(t){t.exports=e}},o={};function s(e){var i=o[e];if(void 0!==i)return i.exports;var n=o[e]={exports:{}};return t[e](n,n.exports,s),n.exports}s.d=(e,t)=>{for(var o in t)s.o(t,o)&&!s.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),s.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};s.r(i),s.d(i,{NoiseFieldGenerator:()=>g});var n=s(303);const r=1,a=0,f=0,l=1,c=0,h=0,d=2*Math.PI,p={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 g{constructor(e){this.noiseGen=e,this.field=[],this.noiseW=0,this.options=(0,n.deepExtend)({},p)}generate(e){const t=e.getPosition(),{size:o}=this.options,s=Math.max(Math.floor(t.x/o),0),i=Math.max(Math.floor(t.y/o),0),r=Math.max(Math.floor(t.z/o),0),{field:a}=this,f=a[s]?.[i]?.[r];return f?f.copy():n.Vector.origin}init(e){this.container=e,this._setup()}reset(){}update(){this.container&&(this._calculateField(),this.noiseW+=this.options.increment,this.options.draw&&this.container.canvas.draw((e=>{this._drawField(e)})))}_calculateField(){const{field:e,noiseGen:t,options:o,noiseW:s}=this,i=o.factor.length,n=o.factor.angle;for(let r=0;r<o.columns;r++){const a=e[r];if(a)for(let e=0;e<o.rows;e++){const f=a[e];if(f)for(let a=0;a<o.layers;a++){const l=f[a];l&&(l.length=t.noise4d(r*i+o.offset.x,e*i+o.offset.y,a*i+o.offset.z,s),l.angle=t.noise4d(r*n,e*n,a*n,s)*d)}}}}_drawField(e){const{field:t,options:o}=this;for(let s=0;s<o.columns;s++){const i=t[s];if(i)for(let t=0;t<o.rows;t++){const o=i[t];if(!o)continue;const n=o[0];if(!n)continue;const{angle:d,length:p}=n;e.setTransform(r,a,f,l,s*this.options.size,t*this.options.size),e.rotate(d),e.strokeStyle="white",e.beginPath(),e.moveTo(0,0),e.lineTo(0,this.options.size*p),e.stroke(),e.setTransform(r,a,f,l,c,h)}}}_initField(){const{columns:e,rows:t,layers:o}=this.options;this.field=new Array(e);for(let s=0;s<e;s++){const e=new Array(t);for(let s=0;s<t;s++){const t=new Array(o);for(let e=0;e<o;e++)t[e]=n.Vector.origin;e[s]=t}this.field[s]=e}}_resetField(){const e=this.container;if(!e)return;const t=e.actualOptions.particles.move.path.options,{options:o}=this;o.width=e.canvas.size.width,o.height=e.canvas.size.height,o.size=t.size>0?t.size:p.size,o.increment=t.increment>0?t.increment:p.increment,o.draw=!!t.draw;const s=t.offset;o.offset.x=s?.x??p.offset.x,o.offset.y=s?.y??p.offset.y,o.offset.z=s?.z??p.offset.z;const i=t.factor;o.factor.angle=i?.angle??p.factor.angle,o.factor.length=i?.length??p.factor.length,o.seed=t.seed,this.noiseGen.seed(o.seed??(0,n.getRandom)()),o.columns=Math.floor(o.width/o.size)+1,o.rows=Math.floor(o.height/o.size)+1,o.layers=Math.floor(e.zLayers/o.size)+1,this._initField()}_setup(){this.noiseW=0,this._resetField(),addEventListener("resize",(()=>{this._resetField()}))}}return i})()));
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 o="object"==typeof exports?t(require("@tsparticles/engine")):t(e.window);for(var i in o)("object"==typeof exports?exports:e)[i]=o[i]}}(this,e=>(()=>{"use strict";var t={303(t){t.exports=e}},o={};function i(e){var s=o[e];if(void 0!==s)return s.exports;var r=o[e]={exports:{}};return t[e](r,r.exports,i),r.exports}i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var s={};i.r(s),i.d(s,{NoiseFieldGenerator:()=>l});var r=i(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;constructor(e,t){this.container=e,this.noiseGen=t,this.field=[],this.noiseW=0,this.options=(0,r.deepExtend)({},n)}generate(e){let t=e.getPosition(),{size:o}=this.options,i={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:s}=this,n=s[i.x]?.[i.y]?.[i.z];return n?n.copy():r.Vector.origin}init(){this._setup()}reset(){}update(){this._calculateField(),this.noiseW+=this.options.increment,this.options.draw&&this.container.canvas.draw(e=>{this._drawField(e)})}_calculateField(){let{field:e,noiseGen:t,options:o,noiseW:i}=this,s=o.factor.length,n=o.factor.angle;for(let l=0;l<o.columns;l++){let a=e[l];if(a)for(let e=0;e<o.rows;e++){let f=a[e];if(f)for(let a=0;a<o.layers;a++){let h=f[a];h&&(h.length=t.noise4d(l*s+o.offset.x,e*s+o.offset.y,a*s+o.offset.z,i),h.angle=t.noise4d(l*n,e*n,a*n,i)*r.doublePI)}}}}_drawField(e){let{field:t,options:o}=this;for(let i=0;i<o.columns;i++){let s=t[i];if(s)for(let t=0;t<o.rows;t++){let o=s[t];if(!o)continue;let r=o[0];if(!r)continue;let{angle:n,length:l}=r;e.setTransform(1,0,0,1,i*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:o}=this.options;this.field=Array(e);for(let i=0;i<e;i++){let e=Array(t);for(let i=0;i<t;i++){let t=Array(o);for(let e=0;e<o;e++)t[e]=r.Vector.origin;e[i]=t}this.field[i]=e}}_resetField(){let e=this.container,t=e.actualOptions.particles.move.path.options,{options:o}=this;o.width=e.canvas.size.width,o.height=e.canvas.size.height,o.size=t.size>0?t.size:n.size,o.increment=t.increment>0?t.increment:n.increment,o.draw=!!t.draw;let i=t.offset;o.offset.x=i?.x??n.offset.x,o.offset.y=i?.y??n.offset.y,o.offset.z=i?.z??n.offset.z;let s=t.factor;o.factor.angle=s?.angle??n.factor.angle,o.factor.length=s?.length??n.factor.length,o.seed=t.seed,this.noiseGen.seed(o.seed??(0,r.getRandom)()),o.columns=Math.floor(o.width/o.size)+1,o.rows=Math.floor(o.height/o.size)+1,o.layers=Math.floor(e.zLayers/o.size)+1,this._initField()}_setup(){this.noiseW=0,this._resetField(),addEventListener("resize",()=>{this._resetField()})}}return s})());
@@ -2,14 +2,14 @@ import { type Container, type IMovePathGenerator, type Particle, Vector } from "
2
2
  import type { INoiseFieldOptions } from "./INoiseFieldOptions.js";
3
3
  import type { INoiseGenerator } from "./INoiseGenerator.js";
4
4
  export declare abstract class NoiseFieldGenerator implements IMovePathGenerator {
5
- container?: Container;
5
+ readonly container: Container;
6
6
  field: Vector[][][];
7
7
  readonly noiseGen: INoiseGenerator;
8
8
  noiseW: number;
9
9
  readonly options: INoiseFieldOptions;
10
- protected constructor(noiseGen: INoiseGenerator);
10
+ protected constructor(container: Container, noiseGen: INoiseGenerator);
11
11
  generate(particle: Particle): Vector;
12
- init(container: Container): void;
12
+ init(): void;
13
13
  reset(): void;
14
14
  update(): void;
15
15
  private _calculateField;
@@ -18,7 +18,7 @@
18
18
  d: 1,
19
19
  e: 0,
20
20
  f: 0,
21
- }, double = 2, doublePI = Math.PI * double, defaultOptions = {
21
+ }, defaultOptions = {
22
22
  draw: false,
23
23
  size: 20,
24
24
  increment: 0.004,
@@ -38,7 +38,13 @@
38
38
  },
39
39
  };
40
40
  class NoiseFieldGenerator {
41
- constructor(noiseGen) {
41
+ container;
42
+ field;
43
+ noiseGen;
44
+ noiseW;
45
+ options;
46
+ constructor(container, noiseGen) {
47
+ this.container = container;
42
48
  this.noiseGen = noiseGen;
43
49
  this.field = [];
44
50
  this.noiseW = 0;
@@ -52,16 +58,12 @@
52
58
  }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
53
59
  return fieldPoint ? fieldPoint.copy() : engine_1.Vector.origin;
54
60
  }
55
- init(container) {
56
- this.container = container;
61
+ init() {
57
62
  this._setup();
58
63
  }
59
64
  reset() {
60
65
  }
61
66
  update() {
62
- if (!this.container) {
63
- return;
64
- }
65
67
  this._calculateField();
66
68
  this.noiseW += this.options.increment;
67
69
  if (!this.options.draw) {
@@ -89,7 +91,7 @@
89
91
  continue;
90
92
  }
91
93
  cell.length = noiseGen.noise4d(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
92
- cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * doublePI;
94
+ cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * engine_1.doublePI;
93
95
  }
94
96
  }
95
97
  }
@@ -138,15 +140,10 @@
138
140
  }
139
141
  }
140
142
  _resetField() {
141
- const container = this.container;
142
- if (!container) {
143
- return;
144
- }
145
- const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
143
+ const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
146
144
  options.width = container.canvas.size.width;
147
145
  options.height = container.canvas.size.height;
148
- options.size =
149
- sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
146
+ options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
150
147
  options.increment =
151
148
  sourceOptions["increment"] > empty
152
149
  ? sourceOptions["increment"]
@@ -1 +0,0 @@
1
- /*! tsParticles Noise Field v4.0.0-alpha.2 by Matteo Bruni */