MovementBehavior<DataType, ParticleType>
Behavior used to control particle movement over their lifetime.
This behavior supports two configuration modes, either by specifying minimum and maximum movement speeds for the X and Y axes, or by providing list data to define movement values over the particle's lifetime.
See
- MinMaxConfigType for min/max speed configuration options.
- ListConfigType for list-based configuration options.
Example
// Configure movement using min/max speeds.
movementBehavior.applyConfig({
minMoveSpeed: { x: -50, y: -100 },
maxMoveSpeed: { x: 50, y: 100 },
mode: "linear",
space: "global",
});
// Configure movement using lists.
movementBehavior.applyConfig({
xListData: {
list: [
{ time: 0.0, value: 0 },
{ time: 1.0, value: 100 },
],
},
yListData: {
list: [
{ time: 0.0, value: 0 },
{ time: 1.0, value: -100 },
],
},
mode: "acceleration",
space: "local",
});Extends
EmitterBehavior<MovementBehaviorConfig,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 MovementBehavior<DataType, ParticleType>(emitter): MovementBehavior<DataType, ParticleType>;Creates new instance of MovementBehavior.
Parameters
emitter
Emitter<DataType, ParticleType>
Emitter instance this behavior belongs to.
Returns
MovementBehavior<DataType, ParticleType>
Overrides
Accessors
maxMoveSpeed
Get Signature
get maxMoveSpeed(): PointData;Maximum movement speed (used when not using lists).
Returns
PointData
Set Signature
set maxMoveSpeed(value): void;Parameters
value
PointData
Returns
void
minMoveSpeed
Get Signature
get minMoveSpeed(): PointData;Minimum movement speed (used when not using lists).
Returns
PointData
Set Signature
set minMoveSpeed(value): void;Parameters
value
PointData
Returns
void
mode
Get Signature
get mode(): "linear" | "acceleration";Movement mode currently used by the behavior.
Returns
"linear" | "acceleration"
Set Signature
set mode(value): void;Parameters
value
"linear" | "acceleration"
Returns
void
space
Get Signature
get space(): "local" | "global";Space in which movement is applied.
Returns
"local" | "global"
Set Signature
set space(value): void;Parameters
value
"local" | "global"
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
useList
Get Signature
get useList(): boolean;Whether to use list-based movement configuration.
Returns
boolean
Set Signature
set useList(value): void;Parameters
value
boolean
Returns
void
xList
Get Signature
get xList(): NumberList;Number list used to interpolate X-axis movement 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 movement 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():
| MovementBehaviorConfig
| undefined;Retrieve the current behavior properties as a configuration object. If the behavior is inactive, undefined is returned.
Returns
| MovementBehaviorConfig | 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, deltaTime): void;Updates the particle.
Parameters
particle
ParticleType
Particle to update.
deltaTime
number
Time elapsed since the last update, in seconds.
Returns
void