sm.noise

Contains methods related to random number and noise generation.

Most noise related functions are used for terrain generation.

Functions:

  • floatNoise2d
  • gunSpread
  • intNoise2d
  • octaveNoise2d
  • perlinNoise2d
  • randomNormalDistribution
  • randomRange
  • simplexNoise1d
  • simplexNoise2d

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

    A number noise 2d function.

    Parameters:

    TypeNameDescription
    numberxThe X value.
    numberyThe Y value.
    integerseedThe seed.

    Returns:

    TypeDescription
    numberThe noise value.

    sm.noise.gunSpread(direction, spreadAngle)

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

    Parameters:

    TypeNameDescription
    Vec3directionThe direction.
    numberspreadAngleThe spread angle in degrees.

    Returns:

    TypeDescription
    Vec3The spread direction.

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

    An integer noise 2d function.

    Parameters:

    TypeNameDescription
    numberxThe X value.
    numberyThe Y value.
    integerseedThe seed.

    Returns:

    TypeDescription
    integerThe noise value.

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

    An octave noise 2d function.

    Parameters:

    TypeNameDescription
    numberxThe X value.
    numberyThe Y value.
    integeroctavesThe octaves.
    integerseedThe seed.

    Returns:

    TypeDescription
    numberThe noise value.

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

    A perlin noise 2d function.

    Parameters:

    TypeNameDescription
    numberxThe X value.
    numberyThe Y value.
    integerseedThe seed.

    Returns:

    TypeDescription
    numberThe noise value.

    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.

    Parameters:

    TypeNameDescription
    numbermeanThe mean.
    numberdeviationThe deviation.

    Returns:

    TypeDescription
    numberThe random number.

    sm.noise.randomRange(a, b)

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

    Parameters:

    TypeNameDescription
    numberaThe lower bound.
    numberbThe upper bound.

    Returns:

    TypeDescription
    numberThe random value.

    sm.noise.simplexNoise1d(x)

    A simplex noise 1d function.

    Parameters:

    TypeNameDescription
    numberxThe X value.

    Returns:

    TypeDescription
    numberThe noise value.

    sm.noise.simplexNoise2d(x, y)

    A simplex noise 2d function.

    Parameters:

    TypeNameDescription
    numberxThe X value.
    numberyThe Y value.

    Returns:

    TypeDescription
    numberThe noise value.