Closed dmnsgn closed 2 years ago
Hey Damien,
Thanks for the feature request. I don't quite understand your use case yet. A simplex noise instance contains nothing but the permutation table.
Why do you need to reinitialize and existing instance of simplex noise, why couldn't you just recreate it?
On a side note, I would strongly advice against 'monkey patching' the built in Math.random. Patching built-ins can disable optimizations and break third party code. Just pass in your own random function.
Cheers, Jonas
A simplex noise instance contains nothing but the permutation table. Why do you need to reinitialize and existing instance of simplex noise, why couldn't you just recreate it?
It is true, I could recreate it, the feature request is probably a very small optimisation here eg. not having to instance the SimplexNoise class when changing the seed function (which sometimes happens often in creative-coding land). My assumption is that keeping the instance would be faster than recreate it (but it might be negligible).
Just pass in your own random function.
Yep 100% right, I am trying to change that too in our lib.
I'm closing this issue since there aren't any more classes in 4.0.
Feature request
Move the following into a
SimplexNoise.init()
(or other name) method: https://github.com/jwagner/simplex-noise.js/blob/37b3125a48ec3347c7a66d6e12ce2e78447ada99/simplex-noise.ts#L80-L87Use case
When updating the random number generator, we are forced to recreate an instance of
SimplexNoise
. With this, we could create a single instance and reinit it if the PRNG changed:Let me know how that sounds and if you need a PR.