Added SDK 0.28.0
The ParticleSystem object encapsulates the core of a particle system, though most of its functionality is plug-in. It is responsible for enabling emitters to create particles, and to be able to update particle states, sort views and render views of a system. The ParticleSystem object is also responsible for CPU-side simulation of particles for tracked GPU particles, and path prediction for emitters.
Note
This is a low-level particle system API.
Summary
A default 1x1 procedural noise texture for updaters and renderers, with all channels set to the normalized, signed float representation of 0 specifying no noise is to be applied.
Syntax
var texture = ParticleSystem.getDefaultNoiseTexture(graphicsDevice);
Summary
Create a new particle system.
Syntax
var system = ParticleSystem.create({
graphicsDevice : graphicsDevice,
center : [0, 0, 0],
halfExtents : [1, 1, 1],
maxSpeed : 10,
maxParticles : 1024,
zSorted : true,
maxSortSteps : null,
maxLifeTime : 10,
animation : animationTexture,
sharedAnimation : false,
trackingEnabled : false,
timer : null,
synchronizer : systemSynchronizer,
updater : systemUpdater,
renderer : systemRenderer,
shaderManager : shaderManager,
geometry : particleGeometry,
sharedRenderContext : null
});
A ParticleSynchronizer object, to update the system and emit particles when the system is updated via a ParticleRenderable.
If unspecified, a DefaultParticleSynchronizer will be used.
The ParticleUpdater object for the particle system, responsible for defining the techniques and parameters used for GPU side simulation of particles, a function used to work on simulation of CPU side particles, and a prediction function to support retrospective creation of particles by emitters.
If unspecified, a shared DefaultParticleUpdater will be used.
The ParticleRenderer object for the particle system, responsible for rendering particles on the GPU.
If unspecified, a shared DefaultParticleRenderer will be used using the alpha blend mode.
A SharedRenderContext object from which to allocate texture regions for particle states on the GPU.
If unspecified then a per-system set of textures and render targets will be created instead and destroyed along with the system. Otherwise on destruction of the system the allocated region will be released back to the shared render context.
Summary
Destroy particle system. The system cannot be used once it has been destroyed. This will release memory used for particle state textures, as well as any non-shared geometry and animation textures.
Syntax
system.destroy();
Summary
Reset a particle system to initial state.
All particles will be removed from the system, with internal timers reset so that particle system can be recycled.
Syntax
system.reset();
Summary
Create a new particle in the system.
Note that this particle will be created at the end of the current update, and so will not take part in the simulation until the following update occurs.
Note
This method should only be called between beginUpdate and endUpdate
Syntax
var id = system.createParticle({
position: [0, 0, 0],
velocity: [0, 1, 0],
lifeTime: 1.5,
animationRange: [0, 1],
userData: 0,
forceCreation: false,
isTracked: false
});
Default value is false. If true, then this particle will be created, even when there is no space remaining in the system. Under such circumstances, the live particle closest to death will be replaced by the newly created particle.
Note that tracked particles are excluded from such replacement, so that even with forceCreation as true, in the rare event that the system is saturated with tracked particles, the creation will still fail.
The return value is the integer id corresponding to the particle slot used to create this particle. If the particle could not be created, then this id will be equal to null. If the particle is tracked, then this id can be used to query the particles attributes throughout its life.
If the particle was not able to be created, then it is guaranteed that no further attempt to create a particle without forceCreation set to true will succeed until a system update has been performed.
Note that tracked particles will not be killed when their life is exhausted, and must be removed manually. This is to enable particle attributes to be queried even after death to determine final position/velocities.
Summary
Update the state of a cpu-tracked particle in the system. It is up to you to know whether a particle has died and been replaced. Updating the state of a particle that has died will have no effect (it will remain dead), however updating the state of a particle that has died, and been ‘replaced’ will cause the replaced particle to have it’s state updated instead.
Note
This method should only be called between beginUpdate and endUpdate
Syntax
system.updateParticle(particleID, {
position: [0, 0, 0],
velocity: [0, 1, 0],
animationRange: [0, 1],
userData: 0,
isTracked: false
});
Summary
Remove a particle from the system by force. This may be called for any particle, whether tracked or not, but it is up to you to ensure the particle id used refers to the particle you want. If the particle you are removing has already died and been replaced, then this call will remove the replaced particle.
Note
This method should only be called between beginUpdate and endUpdate
Syntax
system.removeParticle(particleID);
Summary
Remove all particles from the system by force.
Note
This method should only be called between beginUpdate and endUpdate
Syntax
system.removeAllParticles();
Summary
Synchronize the system. This method is called by any ParticleRenderable visible in a Scene making use of this system, and may also be called manually if required.
This method will invoke the systems synchronizer method, providing it with the frame and time delta (as determined by the system’s timer).
Note
Method will fail if a synchronizer object was not provided to the system.
Syntax
system.sync(currentFrameIndex);
Summary
Begin an update on the system. At this point particles which would be killed by the update are pre-emptively made available for re-use so that creation of new particles may take their place.
Note
Only a single particle system may be updated at any time.
Syntax
system.beginUpdate(deltaTime, shift);
Summary
Complete an update on a system, at this point the system will be updated including adding newly created particles into the system. This call will return true if there is any possibility of a live particle remaining in the system indicating that a render is required for any view onto the system.
Syntax
var shouldRender = system.endUpdate(deltaTime);
Summary
Query the position of a CPU-tracked particle.
Syntax
var position = system.queryPosition(particleID);
// or
system.queryPosition(particleID, position);
Summary
Query the velocity of a CPU-tracked particle.
Syntax
var velocity = system.queryVelocity(particleID);
// or
system.queryVelocity(particleID, velocity);
Summary
Query the remaining life of a CPU-tracked particle.
Syntax
var remainingLife = system.queryRemainingLife(particleID);
Summary
The center of the particle systems extents in local coordinates.
Note
Read Only
Summary
The half-extents of the particle system in local coordinates.
Note
Read Only
Summary
The maximum speed achievable for any particle in the system.
Note
Read Only
Summary
The ParticleUpdater object assigned to this system. Note that modifying the parameters field of this object will have no effect on any system already using the updater.
Note
Read Only
Summary
The ParticleUpdater object assigned to this system. Note that modifying the parameters field of this object will have no effect on any system already using the renderer.
Note
Read Only
Summary
The TechniqueParameters object encapsulating all parameters defined for the specific updater, and by the system for updating the particle system. You may use this object to change the specific updater parameters exposed, but you should not make changes to those defined by the ParticleSystem itself.
Summary
The TechniqueParameters object encapsulating all parameters defined for the specific renderer, and by the system for updating the particle system. You may use this object to change the specific renderer parameters exposed, but you should not make changes to those defined by the ParticleSystem itself.
Summary
Integer constants defining storage information for particles on the CPU and GPU.
Syntax
var attr = ParticleSystem.PARTICLE_X;