Added SDK 0.28.0
Represents the geometry used to render a particle system.
Note
This is a low-level particle system API.
Summary
Create a new ParticleGeometry object.
Syntax
// 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
});
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.
Returns a ParticleGeometry object.
Summary
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.
Syntax
geometry.destroy();
Summary
Register callback handler for when geometry is resized.
Syntax
geometry.register(callback);
callback
Function taking no arguments, should handle that geometry.vertexBuffer will have been changed to a new object.