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
| Param | Type | Description |
|---|---|---|
app | ThreeUseApp | Application instance |
fn | FrameCallback | Per-frame callback (delta, elapsed) => void |
Return Value
| Property | Type | Description |
|---|---|---|
pause | () => void | Pause callback execution |
resume | () => void | Resume callback execution |
isPaused | Ref<boolean> | Current pause state |
Demo
已暂停: