A ParticleSystem manages the updating and display of a collection of particles.
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
optional
Object with the following properties:
|
Members
bursts : Array.<ParticleBurst>
An array of
ParticleBurst
, emitting bursts of particles at periodic times.
-
Default Value:
undefined
complete : Event
Fires an event when the particle system has reached the end of its lifetime.
The number of particles to emit per second.
-
Default Value:
5
The particle emitter for this
-
Default Value:
CircleEmitter
emitterModelMatrix : Matrix4
The 4x4 transformation matrix that transforms the particle system emitter within the particle systems local coordinate system.
-
Default Value:
Matrix4.IDENTITY
endColor : Color
The color of the particle at the end of its life.
-
Default Value:
Color.WHITE
The final scale to apply to the image of the particle at the end of its life.
-
Default Value:
1.0
The URI, HTMLImageElement, or HTMLCanvasElement to use for the billboard.
-
Default Value:
undefined
When
true
, the particle system has reached the end of its lifetime; false
otherwise.
How long the particle system will emit particles, in seconds.
-
Default Value:
Number.MAX_VALUE
Whether the particle system should loop it's bursts when it is complete.
-
Default Value:
true
maximumImageSize : Cartesian2
Sets the maximum bound, width by height, below which to randomly scale the particle image's dimensions in pixels.
-
Default Value:
new Cartesian2(1.0, 1.0)
Sets the maximum mass of particles in kilograms.
-
Default Value:
1.0
Sets the maximum bound in seconds for the possible duration of a particle's life below which a particle's actual life will be randomly chosen.
-
Default Value:
5.0
Sets the maximum bound in meters per second below which a particle's actual speed will be randomly chosen.
-
Default Value:
1.0
minimumImageSize : Cartesian2
Sets the minimum bound, width by height, above which to randomly scale the particle image's dimensions in pixels.
-
Default Value:
new Cartesian2(1.0, 1.0)
Sets the minimum mass of particles in kilograms.
-
Default Value:
1.0
Sets the minimum bound in seconds for the possible duration of a particle's life above which a particle's actual life will be randomly chosen.
-
Default Value:
5.0
Sets the minimum bound in meters per second above which a particle's actual speed will be randomly chosen.
-
Default Value:
1.0
modelMatrix : Matrix4
The 4x4 transformation matrix that transforms the particle system from model to world coordinates.
-
Default Value:
Matrix4.IDENTITY
Whether to display the particle system.
-
Default Value:
true
Gets or sets if the particle size is in meters or pixels.
true
to size particles in meters; otherwise, the size is in pixels.
-
Default Value:
false
startColor : Color
The color of the particle at the beginning of its life.
-
Default Value:
Color.WHITE
The initial scale to apply to the image of the particle at the beginning of its life.
-
Default Value:
1.0
updateCallback : ParticleSystem.updateCallback
An array of force callbacks. The callback is passed a
Particle
and the difference from the last time
-
Default Value:
undefined
Methods
Destroys the WebGL resources held by this object. Destroying an object allows for deterministic
release of WebGL resources, instead of relying on the garbage collector to destroy this object.
Once an object is destroyed, it should not be used; calling any function other than
Once an object is destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception. Therefore,
assign the return value (undefined
) to the object as done in the example.
Throws:
-
DeveloperError : This object was destroyed, i.e., destroy() was called.
Returns true if this object was destroyed; otherwise, false.
If this object was destroyed, it should not be used; calling any function other than
If this object was destroyed, it should not be used; calling any function other than
isDestroyed
will result in a DeveloperError
exception.
Returns:
true
if this object was destroyed; otherwise, false
.
Type Definitions
A function used to modify attributes of the particle at each time step. This can include force modifications,
color, sizing, etc.
Name | Type | Description |
---|---|---|
particle |
Particle | The particle being updated. |
dt |
Number | The time in seconds since the last update. |
Example:
function applyGravity(particle, dt) {
const position = particle.position;
const gravityVector = Cesium.Cartesian3.normalize(position, new Cesium.Cartesian3());
Cesium.Cartesian3.multiplyByScalar(gravityVector, GRAVITATIONAL_CONSTANT * dt, gravityVector);
particle.velocity = Cesium.Cartesian3.add(particle.velocity, gravityVector, particle.velocity);
}