It requires typed arrays, if you want to use it in browsers without support you will need to use a polyfill like typedarray.js.
- Simple 2D plasma demo on codepen.io.
- A more complex 3D voxel world generation example.
- Real world usage for creating film grain in my analog film emulator.
By default simplex-noise.js will use Math.random() to seed the noise.
// initializing a new simplex instance// do this only once as it is relatively expensivevar simplex =value2d = simplexvalue3d = simplexvalue4d = simplex;
You can also pass in a seed string which will then be used to initialize the noise using the built in alea PRNG.
var simplex = 'seed'value2d = simplexsameSeed = 'seed'differentSeed = 'different seed';sameSeed === value2ddifferentSeed !== value2d
You can also pass an alternative random function to the constructor that is used to build the permutation table. This can be used with a custom pseudo random number generator:
var random = seedsimplex = randomvalue2d = simplex;
The ALEA PRNG can be found on in the npm package alea.
Node.js is also supported, you can install the package using npm.
var SimplexNoise =simplex = Mathrandomvalue2d = simplex;
For development you can open
perf/index.html and watch the console or run
node perf/benchmark.js in a shell.
There is also a rake task for comparing your current changes can also run
The command works using git stash.
There are some simple unit tests for this library to run them
npm install && npm test
- Included a PRNG based on ALEA to directly allow seeding
- Included typescript definitions
⚠️ This release changes the output of the noise functions. ⚠️
In the future such changes will be released as a new major version.
- Corrected generation of permutation table
- Moved tests to mocha/chai
- Small performance improvement for 2D noise
- Increased entropy by fixing a little initialization issue.
- AMD support
- Changed node.js api, SimplexNoise is now exported directly.
- Added unit tests
- Initial Release
Copyright (c) 2015 Jonas Wagner, licensed under the MIT License (enclosed)
The integrated pseudo random generator is based on code by by Johannes Baagøe.
The typescript definition has been provided by Neonit.