Optionalconfig: ParticleGeneratorConfiguration = {}The computed target particle count based on visible area (ambient mode) or the configured budget (effect mode).
The maximum alpha range for particles.
An optional anchor used to attach areas and behaviors.
A fixed offset (scene pixels) applied to the anchor.
Which point to use when anchoring.
The blend mode used to render particles.
Optional blur filter options applied to the internal container.
Clip (mask) options.
Out-of-bounds constraint configuration.
The parent container which receives the internal particle container.
Optional random drift configuration.
The elevation for the particle container.
The fade-in duration in milliseconds, or a fraction of lifetime if 0 < value < 1.
The fade-out duration in milliseconds, or a fraction of lifetime if 0 < value < 1.
Follow behavior options.
The initial proportion (0..1) of the computed target particle count to spawn on start.
If true, particles are never spawned automatically.
The target particle count.
The maximum number of particles that may be spawned per frame (auto-spawn mode).
The runtime mode.
An optional callback called when a particle is recycled.
An optional callback called after the particle has been placed and configured.
An optional callback called one time per frame (not per particle!).
Orbit behavior options.
The particle lifetime configuration in milliseconds.
A pool of recycled particles ready to be reused.
The currently active particle instances.
An optional spawn validator.
The rotation speed of particles in radians per second.
The scale range for particles.
The sorting key for the particle container.
The chance (0..1) that a spawn attempt actually creates a particle.
The configured particle textures.
The velocity configuration used to generate per-particle movement.
Viewport-related behavior (used primarily in ambient mode).
Protected_The current anchor position in local coordinates.
Protected_The current anchor position in scene coordinates.
Protected_The active behavior implementation.
Protected_A cached context object passed to behavior hooks.
Protected_The blur filter applied to the internal container, if any.
Protected_Generator bounds in scene coordinates.
Protected_Temp point used to avoid per-frame allocations.
Protected_Temp point used to avoid per-frame allocations.
Protected_The local-space viewport rectangle with padding.
Protected_Optional custom constraint rectangle in local coordinates.
Protected_Normalized debug options.
Protected_Whether profiling is enabled.
Protected_Debug statistics and profiling output. Null when debug stats are disabled.
Protected_Cached debug tint options.
Protected_A mapping from textures to deterministic tint values.
Protected_A function which generates per-particle movement speed vectors.
Protected_Whether the previous-frame budget rectangle is initialized.
Protected_Whether the generator has spawned its initial batch.
Protected_The mask graphics used to clip rendering.
Protected_A fixed pool of rectangles used to describe newly visible areas.
Protected_The list of newly visible areas for the current frame in local coordinates.
Protected_The previous-frame budget rectangle.
Protected_The internal container which holds all particles.
Protected_The configured default spawn area (effect mode). This area is defined in scene coordinates and may be interpreted relative to an anchor.
Protected_Whether the generator is soft-stopped.
Protected_Whether the update callback is attached to the ticker.
Protected_Temp point used to avoid per-frame allocations.
Protected_Temp point used to avoid per-frame allocations.
Protected_The local-space viewport rectangle without padding.
Protected_The local-space generator bounds.
StaticDEFAULT_Default generator config.
The current padded viewport rectangle used for budget/spawning in ambient mode.
Debug statistics and profiling output. Returns null if ParticleGeneratorDebugOptions#stats is not enabled.
Note: This getter returns a stable object reference and updates the live values (active/pool/target) on access.
The current unpadded viewport rectangle in the generator's local space.
Spawn the initial batch.
Spawn a single particle. In "ambient" mode, the default spawn area is the current padded viewport rectangle. In "effect" mode, the default spawn area is the configured ParticleGeneratorArea.
Optionaloptions: {Optionalarea?: ParticleGeneratorArea | nullAn optional spawn area override. Interpreted the same as the configured area (scene coordinates, or relative-to-anchor when anchored).
Optionalposition?: Point | { x: number; y: number } | nullAn optional explicit spawn position (scene coordinates).
Optionaltexture?: string | Texture<Resource>A texture (or texture source string) to force for this particle.
Spawn multiple particles.
The number of particles to spawn.
Optionaloptions: {Optionalarea?: ParticleGeneratorArea | nullAn optional spawn area override. Interpreted the same as the configured area (scene coordinates, or relative-to-anchor when anchored).
Optionalposition?: IPointData | nullAn optional explicit spawn position (scene coordinates).
Optionaltexture?: string | Texture<Resource>A texture (or texture source string) to force for this burst.
The number of successfully spawned particles.
Start the generator, create the update loop and optionally spawn an initial batch.
Optionaloptions: { spawn?: number }Optionalspawn?: numberSpawn this many particles immediately after starting. If ParticleGenerator#manualSpawning is false, this is capped to the remaining budget (target - active).
Stop the generator.
Optionaloptions: { hard?: boolean } = {}Optionalhard?: booleanIf true, detach the update loop and destroy internal resources. If false, stop spawning and let existing particles expire naturally.
Protected_Protected_ProtectedSpawn particles to move toward the current target count.
Protected_ProtectedCompute the current viewport rectangles and target particle count. All rectangles are in the local coordinate space of the internal container.
Protected_ProtectedCompute the portions of newRect that were not visible in oldRect. This method reuses a fixed pool of rectangles to avoid per-frame allocations.
Protected_ProtectedConfigure optional debug helpers. This feature set is fully opt-in and is designed to have near-zero overhead when disabled.
Protected_ProtectedApply the configuration to the ParticleGenerator instance.
The configuration object.
Protected_Protected_ProtectedGet default bounds from the current scene dimensions.
Protected_ProtectedGet a random texture from the configured set.
Protected_ProtectedInitialize behaviors from the configuration object.
Protected_ProtectedInitialize cached generators from the configuration object.
Protected_ProtectedTicker callback.
Protected_Protected_ProtectedUpdate all active particles.
Delta time in milliseconds.
Protected_ProtectedUpdate particles with constraints applied.
Protected_ProtectedUpdate particles without constraints.
Delta time in milliseconds.
Delta time in seconds.
A lightweight, native particle generator designed for VFX.
ParticleGenerator manages:
canvas.primary)The API is intentionally compact:
textures,blend,alpha,scale,count,lifetime, etc.)areato define where particles spawnspawnParticle()orspawnParticles()to spawn particles (optionally overriding texture/area/position)start({spawn: n})when you want to immediately seed a certain number of particles on startonSpawnto customize each particle after it has been positioned and configuredonDeathto react when particles are recycled (optional)Core concepts
Mode
mode: "ambient"maintains a stable density in the visible region.countis scaled by the visible area ratio, and spawning uses the padded viewport (viewPadding).mode: "effect"spawns in a definedarea.countis treated as an absolute target. You can usemanual: trueand spawn at your own rate viaspawnParticle()/spawnParticles().Fade
fade.in/fade.outaccept:Velocity
velocitycan be:{x, y}ornew PIXI.Point(x, y){x: [min, max], y: [min, max]}{speed: [min, max], angle: [min, max]}(angle in degrees)Area
areasupports:{x, y}{x, y, width, height}ornew PIXI.Rectangle(x, y, w, h){x, y, radius}{x, y, innerRadius, outerRadius}or{x, y, radius: [inner, outer]}{from: {x, y}, to: {x, y}}If you provide an
anchor, object-based areas can be treated as offsets relative to that anchor. To force an absolute rectangle while anchored, pass aPIXI.Rectangle.Performance tips
spawnParticle()orspawnParticles()with no options when you can. It avoids per-spawn object allocations.positionTestcheap. It runs in a hot path.Practical limits
ParticleGenerator is meant for local, short-lived effects (bursts, embers, motes, small auras), not for filling the entire scene with massive particle counts. If you push it into many thousands of active particles, performance could degrade quickly. In practice, you’ll get better results by using moderate counts, short lifetimes, and small spawn areas, and by stopping the effect when it’s no longer needed.
Texture size also matters. Large particle textures (or heavy blur) increase pixel work, especially with additive/screen blends and overdraw, which can become fill-rate bound on some GPUs. Prefer small textures (and sprite sheets!), keep particle sizes reasonable on screen, and avoid expensive full-screen coverage when you only need a local effect.
Examples
Example
1) Ambient dust (steady density in view)
Use this for soft, always-on atmospheric particles.
2) Ambient snow (padding + random age)
Great for snowfall that looks continuous when you pan the camera.
3) Manual burst at a point (effect mode)
Use this for clicks, impacts, or quick one-shot effects.
4) Manual spawn rate (embers around a token)
Use this to continuously spawn particles around something.
5) Ring spawn + radial outward motion (use onSpawn)
Good for shockwaves, sparks, or “pushing out” energy.
6) Keep particles inside a rectangle (wrap)
Use this for localized ambient effects in a region.
7) Bounce inside bounds (arcade-style)
Great for “energy balls” in a box or magic motes in a bounded area.
8) Use a clip mask (hard visual boundary)
Use this when you need a strict rectangle cutout.
9) Multiple textures + additive blend (magic motes)
Use this for “sparkly” looks with layered variation.
10) Force a specific texture per spawn
Useful when you want a rare “special” particle occasionally.
11) Spawn into a temporary override area
Use this to reuse one generator for multiple nearby spawns without rebuilding it.