Skip to content

Setup

loop() ​

ts
function loop(fn, options?): Loop;

Defined in: loop.js:35

Runs fn every animation frame.

time is the seconds the loop has been running, not counting time spent stopped, so animations resume where they left off. delta is the seconds since the previous frame.

Parameters ​

ParameterTypeDescription
fn(time, delta, frame) => voidCalled with the seconds the loop has run, the seconds since the last frame, and the frame number.
options?LoopOptionsSee LoopOptions.

Returns ​

Loop

Example ​

ts
loop((time, delta) => {
  quad.bindVAOs();
  quad.setUniforms({ u_time: time });
  quad.render();
});