Skip to content

yunzinan/3x3-Rubik-s-Cube-Simulator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

3x3-Rubik-s-Cube-Simulator

Ask DeepWiki

Web App Demo

A 3×3 Rubik's Cube simulator implemented in Modern C++, supporting both Desktop and Web applications.

Prerequisites

  • CMake ≥ 3.20
  • C++17 compiler (GCC 9+, Clang 10+, MSVC 2019+)
  • SDL2 and SDL2_mixer (Desktop App only; optional for sound)
  • Emscripten SDK (Web App only)

Other dependencies (Corrade, Magnum, Dear ImGui, spdlog, nlohmann/json) are fetched via CMake FetchContent.

Install SDL2 (Desktop):

  • macOS: brew install sdl2 sdl2_mixer
  • Ubuntu/Debian: sudo apt install libsdl2-dev libsdl2-mixer-dev
  • Windows: SDL or vcpkg install sdl2 sdl2-mixer

Install Emscripten (Web):

git clone https://github.com/emscripten-core/emsdk.git && cd emsdk
./emsdk install latest && ./emsdk activate latest
source ./emsdk_env.sh  # Run before each Web build session

Build

Desktop App Web App
Directory build/ build-web/
Configure cmake .. emcmake cmake -DBUILD_DESKTOP_APP=OFF -DBUILD_WEB_APP=ON ..
Build cmake --build . cmake --build .

Desktop App

mkdir build && cd build
cmake ..
cmake --build .

Web App

source ~/emsdk/emsdk_env.sh   # Activate Emscripten
mkdir build-web && cd build-web
emcmake cmake -DBUILD_DESKTOP_APP=OFF -DBUILD_WEB_APP=ON ..
cmake --build .

CMake options: -DBUILD_DESKTOP_APP=ON/OFF, -DBUILD_WEB_APP=ON/OFF, -DBUILD_TESTS=ON/OFF


Run

Desktop App Web App
Command ./RubiksCube or ./src/RubiksCube cd build-web/bin && emrun --no_browser --port 8080 .
Open http://localhost:8080/RubiksCubeWeb.html

Web output: build-web/bin/ (HTML, JS, WASM, data). WASM must be served over HTTP; Python alternative: python3 -m http.server 8080.


Features

  • Move sound: Place audio.mp3 in project root; desktop uses SDL2_mixer, web preloads it.
  • Camera: Orbit, zoom, pan (right/middle drag or Shift+left drag).
  • Input: Keyboard, mouse, file I/O — see interface-specification.md.
  • 3D visualization with move animation.

Requirements

  • Magnum — graphics engine
  • Corrade — utilities
  • SDL2 — desktop windowing/input
  • Emscripten — WebAssembly toolchain
  • Dear ImGui — UI
  • spdlog — logging
  • CMake — build system

Architecture

Module Components
Utils Math, Timer, Logger, Config, File
Core CubeState, Move, History
Render Renderer, Camera, Light, Material, Mesh, Texture (Magnum scene graph)
App DesktopApp (SDL2), WebApp (WASM), UI (ImGui)

About

Coursework of Computer Aided Geometry Modeling, THU '26 Spring | 3x3 Rubik's Cube Simulator

Resources

License

Stars

Watchers

Forks

Contributors