jwagner / simplex-noise.js

A fast simplex noise implementation in Javascript / Typescript.
MIT License
1.61k stars 130 forks source link

Browser use #41

Closed fallenartist closed 2 years ago

fallenartist commented 2 years ago

Sorry, if this is a silly question but how do I use this library in a browser? Is there a minified version of the code somewhere that I could include on the front-end? Your linked codepen example probably uses an older version of the lib as the seed oprion doesn't work. Thank you.

jwagner commented 2 years ago

It's definitely not a silly question. If you care about performance you should use npm or yarn and a modern bundler like webpack or parcel. If you just want to hack on something real quick, this should work (in browsers that support modules):

<script type="module">
import  SimplexNoise from 'https://unpkg.com/simplex-noise@3.0.0/dist/esm/simplex-noise.js'
console.log(new SimplexNoise().noise2D(0,1));
</script>
fallenartist commented 2 years ago

Thanks. I somehow managed to miss Codepen helping to import npm packages, so ended up with: import SimplexNoise from "https://cdn.skypack.dev/simplex-noise@3.0.0";