@tsparticles/path-simplex-noise 3.0.0-beta.3 → 3.0.0-beta.4
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 +73 -54
- package/cjs/SimplexNoiseGenerator.js +72 -53
- package/esm/SimplexNoiseGenerator.js +73 -54
- package/package.json +5 -4
- package/report.html +4 -22
- package/tsparticles.path.simplex.noise.js +84 -171
- 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 +5 -0
- package/types/ISimplexOptions.d.ts +3 -0
- package/types/SimplexNoiseGenerator.d.ts +5 -6
- package/umd/SimplexNoiseGenerator.js +73 -54
- package/browser/simplex.js +0 -205
- package/cjs/simplex.js +0 -210
- package/esm/simplex.js +0 -205
- package/types/Contribution4D.d.ts +0 -11
- package/types/simplex.d.ts +0 -3
- package/umd/simplex.js +0 -220
- /package/browser/{Contribution4D.js → IOffsetValues.js} +0 -0
- /package/cjs/{Contribution4D.js → IOffsetValues.js} +0 -0
- /package/esm/{Contribution4D.js → IOffsetValues.js} +0 -0
- /package/umd/{Contribution4D.js → IOffsetValues.js} +0 -0
|
@@ -1,58 +1,26 @@
|
|
|
1
|
-
import { Vector, getRandom } from "@tsparticles/engine";
|
|
2
|
-
import {
|
|
1
|
+
import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
|
|
2
|
+
import { SimplexNoise } from "@tsparticles/simplex-noise";
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
size: 20,
|
|
5
|
+
increment: 0.004,
|
|
6
|
+
columns: 0,
|
|
7
|
+
rows: 0,
|
|
8
|
+
layers: 0,
|
|
9
|
+
width: 0,
|
|
10
|
+
height: 0,
|
|
11
|
+
offset: {
|
|
12
|
+
x: 40000,
|
|
13
|
+
y: 40000,
|
|
14
|
+
z: 40000,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
3
17
|
export class SimplexNoiseGenerator {
|
|
4
18
|
constructor() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (let y = 0; y < this.options.rows; y++) {
|
|
8
|
-
for (let z = 0; z < this.options.layers; z++) {
|
|
9
|
-
this.field[x][y][z][0] = this.noiseFunc(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2;
|
|
10
|
-
this.field[x][y][z][1] = this.noiseFunc(x / 100 + 40000, y / 100 + 40000, z / 100 + 40000, this.noiseW);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
this._initField = () => {
|
|
16
|
-
this.field = new Array(this.options.columns);
|
|
17
|
-
for (let x = 0; x < this.options.columns; x++) {
|
|
18
|
-
this.field[x] = new Array(this.options.rows);
|
|
19
|
-
for (let y = 0; y < this.options.rows; y++) {
|
|
20
|
-
this.field[x][y] = new Array(this.options.layers);
|
|
21
|
-
for (let z = 0; z < this.options.layers; z++) {
|
|
22
|
-
this.field[x][y][z] = [0, 0];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
this._resetField = (container) => {
|
|
28
|
-
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
29
|
-
this.options.size = sourceOptions.size > 0 ? sourceOptions.size : 20;
|
|
30
|
-
this.options.increment = sourceOptions.increment > 0 ? sourceOptions.increment : 0.004;
|
|
31
|
-
this.options.width = container.canvas.size.width;
|
|
32
|
-
this.options.height = container.canvas.size.height;
|
|
33
|
-
this.noiseFunc = makeNoise4D(sourceOptions.seed ?? getRandom());
|
|
34
|
-
this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
|
|
35
|
-
this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
|
|
36
|
-
this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
|
|
37
|
-
this._initField();
|
|
38
|
-
};
|
|
39
|
-
this._setup = (container) => {
|
|
40
|
-
this.noiseW = 0;
|
|
41
|
-
this._resetField(container);
|
|
42
|
-
addEventListener("resize", () => this._resetField(container));
|
|
43
|
-
};
|
|
19
|
+
const simplex = new SimplexNoise();
|
|
20
|
+
this._simplex = simplex.noise4d;
|
|
44
21
|
this.field = [];
|
|
45
|
-
this.noiseFunc = makeNoise4D(getRandom());
|
|
46
22
|
this.noiseW = 0;
|
|
47
|
-
this.options = {
|
|
48
|
-
size: 20,
|
|
49
|
-
increment: 0.004,
|
|
50
|
-
columns: 0,
|
|
51
|
-
rows: 0,
|
|
52
|
-
layers: 0,
|
|
53
|
-
width: 0,
|
|
54
|
-
height: 0,
|
|
55
|
-
};
|
|
23
|
+
this.options = deepExtend({}, defaultOptions);
|
|
56
24
|
}
|
|
57
25
|
generate(particle) {
|
|
58
26
|
const pos = particle.getPosition(), point = {
|
|
@@ -66,13 +34,14 @@ export class SimplexNoiseGenerator {
|
|
|
66
34
|
!this.field[point.x][point.y][point.z]) {
|
|
67
35
|
return v;
|
|
68
36
|
}
|
|
69
|
-
|
|
70
|
-
v.
|
|
37
|
+
const cell = this.field[point.x][point.y][point.z];
|
|
38
|
+
v.length = cell[1];
|
|
39
|
+
v.angle = cell[0];
|
|
71
40
|
return v;
|
|
72
41
|
}
|
|
73
42
|
init(container) {
|
|
74
43
|
this.container = container;
|
|
75
|
-
this._setup(
|
|
44
|
+
this._setup();
|
|
76
45
|
}
|
|
77
46
|
reset() {
|
|
78
47
|
}
|
|
@@ -83,4 +52,54 @@ export class SimplexNoiseGenerator {
|
|
|
83
52
|
this._calculateField();
|
|
84
53
|
this.noiseW += this.options.increment;
|
|
85
54
|
}
|
|
55
|
+
_calculateField() {
|
|
56
|
+
const options = this.options;
|
|
57
|
+
for (let x = 0; x < options.columns; x++) {
|
|
58
|
+
for (let y = 0; y < options.rows; y++) {
|
|
59
|
+
for (let z = 0; z < options.layers; z++) {
|
|
60
|
+
this.field[x][y][z][0] = this._simplex.noise(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2;
|
|
61
|
+
this.field[x][y][z][1] = this._simplex.noise(x / 100 + options.offset.x, y / 100 + options.offset.y, z / 100 + options.offset.z, this.noiseW);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_initField() {
|
|
67
|
+
this.field = new Array(this.options.columns);
|
|
68
|
+
for (let x = 0; x < this.options.columns; x++) {
|
|
69
|
+
this.field[x] = new Array(this.options.rows);
|
|
70
|
+
for (let y = 0; y < this.options.rows; y++) {
|
|
71
|
+
this.field[x][y] = new Array(this.options.layers);
|
|
72
|
+
for (let z = 0; z < this.options.layers; z++) {
|
|
73
|
+
this.field[x][y][z] = [0, 0];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
_resetField() {
|
|
79
|
+
const container = this.container;
|
|
80
|
+
if (!container) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
84
|
+
this.options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;
|
|
85
|
+
this.options.increment =
|
|
86
|
+
sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;
|
|
87
|
+
this.options.width = container.canvas.size.width;
|
|
88
|
+
this.options.height = container.canvas.size.height;
|
|
89
|
+
const offset = sourceOptions.offset;
|
|
90
|
+
this.options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
91
|
+
this.options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
92
|
+
this.options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
93
|
+
this.options.seed = sourceOptions.seed ?? defaultOptions.seed;
|
|
94
|
+
this._simplex.seed(this.options.seed ?? getRandom());
|
|
95
|
+
this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
|
|
96
|
+
this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
|
|
97
|
+
this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
|
|
98
|
+
this._initField();
|
|
99
|
+
}
|
|
100
|
+
_setup() {
|
|
101
|
+
this.noiseW = 0;
|
|
102
|
+
this._resetField();
|
|
103
|
+
addEventListener("resize", () => this._resetField());
|
|
104
|
+
}
|
|
86
105
|
}
|
|
@@ -2,60 +2,28 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SimplexNoiseGenerator = void 0;
|
|
4
4
|
const engine_1 = require("@tsparticles/engine");
|
|
5
|
-
const
|
|
5
|
+
const simplex_noise_1 = require("@tsparticles/simplex-noise");
|
|
6
|
+
const defaultOptions = {
|
|
7
|
+
size: 20,
|
|
8
|
+
increment: 0.004,
|
|
9
|
+
columns: 0,
|
|
10
|
+
rows: 0,
|
|
11
|
+
layers: 0,
|
|
12
|
+
width: 0,
|
|
13
|
+
height: 0,
|
|
14
|
+
offset: {
|
|
15
|
+
x: 40000,
|
|
16
|
+
y: 40000,
|
|
17
|
+
z: 40000,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
6
20
|
class SimplexNoiseGenerator {
|
|
7
21
|
constructor() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
for (let y = 0; y < this.options.rows; y++) {
|
|
11
|
-
for (let z = 0; z < this.options.layers; z++) {
|
|
12
|
-
this.field[x][y][z][0] = this.noiseFunc(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2;
|
|
13
|
-
this.field[x][y][z][1] = this.noiseFunc(x / 100 + 40000, y / 100 + 40000, z / 100 + 40000, this.noiseW);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
this._initField = () => {
|
|
19
|
-
this.field = new Array(this.options.columns);
|
|
20
|
-
for (let x = 0; x < this.options.columns; x++) {
|
|
21
|
-
this.field[x] = new Array(this.options.rows);
|
|
22
|
-
for (let y = 0; y < this.options.rows; y++) {
|
|
23
|
-
this.field[x][y] = new Array(this.options.layers);
|
|
24
|
-
for (let z = 0; z < this.options.layers; z++) {
|
|
25
|
-
this.field[x][y][z] = [0, 0];
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
this._resetField = (container) => {
|
|
31
|
-
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
32
|
-
this.options.size = sourceOptions.size > 0 ? sourceOptions.size : 20;
|
|
33
|
-
this.options.increment = sourceOptions.increment > 0 ? sourceOptions.increment : 0.004;
|
|
34
|
-
this.options.width = container.canvas.size.width;
|
|
35
|
-
this.options.height = container.canvas.size.height;
|
|
36
|
-
this.noiseFunc = (0, simplex_js_1.makeNoise4D)(sourceOptions.seed ?? (0, engine_1.getRandom)());
|
|
37
|
-
this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
|
|
38
|
-
this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
|
|
39
|
-
this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
|
|
40
|
-
this._initField();
|
|
41
|
-
};
|
|
42
|
-
this._setup = (container) => {
|
|
43
|
-
this.noiseW = 0;
|
|
44
|
-
this._resetField(container);
|
|
45
|
-
addEventListener("resize", () => this._resetField(container));
|
|
46
|
-
};
|
|
22
|
+
const simplex = new simplex_noise_1.SimplexNoise();
|
|
23
|
+
this._simplex = simplex.noise4d;
|
|
47
24
|
this.field = [];
|
|
48
|
-
this.noiseFunc = (0, simplex_js_1.makeNoise4D)((0, engine_1.getRandom)());
|
|
49
25
|
this.noiseW = 0;
|
|
50
|
-
this.options = {
|
|
51
|
-
size: 20,
|
|
52
|
-
increment: 0.004,
|
|
53
|
-
columns: 0,
|
|
54
|
-
rows: 0,
|
|
55
|
-
layers: 0,
|
|
56
|
-
width: 0,
|
|
57
|
-
height: 0,
|
|
58
|
-
};
|
|
26
|
+
this.options = (0, engine_1.deepExtend)({}, defaultOptions);
|
|
59
27
|
}
|
|
60
28
|
generate(particle) {
|
|
61
29
|
const pos = particle.getPosition(), point = {
|
|
@@ -69,13 +37,14 @@ class SimplexNoiseGenerator {
|
|
|
69
37
|
!this.field[point.x][point.y][point.z]) {
|
|
70
38
|
return v;
|
|
71
39
|
}
|
|
72
|
-
|
|
73
|
-
v.
|
|
40
|
+
const cell = this.field[point.x][point.y][point.z];
|
|
41
|
+
v.length = cell[1];
|
|
42
|
+
v.angle = cell[0];
|
|
74
43
|
return v;
|
|
75
44
|
}
|
|
76
45
|
init(container) {
|
|
77
46
|
this.container = container;
|
|
78
|
-
this._setup(
|
|
47
|
+
this._setup();
|
|
79
48
|
}
|
|
80
49
|
reset() {
|
|
81
50
|
}
|
|
@@ -86,5 +55,55 @@ class SimplexNoiseGenerator {
|
|
|
86
55
|
this._calculateField();
|
|
87
56
|
this.noiseW += this.options.increment;
|
|
88
57
|
}
|
|
58
|
+
_calculateField() {
|
|
59
|
+
const options = this.options;
|
|
60
|
+
for (let x = 0; x < options.columns; x++) {
|
|
61
|
+
for (let y = 0; y < options.rows; y++) {
|
|
62
|
+
for (let z = 0; z < options.layers; z++) {
|
|
63
|
+
this.field[x][y][z][0] = this._simplex.noise(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2;
|
|
64
|
+
this.field[x][y][z][1] = this._simplex.noise(x / 100 + options.offset.x, y / 100 + options.offset.y, z / 100 + options.offset.z, this.noiseW);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
_initField() {
|
|
70
|
+
this.field = new Array(this.options.columns);
|
|
71
|
+
for (let x = 0; x < this.options.columns; x++) {
|
|
72
|
+
this.field[x] = new Array(this.options.rows);
|
|
73
|
+
for (let y = 0; y < this.options.rows; y++) {
|
|
74
|
+
this.field[x][y] = new Array(this.options.layers);
|
|
75
|
+
for (let z = 0; z < this.options.layers; z++) {
|
|
76
|
+
this.field[x][y][z] = [0, 0];
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
_resetField() {
|
|
82
|
+
const container = this.container;
|
|
83
|
+
if (!container) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
87
|
+
this.options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;
|
|
88
|
+
this.options.increment =
|
|
89
|
+
sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;
|
|
90
|
+
this.options.width = container.canvas.size.width;
|
|
91
|
+
this.options.height = container.canvas.size.height;
|
|
92
|
+
const offset = sourceOptions.offset;
|
|
93
|
+
this.options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
94
|
+
this.options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
95
|
+
this.options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
96
|
+
this.options.seed = sourceOptions.seed ?? defaultOptions.seed;
|
|
97
|
+
this._simplex.seed(this.options.seed ?? (0, engine_1.getRandom)());
|
|
98
|
+
this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
|
|
99
|
+
this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
|
|
100
|
+
this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
|
|
101
|
+
this._initField();
|
|
102
|
+
}
|
|
103
|
+
_setup() {
|
|
104
|
+
this.noiseW = 0;
|
|
105
|
+
this._resetField();
|
|
106
|
+
addEventListener("resize", () => this._resetField());
|
|
107
|
+
}
|
|
89
108
|
}
|
|
90
109
|
exports.SimplexNoiseGenerator = SimplexNoiseGenerator;
|
|
@@ -1,58 +1,26 @@
|
|
|
1
|
-
import { Vector, getRandom } from "@tsparticles/engine";
|
|
2
|
-
import {
|
|
1
|
+
import { Vector, deepExtend, getRandom, } from "@tsparticles/engine";
|
|
2
|
+
import { SimplexNoise } from "@tsparticles/simplex-noise";
|
|
3
|
+
const defaultOptions = {
|
|
4
|
+
size: 20,
|
|
5
|
+
increment: 0.004,
|
|
6
|
+
columns: 0,
|
|
7
|
+
rows: 0,
|
|
8
|
+
layers: 0,
|
|
9
|
+
width: 0,
|
|
10
|
+
height: 0,
|
|
11
|
+
offset: {
|
|
12
|
+
x: 40000,
|
|
13
|
+
y: 40000,
|
|
14
|
+
z: 40000,
|
|
15
|
+
},
|
|
16
|
+
};
|
|
3
17
|
export class SimplexNoiseGenerator {
|
|
4
18
|
constructor() {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
for (let y = 0; y < this.options.rows; y++) {
|
|
8
|
-
for (let z = 0; z < this.options.layers; z++) {
|
|
9
|
-
this.field[x][y][z][0] = this.noiseFunc(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2;
|
|
10
|
-
this.field[x][y][z][1] = this.noiseFunc(x / 100 + 40000, y / 100 + 40000, z / 100 + 40000, this.noiseW);
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
this._initField = () => {
|
|
16
|
-
this.field = new Array(this.options.columns);
|
|
17
|
-
for (let x = 0; x < this.options.columns; x++) {
|
|
18
|
-
this.field[x] = new Array(this.options.rows);
|
|
19
|
-
for (let y = 0; y < this.options.rows; y++) {
|
|
20
|
-
this.field[x][y] = new Array(this.options.layers);
|
|
21
|
-
for (let z = 0; z < this.options.layers; z++) {
|
|
22
|
-
this.field[x][y][z] = [0, 0];
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
this._resetField = (container) => {
|
|
28
|
-
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
29
|
-
this.options.size = sourceOptions.size > 0 ? sourceOptions.size : 20;
|
|
30
|
-
this.options.increment = sourceOptions.increment > 0 ? sourceOptions.increment : 0.004;
|
|
31
|
-
this.options.width = container.canvas.size.width;
|
|
32
|
-
this.options.height = container.canvas.size.height;
|
|
33
|
-
this.noiseFunc = makeNoise4D(sourceOptions.seed ?? getRandom());
|
|
34
|
-
this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
|
|
35
|
-
this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
|
|
36
|
-
this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
|
|
37
|
-
this._initField();
|
|
38
|
-
};
|
|
39
|
-
this._setup = (container) => {
|
|
40
|
-
this.noiseW = 0;
|
|
41
|
-
this._resetField(container);
|
|
42
|
-
addEventListener("resize", () => this._resetField(container));
|
|
43
|
-
};
|
|
19
|
+
const simplex = new SimplexNoise();
|
|
20
|
+
this._simplex = simplex.noise4d;
|
|
44
21
|
this.field = [];
|
|
45
|
-
this.noiseFunc = makeNoise4D(getRandom());
|
|
46
22
|
this.noiseW = 0;
|
|
47
|
-
this.options = {
|
|
48
|
-
size: 20,
|
|
49
|
-
increment: 0.004,
|
|
50
|
-
columns: 0,
|
|
51
|
-
rows: 0,
|
|
52
|
-
layers: 0,
|
|
53
|
-
width: 0,
|
|
54
|
-
height: 0,
|
|
55
|
-
};
|
|
23
|
+
this.options = deepExtend({}, defaultOptions);
|
|
56
24
|
}
|
|
57
25
|
generate(particle) {
|
|
58
26
|
const pos = particle.getPosition(), point = {
|
|
@@ -66,13 +34,14 @@ export class SimplexNoiseGenerator {
|
|
|
66
34
|
!this.field[point.x][point.y][point.z]) {
|
|
67
35
|
return v;
|
|
68
36
|
}
|
|
69
|
-
|
|
70
|
-
v.
|
|
37
|
+
const cell = this.field[point.x][point.y][point.z];
|
|
38
|
+
v.length = cell[1];
|
|
39
|
+
v.angle = cell[0];
|
|
71
40
|
return v;
|
|
72
41
|
}
|
|
73
42
|
init(container) {
|
|
74
43
|
this.container = container;
|
|
75
|
-
this._setup(
|
|
44
|
+
this._setup();
|
|
76
45
|
}
|
|
77
46
|
reset() {
|
|
78
47
|
}
|
|
@@ -83,4 +52,54 @@ export class SimplexNoiseGenerator {
|
|
|
83
52
|
this._calculateField();
|
|
84
53
|
this.noiseW += this.options.increment;
|
|
85
54
|
}
|
|
55
|
+
_calculateField() {
|
|
56
|
+
const options = this.options;
|
|
57
|
+
for (let x = 0; x < options.columns; x++) {
|
|
58
|
+
for (let y = 0; y < options.rows; y++) {
|
|
59
|
+
for (let z = 0; z < options.layers; z++) {
|
|
60
|
+
this.field[x][y][z][0] = this._simplex.noise(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2;
|
|
61
|
+
this.field[x][y][z][1] = this._simplex.noise(x / 100 + options.offset.x, y / 100 + options.offset.y, z / 100 + options.offset.z, this.noiseW);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
_initField() {
|
|
67
|
+
this.field = new Array(this.options.columns);
|
|
68
|
+
for (let x = 0; x < this.options.columns; x++) {
|
|
69
|
+
this.field[x] = new Array(this.options.rows);
|
|
70
|
+
for (let y = 0; y < this.options.rows; y++) {
|
|
71
|
+
this.field[x][y] = new Array(this.options.layers);
|
|
72
|
+
for (let z = 0; z < this.options.layers; z++) {
|
|
73
|
+
this.field[x][y][z] = [0, 0];
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
_resetField() {
|
|
79
|
+
const container = this.container;
|
|
80
|
+
if (!container) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const sourceOptions = container.actualOptions.particles.move.path.options;
|
|
84
|
+
this.options.size = sourceOptions.size > 0 ? sourceOptions.size : defaultOptions.size;
|
|
85
|
+
this.options.increment =
|
|
86
|
+
sourceOptions.increment > 0 ? sourceOptions.increment : defaultOptions.increment;
|
|
87
|
+
this.options.width = container.canvas.size.width;
|
|
88
|
+
this.options.height = container.canvas.size.height;
|
|
89
|
+
const offset = sourceOptions.offset;
|
|
90
|
+
this.options.offset.x = offset?.x ?? defaultOptions.offset.x;
|
|
91
|
+
this.options.offset.y = offset?.y ?? defaultOptions.offset.y;
|
|
92
|
+
this.options.offset.z = offset?.z ?? defaultOptions.offset.z;
|
|
93
|
+
this.options.seed = sourceOptions.seed ?? defaultOptions.seed;
|
|
94
|
+
this._simplex.seed(this.options.seed ?? getRandom());
|
|
95
|
+
this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
|
|
96
|
+
this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
|
|
97
|
+
this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
|
|
98
|
+
this._initField();
|
|
99
|
+
}
|
|
100
|
+
_setup() {
|
|
101
|
+
this.noiseW = 0;
|
|
102
|
+
this._resetField();
|
|
103
|
+
addEventListener("resize", () => this._resetField());
|
|
104
|
+
}
|
|
86
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tsparticles/path-simplex-noise",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.4",
|
|
4
4
|
"description": "tsParticles simplex noise path",
|
|
5
5
|
"homepage": "https://particles.js.org",
|
|
6
6
|
"repository": {
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"confettijs",
|
|
61
61
|
"fireworksjs",
|
|
62
62
|
"canvas-confetti",
|
|
63
|
-
"
|
|
64
|
-
"
|
|
63
|
+
"tsparticles-plugin",
|
|
64
|
+
"tsparticles-path"
|
|
65
65
|
],
|
|
66
66
|
"publishConfig": {
|
|
67
67
|
"access": "public"
|
|
@@ -104,6 +104,7 @@
|
|
|
104
104
|
"./package.json": "./package.json"
|
|
105
105
|
},
|
|
106
106
|
"dependencies": {
|
|
107
|
-
"@tsparticles/engine": "^3.0.0-beta.
|
|
107
|
+
"@tsparticles/engine": "^3.0.0-beta.4",
|
|
108
|
+
"@tsparticles/simplex-noise": "^3.0.0-beta.4"
|
|
108
109
|
}
|
|
109
110
|
}
|