Giter VIP home page Giter VIP logo

react-three-js-workshop2-edgar-dion's Introduction

React-Three-Js-Workshop2

Introduction

In this second workshop session, you will discover the physics with React Three JS.

Step 1

Clone the repo !
git clone [email protected]:RayanBn/React-Three-Js-Workshop2.git

Steps to follow for compiling :

npm install
npm run dev

Step 2

Let's start by discovering how to debug a react three application! Let's start by surrounding our code with a tag to warn you of any problem you may encounter.

root.render(
    <StrictMode>
        <Canvas
            camera={ {
                fov: 45,
                near: 0.1,
                far: 200,
                position: [ - 4, 3, 6 ]
            } }
        >
            <Experience />
        </Canvas>
    </StrictMode>
)

Step 3

Now, it is important to be able to quickly test what we want to do. For this, we will use leva!
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 } />

Step 4

Now let's go to the physics! For this, we will use a branch of react three called rapier.
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

Step 5

Thanks to step 4, you will be able to access the properties of each object, to then modify them as you wish. This allows you to make them interact with your scene. Now, let's learn how to load 3D models with react-three/drei. Here is a link to the documentation:
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/

react-three-js-workshop2-edgar-dion's People

Contributors

raskc avatar rayanbn avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.