Creating a desktop Minecraft clone using React, Three.js, React Three Fiber, React Three Drei, React Three Cannon.
This project was bootstrapped with Create React App.
Controls
Action | Controls |
---|---|
Movements | W/S/D/A |
Sprint | LShift |
Jump | Space |
Add Cube | LClick |
Remove Cube | Alt+LClick |
Change Material | 1-0 |
note: For better accuracy, when clicking to lock the cursor to the mouse, click as close as you can to the cursor. That aligns the camera center and the mouse. Any offset between clicked position and center of viewport is not handled in this app version.
Back to top
- Runs the app in the development mode.
Open http://localhost:3000 to view it in the browser.cd react-threejs-minecraft npm i npm start
Back to top
In the project directory, you can run:
Runs the app in the development mode.
Open http://localhost:3000 to view it in your browser.
The page will reload when you make changes.
You may also see any lint errors in the console.
Builds the app for production to the build
folder.
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.
Your app is ready to be deployed!
See the section about deployment for more information.
Note: this is a one-way operation. Once you eject
, you can't go back!
If you aren't satisfied with the build tool and configuration choices, you can eject
at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except eject
will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.
You don't have to ever use eject
. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.
Back to top
-
Prerequisite:
- Make sure Node and NPM are installed on your computer. You can download both at nodejs.org (NPM is included in your Node installation).
- Please see
.nvmrc
file at the root ofreact-threejs-minecraft
repo. - Using nvm, a Node Version Manager is recommended as it helps you manage and switch between different Node versions with ease. It provides a command-line interface where you can install different versions with a single command, set a default, switch between them, etc.
-
In GitHub click on the repository nammed react-threejs-minecraft
-
Clone the repository locally. Run
git clone https://github.com/sctlcd/react-threejs-minecraft.git
-
Install all modules listed as dependencies in package.json
cd react-threejs-minecraft npm i
note: in this app
- three - JavaScript 3D library
- react-three/cannon - Physics based hooks for react-three-fiber
- react-three/drei - Useful add-ons for react-three-fiber
- react-three/fiber - React renderer for threejs
- react - JavaScript library for creating user interfaces
- react-dom - Package that serves as the entry point to the DOM and server renderers for React
- react-merge-refs - React utility to merge refs
- react-scripts - Configuration and scripts for Create React App
- react-spring - Cross-platform spring-physics first animation library
- nanoid - Secure, URL-friendly, unique string ID generator for JavaScript
- zustand - State-management solution in React
- react-tooltip - react-tooltip
- babel-plugin-macros - Allows you to build simple compile-time libraries
- @fortawesome/react-fontawesome - Font Awesome React component
- @fortawesome/free-solid-svg-icons - The SVG, font, and CSS toolkit
- @fortawesome/fontawesome-svg-core - The SVG, font, and CSS toolkit
-
Runs the app in the development mode. Open http://localhost:3000 to view it in the browser.
cd react-threejs-minecraft npm start
Back to top
react-threejs-minecraft live website is currently deployed on Firebase using the main
branch on GitHub. Once you have the project setup locally, you can proceed to deploy it remotely.
-
Install Firebase CLI Tools, firebase-tools
npm install -g firebase-tools
-
Create
firebase.json
and.firebaserc
at the root of your project with the following content:firebase.json
:{ "hosting": { "public": "build", "ignore": [], "rewrites": [ { "source": "**", "destination": "/index.html" } ] } }
.firebaserc
:{ "projects": { "default": "<YOUR_FIREBASE_ID>" } }
-
After running
npm run build
, deploy using the commandfirebase deploy
.
=> live link: https://react-threejs-minecraft.web.app/
Back to top
- favicon.ico - icon-icons.com | copyright VectorLogoZone
- grass.jpg - Pinterest | copyright unknown
- log-min.png - Pinterest | copyright unknown
- lava-min.jpg - Pinterest | copyright unknown
- stone-min.jpg - Pinterest | copyright unknown
- dirt-min.jpg - Pinterest | copyright unknown
- sand-min.jpg - Pinterest | copyright unknown
- wood-min.jpg - Pinterest | copyright unknown
- brik-min.jpg - Pinterest | copyright unknown
- glass-min.jpg - Pinterest | copyright unknown
- water-min.jpg - Pinterest | copyright unknown
Back to top