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 |
- Source
// 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 |
- Source
angleDamping
Properties| Type | Description |
|---|---|
| number | Per frame multiplier on that spin, 1 keeps it |
- Source
angleSpeed
Properties| Type | Description |
|---|---|
| number | Radians per frame each particle turns in the camera plane, either way; 0 is no spin |
- Source
colorEndA
Properties| Type | Description |
|---|---|
| Color | Color at end of life, randomized between the end colors |
- Source
colorEndB
Properties| Type | Description |
|---|---|
| Color | Color at end of life, randomized between the end colors |
- Source
colorStartA
Properties| Type | Description |
|---|---|
| Color | Color at start of life, randomized between the start colors |
- Source
colorStartB
Properties| Type | Description |
|---|---|
| Color | Color at start of life, randomized between the start colors |
- Source
damping
Properties| Type | Description |
|---|---|
| number | Per frame velocity multiplier |
- Source
emitConeAngle
Properties| Type | Description |
|---|---|
| number | Half angle around the emit direction, PI is every direction |
- Source
emitRate
Properties| Type | Description |
|---|---|
| number | Particles per second, 0 does not emit |
- Source
emitSize
Properties| Type | Description |
|---|---|
| number | | Spawn area, a number for a sphere diameter or a vec3 for a box |
- Source
emitTime
Properties| Type | Description |
|---|---|
| number | How long to keep emitting, 0 is forever |
- Source
fadeRate
Properties| Type | Description |
|---|---|
| number | Fraction of life spent fading, half in and half out |
- Source
gravity
Properties| Type | Description |
|---|---|
| number | Per frame change to velocity y, its own number and not render3D.gravity |
- Source
particleTime
Properties| Type | Description |
|---|---|
| number | How long particles live in seconds |
- Source
particles :Array.<Object>
- Array.<Object>
| Type | Description |
|---|---|
| Array.<Object> | Live particles |
- Source
randomness
Properties| Type | Description |
|---|---|
| number | Extra randomness applied to speed, size and life |
- Source
sizeEnd
Properties| Type | Description |
|---|---|
| number | Particle size at end of life |
- Source
sizeStart
Properties| Type | Description |
|---|---|
| number | Particle size at start of life |
- Source
speed
Properties| Type | Description |
|---|---|
| number | Spawn speed in world units per frame |
- Source
trailTime
Properties| Type | Description |
|---|---|
| number | Seconds of each particle's path to draw as a ribbon behind it, 0 draws billboards |
- Source
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> |
- Source
emitParticle()
Spawn one particle now
- Source
render3D()
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
- Source
update()
Spawn new particles, move the live ones, and go away when done
- Source