pixijs/pixijs · error · Error
ParticleContainer.setChildIndex() is not available. Please u
Error message
ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()
What it means
ParticleContainer.setChildIndex is overridden to throw; reorder operations must use setParticleIndex so the particle buffer ordering stays correct. The generic index setter is blocked to avoid a silent no-op that desyncs render order from storage.
Source
Thrown at src/scene/particle-container/shared/ParticleContainer.ts:668
*/
public override getChildAt<U extends ContainerChild>(_index: number): U
{
throw new Error(
'ParticleContainer.getChildAt() is not available. Please use ParticleContainer.getParticleAt()',
);
}
/**
* This method is not available in ParticleContainer.
*
* Calling this method will throw an error. Please use `ParticleContainer.setParticleIndex()` instead.
* @param {ContainerChild} _child
* @param {number} _index
* @throws {Error} Always throws an error as this method is not available.
* @ignore
*/
public override setChildIndex(_child: ContainerChild, _index: number): void
{
throw new Error(
'ParticleContainer.setChildIndex() is not available. Please use ParticleContainer.setParticleIndex()',
);
}
/**
* This method is not available in ParticleContainer.
*
* Calling this method will throw an error. Please use `ParticleContainer.getParticleIndex()` instead.
* @param {ContainerChild} _child
* @throws {Error} Always throws an error as this method is not available.
* @ignore
*/
public override getChildIndex(_child: ContainerChild): number
{
throw new Error(
'ParticleContainer.getChildIndex() is not available. Please use ParticleContainer.getParticleIndex()',
);
}
/**View on GitHub (pinned to 4b141e3ced)
Solutions
- Use particleContainer.setParticleIndex(child, newIndex) as the message directs.
- If you only need draw order, check whether the particle container exposes a z/depth-based sort instead.
- Make sort helpers container-type aware.
Example fix
// before particleContainer.setChildIndex(p, 0); // after particleContainer.setParticleIndex(p, 0);
Defensive patterns
Strategy: type-guard
Validate before calling
if (container instanceof ParticleContainer) {
throw new TypeError('Use ParticleContainer.setParticleIndex() instead of setChildIndex()');
} Type guard
import { Container, ParticleContainer } from 'pixi.js';
function isParticleContainer(c: Container): c is ParticleContainer {
return c instanceof ParticleContainer;
} Prevention
- Reorder particles with setParticleIndex.
- Make sort/reorder helpers container-type aware.
- Consider z/depth sorting where supported.
When it happens
Trigger: Calling particleContainer.setChildIndex(child, newIndex) directly, or generic sort/reorder utilities that reorder children by index.
Common situations: Sorting particles (e.g., back-to-front); porting z-order code from a Container; generic drag-to-reorder UI operating on containers.
Related errors
- ParticleContainer.addChild() is not available. Please use Pa
- ParticleContainer.removeChild() is not available. Please use
- ParticleContainer.removeChildren() is not available. Please
- ParticleContainer.removeChildAt() is not available. Please u
- ParticleContainer.getChildAt() is not available. Please use
AI-assisted analysis of pixijs/pixijs@4b141e3ced (2026-08-12).
Data as JSON: /api/errors/4f393a66147abd3c.
Report an issue: GitHub.