Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in /simplex-noise/dist/cjs/simplex-noise.js:460, random is not a function #60

Closed
maxfer1221 opened this issue Apr 15, 2023 · 3 comments

Comments

@maxfer1221
Copy link

Hello, I installed simplex-noise from npm and get the following error upon using it:

.../node_modules/simplex-noise/dist/cjs/simplex-noise.js:460
        const r = i + ~~(random() * (256 - i));
                         ^

TypeError: random is not a function
    at buildPermutationTable (.../node_modules/simplex-noise/dist/cjs/simplex-noise.js:460:26)
    at createNoise3D (.../node_modules/simplex-noise/dist/cjs/simplex-noise.js:164:18)
    ...

Node.js v18.9.1

I've removed my directories from the log.
I can't tell if this is an issue on my side (and I am missing the random function) or if this was supposed to be Math.random

Thanks!

@jwagner
Copy link
Owner

jwagner commented Apr 15, 2023

Hey Maximo,

Random is passed in as an argument to buildPermutationTable so it shouldn't be Math.random. It is passed along from the random argument to createNoiseND where it defaults to Math.random.

If I had to guess you are doing something along the lines of createNoise3D('some string') instead of createNoise3D(someRandomFunction).

Can you show me how you are calling simplex-noise to get this error?

@maxfer1221
Copy link
Author

That seemed to be the issue. I wasn't passing a parameter but I am now passing an Alea prng.
Thanks for the speedy response!

@jwagner
Copy link
Owner

jwagner commented Apr 17, 2023

Not passing a parameter should not leave random undefined, it should fall back to Math.random. Can you share how you triggered this issue? I'd like to figure out what happenes there. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants