1 | (function() {
|
2 |
|
3 | const Alea = require('alea');
|
4 | const FastSimplexNoise = require('fast-simplex-noise');
|
5 | const FastUniformNoise = require('fast-uniform-noise');
|
6 |
|
7 | function Indev(opts) {
|
8 | opts = opts || {};
|
9 | const seed = opts.seed;
|
10 |
|
11 | this._random = seed !== undefined ? new Alea(seed) : Math.random;
|
12 | }
|
13 | Indev.prototype = {
|
14 | simplex: function(opts) {
|
15 | opts = opts || {};
|
16 | opts.min = opts.min || 0;
|
17 | opts.max = opts.max || 1;
|
18 | opts.random = this._random;
|
19 |
|
20 | return new FastSimplexNoise(opts);
|
21 | },
|
22 | uniform: function(opts) {
|
23 | opts = opts || {};
|
24 | opts.min = opts.min || 0;
|
25 | opts.max = opts.max || 1;
|
26 | opts.random = this._random;
|
27 |
|
28 | return new FastUniformNoise(opts);
|
29 | },
|
30 | };
|
31 |
|
32 | function indev(opts) {
|
33 | return new Indev(opts);
|
34 | }
|
35 |
|
36 | module.exports = indev;
|
37 |
|
38 | })();
|