Optionalconfig: ParticleGeneratorConfiguration = {}The computed target particle count based on visible area (ambient mode) or the configured budget (effect mode).
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 for the default clip behavior.
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 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!).
An optional callback called each frame for each live particle.
Orbit behavior options.
An optional sprite anchor override for all particles.
The particle lifetime configuration in milliseconds.
A pool of recycled particles ready to be reused.
The currently active particle instances.
An optional spawn validator.
Resolved rotation configuration for particles.
Which part of the spawn area to sample.
The shader class used to render particles.
The sorting key for the particle container.
The configured default spawn area (effect mode). This area is defined in scene coordinates and may be interpreted relative to an anchor. foundry.data.BaseShapeData instances and source data are always interpreted in absolute scene coordinates. Shape source data is converted to a foundry.data.BaseShapeData instance. Re-read each frame, so it can be replaced or its values mutated at runtime to animate the spawn region.
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 display object used to mask particle 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_Temp point used to sample shape-based spawn areas.
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 bounding rectangle of the generator in scene coordinates. Used to convert between local particle coordinates and scene coordinates.
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 mask applied to the particle container. Set to null to remove the mask. The generator does not manage the lifecycle of externally assigned masks.
The PIXI container that holds all particle display objects.
The maximum number of particles that may be spawned per second (auto-spawn mode).
The current unpadded viewport rectangle in the generator's local space.
Spawn the initial particle batch. In ambient mode, particle ages are randomized so the scene appears pre-settled.
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. Coordinates are in scene space.
OptionalsampleMode?: ParticleGeneratorAreaSampleModeWhich part of the spawn area to sample. Defaults to the configured generator sample mode.
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).
OptionalsampleMode?: ParticleGeneratorAreaSampleModeWhich part of the spawn area to sample. Defaults to the configured generator sample mode.
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_ProtectedMigrate deprecated configuration options.
The user-provided configuration object.
The prepared 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 startshaderClasswhen you want a custom sampler shader for particlesonSpawnto customize each particle after it has been positioned and configuredonUpdateto apply per-particle per-frame logic after position, rotation, tint, and alpha are computedonDeathto 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: value, angle: [min, max]}(angle in degrees){fn: (particle, dt, out) => {out.x = vx; out.y = vy;}}evaluated at spawn and during each update as the full velocity vector for that frameAttribute Values
alpha,scale, polarvelocity.speed, androtation.speedaccept fixed values, random ranges,{min, max, curve}objects, or{fn}objects.tintaccepts fixed color sources or{curve}/{fn}color objects. Curve points use color sources;fnreturns a 0xRRGGBB number. Curve time is normalized over each particle lifetime.alphais multiplied by the fade envelopescaleis applied directly to the particlevelocity.speedupdates magnitude while preserving the spawn directionrotation.speedupdates angular velocity in degrees per secondtintinterpolates RGB channels between curve pointsShader
Pass
shaderClassto render particles with a custom sampler shader.SpriteMeshinstances, so the shader must be compatible withSpriteMesh.onSpawnoronUpdateand read it fromelement.objectin the shader_packInterleavedGeometryoverride.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}}{points: [{x, y}, ...]}or{shape: "points", points: [{x, y}, ...]}{path: [{x, y}, ...]},{shape: "path", path: [...]}, or{shape: "polyline", points: [{x, y}, ...]}{x, y, radiusX, radiusY},{shape: "ellipse", x, y, radiusX, radiusY}, with optionalholeScale,minAngle,maxAngle,shapeRotation, andaffectRotation.{type: "circle", x, y, radius}using the foundry.data.BaseShapeData schema. Plain object areas without atypeare inferred from their properties.Set
sampleModeto"boundary"to spawn along the edge of area types that support boundary sampling.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. Plain objects with a valid foundry.data.BaseShapeDatatypeare shape source data, not object areas, and are always interpreted in absolute scene coordinates.Debug
Use
debugwhile tuning a generator or diagnosing why particles are not spawning as expected. It is optional and should usually be disabled in final effects.debug: trueenables spawn and recycle counters.debug.stats: trueenablesgenerator.debugStats.debug.profile: truealso records the most recent update, spawn, and tick timings.debug.tint: truegives each spawned particle a random tint.debug.tint: {mode: "palette", palette: [0xFFAA00, 0x66CCFF]}tints particles from a palette.debug.tint: {mode: "byTexture"}gives each texture a stable debug color.debug.useWhiteTexture: truefalls back toPIXI.Texture.WHITEwhen no textures are configured.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 leaves (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) Anchored emitter (leaves around a token)
Use this for a continuous local effect attached to a moving object.
5) Custom onTick spawning (leaves around a token)
Use this when custom logic decides whether the generator should spawn during a tick.
6) Spawn-position direction toward a focal point
Use
velocity.fnwhen each particle direction depends on where it spawned.7) Direction evolving over lifetime (spiral)
Use
velocity.fnwhenparticle.timeshould bend the path during update.8) Keep particles inside a rectangle (wrap)
Use this for localized ambient effects in a region.
9) Bounce inside bounds (arcade-style)
Great for “energy balls” in a box or magic motes in a bounded area.
10) Use a clip mask (hard visual boundary)
Use this when you need a strict rectangle cutout.
11) Multiple textures + additive blend (magic leaves)
Use this for “sparkly” looks with layered variation.
12) Force a specific texture per spawn
Useful when you want a rare “special” particle occasionally.
13) Spawn into a temporary override area
Use this to reuse one generator for multiple nearby spawns without rebuilding it.
14) Use a custom batch shader
Assume
MySparkleSamplerShaderis aBaseSamplerShadersubclass whose batch plugin was already registered.15) Use a simple BaseShapeData source area (interior)
BaseShapeData source objects can be passed directly as areas. A simple shape, such as a circle, uses the shape's optimized point sampler after construction.
16) Use a complex BaseShapeData area (boundary)
On a gridded scene, GridShapeData can represent a union of multiple grid spaces. The resulting geometry is sampled through its PolygonTree, which is useful for complex boundaries.
17) Continuous spray with over-life curves
Use
spawnRateand over-life curves for effects that accelerate, shrink, or fade without custom callbacks.