Skip to content

Commit

Permalink
fix: start loop if user calls useRenderLoop (#695)
Browse files Browse the repository at this point in the history
  • Loading branch information
andretchen0 authored May 27, 2024
1 parent dac4d7c commit 43c3229
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/composables/useRenderLoop/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ onAfterLoop.on(() => {
elapsed = clock.getElapsedTime()
})

let startedOnce = false
export const useRenderLoop = (): UseRenderLoopReturn => {
if (!startedOnce) {
// NOTE: `useRenderLoop` is not started by default
// in order not to waste user resources. Instead, we'll
// start the loop the first time the user uses
// `useRenderLoop`.
startedOnce = true
resume()
}
return {
onBeforeLoop: onBeforeLoop.on,
onLoop: onLoop.on,
Expand Down

0 comments on commit 43c3229

Please sign in to comment.