Skip to content

Commit

Permalink
fix: RenderTexture for WebXR (#2010)
Browse files Browse the repository at this point in the history
  • Loading branch information
bbohlender authored Jun 26, 2024
1 parent a0c81c9 commit bd19791
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/core/RenderTexture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,17 +112,23 @@ function Container({
let count = 0
let oldAutoClear
let oldXrEnabled
let oldRenderTarget
let oldIsPresenting
useFrame((state) => {
if (frames === Infinity || count < frames) {
oldAutoClear = state.gl.autoClear
oldXrEnabled = state.gl.xr.enabled
oldRenderTarget = state.gl.getRenderTarget()
oldIsPresenting = state.gl.xr.isPresenting
state.gl.autoClear = true
state.gl.xr.enabled = false
state.gl.xr.isPresenting = false
state.gl.setRenderTarget(fbo)
state.gl.render(state.scene, state.camera)
state.gl.setRenderTarget(null)
state.gl.setRenderTarget(oldRenderTarget)
state.gl.autoClear = oldAutoClear
state.gl.xr.enabled = oldXrEnabled
state.gl.xr.isPresenting = oldIsPresenting
count++
}
}, renderPriority)
Expand Down

0 comments on commit bd19791

Please sign in to comment.