Skip to content

world2d — the 2D render surface

vgai renders through surfaces. The default is Three.js world3d (Object3Ds); the React HUD is a second; world2d is a third — a PixiJS v8 2D surface with Rapier 2D physics. The load-bearing idea: world2d reuses the same engine model — entities, the GameComponent lifecycle, and authored scene data — and only swaps what a node is (a PixiJS display object instead of an Object3D).

A 2D game running on the world2d surface
An authored Scene2D on world2d: Rapier-2D bodies, a GameComponent2D player, a coin HUD.
  • Surface: a PixiJS Application driven by the engine’s shared SystemRunner / phase order (not Pixi’s own ticker) — so 2D systems run in the same phases as 3D.
  • Entities & behavior: GameComponent2D has the same init / update / dispose (and trigger) lifecycle as the 3D GameComponent; gameplay code transfers directly.
  • Scenes: authored as a Scene2DFile (the 2D analogue of .vscn), loaded into PixiJS display objects; a tilemap section maps to @pixi/tilemap.
  • Physics: Rapier 2D (@dimforge/rapier2d-compat) in a separate world, with a 2D transform-writer and collision/trigger handling.