Skip to content

How to manually call renderer.render(scene, camera) of the Canvas? #868

Answered by drcmda
trusktr asked this question in Q&A
Discussion options

You must be logged in to vote

you can always call gl.render inside useFrame((state, delta) => state.gl.render(state.scene, state.camera)), for instance if you wanted to render into an off-buffer: https://codesandbox.io/s/r3f-render-target-qgcrx

but you can also take over the render loop by providing an index: useFrame((state, delta) => ..., index)

https://codesandbox.io/s/react-three-fiber-viewcube-py4db

if there's a non zero index the renderloop belongs to you, and you can even chain render passes like that (bigger index comes last). once the component unmounts the renderloop goes back to normal (automated by r3f)

Replies: 1 comment 8 replies

Comment options

You must be logged in to vote
8 replies
@trusktr
Comment options

@trusktr
Comment options

@trusktr
Comment options

@trusktr
Comment options

@trusktr
Comment options

Answer selected by trusktr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants