|
@@ -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,
|