PixiJS Integration: Effects, Games and Editors
PixiJS draws: display objects, filters, blend modes and meshes stay on the Pixi side. The ai*js packages own data, state and lifecycle, deciding what each frame shows and when objects are created or recycled. Only aispritejs/pixi imports Pixi; every other package is renderer-agnostic.
Each package is covered from three angles:
- In games: runtime game logic and performance.
- In editors: tools, saving, debugging and tests.
- PixiJS techniques: the Pixi display objects, filters and blend modes that pair with it.
Technique index
Section titled “Technique index”| Technique | Effect | Packages |
|---|---|---|
| ColorMatrixFilter | Hit flash, desaturate on pause | aifsmjs, aieventjs |
| BlurFilter | Pause screen or depth of field | aifsmjs |
| DisplacementFilter | Water or heat haze, with the map sprite moved by a system | aiecsjs |
| ParticleContainer | Thousands of bullets | aipooljs, aiecsjs, aiquadtreejs |
| add / screen blend modes | Glow, lasers | aipooljs, aispritejs |
| MeshRope | Trails | aiecsjs (SoA history buffer), aipooljs |
RenderTexture / generateTexture |
Thumbnails, procedural frames | aibridgejs, aispritejs |
| BitmapText | Damage numbers, counters | aipooljs, aieventjs |
| Masks | Fog of war | aiquadtreejs, aiecsjs |
| TilingSprite | Parallax | aiecsjs, aifsmjs |
| Events and hit testing | Drag, marquee select | aibridgejs, aieventjs, aifsmjs, aiquadtreejs |
aiecsjs
Section titled “aiecsjs”Archetype ECS: components live in TypedArray SoA columns, and systems write their results into Pixi each frame. See the aiecsjs guide.
In games
- SoA columns feed Particle positions in a ParticleContainer directly, with no per-object sync.
aiecsjs/loopruns a fixed-step loop, so the simulation does not depend on the display refresh rate.ChildOfrecords which hull a turret belongs to, and a system places the turret from the hull’s position.
In editors
- Format 2 snapshots serve as save and undo files:
toJSONwrites JSON,serializeWorldwrites binary, andcreateDeltaSerializerhandles incremental changes. - Defining the same component
keyagain with the same kind and field layout returns the existing component, which suits script reload; a different layout throwsEcsError. onAdd/onRemoveobservers create and remove scene nodes alongside entities.
PixiJS techniques
- ParticleContainer: SoA columns drive large numbers of Particles.
- DisplacementFilter: a system moves the map sprite each frame.
- MeshRope: recent positions kept in an SoA history buffer become the rope’s points.
aispritejs
Section titled “aispritejs”Input-driven sprite animation graph: game logic sets inputs, and the graph decides which frame plays. See the aispritejs guide.
In games
- The controller turns player actions into
number,booleanandtriggerinputs. from: "*"with aprioritylets a hit or death interrupt whatever animation is playing.- Non-looping clips return to idle through
onEnd.
In editors
aispritejs/schemaexports the graph JSON Schema, so the editor or CI can validate graph JSON.parseAtlasturns a PixiJS v8 style atlas plus a control block into a graph;loadAtlasbuilds the animator directly.- Listeners are run-to-completion: when scrubbing a timeline, read
activeStateafter the outermostupdate()returns and the readout never shows an intermediate state.
PixiJS techniques
createPixiSpriteAnimatorswapssprite.textureon everyupdate().- The adapter owns only the texture and anchor, so tint and blend mode on the same sprite stay free.
- Procedural frames can be baked to a RenderTexture with
generateTexture, then handed to the adapter as a frameKey → Texture map.
aiaudiojs
Section titled “aiaudiojs”Thin wrapper over Howler.js that manages loading, playback, crossfades and disposal. See the aiaudiojs guide.
In games
- Switch level BGMs with a
crossfadeusingcurve: "equal-power". - Call
unlock()in the first Pixipointeruphandler, so the AudioContext resumes inside a user gesture. - An
AbortSignalcancels a running crossfade on scene exit; the abort stops no voice, so the caller handles both sounds afterwards.
In editors
disposeAll()on project switch also rejects in-flightload()calls withAudioDisposedError.- Timeline preview auditions sounds with
play()andstop().
PixiJS techniques
- Match the fade duration to a BlurFilter or ColorMatrixFilter tween;
crossfadetakes itsdurationin seconds,fade()takes milliseconds.
aiaudiojs has no audio sprites and no spatial audio; use Howler directly for those.
aieventjs
Section titled “aieventjs”Typed event emitter for notifications between modules. See the aieventjs guide.
In games
throttleMson pointer-move aiming: leading-edge throttling that drops events inside the window.oncefor cutscene triggers that fire a single time.captureErrorsso one throwing listener cannot break the frame’s dispatch.
In editors
- An event inspector subscribes to
*with asampleRate, so it sees only a sample of the traffic. - Aborting a tool’s
signalremoves all of that tool’s listeners at once.
PixiJS techniques
- Relay FederatedPointerEvents as your own typed events through
emit, copying only the fields you need, because Pixi reuses its event objects. - A BitmapText HUD subscribes to score events and updates its text.
aifsmjs
Section titled “aifsmjs”Deterministic FSM: machine definitions are plain data, and guards, actions and effects are injected at runtime. See the aifsmjs guide.
In games
- Player and weapon each run as a sub-machine.
after()fromaifsmjs/timerschedules the end of the invulnerability frames.- The pure
step()runs no effects, so the same event sequence replays deterministically; it reproduces the parent machine only, not sub-machine state.
In editors
- The
recorderandpersistmiddleware fromaifsmjs/inspectfeed a state panel. aifsmjs/replayreproduces a bug report from its event log.aifsmjs/pbtruns fast-check property tests in CI.
PixiJS techniques
- A ColorMatrixFilter flash on entering
hit. - A BlurFilter on the game layer on entering
paused. - A scene FSM swaps TilingSprite background layers.
aiquadtreejs
Section titled “aiquadtreejs”2D quadtree rebuilt every frame; it does the broadphase only, and the caller does the exact checks. See the aiquadtreejs guide.
In games
- Bullet broadphase:
clear()andinsert()again every frame. boundsand query regions accept PixigetBounds()results directly; both exclude the AABB’s right and bottom edges.retrieveover an enemy’s vision region returns the targets it might see.
In editors
- Marquee selection and hover picking over thousands of nodes:
retrievethe candidates, then check them exactly.
PixiJS techniques
- Fog-of-war masks: query the objects inside the visible region.
- Hit testing: narrow the candidates with the quadtree before exact checks.
aipooljs
Section titled “aipooljs”Fixed-size object pool with O(1) acquire() and release(). See the aipooljs guide.
In games
- Bullets and particles come from the pool and go back after use.
onOverflow: 'null'makesacquire()returnnullunder load, dropping that spawn.borrow(fn, { signal })for scoped effects: the object goes back whenfnends; an abort returns the object but does not stop the work insidefn.- The
aliveandavailablecounters can go straight onto a debug overlay.
In editors
- Preview nodes are pooled too.
- Releasing a foreign or already released object throws
PoolError, which catches tool bugs early.
PixiJS techniques
- Particles, BitmapText damage-number pops and MeshRope segments all suit a pool.
aibridgejs
Section titled “aibridgejs”Transport-agnostic cross-context bridge; adapters handle the differences between hosts. See the aibridgejs guide.
In games
- A game inside a WebView uses
callto ask the host to save or handle a purchase, andemitto report progress. timeoutMsmakes an unresponsive host fail withBridgeTimeoutErrorinstead of hanging.
In editors
- Between the editor shell and the canvas iframe, use the iframe adapter with
targetOriginset to an exact origin, as the Sprite Playground does. - Tests switch to the mock adapter from
aibridgejs/mock. aibridgejs/detectpicks an adapter from the host environment.
PixiJS techniques
- Render a thumbnail to a RenderTexture, encode it as PNG and send it to the host over
call. - The host sends an event when it resizes, and the game calls
renderer.resize.
Recipes
Section titled “Recipes”Bullet hell
Section titled “Bullet hell”aipooljs + aiquadtreejs + aiecsjs + aieventjs. Firing takes a bullet from the pool and creates an entity; a movement system updates the SoA position columns and writes them into a ParticleContainer. Each frame the quadtree is rebuilt from those columns, retrieve returns candidates for the exact check, and a hit emits an event that the BitmapText HUD and the audio subscribe to. Bullets that leave the arena or hit something go back to the pool.
Character
Section titled “Character”aispritejs + aifsmjs + aiaudiojs. Player input goes to an aifsmjs machine that decides the behaviour state, such as idle, attack or hit. On each transition an effect turns the new state into aispritejs inputs and plays the matching sound through aiaudiojs; aispritejs then picks the frame from its graph.
Editor
Section titled “Editor”aibridgejs + aifsmjs (aifsmjs/inspect) + aiecsjs (aiecsjs/serialize) + aispritejs (aispritejs/schema). The editor shell and the Pixi canvas iframe talk through aibridgejs. aifsmjs manages tool modes, and the recorder from aifsmjs/inspect keeps the log behind the state panel and bug reports. Scene data lives in an aiecsjs world, saved and undone through aiecsjs/serialize. Imported animation graphs are validated against aispritejs/schema first. The Sprite Playground implements the bridge between shell and iframe.
Live demos
Section titled “Live demos”Each of these five package guides includes an interactive PixiJS demo: