Minecraft guides ➜ minecraft.mgn.gg
In this video i show how to build a minecraft clone in Javascript using React.js, Three.js and React Three Fiber.
EDIT: nanoid as key on every render is a bad practice, instead it should be applied to each cube on creation in the store, see repo for final implementation 😀👇
Finished Code: https://github.com/danba340/minecraft-react
Starting point for video: https://github.com/danba340/minecraft-react/tree/dev
Play: https://minecraft-js.vercel.app
React three fiber video mentioned in the intro: https://www.youtube.com/watch?v=FGG0EeMNUl0
The game supports five Minecraft block types: Dirt, Grass, Wood, Log and Glass.
You can move around using the mouse and WASD, You can click and Alt+click to add and remove blocks. The tutorial includes many React concepts such as useState, useEffect, useRef and custom Hooks for State management and Keyboard input. Zustand is used for the state management.
Say hi on twitter: https://twitter.com/barelydaniel
Timestamps:
Intro
Starting point
State setup
Cube component
Texturising the Cube
Keyboard input Hook
Moving the player
Looking around
Cube hover state
Rendering Cubes from State
Making glass transparent
Adding/Removing Cubes
Saving the World
Jumping
Adding IDs to Cubes
Lets Minecraft
Outro
source





