Home Reference Source
import Particle from 'three-nebula/src/core/Particle.js'
public class | source

Particle

Direct Subclass:

Emitter

Indirect Subclass:

FollowEmitter

A Particle is an object that is emitted by an emitter.

Constructor Summary

Public Constructor
public

constructor(properties: object): *

Constructs a Particle instance.

Member Summary

Public Members
public

The particle's acceleration

public

The particle's age

public

The particle's alpha

public

behaviours: array

The particle's behaviours array

public

The particle's body

public

The particle's color store

public

Determines if the particle is dead or not

public

The particle's distance to the camera, only set by the GPURenderer for depth sorting purposes.

public

The particle's easing

public

The particle's energy loss

public

The particle's unique id

public

The particle's life

public

The particle's mass

public

The particle's last position, velocity and acceleration

public

The particle's parent

public

The particle's position

public

The particle's radius

public

The particle's rotation

public

The particle's scale

public

Determines if the particle is sleeping or not

public

The particle's transform collection

public

The class type.

public

Determines whether to use alpha or not

public

Determines whether to use color or not

public

The particle's velocity

Method Summary

Public Methods
public

addBehaviour(behaviour: Behaviour): *

Adds a behaviour to the particle.

public

addBehaviours(behaviours: array<Behaviour>): *

Adds multiple behaviours to the particle.

public

destroy(): *

Destroys the particle.

public

Gets the particle's current direction.

public

Removes all behaviours from the particle.

public

removeBehaviour(behaviour: Behaviour): *

Removes the behaviour from the particle.

public

Resets the particle's default properties and clear's its particle's position, velocity, acceleration, color and rotation. Also destroy's the particle's transform collection & removes all behaviours.

public

update(time: number, index: integer): *

Updates the particle's properties by applying each behaviour to the particle. Will also update the particle's energy, unless it's age is greater than it's life in which case it will be destroyed.

Public Constructors

public constructor(properties: object): * source

Constructs a Particle instance.

Params:

NameTypeAttributeDescription
properties object

The properties to instantiate the particle with

Return:

*

void

Return Properties:

NameTypeAttributeDescription
properties.life number

The particle's life

properties.age number

The particle's age

properties.energy number

The particle's energy loss

properties.dead boolean

Determines if the particle is dead or not

properties.sleep boolean

Determines if the particle is sleeping or not

properties.target object

The particle's target

properties.body object

The particle's body

properties.mass number

The particle's mass

properties.radius number

The particle's radius

properties.alpha number

The particle's alpha

properties.scale number

The particle's scale

properties.rotation number

The particle's rotation

properties.color string | number

The particle's color

properties.easing function

The particle's easing

properties.position Vector3D

The particle's position

properties.velocity Vector3D

The particle's velocity

properties.acceleration Vector3D

The particle's acceleration

properties.behaviours array

The particle's behaviours array

properties.transform object

The particle's transform collection

Public Members

public acceleration: Vector3D source

The particle's acceleration

public age: number source

The particle's age

public alpha: number source

The particle's alpha

public behaviours: array source

The particle's behaviours array

public body: object source

The particle's body

public color: object source

The particle's color store

public dead: number source

Determines if the particle is dead or not

public distanceToCamera: number source

The particle's distance to the camera, only set by the GPURenderer for depth sorting purposes.

public easing: string source

The particle's easing

public energy: number source

The particle's energy loss

public id: number source

The particle's unique id

public life: number source

The particle's life

public mass: number source

The particle's mass

public old: Vector3D source

The particle's last position, velocity and acceleration

public parent: Emitter source

The particle's parent

public position: Vector3D source

The particle's position

public radius: number source

The particle's radius

public rotation: number source

The particle's rotation

public scale: number source

The particle's scale

public sleep: number source

Determines if the particle is sleeping or not

public transform: object source

The particle's transform collection

public type: string source

The class type.

public useAlpha: boolean source

Determines whether to use alpha or not

public useColor: boolean source

Determines whether to use color or not

public velocity: Vector3D source

The particle's velocity

Public Methods

public addBehaviour(behaviour: Behaviour): * source

Adds a behaviour to the particle.

Params:

NameTypeAttributeDescription
behaviour Behaviour

The behaviour to add to the particle

Return:

*

void

public addBehaviours(behaviours: array<Behaviour>): * source

Adds multiple behaviours to the particle.

Params:

NameTypeAttributeDescription
behaviours array<Behaviour>

An array of behaviours to add to the particle

Return:

*

void

public destroy(): * source

Destroys the particle.

Return:

*

void

public getDirection(): number source

Gets the particle's current direction.

Return:

number

public removeAllBehaviours(): * source

Removes all behaviours from the particle.

Return:

*

void

public removeBehaviour(behaviour: Behaviour): * source

Removes the behaviour from the particle.

Params:

NameTypeAttributeDescription
behaviour Behaviour

The behaviour to remove from the particle

Return:

*

void

public reset(): Particle source

Resets the particle's default properties and clear's its particle's position, velocity, acceleration, color and rotation. Also destroy's the particle's transform collection & removes all behaviours.

Return:

Particle

public update(time: number, index: integer): * source

Updates the particle's properties by applying each behaviour to the particle. Will also update the particle's energy, unless it's age is greater than it's life in which case it will be destroyed.

Params:

NameTypeAttributeDescription
time number

Integration time

index integer

Particle index

Return:

*

void