git clone [email protected]:RayanBn/React-Three-Js-Workshop2.git
Steps to follow for compiling :
npm install
npm run dev
root.render(
<StrictMode>
<Canvas
camera={ {
fov: 45,
near: 0.1,
far: 200,
position: [ - 4, 3, 6 ]
} }
>
<Experience />
</Canvas>
</StrictMode>
)
To do this, you must first import it:
import { useControls } from 'leva'
Once the module is imported, you will be able to declare several variables with a default value and then modify them in real time on your site:
const { color } = useControls({
color: '#ff0000',
})
<meshStandardMaterial color={ color } />
import { Physics, RigidBody, Debug } from "@react-three/rapier";
Here is a link to the documentation of rapier. Here the goal will be to create simple objects with physics and to be able to modify their hitbox:
https://github.com/pmndrs/react-three-rapier
https://github.com/pmndrs/drei#usegltf
Here is a link where you can find several free model dedicated to react three js:
https://market.pmnd.rs/ Now, using leva, you need to be able to create a single geometric shape on your scene, add physics to it, interact with it and change the shape at any time.
1) Create a dropdown in leva, allowing you to choose the geometric shape.
2) Create a dropdown in leva, allowing you to choose the action to be taken during interaction.
3) Implement the 2 functionalities so that the user can choose a shape and an interaction.
To go a step further, a hook often used is the useScroll, which will make your site more dynamic and pleasant. Here's an example of how to use this hook: https://www.gsap.com/