Clockwork

Clockwork is a TypeScript-first, modular game engine workspace focused on ECS-driven runtime systems and a WebGL2 renderer stack.

ECS Entities

ECS Entities

Entities are represented as:

const entityId = {
  index: 0,
  generation: 0
}

Allocation Model

EntityManager uses:

  • generations[]
  • alive[]
  • freeIndices[]

Destroyed indices are reused, generation increments on destroy.

Safety Model

isAlive(entity) validates both index and generation.

Stale entity handles fail safely.

Iteration

iterAlive() yields only living entity IDs.

Notes

  • aliveCount tracks current live entities.
  • Reuse behavior is covered by tests for generation bump correctness.
Last updated: February 17, 2026