Home Reference Source
import Particles from 'oxygen-core/components/Particles.js'
public class | source

Particles

Extends:

ComponentVerticesRenderer → Particles

Particles renderer.

Example:

const component = new Particles();
component.deserialize({ shader: 'shaders/particles.json', processor: 'particles/fire.ps' });

Static Member Summary

Static Public Members
public static get

Static Method Summary

Static Public Methods
public static

Component factory.

public static

registerProcessor(id: string, contents: string)

Register new particles processor.

public static

Unregister existing processor.

Constructor Summary

Public Constructor
public

Constructor.

Member Summary

Public Members
public get
public get
public set
public get
public set
public get
public set
public get
public set
public get
public set
public

indices: *

public get
public set
public get
public set
public

Method Summary

Public Methods
public
public

emitBurst(count: number, args: *)

Emit burst of particles using burst generator function.

public

emitParticle(life: number, timeScale: number, size: number, args: *): boolean

Emit single particle.

public

onAction(name: *, args: ...*): *

public

onUpdate(deltaTime: *)

public

setParam(id: string, value: number)

Set particles parameter.

Inherited Summary

From class Component
public static get
public static

Component factory.

public get
public

[name]: *

public

deserialize(json: *)

Deserialize JSON properties into this component.

public

Destructor (dispose internal resources and detach from entity).

public

onAction(name: string, args: *)

Called when action arrived.

public

onAlterActionArguments(name: string, args: *): array | undefined

Called when asked to alter arrived action parameters.

public

Called after attached to entity.

public

Called before detached from entity.

public

onPropertySerialize(name: string, value: *): *

Called when property is serialized.

public

onPropertySetup(name: string, value: *)

Called when given property is deserialized.

public

serialize(): *

Serialize component into JSON data.

From class VerticesRenderer
public static get
public static get
public static get

propsTypes: {"visible": string, "shader": string, "vertices": string, "indices": string, "verticesUsage": string, "indicesUsage": string, "overrideUniforms": string, "overrideSamplers": string, "renderMode": string, "layers": string}

public static

factory(): *

public get

indices: *

public set
public get
public set
public get
public set
public get
public set
public get
public set
public get
public set
public get

shader: *

public set
public get
public set
public get
public set
public get

visible: *

public set
public
public

onAction(name: *, args: ...*): *

public

onPreview(gl: *, renderer: *, deltaTime: *)

public

onPropertySerialize(name: *, value: *): *

public

onRender(gl: *, renderer: *, deltaTime: *, layer: *)

public

onRenderLayer(gl: *, renderer: *, deltaTime: *, layer: *)

public
public

updateIndicesChunk(data: *, offset: *, size: number)

public

updateVerticesChunk(data: *, offset: *, size: number)

Static Public Members

public static get propsTypes: * source

Override:

VerticesRenderer#propsTypes

Static Public Methods

public static factory(): Particles source

Component factory.

Override:

VerticesRenderer#factory

Return:

Particles

Component instance.

public static registerProcessor(id: string, contents: string) source

Register new particles processor.

Params:

NameTypeAttributeDescription
id string

Processor id.

contents string

Processor code.

Example:

const code = 'attribute x: 0;\nattribute y: 1;\nprogram:\ny -= deltaTime * life;';
Particles.registerProcessor('fire', code);

public static unregisterProcessor(id: string) source

Unregister existing processor.

Params:

NameTypeAttributeDescription
id string

processor id

Example:

Particles.unregisterProcessor('fire');

Public Constructors

public constructor() source

Constructor.

Override:

VerticesRenderer#constructor

Public Members

public get activeCount: number source

public get burstGenerator: Function | null source

public set burstGenerator: Function | null source

public get capacity: number source

public set capacity: number source

public get constantBurst: boolean source

public set constantBurst: boolean source

public get constantBurstCount: number source

public set constantBurstCount: number source

public get constantBurstDelay: number source

public set constantBurstDelay: number source

public indices: * source

Override:

VerticesRenderer#indices

public get overrideParams: * source

public set overrideParams: * source

public get processor: string | null source

public set processor: string | null source

public verticesUsage: * source

Override:

VerticesRenderer#verticesUsage

Public Methods

public dispose() source

Destructor (dispose internal resources and detach from entity).

Override:

VerticesRenderer#dispose

public emitBurst(count: number, args: *) source

Emit burst of particles using burst generator function.

Params:

NameTypeAttributeDescription
count number

Number of particles to emit.

args *

Particles attributes.

Example:

component.emitBurst(100);

public emitParticle(life: number, timeScale: number, size: number, args: *): boolean source

Emit single particle.

Params:

NameTypeAttributeDescription
life number

Initial life value.

timeScale number

Particle life-cycle time scale.

size number

Particle size.

args *

Particle attributes.

Return:

boolean

True if emitted, false otherwise.

Example:

component.emitParticle(1, 0.5, 10);

public onAction(name: *, args: ...*): * source

Called when action arrived.

Override:

VerticesRenderer#onAction

Params:

NameTypeAttributeDescription
name *
args ...*

Return:

*

public onUpdate(deltaTime: *) source

Params:

NameTypeAttributeDescription
deltaTime *

public setParam(id: string, value: number) source

Set particles parameter.

Params:

NameTypeAttributeDescription
id string

Parameter id.

value number

Parameter value.

Example:

component.setParam('alpha', 0.5);