Example
npm install r3dy
Example
import { Canvas } from '@react-three/fiber'
import { Switch } from 'r3dy'
<div className="flex justify-center">
<div className='h-[200px] w-[300px] '>
<Canvas shadows>
<Switch model={1}/>
</Canvas>
</div>
</div>
r3dy
as well asCanvas
from@react-three/fiber.
Now that you've included dependencies, wrap your component in aCanvas
tag. Make sure to include shadows in theCanvas
tag or they will not show up.Canvas
is nested in 2 divs. The first div is meant to contain theCanvas
. By natureCanvas
will try to fill as much space as its allowed, so if you dont nest it in a div, and you have margins, it will constantly expand to fit those margins. The second div is used to adjust the placement of the first. As mentioned,Canvas
took up the entire space of the first div. Now that its contained, you will need another to move it about the page.