- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Creating a Plane in React using React-Three-Fiber
In this article, we will see how to create a plane in React using React-Three-Fiber. Planes are widely used shapes in 3D rendering. We will create a 2D plane for now, but you can add orbital controls in it to make it 3D. We will also use lighting and different colors. Let's get started.
Example
First install the following package −
npm i --save @react-three/fiber three
threejs and react-three/fiber will be used to add webGL renderer to the website and three-fiber will be used to connect threejs and React.
Add the following lines of code in App.js −
import { Canvas } from "@react-three/fiber"; export default function App() { return ( <Canvas> <ambientLight /> <mesh> <planeBufferGeometry attach="geometry" args={[25, 15]} /> <meshPhongMaterial attach="material" color="green" /> </mesh> </Canvas> ); }
Explanation
We have used −
meshPhongMaterial to add color and style,
planeBufferGeometry to add the geometry. It takes only one argument "args" that contains the width and height of the plane.
Output
On execution, it will produce the following output −
- Related Articles
- Creating a Sky shader in React using React-Three-Fiber
- Creating a 3D donut-like structure in React using react-three-fiber
- Creating a 3D Metal Texture Box in React using React-Three-Fiber
- Creating 3D Text using React-three-fiber
- Creating 3D Globe using React-three-fiber
- Making a wobbling cube in React using react-three-fiber
- Making an axes helper in React using react-three-fiber
- How to make a 3D cube in React using react-three-fiber
- Using pointer light for better lighting in React JS with React-Three-Fiber
- Creating a parallax scrolling effect in React using react-spring.mp4
- Adding OrbitControls in React using reactthree-fiber
- How to make a ring in React using reactthree-fiber
- How to make a cylinder in React using reactthree-fiber
- Creating a Particle Animation in React JS
- Creating a Customizable Modal in React JS

Advertisements