Skip to content

Pixi Plugin

The PixiPlugin bootstraps the PixiJS Application and wires all Pixi-related systems into the ECS world.


import { PixiPlugin } from '@shell/pixi';
world.addPlugin(PixiPlugin);

This is the simplest setup. It registers components, systems, resources, and spawns a default camera entity.


PixiPlugin accepts all pixi.js ApplicationOptions plus one additional option:

interface PixiPluginOptions extends ApplicationOptions {
spawnCamera?: boolean; // default: true
}
OptionTypeDefaultDescription
spawnCamerabooleantrueWhether to spawn a camera at startup.

PixiJS options are passed through to PixiApp.setOptions(). backgroundColor is what the screen is cleared with where no Camera has a background of its own:

world.addPlugin(PixiPlugin, {
backgroundColor: 0x000000,
antialias: true,
spawnCamera: false,
});

On a screen with more than one pixel to a CSS pixel, a phone’s or a Retina display’s, Pixi draws at Math.min(devicePixelRatio, 2) of them: sharp, and on a phone of 3 at less than half the pixels to fill. autoDensity shows the canvas at its CSS size, except a canvas resized to itself (resizeTo: canvas), whose own CSS gives it its size: autoDensity would pin that size, and the canvas would no longer follow the page when a phone is turned. With scaleMode: 'nearest' the canvas gets image-rendering: pixelated, so pixel art keeps hard edges where the browser scales it once more. A resolution or autoDensity in the options is kept.


  • Sprite
  • Text
  • PixiTransformGroup
  • RenderLayer
  • Tint
  • Texture
  • NineSlice
  • Camera
  • pixiApp — PixiApp instance
  • pixiAssets — PixiJS Assets
  • pixiNodes — PixiNodeRegistry with logical groups and role-owned nodes
SystemScheduleOrdering
CameraSyncSchedule.RenderBefore node synchronization
PixiTransformGroupInitSchedule.RenderBefore concrete node creation
Sprite and text syncSchedule.RenderBefore generic transform sync
PixiRenderLayerSyncSchedule.RenderRoutes nodes to world or UI
Transform and pivot syncSchedule.RenderAfter concrete node creation
TickerSchedule.RenderAfter all synchronization

If spawnCamera is true (the default), a CameraPrefab entity is spawned during startup.


PixiJS creates a <canvas> element. If the consumer does not provide a canvas via ApplicationOptions, the plugin appends the auto-created canvas to a DOM element with id="pixi-container":

<div id="pixi-container"></div>

If no container is found, the plugin throws an assertion error.


If you want full control over the camera or other setup, pass spawnCamera: false and spawn your own camera entity:

import { Define } from '@shell/ecs';
import { Camera, PixiPlugin } from '@shell/pixi';
import { Position, Rotation } from '@shell/transform';
world.addPlugin(PixiPlugin, { spawnCamera: false });
commands.spawn(
Define.prefab()
.with(Position, { x: 0, y: 0 })
.with(Camera, { zoom: 1 })
.with(Rotation, { x: 0, y: 0, z: 0 }),
);