@tsparticles/perlin-noise 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.
@@ -0,0 +1,164 @@
1
+ /*!
2
+ * Author : Matteo Bruni
3
+ * MIT license: https://opensource.org/licenses/MIT
4
+ * Demo / Generator : https://particles.js.org/
5
+ * GitHub : https://www.github.com/matteobruni/tsparticles
6
+ * How to use? : Check the GitHub README
7
+ * v3.0.0-beta.4
8
+ */
9
+ (function webpackUniversalModuleDefinition(root, factory) {
10
+ if(typeof exports === 'object' && typeof module === 'object')
11
+ module.exports = factory();
12
+ else if(typeof define === 'function' && define.amd)
13
+ define([], factory);
14
+ else {
15
+ var a = factory();
16
+ for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];
17
+ }
18
+ })(this, () => {
19
+ return /******/ (() => { // webpackBootstrap
20
+ /******/ "use strict";
21
+ /******/ // The require scope
22
+ /******/ var __webpack_require__ = {};
23
+ /******/
24
+ /************************************************************************/
25
+ /******/ /* webpack/runtime/define property getters */
26
+ /******/ (() => {
27
+ /******/ // define getter functions for harmony exports
28
+ /******/ __webpack_require__.d = (exports, definition) => {
29
+ /******/ for(var key in definition) {
30
+ /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
31
+ /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
32
+ /******/ }
33
+ /******/ }
34
+ /******/ };
35
+ /******/ })();
36
+ /******/
37
+ /******/ /* webpack/runtime/hasOwnProperty shorthand */
38
+ /******/ (() => {
39
+ /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
40
+ /******/ })();
41
+ /******/
42
+ /******/ /* webpack/runtime/make namespace object */
43
+ /******/ (() => {
44
+ /******/ // define __esModule on exports
45
+ /******/ __webpack_require__.r = (exports) => {
46
+ /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
47
+ /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
48
+ /******/ }
49
+ /******/ Object.defineProperty(exports, '__esModule', { value: true });
50
+ /******/ };
51
+ /******/ })();
52
+ /******/
53
+ /************************************************************************/
54
+ var __webpack_exports__ = {};
55
+ // ESM COMPAT FLAG
56
+ __webpack_require__.r(__webpack_exports__);
57
+
58
+ // EXPORTS
59
+ __webpack_require__.d(__webpack_exports__, {
60
+ PerlinNoise: () => (/* reexport */ PerlinNoise)
61
+ });
62
+
63
+ ;// CONCATENATED MODULE: ./dist/browser/Grad.js
64
+ class Grad {
65
+ constructor(x, y, z) {
66
+ this.x = x;
67
+ this.y = y;
68
+ this.z = z;
69
+ }
70
+ dot2(x, y) {
71
+ return this.x * x + this.y * y;
72
+ }
73
+ dot3(x, y, z) {
74
+ return this.dot2(x, y) + this.z * z;
75
+ }
76
+ }
77
+ ;// CONCATENATED MODULE: ./dist/browser/PerlinNoise.js
78
+
79
+ class PerlinNoise {
80
+ constructor() {
81
+ this._grad3 = [new Grad(1, 1, 0), new Grad(-1, 1, 0), new Grad(1, -1, 0), new Grad(-1, -1, 0), new Grad(1, 0, 1), new Grad(-1, 0, 1), new Grad(1, 0, -1), new Grad(-1, 0, -1), new Grad(0, 1, 1), new Grad(0, -1, 1), new Grad(0, 1, -1), new Grad(0, -1, -1)];
82
+ this._p = [151, 160, 137, 91, 90, 15, 131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23, 190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33, 88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166, 77, 146, 158, 231, 83, 111, 229, 122, 60, 211, 133, 230, 220, 105, 92, 41, 55, 46, 245, 40, 244, 102, 143, 54, 65, 25, 63, 161, 1, 216, 80, 73, 209, 76, 132, 187, 208, 89, 18, 169, 200, 196, 135, 130, 116, 188, 159, 86, 164, 100, 109, 198, 173, 186, 3, 64, 52, 217, 226, 250, 124, 123, 5, 202, 38, 147, 118, 126, 255, 82, 85, 212, 207, 206, 59, 227, 47, 16, 58, 17, 182, 189, 28, 42, 223, 183, 170, 213, 119, 248, 152, 2, 44, 154, 163, 70, 221, 153, 101, 155, 167, 43, 172, 9, 129, 22, 39, 253, 19, 98, 108, 110, 79, 113, 224, 232, 178, 185, 112, 104, 218, 246, 97, 228, 251, 34, 242, 193, 238, 210, 144, 12, 191, 179, 162, 241, 81, 51, 145, 235, 249, 14, 239, 107, 49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254, 138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180];
83
+ this._gradP = new Array(512);
84
+ this._perm = new Array(512);
85
+ }
86
+ noise2d(x, y) {
87
+ const {
88
+ _gradP,
89
+ _perm
90
+ } = this;
91
+ let X = Math.floor(x),
92
+ Y = Math.floor(y);
93
+ x = x - X;
94
+ y = y - Y;
95
+ X = X & 255;
96
+ Y = Y & 255;
97
+ const n00 = _gradP[X + _perm[Y]].dot2(x, y),
98
+ n01 = _gradP[X + _perm[Y + 1]].dot2(x, y - 1),
99
+ n10 = _gradP[X + 1 + _perm[Y]].dot2(x - 1, y),
100
+ n11 = _gradP[X + 1 + _perm[Y + 1]].dot2(x - 1, y - 1);
101
+ const u = this._fade(x);
102
+ return this._lerp(this._lerp(n00, n10, u), this._lerp(n01, n11, u), this._fade(y));
103
+ }
104
+ noise3d(x, y, z) {
105
+ const {
106
+ _gradP: gradP,
107
+ _perm: perm
108
+ } = this;
109
+ let X = Math.floor(x),
110
+ Y = Math.floor(y),
111
+ Z = Math.floor(z);
112
+ x = x - X;
113
+ y = y - Y;
114
+ z = z - Z;
115
+ X = X & 255;
116
+ Y = Y & 255;
117
+ Z = Z & 255;
118
+ const n000 = gradP[X + perm[Y + perm[Z]]].dot3(x, y, z),
119
+ n001 = gradP[X + perm[Y + perm[Z + 1]]].dot3(x, y, z - 1),
120
+ n010 = gradP[X + perm[Y + 1 + perm[Z]]].dot3(x, y - 1, z),
121
+ n011 = gradP[X + perm[Y + 1 + perm[Z + 1]]].dot3(x, y - 1, z - 1),
122
+ n100 = gradP[X + 1 + perm[Y + perm[Z]]].dot3(x - 1, y, z),
123
+ n101 = gradP[X + 1 + perm[Y + perm[Z + 1]]].dot3(x - 1, y, z - 1),
124
+ n110 = gradP[X + 1 + perm[Y + 1 + perm[Z]]].dot3(x - 1, y - 1, z),
125
+ n111 = gradP[X + 1 + perm[Y + 1 + perm[Z + 1]]].dot3(x - 1, y - 1, z - 1),
126
+ u = this._fade(x),
127
+ v = this._fade(y),
128
+ w = this._fade(z);
129
+ 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);
130
+ }
131
+ seed(inputSeed) {
132
+ const {
133
+ _grad3: grad3,
134
+ _gradP: gradP,
135
+ _perm: perm,
136
+ _p: p
137
+ } = this;
138
+ let seed = inputSeed;
139
+ if (seed > 0 && seed < 1) {
140
+ seed *= 65536;
141
+ }
142
+ seed = Math.floor(seed);
143
+ if (seed < 256) {
144
+ seed |= seed << 8;
145
+ }
146
+ for (let i = 0; i < 256; i++) {
147
+ const v = i & 1 ? p[i] ^ seed & 255 : p[i] ^ seed >> 8 & 255;
148
+ perm[i] = perm[i + 256] = v;
149
+ gradP[i] = gradP[i + 256] = grad3[v % 12];
150
+ }
151
+ }
152
+ _fade(t) {
153
+ return t * t * t * (t * (t * 6 - 15) + 10);
154
+ }
155
+ _lerp(a, b, t) {
156
+ return (1 - t) * a + t * b;
157
+ }
158
+ }
159
+ ;// CONCATENATED MODULE: ./dist/browser/index.js
160
+
161
+ /******/ return __webpack_exports__;
162
+ /******/ })()
163
+ ;
164
+ });
@@ -0,0 +1,2 @@
1
+ /*! For license information please see tsparticles.perlin.noise.min.js.LICENSE.txt */
2
+ !function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var o in r)("object"==typeof exports?exports:e)[o]=r[o]}}(this,(()=>(()=>{"use strict";var e={d:(t,r)=>{for(var o in r)e.o(r,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:r[o]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{PerlinNoise:()=>o});class r{constructor(e,t,r){this.x=e,this.y=t,this.z=r}dot2(e,t){return this.x*e+this.y*t}dot3(e,t,r){return this.dot2(e,t)+this.z*r}}class o{constructor(){this._grad3=[new r(1,1,0),new r(-1,1,0),new r(1,-1,0),new r(-1,-1,0),new r(1,0,1),new r(-1,0,1),new r(1,0,-1),new r(-1,0,-1),new r(0,1,1),new r(0,-1,1),new r(0,1,-1),new r(0,-1,-1)],this._p=[151,160,137,91,90,15,131,13,201,95,96,53,194,233,7,225,140,36,103,30,69,142,8,99,37,240,21,10,23,190,6,148,247,120,234,75,0,26,197,62,94,252,219,203,117,35,11,32,57,177,33,88,237,149,56,87,174,20,125,136,171,168,68,175,74,165,71,134,139,48,27,166,77,146,158,231,83,111,229,122,60,211,133,230,220,105,92,41,55,46,245,40,244,102,143,54,65,25,63,161,1,216,80,73,209,76,132,187,208,89,18,169,200,196,135,130,116,188,159,86,164,100,109,198,173,186,3,64,52,217,226,250,124,123,5,202,38,147,118,126,255,82,85,212,207,206,59,227,47,16,58,17,182,189,28,42,223,183,170,213,119,248,152,2,44,154,163,70,221,153,101,155,167,43,172,9,129,22,39,253,19,98,108,110,79,113,224,232,178,185,112,104,218,246,97,228,251,34,242,193,238,210,144,12,191,179,162,241,81,51,145,235,249,14,239,107,49,192,214,31,181,199,106,157,184,84,204,176,115,121,50,45,127,4,150,254,138,236,205,93,222,114,67,29,24,72,243,141,128,195,78,66,215,61,156,180],this._gradP=new Array(512),this._perm=new Array(512)}noise2d(e,t){const{_gradP:r,_perm:o}=this;let s=Math.floor(e),i=Math.floor(t);e-=s,t-=i,s&=255,i&=255;const n=r[s+o[i]].dot2(e,t),d=r[s+o[i+1]].dot2(e,t-1),l=r[s+1+o[i]].dot2(e-1,t),h=r[s+1+o[i+1]].dot2(e-1,t-1),a=this._fade(e);return this._lerp(this._lerp(n,l,a),this._lerp(d,h,a),this._fade(t))}noise3d(e,t,r){const{_gradP:o,_perm:s}=this;let i=Math.floor(e),n=Math.floor(t),d=Math.floor(r);e-=i,t-=n,r-=d,i&=255,n&=255,d&=255;const l=o[i+s[n+s[d]]].dot3(e,t,r),h=o[i+s[n+s[d+1]]].dot3(e,t,r-1),a=o[i+s[n+1+s[d]]].dot3(e,t-1,r),p=o[i+s[n+1+s[d+1]]].dot3(e,t-1,r-1),f=o[i+1+s[n+s[d]]].dot3(e-1,t,r),_=o[i+1+s[n+s[d+1]]].dot3(e-1,t,r-1),c=o[i+1+s[n+1+s[d]]].dot3(e-1,t-1,r),u=o[i+1+s[n+1+s[d+1]]].dot3(e-1,t-1,r-1),y=this._fade(e),w=this._fade(t),b=this._fade(r);return this._lerp(this._lerp(this._lerp(l,f,y),this._lerp(h,_,y),b),this._lerp(this._lerp(a,c,y),this._lerp(p,u,y),b),w)}seed(e){const{_grad3:t,_gradP:r,_perm:o,_p:s}=this;let i=e;i>0&&i<1&&(i*=65536),i=Math.floor(i),i<256&&(i|=i<<8);for(let e=0;e<256;e++){const n=1&e?s[e]^255&i:s[e]^i>>8&255;o[e]=o[e+256]=n,r[e]=r[e+256]=t[n%12]}}_fade(e){return e*e*e*(e*(6*e-15)+10)}_lerp(e,t,r){return(1-r)*e+r*t}}return t})()));
@@ -0,0 +1 @@
1
+ /*! tsParticles Perlin Noise v3.0.0-beta.4 by Matteo Bruni */
@@ -0,0 +1,8 @@
1
+ export declare class Grad {
2
+ readonly x: number;
3
+ readonly y: number;
4
+ readonly z: number;
5
+ constructor(x: number, y: number, z: number);
6
+ dot2(x: number, y: number): number;
7
+ dot3(x: number, y: number, z: number): number;
8
+ }
@@ -0,0 +1,12 @@
1
+ export declare class PerlinNoise {
2
+ private readonly _grad3;
3
+ private readonly _gradP;
4
+ private readonly _p;
5
+ private readonly _perm;
6
+ constructor();
7
+ noise2d(x: number, y: number): number;
8
+ noise3d(x: number, y: number, z: number): number;
9
+ seed(inputSeed: number): void;
10
+ private _fade;
11
+ private _lerp;
12
+ }
@@ -0,0 +1 @@
1
+ export { PerlinNoise } from "./PerlinNoise.js";
package/umd/Grad.js ADDED
@@ -0,0 +1,27 @@
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
+ constructor(x, y, z) {
15
+ this.x = x;
16
+ this.y = y;
17
+ this.z = z;
18
+ }
19
+ dot2(x, y) {
20
+ return this.x * x + this.y * y;
21
+ }
22
+ dot3(x, y, z) {
23
+ return this.dot2(x, y) + this.z * z;
24
+ }
25
+ }
26
+ exports.Grad = Grad;
27
+ });
@@ -0,0 +1,338 @@
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
+ constructor() {
16
+ this._grad3 = [
17
+ new Grad_js_1.Grad(1, 1, 0),
18
+ new Grad_js_1.Grad(-1, 1, 0),
19
+ new Grad_js_1.Grad(1, -1, 0),
20
+ new Grad_js_1.Grad(-1, -1, 0),
21
+ new Grad_js_1.Grad(1, 0, 1),
22
+ new Grad_js_1.Grad(-1, 0, 1),
23
+ new Grad_js_1.Grad(1, 0, -1),
24
+ new Grad_js_1.Grad(-1, 0, -1),
25
+ new Grad_js_1.Grad(0, 1, 1),
26
+ new Grad_js_1.Grad(0, -1, 1),
27
+ new Grad_js_1.Grad(0, 1, -1),
28
+ new Grad_js_1.Grad(0, -1, -1),
29
+ ];
30
+ this._p = [
31
+ 151,
32
+ 160,
33
+ 137,
34
+ 91,
35
+ 90,
36
+ 15,
37
+ 131,
38
+ 13,
39
+ 201,
40
+ 95,
41
+ 96,
42
+ 53,
43
+ 194,
44
+ 233,
45
+ 7,
46
+ 225,
47
+ 140,
48
+ 36,
49
+ 103,
50
+ 30,
51
+ 69,
52
+ 142,
53
+ 8,
54
+ 99,
55
+ 37,
56
+ 240,
57
+ 21,
58
+ 10,
59
+ 23,
60
+ 190,
61
+ 6,
62
+ 148,
63
+ 247,
64
+ 120,
65
+ 234,
66
+ 75,
67
+ 0,
68
+ 26,
69
+ 197,
70
+ 62,
71
+ 94,
72
+ 252,
73
+ 219,
74
+ 203,
75
+ 117,
76
+ 35,
77
+ 11,
78
+ 32,
79
+ 57,
80
+ 177,
81
+ 33,
82
+ 88,
83
+ 237,
84
+ 149,
85
+ 56,
86
+ 87,
87
+ 174,
88
+ 20,
89
+ 125,
90
+ 136,
91
+ 171,
92
+ 168,
93
+ 68,
94
+ 175,
95
+ 74,
96
+ 165,
97
+ 71,
98
+ 134,
99
+ 139,
100
+ 48,
101
+ 27,
102
+ 166,
103
+ 77,
104
+ 146,
105
+ 158,
106
+ 231,
107
+ 83,
108
+ 111,
109
+ 229,
110
+ 122,
111
+ 60,
112
+ 211,
113
+ 133,
114
+ 230,
115
+ 220,
116
+ 105,
117
+ 92,
118
+ 41,
119
+ 55,
120
+ 46,
121
+ 245,
122
+ 40,
123
+ 244,
124
+ 102,
125
+ 143,
126
+ 54,
127
+ 65,
128
+ 25,
129
+ 63,
130
+ 161,
131
+ 1,
132
+ 216,
133
+ 80,
134
+ 73,
135
+ 209,
136
+ 76,
137
+ 132,
138
+ 187,
139
+ 208,
140
+ 89,
141
+ 18,
142
+ 169,
143
+ 200,
144
+ 196,
145
+ 135,
146
+ 130,
147
+ 116,
148
+ 188,
149
+ 159,
150
+ 86,
151
+ 164,
152
+ 100,
153
+ 109,
154
+ 198,
155
+ 173,
156
+ 186,
157
+ 3,
158
+ 64,
159
+ 52,
160
+ 217,
161
+ 226,
162
+ 250,
163
+ 124,
164
+ 123,
165
+ 5,
166
+ 202,
167
+ 38,
168
+ 147,
169
+ 118,
170
+ 126,
171
+ 255,
172
+ 82,
173
+ 85,
174
+ 212,
175
+ 207,
176
+ 206,
177
+ 59,
178
+ 227,
179
+ 47,
180
+ 16,
181
+ 58,
182
+ 17,
183
+ 182,
184
+ 189,
185
+ 28,
186
+ 42,
187
+ 223,
188
+ 183,
189
+ 170,
190
+ 213,
191
+ 119,
192
+ 248,
193
+ 152,
194
+ 2,
195
+ 44,
196
+ 154,
197
+ 163,
198
+ 70,
199
+ 221,
200
+ 153,
201
+ 101,
202
+ 155,
203
+ 167,
204
+ 43,
205
+ 172,
206
+ 9,
207
+ 129,
208
+ 22,
209
+ 39,
210
+ 253,
211
+ 19,
212
+ 98,
213
+ 108,
214
+ 110,
215
+ 79,
216
+ 113,
217
+ 224,
218
+ 232,
219
+ 178,
220
+ 185,
221
+ 112,
222
+ 104,
223
+ 218,
224
+ 246,
225
+ 97,
226
+ 228,
227
+ 251,
228
+ 34,
229
+ 242,
230
+ 193,
231
+ 238,
232
+ 210,
233
+ 144,
234
+ 12,
235
+ 191,
236
+ 179,
237
+ 162,
238
+ 241,
239
+ 81,
240
+ 51,
241
+ 145,
242
+ 235,
243
+ 249,
244
+ 14,
245
+ 239,
246
+ 107,
247
+ 49,
248
+ 192,
249
+ 214,
250
+ 31,
251
+ 181,
252
+ 199,
253
+ 106,
254
+ 157,
255
+ 184,
256
+ 84,
257
+ 204,
258
+ 176,
259
+ 115,
260
+ 121,
261
+ 50,
262
+ 45,
263
+ 127,
264
+ 4,
265
+ 150,
266
+ 254,
267
+ 138,
268
+ 236,
269
+ 205,
270
+ 93,
271
+ 222,
272
+ 114,
273
+ 67,
274
+ 29,
275
+ 24,
276
+ 72,
277
+ 243,
278
+ 141,
279
+ 128,
280
+ 195,
281
+ 78,
282
+ 66,
283
+ 215,
284
+ 61,
285
+ 156,
286
+ 180,
287
+ ];
288
+ this._gradP = new Array(512);
289
+ this._perm = new Array(512);
290
+ }
291
+ noise2d(x, y) {
292
+ const { _gradP, _perm } = this;
293
+ let X = Math.floor(x), Y = Math.floor(y);
294
+ x = x - X;
295
+ y = y - Y;
296
+ X = X & 255;
297
+ Y = Y & 255;
298
+ 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);
299
+ const u = this._fade(x);
300
+ return this._lerp(this._lerp(n00, n10, u), this._lerp(n01, n11, u), this._fade(y));
301
+ }
302
+ noise3d(x, y, z) {
303
+ const { _gradP: gradP, _perm: perm } = this;
304
+ let X = Math.floor(x), Y = Math.floor(y), Z = Math.floor(z);
305
+ x = x - X;
306
+ y = y - Y;
307
+ z = z - Z;
308
+ X = X & 255;
309
+ Y = Y & 255;
310
+ Z = Z & 255;
311
+ 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);
312
+ 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);
313
+ }
314
+ seed(inputSeed) {
315
+ const { _grad3: grad3, _gradP: gradP, _perm: perm, _p: p } = this;
316
+ let seed = inputSeed;
317
+ if (seed > 0 && seed < 1) {
318
+ seed *= 65536;
319
+ }
320
+ seed = Math.floor(seed);
321
+ if (seed < 256) {
322
+ seed |= seed << 8;
323
+ }
324
+ for (let i = 0; i < 256; i++) {
325
+ const v = i & 1 ? p[i] ^ (seed & 255) : p[i] ^ ((seed >> 8) & 255);
326
+ perm[i] = perm[i + 256] = v;
327
+ gradP[i] = gradP[i + 256] = grad3[v % 12];
328
+ }
329
+ }
330
+ _fade(t) {
331
+ return t * t * t * (t * (t * 6 - 15) + 10);
332
+ }
333
+ _lerp(a, b, t) {
334
+ return (1 - t) * a + t * b;
335
+ }
336
+ }
337
+ exports.PerlinNoise = PerlinNoise;
338
+ });
package/umd/index.js ADDED
@@ -0,0 +1,15 @@
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
+ });