dot big bang

Developer API
Menu

Class Noise

All
  • Public
  • Public/Protected
  • All

Generates 1D, 2D, 3D, or 4D noise, as numbers in the range 0 to 1 (inclusive).

Hierarchy

  • Noise

Index

Constructors

constructor

  • Construct a new noise generator.

    Parameters

    • kind: NoiseKind

      The style of noise to generate; either NoiseKind.SPIKY or NoiseKind.SMOOTH.

    • Optional seed: string | number

      The seed value; optional. If unspecified, defaults to a random integer.

      Example:

      const noise = new Noise(NoiseKind.SMOOTH, "someSeed");
      

    Returns Noise

Accessors

seed

  • get seed(): string | number
  • set seed(newValue: string | number): void
  • The current seed value.

    You can freely change this value. If you set it to a string, the string will be hashed into a number using Random.hashStringToNum.

    Returns string | number

  • The current seed value.

    You can freely change this value. If you set it to a string, the string will be hashed into a number using Random.hashStringToNum.

    Parameters

    • newValue: string | number

    Returns void

Methods

get1D

  • get1D(x: number): number
  • Using the current seed, get the value at a given 1D position.

    Parameters

    • x: number

      The input position.

    Returns number

    The output noise value, in the range of 0 to 1, inclusive on both ends.

get2D

  • get2D(x: number, y: number): number
  • Using the current seed, get the value at a given 2D position.

    Parameters

    • x: number

      The input x position.

    • y: number

      The input y position.

    Returns number

    The output noise value, in the range of 0 to 1, inclusive on both ends.

get3D

  • get3D(x: number, y: number, z: number): number
  • Using the current seed, get the value at a given 3D position.

    Parameters

    • x: number

      The input x position.

    • y: number

      The input y position.

    • z: number

      The input z position.

    Returns number

    The output noise value, in the range of 0 to 1, inclusive on both ends.

get4D

  • get4D(x: number, y: number, z: number, w: number): number
  • Using the current seed, get the value at a given 4D position.

    Parameters

    • x: number

      The input x position.

    • y: number

      The input y position.

    • z: number

      The input z position.

    • w: number

      The input w position.

    Returns number

    The output noise value, in the range of 0 to 1, inclusive on both ends.

getFromVector2

  • getFromVector2(vec2: Vector2): number
  • Using the current seed, get the value at a given 2D position.

    Parameters

    • vec2: Vector2

      The input position.

    Returns number

    The output noise value, in the range of 0 to 1, inclusive on both ends.

getFromVector3

  • getFromVector3(vec3: Vector3): number
  • Using the current seed, get the value at a given 3D position.

    Parameters

    • vec3: Vector3

      The input position.

    Returns number

    The output noise value, in the range of 0 to 1, inclusive on both ends.

getFromVector4

  • getFromVector4(vec4: Vector4): number
  • Using the current seed, get the value at a given 4D position.

    Parameters

    • vec4: Vector4

      The input position.

    Returns number

    The output noise value, in the range of 0 to 1, inclusive on both ends.