npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

noise3d

v1.0.0

Published

3D Noise

Downloads

17

Readme

noise3d

Install

npm install noise3d

Usage

var noise = require("noise3d");

var perlin = noise.createPerlin({
	interpolation: noise.interpolation.linear,
	permutation: noise.array.shuffle(noise.array.range(0, 255), Math.random)
});

var brownian = noise.createBrownianMotion({
	octaves: 4,
	persistence: 0.5,
	noise: perlin
});

for (var x = 0; x < 512; x++) {
	for (var y = 0; y < 512; y++) {
		var z = 1; // keep z constant for 2D noise
		image[x][y] = 127 + brownian(x / 64, y / 64, z) * 128;
	}
}

Noise functions

All noise functions implement following interface:

value = noise(x, y, z)
  • x x coordinate
  • y y coordinate
  • z z coordinate
  • value noise value between [-1, +1]

noise.createPerlin(params)

Perlin Noise

var perlin = noise.createPerlin({
	interpolation: noise.interpolation.linear,
	permutation: noise.array.shuffle(noise.array.range(0, 255), Math.random)
});
  • params.interpolation interpolation method (see utility methods)
  • params.permutation permutation array (numbers 0 to 255 in pseudorandom order)

noise.createCheckerboard(params)

Checkerboard Pattern

var checker = noise.createCheckerboard({
	interpolation: noise.interpolation.nearestNeighbour,
	size: 2
});
  • params.interpolation interpolation method (see utility methods)
  • params.size size between checkerboard rectangles

noise.createConstant(params)

Constant Value

var constant = noise.createConstant({
	value: 0.3
});
  • params.value constant value between [-1, +1]

noise.createInverter(params)

Inverts noise values

var invert = noise.createInverter({
	noise: perlin
});
  • params.noise the noise function (x, y, z) to invert

noise.createBrownianMotion

Fractal Brownian Motion

var brownian = noise.createBrownianMotion({
	octaves: 4,
	persistence: 0.5,
	noise: perlin
});
  • params.octaves number of octaves
  • params.persistence persistence (amplitude)
  • params.noise input noise function to fractionally combine

Utility methods

Interpolation

All interpolation methods implement following interface:

value = interpolate(a, b, t)
  • noise.interpolation.nearestNeighbour
  • noise.interpolation.linear
  • noise.interpolation.cosine

noise.array.range(a, b)

Create an array with items between a and b

noise.array.range(3, 5) == [3, 4, 5]

noise.array.shuffle(array, random)

Shuffle an array

noise.array.shuffle([3, 4, 5], Math.random)
  • array the array to be shuffled
  • random a random function that generates numbers between [0, 1)