Skip to content

How to split logic into multiple system phases

  1. Create a Schedule and register systems by phase name:
1
2
3
4
5
6
const sched = new Schedule();

sched
  .add("input", (w: any) => { /* ... */ })
  .add("sim",   (w: any, dt: number) => { /* ... */ })
  .add("render",(w: any) => { /* ... */ });
  1. Define phase order:
1
const phases = ["input", "sim", "render"];
  1. Run it each tick (flush happens after each phase):
1
sched.run(world, dt, phases);