fastnoisejs
v1.0.1
Published
FastNoise.cc N-API bindings for Node.js!
Downloads
120
Maintainers
Readme
FastNoiseJS
FastNoiseJS provides N-API bindings for FastNoise, so you can call FastNoise functions in Node.js.
Installation
$ npm install fastnoisejs --save
Usage
const fastnoise = require('fastnoisejs')
const noise = fastnoise.Create(123)
noise.SetNoiseType(fastnoise.Simplex)
for (let x = 0; x < 10; x++) {
for (let y = 0; y < 10; y++) {
console.log(noise.GetNoise(x, y))
}
}
API
For more exhaustive documentation, refer to the FastNoise wiki. The example below highlights how fastnoisejs
binds FastNoise
's methods and enumerated types:
#include "FastNoise.h"
#include <iostream>
int main() {
FastNoise noise;
noise.SetNoiseType(FastNoise::Simplex);
std::cout << noise.GetNoise(21, 43) << std::endl;
return 0;
}
const fastnoise = require('fastnoisejs')
const noise = fastnoise.Create()
noise.SetNoiseType(fastnoise.Simplex)
console.log(noise.GetNoise(21, 43))
Noise constructor
const fastnoise = require('fastnoisejs')
// Optional seed argument; must be an integer
const noise = fastnoise.Create(324)
Accessing enumerated types
const fastnoise = require('fastnoisejs')
// This is not an exhaustive list; read the FastNoise wiki
const enums = [
fastnoise.Simplex,
fastnoise.Perlin,
fastnoise.Linear,
fastnoise.Quintic
]
console.log(enums)
Using FastNoise instance methods
const fastnoise = require('fastnoisejs')
const noise = fastnoise.Create()
// SetNoiseType sets the algorithm for noise.GetNoise(x, y)
noise.SetNoiseType(noise.Simplex)
const noiseVals = [
noise.GetSimplex(23, 43),
noise.GetValue(23, 43),
noise.GetPerlin(23, 43),
noise.GetNoise(23, 43)
]
console.log(noiseVals)