Constructor
new ParticleEmitter3D(pos3Dopt, emitSizeopt, emitTimeopt, emitRateopt, emitConeAngleopt, tileInfoopt, colorStartAopt, colorStartBopt, colorEndAopt, colorEndBopt, particleTimeopt, sizeStartopt, sizeEndopt, speedopt, dampingopt, gravityopt, fadeRateopt, randomnessopt, additiveopt)
Create a particle emitter
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
pos3D | Vector3 | <optional> | World space position of the emitter | |
emitSize | number | | <optional> | 0 | Spawn area, a number for a sphere diameter or a vec3 for a box |
emitTime | number | <optional> | 0 | How long to keep emitting, 0 is forever |
emitRate | number | <optional> | 100 | Particles per second, 0 does not emit |
emitConeAngle | number | <optional> | Half angle around the emit direction, PI is every direction | |
tileInfo | TileInfo | | <optional> | Tile to render particles with, or a whole texture, undefined is untextured | |
colorStartA | Color | <optional> | Color at start of life, randomized between the start colors | |
colorStartB | Color | <optional> | ||
colorEndA | Color | <optional> | Color at end of life, randomized between the end colors | |
colorEndB | Color | <optional> | ||
particleTime | number | <optional> | 0.5 | How long particles live in seconds |
sizeStart | number | <optional> | 0.1 | Particle size at start of life |
sizeEnd | number | <optional> | 1 | Particle size at end of life |
speed | number | <optional> | 0.1 | Spawn speed in world units per frame |
damping | number | <optional> | 1 | Per frame velocity multiplier, 1 is none |
gravity | number | <optional> | 0 | Per frame change to velocity y, negative pulls down; its own number, not render3D.gravity, so the 2D emitter's gravityScale has no equivalent here |
fadeRate | number | <optional> | 0.1 | Fraction of life spent fading, half in and half out |
randomness | number | <optional> | 0.2 | Extra randomness applied to speed, size and life |
additive | boolean | <optional> | false | Additive blending |
// fire: a stream upward, yellow fading to transparent red, additive
new ParticleEmitter3D(vec3(), .5, 0, 100, .3, undefined, hsl(.12, 1, .6), hsl(.08, 1, .5), hsl(0, 1, .5, 0), hsl(0, 1, .25, 0), 1, .5, 1.5, .05, .95, 0, .3, .2, true);Extends
- EngineObject3D
Members
additive
Properties| Type | Description |
|---|---|
| boolean | Additive blending |
angleDamping
Properties| Type | Description |
|---|---|
| number | Per frame multiplier on that spin, 1 keeps it |
angleSpeed
Properties| Type | Description |
|---|---|
| number | Radians per frame each particle turns in the camera plane, either way; 0 is no spin |
collideLevel
Properties| Type | Description |
|---|---|
| boolean | Particles hit the level, the height maps and voxel maps, bouncing by restitution and sliding along by friction; off by default, it tests each particle's move against the level every frame |
colorEndA
Properties| Type | Description |
|---|---|
| Color | Color at end of life, randomized between the end colors |
colorEndB
Properties| Type | Description |
|---|---|
| Color | Color at end of life, randomized between the end colors |
colorStartA
Properties| Type | Description |
|---|---|
| Color | Color at start of life, randomized between the start colors |
colorStartB
Properties| Type | Description |
|---|---|
| Color | Color at start of life, randomized between the start colors |
damping
Properties| Type | Description |
|---|---|
| number | Per frame velocity multiplier |
emitConeAngle
Properties| Type | Description |
|---|---|
| number | Half angle around the emit direction, PI is every direction |
emitRate
Properties| Type | Description |
|---|---|
| number | Particles per second, 0 does not emit |
emitSize
Properties| Type | Description |
|---|---|
| number | | Spawn area, a number for a sphere diameter or a vec3 for a box |
emitTime
Properties| Type | Description |
|---|---|
| number | How long to keep emitting, 0 is forever |
fadeRate
Properties| Type | Description |
|---|---|
| number | Fraction of life spent fading, half in and half out |
gravity
Properties| Type | Description |
|---|---|
| number | Per frame change to velocity y, its own number and not render3D.gravity |
particleCollideCallback :Particle3DCollideCallback|undefined
- Particle3DCollideCallback |
undefined
| Type | Description |
|---|---|
| Particle3DCollideCallback | | Decides if a particle stops where it hits the level, with collideLevel on; a callback that returns nothing lets it through |
particleCount
Properties| Type | Description |
|---|---|
| number | How many particles are alive, the first that many of particleData |
particleCreateCallback :Particle3DCallback|undefined
- Particle3DCallback |
undefined
| Type | Description |
|---|---|
| Particle3DCallback | | Called with each particle as it is made |
particleData
Properties| Type | Description |
|---|---|
| Float32Array | The live particles, 21 floats each: position, velocity, start and end color, start and end size, life, age, angle, spin, and trail point count; the emitter owns them, nothing else needs to |
particleDestroyCallback :Particle3DCallback|undefined
- Particle3DCallback |
undefined
| Type | Description |
|---|---|
| Particle3DCallback | | Called with each particle as it goes, its life over or destroyed |
particleTime
Properties| Type | Description |
|---|---|
| number | How long particles live in seconds |
particleUpdateCallback :Particle3DCallback|undefined
- Particle3DCallback |
undefined
| Type | Description |
|---|---|
| Particle3DCallback | | Called with each particle each update, after it moves |
particleView :Particle3D
- Particle3D
| Type | Description |
|---|---|
| Particle3D | The particle the callbacks get, one object for every particle and call |
randomness
Properties| Type | Description |
|---|---|
| number | Extra randomness applied to speed, size and life |
sizeEnd
Properties| Type | Description |
|---|---|
| number | Particle size at end of life |
sizeStart
Properties| Type | Description |
|---|---|
| number | Particle size at start of life |
speed
Properties| Type | Description |
|---|---|
| number | Spawn speed in world units per frame |
trailData :Float32Array|undefined
- Float32Array |
undefined
| Type | Description |
|---|---|
| Float32Array | | The trail points of every particle, trailMax per particle oldest first, when trailTime is set |
trailMax
Properties| Type | Description |
|---|---|
| number | Trail points kept per particle, from trailTime |
trailTime
Properties| Type | Description |
|---|---|
| number | Seconds of each particle's path to draw as a ribbon behind it, 0 draws billboards; with engineVariableStep it keeps trailTime * frameRate updates of path |
worldPos3D :Vector3|undefined
- Vector3 |
undefined
| Type | Description |
|---|---|
| Vector3 | | Where the emitter was at its last update, for when its parent is destroyed |
Methods
destroy(immediateopt)
Stop emitting, and go away once the particles already out have finished like the 2D emitter's do
| Name | Type | Attributes | Description |
|---|---|---|---|
immediate | boolean | <optional> |
emitParticle()
Spawn one particle now
render3D() → {void}
Draw the particles, as flat squares or as streaks when trailTime is set
- The whole emitter sorts as one thing, its particles are not sorted against each other
- With render3D.instancing on the squares go out as one instanced draw of render3D.billboardMesh
- Type:
- void
update()
Spawn new particles, move the live ones, and go away when done