![npm](https://img.shields.io/npm/dt/drei.svg)
A growing collection of useful helpers and abstractions for react-three-fiber, saving you some boilerplate.
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
yarn add drei
import { ... } from 'drei'
Index
<PerspectiveCamera />
![](https://img.shields.io/badge/-codesandbox-blue)
<OrbitControls />
![](https://img.shields.io/badge/-codesandbox-blue)
<MapControls />
![](https://img.shields.io/badge/-codesandbox-blue)
<TrackballControls />
<TransformControls />
![](https://img.shields.io/badge/-codesandbox-blue)
<Detailed />
![](https://img.shields.io/badge/-codesandbox-blue)
<PositionalAudio />
![](https://img.shields.io/badge/-suspense-brightgreen)
<StandardEffects />
![](https://img.shields.io/badge/-useFrame-red)
<Sky />
![](https://img.shields.io/badge/-codesandbox-blue)
<HTML />
![](https://img.shields.io/badge/-codesandbox-blue)
<Stats />
![](https://img.shields.io/badge/-useFrame-red)
draco()
![](https://img.shields.io/badge/-codesandbox-blue)
Exports
Cameras
⚡️ <PerspectiveCamera />
![](https://img.shields.io/badge/-codesandbox-blue)
A responsive THREE.PerspectiveCamera that sets itself as the default.
<PerspectiveCamera
makeDefault
{...props}
>
<mesh />
</PerspectiveCamera>
Controls
If available controls have damping enabled by default, they manage their own updates, remove themselves on unmount, are compatible with the invalidateFrameloop
canvas-flag. They inherit all props from their underlying THREE controls.
⚡️ <OrbitControls />
![](https://img.shields.io/badge/-codesandbox-blue)
⚡️ <MapControls />
![](https://img.shields.io/badge/-codesandbox-blue)
⚡️ <TrackballControls />
⚡️ <TransformControls />
![](https://img.shields.io/badge/-codesandbox-blue)
Abstractions
⚡️ <Detailed
> ![](https://img.shields.io/badge/-codesandbox-blue)
A wrapper around THREE.LOD (Level of detail).
<Detailed
distances={[0, 10, 20]}
{...props}
>
<mesh geometry={highDetail} />
<mesh geometry={mediumDetail} />
<mesh geometry={lowDetail} />
</Detailed>
⚡️ <PositionalAudio />
![](https://img.shields.io/badge/-suspense-brightgreen)
A wrapper around THREE.PositionalAudio. Add this to groups or meshes to tie them to a sound that plays when the camera comes near.
<PositionalAudio
url="/sound.mp3"
distance={1}
loop
{...props}
/>
⚡️ <StandardEffects />
![](https://img.shields.io/badge/-useFrame-red)
Adds ambient-occlusion, bloom and SMAA using the postprocessing library.
<StandardEffects
smaa
ao
bloom
edgeDetection={0.1}
bloomOpacity={1}
effects={() => [...fx]}
/>
Shaders
⚡️ <Sky />
![](https://img.shields.io/badge/-codesandbox-blue)
Adds a sky to your scene.
<Sky
distance={450000}
sunPosition={[0, 1, 0]}
{...props}
/>
Misc
⚡️ <HTML />
![](https://img.shields.io/badge/-codesandbox-blue)
Allows you to tie HTML content to any object of your scene. It will be projected to the objects whereabouts automatically.
<HTML
prepend
center
fullscreen
scaleFactor={10}
zIndexRange={[100, 0]}
portal={domnodeRef}
{...groupProps}
{...divProps}
>
<h1>hello</h1>
<p>world</p>
</HTML>
⚡️ <Stats />
![](https://img.shields.io/badge/-useFrame-red)
Adds stats to document.body. It takes over the render-loop!
<Stats
showPanel={0}
{...props}
/>
⚡️ draco()
![](https://img.shields.io/badge/-codesandbox-blue)
Adds the Draco extension to your GLTFLoader.
useLoader(
GLTFLoader,
url,
draco(
'/draco-gtltf/'
)
)