On-demand rendering

Render only while the camera is moving.

klipp.update returns true while anything is still moving (a blend, damping catching up, a shake), or the shot changed this frame. Render only then, and skip frames while the camera has settled.

Keep calling update every frame, even while nothing renders. It notices on its own when a target moves or a setting changes. React Three Fiber's frameloop="demand" is different: it stops calling frames altogether, so it needs a nudge, see its tab.

Usage

function frame(dt: number) {
  if (klipp.update(dt) || sceneChanged) {
    engine.camera.setTransform(klipp.shot.position, klipp.shot.quaternion);
    engine.render();
  }
}