Fast implementation of simplex noise using ES6. Based on source of Jonas Wagner. Added octaves, amplitude, scale, and distribution. Good explanation of these parameters may be found here. Only 3D version + time is implemented. By default all configs === 1
.
Simplex noise may be used for generationg terrains, clouds, fog and different visualisations. It's
used in game development and computer graphics. The idea behind is very simple. You just need to
create an instance of Simplex
class and call noise()
function. It returns height (or z coordinate),
which may be used to create 3D or 2D terrain. Playing with colors and parameters, which are described
below you may generate different realistic worlds.
scale [0..1]
- zoom coefficient.0
- max zoom,1
- min zoomamplitude [0..1]
- similar to amplitude in waves. Means a range of returning function valuesdistrib [0..X]
-0..1
- noise function will return top values,1..X
noise function will return buttom valuesoctaves [1..X]
- amount of details of a 3D map. Less value, means less details.random
- reference to random function, which return values between0..1
.Math.random()
- by default
let simplex = new Simplex({distrib: 2, scale: .009, octaves: 8, amplitude: .005});
let t = 0;
/**
* Call this function many times to obtain dynamic noise
*/
function drawNoise(width, height) {
for (let x = 0; x < width; x++) {
for (let y = 0; y < height; y++) {
const z = simplex.noise(x, y, t);
// draw x,y,z point
}
}
t += .001;
}
drawNoise(128, 128);
Just put any html file into Chrome browser