Skip to content

Prefabs

@shell/pixi provides render bundles and a camera prefab. Render bundles contain public intent and layout data; the runtime transform group arrives through required-component relationships.

Image includes Sprite, Texture, Size, Position, and Anchor.

TextLabel includes Text, Size, Pivot, and Position. Adding Text automatically adds PixiTransformGroup; the bundle does not manually include runtime plumbing.


export const CameraPrefab = Define.prefab().with(Camera, Position, Rotation);

A prefab bundling the three components needed for a functional camera. Position and Rotation are canonical @shell/transform components used internally by the Pixi camera systems.

ComponentPurpose
CameraZoom level
PositionPosition in world space
RotationRotation around Z axis

When PixiPlugin is added with spawnCamera: true (the default), a camera entity is spawned automatically during startup:

world.addPlugin(PixiPlugin); // spawns CameraPrefab

The spawned entity has default values for all components:

  • Camera.zoom = 1
  • Position.x = 0, Position.y = 0, Position.z = 0
  • Rotation.x = 0, Rotation.y = 0, Rotation.z = 0

To create a camera with custom initial values, disable the default spawn and spawn your own:

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(Camera, { zoom: 2 })
.with(Position, { x: 0, y: 0, z: 0 })
.with(Rotation, { x: 0, y: 0, z: 0 }),
);

Only one camera entity is needed. The CameraSync system applies the first matching camera’s transform to the world container.