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

perlin-noise-3d

v0.5.4

Published

3D Perlin Noise

Downloads

245

Readme

perlin-noise-3d

NPM Version gzip File Size

3D Perlin Noise as JavasScript module adapted from the original algorithm implemented by Ken Perlin on mrl.nyu.edu/~perlin/noise from the SIGGRAPH 2002 paper.

This is based on the previous adapting done by Rune Madsen on rune.noise.js, which was an adaptation from P5.js done by Daniel Shiffman, which was an adaptation from Processing / PApplet.java done by Ben Fry, which was an adaptation from the contributions by Karsten Schmidt aka toxi adapting the code created by the German demo scene group Farbrausch on their demo production "art" ( [email protected] ) adapted from the original work by Ken Perlin. — Props to all of them adaptors!


Install

$ npm install perlin-noise-3d

There are two available files for this module:

  • dist/perlin-noise-3d.js › CommonJS & ES Module
  • dist/perlin-noise-3d.min.js › UMD

Include perlin-noise-3d:

// ES6
import perlinNoise3d from 'perlin-noise-3d'

// CJS
const perlinNoise3d = require('perlin-noise-3d');

Include the minified UMD file for the browser ( dist/perlin-noise-3d.min.js ) or you can add the script directly from unpkg.

<script src="https://unpkg.com/perlin-noise-3d"></script>

Usage

Create an instance then you can get x, y and z values.

const noise = new perlinNoise3d();
      noise.get(x, y, z);

Plant a seed with noiseSeed. i.e:

      noise.noiseSeed(Math.E);

— Example #01 : linear x and noised y

const noise = new perlinNoise3d();
let noiseStep = 0;

for(let x = 0; x < 50; x++ ) {
	let y = noise.get(noiseStep) * 100;
	console.log(x, Math.floor(y));
	noiseStep += 0.1;
}

— Example #02 : plotting a 2D square graph using a seed

let n = new perlinNoise3d();
    n.noiseSeed(Math.PI);

let size = 10;
let output = [];
for (let x = 0; x < size; x++) {
    for (let y = 0; y < size; y++) {
        output.push({ x:x, y:y, value: n.get(x/10, y/10)});
    }
}
console.table(output);

API

perlinNoise3d

Returns an object.You can create your instance as follows: let noise = new perlinNoise3d;

noise.get(x, y, z)

Returns a float : x, y, z are the coordinates where you want to get the value. Both second and third parameter are optional.

noise.noiseSeed(seed)

Set a seed value (float) to get different noise depending on the noise value.