PixiJS 2D World Viewer — Technical Summary

A focused rendering approach: treat the world as data, render only visible projections, and reuse display objects to keep performance stable.

Data vs Rendering Separation

World objects are stored as lightweight data (position/velocity/type). Pixi display objects are created only for visible elements. This keeps memory predictable and makes performance scale with what the camera actually sees.

Spatial Partitioning (Grid)

The world is divided into fixed-size cells. Each object is assigned to a cell: cellX = floor(x / cellSize), cellY = floor(y / cellSize). Cells are stored in a map (chunked lookup).

Viewport Culling

On each camera update, compute the visible rectangle (viewport + margin) and query only intersecting cells. Off-screen objects do not exist in the active Pixi render tree, so they do not consume rendering cost.

Object Pooling

Reuse Pixi display objects instead of creating/destroying them during panning. Lifecycle is driven by visibility: visible → acquire, invisible → release.

Camera System

Smooth panning (with inertia/smoothing) keeps navigation responsive while the visibility-driven render tree adapts.

Tradeoffs

What to Build Next

Same system, three representations: abstract (this page) → story → live simulation.