Home Reference Source
public class | source

Spring

Extends:

Behaviour → Spring

Behaviour that causes particles to spring.

Static Method Summary

Static Public Methods
public static

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

Constructor Summary

Public Constructor
public

constructor(x: number, y: number, z: number, spring: number, friction: number, life: number, easing: function, isEnabled: boolean): *

Constructs a Spring behaviour instance.

Member Summary

Public Members
public
public

pos: *

public

spring: *

Method Summary

Public Methods
public

mutate(particle: object, time: number, index: integer): *

Applies the behaviour to the particle.

public

reset(x: number, y: number, z: number, spring: number, friction: number): *

Resets the behaviour properties.

Inherited Summary

From class Behaviour
public get

life: Number: *

Gets the behaviour's life.

public set

life: *

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

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

The class type.

private

_life: *

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

Static Public Methods

public static fromJSON(json: object): Spring source

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

Override:

Behaviour#fromJSON

Params:

NameTypeAttributeDescription
json object

JSON object containing the required constructor properties

Return:

Spring

Public Constructors

public constructor(x: number, y: number, z: number, spring: number, friction: number, life: number, easing: function, isEnabled: boolean): * source

Constructs a Spring behaviour instance.

Override:

Behaviour#constructor

Params:

NameTypeAttributeDescription
x number

X axis spring

y number

Y axis spring

z number

Z axis spring

spring number

Spring factor

friction number

Spring friction

life number

The life of the behaviour

easing function

The easing equation to use for transforms

isEnabled boolean
  • optional
  • default: true

Determines if the behaviour will be applied or not

Return:

*

void

Public Members

public friction: * source

public pos: * source

public spring: * source

Public Methods

public mutate(particle: object, time: number, index: integer): * source

Applies the behaviour to the particle. Mutates the particle's velocity according to this.pos and this.spring.

Override:

Behaviour#mutate

Params:

NameTypeAttributeDescription
particle object

the particle to apply the behaviour to

time number

engine time

index integer

the particle index

Return:

*

void

public reset(x: number, y: number, z: number, spring: number, friction: number): * source

Resets the behaviour properties.

Override:

Behaviour#reset

Params:

NameTypeAttributeDescription
x number

X axis spring

y number

Y axis spring

z number

Z axis spring

spring number

Spring factor

friction number

Spring friction

Return:

*

void