Skip to content

About

Scan a Rubik's cube with your webcam and get the solution, step by step on an animated 3D cube. Rust + gpui-kit.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Cube Solver icon

Cube Solver

Scan a Rubik's cube with your webcam and get the solution as notation or as guided, step-by-step turns.

This is a Rust app built with gpui-kit. Solving uses the two-phase algorithm from the min2phase crate.

Solve screen in Notation mode, with the animated 3D cube

Install

Download the file for your system from the Releases page of this repository.

OS Artifact Steps
macOS 11+ (universal) CubeSolver-<version>-macos-universal.dmg Open the DMG and drag "Cube Solver" to Applications.
Windows (x64) CubeSolver-<version>-windows-x64.zip Unzip and run cube-solver.exe.
Linux (x64) CubeSolver-<version>-linux-x64.tar.gz Extract and run ./cube-solver.

macOS first open

The app is ad-hoc signed and not notarized, so Gatekeeper asks on first launch:

  • Right-click "Cube Solver" in Applications and choose Open, or
  • open System Settings > Privacy & Security and click "Open Anyway".

Allow camera access when asked.

Windows

SmartScreen may warn about an unrecognized app. Click More info, then Run anyway.

Linux

You need a Wayland or X11 session with a Vulkan-capable driver and a V4L2 webcam. Your user may need to be in the video group to open the camera.

Use

The title bar has a camera selector, a language button (EN/ES) and a light/dark theme toggle. Change the camera there if the default is not the one you want.

1. Scan the six faces

The app shows which face to present at each step. Hold the cube so the face fills the grid on the preview, then capture.

Step Face center facing the camera Center on top
1 Yellow Blue
2 Green Yellow
3 Orange Yellow
4 Blue Yellow
5 Red Yellow
6 White Red
  • Capture with the Capture button or Space.
  • Undo removes the last captured face. Restart discards all captured faces.
  • Tips: use even, bright light; avoid glare on the stickers; fill the grid with the face; hold the cube steady while capturing.

2. Get the solution

After the sixth face the app solves the cube automatically. The result screen shows what the app read ("What we read") and the number of moves.

Hold the cube with the orange center facing you and the yellow center on top, then follow either mode:

Mode How it works
Notation The full move sequence. Copy puts it on the clipboard.
Step by step One turn at a time. Use Previous / Next, the Left/Right arrow keys, or Space for next.

Below the solution, a 3D cube shows the state at the current step:

  • Drag the cube to rotate it.
  • Click a move in Notation to play it. Clicking a move further ahead or behind fast-forwards or rewinds to it at double speed.
  • Play runs the remaining steps one by one; Pause stops after the turn in progress.
  • The slider sets the animation speed, from 0.5x to 3x.

Step by step mode playing the solution on the 3D cube

Click Scan again to start over.

Reading the notation

Letter Face (center color)
U Up (yellow)
D Down (white)
F Front (orange)
B Back (red)
L Left (green)
R Right (blue)
  • No suffix: turn the face 90 degrees clockwise, as seen looking straight at that face.
  • ': 90 degrees counter-clockwise.
  • 2: 180 degrees.

More on the notation: https://jperm.net/3x3/moves.

Troubleshooting

Problem What to do
"Camera unavailable" Grant camera permission (macOS: System Settings > Privacy & Security > Camera; Windows: Settings > Privacy & security > Camera; Linux: check the video group), or pick another camera in the title bar.
"Invalid scan" ("We couldn't read a valid cube") Compare the colors under "What we read" with your cube. Improve the lighting, avoid reflections, and click Scan again.
Camera permission goes to Terminal on macOS When started from a terminal, the camera permission is attributed to that terminal app. Launch the bundled app instead, or allow the terminal app in Privacy & Security > Camera.

Build from source

Requirements:

  • Rust stable.
  • macOS: Xcode (provides the Metal shader compiler).
  • Linux: clang libclang-dev libfontconfig-dev libwayland-dev libxkbcommon-x11-dev libx11-xcb-dev libssl-dev libzstd-dev libasound2-dev libvulkan1 (for example sudo apt-get install -y ... on Debian/Ubuntu).
  • Windows: the MSVC toolchain.
cargo run --release
cargo test
cargo clippy --all-targets -- -D warnings
cargo fmt --check

Build a local macOS bundle and DMG from a release binary:

scripts/bundle-macos.sh target/release/cube-solver <version> dist

Project structure

Source is layered, with dependencies pointing inward.

Path Role
src/domain Pure rules: color math, sticker classification, cube model and scan order, moves.
src/application Use cases, ports and session state: scan session, solve use case, camera state.
src/infrastructure Adapters: camera, frame conversion, min2phase solver.
src/ui gpui-kit views: app shell, scan and result screens, i18n strings, theme.
src/main.rs Composition root that wires the layers together.

Unit tests live next to the code they cover. tests/pipeline.rs is the end-to-end test.

Releasing

  1. Bump version in Cargo.toml and commit.
  2. Tag the commit vX.Y.Z; the tag must match the Cargo.toml version, or the Release workflow fails.
  3. Push the tag.

The Release workflow builds the macOS, Windows and Linux artifacts and publishes the GitHub release. CI (format, clippy, test on all three OSes) runs on pushes to main and on pull requests.

License

MIT. See LICENSE.

About

Scan a Rubik's cube with your webcam and get the solution, step by step on an animated 3D cube. Rust + gpui-kit.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages