Class: ParticleSystem

ParticleSystem

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

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

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 than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.

See:
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 than isDestroyed will result in a DeveloperError exception.

See:
Returns:
Type Description
Boolean true if 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
delay Number

以毫秒为单位定义启动系统前的延迟时间(默认为 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
particle Particle

The particle being updated.

dt Number

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);
}

ParticleSystem

new ParticleSystem(options)

A ParticleSystem manages the updating and display of a collection of particles.

Name Type Description
options Object 可选

Object with the following properties:

Name Type Default Description
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.

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.

sizeInMeters Boolean false 可选

Sets unit of particle size is meters or pixels

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

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

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 than isDestroyed will result in a DeveloperError exception. Therefore, assign the return value (undefined) to the object as done in the example.

See:
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 than isDestroyed will result in a DeveloperError exception.

See:
Returns:
Type Description
Boolean true if 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
delay Number

以毫秒为单位定义启动系统前的延迟时间(默认为 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
particle Particle

The particle being updated.

dt Number

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);
}