AlphaBehavior<DataType, ParticleType>
Behavior used to control the transparency of particles over their lifetime.
Behavior supports three modes, a static mode where a single value is applied to all particles, a list mode where values are interpolated over the particle's lifetime based on a provided list, and a random mode where a random value from the list is applied to the particle upon initialization.
See
- BehaviorStaticConfig for static configuration options.
- BehaviorSingleListConfig for list configuration options.
Example
// Apply a static alpha value of 0.5 to all particles.
alphaBehavior.applyConfig({
value: 0.5,
});
// Interpolate particle alpha from 0.0 to 1.0 over lifetime.
alphaBehavior.applyConfig({
listData: [
{ time: 0.0, value: 0.0 },
{ time: 1.0, value: 1.0 },
],
mode: "list",
});
// Assign a random alpha value between 0.2 and 0.8.
alphaBehavior.applyConfig({
listData: [
{ time: 0.0, value: 0.2 },
{ time: 1.0, value: 0.8 },
],
mode: "random",
});Extends
EmitterBehavior<AlphaBehaviorConfig,DataType,ParticleType>
Type Parameters
DataType
DataType extends BaseParticleData = BaseParticleData
Type describing the data object stored on particles.
ParticleType
ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>
Type describing the particle used within the emitter.
Implements
InitBehavior<DataType,ParticleType>UpdateBehavior<DataType,ParticleType>
Constructors
Constructor
new AlphaBehavior<DataType, ParticleType>(emitter): AlphaBehavior<DataType, ParticleType>;Creates new instance of AlphaBehavior.
Parameters
emitter
Emitter<DataType, ParticleType>
Emitter instance this behavior belongs to.
Returns
AlphaBehavior<DataType, ParticleType>
Overrides
Accessors
list
Get Signature
get list(): NumberList;Number list used to interpolate alpha values over particle lifetime.
A behavior will always have a list, even when not using list-based configuration, but the list might not be initialized and will be empty in that case.
Returns
mode
Get Signature
get mode(): "static" | "list" | "random";Mode currently used by the behavior.
Returns
"static" | "list" | "random"
Set Signature
set mode(value): void;Parameters
value
"static" | "list" | "random"
Returns
void
staticValue
Get Signature
get staticValue(): number;Alpha value applied to all particles in static mode.
Returns
number
Set Signature
set staticValue(value): void;Parameters
value
number
Returns
void
updateOrder
Get Signature
get updateOrder(): BehaviorOrder;Defines at which step of the update cycle the behavior is applied.
initial: Earliest step, useful when other behaviors depend on this behavior.normal: Default step for most behaviors.late: Latest step, useful for behaviors that should override others or depend on their properties.
Returns
Implementation of
Overrides
Methods
applyConfig()
applyConfig(config): void;Reset the behavior and apply the provided configuration.
Parameters
config
Behavior configuration.
Returns
void
Implementation of
Overrides
getConfig()
getConfig():
| AlphaBehaviorConfig
| undefined;Retrieve the current behavior properties as a configuration object. If the behavior is inactive, undefined is returned.
Returns
| AlphaBehaviorConfig | undefined
Behavior configuration object or undefined if inactive.
Implementation of
Overrides
init()
init(particle): void;Initialize the particle.
Parameters
particle
ParticleType
Particle to initialize.
Returns
void
Implementation of
reset()
protected reset(): void;Reset the behavior to its default state.
Returns
void
Implementation of
Overrides
update()
update(particle): void;Updates the particle.
Parameters
particle
ParticleType
Particle to update.
Returns
void