@tsparticles/noise-field 4.0.0-alpha.25 → 4.0.0-alpha.27

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,4 +1,4 @@
1
- import { Vector, deepExtend, doublePI, getRandom, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, doublePI, getRandom } from "@tsparticles/engine";
2
2
  const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
3
  a: 1,
4
4
  b: 0,
@@ -31,11 +31,13 @@ export class NoiseFieldGenerator {
31
31
  noiseGen;
32
32
  noiseW;
33
33
  options;
34
+ _res;
34
35
  constructor(container, noiseGen) {
35
36
  this.container = container;
36
37
  this.noiseGen = noiseGen;
37
38
  this.field = [];
38
39
  this.noiseW = 0;
40
+ this._res = Vector.origin;
39
41
  this.options = deepExtend({}, defaultOptions);
40
42
  }
41
43
  generate(particle) {
@@ -44,7 +46,15 @@ export class NoiseFieldGenerator {
44
46
  y: Math.max(Math.floor(pos.y / size), originCoordinate),
45
47
  z: Math.max(Math.floor(pos.z / size), originCoordinate),
46
48
  }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
47
- return fieldPoint ? fieldPoint.copy() : Vector.origin;
49
+ if (fieldPoint) {
50
+ this._res.x = fieldPoint.x;
51
+ this._res.y = fieldPoint.y;
52
+ }
53
+ else {
54
+ this._res.x = 0;
55
+ this._res.y = 0;
56
+ }
57
+ return this._res;
48
58
  }
49
59
  init() {
50
60
  this._setup();
@@ -1,4 +1,4 @@
1
- import { Vector, deepExtend, doublePI, getRandom, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, doublePI, getRandom } from "@tsparticles/engine";
2
2
  const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
3
  a: 1,
4
4
  b: 0,
@@ -31,11 +31,13 @@ export class NoiseFieldGenerator {
31
31
  noiseGen;
32
32
  noiseW;
33
33
  options;
34
+ _res;
34
35
  constructor(container, noiseGen) {
35
36
  this.container = container;
36
37
  this.noiseGen = noiseGen;
37
38
  this.field = [];
38
39
  this.noiseW = 0;
40
+ this._res = Vector.origin;
39
41
  this.options = deepExtend({}, defaultOptions);
40
42
  }
41
43
  generate(particle) {
@@ -44,7 +46,15 @@ export class NoiseFieldGenerator {
44
46
  y: Math.max(Math.floor(pos.y / size), originCoordinate),
45
47
  z: Math.max(Math.floor(pos.z / size), originCoordinate),
46
48
  }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
47
- return fieldPoint ? fieldPoint.copy() : Vector.origin;
49
+ if (fieldPoint) {
50
+ this._res.x = fieldPoint.x;
51
+ this._res.y = fieldPoint.y;
52
+ }
53
+ else {
54
+ this._res.x = 0;
55
+ this._res.y = 0;
56
+ }
57
+ return this._res;
48
58
  }
49
59
  init() {
50
60
  this._setup();
@@ -1,4 +1,4 @@
1
- import { Vector, deepExtend, doublePI, getRandom, } from "@tsparticles/engine";
1
+ import { Vector, deepExtend, doublePI, getRandom } from "@tsparticles/engine";
2
2
  const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
3
3
  a: 1,
4
4
  b: 0,
@@ -31,11 +31,13 @@ export class NoiseFieldGenerator {
31
31
  noiseGen;
32
32
  noiseW;
33
33
  options;
34
+ _res;
34
35
  constructor(container, noiseGen) {
35
36
  this.container = container;
36
37
  this.noiseGen = noiseGen;
37
38
  this.field = [];
38
39
  this.noiseW = 0;
40
+ this._res = Vector.origin;
39
41
  this.options = deepExtend({}, defaultOptions);
40
42
  }
41
43
  generate(particle) {
@@ -44,7 +46,15 @@ export class NoiseFieldGenerator {
44
46
  y: Math.max(Math.floor(pos.y / size), originCoordinate),
45
47
  z: Math.max(Math.floor(pos.z / size), originCoordinate),
46
48
  }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
47
- return fieldPoint ? fieldPoint.copy() : Vector.origin;
49
+ if (fieldPoint) {
50
+ this._res.x = fieldPoint.x;
51
+ this._res.y = fieldPoint.y;
52
+ }
53
+ else {
54
+ this._res.x = 0;
55
+ this._res.y = 0;
56
+ }
57
+ return this._res;
48
58
  }
49
59
  init() {
50
60
  this._setup();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tsparticles/noise-field",
3
- "version": "4.0.0-alpha.25",
3
+ "version": "4.0.0-alpha.27",
4
4
  "description": "tsParticles noise field library",
5
5
  "homepage": "https://particles.js.org",
6
6
  "repository": {
@@ -92,7 +92,8 @@
92
92
  "module": "esm/index.js",
93
93
  "types": "types/index.d.ts",
94
94
  "dependencies": {
95
- "@tsparticles/engine": "4.0.0-alpha.25"
95
+ "@tsparticles/engine": "4.0.0-alpha.27",
96
+ "@tsparticles/plugin-move": "4.0.0-alpha.27"
96
97
  },
97
98
  "exports": {
98
99
  ".": {
package/report.html CHANGED
@@ -3,7 +3,7 @@
3
3
  <head>
4
4
  <meta charset="UTF-8"/>
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1"/>
6
- <title>@tsparticles/noise-field [21 Feb 2026 at 12:49]</title>
6
+ <title>@tsparticles/noise-field [9 Mar 2026 at 17:23]</title>
7
7
  <link rel="shortcut icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAMAAACdt4HsAAABrVBMVEUAAAD///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////+O1foceMD///+J0/qK1Pr7/v8Xdr/9///W8P4UdL7L7P0Scr2r4Pyj3vwad8D5/f/2/f+55f3E6f34+/2H0/ojfMKpzOd0rNgQcb3F3O/j9f7c8v6g3Pz0/P/w+v/q+P7n9v6T1/uQ1vuE0vqLut/y+v+Z2fvt+f+15Pzv9fuc2/vR7v2V2Pvd6/bg9P7I6/285/2y4/yp3/zp8vk8i8kqgMT7/P31+fyv4vxGkcz6/P6/6P3j7vfS5PNnpNUxhcbO7f7F6v3O4vHK3/DA2u631Ouy0eqXweKJud5wqthfoNMMbLvY8f73+v2dxeR8sNtTmdDx9/zX6PSjyeaCtd1YnNGX2PuQveCGt95Nls42h8dLlM3F4vBtAAAAM3RSTlMAAyOx0/sKBvik8opWGBMOAe3l1snDm2E9LSb06eHcu5JpHbarfHZCN9CBb08zzkdNS0kYaptYAAAFV0lEQVRYw92X51/aYBDHHS2O2qqttVbrqNq9m+TJIAYIShBkWwqIiCgoWvfeq7Z2/s29hyQNyUcR7LveGwVyXy6XH8/9rqxglLfUPLxVduUor3h0rfp2TYvpivk37929TkG037hffoX0+peVtZQc1589rigVUdXS/ABSAyEmGIO/1XfvldSK8vs3OqB6u3m0nxmIrvgB0dj7rr7Y9IbuF68hnfFaiHA/sxqm0wciIG43P60qKv9WXWc1RXGh/mFESFABTSBi0sNAKzqet17eCtOb3kZIDwxEEU0oAIJGYxNBDhBND29e0rtXXbcpuPmED9IhEAAQ/AXEaF8EPmnrrKsv0LvWR3fg5sWDNAFZOgAgaKvZDogHNU9MFwnnYROkc56RD5CjAbQX9Ow4g7upCsvYu55aSI/Nj0H1akgKQEUM94dwK65hYRmFU9MIcH/fqJYOZYcnuJSU/waKDgTOEVaVKhwrTRP5XzgSpAITYzom7UvkhFX5VutmxeNnWDjjswTKTyfgluNDGbUpWissXhF3s7mlSml+czWkg3D0l1nNjGNjz3myOQOa1KM/jOS6ebdbAVTCi4gljHSFrviza7tOgRWcS0MOUX9zdNgag5w7rRqA44Lzw0hr1WqES36dFliSJFlh2rXIae3FFcDDgKdxrUIDePr8jGcSClV1u7A9xeN0ModY/pHMxmR1EzRh8TJiwqsHmKW0l4FCEZI+jHio+JdPPE9qwQtTRxku2D8sIeRL2LnxWSllANCQGOIiqVHAz2ye2JR0DcH+HoxDkaADLjgxjKQ+AwCX/g0+DNgdG0ukYCONAe+dbc2IAc6fwt1ARoDSezNHxV2Cmzwv3O6lDMV55edBGwGK9n1+x2F8EDfAGCxug8MhpsMEcTEAWf3rx2vZhe/LAmtIn/6apE6PN0ULKgywD9mmdxbmFl3OvD5AS5fW5zLbv/YHmcsBTjf/afDz3MaZTVCfAP9z6/Bw6ycv8EUBWJIn9zYcoAWWlW9+OzO3vkTy8H+RANLmdrpOuYWdZYEXpo+TlCJrW5EARb7fF+bWdqf3hhyZI1nWJQHgznErZhbjoEsWqi8dQNoE294aldzFurwSABL2XXMf9+H1VQGke9exw5P/AnA5Pv5ngMul7LOvO922iwACu8WkCwLCafvM4CeWPxfA8lNHcWZSoi8EwMAIciKX2Z4SWCMAa3snCZ/G4EA8D6CMLNFsGQhkkz/gQNEBbPCbWsxGUpYVu3z8IyNAknwJkfPMEhLyrdi5RTyUVACkw4GSFRNWJNEW+fgPGwHD8/JxnRuLabN4CGNRkAE23na2+VmEAUmrYymSGjMAYqH84YUIyzgzs3XC7gNgH36Vcc4zKY9o9fgPBXUAiHHwVboBHGLiX6Zcjp1f2wu4tvzZKo0ecPnDtQYDQvJXaBeNzce45Fp28ZQLrEZVuFqgBwOalArKXnW1UzlnSusQKJqKYNuz4tOnI6sZG4zanpemv+7ySU2jbA9h6uhcgpfy6G2PahirDZ6zvq6zDduMVFTKvzw8wgyEdelwY9in3XkEPs3osJuwRQ4qTkfzifndg9Gfc4pdsu82+tTnHZTBa2EAMrqr2t43pguc8tNm7JQVQ2S0ukj2d22dhXYP0/veWtwKrCkNoNimAN5+Xr/oLrxswKbVJjteWrX7eR63o4j9q0GxnaBdWgGA5VStpanIjQmEhV0/nVt5VOFUvix6awJhPcAaTEShgrG+iGyvb5a0Ndb1YGHFPEwoqAinoaykaID1o1pdPNu7XsnCKQ3R+hwWIIhGvORcJUBYXe3Xa3vq/mF/N9V13ugufMkfXn+KHsRD0B8AAAAASUVORK5CYII=" type="image/x-icon" />
8
8
 
9
9
  <script>
@@ -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.25
7
+ * v4.0.0-alpha.27
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
@@ -44,7 +44,7 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
44
44
  \*********************************************/
45
45
  (__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) {
46
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 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}");
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, 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 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.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
48
 
49
49
  /***/ },
50
50
 
@@ -70,12 +70,6 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
70
70
  /******/ if (cachedModule !== undefined) {
71
71
  /******/ return cachedModule.exports;
72
72
  /******/ }
73
- /******/ // Check if module exists (development only)
74
- /******/ if (__webpack_modules__[moduleId] === undefined) {
75
- /******/ var e = new Error("Cannot find module '" + moduleId + "'");
76
- /******/ e.code = 'MODULE_NOT_FOUND';
77
- /******/ throw e;
78
- /******/ }
79
73
  /******/ // Create a new module (and put it into the cache)
80
74
  /******/ var module = __webpack_module_cache__[moduleId] = {
81
75
  /******/ // no module.id needed
@@ -84,6 +78,12 @@ eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpa
84
78
  /******/ };
85
79
  /******/
86
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
87
  /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
88
88
  /******/
89
89
  /******/ // Return the exports of the module
@@ -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 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})());
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={x:Math.max(Math.floor(t.x/i),0),y:Math.max(Math.floor(t.y/i),0),z:Math.max(Math.floor(t.z/i),0)},{field:s}=this,r=s[o.x]?.[o.y]?.[o.z];return r?(this._res.x=r.x,this._res.y=r.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.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,4 +1,5 @@
1
- import { type Container, type IMovePathGenerator, type Particle, Vector } from "@tsparticles/engine";
1
+ import { type Container, type Particle, Vector } from "@tsparticles/engine";
2
+ import { type IMovePathGenerator } from "@tsparticles/plugin-move";
2
3
  import type { INoiseFieldOptions } from "./INoiseFieldOptions.js";
3
4
  import type { INoiseGenerator } from "./INoiseGenerator.js";
4
5
  export declare abstract class NoiseFieldGenerator implements IMovePathGenerator {
@@ -7,6 +8,7 @@ export declare abstract class NoiseFieldGenerator implements IMovePathGenerator
7
8
  readonly noiseGen: INoiseGenerator;
8
9
  noiseW: number;
9
10
  readonly options: INoiseFieldOptions;
11
+ private readonly _res;
10
12
  protected constructor(container: Container, noiseGen: INoiseGenerator);
11
13
  generate(particle: Particle): Vector;
12
14
  init(): void;
@@ -43,11 +43,13 @@
43
43
  noiseGen;
44
44
  noiseW;
45
45
  options;
46
+ _res;
46
47
  constructor(container, noiseGen) {
47
48
  this.container = container;
48
49
  this.noiseGen = noiseGen;
49
50
  this.field = [];
50
51
  this.noiseW = 0;
52
+ this._res = engine_1.Vector.origin;
51
53
  this.options = (0, engine_1.deepExtend)({}, defaultOptions);
52
54
  }
53
55
  generate(particle) {
@@ -56,7 +58,15 @@
56
58
  y: Math.max(Math.floor(pos.y / size), originCoordinate),
57
59
  z: Math.max(Math.floor(pos.z / size), originCoordinate),
58
60
  }, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
59
- return fieldPoint ? fieldPoint.copy() : engine_1.Vector.origin;
61
+ if (fieldPoint) {
62
+ this._res.x = fieldPoint.x;
63
+ this._res.y = fieldPoint.y;
64
+ }
65
+ else {
66
+ this._res.x = 0;
67
+ this._res.y = 0;
68
+ }
69
+ return this._res;
60
70
  }
61
71
  init() {
62
72
  this._setup();