firtoz / react-three-renderer

Render into a three.js canvas using React.
https://toxicfork.github.com/react-three-renderer-example/
MIT License
1.49k stars 155 forks source link

Added handling for if environment doesn't have a 3d context #164

Closed matthova closed 7 years ago

toxicFork commented 7 years ago

Thanks for the PR! ❤️

I think it could be improved a bit more, for example there are a few more places where requestAnimationFrame is being used, as well as cancelAnimationFrame which may have similar issues.

It could be a good idea to do a one-time check in the beginning, e.g. in the top of the file, check if requestAnimationFrame is a function. If not, try to get a shim for it. Speaking of shims, I remembered the raf package.

Can you please check how that package could be used and update the PR? I can provide hints if you get stuck :)

toxicFork commented 7 years ago

Resolved by using raf