melonJS
    Preparing search index...

    Class Noise

    Coherent value/gradient noise with fractal (fBm / ridged) layering.

    Noise is the renderer-free algorithm: a CPU-samplable field you can read directly with Noise#getNoise2d / Noise#getNoise3d for gameplay (heightmaps, terrain, spawn jitter, flow fields), or feed to a NoiseTexture2d to bake it into a drawable texture.

    Each sample returns a value in the [-1, 1] range. The field is fully deterministic for a given seed, so the same parameters always reproduce the same field.

    const noise = new me.Noise({ type: "simplex", seed: 1337, frequency: 0.02, octaves: 4 });
    const h = noise.getNoise2d(x, y); // -1 .. 1
    Index
    cellularJitter: number
    domainWarp: boolean
    domainWarpAmp: number
    domainWarpFrequency: number
    fractalType: FractalType
    frequency: number
    gain: number
    lacunarity: number
    octaves: number
    offsetX: number
    offsetY: number
    offsetZ: number
    pingPongStrength: number
    seed: number
    type: NoiseType
    • Sample the 1D noise field (a 2D slice at y = 0).

      Parameters

      • x: number

        sample coordinate

      Returns number

      noise value in the [-1, 1] range

    • Sample the 2D noise field at (x, y).

      Parameters

      • x: number

        horizontal sample coordinate

      • y: number

        vertical sample coordinate

      Returns number

      noise value in the [-1, 1] range

    • Sample the 3D noise field at (x, y, z) — useful for animating a 2D field by advancing z over time, or for volumetric/tiling effects.

      Parameters

      • x: number

        sample coordinate

      • y: number

        sample coordinate

      • z: number

        sample coordinate

      Returns number

      noise value in the [-1, 1] range