Can you download the canvas of react Three Fiber as image ? #2054
-
How are you ? Based on the example in the documentation, do you know how to do it ? https://docs.pmnd.rs/react-three-fiber/getting-started/introduction |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
sure. here's a running example (open leva, click "screenshot"): https://codesandbox.io/s/basic-demo-forked-rnuve the threejs canvas needs a prop for that to work: <Canvas gl={{ preserveDrawingBuffer: true }} this is not something for us to document i guess, it's a regular webgl/threejs thing. like a thousand other things that are very specific and usecase driven. |
Beta Was this translation helpful? Give feedback.
-
Thank you for everything you do for the community |
Beta Was this translation helpful? Give feedback.
-
In my case, I don't want to leave preserveDrawingBuffer as true all the time, because as far as I know that can have performance implications. I want to be able to turn it on, capture a screenshot, then turn it off; turning it on after a while doesnt seem to have an effect though; I came across this answer on stackoverflow for another way tot do this in three.js: renderer.render( scene, camera );
var screenshot = renderer.domElement.toDataURL();
Are there hooks in r3f, like onAfterRender - that can be used on a |
Beta Was this translation helpful? Give feedback.
sure. here's a running example (open leva, click "screenshot"): https://codesandbox.io/s/basic-demo-forked-rnuve
the threejs canvas needs a prop for that to work:
this is not something for us to document i guess, it's a regular webgl/threejs thing. like a thousand other things that are very specific and usecase driven.