Module gamejs/math/noise

A noise generator comparable to Perlin noise, which is useful for generating procedural content.

This implementation provides 2D and 3D noise:

var simplex = new Simplex(); simplex.get(2, 4); simple.get3d(1, 2, 4);

You can optionally pass a seedable pseudo-random number generator to its constructor. This generator object is assumed to have a random() method; Math is used per default:

var Alea = require('gamejs/math/random').Alea;
var simplex = new Simplex(new Alea());

Also see gamejs/math/random for a seedable pseudo random number generator

See

gamejs/utils/prng

Class Simplex

Instance Methods


Simplex (randomNumberGenerator)

Parameters

Object randomNumberGenerator the random number generator to use; most provide `random()` method

Simplex.prototype.get (x, y)

Parameters

Number x
Number y

Returns

Number noise for given position, in range [-1, 1]

Simplex.prototype.get3d (x, y, y)

Parameters

Number x
Number y
Number y

Returns

Number noise for given position, in range [-1, 1]