@tsparticles/path-simplex-noise 3.8.1 → 3.9.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/SimplexNoiseGenerator.js +60 -32
- package/browser/index.js +1 -1
- package/cjs/SimplexNoiseGenerator.js +60 -32
- package/cjs/index.js +1 -1
- package/esm/SimplexNoiseGenerator.js +60 -32
- package/esm/index.js +1 -1
- package/package.json +3 -3
- package/report.html +1 -1
- package/tsparticles.path.simplex.noise.js +3 -3
- package/tsparticles.path.simplex.noise.min.js +1 -1
- package/tsparticles.path.simplex.noise.min.js.LICENSE.txt +1 -1
- package/types/{IOffsetValues.d.ts → IFactorOffsetValues.d.ts} +4 -0
- package/types/ISimplexOptions.d.ts +3 -1
- package/types/SimplexNoiseGenerator.d.ts +1 -0
- package/umd/SimplexNoiseGenerator.js +60 -32
- package/umd/index.js +1 -1
- /package/browser/{IOffsetValues.js → IFactorOffsetValues.js} +0 -0
- /package/cjs/{IOffsetValues.js → IFactorOffsetValues.js} +0 -0
- /package/esm/{IOffsetValues.js → IFactorOffsetValues.js} +0 -0
- /package/umd/{IOffsetValues.js → IFactorOffsetValues.js} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
|
|
2
2
|
import { SimplexNoise } from "@tsparticles/simplex-noise";
|
|
3
3
|
const defaultOptions = {
|
|
4
|
+
draw: false,
|
|
4
5
|
size: 20,
|
|
5
6
|
increment: 0.004,
|
|
6
7
|
columns: 0,
|
|
@@ -8,6 +9,10 @@ const defaultOptions = {
|
|
|
8
9
|
layers: 0,
|
|
9
10
|
width: 0,
|
|
10
11
|
height: 0,
|
|
12
|
+
factor: {
|
|
13
|
+
angle: 0.02,
|
|
14
|
+
length: 0.01,
|
|
15
|
+
},
|
|
11
16
|
offset: {
|
|
12
17
|
x: 40000,
|
|
13
18
|
y: 40000,
|
|
@@ -23,16 +28,12 @@ export class SimplexNoiseGenerator {
|
|
|
23
28
|
this.options = deepExtend({}, defaultOptions);
|
|
24
29
|
}
|
|
25
30
|
generate(particle) {
|
|
26
|
-
const pos = particle.getPosition(), point = {
|
|
27
|
-
x: Math.max(Math.floor(pos.x /
|
|
28
|
-
y: Math.max(Math.floor(pos.y /
|
|
29
|
-
z: Math.max(Math.floor(pos.z /
|
|
30
|
-
}, v = Vector.origin;
|
|
31
|
-
|
|
32
|
-
return v;
|
|
33
|
-
}
|
|
34
|
-
v.setTo(this.field[point.x][point.y][point.z]);
|
|
35
|
-
return v;
|
|
31
|
+
const pos = particle.getPosition(), { size } = this.options, point = {
|
|
32
|
+
x: Math.max(Math.floor(pos.x / size), 0),
|
|
33
|
+
y: Math.max(Math.floor(pos.y / size), 0),
|
|
34
|
+
z: Math.max(Math.floor(pos.z / size), 0),
|
|
35
|
+
}, v = Vector.origin, { field } = this;
|
|
36
|
+
return field?.[point.x]?.[point.y]?.[point.z] ? field[point.x][point.y][point.z].copy() : v;
|
|
36
37
|
}
|
|
37
38
|
init(container) {
|
|
38
39
|
this.container = container;
|
|
@@ -46,25 +47,48 @@ export class SimplexNoiseGenerator {
|
|
|
46
47
|
}
|
|
47
48
|
this._calculateField();
|
|
48
49
|
this.noiseW += this.options.increment;
|
|
50
|
+
if (this.options.draw) {
|
|
51
|
+
this.container.canvas.draw(ctx => this._drawField(ctx));
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
_calculateField() {
|
|
51
|
-
const options = this.options;
|
|
55
|
+
const { options, field, _simplex: noiseGen, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
|
|
52
56
|
for (let x = 0; x < options.columns; x++) {
|
|
53
57
|
for (let y = 0; y < options.rows; y++) {
|
|
54
58
|
for (let z = 0; z < options.layers; z++) {
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
const cell = field[x][y][z];
|
|
60
|
+
cell.length = noiseGen.noise(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
|
|
61
|
+
cell.angle =
|
|
62
|
+
noiseGen.noise(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * Math.PI * 2;
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
}
|
|
67
|
+
_drawField(ctx) {
|
|
68
|
+
const { field, options } = this;
|
|
69
|
+
for (let x = 0; x < options.columns; x++) {
|
|
70
|
+
const column = field[x];
|
|
71
|
+
for (let y = 0; y < options.rows; y++) {
|
|
72
|
+
const cell = column[y][0], { angle, length } = cell;
|
|
73
|
+
ctx.setTransform(1, 0, 0, 1, x * this.options.size, y * this.options.size);
|
|
74
|
+
ctx.rotate(angle);
|
|
75
|
+
ctx.strokeStyle = "white";
|
|
76
|
+
ctx.beginPath();
|
|
77
|
+
ctx.moveTo(0, 0);
|
|
78
|
+
ctx.lineTo(0, this.options.size * length);
|
|
79
|
+
ctx.stroke();
|
|
80
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
61
84
|
_initField() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
const { columns, rows, layers } = this.options;
|
|
86
|
+
this.field = new Array(columns);
|
|
87
|
+
for (let x = 0; x < columns; x++) {
|
|
88
|
+
this.field[x] = new Array(rows);
|
|
89
|
+
for (let y = 0; y < rows; y++) {
|
|
90
|
+
this.field[x][y] = new Array(layers);
|
|
91
|
+
for (let z = 0; z < layers; z++) {
|
|
68
92
|
this.field[x][y][z] = Vector.origin;
|
|
69
93
|
}
|
|
70
94
|
}
|
|
@@ -75,21 +99,25 @@ export class SimplexNoiseGenerator {
|
|
|
75
99
|
if (!container) {
|
|
76
100
|
return;
|
|
77
101
|
}
|
|
78
|
-
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
103
|
+
options.width = container.canvas.size.width;
|
|
104
|
+
options.height = container.canvas.size.height;
|
|
105
|
+
options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;
|
|
106
|
+
options.increment =
|
|
81
107
|
sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;
|
|
82
|
-
|
|
83
|
-
this.options.height = container.canvas.size.height;
|
|
108
|
+
options.draw = !!sourceOptions.draw;
|
|
84
109
|
const offset = sourceOptions.offset;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.options.
|
|
110
|
+
options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
111
|
+
options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
112
|
+
options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
113
|
+
const factor = sourceOptions.factor;
|
|
114
|
+
options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
|
|
115
|
+
options.factor.length = factor?.length ?? defaultOptions.factor.length;
|
|
116
|
+
options.seed = sourceOptions.seed;
|
|
117
|
+
this._simplex.seed(options.seed ?? getRandom());
|
|
118
|
+
options.columns = Math.floor(options.width / options.size) + 1;
|
|
119
|
+
options.rows = Math.floor(options.height / options.size) + 1;
|
|
120
|
+
options.layers = Math.floor(container.zLayers / options.size) + 1;
|
|
93
121
|
this._initField();
|
|
94
122
|
}
|
|
95
123
|
_setup() {
|
package/browser/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SimplexNoiseGenerator } from "./SimplexNoiseGenerator.js";
|
|
2
2
|
export const simplexNoisePathName = "simplexNoise";
|
|
3
3
|
export async function loadSimplexNoisePath(engine, refresh = true) {
|
|
4
|
-
engine.checkVersion("3.
|
|
4
|
+
engine.checkVersion("3.9.0");
|
|
5
5
|
await engine.addPathGenerator(simplexNoisePathName, new SimplexNoiseGenerator(), refresh);
|
|
6
6
|
}
|
|
@@ -4,6 +4,7 @@ exports.SimplexNoiseGenerator = void 0;
|
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
5
|
const simplex_noise_1 = require("@tsparticles/simplex-noise");
|
|
6
6
|
const defaultOptions = {
|
|
7
|
+
draw: false,
|
|
7
8
|
size: 20,
|
|
8
9
|
increment: 0.004,
|
|
9
10
|
columns: 0,
|
|
@@ -11,6 +12,10 @@ const defaultOptions = {
|
|
|
11
12
|
layers: 0,
|
|
12
13
|
width: 0,
|
|
13
14
|
height: 0,
|
|
15
|
+
factor: {
|
|
16
|
+
angle: 0.02,
|
|
17
|
+
length: 0.01,
|
|
18
|
+
},
|
|
14
19
|
offset: {
|
|
15
20
|
x: 40000,
|
|
16
21
|
y: 40000,
|
|
@@ -26,16 +31,12 @@ class SimplexNoiseGenerator {
|
|
|
26
31
|
this.options = (0, engine_1.deepExtend)({}, defaultOptions);
|
|
27
32
|
}
|
|
28
33
|
generate(particle) {
|
|
29
|
-
const pos = particle.getPosition(), point = {
|
|
30
|
-
x: Math.max(Math.floor(pos.x /
|
|
31
|
-
y: Math.max(Math.floor(pos.y /
|
|
32
|
-
z: Math.max(Math.floor(pos.z /
|
|
33
|
-
}, v = engine_1.Vector.origin;
|
|
34
|
-
|
|
35
|
-
return v;
|
|
36
|
-
}
|
|
37
|
-
v.setTo(this.field[point.x][point.y][point.z]);
|
|
38
|
-
return v;
|
|
34
|
+
const pos = particle.getPosition(), { size } = this.options, point = {
|
|
35
|
+
x: Math.max(Math.floor(pos.x / size), 0),
|
|
36
|
+
y: Math.max(Math.floor(pos.y / size), 0),
|
|
37
|
+
z: Math.max(Math.floor(pos.z / size), 0),
|
|
38
|
+
}, v = engine_1.Vector.origin, { field } = this;
|
|
39
|
+
return field?.[point.x]?.[point.y]?.[point.z] ? field[point.x][point.y][point.z].copy() : v;
|
|
39
40
|
}
|
|
40
41
|
init(container) {
|
|
41
42
|
this.container = container;
|
|
@@ -49,25 +50,48 @@ class SimplexNoiseGenerator {
|
|
|
49
50
|
}
|
|
50
51
|
this._calculateField();
|
|
51
52
|
this.noiseW += this.options.increment;
|
|
53
|
+
if (this.options.draw) {
|
|
54
|
+
this.container.canvas.draw(ctx => this._drawField(ctx));
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
_calculateField() {
|
|
54
|
-
const options = this.options;
|
|
58
|
+
const { options, field, _simplex: noiseGen, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
|
|
55
59
|
for (let x = 0; x < options.columns; x++) {
|
|
56
60
|
for (let y = 0; y < options.rows; y++) {
|
|
57
61
|
for (let z = 0; z < options.layers; z++) {
|
|
58
|
-
|
|
59
|
-
|
|
62
|
+
const cell = field[x][y][z];
|
|
63
|
+
cell.length = noiseGen.noise(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
|
|
64
|
+
cell.angle =
|
|
65
|
+
noiseGen.noise(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * Math.PI * 2;
|
|
60
66
|
}
|
|
61
67
|
}
|
|
62
68
|
}
|
|
63
69
|
}
|
|
70
|
+
_drawField(ctx) {
|
|
71
|
+
const { field, options } = this;
|
|
72
|
+
for (let x = 0; x < options.columns; x++) {
|
|
73
|
+
const column = field[x];
|
|
74
|
+
for (let y = 0; y < options.rows; y++) {
|
|
75
|
+
const cell = column[y][0], { angle, length } = cell;
|
|
76
|
+
ctx.setTransform(1, 0, 0, 1, x * this.options.size, y * this.options.size);
|
|
77
|
+
ctx.rotate(angle);
|
|
78
|
+
ctx.strokeStyle = "white";
|
|
79
|
+
ctx.beginPath();
|
|
80
|
+
ctx.moveTo(0, 0);
|
|
81
|
+
ctx.lineTo(0, this.options.size * length);
|
|
82
|
+
ctx.stroke();
|
|
83
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
64
87
|
_initField() {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
88
|
+
const { columns, rows, layers } = this.options;
|
|
89
|
+
this.field = new Array(columns);
|
|
90
|
+
for (let x = 0; x < columns; x++) {
|
|
91
|
+
this.field[x] = new Array(rows);
|
|
92
|
+
for (let y = 0; y < rows; y++) {
|
|
93
|
+
this.field[x][y] = new Array(layers);
|
|
94
|
+
for (let z = 0; z < layers; z++) {
|
|
71
95
|
this.field[x][y][z] = engine_1.Vector.origin;
|
|
72
96
|
}
|
|
73
97
|
}
|
|
@@ -78,21 +102,25 @@ class SimplexNoiseGenerator {
|
|
|
78
102
|
if (!container) {
|
|
79
103
|
return;
|
|
80
104
|
}
|
|
81
|
-
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
82
|
-
|
|
83
|
-
|
|
105
|
+
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
106
|
+
options.width = container.canvas.size.width;
|
|
107
|
+
options.height = container.canvas.size.height;
|
|
108
|
+
options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;
|
|
109
|
+
options.increment =
|
|
84
110
|
sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;
|
|
85
|
-
|
|
86
|
-
this.options.height = container.canvas.size.height;
|
|
111
|
+
options.draw = !!sourceOptions.draw;
|
|
87
112
|
const offset = sourceOptions.offset;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
this.options.
|
|
113
|
+
options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
114
|
+
options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
115
|
+
options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
116
|
+
const factor = sourceOptions.factor;
|
|
117
|
+
options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
|
|
118
|
+
options.factor.length = factor?.length ?? defaultOptions.factor.length;
|
|
119
|
+
options.seed = sourceOptions.seed;
|
|
120
|
+
this._simplex.seed(options.seed ?? (0, engine_1.getRandom)());
|
|
121
|
+
options.columns = Math.floor(options.width / options.size) + 1;
|
|
122
|
+
options.rows = Math.floor(options.height / options.size) + 1;
|
|
123
|
+
options.layers = Math.floor(container.zLayers / options.size) + 1;
|
|
96
124
|
this._initField();
|
|
97
125
|
}
|
|
98
126
|
_setup() {
|
package/cjs/index.js
CHANGED
|
@@ -5,6 +5,6 @@ exports.loadSimplexNoisePath = loadSimplexNoisePath;
|
|
|
5
5
|
const SimplexNoiseGenerator_js_1 = require("./SimplexNoiseGenerator.js");
|
|
6
6
|
exports.simplexNoisePathName = "simplexNoise";
|
|
7
7
|
async function loadSimplexNoisePath(engine, refresh = true) {
|
|
8
|
-
engine.checkVersion("3.
|
|
8
|
+
engine.checkVersion("3.9.0");
|
|
9
9
|
await engine.addPathGenerator(exports.simplexNoisePathName, new SimplexNoiseGenerator_js_1.SimplexNoiseGenerator(), refresh);
|
|
10
10
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
|
|
2
2
|
import { SimplexNoise } from "@tsparticles/simplex-noise";
|
|
3
3
|
const defaultOptions = {
|
|
4
|
+
draw: false,
|
|
4
5
|
size: 20,
|
|
5
6
|
increment: 0.004,
|
|
6
7
|
columns: 0,
|
|
@@ -8,6 +9,10 @@ const defaultOptions = {
|
|
|
8
9
|
layers: 0,
|
|
9
10
|
width: 0,
|
|
10
11
|
height: 0,
|
|
12
|
+
factor: {
|
|
13
|
+
angle: 0.02,
|
|
14
|
+
length: 0.01,
|
|
15
|
+
},
|
|
11
16
|
offset: {
|
|
12
17
|
x: 40000,
|
|
13
18
|
y: 40000,
|
|
@@ -23,16 +28,12 @@ export class SimplexNoiseGenerator {
|
|
|
23
28
|
this.options = deepExtend({}, defaultOptions);
|
|
24
29
|
}
|
|
25
30
|
generate(particle) {
|
|
26
|
-
const pos = particle.getPosition(), point = {
|
|
27
|
-
x: Math.max(Math.floor(pos.x /
|
|
28
|
-
y: Math.max(Math.floor(pos.y /
|
|
29
|
-
z: Math.max(Math.floor(pos.z /
|
|
30
|
-
}, v = Vector.origin;
|
|
31
|
-
|
|
32
|
-
return v;
|
|
33
|
-
}
|
|
34
|
-
v.setTo(this.field[point.x][point.y][point.z]);
|
|
35
|
-
return v;
|
|
31
|
+
const pos = particle.getPosition(), { size } = this.options, point = {
|
|
32
|
+
x: Math.max(Math.floor(pos.x / size), 0),
|
|
33
|
+
y: Math.max(Math.floor(pos.y / size), 0),
|
|
34
|
+
z: Math.max(Math.floor(pos.z / size), 0),
|
|
35
|
+
}, v = Vector.origin, { field } = this;
|
|
36
|
+
return field?.[point.x]?.[point.y]?.[point.z] ? field[point.x][point.y][point.z].copy() : v;
|
|
36
37
|
}
|
|
37
38
|
init(container) {
|
|
38
39
|
this.container = container;
|
|
@@ -46,25 +47,48 @@ export class SimplexNoiseGenerator {
|
|
|
46
47
|
}
|
|
47
48
|
this._calculateField();
|
|
48
49
|
this.noiseW += this.options.increment;
|
|
50
|
+
if (this.options.draw) {
|
|
51
|
+
this.container.canvas.draw(ctx => this._drawField(ctx));
|
|
52
|
+
}
|
|
49
53
|
}
|
|
50
54
|
_calculateField() {
|
|
51
|
-
const options = this.options;
|
|
55
|
+
const { options, field, _simplex: noiseGen, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
|
|
52
56
|
for (let x = 0; x < options.columns; x++) {
|
|
53
57
|
for (let y = 0; y < options.rows; y++) {
|
|
54
58
|
for (let z = 0; z < options.layers; z++) {
|
|
55
|
-
|
|
56
|
-
|
|
59
|
+
const cell = field[x][y][z];
|
|
60
|
+
cell.length = noiseGen.noise(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
|
|
61
|
+
cell.angle =
|
|
62
|
+
noiseGen.noise(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * Math.PI * 2;
|
|
57
63
|
}
|
|
58
64
|
}
|
|
59
65
|
}
|
|
60
66
|
}
|
|
67
|
+
_drawField(ctx) {
|
|
68
|
+
const { field, options } = this;
|
|
69
|
+
for (let x = 0; x < options.columns; x++) {
|
|
70
|
+
const column = field[x];
|
|
71
|
+
for (let y = 0; y < options.rows; y++) {
|
|
72
|
+
const cell = column[y][0], { angle, length } = cell;
|
|
73
|
+
ctx.setTransform(1, 0, 0, 1, x * this.options.size, y * this.options.size);
|
|
74
|
+
ctx.rotate(angle);
|
|
75
|
+
ctx.strokeStyle = "white";
|
|
76
|
+
ctx.beginPath();
|
|
77
|
+
ctx.moveTo(0, 0);
|
|
78
|
+
ctx.lineTo(0, this.options.size * length);
|
|
79
|
+
ctx.stroke();
|
|
80
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
61
84
|
_initField() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
85
|
+
const { columns, rows, layers } = this.options;
|
|
86
|
+
this.field = new Array(columns);
|
|
87
|
+
for (let x = 0; x < columns; x++) {
|
|
88
|
+
this.field[x] = new Array(rows);
|
|
89
|
+
for (let y = 0; y < rows; y++) {
|
|
90
|
+
this.field[x][y] = new Array(layers);
|
|
91
|
+
for (let z = 0; z < layers; z++) {
|
|
68
92
|
this.field[x][y][z] = Vector.origin;
|
|
69
93
|
}
|
|
70
94
|
}
|
|
@@ -75,21 +99,25 @@ export class SimplexNoiseGenerator {
|
|
|
75
99
|
if (!container) {
|
|
76
100
|
return;
|
|
77
101
|
}
|
|
78
|
-
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
79
|
-
|
|
80
|
-
|
|
102
|
+
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
103
|
+
options.width = container.canvas.size.width;
|
|
104
|
+
options.height = container.canvas.size.height;
|
|
105
|
+
options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;
|
|
106
|
+
options.increment =
|
|
81
107
|
sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;
|
|
82
|
-
|
|
83
|
-
this.options.height = container.canvas.size.height;
|
|
108
|
+
options.draw = !!sourceOptions.draw;
|
|
84
109
|
const offset = sourceOptions.offset;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this.options.
|
|
110
|
+
options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
111
|
+
options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
112
|
+
options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
113
|
+
const factor = sourceOptions.factor;
|
|
114
|
+
options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
|
|
115
|
+
options.factor.length = factor?.length ?? defaultOptions.factor.length;
|
|
116
|
+
options.seed = sourceOptions.seed;
|
|
117
|
+
this._simplex.seed(options.seed ?? getRandom());
|
|
118
|
+
options.columns = Math.floor(options.width / options.size) + 1;
|
|
119
|
+
options.rows = Math.floor(options.height / options.size) + 1;
|
|
120
|
+
options.layers = Math.floor(container.zLayers / options.size) + 1;
|
|
93
121
|
this._initField();
|
|
94
122
|
}
|
|
95
123
|
_setup() {
|
package/esm/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SimplexNoiseGenerator } from "./SimplexNoiseGenerator.js";
|
|
2
2
|
export const simplexNoisePathName = "simplexNoise";
|
|
3
3
|
export async function loadSimplexNoisePath(engine, refresh = true) {
|
|
4
|
-
engine.checkVersion("3.
|
|
4
|
+
engine.checkVersion("3.9.0");
|
|
5
5
|
await engine.addPathGenerator(simplexNoisePathName, new SimplexNoiseGenerator(), refresh);
|
|
6
6
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/path-simplex-noise",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0",
|
|
4
4
|
"description": "tsParticles simplex noise path",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"./package.json": "./package.json"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@tsparticles/engine": "3.
|
|
108
|
-
"@tsparticles/simplex-noise": "3.
|
|
107
|
+
"@tsparticles/engine": "3.9.0",
|
|
108
|
+
"@tsparticles/simplex-noise": "3.9.0"
|
|
109
109
|
}
|
|
110
110
|
}
|
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/path-simplex-noise [
|
|
6
|
+
<title>@tsparticles/path-simplex-noise [1 Aug 2025 at 08:53]</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
|
-
* v3.
|
|
7
|
+
* v3.9.0
|
|
8
8
|
*/
|
|
9
9
|
/*
|
|
10
10
|
* ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
|
|
@@ -34,7 +34,7 @@ return /******/ (() => { // webpackBootstrap
|
|
|
34
34
|
\***********************************************/
|
|
35
35
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
36
36
|
|
|
37
|
-
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SimplexNoiseGenerator: () => (/* binding */ SimplexNoiseGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _tsparticles_simplex_noise__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/simplex-noise */ \"@tsparticles/simplex-noise\");\n/* harmony import */ var _tsparticles_simplex_noise__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_simplex_noise__WEBPACK_IMPORTED_MODULE_1__);\n\n\nconst defaultOptions = {\n size: 20,\n increment: 0.004,\n columns: 0,\n rows: 0,\n layers: 0,\n width: 0,\n height: 0,\n offset: {\n x: 40000,\n y: 40000,\n z: 40000\n }\n};\nclass SimplexNoiseGenerator {\n constructor() {\n const simplex = new _tsparticles_simplex_noise__WEBPACK_IMPORTED_MODULE_1__.SimplexNoise();\n this._simplex = simplex.noise4d;\n this.field = [];\n this.noiseW = 0;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle) {\n const pos = particle.getPosition(),\n point = {\n x: Math.max(Math.floor(pos.x /
|
|
37
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ SimplexNoiseGenerator: () => (/* binding */ SimplexNoiseGenerator)\n/* harmony export */ });\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @tsparticles/engine */ \"@tsparticles/engine\");\n/* harmony import */ var _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__);\n/* harmony import */ var _tsparticles_simplex_noise__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @tsparticles/simplex-noise */ \"@tsparticles/simplex-noise\");\n/* harmony import */ var _tsparticles_simplex_noise__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_tsparticles_simplex_noise__WEBPACK_IMPORTED_MODULE_1__);\n\n\nconst 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 SimplexNoiseGenerator {\n constructor() {\n const simplex = new _tsparticles_simplex_noise__WEBPACK_IMPORTED_MODULE_1__.SimplexNoise();\n this._simplex = simplex.noise4d;\n this.field = [];\n this.noiseW = 0;\n this.options = (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.deepExtend)({}, defaultOptions);\n }\n generate(particle) {\n const pos = particle.getPosition(),\n {\n size\n } = this.options,\n point = {\n x: Math.max(Math.floor(pos.x / size), 0),\n y: Math.max(Math.floor(pos.y / size), 0),\n z: Math.max(Math.floor(pos.z / size), 0)\n },\n v = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin,\n {\n field\n } = this;\n return field?.[point.x]?.[point.y]?.[point.z] ? field[point.x][point.y][point.z].copy() : v;\n }\n init(container) {\n this.container = container;\n this._setup();\n }\n reset() {}\n update() {\n if (!this.container) {\n return;\n }\n this._calculateField();\n this.noiseW += this.options.increment;\n if (this.options.draw) {\n this.container.canvas.draw(ctx => this._drawField(ctx));\n }\n }\n _calculateField() {\n const {\n options,\n field,\n _simplex: noiseGen,\n noiseW\n } = this,\n lengthFactor = options.factor.length,\n angleFactor = options.factor.angle;\n for (let x = 0; x < options.columns; x++) {\n for (let y = 0; y < options.rows; y++) {\n for (let z = 0; z < options.layers; z++) {\n const cell = field[x][y][z];\n cell.length = noiseGen.noise(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);\n cell.angle = noiseGen.noise(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * Math.PI * 2;\n }\n }\n }\n }\n _drawField(ctx) {\n const {\n field,\n options\n } = this;\n for (let x = 0; x < options.columns; x++) {\n const column = field[x];\n for (let y = 0; y < options.rows; y++) {\n const cell = column[y][0],\n {\n angle,\n length\n } = cell;\n ctx.setTransform(1, 0, 0, 1, x * this.options.size, y * this.options.size);\n ctx.rotate(angle);\n ctx.strokeStyle = \"white\";\n ctx.beginPath();\n ctx.moveTo(0, 0);\n ctx.lineTo(0, this.options.size * length);\n ctx.stroke();\n ctx.setTransform(1, 0, 0, 1, 0, 0);\n }\n }\n }\n _initField() {\n const {\n columns,\n rows,\n layers\n } = this.options;\n this.field = new Array(columns);\n for (let x = 0; x < columns; x++) {\n this.field[x] = new Array(rows);\n for (let y = 0; y < rows; y++) {\n this.field[x][y] = new Array(layers);\n for (let z = 0; z < layers; z++) {\n this.field[x][y][z] = _tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.Vector.origin;\n }\n }\n }\n }\n _resetField() {\n const container = this.container;\n if (!container) {\n return;\n }\n const sourceOptions = container.actualOptions.particles.move.path.options,\n {\n options\n } = this;\n options.width = container.canvas.size.width;\n options.height = container.canvas.size.height;\n options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;\n options.increment = sourceOptions.increment > 0 ? 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._simplex.seed(options.seed ?? (0,_tsparticles_engine__WEBPACK_IMPORTED_MODULE_0__.getRandom)());\n options.columns = Math.floor(options.width / options.size) + 1;\n options.rows = Math.floor(options.height / options.size) + 1;\n options.layers = Math.floor(container.zLayers / options.size) + 1;\n this._initField();\n }\n _setup() {\n this.noiseW = 0;\n this._resetField();\n addEventListener(\"resize\", () => this._resetField());\n }\n}\n\n//# sourceURL=webpack://@tsparticles/path-simplex-noise/./dist/browser/SimplexNoiseGenerator.js?\n}");
|
|
38
38
|
|
|
39
39
|
/***/ }),
|
|
40
40
|
|
|
@@ -44,7 +44,7 @@ eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpac
|
|
|
44
44
|
\*******************************/
|
|
45
45
|
/***/ ((__unused_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 */ loadSimplexNoisePath: () => (/* binding */ loadSimplexNoisePath),\n/* harmony export */ simplexNoisePathName: () => (/* binding */ simplexNoisePathName)\n/* harmony export */ });\n/* harmony import */ var _SimplexNoiseGenerator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SimplexNoiseGenerator.js */ \"./dist/browser/SimplexNoiseGenerator.js\");\n\nconst simplexNoisePathName = \"simplexNoise\";\nasync function loadSimplexNoisePath(engine, refresh = true) {\n engine.checkVersion(\"3.
|
|
47
|
+
eval("{__webpack_require__.r(__webpack_exports__);\n/* harmony export */ __webpack_require__.d(__webpack_exports__, {\n/* harmony export */ loadSimplexNoisePath: () => (/* binding */ loadSimplexNoisePath),\n/* harmony export */ simplexNoisePathName: () => (/* binding */ simplexNoisePathName)\n/* harmony export */ });\n/* harmony import */ var _SimplexNoiseGenerator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./SimplexNoiseGenerator.js */ \"./dist/browser/SimplexNoiseGenerator.js\");\n\nconst simplexNoisePathName = \"simplexNoise\";\nasync function loadSimplexNoisePath(engine, refresh = true) {\n engine.checkVersion(\"3.9.0\");\n await engine.addPathGenerator(simplexNoisePathName, new _SimplexNoiseGenerator_js__WEBPACK_IMPORTED_MODULE_0__.SimplexNoiseGenerator(), refresh);\n}\n\n//# sourceURL=webpack://@tsparticles/path-simplex-noise/./dist/browser/index.js?\n}");
|
|
48
48
|
|
|
49
49
|
/***/ }),
|
|
50
50
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see tsparticles.path.simplex.noise.min.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/simplex-noise"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/simplex-noise"],t);else{var
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("@tsparticles/engine"),require("@tsparticles/simplex-noise"));else if("function"==typeof define&&define.amd)define(["@tsparticles/engine","@tsparticles/simplex-noise"],t);else{var s="object"==typeof exports?t(require("@tsparticles/engine"),require("@tsparticles/simplex-noise")):t(e.window,e.window);for(var o in s)("object"==typeof exports?exports:e)[o]=s[o]}}(this,((e,t)=>(()=>{var s={226:e=>{e.exports=t},303:t=>{t.exports=e}},o={};function i(e){var t=o[e];if(void 0!==t)return t.exports;var n=o[e]={exports:{}};return s[e](n,n.exports,i),n.exports}i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};i.r(n),i.d(n,{loadSimplexNoisePath:()=>h,simplexNoisePathName:()=>c});var r=i(303),a=i(226);const 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 f{constructor(){const e=new a.SimplexNoise;this._simplex=e.noise4d,this.field=[],this.noiseW=0,this.options=(0,r.deepExtend)({},l)}generate(e){const t=e.getPosition(),{size:s}=this.options,o=Math.max(Math.floor(t.x/s),0),i=Math.max(Math.floor(t.y/s),0),n=Math.max(Math.floor(t.z/s),0),a=r.Vector.origin,{field:l}=this;return l?.[o]?.[i]?.[n]?l[o][i][n].copy():a}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{options:e,field:t,_simplex:s,noiseW:o}=this,i=e.factor.length,n=e.factor.angle;for(let r=0;r<e.columns;r++)for(let a=0;a<e.rows;a++)for(let l=0;l<e.layers;l++){const f=t[r][a][l];f.length=s.noise(r*i+e.offset.x,a*i+e.offset.y,l*i+e.offset.z,o),f.angle=s.noise(r*n,a*n,l*n,o)*Math.PI*2}}_drawField(e){const{field:t,options:s}=this;for(let o=0;o<s.columns;o++){const i=t[o];for(let t=0;t<s.rows;t++){const s=i[t][0],{angle:n,length:r}=s;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*r),e.stroke(),e.setTransform(1,0,0,1,0,0)}}}_initField(){const{columns:e,rows:t,layers:s}=this.options;this.field=new Array(e);for(let o=0;o<e;o++){this.field[o]=new Array(t);for(let e=0;e<t;e++){this.field[o][e]=new Array(s);for(let t=0;t<s;t++)this.field[o][e][t]=r.Vector.origin}}}_resetField(){const e=this.container;if(!e)return;const t=e.actualOptions.particles.move.path.options,{options:s}=this;s.width=e.canvas.size.width,s.height=e.canvas.size.height,s.size=t.size>0?t.size:l.size,s.increment=t.increment>0?t.increment:l.increment,s.draw=!!t.draw;const o=t.offset;s.offset.x=o?.x??l.offset.x,s.offset.y=o?.y??l.offset.y,s.offset.z=o?.z??l.offset.z;const i=t.factor;s.factor.angle=i?.angle??l.factor.angle,s.factor.length=i?.length??l.factor.length,s.seed=t.seed,this._simplex.seed(s.seed??(0,r.getRandom)()),s.columns=Math.floor(s.width/s.size)+1,s.rows=Math.floor(s.height/s.size)+1,s.layers=Math.floor(e.zLayers/s.size)+1,this._initField()}_setup(){this.noiseW=0,this._resetField(),addEventListener("resize",(()=>this._resetField()))}}const c="simplexNoise";async function h(e,t=!0){e.checkVersion("3.9.0"),await e.addPathGenerator(c,new f,t)}return n})()));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
/*! tsParticles Simplex Noise Path v3.
|
|
1
|
+
/*! tsParticles Simplex Noise Path v3.9.0 by Matteo Bruni */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { IOffsetValues } from "./
|
|
1
|
+
import type { IFactorValues, IOffsetValues } from "./IFactorOffsetValues.js";
|
|
2
2
|
export interface ISimplexOptions {
|
|
3
3
|
columns: number;
|
|
4
|
+
draw: boolean;
|
|
5
|
+
factor: IFactorValues;
|
|
4
6
|
height: number;
|
|
5
7
|
increment: number;
|
|
6
8
|
layers: number;
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
const engine_1 = require("@tsparticles/engine");
|
|
14
14
|
const simplex_noise_1 = require("@tsparticles/simplex-noise");
|
|
15
15
|
const defaultOptions = {
|
|
16
|
+
draw: false,
|
|
16
17
|
size: 20,
|
|
17
18
|
increment: 0.004,
|
|
18
19
|
columns: 0,
|
|
@@ -20,6 +21,10 @@
|
|
|
20
21
|
layers: 0,
|
|
21
22
|
width: 0,
|
|
22
23
|
height: 0,
|
|
24
|
+
factor: {
|
|
25
|
+
angle: 0.02,
|
|
26
|
+
length: 0.01,
|
|
27
|
+
},
|
|
23
28
|
offset: {
|
|
24
29
|
x: 40000,
|
|
25
30
|
y: 40000,
|
|
@@ -35,16 +40,12 @@
|
|
|
35
40
|
this.options = (0, engine_1.deepExtend)({}, defaultOptions);
|
|
36
41
|
}
|
|
37
42
|
generate(particle) {
|
|
38
|
-
const pos = particle.getPosition(), point = {
|
|
39
|
-
x: Math.max(Math.floor(pos.x /
|
|
40
|
-
y: Math.max(Math.floor(pos.y /
|
|
41
|
-
z: Math.max(Math.floor(pos.z /
|
|
42
|
-
}, v = engine_1.Vector.origin;
|
|
43
|
-
|
|
44
|
-
return v;
|
|
45
|
-
}
|
|
46
|
-
v.setTo(this.field[point.x][point.y][point.z]);
|
|
47
|
-
return v;
|
|
43
|
+
const pos = particle.getPosition(), { size } = this.options, point = {
|
|
44
|
+
x: Math.max(Math.floor(pos.x / size), 0),
|
|
45
|
+
y: Math.max(Math.floor(pos.y / size), 0),
|
|
46
|
+
z: Math.max(Math.floor(pos.z / size), 0),
|
|
47
|
+
}, v = engine_1.Vector.origin, { field } = this;
|
|
48
|
+
return field?.[point.x]?.[point.y]?.[point.z] ? field[point.x][point.y][point.z].copy() : v;
|
|
48
49
|
}
|
|
49
50
|
init(container) {
|
|
50
51
|
this.container = container;
|
|
@@ -58,25 +59,48 @@
|
|
|
58
59
|
}
|
|
59
60
|
this._calculateField();
|
|
60
61
|
this.noiseW += this.options.increment;
|
|
62
|
+
if (this.options.draw) {
|
|
63
|
+
this.container.canvas.draw(ctx => this._drawField(ctx));
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
_calculateField() {
|
|
63
|
-
const options = this.options;
|
|
67
|
+
const { options, field, _simplex: noiseGen, noiseW } = this, lengthFactor = options.factor.length, angleFactor = options.factor.angle;
|
|
64
68
|
for (let x = 0; x < options.columns; x++) {
|
|
65
69
|
for (let y = 0; y < options.rows; y++) {
|
|
66
70
|
for (let z = 0; z < options.layers; z++) {
|
|
67
|
-
|
|
68
|
-
|
|
71
|
+
const cell = field[x][y][z];
|
|
72
|
+
cell.length = noiseGen.noise(x * lengthFactor + options.offset.x, y * lengthFactor + options.offset.y, z * lengthFactor + options.offset.z, noiseW);
|
|
73
|
+
cell.angle =
|
|
74
|
+
noiseGen.noise(x * angleFactor, y * angleFactor, z * angleFactor, noiseW) * Math.PI * 2;
|
|
69
75
|
}
|
|
70
76
|
}
|
|
71
77
|
}
|
|
72
78
|
}
|
|
79
|
+
_drawField(ctx) {
|
|
80
|
+
const { field, options } = this;
|
|
81
|
+
for (let x = 0; x < options.columns; x++) {
|
|
82
|
+
const column = field[x];
|
|
83
|
+
for (let y = 0; y < options.rows; y++) {
|
|
84
|
+
const cell = column[y][0], { angle, length } = cell;
|
|
85
|
+
ctx.setTransform(1, 0, 0, 1, x * this.options.size, y * this.options.size);
|
|
86
|
+
ctx.rotate(angle);
|
|
87
|
+
ctx.strokeStyle = "white";
|
|
88
|
+
ctx.beginPath();
|
|
89
|
+
ctx.moveTo(0, 0);
|
|
90
|
+
ctx.lineTo(0, this.options.size * length);
|
|
91
|
+
ctx.stroke();
|
|
92
|
+
ctx.setTransform(1, 0, 0, 1, 0, 0);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
73
96
|
_initField() {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
97
|
+
const { columns, rows, layers } = this.options;
|
|
98
|
+
this.field = new Array(columns);
|
|
99
|
+
for (let x = 0; x < columns; x++) {
|
|
100
|
+
this.field[x] = new Array(rows);
|
|
101
|
+
for (let y = 0; y < rows; y++) {
|
|
102
|
+
this.field[x][y] = new Array(layers);
|
|
103
|
+
for (let z = 0; z < layers; z++) {
|
|
80
104
|
this.field[x][y][z] = engine_1.Vector.origin;
|
|
81
105
|
}
|
|
82
106
|
}
|
|
@@ -87,21 +111,25 @@
|
|
|
87
111
|
if (!container) {
|
|
88
112
|
return;
|
|
89
113
|
}
|
|
90
|
-
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
91
|
-
|
|
92
|
-
|
|
114
|
+
const sourceOptions = container.actualOptions.particles.move.path.options, { options } = this;
|
|
115
|
+
options.width = container.canvas.size.width;
|
|
116
|
+
options.height = container.canvas.size.height;
|
|
117
|
+
options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;
|
|
118
|
+
options.increment =
|
|
93
119
|
sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;
|
|
94
|
-
|
|
95
|
-
this.options.height = container.canvas.size.height;
|
|
120
|
+
options.draw = !!sourceOptions.draw;
|
|
96
121
|
const offset = sourceOptions.offset;
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
this.options.
|
|
122
|
+
options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
123
|
+
options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
124
|
+
options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
125
|
+
const factor = sourceOptions.factor;
|
|
126
|
+
options.factor.angle = factor?.angle ?? defaultOptions.factor.angle;
|
|
127
|
+
options.factor.length = factor?.length ?? defaultOptions.factor.length;
|
|
128
|
+
options.seed = sourceOptions.seed;
|
|
129
|
+
this._simplex.seed(options.seed ?? (0, engine_1.getRandom)());
|
|
130
|
+
options.columns = Math.floor(options.width / options.size) + 1;
|
|
131
|
+
options.rows = Math.floor(options.height / options.size) + 1;
|
|
132
|
+
options.layers = Math.floor(container.zLayers / options.size) + 1;
|
|
105
133
|
this._initField();
|
|
106
134
|
}
|
|
107
135
|
_setup() {
|
package/umd/index.js
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
const SimplexNoiseGenerator_js_1 = require("./SimplexNoiseGenerator.js");
|
|
15
15
|
exports.simplexNoisePathName = "simplexNoise";
|
|
16
16
|
async function loadSimplexNoisePath(engine, refresh = true) {
|
|
17
|
-
engine.checkVersion("3.
|
|
17
|
+
engine.checkVersion("3.9.0");
|
|
18
18
|
await engine.addPathGenerator(exports.simplexNoisePathName, new SimplexNoiseGenerator_js_1.SimplexNoiseGenerator(), refresh);
|
|
19
19
|
}
|
|
20
20
|
});
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|