enable rendering even when tab is out of focus #2204
Unanswered
ashleymvanduzer
asked this question in
Q&A
Replies: 1 comment 4 replies
-
render loops should normally use requestAnimationFrame which the browser can schedule and interupt. your components could still rely on time and deltas, it shouldn't make any difference if the tab is active or not. not sure why you'd want that, all it does is waste energy, but here's something that will more or less work. function Render() {
const { gl, scene, came, invalidate, clock, internal } = useThree()
useEffect(() => {
const interval = setInterval(() => {
const delta = state.clock.getDelta()
// Call subscribers (useFrame)
const subscribers = internal.subscribers
for (i = 0; i < subscribers.length; i++) {
subscription = subscribers[i]
subscription.ref.current(subscription.store.getState(), delta)
}
// Render out
gl.render(scene, camera)
}, 1000 / 60)
return () => clearInterval(interval)
}, [gl, scene, camera, clock, internal])
}
<Canvas frameloop="never">
<Render /> |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone!
is there a prop to force rendering even when the tab is out of focus? or maybe there is a way if using a custom renderer?
Beta Was this translation helpful? Give feedback.
All reactions