English中文

ParticleSystem

new Cesium.ParticleSystem(options)

粒子系统管理粒子集合的更新和显示。 A ParticleSystem manages the updating and display of a collection of particles.
名称 Name 类型 Type 说明 Description
options object 可选 optional 具有以下属性的对象: Object with the following properties:
名称 Name 类型 Type 默认值 Default 说明 Description
show boolean true 可选 optional 是否显示粒子系统。 Whether to display the particle system.
updateCallback ParticleSystem.updateCallback 可选 optional 每帧调用回调函数来更新粒子。 The callback function to be called each frame to update a particle.
emitter ParticleEmitter new CircleEmitter(0.5) 可选 optional 该系统的粒子发射器。 The particle emitter for this system.
modelMatrix Matrix4 Matrix4.IDENTITY 可选 optional 将粒子系统从模型变换到世界坐标的 4x4 变换矩阵。 The 4x4 transformation matrix that transforms the particle system from model to world coordinates.
emitterModelMatrix Matrix4 Matrix4.IDENTITY 可选 optional 4x4 变换矩阵,用于在粒子系统局部坐标系内变换粒子系统发射器。 The 4x4 transformation matrix that transforms the particle system emitter within the particle systems local coordinate system.
emissionRate number 5 可选 optional 每秒发射的粒子数。 The number of particles to emit per second.
bursts Array.<ParticleBurst> 可选 optional 一个数组 An array of ParticleBurst,周期性地发射粒子爆发。 , emitting bursts of particles at periodic times.
loop boolean true 可选 optional 粒子系统在完成时是否应循环其爆发。 Whether the particle system should loop its bursts when it is complete.
scale number 1.0 可选 optional 设置在粒子生命周期内应用于粒子图像的比例。 Sets the scale to apply to the image of the particle for the duration of its particleLife.
startScale number 可选 optional 应用于粒子生命初期图像的初始比例。 The initial scale to apply to the image of the particle at the beginning of its life.
endScale number 可选 optional 应用到粒子寿命结束时的图像的最终比例。 The final scale to apply to the image of the particle at the end of its life.
color Color Color.WHITE 可选 optional 设置粒子在其粒子生命周期内的颜色。 Sets the color of a particle for the duration of its particleLife.
startColor Color 可选 optional 粒子在其生命开始时的颜色。 The color of the particle at the beginning of its life.
endColor Color 可选 optional 粒子在其生命结束时的颜色。 The color of the particle at the end of its life.
image object 可选 optional 用于广告牌的 URI、HTMLImageElement 或 HTMLCanvasElement。 The URI, HTMLImageElement, or HTMLCanvasElement to use for the billboard.
imageSize Cartesian2 new Cartesian2(1.0, 1.0) 可选 optional 如果设置,则覆盖minimumImageSize和maximumImageSize输入,以像素为单位缩放粒子图像的尺寸。 If set, overrides the minimumImageSize and maximumImageSize inputs that scale the particle image's dimensions in pixels.
minimumImageSize Cartesian2 可选 optional 设置最小边界(宽度乘高度),高于该边界可随机缩放粒子图像的尺寸(以像素为单位)。 Sets the minimum bound, width by height, above which to randomly scale the particle image's dimensions in pixels.
maximumImageSize Cartesian2 可选 optional 设置最大边界(宽度乘高度),低于该边界可随机缩放粒子图像的尺寸(以像素为单位)。 Sets the maximum bound, width by height, below which to randomly scale the particle image's dimensions in pixels.
sizeInMeters boolean 可选 optional 设置粒子的大小是以米还是像素为单位。 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 可选 optional 如果设置,则用该值覆盖最小速度和最大速度输入。 If set, overrides the minimumSpeed and maximumSpeed inputs with this value.
minimumSpeed number 可选 optional 设置以米每秒为单位的最小界限,高于该界限将随机选择粒子的实际速度。 Sets the minimum bound in meters per second above which a particle's actual speed will be randomly chosen.
maximumSpeed number 可选 optional 设置以米每秒为单位的最大界限,低于该界限将随机选择粒子的实际速度。 Sets the maximum bound in meters per second below which a particle's actual speed will be randomly chosen.
lifetime number Number.MAX_VALUE 可选 optional 粒子系统发射粒子的时间长度(以秒为单位)。 How long the particle system will emit particles, in seconds.
particleLife number 5.0 可选 optional 如果设置,则使用该值覆盖minimumParticleLife和maximumParticleLife输入。 If set, overrides the minimumParticleLife and maximumParticleLife inputs with this value.
minimumParticleLife number 可选 optional 设置粒子生命可能持续时间的最小界限(以秒为单位),超过该界限将随机选择粒子的实际生命。 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 可选 optional 设置粒子生命可能持续时间的最大界限(以秒为单位),低于该界限将随机选择粒子的实际生命。 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 可选 optional 设置粒子的最小和最大质量(以千克为单位)。 Sets the minimum and maximum mass of particles in kilograms.
minimumMass number 可选 optional 设置粒子质量的最小界限(以千克为单位)。粒子的实际质量将被选择为高于该值的随机量。 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 可选 optional 设置粒子的最大质量(以千克为单位)。粒子的实际质量将被选择为低于该值的随机量。 Sets the maximum mass of particles in kilograms. A particle's actual mass will be chosen as a random amount below this value.
演示: Demo:

成员 Members

一个数组 An array of ParticleBurst,周期性地发射粒子爆发。 , emitting bursts of particles at periodic times.
默认值: Default Value: undefined
当粒子系统达到其生命周期终点时触发事件。 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
4x4 变换矩阵,用于在粒子系统局部坐标系内变换粒子系统发射器。 The 4x4 transformation matrix that transforms the particle system emitter within the particle systems local coordinate system.
默认值: Default Value: Matrix4.IDENTITY
粒子在其生命结束时的颜色。 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
用于广告牌的 URI、HTMLImageElement 或 HTMLCanvasElement。 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
设置最大边界(宽度乘高度),低于该边界可随机缩放粒子图像的尺寸(以像素为单位)。 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

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.
默认值: 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
设置最小边界(宽度乘高度),高于该边界可随机缩放粒子图像的尺寸(以像素为单位)。 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

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.
默认值: 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
将粒子系统从模型变换到世界坐标的 4x4 变换矩阵。 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
粒子在其生命开始时的颜色。 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
强制回调数组。回调传递了一个 An array of force callbacks. The callback is passed a Particle 以及与上次的区别 and the difference from the last time
默认值: Default Value: undefined

方法 Methods

销毁该对象持有的 WebGL 资源。销毁对象可以确定性地释放 WebGL 资源,而不是依赖垃圾收集器来销毁该对象。 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.
另见: See:

isDestroyed()boolean

如果该对象被销毁则返回 true;否则为假。 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.
返回: Returns:
true 如果该物体被摧毁;否则, if this object was destroyed; otherwise, false.
另见: See:

类型定义 Type Definitions

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.
名称 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);
}
需要帮助吗?获得答案的最快方法是从社区和团队那里获得答案 Need help? The fastest way to get answers is from the community and team on the Cesium Forum.