You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
// Use default Math.random (non predictable)letsimplex=newSimplexNoise(Math.random);functionsetSeed(s){// Update seed to make Math.random predictableseedMathRandom(s)// Before:// Recreate noise instancesimplex=newSimplexNoise(Math.random);// After proposed change:// Reset permutation tablesimplex.init(Math.random);}setSeed('0')
Let me know how that sounds and if you need a PR.
The text was updated successfully, but these errors were encountered:
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.
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.
Feature request
Move the following into a
SimplexNoise.init()
(or other name) method:simplex-noise.js/simplex-noise.ts
Lines 80 to 87 in 37b3125
Use 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.
The text was updated successfully, but these errors were encountered: