@tsparticles/noise-field 4.0.0-beta.1 → 4.0.0-beta.10
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/README.md +17 -0
- package/package.json +5 -6
- package/report.html +1 -1
- package/tsparticles.noise.field.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/README.md
CHANGED
|
@@ -8,6 +8,12 @@
|
|
|
8
8
|
|
|
9
9
|
[tsParticles](https://github.com/tsparticles/tsparticles) path plugin for fractal noise movement.
|
|
10
10
|
|
|
11
|
+
## Quick checklist
|
|
12
|
+
|
|
13
|
+
1. Install `@tsparticles/engine` (or use the CDN bundle below)
|
|
14
|
+
2. Call the package loader function(s) before `tsParticles.load(...)`
|
|
15
|
+
3. Apply the package options in your `tsParticles.load(...)` config
|
|
16
|
+
|
|
11
17
|
## How to use it
|
|
12
18
|
|
|
13
19
|
### CDN / Vanilla JS / jQuery
|
|
@@ -72,3 +78,14 @@ import { loadFractalNoisePath } from "@tsparticles/fractal-noise";
|
|
|
72
78
|
await loadFractalNoisePath(tsParticles);
|
|
73
79
|
})();
|
|
74
80
|
```
|
|
81
|
+
|
|
82
|
+
## Common pitfalls
|
|
83
|
+
|
|
84
|
+
- Calling `tsParticles.load(...)` before `loadFractalNoisePath(...)`
|
|
85
|
+
- Verify required peer packages before enabling advanced options
|
|
86
|
+
- Change one option group at a time to isolate regressions quickly
|
|
87
|
+
|
|
88
|
+
## Related docs
|
|
89
|
+
|
|
90
|
+
- All packages catalog: <https://github.com/tsparticles/tsparticles>
|
|
91
|
+
- Main docs: <https://particles.js.org/docs/>
|
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.10",
|
|
4
4
|
"description": "tsParticles noise field library",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -91,9 +91,9 @@
|
|
|
91
91
|
"main": "cjs/index.js",
|
|
92
92
|
"module": "esm/index.js",
|
|
93
93
|
"types": "types/index.d.ts",
|
|
94
|
-
"
|
|
95
|
-
"@tsparticles/engine": "4.0.0-beta.
|
|
96
|
-
"@tsparticles/plugin-move": "4.0.0-beta.
|
|
94
|
+
"peerDependencies": {
|
|
95
|
+
"@tsparticles/engine": "4.0.0-beta.10",
|
|
96
|
+
"@tsparticles/plugin-move": "4.0.0-beta.10"
|
|
97
97
|
},
|
|
98
98
|
"exports": {
|
|
99
99
|
".": {
|
|
@@ -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 [8 Apr 2026 at 15:55]</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/ojfMKpzOd0rNgQcb3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13ugufMkfXn+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.10
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -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
|
-
});
|