@tsparticles/perlin-noise 4.0.0-beta.0 → 4.0.0-beta.2

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.
@@ -4,7 +4,7 @@
4
4
  * Demo / Generator : https://particles.js.org/
5
5
  * GitHub : https://www.github.com/matteobruni/tsparticles
6
6
  * How to use? : Check the GitHub README
7
- * v4.0.0-beta.0
7
+ * v4.0.0-beta.2
8
8
  */
9
9
  /*
10
10
  * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
package/umd/Grad.js DELETED
@@ -1,35 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.Grad = void 0;
13
- class Grad {
14
- w;
15
- x;
16
- y;
17
- z;
18
- constructor(x, y, z, w) {
19
- this.x = x;
20
- this.y = y;
21
- this.z = z;
22
- this.w = w;
23
- }
24
- dot2(x, y) {
25
- return this.x * x + this.y * y;
26
- }
27
- dot3(x, y, z) {
28
- return this.dot2(x, y) + this.z * z;
29
- }
30
- dot4(x, y, z, w) {
31
- return this.dot3(x, y, z) + this.w * w;
32
- }
33
- }
34
- exports.Grad = Grad;
35
- });
@@ -1,376 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./Grad.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PerlinNoise = void 0;
13
- const Grad_js_1 = require("./Grad.js");
14
- class PerlinNoise {
15
- _grad4;
16
- _gradP;
17
- _p;
18
- _perm;
19
- constructor() {
20
- this._grad4 = [
21
- new Grad_js_1.Grad(0, 1, 1, 1),
22
- new Grad_js_1.Grad(0, 1, 1, -1),
23
- new Grad_js_1.Grad(0, 1, -1, 1),
24
- new Grad_js_1.Grad(0, 1, -1, -1),
25
- new Grad_js_1.Grad(0, -1, 1, 1),
26
- new Grad_js_1.Grad(0, -1, 1, -1),
27
- new Grad_js_1.Grad(0, -1, -1, 1),
28
- new Grad_js_1.Grad(0, -1, -1, -1),
29
- new Grad_js_1.Grad(1, 0, 1, 1),
30
- new Grad_js_1.Grad(1, 0, 1, -1),
31
- new Grad_js_1.Grad(1, 0, -1, 1),
32
- new Grad_js_1.Grad(1, 0, -1, -1),
33
- new Grad_js_1.Grad(-1, 0, 1, 1),
34
- new Grad_js_1.Grad(-1, 0, 1, -1),
35
- new Grad_js_1.Grad(-1, 0, -1, 1),
36
- new Grad_js_1.Grad(-1, 0, -1, -1),
37
- new Grad_js_1.Grad(1, 1, 0, 1),
38
- new Grad_js_1.Grad(1, 1, 0, -1),
39
- new Grad_js_1.Grad(1, -1, 0, 1),
40
- new Grad_js_1.Grad(1, -1, 0, -1),
41
- new Grad_js_1.Grad(-1, 1, 0, 1),
42
- new Grad_js_1.Grad(-1, 1, 0, -1),
43
- new Grad_js_1.Grad(-1, -1, 0, 1),
44
- new Grad_js_1.Grad(-1, -1, 0, -1),
45
- new Grad_js_1.Grad(1, 1, 1, 0),
46
- new Grad_js_1.Grad(1, 1, -1, 0),
47
- new Grad_js_1.Grad(1, -1, 1, 0),
48
- new Grad_js_1.Grad(1, -1, -1, 0),
49
- new Grad_js_1.Grad(-1, 1, 1, 0),
50
- new Grad_js_1.Grad(-1, 1, -1, 0),
51
- new Grad_js_1.Grad(-1, -1, 1, 0),
52
- new Grad_js_1.Grad(-1, -1, -1, 0),
53
- ];
54
- this._p = [
55
- 151,
56
- 160,
57
- 137,
58
- 91,
59
- 90,
60
- 15,
61
- 131,
62
- 13,
63
- 201,
64
- 95,
65
- 96,
66
- 53,
67
- 194,
68
- 233,
69
- 7,
70
- 225,
71
- 140,
72
- 36,
73
- 103,
74
- 30,
75
- 69,
76
- 142,
77
- 8,
78
- 99,
79
- 37,
80
- 240,
81
- 21,
82
- 10,
83
- 23,
84
- 190,
85
- 6,
86
- 148,
87
- 247,
88
- 120,
89
- 234,
90
- 75,
91
- 0,
92
- 26,
93
- 197,
94
- 62,
95
- 94,
96
- 252,
97
- 219,
98
- 203,
99
- 117,
100
- 35,
101
- 11,
102
- 32,
103
- 57,
104
- 177,
105
- 33,
106
- 88,
107
- 237,
108
- 149,
109
- 56,
110
- 87,
111
- 174,
112
- 20,
113
- 125,
114
- 136,
115
- 171,
116
- 168,
117
- 68,
118
- 175,
119
- 74,
120
- 165,
121
- 71,
122
- 134,
123
- 139,
124
- 48,
125
- 27,
126
- 166,
127
- 77,
128
- 146,
129
- 158,
130
- 231,
131
- 83,
132
- 111,
133
- 229,
134
- 122,
135
- 60,
136
- 211,
137
- 133,
138
- 230,
139
- 220,
140
- 105,
141
- 92,
142
- 41,
143
- 55,
144
- 46,
145
- 245,
146
- 40,
147
- 244,
148
- 102,
149
- 143,
150
- 54,
151
- 65,
152
- 25,
153
- 63,
154
- 161,
155
- 1,
156
- 216,
157
- 80,
158
- 73,
159
- 209,
160
- 76,
161
- 132,
162
- 187,
163
- 208,
164
- 89,
165
- 18,
166
- 169,
167
- 200,
168
- 196,
169
- 135,
170
- 130,
171
- 116,
172
- 188,
173
- 159,
174
- 86,
175
- 164,
176
- 100,
177
- 109,
178
- 198,
179
- 173,
180
- 186,
181
- 3,
182
- 64,
183
- 52,
184
- 217,
185
- 226,
186
- 250,
187
- 124,
188
- 123,
189
- 5,
190
- 202,
191
- 38,
192
- 147,
193
- 118,
194
- 126,
195
- 255,
196
- 82,
197
- 85,
198
- 212,
199
- 207,
200
- 206,
201
- 59,
202
- 227,
203
- 47,
204
- 16,
205
- 58,
206
- 17,
207
- 182,
208
- 189,
209
- 28,
210
- 42,
211
- 223,
212
- 183,
213
- 170,
214
- 213,
215
- 119,
216
- 248,
217
- 152,
218
- 2,
219
- 44,
220
- 154,
221
- 163,
222
- 70,
223
- 221,
224
- 153,
225
- 101,
226
- 155,
227
- 167,
228
- 43,
229
- 172,
230
- 9,
231
- 129,
232
- 22,
233
- 39,
234
- 253,
235
- 19,
236
- 98,
237
- 108,
238
- 110,
239
- 79,
240
- 113,
241
- 224,
242
- 232,
243
- 178,
244
- 185,
245
- 112,
246
- 104,
247
- 218,
248
- 246,
249
- 97,
250
- 228,
251
- 251,
252
- 34,
253
- 242,
254
- 193,
255
- 238,
256
- 210,
257
- 144,
258
- 12,
259
- 191,
260
- 179,
261
- 162,
262
- 241,
263
- 81,
264
- 51,
265
- 145,
266
- 235,
267
- 249,
268
- 14,
269
- 239,
270
- 107,
271
- 49,
272
- 192,
273
- 214,
274
- 31,
275
- 181,
276
- 199,
277
- 106,
278
- 157,
279
- 184,
280
- 84,
281
- 204,
282
- 176,
283
- 115,
284
- 121,
285
- 50,
286
- 45,
287
- 127,
288
- 4,
289
- 150,
290
- 254,
291
- 138,
292
- 236,
293
- 205,
294
- 93,
295
- 222,
296
- 114,
297
- 67,
298
- 29,
299
- 24,
300
- 72,
301
- 243,
302
- 141,
303
- 128,
304
- 195,
305
- 78,
306
- 66,
307
- 215,
308
- 61,
309
- 156,
310
- 180,
311
- ];
312
- this._gradP = new Array(512);
313
- this._perm = new Array(512);
314
- }
315
- noise2d(x, y) {
316
- const { _gradP, _perm } = this;
317
- let X = Math.floor(x), Y = Math.floor(y);
318
- x -= X;
319
- y -= Y;
320
- X &= 255;
321
- Y &= 255;
322
- const n00 = _gradP[X + _perm[Y]].dot2(x, y), n01 = _gradP[X + _perm[Y + 1]].dot2(x, y - 1), n10 = _gradP[X + 1 + _perm[Y]].dot2(x - 1, y), n11 = _gradP[X + 1 + _perm[Y + 1]].dot2(x - 1, y - 1), u = this._fade(x);
323
- return this._lerp(this._lerp(n00, n10, u), this._lerp(n01, n11, u), this._fade(y));
324
- }
325
- noise3d(x, y, z) {
326
- const { _gradP: gradP, _perm: perm } = this;
327
- let X = Math.floor(x), Y = Math.floor(y), Z = Math.floor(z);
328
- x = x - X;
329
- y = y - Y;
330
- z = z - Z;
331
- X = X & 255;
332
- Y = Y & 255;
333
- Z = Z & 255;
334
- const n000 = gradP[X + perm[Y + perm[Z]]].dot3(x, y, z), n001 = gradP[X + perm[Y + perm[Z + 1]]].dot3(x, y, z - 1), n010 = gradP[X + perm[Y + 1 + perm[Z]]].dot3(x, y - 1, z), n011 = gradP[X + perm[Y + 1 + perm[Z + 1]]].dot3(x, y - 1, z - 1), n100 = gradP[X + 1 + perm[Y + perm[Z]]].dot3(x - 1, y, z), n101 = gradP[X + 1 + perm[Y + perm[Z + 1]]].dot3(x - 1, y, z - 1), n110 = gradP[X + 1 + perm[Y + 1 + perm[Z]]].dot3(x - 1, y - 1, z), n111 = gradP[X + 1 + perm[Y + 1 + perm[Z + 1]]].dot3(x - 1, y - 1, z - 1), u = this._fade(x), v = this._fade(y), w = this._fade(z);
335
- return this._lerp(this._lerp(this._lerp(n000, n100, u), this._lerp(n001, n101, u), w), this._lerp(this._lerp(n010, n110, u), this._lerp(n011, n111, u), w), v);
336
- }
337
- noise4d(x, y, z, w) {
338
- const { _gradP: gradP, _perm: perm } = this;
339
- let X = Math.floor(x), Y = Math.floor(y), Z = Math.floor(z), W = Math.floor(w);
340
- x -= X;
341
- y -= Y;
342
- z -= Z;
343
- w -= W;
344
- X &= 255;
345
- Y &= 255;
346
- Z &= 255;
347
- W &= 255;
348
- const u = this._fade(x), v = this._fade(y), s = this._fade(z), t = this._fade(w), gi = (i, j, k, l) => gradP[X + i + perm[Y + j + perm[Z + k + perm[W + l]]]], n0000 = gi(0, 0, 0, 0).dot4(x, y, z, w), n0001 = gi(0, 0, 0, 1).dot4(x, y, z, w - 1), n0010 = gi(0, 0, 1, 0).dot4(x, y, z - 1, w), n0011 = gi(0, 0, 1, 1).dot4(x, y, z - 1, w - 1), n0100 = gi(0, 1, 0, 0).dot4(x, y - 1, z, w), n0101 = gi(0, 1, 0, 1).dot4(x, y - 1, z, w - 1), n0110 = gi(0, 1, 1, 0).dot4(x, y - 1, z - 1, w), n0111 = gi(0, 1, 1, 1).dot4(x, y - 1, z - 1, w - 1), n1000 = gi(1, 0, 0, 0).dot4(x - 1, y, z, w), n1001 = gi(1, 0, 0, 1).dot4(x - 1, y, z, w - 1), n1010 = gi(1, 0, 1, 0).dot4(x - 1, y, z - 1, w), n1011 = gi(1, 0, 1, 1).dot4(x - 1, y, z - 1, w - 1), n1100 = gi(1, 1, 0, 0).dot4(x - 1, y - 1, z, w), n1101 = gi(1, 1, 0, 1).dot4(x - 1, y - 1, z, w - 1), n1110 = gi(1, 1, 1, 0).dot4(x - 1, y - 1, z - 1, w), n1111 = gi(1, 1, 1, 1).dot4(x - 1, y - 1, z - 1, w - 1), x00 = this._lerp(n0000, n1000, u), x01 = this._lerp(n0001, n1001, u), x10 = this._lerp(n0010, n1010, u), x11 = this._lerp(n0011, n1011, u), y00 = this._lerp(x00, x10, s), y01 = this._lerp(x01, x11, s), x20 = this._lerp(n0100, n1100, u), x21 = this._lerp(n0101, n1101, u), x30 = this._lerp(n0110, n1110, u), x31 = this._lerp(n0111, n1111, u), y10 = this._lerp(x20, x30, s), y11 = this._lerp(x21, x31, s), z0 = this._lerp(y00, y10, v), z1 = this._lerp(y01, y11, v);
349
- return this._lerp(z0, z1, t);
350
- }
351
- seed(inputSeed) {
352
- const { _grad4: grad4, _gradP: gradP, _perm: perm, _p: p } = this;
353
- let seed = inputSeed;
354
- if (seed > 0 && seed < 1) {
355
- seed *= 65536;
356
- }
357
- seed = Math.floor(seed);
358
- if (seed < 256) {
359
- seed |= seed << 8;
360
- }
361
- const grad4Length = grad4.length;
362
- for (let i = 0; i < 256; i++) {
363
- const v = i & 1 ? p[i] ^ (seed & 255) : p[i] ^ ((seed >> 8) & 255);
364
- perm[i] = perm[i + 256] = v;
365
- gradP[i] = gradP[i + 256] = grad4[v % grad4Length];
366
- }
367
- }
368
- _fade(t) {
369
- return t * t * t * (t * (t * 6 - 15) + 10);
370
- }
371
- _lerp(a, b, t) {
372
- return (1 - t) * a + t * b;
373
- }
374
- }
375
- exports.PerlinNoise = PerlinNoise;
376
- });
package/umd/index.js DELETED
@@ -1,15 +0,0 @@
1
- (function (factory) {
2
- if (typeof module === "object" && typeof module.exports === "object") {
3
- var v = factory(require, exports);
4
- if (v !== undefined) module.exports = v;
5
- }
6
- else if (typeof define === "function" && define.amd) {
7
- define(["require", "exports", "./PerlinNoise.js"], factory);
8
- }
9
- })(function (require, exports) {
10
- "use strict";
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.PerlinNoise = void 0;
13
- var PerlinNoise_js_1 = require("./PerlinNoise.js");
14
- Object.defineProperty(exports, "PerlinNoise", { enumerable: true, get: function () { return PerlinNoise_js_1.PerlinNoise; } });
15
- });