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

mesh-particle-system

v0.11.0

Published

Particle system for Babylon.js that composites like a standard mesh

Downloads

8

Readme

mesh-particle-system

Particle system for Babylon.js that composites like a standard mesh

Usage:

var MPS = require('mesh-particle-system');

var tex = new BABYLON.Texture('particle.png', scene);
var capacity = 200;
var rate = 30;           // particles/second
var mps = new MPS(capacity, rate, scene);
mps.setTexture(tex);

Live demo here.

Installation

npm install mesh-particle-system

To run demo locally (with webpack-dev-server):

cd mesh-particle-system
npm install
npm test

API

// constructor optionally takes a starting color and vertex UV ranges for each particle
var startColor = BABYLON.Color3.White();
var uRange = [0, 1];
var vRange = [0, 1];
var mps = new MPS(capacity, rate, scene, startColor, uRange, vRange);

// if no material is passed in one will be created (and later disposed) internally
mps.setTexture(myTexture, myMaterial);

// particle system settings
mps.gravity = -5; // y direction only for now
mps.rate = 50; // particles/second
mps.friction = 0.99; // velocity *= friction each frame

// define ranges that particles go through in their lifetime
mps.setAlphaRange( 1, 0 );
mps.setColorRange( BABYLON.Color3.Red(), BABYLON.Color3.Green() );
mps.setSizeRange( 1, 0.5 );

// set the mesh's initial position by directly accessing it
mps.mesh.position.y = 2;

// later on, move the mesh by repositioning it
// this offsets each particle so they keep a consistent world position
mps.setMeshPosition(0, 3, 0);

// define a custom particle init function to set 
mps.initParticle = function myInitParticle(pdata) {
  pdata.position.copyFromFloats( /* ... */ );
  pdata.velocity.copyFromFloats( /* ... */ );
  pdata.size = Math.random();
  pdata.age = 0;
  pdata.lifetime = Math.random() + 1;
}

// other stuff
mps.start();
mps.stop();
mps.emit(20); // particles get emitted the following frame
mps.dispose();
mps.onDispose; // default null
mps.stopOnEmpty // default false
mps.disposeOnEmpty // default false

Recent changes

  • 0.10.0
    • Adds setMeshPosition, removes default behavior of watching mesh position and rebasing automatically
    • Removes parent parameter and behavior
  • 0.9.0
    • Adds startColor parameter to constructor
  • 0.8.0
    • Performance fix
  • 0.7.0
    • Texture is now set via method rather than being passed in to constructor
    • Constructor now takes UV ranges, which are baked into particle vertices