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

Trouble importing #33

Open
the-Kob opened this issue Jan 22, 2022 · 3 comments
Open

Trouble importing #33

the-Kob opened this issue Jan 22, 2022 · 3 comments

Comments

@the-Kob
Copy link

the-Kob commented Jan 22, 2022

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?

@EdgeCaseLord
Copy link

Did you already find a solution for this problem?

@alanko0511
Copy link

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

@ada-ada-ada-art
Copy link

@alanko0511, you are a life saver! 🙏

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

4 participants