PixiJS v8 includes a high-performance particle system via the ParticleContainer and Particle classes. Designed for rendering vast numbers of lightweight visuals (sparks, bubbles, explosions), this system provides raw speed by stripping away non-essential overhead.
The Particle API is stable but experimental. Its interface may evolve in future PixiJS versions. We welcome feedback to help guide its development.
import { ParticleContainer, Particle, Texture } from 'pixi.js';
const texture = Texture.from('bunny.png');
const container = new ParticleContainer({
dynamicProperties: {
position: true, // default
vertex: false,
rotation: false,
color: false,
},
});
for (let i = 0; i < 100000; i++) {
const particle = new Particle({
texture,
x: Math.random() * 800,
y: Math.random() * 600,
});
container.addParticle(particle);
}
app.stage.addChild(container);
Sprite, lacking children, events, or filters.dynamic) vs which are set once (static). Only dynamic properties are uploaded to the GPU each frame, reducing bandwidth.update() is called.Declare your needs explicitly:
const container = new ParticleContainer({
dynamicProperties: {
position: true,
rotation: true,
vertex: false,
color: false,
},
});
If you later modify a static property or the particle list, you must call:
container.update();
ParticleContainer is designed for speed and simplicity. As such, it doesn't support the full Container API:
ParticleContainer uses a separate child management API optimized for GPU buffer updates:
| Standard Container method | ParticleContainer equivalent |
|---|---|
addChild(child) |
addParticle(particle) |
removeChild(child) |
removeParticle(particle) |
addChildAt(child, index) |
addParticleAt(particle, index) |
removeChildAt(index) |
removeParticleAt(index) |
removeChildren(begin, end) |
removeParticles(begin, end) |
getChildAt(index) |
Access container.particleChildren[index] directly |
swapChildren() |
Not available |
reparentChild() |
Not available |
A Particle supports key display properties and is far more efficient than Sprite.
const particle = new Particle({
texture: Texture.from('spark.png'),
x: 200,
y: 100,
scaleX: 0.8,
scaleY: 0.8,
rotation: Math.PI / 4,
tint: 0xff0000,
alpha: 0.5,
});
You can also use the shorthand:
const particle = new Particle(Texture.from('spark.png'));