Table Of Contents

Previous topic

20.4. The ParticleSystem Object

Next topic

20.6. The ParticleUpdater Interface

This Page

20.5. The ParticleGeometry Object

Added SDK 0.28.0

Represents the geometry used to render a particle system.


This is a low-level particle system API.

20.5.1. Methods create


Create a new ParticleGeometry object.


// Creating particle geometry for the default renderer
// Geometry is a single quad rendered as 2 GL_TRIANGLES where the indices in the template correspond to which vertex of the quad is being rendered.
// The default render shader expects a float2 as vertex data input, hence the choice of attributes
// And it expects that float2 to be a POSITION.
var geometry = ParticleGeometry.create({
    graphicsDevice: graphicsDevice,
    maxParticles: 1024,
    template: [0, null,  1, null,  2, null,
               0, null,  2, null,  3, null],
    attributes: [graphicsDevice.VERTEXFORMAT_USHORT2],
    stride: 2,
    semantics: graphicsDevice.createSemantics([graphicsDevice.SEMANTIC_POSITION]),
    primitive: graphicsDevice.PRIMITIVE_TRIANGLES,
    shared: true
GraphicsDevice object to construct VertexBuffer data.
The maximum amount of particles that will be renderable with the resultant geometry. Attempts to render more than this number of particles will fail.

The template defines the geometry for a single particle, where null will be replaced by the particle index [0,maxParticles).

In the above example, assuming maxParticles = 5 would generate vertex data equivalent to:

[0,0, 1,0, 2,0,  0,0, 2,0, 3,0,
 0,1, 1,1, 2,1,  0,1, 2,1, 3,1,
 0,2, 1,2, 2,2,  0,2, 2,2, 3,2,
 0,3, 1,3, 2,3,  0,3, 2,3, 3,3,
 0,4, 1,4, 2,4,  0,4, 2,4, 3,4]

The default renderer uses the first integer to determine suitable offsets to the particles position for the 4 quad vertices, whilst the second integer (represented by null in the template) represents the index of the particle the vertex corresponds to.

The vertex buffer data is restricted to a Uint16Array, so any data associated with a vertex must be compatible.

Vertex formats of the particle geometry.
The vertex stride of the geometry.
The Semantics object for rendering the geometry.
primitive (Optional)
The GraphicsDevice primitive type for rendering the geometry, by default this is graphicsDevice.PRIMITIVE_TRIANGLES.
shared (Optional)
Whether this geometry is shared. If geometry is not shared (Default), then when a ParticleSystem using this geometry is destroyed, the geometry will also be destroyed.

Returns a ParticleGeometry object. destroy


Release memory used by geometry instance. This should only be called on shared geometry instances when you are sure that they are no longer in use. For un-shared geometries, the ParticleSystem using the geometry is responsible for calling destroy on the geometry when it is destroyed itself.


geometry.destroy(); resize


Resize the geometry object.


geometry.resize(newMaxParticles); register


Register callback handler for when geometry is resized.




Function taking no arguments, should handle that geometry.vertexBuffer will have been changed to a new object. unregister


Unregister callback handler.



20.5.2. Properties maxParticles

The maximum amount of particles renderable with this geometry.


Read Only shared

Whether this geometry instance is shared.


Read Only