Particle systems have a huge number of uses in graphical simulation. Smoke, fire, and water in particular are often most efficiently emulated with a particle system. Each particle is a simple billboard with a number assigned to it to indicate its age. The transparency of the particle usually increases as it ages. Forces may also be applied to the particle system to simulate wind, gravity, etc.
var mapA = THREE.ImageUtils.loadTexture( "images/smoke.png" );
var cloud = new THREE.Object3D();
scene.add(cloud);
var psys = new SpriteParticleSystem({
cloud:cloud,
rate:3,
num:300,
texture:mapA,
scaleR:[1,5],
speedR:[0,10],
rspeedR:[-0.8,0.8],
lifespan:[3,4],
terminalSpeed:10
});
psys.addForce(new THREE.Vector3(50,0,0));
psys.start();
Before creating the particle system, the texture used for the particles must be loaded and a "cloud" object created. The cloud object is the parent of the particles. The particle system object itself is called SpriteParticleSystem
, and the arguments to the constructor are listed below. Note that the constructor is passed a literal JavaScript object containing all of the option settings. After creating, forces (if any) are added to the particle system using addForce
, and then start
is called to make the system ready for use.