@tsparticles/path-simplex-noise 3.0.0-alpha.1 → 3.0.0-beta.1

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.
@@ -2,12 +2,50 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SimplexNoiseGenerator = void 0;
4
4
  const engine_1 = require("@tsparticles/engine");
5
- const engine_2 = require("@tsparticles/engine");
6
- const simplex_1 = require("./simplex");
5
+ const simplex_js_1 = require("./simplex.js");
7
6
  class SimplexNoiseGenerator {
8
7
  constructor() {
8
+ this._calculateField = () => {
9
+ for (let x = 0; x < this.options.columns; x++) {
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
+ };
9
47
  this.field = [];
10
- this.noiseFunc = (0, simplex_1.makeNoise4D)((0, engine_2.getRandom)());
48
+ this.noiseFunc = (0, simplex_js_1.makeNoise4D)((0, engine_1.getRandom)());
11
49
  this.noiseW = 0;
12
50
  this.options = {
13
51
  size: 20,
@@ -37,7 +75,7 @@ class SimplexNoiseGenerator {
37
75
  }
38
76
  init(container) {
39
77
  this.container = container;
40
- this.setup(this.container);
78
+ this._setup(this.container);
41
79
  }
42
80
  reset() {
43
81
  }
@@ -45,49 +83,8 @@ class SimplexNoiseGenerator {
45
83
  if (!this.container) {
46
84
  return;
47
85
  }
48
- this.calculateField();
86
+ this._calculateField();
49
87
  this.noiseW += this.options.increment;
50
88
  }
51
- calculateField() {
52
- for (let x = 0; x < this.options.columns; x++) {
53
- for (let y = 0; y < this.options.rows; y++) {
54
- for (let z = 0; z < this.options.layers; z++) {
55
- const angle = this.noiseFunc(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2, length = this.noiseFunc(x / 100 + 40000, y / 100 + 40000, z / 100 + 40000, this.noiseW);
56
- this.field[x][y][z][0] = angle;
57
- this.field[x][y][z][1] = length;
58
- }
59
- }
60
- }
61
- }
62
- initField() {
63
- this.field = new Array(this.options.columns);
64
- for (let x = 0; x < this.options.columns; x++) {
65
- this.field[x] = new Array(this.options.rows);
66
- for (let y = 0; y < this.options.rows; y++) {
67
- this.field[x][y] = new Array(this.options.layers);
68
- for (let z = 0; z < this.options.layers; z++) {
69
- this.field[x][y][z] = [0, 0];
70
- }
71
- }
72
- }
73
- }
74
- resetField(container) {
75
- var _a;
76
- const sourceOptions = container.actualOptions.particles.move.path.options;
77
- this.options.size = sourceOptions.size > 0 ? sourceOptions.size : 20;
78
- this.options.increment = sourceOptions.increment > 0 ? sourceOptions.increment : 0.004;
79
- this.options.width = container.canvas.size.width;
80
- this.options.height = container.canvas.size.height;
81
- this.noiseFunc = (0, simplex_1.makeNoise4D)((_a = sourceOptions.seed) !== null && _a !== void 0 ? _a : (0, engine_2.getRandom)());
82
- this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
83
- this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
84
- this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
85
- this.initField();
86
- }
87
- setup(container) {
88
- this.noiseW = 0;
89
- this.resetField(container);
90
- addEventListener("resize", () => this.resetField(container));
91
- }
92
89
  }
93
90
  exports.SimplexNoiseGenerator = SimplexNoiseGenerator;
package/cjs/index.js CHANGED
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadSimplexNoisePath = exports.simplexNoisePathName = void 0;
4
- const SimplexNoiseGenerator_1 = require("./SimplexNoiseGenerator");
4
+ const SimplexNoiseGenerator_js_1 = require("./SimplexNoiseGenerator.js");
5
5
  exports.simplexNoisePathName = "simplexNoise";
6
- function loadSimplexNoisePath(engine) {
7
- engine.addPathGenerator(exports.simplexNoisePathName, new SimplexNoiseGenerator_1.SimplexNoiseGenerator());
6
+ async function loadSimplexNoisePath(engine, refresh = true) {
7
+ await engine.addPathGenerator(exports.simplexNoisePathName, new SimplexNoiseGenerator_js_1.SimplexNoiseGenerator(), refresh);
8
8
  }
9
9
  exports.loadSimplexNoisePath = loadSimplexNoisePath;
@@ -0,0 +1 @@
1
+ { "type": "commonjs" }
package/cjs/simplex.js CHANGED
@@ -7,9 +7,7 @@ function shuffleSeed(seed) {
7
7
  return newSeed;
8
8
  }
9
9
  exports.default = shuffleSeed;
10
- const NORM_4D = 1.0 / 30.0;
11
- const SQUISH_4D = (Math.sqrt(4 + 1) - 1) / 4;
12
- const STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) / 4;
10
+ const NORM_4D = 1.0 / 30.0, SQUISH_4D = (Math.sqrt(4 + 1) - 1) / 4, STRETCH_4D = (1 / Math.sqrt(4 + 1) - 1) / 4;
13
11
  function contribution4D(multiplier, xsb, ysb, zsb, wsb) {
14
12
  return {
15
13
  dx: -xsb - multiplier * SQUISH_4D,
@@ -26,8 +24,7 @@ function makeNoise4D(clientSeed) {
26
24
  const contributions = [];
27
25
  for (let i = 0; i < p4D.length; i += 16) {
28
26
  const baseSet = base4D[p4D[i]];
29
- let previous = null;
30
- let current = null;
27
+ let previous = null, current = null;
31
28
  for (let k = 0; k < baseSet.length; k += 5) {
32
29
  current = contribution4D(baseSet[k], baseSet[k + 1], baseSet[k + 2], baseSet[k + 3], baseSet[k + 4]);
33
30
  if (previous === null) {
@@ -48,11 +45,10 @@ function makeNoise4D(clientSeed) {
48
45
  for (let i = 0; i < lookupPairs4D.length; i += 2) {
49
46
  lookup[lookupPairs4D[i]] = contributions[lookupPairs4D[i + 1]];
50
47
  }
51
- const perm = new Uint8Array(256);
52
- const perm4D = new Uint8Array(256);
53
- const source = new Uint8Array(256);
54
- for (let i = 0; i < 256; i++)
48
+ const perm = new Uint8Array(256), perm4D = new Uint8Array(256), source = new Uint8Array(256);
49
+ for (let i = 0; i < 256; i++) {
55
50
  source[i] = i;
51
+ }
56
52
  let seed = new Uint32Array(1);
57
53
  seed[0] = clientSeed;
58
54
  seed = shuffleSeed(shuffleSeed(shuffleSeed(seed)));
@@ -60,33 +56,15 @@ function makeNoise4D(clientSeed) {
60
56
  seed = shuffleSeed(seed);
61
57
  const r = new Uint32Array(1);
62
58
  r[0] = (seed[0] + 31) % (i + 1);
63
- if (r[0] < 0)
59
+ if (r[0] < 0) {
64
60
  r[0] += i + 1;
61
+ }
65
62
  perm[i] = source[r[0]];
66
63
  perm4D[i] = perm[i] & 0xfc;
67
64
  source[r[0]] = source[i];
68
65
  }
69
66
  return (x, y, z, w) => {
70
- const stretchOffset = (x + y + z + w) * STRETCH_4D;
71
- const xs = x + stretchOffset;
72
- const ys = y + stretchOffset;
73
- const zs = z + stretchOffset;
74
- const ws = w + stretchOffset;
75
- const xsb = Math.floor(xs);
76
- const ysb = Math.floor(ys);
77
- const zsb = Math.floor(zs);
78
- const wsb = Math.floor(ws);
79
- const squishOffset = (xsb + ysb + zsb + wsb) * SQUISH_4D;
80
- const dx0 = x - (xsb + squishOffset);
81
- const dy0 = y - (ysb + squishOffset);
82
- const dz0 = z - (zsb + squishOffset);
83
- const dw0 = w - (wsb + squishOffset);
84
- const xins = xs - xsb;
85
- const yins = ys - ysb;
86
- const zins = zs - zsb;
87
- const wins = ws - wsb;
88
- const inSum = xins + yins + zins + wins;
89
- const hash = (zins - wins + 1) |
67
+ const stretchOffset = (x + y + z + w) * STRETCH_4D, xs = x + stretchOffset, ys = y + stretchOffset, zs = z + stretchOffset, ws = w + stretchOffset, xsb = Math.floor(xs), ysb = Math.floor(ys), zsb = Math.floor(zs), wsb = Math.floor(ws), squishOffset = (xsb + ysb + zsb + wsb) * SQUISH_4D, dx0 = x - (xsb + squishOffset), dy0 = y - (ysb + squishOffset), dz0 = z - (zsb + squishOffset), dw0 = w - (wsb + squishOffset), xins = xs - xsb, yins = ys - ysb, zins = zs - zsb, wins = ws - wsb, inSum = xins + yins + zins + wins, hash = (zins - wins + 1) |
90
68
  ((yins - zins + 1) << 1) |
91
69
  ((yins - wins + 1) << 2) |
92
70
  ((xins - yins + 1) << 3) |
@@ -99,21 +77,9 @@ function makeNoise4D(clientSeed) {
99
77
  ((inSum + xins) << 17);
100
78
  let value = 0;
101
79
  for (let c = lookup[hash]; c !== undefined; c = c.next) {
102
- const dx = dx0 + c.dx;
103
- const dy = dy0 + c.dy;
104
- const dz = dz0 + c.dz;
105
- const dw = dw0 + c.dw;
106
- const attn = 2 - dx * dx - dy * dy - dz * dz - dw * dw;
80
+ const dx = dx0 + c.dx, dy = dy0 + c.dy, dz = dz0 + c.dz, dw = dw0 + c.dw, attn = 2 - dx * dx - dy * dy - dz * dz - dw * dw;
107
81
  if (attn > 0) {
108
- const px = xsb + c.xsb;
109
- const py = ysb + c.ysb;
110
- const pz = zsb + c.zsb;
111
- const pw = wsb + c.wsb;
112
- const indexPartA = perm[px & 0xff];
113
- const indexPartB = perm[(indexPartA + py) & 0xff];
114
- const indexPartC = perm[(indexPartB + pz) & 0xff];
115
- const index = perm4D[(indexPartC + pw) & 0xff];
116
- const valuePart = gradients4D[index] * dx +
82
+ const px = xsb + c.xsb, py = ysb + c.ysb, pz = zsb + c.zsb, pw = wsb + c.wsb, indexPartA = perm[px & 0xff], indexPartB = perm[(indexPartA + py) & 0xff], indexPartC = perm[(indexPartB + pz) & 0xff], index = perm4D[(indexPartC + pw) & 0xff], valuePart = gradients4D[index] * dx +
117
83
  gradients4D[index + 1] * dy +
118
84
  gradients4D[index + 2] * dz +
119
85
  gradients4D[index + 3] * dw;
@@ -128,115 +94,117 @@ const base4D = [
128
94
  [0, 0, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1],
129
95
  [3, 1, 1, 1, 0, 3, 1, 1, 0, 1, 3, 1, 0, 1, 1, 3, 0, 1, 1, 1, 4, 1, 1, 1, 1],
130
96
  [
131
- 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 2, 1, 1, 0, 0, 2, 1, 0, 1, 0, 2, 1, 0, 0, 1, 2, 0,
132
- 1, 1, 0, 2, 0, 1, 0, 1, 2, 0, 0, 1, 1,
97
+ 1, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 0, 0, 0, 1, 2, 1, 1, 0, 0, 2, 1, 0, 1, 0, 2, 1, 0, 0, 1, 2,
98
+ 0, 1, 1, 0, 2, 0, 1, 0, 1, 2, 0, 0, 1, 1,
133
99
  ],
134
100
  [
135
- 3, 1, 1, 1, 0, 3, 1, 1, 0, 1, 3, 1, 0, 1, 1, 3, 0, 1, 1, 1, 2, 1, 1, 0, 0, 2, 1, 0, 1, 0, 2, 1, 0, 0, 1, 2, 0,
136
- 1, 1, 0, 2, 0, 1, 0, 1, 2, 0, 0, 1, 1,
101
+ 3, 1, 1, 1, 0, 3, 1, 1, 0, 1, 3, 1, 0, 1, 1, 3, 0, 1, 1, 1, 2, 1, 1, 0, 0, 2, 1, 0, 1, 0, 2, 1, 0, 0, 1, 2,
102
+ 0, 1, 1, 0, 2, 0, 1, 0, 1, 2, 0, 0, 1, 1,
137
103
  ],
138
- ];
139
- const gradients4D = [
140
- 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, -3, 1, 1, 1, -1, 3, 1, 1, -1, 1, 3, 1, -1, 1, 1, 3, 3, -1, 1, 1, 1,
141
- -3, 1, 1, 1, -1, 3, 1, 1, -1, 1, 3, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, 3, 1, -1, 1, 1, 3, -1,
142
- 1, 1, 1, -3, 1, 1, 1, -1, 3, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3, 3, -1, -1, 1, 1, -3, -1, 1, 1,
143
- -1, -3, 1, 1, -1, -1, 3, -3, -1, -1, 1, -1, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, 3, 1, 1, -1, 1, 3, 1, -1, 1, 1,
144
- 3, -1, 1, 1, 1, -3, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, -1, -1, 1, 1, -3, 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3,
145
- -1, 1, -1, 1, -3, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, 3, 1, -1, -1, 1, 3, -1, -1, 1, 1, -3,
146
- -1, 1, 1, -1, -3, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, -1, -1, 1, -1, -3, 3, -1, -1, -1, 1, -3, -1, -1, 1, -1,
147
- -3, -1, 1, -1, -1, -3, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3,
148
- ];
149
- const lookupPairs4D = [
150
- 0, 3, 1, 2, 2, 3, 5, 2, 6, 1, 7, 1, 8, 3, 9, 2, 10, 3, 13, 2, 16, 3, 18, 3, 22, 1, 23, 1, 24, 3, 26, 3, 33, 2, 37,
151
- 2, 38, 1, 39, 1, 41, 2, 45, 2, 54, 1, 55, 1, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 256, 3, 258, 3,
152
- 264, 3, 266, 3, 272, 3, 274, 3, 280, 3, 282, 3, 2049, 2, 2053, 2, 2057, 2, 2061, 2, 2081, 2, 2085, 2, 2089, 2, 2093,
153
- 2, 2304, 9, 2305, 9, 2312, 9, 2313, 9, 16390, 1, 16391, 1, 16406, 1, 16407, 1, 16422, 1, 16423, 1, 16438, 1, 16439,
154
- 1, 16642, 8, 16646, 8, 16658, 8, 16662, 8, 18437, 6, 18439, 6, 18469, 6, 18471, 6, 18688, 9, 18689, 9, 18690, 8,
155
- 18693, 6, 18694, 8, 18695, 6, 18696, 9, 18697, 9, 18706, 8, 18710, 8, 18725, 6, 18727, 6, 131128, 0, 131129, 0,
156
- 131130, 0, 131131, 0, 131132, 0, 131133, 0, 131134, 0, 131135, 0, 131352, 7, 131354, 7, 131384, 7, 131386, 7,
157
- 133161, 5, 133165, 5, 133177, 5, 133181, 5, 133376, 9, 133377, 9, 133384, 9, 133385, 9, 133400, 7, 133402, 7,
158
- 133417, 5, 133421, 5, 133432, 7, 133433, 5, 133434, 7, 133437, 5, 147510, 4, 147511, 4, 147518, 4, 147519, 4,
159
- 147714, 8, 147718, 8, 147730, 8, 147734, 8, 147736, 7, 147738, 7, 147766, 4, 147767, 4, 147768, 7, 147770, 7,
160
- 147774, 4, 147775, 4, 149509, 6, 149511, 6, 149541, 6, 149543, 6, 149545, 5, 149549, 5, 149558, 4, 149559, 4,
161
- 149561, 5, 149565, 5, 149566, 4, 149567, 4, 149760, 9, 149761, 9, 149762, 8, 149765, 6, 149766, 8, 149767, 6,
162
- 149768, 9, 149769, 9, 149778, 8, 149782, 8, 149784, 7, 149786, 7, 149797, 6, 149799, 6, 149801, 5, 149805, 5,
163
- 149814, 4, 149815, 4, 149816, 7, 149817, 5, 149818, 7, 149821, 5, 149822, 4, 149823, 4, 149824, 37, 149825, 37,
164
- 149826, 36, 149829, 34, 149830, 36, 149831, 34, 149832, 37, 149833, 37, 149842, 36, 149846, 36, 149848, 35, 149850,
165
- 35, 149861, 34, 149863, 34, 149865, 33, 149869, 33, 149878, 32, 149879, 32, 149880, 35, 149881, 33, 149882, 35,
166
- 149885, 33, 149886, 32, 149887, 32, 150080, 49, 150082, 48, 150088, 49, 150098, 48, 150104, 47, 150106, 47, 151873,
167
- 46, 151877, 45, 151881, 46, 151909, 45, 151913, 44, 151917, 44, 152128, 49, 152129, 46, 152136, 49, 152137, 46,
168
- 166214, 43, 166215, 42, 166230, 43, 166247, 42, 166262, 41, 166263, 41, 166466, 48, 166470, 43, 166482, 48, 166486,
169
- 43, 168261, 45, 168263, 42, 168293, 45, 168295, 42, 168512, 31, 168513, 28, 168514, 31, 168517, 28, 168518, 25,
170
- 168519, 25, 280952, 40, 280953, 39, 280954, 40, 280957, 39, 280958, 38, 280959, 38, 281176, 47, 281178, 47, 281208,
171
- 40, 281210, 40, 282985, 44, 282989, 44, 283001, 39, 283005, 39, 283208, 30, 283209, 27, 283224, 30, 283241, 27,
172
- 283256, 22, 283257, 22, 297334, 41, 297335, 41, 297342, 38, 297343, 38, 297554, 29, 297558, 24, 297562, 29, 297590,
173
- 24, 297594, 21, 297598, 21, 299365, 26, 299367, 23, 299373, 26, 299383, 23, 299389, 20, 299391, 20, 299584, 31,
174
- 299585, 28, 299586, 31, 299589, 28, 299590, 25, 299591, 25, 299592, 30, 299593, 27, 299602, 29, 299606, 24, 299608,
175
- 30, 299610, 29, 299621, 26, 299623, 23, 299625, 27, 299629, 26, 299638, 24, 299639, 23, 299640, 22, 299641, 22,
176
- 299642, 21, 299645, 20, 299646, 21, 299647, 20, 299648, 61, 299649, 60, 299650, 61, 299653, 60, 299654, 59, 299655,
177
- 59, 299656, 58, 299657, 57, 299666, 55, 299670, 54, 299672, 58, 299674, 55, 299685, 52, 299687, 51, 299689, 57,
178
- 299693, 52, 299702, 54, 299703, 51, 299704, 56, 299705, 56, 299706, 53, 299709, 50, 299710, 53, 299711, 50, 299904,
179
- 61, 299906, 61, 299912, 58, 299922, 55, 299928, 58, 299930, 55, 301697, 60, 301701, 60, 301705, 57, 301733, 52,
180
- 301737, 57, 301741, 52, 301952, 79, 301953, 79, 301960, 76, 301961, 76, 316038, 59, 316039, 59, 316054, 54, 316071,
181
- 51, 316086, 54, 316087, 51, 316290, 78, 316294, 78, 316306, 73, 316310, 73, 318085, 77, 318087, 77, 318117, 70,
182
- 318119, 70, 318336, 79, 318337, 79, 318338, 78, 318341, 77, 318342, 78, 318343, 77, 430776, 56, 430777, 56, 430778,
183
- 53, 430781, 50, 430782, 53, 430783, 50, 431000, 75, 431002, 72, 431032, 75, 431034, 72, 432809, 74, 432813, 69,
184
- 432825, 74, 432829, 69, 433032, 76, 433033, 76, 433048, 75, 433065, 74, 433080, 75, 433081, 74, 447158, 71, 447159,
185
- 68, 447166, 71, 447167, 68, 447378, 73, 447382, 73, 447386, 72, 447414, 71, 447418, 72, 447422, 71, 449189, 70,
186
- 449191, 70, 449197, 69, 449207, 68, 449213, 69, 449215, 68, 449408, 67, 449409, 67, 449410, 66, 449413, 64, 449414,
187
- 66, 449415, 64, 449416, 67, 449417, 67, 449426, 66, 449430, 66, 449432, 65, 449434, 65, 449445, 64, 449447, 64,
188
- 449449, 63, 449453, 63, 449462, 62, 449463, 62, 449464, 65, 449465, 63, 449466, 65, 449469, 63, 449470, 62, 449471,
189
- 62, 449472, 19, 449473, 19, 449474, 18, 449477, 16, 449478, 18, 449479, 16, 449480, 19, 449481, 19, 449490, 18,
190
- 449494, 18, 449496, 17, 449498, 17, 449509, 16, 449511, 16, 449513, 15, 449517, 15, 449526, 14, 449527, 14, 449528,
191
- 17, 449529, 15, 449530, 17, 449533, 15, 449534, 14, 449535, 14, 449728, 19, 449729, 19, 449730, 18, 449734, 18,
192
- 449736, 19, 449737, 19, 449746, 18, 449750, 18, 449752, 17, 449754, 17, 449784, 17, 449786, 17, 451520, 19, 451521,
193
- 19, 451525, 16, 451527, 16, 451528, 19, 451529, 19, 451557, 16, 451559, 16, 451561, 15, 451565, 15, 451577, 15,
194
- 451581, 15, 451776, 19, 451777, 19, 451784, 19, 451785, 19, 465858, 18, 465861, 16, 465862, 18, 465863, 16, 465874,
195
- 18, 465878, 18, 465893, 16, 465895, 16, 465910, 14, 465911, 14, 465918, 14, 465919, 14, 466114, 18, 466118, 18,
196
- 466130, 18, 466134, 18, 467909, 16, 467911, 16, 467941, 16, 467943, 16, 468160, 13, 468161, 13, 468162, 13, 468163,
197
- 13, 468164, 13, 468165, 13, 468166, 13, 468167, 13, 580568, 17, 580570, 17, 580585, 15, 580589, 15, 580598, 14,
198
- 580599, 14, 580600, 17, 580601, 15, 580602, 17, 580605, 15, 580606, 14, 580607, 14, 580824, 17, 580826, 17, 580856,
199
- 17, 580858, 17, 582633, 15, 582637, 15, 582649, 15, 582653, 15, 582856, 12, 582857, 12, 582872, 12, 582873, 12,
200
- 582888, 12, 582889, 12, 582904, 12, 582905, 12, 596982, 14, 596983, 14, 596990, 14, 596991, 14, 597202, 11, 597206,
201
- 11, 597210, 11, 597214, 11, 597234, 11, 597238, 11, 597242, 11, 597246, 11, 599013, 10, 599015, 10, 599021, 10,
202
- 599023, 10, 599029, 10, 599031, 10, 599037, 10, 599039, 10, 599232, 13, 599233, 13, 599234, 13, 599235, 13, 599236,
203
- 13, 599237, 13, 599238, 13, 599239, 13, 599240, 12, 599241, 12, 599250, 11, 599254, 11, 599256, 12, 599257, 12,
204
- 599258, 11, 599262, 11, 599269, 10, 599271, 10, 599272, 12, 599273, 12, 599277, 10, 599279, 10, 599282, 11, 599285,
205
- 10, 599286, 11, 599287, 10, 599288, 12, 599289, 12, 599290, 11, 599293, 10, 599294, 11, 599295, 10,
206
- ];
207
- const p4D = [
208
- 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, -1, 0,
209
- 1, 0, 0, 0, -1, 1, 0, 0, 0, 0, 1, -1, 0, 0, -1, 0, 0, 1, 0, 0, -1, 0, 1, 0, 0, 0, -1, 1, 0, 2, 1, 1, 0, 0, 1, 1, 1,
210
- -1, 0, 1, 1, 1, 0, -1, 0, 2, 1, 0, 1, 0, 1, 1, -1, 1, 0, 1, 1, 0, 1, -1, 0, 2, 0, 1, 1, 0, 1, -1, 1, 1, 0, 1, 0, 1,
211
- 1, -1, 0, 2, 1, 0, 0, 1, 1, 1, -1, 0, 1, 1, 1, 0, -1, 1, 0, 2, 0, 1, 0, 1, 1, -1, 1, 0, 1, 1, 0, 1, -1, 1, 0, 2, 0,
212
- 0, 1, 1, 1, -1, 0, 1, 1, 1, 0, -1, 1, 1, 1, 4, 2, 1, 1, 0, 4, 1, 2, 1, 0, 4, 1, 1, 2, 0, 1, 4, 2, 1, 0, 1, 4, 1, 2,
213
- 0, 1, 4, 1, 1, 0, 2, 1, 4, 2, 0, 1, 1, 4, 1, 0, 2, 1, 4, 1, 0, 1, 2, 1, 4, 0, 2, 1, 1, 4, 0, 1, 2, 1, 4, 0, 1, 1, 2,
214
- 1, 2, 1, 1, 0, 0, 3, 2, 1, 0, 0, 3, 1, 2, 0, 0, 1, 2, 1, 0, 1, 0, 3, 2, 0, 1, 0, 3, 1, 0, 2, 0, 1, 2, 0, 1, 1, 0, 3,
215
- 0, 2, 1, 0, 3, 0, 1, 2, 0, 1, 2, 1, 0, 0, 1, 3, 2, 0, 0, 1, 3, 1, 0, 0, 2, 1, 2, 0, 1, 0, 1, 3, 0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105
+ 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, 1, 1, 1, 1, 3, -3, 1, 1, 1, -1, 3, 1, 1, -1, 1, 3, 1, -1, 1, 1, 3, 3, -1, 1, 1,
106
+ 1, -3, 1, 1, 1, -1, 3, 1, 1, -1, 1, 3, -3, -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, 3, 1, -1, 1, 1,
107
+ 3, -1, 1, 1, 1, -3, 1, 1, 1, -1, 3, -3, 1, -1, 1, -1, 3, -1, 1, -1, 1, -3, 1, -1, 1, -1, 3, 3, -1, -1, 1, 1, -3,
108
+ -1, 1, 1, -1, -3, 1, 1, -1, -1, 3, -3, -1, -1, 1, -1, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, 3, 1, 1, -1, 1,
109
+ 3, 1, -1, 1, 1, 3, -1, 1, 1, 1, -3, -3, 1, 1, -1, -1, 3, 1, -1, -1, 1, 3, -1, -1, 1, 1, -3, 3, -1, 1, -1, 1, -3,
110
+ 1, -1, 1, -1, 3, -1, 1, -1, 1, -3, -3, -1, 1, -1, -1, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, 3, 1, -1, -1, 1,
111
+ 3, -1, -1, 1, 1, -3, -1, 1, 1, -1, -3, -3, 1, -1, -1, -1, 3, -1, -1, -1, 1, -3, -1, -1, 1, -1, -3, 3, -1, -1,
112
+ -1, 1, -3, -1, -1, 1, -1, -3, -1, 1, -1, -1, -3, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3, -1, -1, -1, -1, -3,
113
+ ], lookupPairs4D = [
114
+ 0, 3, 1, 2, 2, 3, 5, 2, 6, 1, 7, 1, 8, 3, 9, 2, 10, 3, 13, 2, 16, 3, 18, 3, 22, 1, 23, 1, 24, 3, 26, 3, 33, 2,
115
+ 37, 2, 38, 1, 39, 1, 41, 2, 45, 2, 54, 1, 55, 1, 56, 0, 57, 0, 58, 0, 59, 0, 60, 0, 61, 0, 62, 0, 63, 0, 256, 3,
116
+ 258, 3, 264, 3, 266, 3, 272, 3, 274, 3, 280, 3, 282, 3, 2049, 2, 2053, 2, 2057, 2, 2061, 2, 2081, 2, 2085, 2,
117
+ 2089, 2, 2093, 2, 2304, 9, 2305, 9, 2312, 9, 2313, 9, 16390, 1, 16391, 1, 16406, 1, 16407, 1, 16422, 1, 16423,
118
+ 1, 16438, 1, 16439, 1, 16642, 8, 16646, 8, 16658, 8, 16662, 8, 18437, 6, 18439, 6, 18469, 6, 18471, 6, 18688, 9,
119
+ 18689, 9, 18690, 8, 18693, 6, 18694, 8, 18695, 6, 18696, 9, 18697, 9, 18706, 8, 18710, 8, 18725, 6, 18727, 6,
120
+ 131128, 0, 131129, 0, 131130, 0, 131131, 0, 131132, 0, 131133, 0, 131134, 0, 131135, 0, 131352, 7, 131354, 7,
121
+ 131384, 7, 131386, 7, 133161, 5, 133165, 5, 133177, 5, 133181, 5, 133376, 9, 133377, 9, 133384, 9, 133385, 9,
122
+ 133400, 7, 133402, 7, 133417, 5, 133421, 5, 133432, 7, 133433, 5, 133434, 7, 133437, 5, 147510, 4, 147511, 4,
123
+ 147518, 4, 147519, 4, 147714, 8, 147718, 8, 147730, 8, 147734, 8, 147736, 7, 147738, 7, 147766, 4, 147767, 4,
124
+ 147768, 7, 147770, 7, 147774, 4, 147775, 4, 149509, 6, 149511, 6, 149541, 6, 149543, 6, 149545, 5, 149549, 5,
125
+ 149558, 4, 149559, 4, 149561, 5, 149565, 5, 149566, 4, 149567, 4, 149760, 9, 149761, 9, 149762, 8, 149765, 6,
126
+ 149766, 8, 149767, 6, 149768, 9, 149769, 9, 149778, 8, 149782, 8, 149784, 7, 149786, 7, 149797, 6, 149799, 6,
127
+ 149801, 5, 149805, 5, 149814, 4, 149815, 4, 149816, 7, 149817, 5, 149818, 7, 149821, 5, 149822, 4, 149823, 4,
128
+ 149824, 37, 149825, 37, 149826, 36, 149829, 34, 149830, 36, 149831, 34, 149832, 37, 149833, 37, 149842, 36,
129
+ 149846, 36, 149848, 35, 149850, 35, 149861, 34, 149863, 34, 149865, 33, 149869, 33, 149878, 32, 149879, 32,
130
+ 149880, 35, 149881, 33, 149882, 35, 149885, 33, 149886, 32, 149887, 32, 150080, 49, 150082, 48, 150088, 49,
131
+ 150098, 48, 150104, 47, 150106, 47, 151873, 46, 151877, 45, 151881, 46, 151909, 45, 151913, 44, 151917, 44,
132
+ 152128, 49, 152129, 46, 152136, 49, 152137, 46, 166214, 43, 166215, 42, 166230, 43, 166247, 42, 166262, 41,
133
+ 166263, 41, 166466, 48, 166470, 43, 166482, 48, 166486, 43, 168261, 45, 168263, 42, 168293, 45, 168295, 42,
134
+ 168512, 31, 168513, 28, 168514, 31, 168517, 28, 168518, 25, 168519, 25, 280952, 40, 280953, 39, 280954, 40,
135
+ 280957, 39, 280958, 38, 280959, 38, 281176, 47, 281178, 47, 281208, 40, 281210, 40, 282985, 44, 282989, 44,
136
+ 283001, 39, 283005, 39, 283208, 30, 283209, 27, 283224, 30, 283241, 27, 283256, 22, 283257, 22, 297334, 41,
137
+ 297335, 41, 297342, 38, 297343, 38, 297554, 29, 297558, 24, 297562, 29, 297590, 24, 297594, 21, 297598, 21,
138
+ 299365, 26, 299367, 23, 299373, 26, 299383, 23, 299389, 20, 299391, 20, 299584, 31, 299585, 28, 299586, 31,
139
+ 299589, 28, 299590, 25, 299591, 25, 299592, 30, 299593, 27, 299602, 29, 299606, 24, 299608, 30, 299610, 29,
140
+ 299621, 26, 299623, 23, 299625, 27, 299629, 26, 299638, 24, 299639, 23, 299640, 22, 299641, 22, 299642, 21,
141
+ 299645, 20, 299646, 21, 299647, 20, 299648, 61, 299649, 60, 299650, 61, 299653, 60, 299654, 59, 299655, 59,
142
+ 299656, 58, 299657, 57, 299666, 55, 299670, 54, 299672, 58, 299674, 55, 299685, 52, 299687, 51, 299689, 57,
143
+ 299693, 52, 299702, 54, 299703, 51, 299704, 56, 299705, 56, 299706, 53, 299709, 50, 299710, 53, 299711, 50,
144
+ 299904, 61, 299906, 61, 299912, 58, 299922, 55, 299928, 58, 299930, 55, 301697, 60, 301701, 60, 301705, 57,
145
+ 301733, 52, 301737, 57, 301741, 52, 301952, 79, 301953, 79, 301960, 76, 301961, 76, 316038, 59, 316039, 59,
146
+ 316054, 54, 316071, 51, 316086, 54, 316087, 51, 316290, 78, 316294, 78, 316306, 73, 316310, 73, 318085, 77,
147
+ 318087, 77, 318117, 70, 318119, 70, 318336, 79, 318337, 79, 318338, 78, 318341, 77, 318342, 78, 318343, 77,
148
+ 430776, 56, 430777, 56, 430778, 53, 430781, 50, 430782, 53, 430783, 50, 431000, 75, 431002, 72, 431032, 75,
149
+ 431034, 72, 432809, 74, 432813, 69, 432825, 74, 432829, 69, 433032, 76, 433033, 76, 433048, 75, 433065, 74,
150
+ 433080, 75, 433081, 74, 447158, 71, 447159, 68, 447166, 71, 447167, 68, 447378, 73, 447382, 73, 447386, 72,
151
+ 447414, 71, 447418, 72, 447422, 71, 449189, 70, 449191, 70, 449197, 69, 449207, 68, 449213, 69, 449215, 68,
152
+ 449408, 67, 449409, 67, 449410, 66, 449413, 64, 449414, 66, 449415, 64, 449416, 67, 449417, 67, 449426, 66,
153
+ 449430, 66, 449432, 65, 449434, 65, 449445, 64, 449447, 64, 449449, 63, 449453, 63, 449462, 62, 449463, 62,
154
+ 449464, 65, 449465, 63, 449466, 65, 449469, 63, 449470, 62, 449471, 62, 449472, 19, 449473, 19, 449474, 18,
155
+ 449477, 16, 449478, 18, 449479, 16, 449480, 19, 449481, 19, 449490, 18, 449494, 18, 449496, 17, 449498, 17,
156
+ 449509, 16, 449511, 16, 449513, 15, 449517, 15, 449526, 14, 449527, 14, 449528, 17, 449529, 15, 449530, 17,
157
+ 449533, 15, 449534, 14, 449535, 14, 449728, 19, 449729, 19, 449730, 18, 449734, 18, 449736, 19, 449737, 19,
158
+ 449746, 18, 449750, 18, 449752, 17, 449754, 17, 449784, 17, 449786, 17, 451520, 19, 451521, 19, 451525, 16,
159
+ 451527, 16, 451528, 19, 451529, 19, 451557, 16, 451559, 16, 451561, 15, 451565, 15, 451577, 15, 451581, 15,
160
+ 451776, 19, 451777, 19, 451784, 19, 451785, 19, 465858, 18, 465861, 16, 465862, 18, 465863, 16, 465874, 18,
161
+ 465878, 18, 465893, 16, 465895, 16, 465910, 14, 465911, 14, 465918, 14, 465919, 14, 466114, 18, 466118, 18,
162
+ 466130, 18, 466134, 18, 467909, 16, 467911, 16, 467941, 16, 467943, 16, 468160, 13, 468161, 13, 468162, 13,
163
+ 468163, 13, 468164, 13, 468165, 13, 468166, 13, 468167, 13, 580568, 17, 580570, 17, 580585, 15, 580589, 15,
164
+ 580598, 14, 580599, 14, 580600, 17, 580601, 15, 580602, 17, 580605, 15, 580606, 14, 580607, 14, 580824, 17,
165
+ 580826, 17, 580856, 17, 580858, 17, 582633, 15, 582637, 15, 582649, 15, 582653, 15, 582856, 12, 582857, 12,
166
+ 582872, 12, 582873, 12, 582888, 12, 582889, 12, 582904, 12, 582905, 12, 596982, 14, 596983, 14, 596990, 14,
167
+ 596991, 14, 597202, 11, 597206, 11, 597210, 11, 597214, 11, 597234, 11, 597238, 11, 597242, 11, 597246, 11,
168
+ 599013, 10, 599015, 10, 599021, 10, 599023, 10, 599029, 10, 599031, 10, 599037, 10, 599039, 10, 599232, 13,
169
+ 599233, 13, 599234, 13, 599235, 13, 599236, 13, 599237, 13, 599238, 13, 599239, 13, 599240, 12, 599241, 12,
170
+ 599250, 11, 599254, 11, 599256, 12, 599257, 12, 599258, 11, 599262, 11, 599269, 10, 599271, 10, 599272, 12,
171
+ 599273, 12, 599277, 10, 599279, 10, 599282, 11, 599285, 10, 599286, 11, 599287, 10, 599288, 12, 599289, 12,
172
+ 599290, 11, 599293, 10, 599294, 11, 599295, 10,
173
+ ], p4D = [
174
+ 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, 1, 0, 0, -1, 0, 0, -1, 1, 0, 0, 0, 0, 1, -1, 0, 0, 0, 1, 0, -1, 0, 0, -1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, 3, 1, 0, 2, 0,
202
+ 4, 1, 1, 1, 1, 3, 3, 0, 2, 1, 0, 3, 0, 1, 2, 0, 4, 1, 1, 1, 1, 3, 3, 2, 0, 0, 1, 3, 1, 0, 0, 2, 4, 1, 1, 1, 1,
203
+ 3, 3, 0, 2, 0, 1, 3, 0, 1, 0, 2, 4, 1, 1, 1, 1, 3, 3, 0, 0, 2, 1, 3, 0, 0, 1, 2, 4, 1, 1, 1, 1, 3, 3, 2, 1, 0,
204
+ 0, 3, 1, 2, 0, 0, 2, 1, 1, 1, -1, 3, 3, 2, 0, 1, 0, 3, 1, 0, 2, 0, 2, 1, 1, 1, -1, 3, 3, 0, 2, 1, 0, 3, 0, 1, 2,
205
+ 0, 2, 1, 1, 1, -1, 3, 3, 2, 1, 0, 0, 3, 1, 2, 0, 0, 2, 1, 1, -1, 1, 3, 3, 2, 0, 0, 1, 3, 1, 0, 0, 2, 2, 1, 1,
206
+ -1, 1, 3, 3, 0, 2, 0, 1, 3, 0, 1, 0, 2, 2, 1, 1, -1, 1, 3, 3, 2, 0, 1, 0, 3, 1, 0, 2, 0, 2, 1, -1, 1, 1, 3, 3,
207
+ 2, 0, 0, 1, 3, 1, 0, 0, 2, 2, 1, -1, 1, 1, 3, 3, 0, 0, 2, 1, 3, 0, 0, 1, 2, 2, 1, -1, 1, 1, 3, 3, 0, 2, 1, 0, 3,
208
+ 0, 1, 2, 0, 2, -1, 1, 1, 1, 3, 3, 0, 2, 0, 1, 3, 0, 1, 0, 2, 2, -1, 1, 1, 1, 3, 3, 0, 0, 2, 1, 3, 0, 0, 1, 2, 2,
209
+ -1, 1, 1, 1,
242
210
  ];
@@ -1,8 +1,46 @@
1
- import { Vector } from "@tsparticles/engine";
2
- import { getRandom } from "@tsparticles/engine";
3
- import { makeNoise4D } from "./simplex";
1
+ import { Vector, getRandom } from "@tsparticles/engine";
2
+ import { makeNoise4D } from "./simplex.js";
4
3
  export class SimplexNoiseGenerator {
5
4
  constructor() {
5
+ this._calculateField = () => {
6
+ for (let x = 0; x < this.options.columns; x++) {
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
+ };
6
44
  this.field = [];
7
45
  this.noiseFunc = makeNoise4D(getRandom());
8
46
  this.noiseW = 0;
@@ -34,7 +72,7 @@ export class SimplexNoiseGenerator {
34
72
  }
35
73
  init(container) {
36
74
  this.container = container;
37
- this.setup(this.container);
75
+ this._setup(this.container);
38
76
  }
39
77
  reset() {
40
78
  }
@@ -42,48 +80,7 @@ export class SimplexNoiseGenerator {
42
80
  if (!this.container) {
43
81
  return;
44
82
  }
45
- this.calculateField();
83
+ this._calculateField();
46
84
  this.noiseW += this.options.increment;
47
85
  }
48
- calculateField() {
49
- for (let x = 0; x < this.options.columns; x++) {
50
- for (let y = 0; y < this.options.rows; y++) {
51
- for (let z = 0; z < this.options.layers; z++) {
52
- const angle = this.noiseFunc(x / 50, y / 50, z / 50, this.noiseW) * Math.PI * 2, length = this.noiseFunc(x / 100 + 40000, y / 100 + 40000, z / 100 + 40000, this.noiseW);
53
- this.field[x][y][z][0] = angle;
54
- this.field[x][y][z][1] = length;
55
- }
56
- }
57
- }
58
- }
59
- initField() {
60
- this.field = new Array(this.options.columns);
61
- for (let x = 0; x < this.options.columns; x++) {
62
- this.field[x] = new Array(this.options.rows);
63
- for (let y = 0; y < this.options.rows; y++) {
64
- this.field[x][y] = new Array(this.options.layers);
65
- for (let z = 0; z < this.options.layers; z++) {
66
- this.field[x][y][z] = [0, 0];
67
- }
68
- }
69
- }
70
- }
71
- resetField(container) {
72
- var _a;
73
- const sourceOptions = container.actualOptions.particles.move.path.options;
74
- this.options.size = sourceOptions.size > 0 ? sourceOptions.size : 20;
75
- this.options.increment = sourceOptions.increment > 0 ? sourceOptions.increment : 0.004;
76
- this.options.width = container.canvas.size.width;
77
- this.options.height = container.canvas.size.height;
78
- this.noiseFunc = makeNoise4D((_a = sourceOptions.seed) !== null && _a !== void 0 ? _a : getRandom());
79
- this.options.columns = Math.floor(this.options.width / this.options.size) + 1;
80
- this.options.rows = Math.floor(this.options.height / this.options.size) + 1;
81
- this.options.layers = Math.floor(container.zLayers / this.options.size) + 1;
82
- this.initField();
83
- }
84
- setup(container) {
85
- this.noiseW = 0;
86
- this.resetField(container);
87
- addEventListener("resize", () => this.resetField(container));
88
- }
89
86
  }