Giter VIP home page Giter VIP logo

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

React-Three-Js-Workshop

Introduction

Hi ! !
Welcome to our workshop. Today we are gonna learn the basic of React ThreeJS.
In order to not get lost during the Workshop, please follow the steps below.

Step 1 :

First, you need to install node !
sudo dnf install nodejs

Clone the repo !

git clone [email protected]:RayanBn/React-Three-Js-Workshop.git

Steps to follow for compiling :

npm install
npm run dev

Step 2 :


Let's begin by creating objects (Experience.js)

<mesh>
    <boxBufferGeometry></boxBufferGeometry>
    <meshStandardMaterial></meshStandardMaterial>
</mesh>

Now it's your turn to play with the object parameters to get the result you like the most ! When the object will be created, you will notice that its color won't apply. In order to fix this issue, you have to add lights to your scene.

https://docs.pmnd.rs/react-three-fiber/getting-started/your-first-scene#adding-lights

Step 3 :


Camera movement, in your canva object of the index.js file, a camera has already been added to the scene. It is up to you to learn about it and to be able to modify and manipulate it as you wish!

camera={ {
    fov: 45,
    near: 0.1,
    far: 200,
    position: [ -4, 3, 6 ]
} }

The goal here is to be able to create a camera control, that will allow us to turn around our scene ! (OrbitControl)

Step 4 :


Now let's try to make the objects on our scene move. In order to interact with the objects in our scene in react, we need to use hooks. The most used Hook in React Three is UseFrame, this one will take a function that will be called at each frame of your scene. Here is a link to learn how to use it:

https://docs.pmnd.rs/react-three-fiber/api/hooks#useframe

import { useFrame } from '@react-three/fiber'

function Foo() {
  useFrame((state, delta, xrFrame) => {
    // This function runs at the native refresh rate inside of a shared render-loop
})

Step 5:


Enjoy ! If you liked this workshop, don't hesitate to star the repository :) ! Workshop 2

react-three-js-workshop-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.