This is a small set of personal R3F utils I use in my projects.
npm install @keupoz/r3f-utils @react-three/fiber @react-three/drei three camera-controls
import { CameraControls, Canvas, FocusControls, Grid, Lights } from '@keupoz/r3f-utils'
import { Box, PerspectiveCamera } from '@react-three/drei'
export function App() {
return (
<Canvas>
<PerspectiveCamera makeDefault position={[32, 32, 32]} />
<CameraControls makeDefault />
<Lights />
<Grid color={0x252525} />
<FocusControls>
<Box />
</FocusControls>
</Canvas>
)
}
Adapted version of CameraControls from Drei. It has fixes for the demand
frameloop and a bit better structured code.
Just the Canvas component from R3F with some preconfigured properties such as demand
frameloop and linear color space.
A simple components that allows the user to focus the camera on scene object of their choice. Also includes a simple highlight of the hovered object.
How to use:
- Double click on any object to focus on them.
- Double click on empty space to reset focus.
Just the Grid component from Drei with some preconfigured properties.
A preset of scene lights.
Internally used by FocusControls. Exposed to be able to set focus on any specified object.
- CameraControls doesn't properly update when its methods are called without enabled transition. I won't bother fixing as I only need them with enabled transition.