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

vesuvius

v1.0.3

Published

Simplex noise points map (2D and 3D) generator

Downloads

8

Readme

Vesuvius

When working on a new project, I needed a way to procedurally generate points. I used simplex-noise for this and wrote a sort of wrapper for the functionality I needed.

It's open source, so it may be of some help to some of you. The module uses procedural noise (specifically simplex noise) to generate a map (array) of points. These points are noise values exceeding a set threshold. For my use case, these points were stars in a procedurally generated 'universe', but for you they can be anything you want.

So, how does it work?

Install

npm install vesuvius --save

Use it (duh!)

var Generator = require('vesuvius').Generator;

// Create a new Generator object with an integer seed value (4443 in this case)
var generator = new Generator(4443);

You can also pass an options array as the second parameter. These can define boxSize, threshold and dimensions (in the same way as below).

// Set the box size to 10
// For 2D, this means a 10x10 (100) grid
// For 3D this means a 10x10x10 (1000) grid,
// For 4D, this means a 10x10x10x10 (10,000) grid
generator.boxSize(10);

// Set the threshold value
// All values lower than this will not be added to the map
generator.threshold(0.75);

// Set the dimensions for the generator
// 2: 2D (x,y)
// 3: 3D (x, y, z)
// 4: 4D (x, y, z, w)
generator.dimensions(3);

And then, generate the map:

// Generate the map
var map = generator.generate();

The result will be something like this (truncated):

[
	{"x":0,"y":2,"z":3},
	{"x":0,"y":2,"z":6},
	{"x":0,"y":5,"z":8},
	{"x":0,"y":6,"z":1},
	{"x":0,"y":7,"z":0},
	{"x":0,"y":9,"z":4},
	{"x":1,"y":0,"z":3},
	{"x":1,"y":0,"z":4},
	{"x":1,"y":1,"z":2},
	{"x":1,"y":1,"z":8}
]

Note that the Generator does not cache the map in any way! Calling generator.generate() a second time will recalculate all over again and return the same data regardless (since it's procedural noise), if none of the parameters have changed.

Changelog

  • 1.0.3 - 19 November 2015
  • Replaced Alea (repo) with MersenneTwister (repo) as the pseudo-random number generator of choice

License

Copyright 2015 Michiel van der Velde.

This software is licensed under the MIT License.