new ParticleSystem()
实现粒子系统。继承自 BaseParticleSystem 类。 粒子通常用于实现火焰、烟雾、水等可视化效果。
- See:
Members
-
burstsArray.<ParticleBurst>
-
An array of
ParticleBurst, emitting bursts of particles at periodic times.- Default Value: undefined
completeEvent
Fires an event when the particle system has reached the end of its lifetime.
emissionRateNumber
The number of particles to emit per second.
- Default Value: 5
emitterParticleEmitter
The particle emitter for this
- Default Value: CircleEmitter
emitterModelMatrixMatrix4
The 4x4 transformation matrix that transforms the particle system emitter within the particle systems local coordinate system.
- Default Value: Matrix4.IDENTITY
endColorColor
The color of the particle at the end of its life.
- Default Value: Color.WHITE
endScaleNumber
The final scale to apply to the image of the particle at the end of its life.
- Default Value: 1.0
imageObject
The URI, HTMLImageElement, or HTMLCanvasElement to use for the billboard.
- Default Value: undefined
isCompleteBoolean
When true, the particle system has reached the end of its lifetime; false otherwise.
lifetimeNumber
How long the particle system will emit particles, in seconds.
- Default Value: Number.MAX_VALUE
loopBoolean
Whether the particle system should loop it's bursts when it is complete.
- Default Value: true
maximumImageSizeCartesian2
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)
maximumMassNumber
Sets the maximum mass of particles in kilograms.
- Default Value: 1.0
maximumParticleLifeNumber
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
maximumSpeedNumber
Sets the maximum bound in meters per second below which a particle's actual speed will be randomly chosen.
- Default Value: 1.0
minimumImageSizeCartesian2
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)
minimumMassNumber
Sets the minimum mass of particles in kilograms.
- Default Value: 1.0
minimumParticleLifeNumber
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
minimumSpeedNumber
Sets the minimum bound in meters per second above which a particle's actual speed will be randomly chosen.
- Default Value: 1.0
modelMatrixMatrix4
The 4x4 transformation matrix that transforms the particle system from model to world coordinates.
- Default Value: Matrix4.IDENTITY
showBoolean
Whether to display the particle system.
- Default Value: true
startColorColor
The color of the particle at the beginning of its life.
- Default Value: Color.WHITE
startScaleNumber
The initial scale to apply to the image of the particle at the beginning of its life.
- Default Value: 1.0
updateCallbackParticleSystem~updateCallback
An array of force callbacks. The callback is passed a Particle and the difference from the last time
- Default Value: undefined
Methods
-
destroy()
-
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 thanisDestroyedwill result in aDeveloperErrorexception. Therefore, assign the return value (undefined) to the object as done in the example.Throws:
-
This object was destroyed, i.e., destroy() was called.
- Type
- DeveloperError
-
-
getCapacity()
-
获取同时激活的粒子最大数量。
Returns:
活动粒子的最大数量。 -
isAlive()
-
获取系统中是否仍有活动粒子。
Returns:
如果还活着则为 True,否则为 false。 -
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 thanisDestroyedwill result in aDeveloperErrorexception.Returns:
Type Description Boolean trueif this object was destroyed; otherwise,false. -
isReady()
-
该系统是否可以使用/渲染
Returns:
如果系统已准备就绪,则为 true。 -
isStarted()
-
获取系统是否已启动。(注意:调用 stop 后仍为 true)。
Returns:
如果已启动,则为 true,否则为 false。 -
isStopping()
-
获取指示粒子系统正在停止的布尔值
Returns:
如果粒子系统正在停止,则为true -
reset()
-
移除全部激活的粒子
-
setParticleType()
-
根据粒子枚举类型,设置粒子的参数
-
start(delay)
-
启动粒子系统并开始发射。
Name Type Description delayNumber 以毫秒为单位定义启动系统前的延迟时间(默认为 this.startDelay)。
- Default Value: 0
stop(stopSubEmitters)
停止粒子系统。
| Name | Type | Description |
|---|---|---|
stopSubEmitters |
Boolean |
如果为 true,将停止当前系统和所有已创建的子系统;如果为 false,则仅停止当前根系统。 |
- Default Value: false
Type Definitions
-
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 particleParticle The particle being updated.
dtNumber The time in seconds since the last update.
Example
function applyGravity(particle, dt) { var position = particle.position; var gravityVector = SuperMap3D.Cartesian3.normalize(position, new SuperMap3D.Cartesian3()); SuperMap3D.Cartesian3.multiplyByScalar(gravityVector, GRAVITATIONAL_CONSTANT * dt, gravityVector); particle.velocity = SuperMap3D.Cartesian3.add(particle.velocity, gravityVector, particle.velocity); }