README.md
31 lines · 1.0 KB
Rubik's Cube 3D
A 3D Rubik's Cube game built with TypeScript, Vite, and Three.js.
Run
npm install
npm run dev # dev server at http://localhost:5173
npm run build # type-check + production build to dist/
How to play
- Drag a sticker to turn its layer (middle layers work too).
- Drag the background to orbit the camera; scroll to zoom.
- Keyboard:
U D L R F Bturn faces clockwise; holdShiftfor counter-clockwise (standard cube notation). - Scramble starts a timed game with a move counter; solve the cube to stop the clock.
- Reset returns the cube to the solved state.
Code layout
| File | Role |
|---|---|
src/cube.ts | Builds the 26 cubie meshes with sticker materials |
src/rubiks.ts | Move queue, animated 90Β° layer turns, scramble, solved detection |
src/dragControls.ts | Raycast-based drag-to-turn pointer input |
src/scene.ts | Renderer, camera, lights, resize handling |
src/main.ts | Game state (idle / scrambling / playing), HUD, keyboard input |