@tsparticles/noise-field 4.0.0-beta.1 → 4.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/browser/NoiseFieldGenerator.js +1 -0
- package/cjs/NoiseFieldGenerator.js +1 -0
- package/esm/NoiseFieldGenerator.js +1 -0
- package/package.json +3 -4
- package/report.html +1 -1
- package/tsparticles.noise.field.js +16 -6
- package/tsparticles.noise.field.min.js +1 -1
- package/umd/IFactorOffsetValues.js +0 -12
- package/umd/INoiseFieldOptions.js +0 -12
- package/umd/INoiseGenerator.js +0 -12
- package/umd/NoiseFieldGenerator.js +0 -185
- package/umd/index.js +0 -15
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/noise-field",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.2",
|
|
4
4
|
"description": "tsParticles noise field library",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"main": "cjs/index.js",
|
|
92
92
|
"module": "esm/index.js",
|
|
93
93
|
"types": "types/index.d.ts",
|
|
94
|
-
"
|
|
94
|
+
"peerDependencies": {
|
|
95
95
|
"@tsparticles/engine": "4.0.0-beta.1",
|
|
96
96
|
"@tsparticles/plugin-move": "4.0.0-beta.1"
|
|
97
97
|
},
|
|
@@ -101,8 +101,7 @@
|
|
|
101
101
|
"browser": "./browser/index.js",
|
|
102
102
|
"import": "./esm/index.js",
|
|
103
103
|
"require": "./cjs/index.js",
|
|
104
|
-
"
|
|
105
|
-
"default": "./cjs/index.js"
|
|
104
|
+
"default": "./esm/index.js"
|
|
106
105
|
},
|
|
107
106
|
"./package.json": "./package.json"
|
|
108
107
|
},
|
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 [
|
|
6
|
+
<title>@tsparticles/noise-field [2 Apr 2026 at 07:39]</title>
|
|
7
7
|
<link
|
|
8
8
|
rel="shortcut icon"
|
|
9
9
|
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="
|
|
@@ -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-beta.
|
|
7
|
+
* v4.0.0-beta.2
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -16,14 +16,14 @@
|
|
|
16
16
|
*/
|
|
17
17
|
(function webpackUniversalModuleDefinition(root, factory) {
|
|
18
18
|
if(typeof exports === 'object' && typeof module === 'object')
|
|
19
|
-
module.exports = factory(require("@tsparticles/engine"));
|
|
19
|
+
module.exports = factory(require("@tsparticles/engine"), require("@tsparticles/plugin-move"));
|
|
20
20
|
else if(typeof define === 'function' && define.amd)
|
|
21
|
-
define(["@tsparticles/engine"], factory);
|
|
21
|
+
define(["@tsparticles/engine", "@tsparticles/plugin-move"], factory);
|
|
22
22
|
else {
|
|
23
|
-
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine")) : factory(root["window"]);
|
|
23
|
+
var a = typeof exports === 'object' ? factory(require("@tsparticles/engine"), require("@tsparticles/plugin-move")) : factory(root["window"], root["window"]);
|
|
24
24
|
for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
|
|
25
25
|
}
|
|
26
|
-
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__) => {
|
|
26
|
+
})(this, (__WEBPACK_EXTERNAL_MODULE__tsparticles_engine__, __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_move__) => {
|
|
27
27
|
return /******/ (() => { // webpackBootstrap
|
|
28
28
|
/******/ "use strict";
|
|
29
29
|
/******/ var __webpack_modules__ = ({
|
|
@@ -38,13 +38,23 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
38
38
|
|
|
39
39
|
/***/ },
|
|
40
40
|
|
|
41
|
+
/***/ "@tsparticles/plugin-move"
|
|
42
|
+
/*!************************************************************************************************************************************************!*\
|
|
43
|
+
!*** external {"commonjs":"@tsparticles/plugin-move","commonjs2":"@tsparticles/plugin-move","amd":"@tsparticles/plugin-move","root":"window"} ***!
|
|
44
|
+
\************************************************************************************************************************************************/
|
|
45
|
+
(module) {
|
|
46
|
+
|
|
47
|
+
module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_plugin_move__;
|
|
48
|
+
|
|
49
|
+
/***/ },
|
|
50
|
+
|
|
41
51
|
/***/ "./dist/browser/NoiseFieldGenerator.js"
|
|
42
52
|
/*!*********************************************!*\
|
|
43
53
|
!*** ./dist/browser/NoiseFieldGenerator.js ***!
|
|
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: () => (/* 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}");
|
|
57
|
+
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/* harmony import */ var _tsparticles_plugin_move__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/plugin-move */ \"@tsparticles/plugin-move\");\n\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
58
|
|
|
49
59
|
/***/ },
|
|
50
60
|
|
|
@@ -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
|
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/plugin-move"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/plugin-move"],t);else{var i="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/plugin-move")):t(e.window,e.window);for(var s in i)("object"==typeof exports?exports:e)[s]=i[s]}}(this,(e,t)=>(()=>{"use strict";var i={303(t){t.exports=e},400(e){e.exports=t}},s={};function o(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return i[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 r={};o.r(r),o.d(r,{NoiseFieldGenerator:()=>a});var n=o(303);o(400);let l={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 a{container;field;noiseGen;noiseW;options;_res;constructor(e,t){this.container=e,this.noiseGen=t,this.field=[],this.noiseW=0,this._res=n.Vector.origin,this.options=(0,n.deepExtend)({},l)}generate(e){let t=e.getPosition(),{size:i}=this.options,s=n.identity/i,o={x:Math.max(Math.floor(t.x*s),0),y:Math.max(Math.floor(t.y*s),0),z:Math.max(Math.floor(t.z*s),0)},{field:r}=this,l=r[o.x]?.[o.y]?.[o.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:s}=this,o=i.factor.length,r=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*o+i.offset.x,e*o+i.offset.y,a*o+i.offset.z,s),h.angle=t.noise4d(l*r,e*r,a*r,s)*n.doublePI)}}}}_drawField(e){let{field:t,options:i}=this;for(let s=0;s<i.columns;s++){let o=t[s];if(o)for(let t=0;t<i.rows;t++){let i=o[t];if(!i)continue;let r=i[0];if(!r)continue;let{angle:n,length:l}=r;e.setTransform(1,0,0,1,s*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 s=0;s<e;s++){let e=Array(t);for(let s=0;s<t;s++){let t=Array(i);for(let e=0;e<i;e++)t[e]=n.Vector.origin;e[s]=t}this.field[s]=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:l.size,i.increment=t.increment>0?t.increment:l.increment,i.draw=!!t.draw;let s=t.offset;i.offset.x=s?.x??l.offset.x,i.offset.y=s?.y??l.offset.y,i.offset.z=s?.z??l.offset.z;let o=t.factor;i.factor.angle=o?.angle??l.factor.angle,i.factor.length=o?.length??l.factor.length,i.seed=t.seed,this.noiseGen.seed(i.seed??(0,n.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 r})());
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|
package/umd/INoiseGenerator.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
});
|
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "@tsparticles/engine"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.NoiseFieldGenerator = void 0;
|
|
13
|
-
const engine_1 = require("@tsparticles/engine");
|
|
14
|
-
const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, transformDefaultValues = {
|
|
15
|
-
a: 1,
|
|
16
|
-
b: 0,
|
|
17
|
-
c: 0,
|
|
18
|
-
d: 1,
|
|
19
|
-
e: 0,
|
|
20
|
-
f: 0,
|
|
21
|
-
}, defaultOptions = {
|
|
22
|
-
draw: false,
|
|
23
|
-
size: 20,
|
|
24
|
-
increment: 0.004,
|
|
25
|
-
columns: 0,
|
|
26
|
-
rows: 0,
|
|
27
|
-
layers: 0,
|
|
28
|
-
width: 0,
|
|
29
|
-
height: 0,
|
|
30
|
-
factor: {
|
|
31
|
-
angle: 0.02,
|
|
32
|
-
length: 0.01,
|
|
33
|
-
},
|
|
34
|
-
offset: {
|
|
35
|
-
x: 40000,
|
|
36
|
-
y: 40000,
|
|
37
|
-
z: 40000,
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
class NoiseFieldGenerator {
|
|
41
|
-
container;
|
|
42
|
-
field;
|
|
43
|
-
noiseGen;
|
|
44
|
-
noiseW;
|
|
45
|
-
options;
|
|
46
|
-
_res;
|
|
47
|
-
constructor(container, noiseGen) {
|
|
48
|
-
this.container = container;
|
|
49
|
-
this.noiseGen = noiseGen;
|
|
50
|
-
this.field = [];
|
|
51
|
-
this.noiseW = 0;
|
|
52
|
-
this._res = engine_1.Vector.origin;
|
|
53
|
-
this.options = (0, engine_1.deepExtend)({}, defaultOptions);
|
|
54
|
-
}
|
|
55
|
-
generate(particle) {
|
|
56
|
-
const pos = particle.getPosition(), { size } = this.options, sizeFactor = engine_1.identity / size, point = {
|
|
57
|
-
x: Math.max(Math.floor(pos.x * sizeFactor), originCoordinate),
|
|
58
|
-
y: Math.max(Math.floor(pos.y * sizeFactor), originCoordinate),
|
|
59
|
-
z: Math.max(Math.floor(pos.z * sizeFactor), originCoordinate),
|
|
60
|
-
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
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;
|
|
70
|
-
}
|
|
71
|
-
init() {
|
|
72
|
-
this._setup();
|
|
73
|
-
}
|
|
74
|
-
reset() {
|
|
75
|
-
}
|
|
76
|
-
update() {
|
|
77
|
-
this._calculateField();
|
|
78
|
-
this.noiseW += this.options.increment;
|
|
79
|
-
if (!this.options.draw) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
this.container.canvas.render.draw(ctx => {
|
|
83
|
-
this._drawField(ctx);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
_calculateField() {
|
|
87
|
-
const { field, noiseGen, options, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
|
|
88
|
-
for (let x = 0; x < options.columns; x++) {
|
|
89
|
-
const xColumn = field[x];
|
|
90
|
-
if (!xColumn) {
|
|
91
|
-
continue;
|
|
92
|
-
}
|
|
93
|
-
for (let y = 0; y < options.rows; y++) {
|
|
94
|
-
const yColumn = xColumn[y];
|
|
95
|
-
if (!yColumn) {
|
|
96
|
-
continue;
|
|
97
|
-
}
|
|
98
|
-
for (let z = 0; z < options.layers; z++) {
|
|
99
|
-
const cell = yColumn[z];
|
|
100
|
-
if (!cell) {
|
|
101
|
-
continue;
|
|
102
|
-
}
|
|
103
|
-
cell.length = noiseGen.noise4d(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
|
|
104
|
-
cell.angle = noiseGen.noise4d(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * engine_1.doublePI;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
_drawField(ctx) {
|
|
110
|
-
const { field, options } = this;
|
|
111
|
-
for (let x = 0; x < options.columns; x++) {
|
|
112
|
-
const xColumn = field[x];
|
|
113
|
-
if (!xColumn) {
|
|
114
|
-
continue;
|
|
115
|
-
}
|
|
116
|
-
for (let y = 0; y < options.rows; y++) {
|
|
117
|
-
const yColumn = xColumn[y];
|
|
118
|
-
if (!yColumn) {
|
|
119
|
-
continue;
|
|
120
|
-
}
|
|
121
|
-
const cell = yColumn[firstIndex];
|
|
122
|
-
if (!cell) {
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
const { angle, length } = cell;
|
|
126
|
-
ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, x * this.options.size, y * this.options.size);
|
|
127
|
-
ctx.rotate(angle);
|
|
128
|
-
ctx.strokeStyle = "white";
|
|
129
|
-
ctx.beginPath();
|
|
130
|
-
ctx.moveTo(originCoordinate, originCoordinate);
|
|
131
|
-
ctx.lineTo(originCoordinate, this.options.size * length);
|
|
132
|
-
ctx.stroke();
|
|
133
|
-
ctx.setTransform(transformDefaultValues.a, transformDefaultValues.b, transformDefaultValues.c, transformDefaultValues.d, transformDefaultValues.e, transformDefaultValues.f);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
_initField() {
|
|
138
|
-
const { columns, rows, layers } = this.options;
|
|
139
|
-
this.field = new Array(columns);
|
|
140
|
-
for (let x = 0; x < columns; x++) {
|
|
141
|
-
const newX = new Array(rows);
|
|
142
|
-
for (let y = 0; y < rows; y++) {
|
|
143
|
-
const newY = new Array(layers);
|
|
144
|
-
for (let z = 0; z < layers; z++) {
|
|
145
|
-
newY[z] = engine_1.Vector.origin;
|
|
146
|
-
}
|
|
147
|
-
newX[y] = newY;
|
|
148
|
-
}
|
|
149
|
-
this.field[x] = newX;
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
_resetField() {
|
|
153
|
-
const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
154
|
-
options.width = container.canvas.size.width;
|
|
155
|
-
options.height = container.canvas.size.height;
|
|
156
|
-
options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
157
|
-
options.increment =
|
|
158
|
-
sourceOptions["increment"] > empty
|
|
159
|
-
? sourceOptions["increment"]
|
|
160
|
-
: defaultOptions.increment;
|
|
161
|
-
options.draw = !!sourceOptions["draw"];
|
|
162
|
-
const offset = sourceOptions["offset"];
|
|
163
|
-
options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
164
|
-
options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
165
|
-
options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
166
|
-
const factor = sourceOptions["factor"];
|
|
167
|
-
options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
|
|
168
|
-
options.factor.length = factor?.length ?? defaultOptions.factor.length;
|
|
169
|
-
options.seed = sourceOptions["seed"];
|
|
170
|
-
this.noiseGen.seed(options.seed ?? (0, engine_1.getRandom)());
|
|
171
|
-
options.columns = Math.floor(options.width / options.size) + optionsSizeOffset;
|
|
172
|
-
options.rows = Math.floor(options.height / options.size) + optionsSizeOffset;
|
|
173
|
-
options.layers = Math.floor(container.zLayers / options.size) + optionsSizeOffset;
|
|
174
|
-
this._initField();
|
|
175
|
-
}
|
|
176
|
-
_setup() {
|
|
177
|
-
this.noiseW = 0;
|
|
178
|
-
this._resetField();
|
|
179
|
-
addEventListener("resize", () => {
|
|
180
|
-
this._resetField();
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
exports.NoiseFieldGenerator = NoiseFieldGenerator;
|
|
185
|
-
});
|
package/umd/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
(function (factory) {
|
|
2
|
-
if (typeof module === "object" && typeof module.exports === "object") {
|
|
3
|
-
var v = factory(require, exports);
|
|
4
|
-
if (v !== undefined) module.exports = v;
|
|
5
|
-
}
|
|
6
|
-
else if (typeof define === "function" && define.amd) {
|
|
7
|
-
define(["require", "exports", "./NoiseFieldGenerator.js"], factory);
|
|
8
|
-
}
|
|
9
|
-
})(function (require, exports) {
|
|
10
|
-
"use strict";
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.NoiseFieldGenerator = void 0;
|
|
13
|
-
var NoiseFieldGenerator_js_1 = require("./NoiseFieldGenerator.js");
|
|
14
|
-
Object.defineProperty(exports, "NoiseFieldGenerator", { enumerable: true, get: function () { return NoiseFieldGenerator_js_1.NoiseFieldGenerator; } });
|
|
15
|
-
});
|