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

particulate

v0.3.3

Published

Particle physics micro library.

Downloads

12

Readme

Particulate.js

Stability Build Status Test Coverage Code Climate Inline Docs

Particulate.js is a JavaScript particle physics micro library (~3.7kb gz) designed to be simple, extensible, fast, and stable; it is capable of running a simulation with tens of thousands of particles and tens of thousands of constraints in real time. The core system is derived from that described in Advanced Character Physics by Thomas Jakobsen.

WebsiteExamplesDocsTests

Usage

The library provides an interface for defining a particle system with many inter-particle constraints and globally acting forces. Internal management of particle positions and state is designed to be easily integrated with a WebGL rendering pipeline, although no specific rendering scheme is required.

Install

Install with npm or bower or download the built package.

npm install particulate --save
bower install particulate --save

Then include the library as an AMD or commonJS module, or browser global.

define(['particulate'], function (Particulate) { /* ... */ });
var Particulate = require('particulate');
var Particulate = window.Particulate;

Integrate Renderer

The following is a simplified version of the chain example, rendered with Three.js:

// ..................................................
// Define particle chain system
//

var particleCount = 5;
var relaxIterations = 2;

var system = Particulate.ParticleSystem.create(particleCount, relaxIterations);
var dist = Particulate.DistanceConstraint.create(10, [0, 1, 1, 2, 2, 3, 3, 4]);
var pin = Particulate.PointConstraint.create([0, 0, 0], 0);
var gravity = Particulate.DirectionalForce.create([0, -0.05, 0]);

system.addConstraint(dist);
system.addPinConstraint(pin);
system.addForce(gravity);

// ..................................................
// Integrate with Three.js
//

var scene = new THREE.Scene();

// Use system positions buffer
var vertices = new THREE.BufferAttribute(system.positions, 3);

// Use distance constraint indices
var indices = new THREE.BufferAttribute(new Uint16Array(dist.indices));

// Particles
var dotsGeom = new THREE.BufferGeometry();
dotsGeom.addAttribute('position', vertices);

var dots = new THREE.PointCloud(dotsGeom,
  new THREE.PointCloudMaterial({ size : 2 }));

// Connections
var linesGeom = new THREE.BufferGeometry();
linesGeom.addAttribute('position', vertices);
linesGeom.addAttribute('index', indices);

var lines = new THREE.Line(linesGeom,
  new THREE.LineBasicMaterial());

scene.add(dots);
scene.add(lines);

function animate() {
  system.tick(1);
  dotsGeom.attributes.position.needsUpdate = true; // Flag to update WebGL buffer
  render();
}

Development

Grunt is used for building and testing the library. You should have one path for each dependency:

which node npm grunt

After resolving development dependencies, run:

npm install

Test

Run a development server with grunt server. Visit localhost:8000/examples/ to view examples or localhost:8000/test/ to run tests. The development version of the library will be automatically rebuilt when any file matching /src/**/* changes.

Tests can also be run from the command line with grunt test.

Build

Running grunt build will generate a fully commented development version of the library as well as a minified production version in /dist.

Document

Source code is documented in-line using YUIDoc syntax and compiled by running grunt yuidoc.

Contribute

There is not a formal style guide, but please maintain the existing coding style. Any new or changed functionality should be documented and covered by unit tests.