Skip to content

RotationBehavior<DataType, ParticleType>

Behavior used to control the rotation of particles over their lifetime.

Behavior supports four 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, a direction mode where the rotation is set based on the particle's movement direction, and an acceleration mode where the rotation changes over time based on an acceleration value.

See

Example

ts
// Apply a static rotation of 45 degrees to all particles.
rotationBehavior.applyConfig({
    mode: "static",
    value: Math.PI / 4,
});

// Interpolate particle rotation from 0 to 360 degrees over lifetime.
rotationBehavior.applyConfig({
    listData: [
        { time: 0.0, value: 0 },
        { time: 1.0, value: Math.PI * 2 },
    ],
    mode: "list",
});

Extends

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

Constructors

Constructor

ts
new RotationBehavior<DataType, ParticleType>(emitter): RotationBehavior<DataType, ParticleType>;

Creates a new RotationBehavior.

Parameters

emitter

Emitter<DataType, ParticleType>

Emitter instance this behavior belongs to.

Returns

RotationBehavior<DataType, ParticleType>

Overrides

EmitterBehavior.constructor

Accessors

acceleration

Get Signature

ts
get acceleration(): number;

Rotation acceleration applied over time (used for acceleration mode).

Returns

number

Set Signature

ts
set acceleration(value): void;
Parameters
value

number

Returns

void


list

Get Signature

ts
get list(): NumberList;

Number list used to interpolate rotation 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

NumberList


mode

Get Signature

ts
get mode(): RotationBehaviorMode;

Current mode used by the behavior.

Returns

RotationBehaviorMode

Set Signature

ts
set mode(value): void;
Parameters
value

RotationBehaviorMode

Returns

void


startRotation

Get Signature

ts
get startRotation(): number;

Initial rotation value for the particle (used for acceleration mode).

Returns

number

Set Signature

ts
set startRotation(value): void;
Parameters
value

number

Returns

void


staticValue

Get Signature

ts
get staticValue(): number;

Static rotation value applied to all particles.

Returns

number

Set Signature

ts
set staticValue(value): void;
Parameters
value

number

Returns

void


updateOrder

Get Signature

ts
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

BehaviorOrder

Implementation of

UpdateBehavior.updateOrder

Overrides

EmitterBehavior.updateOrder

Methods

applyConfig()

ts
applyConfig(config): void;

Reset the behavior and apply the provided configuration.

Parameters

config

RotationBehaviorConfig

Behavior configuration.

Returns

void

Implementation of

UpdateBehavior.applyConfig

Overrides

EmitterBehavior.applyConfig


getConfig()

ts
getConfig():
  | RotationBehaviorConfig
  | undefined;

Retrieve the current behavior properties as a configuration object. If the behavior is inactive, undefined is returned.

Returns

| RotationBehaviorConfig | undefined

Behavior configuration object or undefined if inactive.

Implementation of

UpdateBehavior.getConfig

Overrides

EmitterBehavior.getConfig


init()

ts
init(particle): void;

Initialize the particle.

Parameters

particle

ParticleType

Particle to initialize.

Returns

void

Implementation of

InitBehavior.init


reset()

ts
protected reset(): void;

Reset the behavior to its default state.

Returns

void

Implementation of

UpdateBehavior.reset

Overrides

EmitterBehavior.reset


update()

ts
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

Implementation of

UpdateBehavior.update