0.2.2 • Published 9 months ago

uber-noise v0.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

uber-noise

advanced noise generation for the browser and node.js

  • written in typescript
  • seeded noise
  • based on simplex noise (2D, 3D and 4D)
  • fractal brownian motion (fbm)
  • custom gain, lacunarity, scale, shift, power
  • billowed, ridged, warped, stepped noise
  • seamless tiling noise (1D and 2D)
  • most options can be set to own noise instance

Install

npm i uber-noise
import UberNoise from "uber-noise";

Usage

Basic

Get noise value

const noise = new UberNoise();

// get noise value at x, y, z
const value = noise.get(x, y, z);
// OR
const value = noise.get({x, y, z});

Set noise options

// simple fbm noise
const noise = new UberNoise({
  scale: 0.01,
  octaves: 4,
  gain: 0.5,
  lacunarity: 2.0,
});

Set noise options to noise instance

const noise = new UberNoise({
  // this will set the scale to a noise instance returning values between 0.01 and 0.1
  scale: { min: 0.01, max: 0.1, scale: 0.01 },
});

All options

OptionTypeDefault ValueDescription
seedstring \| numberMath.random()Seed for the noise, defaults to a random value.
minnumber \| UberNoise \| NoiseOptions-1Minimum value of noise.
maxnumber \| UberNoise \| NoiseOptions1Maximum value of noise.
scalenumber \| UberNoise \| NoiseOptions1Scale of the noise ("zoom" level).
powernumber \| UberNoise \| NoiseOptions1Power of the noise (1 = linear, 2 = quadratic).
shiftnumber[][0, 0, 0, 0]Move noise in 2D, 3D, or 4D space.
octavesnumber0Number of layers for fbm noise.
gainnumber \| UberNoise \| NoiseOptions0.5Amplitude multiplier per fbm layer.
lacunaritynumber \| UberNoise \| NoiseOptions2Scale multiplier per fbm layer.
ampsnumber[][]Array of custom amplitudes for each fbm layer.
layersNoiseOptions[][]Custom noise options for each fbm layer.
sharpnessnumber \| UberNoise \| NoiseOptions0Sharpness of noise (0 = normal, 1 = billowed, -1 = ridged).
stepsnumber \| UberNoise \| NoiseOptions0Discretizes the noise into steps.
warpnumber \| UberNoise \| NoiseOptions0Amount to warp the noise.
warpNoiseUberNoiseundefinedCustom noise used to warp the noise.
warp2number \| UberNoise \| NoiseOptions0Second level of warping, only used if warp is used too.
warpNoise2UberNoiseundefinedSecond custom noise for additional warping.
invertbooleanfalseInvert the noise output.
absbooleanfalseTake the absolute value of the noise.
clampbooleanfalseClamp the noise between min and max values (otherwise noise might overflow slightly).
tileXbooleanfalseTile the noise in the x direction.
tileYbooleanfalseTile the noise in the y direction.
tilebooleanfalseTile the noise in x and y directions (overwrites tileX and tileY)
0.2.1

9 months ago

0.2.0

9 months ago

0.2.2

9 months ago

0.1.8

2 years ago

0.1.7

2 years ago

0.1.6

2 years ago

0.1.5

2 years ago

0.1.4

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago