Git Product home page Git Product logo

Particulate.js

Stability Build Status Test Coverage Code Climate Inline Docs File Size

Particulate.js is a JavaScript particle physics micro library 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 ES6, AMD, or commonJS module, or browser global.

import { ParticleSystem, DistanceConstraint } from 'particulate'
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.

Neural.Club's Projects

3d_nn icon 3d_nn

Raymarching neural network using shaders

baron icon baron

Baron is a Bitcoin payment processor that anyone can deploy

bitmerchant icon bitmerchant

A free, self-hostable bitcoin wallet made for merchants.

carbonkey icon carbonkey

Ionic mobile app for authentication and transaction signing.

cheapbase icon cheapbase

like Firebase, but for free (thanks to Heroku).

cm icon cm

Google Chrome extension ContextMenus

conv_arithmetic icon conv_arithmetic

A technical report on convolution arithmetic in the context of deep learning

convnetjs icon convnetjs

Deep Learning in Javascript. Train Convolutional Neural Networks (or ordinary ones) in your browser.

encom-globe icon encom-globe

🌎 WebGL globe based on the boardroom scene from Tron: Legacy

ethereumbook icon ethereumbook

Decentalized Application Development - The Ethereum Guide - Draft

ethereumminingcalculator icon ethereumminingcalculator

Forked from my Bitcoin Mining Calculator. An easy to use Ethereum Mining Profitability Calculator featuring multiple currencies and a responsive profitability chart. Built using AngularJS, jQuery, and charts.js

etherex icon etherex

EtherEx is an open source, fully transparent, next generation decentralized exchange built on Ethereum.

keras-js icon keras-js

Run Keras models in the browser, with GPU support

krypto-trading-bot icon krypto-trading-bot

Self-hosted crypto trading bot (automated high frequency market making) in node.js, angular, typescript and c++

linux icon linux

Linux Vcash Install Script :penguin:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.