本文へスキップ

パーティクルエミッター

概要

このコンポーネントは、エンティティにパーティクルを放出させます。

物件

プロパティタイプデフォルト説明
stoppedbooleanfalsePlayback state of the emitter
emitterLifenumber1The lifetime of the emitter in seconds
particlesPerShotnumber1Particles per emission
emitDelaynumber1The time between particle emissions
minimumLifespannumber1Minimum lifetime range for each particle
maximumLifespannumber10Maximum lifetime range for each particle
massnumber1Mass of each particle
gravitynumber0Gravity factor of each particle
scalenumber1Uniform scale of each particle
forceXnumber0Force applied to each particle in the X direction
forceYnumber0Force applied to each particle in the Y direction
forceZnumber0Force applied to each particle in the Z direction
spreadnumber0Area and direction that each particles spawns relative to its origin
radialVelocitynumber0Amount of radial velocity applied to each particle
spawnAreaTypestring'point'Allowed values: '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''Allowed values: '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'none'Allowed values: 'sprite', 'model'
resourceUrlstring''URL of the resource
blendingModestring''Allowed values: 'none', 'normal', 'add', 'multiply', 'subtract'
animateColorbooleanfalseDetermines if color should be animated
colorStartstring''The starting color of each particle
colorEndstring''The ending color of each particle
randomDriftbooleanfalseEnable randomized drifting for each particle
randomDriftRangenumber0Determines the randomized drift range and speed of each particle
collisionsbooleanfalseDetermines if particles should respond to physics collisions

機能

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)