noise3d
Install
npm install noise3d
Usage
var noise = ; var perlin = noise; var brownian = noise; for var x = 0; x < 512; x++ for var y = 0; y < 512; y++ var z = 1; // keep z constant for 2D noise imagexy = 127 + * 128;
Noise functions
All noise functions implement following interface:
value =
x
x coordinatey
y coordinatez
z coordinatevalue
noise value between [-1, +1]
noise.createPerlin(params)
Perlin Noise
var perlin = noise;
params.interpolation
interpolation method (see utility methods)params.permutation
permutation array (numbers 0 to 255 in pseudorandom order)
noise.createCheckerboard(params)
Checkerboard Pattern
var checker = noise;
params.interpolation
interpolation method (see utility methods)params.size
size between checkerboard rectangles
noise.createConstant(params)
Constant Value
var constant = noise;
params.value
constant value between [-1, +1]
noise.createInverter(params)
Inverts noise values
var invert = noise;
params.noise
the noise function (x, y, z) to invert
noise.createBrownianMotion
Fractal Brownian Motion
var brownian = noise;
params.octaves
number of octavesparams.persistence
persistence (amplitude)params.noise
input noise function to fractionally combine
Utility methods
Interpolation
All interpolation methods implement following interface:
value =
- noise.interpolation.nearestNeighbour
- noise.interpolation.linear
- noise.interpolation.cosine
noise.array.range(a, b)
Create an array with items between a and b
noisearray == 3 4 5
noise.array.shuffle(array, random)
Shuffle an array
noisearray
array
the array to be shuffledrandom
a random function that generates numbers between [0, 1)