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:
Type | Name | Description |
number | x | The X value. |
number | y | The Y value. |
integer | seed | The seed. |
Returns:
Type | Description |
number | The noise value. |
sm.noise.gunSpread(direction, spreadAngle)
Returns a directional vector with a random spread given by a normal distribution.
Parameters:
Type | Name | Description |
Vec3 | direction | The direction. |
number | spreadAngle | The spread angle in degrees. |
Returns:
Type | Description |
Vec3 | The spread direction. |
sm.noise.intNoise2d(x, y, seed)
An integer noise 2d function.
Parameters:
Type | Name | Description |
number | x | The X value. |
number | y | The Y value. |
integer | seed | The seed. |
Returns:
Type | Description |
integer | The noise value. |
sm.noise.octaveNoise2d(x, y, octaves, seed)
An octave noise 2d function.
Parameters:
Type | Name | Description |
number | x | The X value. |
number | y | The Y value. |
integer | octaves | The octaves. |
integer | seed | The seed. |
Returns:
Type | Description |
number | The noise value. |
sm.noise.perlinNoise2d(x, y, seed)
A perlin noise 2d function.
Parameters:
Type | Name | Description |
number | x | The X value. |
number | y | The Y value. |
integer | seed | The seed. |
Returns:
Type | Description |
number | The 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:
Type | Name | Description |
number | mean | The mean. |
number | deviation | The deviation. |
Returns:
Type | Description |
number | The random number. |
sm.noise.randomRange(a, b)
Returns a random number N such that `a <= N <= b`.
Parameters:
Type | Name | Description |
number | a | The lower bound. |
number | b | The upper bound. |
Returns:
Type | Description |
number | The random value. |
sm.noise.simplexNoise1d(x)
A simplex noise 1d function.
Parameters:
Type | Name | Description |
number | x | The X value. |
Returns:
Type | Description |
number | The noise value. |
sm.noise.simplexNoise2d(x, y)
A simplex noise 2d function.
Parameters:
Type | Name | Description |
number | x | The X value. |
number | y | The Y value. |
Returns:
Type | Description |
number | The noise value. |