This is a growing collection of useful helpers and abstractions for react-three-fiber, saving you some boilerplate.
yarn add drei
import { ... } from 'drei'
Exports
Cameras
<PerspectiveCamera>
<mesh />
</PerspectiveCamera>
Controls
All controls have damping enabled by default, they manage their own updates, remove themselves on unmount, are compatible with the invalidateFrameloop
canvas-flag.
<TransformControls>
<mesh />
</TransformControls>
Abstractions
<Detailed distances={[0, 10, 20]}>
<mesh />
<mesh />
<mesh />
</Detailed>
<mesh>
<PositionalAudo url="/song.mp3" />
</mesh>
Misc
useLoader(GLTFLoader, url, draco())
Contributions
If you find yourself repeating set-up code often and if it's generic enough, add it here, everyone benefits!
Requirements
- Types
- ForwardRefs if possible, so that objects can be referenced back
- Invalidate frames on any movement for those using invalidateFrameloop
- Cleanup on unmount, no left-overs, restore previous states