How to click a button outside of r3f and pass the click into r3f? #2329
Replies: 3 comments 2 replies
-
Have you considered using a global state management library like Zustand? As long as it's not something inside the render loop (i.e. it's not changing something within 60fps+ loops) then you should be fine with that too. Either way, depending on the size of the app, you might want to reconsider using a global state management tool instead of trying to pass functions and props into the React tree. |
Beta Was this translation helpful? Give feedback.
-
ref on canvas gives you the html canvas element which is useless for what you are trying to do. there are many way in which you can access canvas state, for instance onCreated const [state, set] = useState()
return <Canvas onCreated={set} /> state will contains the scene, camera, everything you need. |
Beta Was this translation helpful? Give feedback.
-
There needs to be a standard solution for this, Building a web interface for r3f using normal react is essential. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there, I would like to have a
<button>
outside of r3f that I can click and then tell r3f that I clicked.The use case is similar to this question where I want to export some meshes from the r3f scene based on the click: https://stackoverflow.com/questions/71874160/how-to-export-obj-file-using-react-three-fiber
A minimal and working repro can be found here: https://codesandbox.io/s/shy-worker-g64peh?file=/src/App.js
Thank you for any help!
Beta Was this translation helpful? Give feedback.
All reactions