mesh-particle-system
Particle system for Babylon.js that composites like a standard mesh
Usage:
var MPS = ; var tex = 'particle.png' scene;var capacity = 200;var rate = 30; // particles/secondvar mps = capacity rate scene;mps;
Live demo here.
Installation
npm install mesh-particle-system
To run demo locally (with webpack-dev-server
):
cd mesh-particle-systemnpm installnpm test
API
// constructor optionally takes a starting color and vertex UV ranges for each particlevar startColor = BABYLONColor3;var uRange = 0 1;var vRange = 0 1;var mps = capacity rate scene startColor uRange vRange; // if no material is passed in one will be created (and later disposed) internallymps; // particle system settingsmpsgravity = -5; // y direction only for nowmpsrate = 50; // particles/secondmpsfriction = 099; // velocity *= friction each frame // define ranges that particles go through in their lifetimemps;mps;mps; // set the mesh's initial position by directly accessing itmpsmeshpositiony = 2; // later on, move the mesh by repositioning it// this offsets each particle so they keep a consistent world positionmps; // define a custom particle init function to set mps { pdataposition; pdatavelocity; pdatasize = Math; pdataage = 0; pdatalifetime = Math + 1;} // other stuffmpsstart;mps;mps; // particles get emitted the following framemps;mpsonDispose; // default nullmpsstopOnEmpty // default falsempsdisposeOnEmpty // default false
Recent changes
- 0.10.0
- Adds
setMeshPosition
, removes default behavior of watching mesh position and rebasing automatically - Removes
parent
parameter and behavior
- Adds
- 0.9.0
- Adds
startColor
parameter to constructor
- Adds
- 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