Skip to content

Particle system documentation

Peter Crew edited this page Jan 6, 2019 · 2 revisions

This page covers the ParticleSystem class, along with all of the classes for particle spawn shapes.


ParticleSystem

This class represents a system of particles, and is responsible for detailing how the particles behave.

Constructor

The constructor takes a single JavaScript object with the following properties:

Name Type Required? Description
texture ParticleTexture Only if colour and additive are not provided. The texture for the particle texture atlas that should be used.
colour Vector3f Only if texture is not provided. The colour of the particle, with normalised values (RGB is from 0-1).
additive boolean Only if texture is not provided. True if additive blending should be used.
spawn ParticleSpawn Yes The spawn shape of the particles.
rate float Yes The number of particles spawned per second.
speed float Yes The average speed of each spawned particle.
gravity float Yes How much gravity affects each particle (1 is standard gravity).
life float Yes The average number of seconds that the particle is alive for.
scale float Yes The average scale of each particle.

Particle spawns

These spawns control how particles are spawned, and are responsible for defining the shape that they create.

CircleSpawn

Spawns particles in a circle.

Constructor

The constructor takes two arguments: a Vector3f defining the normal of the circle (the direction perpendicular to the circle's surface), and a float defining the radius. For example, new CircleSpawn(new Vector3f(0, 0, 1), 5) creates a circle spawn with a radius of five that is parallel to the x-y plane.

CuboidSpawn

Spawns particles in a cuboid shape.

Constructor

The constructor takes a JavaScript object which can have the following properties:

Name Type Required? Description
xScale float Yes The scale of the cuboid in the x direction.
yScale float Yes The scale of the cuboid in the y direction.
zScale float Yes The scale of the cuboid in the z direction.
yOffset float No How high to offset the cuboid from the ground.

LineSpawn

Spawns particles in a line.

Constructor

The constructor takes two arguments: a Vector3f defining the direction of the line , and a float defining the length. For example, new CircleSpawn(new Vector3f(0, 1, 0), 5) creates a line spawn with a length of five that is points straight up.

PointSpawn

Spawns particles from a single point.

Constructor

The constructor is empty, taking no arguments: new PointSpawn().

SphereSpawn

Spawns particles in a sphere shape.

Constructor

The constructor takes a single float argument defining the radius of the sphere, e.g. new SphereSpawn(10) creates a sphere of radius 10.

Clone this wiki locally