粒子系统管理粒子集合的更新和显示。 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>
-
默认值: 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
4x4 变换矩阵,用于在粒子系统局部坐标系内变换粒子系统发射器。 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
用于广告牌的 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
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
将粒子系统从模型变换到世界坐标的 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
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
销毁该对象持有的 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
一旦对象被销毁,就不应再使用;调用除 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:
如果该对象被销毁则返回 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
如果该对象被破坏,则不应使用它;调用除 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
用于在每个时间步修改粒子属性的函数。这可以包括力修改、颜色、尺寸等。 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);
}
