perlin-noise-3d
3D Perlin Noise as JavasScript module adapted from the original algorithm implemented by Ken Perlin on mrl.nyu.edu/~perlin/noise from the SIGGRAPH 2002 paper.
This is based on the previous adapting done by Rune Madsen on rune.noise.js, which was an adaptation from P5.js done by Daniel Shiffman, which was an adaptation from Processing / PApplet.java done by Ben Fry, which was an adaptation from the contributions by Karsten Schmidt aka toxi adapting the code created by the German demo scene group Farbrausch on their demo production "art" ( fr010src.zip@files.scene.org ) adapted from the original work by Ken Perlin. — Props to all of them adaptors!
Install
$ npm install perlin-noise-3d
There are two available files for this module:
dist/perlin-noise-3d.js
› CommonJS & ES Moduledist/perlin-noise-3d.min.js
› UMD
Include perlin-noise-3d
:
// ES6 // CJSconst perlinNoise3d = ;
Include the minified UMD file for the browser ( dist/perlin-noise-3d.min.js
) or you can add the script directly from unpkg.
Usage
Create an instance then you can get x
, y
and z
values.
const noise = ; noise;
Plant a seed with noiseSeed
. i.e:
noise;
linear
x and noised y
— Example #01 : const noise = ;let noiseStep = 0; forlet x = 0; x < 50; x++ let y = noise * 100; console; noiseStep += 01;
— Example #02 : plotting a 2D square graph using a seed
let n = ; n; let size = 10;let output = ;for let x = 0; x < size; x++ for let y = 0; y < size; y++ output; console;
API
perlinNoise3d
Returns an object
.
You can create your instance as follows: let noise = new perlinNoise3d;
noise.get(x, y, z)
Returns a float
: x
, y
, z
are the coordinates where you want to get the value. Both second and third parameter are optional.
noise.noiseSeed(seed)
Set a seed value (float
) to get different noise depending on the noise value.