@react-three/fiber
react-three-fiber is a React renderer for threejs.
Build your scene declaratively with re-usable, self-contained components that react to state, are readily interactive and can participate in React's ecosystem.
npm install three @types/three @react-three/fiber
Does it have limitations?
None. Everything that works in Threejs will work here without exception.
Is it slower than plain Threejs?
No. There is no overhead. Components render outside of React. It outperforms Threejs in scale due to React's scheduling abilities.
Can it keep up with frequent feature updates to Threejs?
Yes. It merely expresses Threejs in JSX, <mesh />
dynamically turns into new THREE.Mesh()
. If a new Threejs version adds, removes or changes features, it will be available to you instantly without depending on updates to this library.
What does it look like?
Let's make a re-usable component that has its own state, reacts to user-input and participates in the render-loop. (live demo |