@tsparticles/noise-field 4.0.0-alpha.8 → 4.0.0-beta.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.
- package/browser/NoiseFieldGenerator.js +21 -13
- package/cjs/NoiseFieldGenerator.js +21 -13
- package/esm/NoiseFieldGenerator.js +21 -13
- package/package.json +3 -2
- package/report.html +1 -1
- package/tsparticles.noise.field.js +19 -19
- package/tsparticles.noise.field.min.js +1 -2
- package/types/NoiseFieldGenerator.d.ts +6 -4
- package/umd/NoiseFieldGenerator.js +20 -12
- package/tsparticles.noise.field.min.js.LICENSE.txt +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector, deepExtend, doublePI, getRandom
|
|
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,
|
|
@@ -26,10 +26,18 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
export class NoiseFieldGenerator {
|
|
29
|
-
|
|
29
|
+
container;
|
|
30
|
+
field;
|
|
31
|
+
noiseGen;
|
|
32
|
+
noiseW;
|
|
33
|
+
options;
|
|
34
|
+
_res;
|
|
35
|
+
constructor(container, noiseGen) {
|
|
36
|
+
this.container = container;
|
|
30
37
|
this.noiseGen = noiseGen;
|
|
31
38
|
this.field = [];
|
|
32
39
|
this.noiseW = 0;
|
|
40
|
+
this._res = Vector.origin;
|
|
33
41
|
this.options = deepExtend({}, defaultOptions);
|
|
34
42
|
}
|
|
35
43
|
generate(particle) {
|
|
@@ -38,18 +46,22 @@ export class NoiseFieldGenerator {
|
|
|
38
46
|
y: Math.max(Math.floor(pos.y / size), originCoordinate),
|
|
39
47
|
z: Math.max(Math.floor(pos.z / size), originCoordinate),
|
|
40
48
|
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
41
|
-
|
|
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;
|
|
42
58
|
}
|
|
43
|
-
init(
|
|
44
|
-
this.container = container;
|
|
59
|
+
init() {
|
|
45
60
|
this._setup();
|
|
46
61
|
}
|
|
47
62
|
reset() {
|
|
48
63
|
}
|
|
49
64
|
update() {
|
|
50
|
-
if (!this.container) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
65
|
this._calculateField();
|
|
54
66
|
this.noiseW += this.options.increment;
|
|
55
67
|
if (!this.options.draw) {
|
|
@@ -126,11 +138,7 @@ export class NoiseFieldGenerator {
|
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
_resetField() {
|
|
129
|
-
const container = this.container;
|
|
130
|
-
if (!container) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
141
|
+
const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
134
142
|
options.width = container.canvas.size.width;
|
|
135
143
|
options.height = container.canvas.size.height;
|
|
136
144
|
options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector, deepExtend, doublePI, getRandom
|
|
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,
|
|
@@ -26,10 +26,18 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
export class NoiseFieldGenerator {
|
|
29
|
-
|
|
29
|
+
container;
|
|
30
|
+
field;
|
|
31
|
+
noiseGen;
|
|
32
|
+
noiseW;
|
|
33
|
+
options;
|
|
34
|
+
_res;
|
|
35
|
+
constructor(container, noiseGen) {
|
|
36
|
+
this.container = container;
|
|
30
37
|
this.noiseGen = noiseGen;
|
|
31
38
|
this.field = [];
|
|
32
39
|
this.noiseW = 0;
|
|
40
|
+
this._res = Vector.origin;
|
|
33
41
|
this.options = deepExtend({}, defaultOptions);
|
|
34
42
|
}
|
|
35
43
|
generate(particle) {
|
|
@@ -38,18 +46,22 @@ export class NoiseFieldGenerator {
|
|
|
38
46
|
y: Math.max(Math.floor(pos.y / size), originCoordinate),
|
|
39
47
|
z: Math.max(Math.floor(pos.z / size), originCoordinate),
|
|
40
48
|
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
41
|
-
|
|
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;
|
|
42
58
|
}
|
|
43
|
-
init(
|
|
44
|
-
this.container = container;
|
|
59
|
+
init() {
|
|
45
60
|
this._setup();
|
|
46
61
|
}
|
|
47
62
|
reset() {
|
|
48
63
|
}
|
|
49
64
|
update() {
|
|
50
|
-
if (!this.container) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
65
|
this._calculateField();
|
|
54
66
|
this.noiseW += this.options.increment;
|
|
55
67
|
if (!this.options.draw) {
|
|
@@ -126,11 +138,7 @@ export class NoiseFieldGenerator {
|
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
_resetField() {
|
|
129
|
-
const container = this.container;
|
|
130
|
-
if (!container) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
141
|
+
const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
134
142
|
options.width = container.canvas.size.width;
|
|
135
143
|
options.height = container.canvas.size.height;
|
|
136
144
|
options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector, deepExtend, doublePI, getRandom
|
|
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,
|
|
@@ -26,10 +26,18 @@ const originCoordinate = 0, firstIndex = 0, empty = 0, optionsSizeOffset = 1, tr
|
|
|
26
26
|
},
|
|
27
27
|
};
|
|
28
28
|
export class NoiseFieldGenerator {
|
|
29
|
-
|
|
29
|
+
container;
|
|
30
|
+
field;
|
|
31
|
+
noiseGen;
|
|
32
|
+
noiseW;
|
|
33
|
+
options;
|
|
34
|
+
_res;
|
|
35
|
+
constructor(container, noiseGen) {
|
|
36
|
+
this.container = container;
|
|
30
37
|
this.noiseGen = noiseGen;
|
|
31
38
|
this.field = [];
|
|
32
39
|
this.noiseW = 0;
|
|
40
|
+
this._res = Vector.origin;
|
|
33
41
|
this.options = deepExtend({}, defaultOptions);
|
|
34
42
|
}
|
|
35
43
|
generate(particle) {
|
|
@@ -38,18 +46,22 @@ export class NoiseFieldGenerator {
|
|
|
38
46
|
y: Math.max(Math.floor(pos.y / size), originCoordinate),
|
|
39
47
|
z: Math.max(Math.floor(pos.z / size), originCoordinate),
|
|
40
48
|
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
41
|
-
|
|
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;
|
|
42
58
|
}
|
|
43
|
-
init(
|
|
44
|
-
this.container = container;
|
|
59
|
+
init() {
|
|
45
60
|
this._setup();
|
|
46
61
|
}
|
|
47
62
|
reset() {
|
|
48
63
|
}
|
|
49
64
|
update() {
|
|
50
|
-
if (!this.container) {
|
|
51
|
-
return;
|
|
52
|
-
}
|
|
53
65
|
this._calculateField();
|
|
54
66
|
this.noiseW += this.options.increment;
|
|
55
67
|
if (!this.options.draw) {
|
|
@@ -126,11 +138,7 @@ export class NoiseFieldGenerator {
|
|
|
126
138
|
}
|
|
127
139
|
}
|
|
128
140
|
_resetField() {
|
|
129
|
-
const container = this.container;
|
|
130
|
-
if (!container) {
|
|
131
|
-
return;
|
|
132
|
-
}
|
|
133
|
-
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
141
|
+
const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
134
142
|
options.width = container.canvas.size.width;
|
|
135
143
|
options.height = container.canvas.size.height;
|
|
136
144
|
options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/noise-field",
|
|
3
|
-
"version": "4.0.0-
|
|
3
|
+
"version": "4.0.0-beta.0",
|
|
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-
|
|
95
|
+
"@tsparticles/engine": "4.0.0-beta.0",
|
|
96
|
+
"@tsparticles/plugin-move": "4.0.0-beta.0"
|
|
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 [
|
|
6
|
+
<title>@tsparticles/noise-field [19 Mar 2026 at 14:00]</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-
|
|
7
|
+
* v4.0.0-beta.0
|
|
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
|
|
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}");
|
|
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
|
|
|
@@ -70,12 +70,6 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
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 @@ module.exports = __WEBPACK_EXTERNAL_MODULE__tsparticles_engine__;
|
|
|
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,2 +1 @@
|
|
|
1
|
-
|
|
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:()=>p});var n=s(303);const r=1,a=0,l=0,f=1,c=0,h=0,d={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 p{constructor(e){this.noiseGen=e,this.field=[],this.noiseW=0,this.options=(0,n.deepExtend)({},d)}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,l=a[s]?.[i]?.[r];return l?l.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,r=o.factor.angle;for(let a=0;a<o.columns;a++){const l=e[a];if(l)for(let e=0;e<o.rows;e++){const f=l[e];if(f)for(let l=0;l<o.layers;l++){const c=f[l];c&&(c.length=t.noise4d(a*i+o.offset.x,e*i+o.offset.y,l*i+o.offset.z,s),c.angle=t.noise4d(a*r,e*r,l*r,s)*n.doublePI)}}}}_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,l,f,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,l,f,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:d.size,o.increment=t.increment>0?t.increment:d.increment,o.draw=!!t.draw;const s=t.offset;o.offset.x=s?.x??d.offset.x,o.offset.y=s?.y??d.offset.y,o.offset.z=s?.z??d.offset.z;const i=t.factor;o.factor.angle=i?.angle??d.factor.angle,o.factor.length=i?.length??d.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 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,15 +1,17 @@
|
|
|
1
|
-
import { type Container, type
|
|
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 {
|
|
5
|
-
container
|
|
6
|
+
readonly container: Container;
|
|
6
7
|
field: Vector[][][];
|
|
7
8
|
readonly noiseGen: INoiseGenerator;
|
|
8
9
|
noiseW: number;
|
|
9
10
|
readonly options: INoiseFieldOptions;
|
|
10
|
-
|
|
11
|
+
private readonly _res;
|
|
12
|
+
protected constructor(container: Container, noiseGen: INoiseGenerator);
|
|
11
13
|
generate(particle: Particle): Vector;
|
|
12
|
-
init(
|
|
14
|
+
init(): void;
|
|
13
15
|
reset(): void;
|
|
14
16
|
update(): void;
|
|
15
17
|
private _calculateField;
|
|
@@ -38,10 +38,18 @@
|
|
|
38
38
|
},
|
|
39
39
|
};
|
|
40
40
|
class NoiseFieldGenerator {
|
|
41
|
-
|
|
41
|
+
container;
|
|
42
|
+
field;
|
|
43
|
+
noiseGen;
|
|
44
|
+
noiseW;
|
|
45
|
+
options;
|
|
46
|
+
_res;
|
|
47
|
+
constructor(container, noiseGen) {
|
|
48
|
+
this.container = container;
|
|
42
49
|
this.noiseGen = noiseGen;
|
|
43
50
|
this.field = [];
|
|
44
51
|
this.noiseW = 0;
|
|
52
|
+
this._res = engine_1.Vector.origin;
|
|
45
53
|
this.options = (0, engine_1.deepExtend)({}, defaultOptions);
|
|
46
54
|
}
|
|
47
55
|
generate(particle) {
|
|
@@ -50,18 +58,22 @@
|
|
|
50
58
|
y: Math.max(Math.floor(pos.y / size), originCoordinate),
|
|
51
59
|
z: Math.max(Math.floor(pos.z / size), originCoordinate),
|
|
52
60
|
}, { field } = this, fieldPoint = field[point.x]?.[point.y]?.[point.z];
|
|
53
|
-
|
|
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;
|
|
54
70
|
}
|
|
55
|
-
init(
|
|
56
|
-
this.container = container;
|
|
71
|
+
init() {
|
|
57
72
|
this._setup();
|
|
58
73
|
}
|
|
59
74
|
reset() {
|
|
60
75
|
}
|
|
61
76
|
update() {
|
|
62
|
-
if (!this.container) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
77
|
this._calculateField();
|
|
66
78
|
this.noiseW += this.options.increment;
|
|
67
79
|
if (!this.options.draw) {
|
|
@@ -138,11 +150,7 @@
|
|
|
138
150
|
}
|
|
139
151
|
}
|
|
140
152
|
_resetField() {
|
|
141
|
-
const container = this.container;
|
|
142
|
-
if (!container) {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
153
|
+
const container = this.container, sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
146
154
|
options.width = container.canvas.size.width;
|
|
147
155
|
options.height = container.canvas.size.height;
|
|
148
156
|
options.size = sourceOptions["size"] > empty ? sourceOptions["size"] : defaultOptions.size;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
/*! tsParticles Noise Field v4.0.0-alpha.8 by Matteo Bruni */
|