ScaleBehavior<DataType, ParticleType>
Behavior used to control the scale 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 provided lists, and a random mode where random values from the lists are applied to the particle upon initialization.
See
- BehaviorStaticConfig for static configuration options.
- BehaviorXYListConfig for list configuration options.
Example
// Apply a static scale of 2x on both axes to all particles.
scaleBehavior.applyConfig({
value: { x: 2, y: 2 },
});
// Interpolate particle scale from 0.5x to 1.5x on X axis and 1.0x to 2.0x on Y axis over lifetime.
scaleBehavior.applyConfig({
xListData: [
{ time: 0.0, value: 0.5 },
{ time: 1.0, value: 1.5 },
],
yListData: [
{ time: 0.0, value: 1.0 },
{ time: 1.0, value: 2.0 },
],
mode: "list",
});
// Assign a random scale between 1.0x and 3.0x on X axis and between 0.5x and 2.5x on Y axis.
scaleBehavior.applyConfig({
xListData: [
{ time: 0.0, value: 1.0 },
{ time: 1.0, value: 3.0 },
],
yListData: [
{ time: 0.0, value: 0.5 },
{ time: 1.0, value: 2.5 },
],
mode: "random",
});Extends
EmitterBehavior<ScaleBehaviorConfig,DataType,ParticleType>
Type Parameters
DataType
DataType extends 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 ScaleBehavior<DataType, ParticleType>(emitter): ScaleBehavior<DataType, ParticleType>;Creates a new ScaleBehavior.
Parameters
emitter
Emitter<DataType, ParticleType>
Emitter instance this behavior belongs to.
Returns
ScaleBehavior<DataType, ParticleType>
Overrides
Accessors
mode
Get Signature
get mode(): "static" | "list" | "random";Current mode 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(): PointData;Static scale value applied to all particles.
Returns
PointData
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
xList
Get Signature
get xList(): NumberList;Number list used to interpolate X-axis scale 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
yList
Get Signature
get yList(): NumberList;Number list used to interpolate Y-axis scale 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
Methods
applyConfig()
applyConfig(config): void;Reset the behavior and apply the provided configuration.
Parameters
config
Behavior configuration.
Returns
void
Implementation of
Overrides
getConfig()
getConfig():
| ScaleBehaviorConfig
| undefined;Retrieve the current behavior properties as a configuration object. If the behavior is inactive, undefined is returned.
Returns
| ScaleBehaviorConfig | 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