ParticleSystem

new Cesium.ParticleSystem(options)

A ParticleSystem manages the updating and display of a collection of particles.
参数名称 类型 描述信息
options object 可选 Object with the following properties:
参数名称 类型 默认值 描述信息
show boolean true 可选 Whether to display the particle system.
updateCallback ParticleSystem.updateCallback 可选 The callback function to be called each frame to update a particle.
emitter ParticleEmitter new CircleEmitter(0.5) 可选 The particle emitter for this system.
modelMatrix Matrix4 Matrix4.IDENTITY 可选 The 4x4 transformation matrix that transforms the particle system from model to world coordinates.
emitterModelMatrix Matrix4 Matrix4.IDENTITY 可选 The 4x4 transformation matrix that transforms the particle system emitter within the particle systems local coordinate system.
emissionRate number 5 可选 The number of particles to emit per second.
bursts Array.<ParticleBurst> 可选 An array of ParticleBurst, emitting bursts of particles at periodic times.
loop boolean true 可选 Whether the particle system should loop its bursts when it is complete.
scale number 1.0 可选 Sets the scale to apply to the image of the particle for the duration of its particleLife.
startScale number 可选 The initial scale to apply to the image of the particle at the beginning of its life.
endScale number 可选 The final scale to apply to the image of the particle at the end of its life.
color Color Color.WHITE 可选 Sets the color of a particle for the duration of its particleLife.
startColor Color 可选 The color of the particle at the beginning of its life.
endColor Color 可选 The color of the particle at the end of its life.
image object 可选 The URI, HTMLImageElement, or HTMLCanvasElement to use for the billboard.
imageSize Cartesian2 new Cartesian2(1.0, 1.0) 可选 If set, overrides the minimumImageSize and maximumImageSize inputs that scale the particle image's dimensions in pixels.
minimumImageSize Cartesian2 可选 Sets the minimum bound, width by height, above which to randomly scale the particle image's dimensions in pixels.
maximumImageSize Cartesian2 可选 Sets the maximum bound, width by height, below which to randomly scale the particle image's dimensions in pixels.
sizeInMeters boolean 可选 Sets if the size of particles is in meters or pixels. true to size the particles in meters; otherwise, the size is in pixels.
speed number 1.0 可选 If set, overrides the minimumSpeed and maximumSpeed inputs with this value.
minimumSpeed number 可选 Sets the minimum bound in meters per second above which a particle's actual speed will be randomly chosen.
maximumSpeed number 可选 Sets the maximum bound in meters per second below which a particle's actual speed will be randomly chosen.
lifetime number Number.MAX_VALUE 可选 How long the particle system will emit particles, in seconds.
particleLife number 5.0 可选 If set, overrides the minimumParticleLife and maximumParticleLife inputs with this value.
minimumParticleLife number 可选 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.
maximumParticleLife number 可选 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.
mass number 1.0 可选 Sets the minimum and maximum mass of particles in kilograms.
minimumMass number 可选 Sets the minimum bound for the mass of a particle in kilograms. A particle's actual mass will be chosen as a random amount above this value.
maximumMass number 可选 Sets the maximum mass of particles in kilograms. A particle's actual mass will be chosen as a random amount below this value.
Demo:

成员(属性)

An array of ParticleBurst, emitting bursts of particles at periodic times.
默认值: undefined
Fires an event when the particle system has reached the end of its lifetime.
The number of particles to emit per second.
默认值: 5
The particle emitter for this
默认值: CircleEmitter
The 4x4 transformation matrix that transforms the particle system emitter within the particle systems local coordinate system.
默认值: Matrix4.IDENTITY
The color of the particle at the end of its life.
默认值: Color.WHITE
The final scale to apply to the image of the particle at the end of its life.
默认值: 1.0
The URI, HTMLImageElement, or HTMLCanvasElement to use for the billboard.
默认值: 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.
默认值: Number.MAX_VALUE
Whether the particle system should loop it's bursts when it is complete.
默认值: true
Sets the maximum bound, width by height, below which to randomly scale the particle image's dimensions in pixels.
默认值: new Cartesian2(1.0, 1.0)
Sets the maximum mass of particles in kilograms.
默认值: 1.0

maximumParticleLife : number

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.
默认值: 5.0
Sets the maximum bound in meters per second below which a particle's actual speed will be randomly chosen.
默认值: 1.0
Sets the minimum bound, width by height, above which to randomly scale the particle image's dimensions in pixels.
默认值: new Cartesian2(1.0, 1.0)
Sets the minimum mass of particles in kilograms.
默认值: 1.0

minimumParticleLife : number

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.
默认值: 5.0
Sets the minimum bound in meters per second above which a particle's actual speed will be randomly chosen.
默认值: 1.0
The 4x4 transformation matrix that transforms the particle system from model to world coordinates.
默认值: Matrix4.IDENTITY
Whether to display the particle system.
默认值: 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.
默认值: false
The color of the particle at the beginning of its life.
默认值: Color.WHITE
The initial scale to apply to the image of the particle at the beginning of its life.
默认值: 1.0
An array of force callbacks. The callback is passed a Particle and the difference from the last time
默认值: undefined

方法

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 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.
参考:

isDestroyed()boolean

Returns true if this object was destroyed; otherwise, false.

If this object was destroyed, it should not be used; calling any function other than isDestroyed will result in a DeveloperError exception.
返回值:
true if this object was destroyed; otherwise, false.
参考:

定义的类型

Cesium.ParticleSystem.updateCallback(particle, dt)

A function used to modify attributes of the particle at each time step. This can include force modifications, color, sizing, etc.
参数名称 类型 描述信息
particle Particle The particle being updated.
dt number The time in seconds since the last update.
使用示例:
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);
}