🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

fastnoise-lite

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fastnoise-lite

FastNoise Lite is an extremely portable open source noise generation library with a large selection of noise algorithms

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
1
Created
Source

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
  • 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

Keywords

noise

FAQs

Package last updated on 05 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts