jwagner / simplex-noise.js

A fast simplex noise implementation in Javascript / Typescript.
MIT License
1.62k stars 130 forks source link

Allow to pass either random function or number #17

Closed ghost closed 6 years ago

ghost commented 6 years ago

Make so random seed can be passed also as value, not only function.

jwagner commented 6 years ago

Thank you for submitting a pull request. I think you have misunderstood something. The random argument is not a seed value, it needs to be an actual function that can be called multiple times to build the permutation table (a shuffled list of indexes).

There is an example in the README the explains how to correctly initialize simplex-noise with a seed:

This can be used with a PRNG like alea to initialize the noise function with a seed:

  var random = new Alea(seed),
   simplex = new SimplexNoise(random),
   value2d = simplex.noise2D(x, y);

Please let me know if you can't get it to work so I can make this more clear in the README.