Skip to content

Latest commit

 

History

History
93 lines (66 loc) · 2.41 KB

README.md

File metadata and controls

93 lines (66 loc) · 2.41 KB

npmGitHub

FastNoise Lite

FastNoise Lite is an extremely portable open source noise generation library with a large selection of noise algorithms. This library focuses on high performance while avoiding platform/language specific features, allowing for easy ports to as many possible languages.

Features

  • 2D & 3D sampling
  • OpenSimplex2 noise
  • OpenSimplex2S noise
  • Cellular (Voronoi) noise
  • Perlin noise
  • Value noise
  • Value Cubic noise
  • OpenSimplex2-based domain warp
  • Basic Grid Gradient domain warp
  • Multiple fractal options for all of the above

Getting Started

Using FastNoise Lite with npm

To begin install the npm package fastnoise-lite with

Note FastNoise Lite does not support the node.js require(''); function. Instead, enable ES6 modules and import.

import FastNoiseLite from "fastnoise-lite";

let noise = new FastNoiseLite();

Creating a 128x128 Array of OpenSimplex2 Noise

// Create and configure FastNoiseLite object
let noise = new FastNoiseLite();
noise.SetNoiseType(FastNoiseLite.NoiseType.OpenSimplex2);

// Gather noise data
let noiseData = [];

for (let x = 0; x < 128; x++) {
    noiseData[x] = [];

    for (let y = 0; y < 128; y++) {        
        noiseData[x][y] = noise.GetNoise(x,y);
    }
}

// Do something with this data...

Internal Method Overloading

Since JavaScript does not support method overloading it has been simulated to make the user experience more continuous between language versions.

Some of the code has been changed to use switch statements since it provided a minor performance boost in some small frequently used places eg the _Hash methods.

Here is a template for the method overloading:

class FastNoiseLite {
    /**
     * JSdoc
     */
    Method() {
        let R2 = (Param1, Param2) => {
            // do something 2D
        }

        let R3 = (Param1, Param2, Param3) => {
            // do something 3D
        }

        if (arguments.lenght === 2) {
            return R2(arguments[0], arguments[1]);
        }

        if (arguments.length === 3) {
            return R3(arguments[0], arguments[1], arguments[2])
        }
    }

}

DM dev_storm on discord or email w/ any questions or need any support or ask someone in our discord :D