Skip to content

useRenderLoop

Register a callback in the app's render loop (onBeforeRender), with support for dynamic pause and resume.

Usage

ts
import { useRenderLoop } from '@threeuse/core'

const { pause, resume, isPaused } = useRenderLoop(app, (delta, elapsed) => {
  mesh.rotation.y += delta
})

Parameters

ParamTypeDescription
appThreeUseAppApplication instance
fnFrameCallbackPer-frame callback (delta, elapsed) => void

Return Value

PropertyTypeDescription
pause() => voidPause callback execution
resume() => voidResume callback execution
isPausedRef<boolean>Current pause state

Demo

已暂停:

Released under the MIT License.