Zum Hauptinhalt springen

ParticleEmitter

Description​

This component makes an entity emit particles.

Properties​

PropertyTypeDefaultDescription
stoppedbooleanfalsePlayback state of the emitter
emitterLifenumber0The lifetime of the emitter in seconds
particlesPerShotinteger20Particles per emission
emitDelaynumber0.1The time between particle emissions
minimumLifespannumber1Minimum lifetime range for each particle
maximumLifespannumber1Maximum lifetime range for each particle
massnumber1Mass of each particle
gravitynumber0.2Gravity factor of each particle
scalenumber0.2Uniform scale of each particle
forceXnumber5Force applied to each particle in the X direction
forceYnumber12Force applied to each particle in the Y direction
forceZnumber5Force applied to each particle in the Z direction
spreadnumber360Area and direction that each particles spawns relative to its origin
radialVelocitynumber5Amount of radial velocity applied to each particle
spawnAreaTypestring'point'Supported types are: 'point', 'box' and 'sphere'
spawnAreaWidthnumber0Width of the spawn area box (Box only)
spawnAreaHeightnumber0Height of the spawn area box (Box only)
spawnAreaDepthnumber0Depth of the spawn area box (Box only)
spawnAreaRadiusnumber0Radius of the spawn area sphere (Sphere only)
boundingZoneTypestring'none'Supported types are: 'none', 'box', 'sphere'
boundingZoneWidthnumber0Width of the bounding zone (Box only)
boundingZoneHeightnumber0Height of the bounding zone (Box only)
boundingZoneDepthnumber0Depth of the bounding zone (Box only)
boundingZoneRadiusnumber0Radius of the bounding zone (Sphere only)
resourceTypestring'sprite'Supported types are: 'sprite', and 'model'
resourceUrlstring (URL)''URL of the resource
blendingModestring'none'Supported types are: 'none', 'normal', 'add', 'multiply' and 'subtract'
animateColorbooleanfalseDetermines if color should be animated
colorStartstring (Hex)undefinedThe starting color of each particle
colorEndstring (Hex)undefinedThe ending color of each particle
randomDriftbooleanfalseEnable randomized drifting for each particle
randomDriftRangenumberundefinedDetermines the randomized drift range and speed of each particle
collisionsbooleanfalseDetermines if particles should respond to physics collisions

Functions​

Get​

Returns a read-only reference.

Example

ecs.ParticleEmitter.get(world, component.eid)

Set​

Ensures the component exists on the entity, then assigns the (optional) data to the component.

Example

ecs.ParticleEmitter.set(world, component.eid, {
stopped: false,
emitterLife: 0,
particlesPerShot: 20,
emitDelay: 0.1,
minimumLifespan: 1,
maximumLifespan: 1,
mass: 1,
gravity: 0.2,
scale: 0.2,
forceX: 5,
forceY: 12,
forceZ: 5,
spread: 360
})

Mutate​

Perform an update to the component within a callback function. Return true to indicate no changes made.

Example

ecs.ParticleEmitter.mutate(world, component.eid, (cursor) => {
cursor.emitDelay = 0.05;
cursor.particlesPerShot = 50;
return false;
})

Remove​

Removes the component from the entity.

Example

ecs.ParticleEmitter.remove(world, component.eid)

Has​

Returns true if the component is present on the entity.

Example

ecs.ParticleEmitter.has(world, component.eid)

Reset​

Adds, or resets the component to its default state.

Example

ecs.ParticleEmitter.reset(world, component.eid)

Advanced Functions​

Cursor​

Returns a mutable reference. Cursors are reused so only one cursor for each component can exist at a time.

Example
ecs.ParticleEmitter.cursor(world, component.eid)

Acquire​

Same behavior as cursor, but commit must be called after the cursor is done being used.

Example
ecs.ParticleEmitter.acquire(world, component.eid)

Commit​

Called after acquire. An optional third argument determines whether the cursor was mutated or not.

Example
ecs.ParticleEmitter.commit(world, component.eid)
ecs.ParticleEmitter.commit(world, component.eid, false)

Dirty​

Mark the entity as having been mutated. Only needed in a specific case where systems are mutating data.

Example
ecs.ParticleEmitter.dirty(world, component.eid)