Class c3dl.ParticleSystem
A subsystem is one part of a particle system. A particle system may have
many subsystem. A fire particle system for example will have a smoke
subsystem, flame subsystem and sparks subsystem. Even though fire is a
particle system, it must be divided into parts since parts of the
system behave differently.
Defined in: particlesystem.js.
| Constructor Attributes | Constructor Name and Description |
|---|---|
| Method Attributes | Method Name and Description |
|---|---|
|
emit(numToEmit)
Emit a number of particles all at once.
|
|
|
Get the acceleration of all the particles.
|
|
|
get the desination blend factor.
|
|
|
Get the maximum color range.
|
|
|
Get the maximum number of seconds for which any particle can live.
|
|
|
Get the maximum values for each xyz component any particle can
be assigned when emitted.
|
|
|
Get the minimum color range.
|
|
|
Get the minimum amount of seconds for which any particle can live.
|
|
|
Get the total amount of particles in the system, including dead ones.
|
|
|
getParticle(i)
Get the particle at index i.
|
|
|
Get the source blending factor.
|
|
|
Get the texture which all particles are assigned.
|
|
|
init(numParticles)
Initialize the subsystem.
|
|
|
isReady()
is the subsystem ready to render?
|
|
|
Removed the particle at index 'index' from being update and rendered.
|
|
|
postRender(glCanvas3D, scene)
Re-enable the depth testing, lighting, etc.
|
|
|
render(glCanvas3D, scene)
Draw all the particles which are alive.
|
|
|
setAcceleration(acceleration)
Set the acceleration of this subsystem.
|
|
|
setBlendEquation(blenEq)
(src * srcBlend) Eq (dst * dstBlend)
|
|
|
setDstBlend(dstBlend)
Set the destination blend factor.
|
|
|
setEmitRate(particlesPerSecond)
Set the amount of particles to emit per second.
|
|
|
setMaxColor(maxColor)
Set the maximum color range a particle can be assigned.
|
|
|
setMaxLifetime(maxLifetime)
Set the maximum number of seconds for which any particle can live.
|
|
|
setMaxVelocity(maxVelocity)
|
|
|
setMinColor(minParticleColor)
Set the minimum color values each particle can be.
|
|
|
setMinLifetime(minParticleLifetime)
Set the minimum amount of seconds for which particles will live.
|
|
|
setMinVelocity(minVelocity)
|
|
|
setPosition(vec)
|
|
|
setSrcBlend(srcBlend)
Set the Source blending factor.
|
|
|
setTexture(textureName)
Set the texures of the particles.
|
|
|
translate(vec)
testing funciton
|
|
|
update(timeStep)
Update the positions of the particles if they are alive.
|
Method Detail
emit(numToEmit)
Emit a number of particles all at once. If the amount of particles
to emit exceeds the amount which are available, the last remaining
particles are emitted. If there are no particles available to emit,
none are emitted.
- Parameters:
- numToEmit
getAcceleration()
Get the acceleration of all the particles. This is sometimes
gravity, but does not have to be.
{int}
getDstBlend()
get the desination blend factor.
- Returns:
- {int} the destination blend factor.
{Array}
getMaxColor()
Get the maximum color range. The max color range
is an array of components which each contain the
maximum value each component can be assigned. components
range from 0 to 1.
- Returns:
- {Array}
getMaxLifetime()
Get the maximum number of seconds for which any particle can live.
- Returns:
- the maximum number of seconds for which any particle can live.
{Array}
getMaxVelocity()
Get the maximum values for each xyz component any particle can
be assigned when emitted.
- Returns:
- {Array} the maximum values for each xyz component any particle can be assigned when emitted.
{Array}
getMinColor()
Get the minimum color range.
- Returns:
- {Array}
getMinLifetime()
Get the minimum amount of seconds for which any particle can live.
- Returns:
- the minimum amount of seconds for which any particle can live.
getMinVelocity()
getNumParticles()
Get the total amount of particles in the system, including dead ones.
getParticle(i)
Get the particle at index i.
- Parameters:
- {int} i
- the index of the particle to get.
{int}
getSrcBlend()
Get the source blending factor.
- Returns:
- {int} the source blending factor.
getTexCoords()
{string}
getTexture()
Get the texture which all particles are assigned.
- Returns:
- {string} the texture which all particles are assigned.
getTextureID()
getVertices()
init(numParticles)
Initialize the subsystem. This must be called before the particle
system is actually used.
- Parameters:
- {integer} numParticles
isReady()
is the subsystem ready to render?
- Returns:
- true if the subsystem is ready to render.
killParticle()
Removed the particle at index 'index' from being update and rendered.
- Parameters:
postRender(glCanvas3D, scene)
Re-enable the depth testing, lighting, etc.
- Parameters:
- glCanvas3D
- {Scene} scene
render(glCanvas3D, scene)
Draw all the particles which are alive.
- Parameters:
- glCanvas3D
- {Scene} scene
setAcceleration(acceleration)
Set the acceleration of this subsystem. This is commonly gravity, but can be
any valid vector.
- Parameters:
- {Array} acceleration
setBlendEquation(blenEq)
(src * srcBlend) Eq (dst * dstBlend)
- Parameters:
- {int} blenEq
setDstBlend(dstBlend)
Set the destination blend factor. parameter must be one of:
c3dl.const.ZERO,
c3dl.const.ONE,
c3dl.const.SRC_COLOR,
c3dl.const.ONE_MINUS_SRC_COLOR,
c3dl.const.SRC_ALPHA,
c3dl.const.ONE_MINUS_SRC_ALPHA,
c3dl.const.DST_ALPHA,
c3dl.const.ONE_MINUS_DST_ALPHA,
c3dl.const.DST_COLOR,
c3dl.const.ONE_MINUS_DST_COLOR or
c3dl.const.SRC_ALPHA_SATURATE
- Parameters:
- {int} dstBlend
setEmitRate(particlesPerSecond)
Set the amount of particles to emit per second. To stop emission, pass in zero.
- Parameters:
- particlesPerSecond
setMaxColor(maxColor)
Set the maximum color range a particle can be assigned. Each component
must range from 0 to 1 inclusive.
- Parameters:
- {Array} maxColor
- - array of 4 floating point values ranging from 0 to 1 inclusive.
setMaxLifetime(maxLifetime)
Set the maximum number of seconds for which any particle can live.
Value must be greater than zero.
- Parameters:
- {float} maxLifetime
setMaxVelocity(maxVelocity)
- Parameters:
- maxVelocity
setMinColor(minParticleColor)
Set the minimum color values each particle can be.
- Parameters:
- {Array} minParticleColor
- the minimum Color values each particle can be.
setMinLifetime(minParticleLifetime)
Set the minimum amount of seconds for which particles will live.
Value must be greater than zero.
- Parameters:
- minParticleLifetime
- the minimum amount of seconds for which the particles can live.
setMinVelocity(minVelocity)
- Parameters:
- minVelocity
setPosition(vec)
- Parameters:
- vec
setSrcBlend(srcBlend)
Set the Source blending factor. parameter must be one of:
c3dl.const.ZERO,
c3dl.const.ONE,
c3dl.const.SRC_COLOR,
c3dl.const.ONE_MINUS_SRC_COLOR,
c3dl.const.SRC_ALPHA,
c3dl.const.ONE_MINUS_SRC_ALPHA,
c3dl.const.DST_ALPHA,
c3dl.const.ONE_MINUS_DST_ALPHA,
c3dl.const.DST_COLOR,
c3dl.const.ONE_MINUS_DST_COLOR or
c3dl.const.SRC_ALPHA_SATURATE
- Parameters:
- {int} srcBlend
setTexture(textureName)
Set the texures of the particles.
- Parameters:
- textureName
translate(vec)
testing funciton
- Parameters:
- vec
update(timeStep)
Update the positions of the particles if they are alive. Also,
calculate how many particles to emit if the emit rate has been
set.
- Parameters:
- {float} timeStep