Skip to main content

sm.noise

Contains methods related to random number and noise generation.

Most noise related functions are used for terrain generation.

Functions

floatNoise2d

sm.noise.floatNoise2d( x, y, seed )

A number noise 2D function.

Arguments:
  • x [ number ]: The X value.
  • y [ number ]: The Y value.
  • seed [ int ]: The seed.
Returns:
  • [ number ]: The noise value.

gunSpread

sm.noise.gunSpread( direction, spreadAngle )

Returns a directional vector with a random spread given by a normal distribution.

Arguments:
  • direction [ Vec3 ]: The direction.
  • spreadAngle [ number ]: The spread angle in degrees.
Returns:
  • [ Vec3 ]: The spread direction.

intNoise2d

sm.noise.intNoise2d( x, y, seed )

An integer noise 2D function.

Arguments:
  • x [ number ]: The X value.
  • y [ number ]: The Y value.
  • seed [ int ]: The seed.
Returns:
  • [ int ]: The noise value.

octaveNoise2d

sm.noise.octaveNoise2d( x, y, octaves, seed )

An octave noise 2D function.

Arguments:
  • x [ number ]: The X value.
  • y [ number ]: The Y value.
  • octaves [ int ]: The octaves.
  • seed [ int ]: The seed.
Returns:
  • [ number ]: The noise value.

perlinNoise2d

sm.noise.perlinNoise2d( x, y, seed )

A perlin noise 2D function.

Arguments:
  • x [ number ]: The X value.
  • y [ number ]: The Y value.
  • seed [ int ]: The seed.
Returns:
  • [ number ]: The noise value.

randomNormalDistribution

sm.noise.randomNormalDistribution( mean, deviation )

Returns a random number according to the normal random number distribution.

Values near the mean are the most likely.

Standard deviation affects the dispersion of generated values from the mean.

Arguments:
  • mean [ number ]: The mean.
  • deviation [ number ]: The deviation.
Returns:
  • [ number ]: The random number.

randomRange

sm.noise.randomRange( a, b )

Returns a random number N such that a <= N <= b.

Arguments:
  • a [ number ]: The lower bound.
  • b [ number ]: The upper bound.
Returns:
  • [ number ]: The random number.

simplexNoise1d

sm.noise.simplexNoise1d( x )

A simplex noise 1D function.

Arguments:
  • x [ number ]: The X value.
Returns:
  • [ number ]: The noise value.

simplexNoise2d

sm.noise.simplexNoise2d( x, y )

A simplex noise 2D function.

Arguments:
  • x [ number ]: The X value.
  • y [ number ]: The Y value.
Returns:
  • [ number ]: The noise value.