Home Reference Source
public class | source

Behaviour

Indirect Subclass:

Gravity, Repulsion

The base behaviour class. Behaviours manage a particle's behaviour after they have been emitted.

Constructor Summary

Public Constructor
public

constructor(life: number, easing: function, type: string, isEnabled: boolean): *

Constructs a Behaviour instance.

Member Summary

Public Members
public

The age of the behaviour

public

Determines if the behaviour is dead or not

public

The behaviour's decaying trend

public

The energy of the behaviour

public

The behaviour's id

public

Determines if the behaviour will be applied or not

public set

life: *

Ensures that life is infinity if an invalid value is supplied.

public get

life: Number: *

Gets the behaviour's life.

public

The class type.

Private Members
private

_life: *

Method Summary

Public Methods
public abstract

applyBehaviour(target: Particle | Emitter, time: Number, index: integer): *

Apply behaviour to the target as a factor of time.

public abstract

Destory this behaviour.

public

energize(particle: Particle, time: Number): *

Compares the age of the behaviour vs integration time and determines if the behaviour should be set to dead or not.

public abstract

Returns a new instance of the behaviour from the JSON object passed.

public abstract

initialize(particle: Particle)

Set the behaviour's initial properties on the particle.

public abstract

mutate(target: Particle | Emitter, time: Number): *

Change the target's properties according to specific behaviour logic.

public

Normalize a force by 1:100;

public

Normalize a value by 1:100;

public

reset(life: number, easing: function)

Reset this behaviour's parameters

Public Constructors

public constructor(life: number, easing: function, type: string, isEnabled: boolean): * source

Constructs a Behaviour instance.

Params:

NameTypeAttributeDescription
life number
  • optional
  • default: Infinity

The life of the behaviour

easing function
  • optional
  • default: DEFAULT_BEHAVIOUR_EASING

The behaviour's decaying trend

type string
  • optional
  • default: BEHAVIOUR_TYPE_ABSTRACT

The behaviour type

isEnabled boolean
  • optional
  • default: true

Determines if the behaviour will be applied or not

Return:

*

void

Public Members

public age: number source

The age of the behaviour

public dead: boolean source

Determines if the behaviour is dead or not

public easing: function source

The behaviour's decaying trend

public energy: number source

The energy of the behaviour

public id: string source

The behaviour's id

public isEnabled: boolean source

Determines if the behaviour will be applied or not

public set life: * source

Ensures that life is infinity if an invalid value is supplied.

Return:

*

void

public get life: Number: * source

Gets the behaviour's life.

Return:

Number

public type: string source

The class type.

Private Members

private _life: * source

Public Methods

public abstract applyBehaviour(target: Particle | Emitter, time: Number, index: integer): * source

Apply behaviour to the target as a factor of time. Internally calls the mutate method to change properties on the target Will not do so if the behaviour is disabled

Params:

NameTypeAttributeDescription
target Particle | Emitter

The particle or emitter to apply the behaviour to

time Number

the system integration time

index integer

the target index

Return:

*

mixed

public abstract destroy() source

Destory this behaviour.

public energize(particle: Particle, time: Number): * source

Compares the age of the behaviour vs integration time and determines if the behaviour should be set to dead or not. Sets the behaviour energy as a factor of particle age and life.

Params:

NameTypeAttributeDescription
particle Particle

The particle to apply the behaviour to

time Number

the system integration time

Return:

*

void

public abstract fromJSON(json: object): Behaviour source

Returns a new instance of the behaviour from the JSON object passed.

Params:

NameTypeAttributeDescription
json object

JSON object containing the required constructor properties

Return:

Behaviour

public abstract initialize(particle: Particle) source

Set the behaviour's initial properties on the particle.

Params:

NameTypeAttributeDescription
particle Particle

public abstract mutate(target: Particle | Emitter, time: Number): * source

Change the target's properties according to specific behaviour logic.

Params:

NameTypeAttributeDescription
target Particle | Emitter

The particle or emitter to apply the behaviour to

time Number

the system integration time

Return:

*

mixed

public normalizeForce(force: Vector3D): Vector3D source

Normalize a force by 1:100;

Params:

NameTypeAttributeDescription
force Vector3D

The force to normalize.

Return:

Vector3D

public normalizeValue(value: number): number source

Normalize a value by 1:100;

Params:

NameTypeAttributeDescription
value number

The value to normalize

Return:

number

public reset(life: number, easing: function) source

Reset this behaviour's parameters

Params:

NameTypeAttributeDescription
life number
  • optional
  • default: DEFAULT_LIFE

The life of the behaviour

easing function
  • optional
  • default: DEFAULT_BEHAVIOUR_EASING

The behaviour's decaying trend