API

Managing The Solid Particle System

Once built, the SPS mesh has all the properties and methods that you can apply to any mesh. In addition, there are useful properties you can use with the SPS. You should already have seen some of them.

PropertyTypeUse
SPS.particles
particle[]
iterate over this array in initParticles()
SPS.nbParticles
number
total number of particles in the SPS
SPS.billboard
Boolean
turns particles towards camera; false by default
SPS.counter
number
for your own usage; it's not set by the SPS

When working with JavaScript you can add your own properties like capacity or rate if needed.

When you no longer need your SPS, you can dispose of it to free memory with

SPS.dispose();
SPS = null; // tells the GC the reference can be cleaned up also

When you are not going to use some particle features, you can set other SPS properties to false to disable them. You can always enable them again with true. This improves scene performance because no attempt will be made to update these properties.

PropertyTypeDefaultUse
SPS.computeParticleRotation
Boolean
true
allows or prevents computing particle.rotation
SPS.computeParticleTexture
Boolean
true
allows or prevents computing particle.uvs
SPS.computeParticleColor
Boolean
true
allows or prevents from computing particle.color
SPS.computeParticleVertex
Boolean
false
allows or prevents calling the custom updateParticleVertex() function

These properties affect only the SPS.setParticles() process. You can change them between calls to SPS.setParticles(). For example, setting SPS.computeParticleColor to false after the first call to SPS.setParticles() allows particle colors set during initParticles() to be applied, but prevents any later color updates in subsequent calls to SPS.setParticles(). When SPS.setParticles() is inside the render loop, this can be very beneficial.

Tetra fountain color and texture not updated: Tetrahedron Fountain Color And Texture Not Updated