noisejs
noisejs copied to clipboard
Trouble importing
https://stackoverflow.com/questions/70817415/having-trouble-importing-a-library-cannot-set-properties-of-undefined-setting
I'm trying to import this library to my project, but I'm having trouble doing so. It's true that I'm not doing it like it is said to be done on the git demo (doing the js directly in the html file), but my guess is that it should still work.
I have something like this:
import * as NOISE from "../libs/perlin.js";
//...
var y = Math.round(noise.perlin2(x, z)); //like they do in the git example
But I'm getting an error regarding the library itself:
Cannot set properties of undefined (setting 'noise')
at noise.js:18
at noise.js:310
(function(global){
var module = global.noise = {}; /*18*/
//...
module.perlin2 = function(x, y) {
//...
})(this); /*310*/
What am I doing wrong?
Did you already find a solution for this problem?
I have made a simple wrapper for this library with a class in typescript, feel free to use it: https://github.com/alanko0511/noisejs-typescript
@alanko0511, you are a life saver! 🙏