PIXI.ParticleContainer

class ParticleContainer

The ParticleContainer class is a really fast version of the Container built solely for speed, so use when you need a lot of sprites or particles.

The tradeoff of the ParticleContainer is that most advanced functionality will not work. ParticleContainer implements the basic object transform (position, scale, rotation) and some advanced functionality like tint (as of v4.5.6).

Other more advanced functionality like masking, children, filters, etc will not work on sprites in this batch.

It's extremely easy to use:

let container = new ParticleContainer();

for (let i = 0; i < 100; ++i)
{
    let sprite = PIXI.Sprite.from("myImage.png");
    container.addChild(sprite);
}

And here you have a hundred sprites that will be rendered at the speed of light.

Constructor


new PIXI.ParticleContainer(maxSize: number, properties: IParticleProperties, batchSize: number, autoResize: boolean) → {}
Parameters:
Name Type Attributes Default Description
maxSize number 1500

The maximum number of particles that can be rendered by the container. Affects size of allocated buffers.

properties IParticleProperties

<optional>

The properties of children that should be uploaded to the gpu and applied.

properties.vertices boolean

<optional>

false

When true, vertices be uploaded and applied. if sprite's scale/anchor/trim/frame/orig is dynamic, please set true.

properties.position boolean

<optional>

true

When true, position be uploaded and applied.

properties.rotation boolean

<optional>

false

When true, rotation be uploaded and applied.

properties.uvs boolean

<optional>

false

When true, uvs be uploaded and applied.

properties.tint boolean

<optional>

false

When true, alpha and tint be uploaded and applied.

batchSize number

<optional>

16384

Number of particles per batch. If less than maxSize, it uses maxSize instead.

autoResize boolean

<optional>

false

If true, container allocates more batches in case there are more than maxSize particles.

Public Properties


autoResize ParticleContainer.ts:54
autoResize: boolean = false

If true, container allocates more batches in case there are more than maxSize particles.

baseTexture ParticleContainer.ts:69
baseTexture: PIXI.BaseTexture

The texture used to render the children.

blendMode ParticleContainer.ts:47
blendMode: PIXI.BLEND_MODES = PIXI.BLEND_MODES.NORMAL

The blend mode to be applied to the sprite. Apply a value of PIXI.BLEND_MODES.NORMAL to reset the blend mode.

roundPixels ParticleContainer.ts:60
roundPixels: boolean = true

If true PixiJS will Math.floor() x/y values when rendering, stopping pixel interpolation. Advantages can include sharper image quality (like text) and faster rendering on canvas. The main disadvantage is movement of objects may appear less smooth. Default to true here as performance is usually the priority for particles.

tint ParticleContainer.ts:182
tint: number = 0xFFFFFF

The tint applied to the container. This is a hex value. A value of 0xFFFFFF will remove any tint effect. IMPORTANT: This is a WebGL only feature and will be ignored by the canvas renderer.

Public Methods


destroy ParticleContainer.ts:251
destroy(options: IDestroyOptions | boolean) → {void}

Destroys the container

Parameters:
Name Type Attributes Default Description
options IDestroyOptions | boolean

<optional>

Options parameter. A boolean will act as if all options have been set to that value

options.children boolean

<optional>

false

if set to true, all the children will have their destroy method called as well. 'options' will be passed on to those calls.

options.texture boolean

<optional>

false

Only used for child Sprites if options.children is set to true Should it destroy the texture of the child sprite

options.baseTexture boolean

<optional>

false

Only used for child Sprites if options.children is set to true Should it destroy the base texture of the child sprite

Returns:
Type Description
void
render ParticleContainer.ts:199
render(renderer: PIXI.Renderer) → {void}

Renders the container using the WebGL renderer.

Parameters:
Name Type Description
renderer PIXI.Renderer

The WebGL renderer.

Returns:
Type Description
void
setProperties ParticleContainer.ts:158
setProperties(properties: IParticleProperties) → {void}

Sets the private properties array to dynamic / static based on the passed properties object

Parameters:
Name Type Description
properties IParticleProperties

The properties to be uploaded

Returns:
Type Description
void

Protected Methods


onChildrenChange ParticleContainer.ts:223
protected onChildrenChange(smallestChildIndex: number) → {void}

Set the flag that static data should be updated to true

Parameters:
Name Type Description
smallestChildIndex number

The smallest child index.

Returns:
Type Description
void

Powered by webdoc!