FastNoiseJS provides N-API bindings for FastNoise, so you can call FastNoise functions in Node.js.
$ npm install fastnoisejs --save
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))
}
}
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))
const fastnoise = require('fastnoisejs')
// Optional seed argument; must be an integer
const noise = fastnoise.Create(324)
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)
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)