Skip to content

Commit

Permalink
Perf: Pause RAF loop when there are no updates
Browse files Browse the repository at this point in the history
Co-authored-by: Wouter lucas van Boesschoten <[email protected]>
  • Loading branch information
frank-weindel and wouterlucas committed Dec 5, 2023
1 parent b96eb19 commit 753f568
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/core/platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ export const startLoop = (stage: Stage) => {
const runLoop = () => {
stage.updateAnimations();

if (!stage.hasSceneUpdates()) {
setTimeout(runLoop, 1000 / 60);
return;
}

stage.drawFrame();
requestAnimationFrame(runLoop);
};
Expand Down

0 comments on commit 753f568

Please sign in to comment.