How shiarauzo/rubik-cube-3d works
Rubik 3D is a browser cube simulator with mouse/keyboard and webcam hand-gesture controls. Users manipulate the rendered cube or trigger turns, scrambles, and solving; each turn animates the 3D cubies and then updates the logical cube state. AR adds camera tracking, gesture interpretation, overlays, and an automatic solve path. The graph follows documented and indexed relationships; unsampled modules are included where README capabilities warrant them, but uncertain wiring is omitted.
Main entry points: App.ts App shell · TwoHandController.ts Gesture coordinator · MoveEngine.ts Move animation · Hud.ts HUD
Components 25
Cube gameplay
- Logical cube
src/cube/CubeModel.ts - 3D cubies
src/cube/CubeView.ts - Move animation
src/cube/MoveEngine.ts - Move notation
src/cube/Notation.ts - Scramble generator
src/cube/Scrambler.ts
Hand controls
- Webcam access
src/cv/Webcam.ts - Camera permission UI
src/cv/CameraPermissionModal.ts - Hand tracker
src/cv/HandTracker.ts - Gesture classifier
src/cv/gestures/GestureClassifier.ts - Gesture coordinator
src/cv/gestures/TwoHandController.ts - Hand rotation
src/cv/gestures/HandRotation.ts - Face control
src/cv/gestures/FaceControl.ts - Hand overlay
src/cv/HandOverlay.ts - Mode indicator
src/cv/ModeIndicator.ts
Rendering and HUD
- WebGL renderer
src/render/Renderer.ts - 3D scene
src/render/Scene.ts - Orbit controls
src/render/OrbitCam.ts - HUD
src/hud/Hud.ts - Timer
src/hud/Timer.ts - Move counter
src/hud/MoveCounter.ts
Solver
- Solver proxy
src/solver/Solver.ts - Solver worker
src/solver/solver.worker.ts
Other components
- Player
Connections 42
- Player → App shell: operates
README.md - App shell → WebGL renderer: creates
src/app/App.ts - App shell → 3D scene: creates
src/app/App.ts - App shell → Orbit controls: creates
src/app/App.ts - App shell → 3D cubies: creates
src/app/App.ts - App shell → Logical cube: creates
src/app/App.ts - App shell → Move animation: creates
src/app/App.ts - App shell → HUD: creates
src/app/App.ts - App shell → Webcam access: starts
src/app/App.ts - App shell → Hand tracker: initializes
src/app/App.ts - App shell → Gesture coordinator: processes frames
src/app/App.ts - App shell → Hand overlay: creates
src/app/App.ts - App shell → Mode indicator: creates
src/app/App.ts - App shell → Camera permission UI: creates
src/app/App.ts - App shell → Scramble generator: generates scramble
src/app/App.ts - Scramble generator → Move animation: queues moves
- Move animation → 3D cubies: animates cubies
src/cube/MoveEngine.ts - Move animation → Logical cube: applies move
src/cube/MoveEngine.ts - Move animation → Event bus: emits move events
src/cube/MoveEngine.ts - 3D cubies → Logical cube: maps facelets
src/cube/CubeView.ts - App shell → Event bus: publishes state
src/app/App.ts - HUD → Event bus: observes events
src/hud/Hud.ts - HUD → Timer: uses
src/hud/Hud.ts - HUD → Move counter: uses
src/hud/Hud.ts - Player → HUD: selects actions
- Hand tracker → Gesture classifier: provides landmarks
- Gesture classifier → Gesture coordinator: classifies gestures
- Gesture coordinator → Hand rotation: delegates rotation
src/cv/gestures/TwoHandController.ts - Gesture coordinator → Face control: delegates face control
src/cv/gestures/TwoHandController.ts - Face control → 3D cubies: highlights layer
src/cv/gestures/FaceControl.ts - Face control → Move animation: queues turns
src/cv/gestures/FaceControl.ts - Hand rotation → 3D cubies: rotates view
src/cv/gestures/HandRotation.ts - Gesture coordinator → Logical cube: reads facelets
src/cv/gestures/TwoHandController.ts - Gesture coordinator → Solver proxy: requests solution
src/cv/gestures/TwoHandController.ts - Gesture coordinator → Move animation: queues solution
src/cv/gestures/TwoHandController.ts - Solver proxy → Solver worker: dispatches solve
src/solver/Solver.ts - Solver worker → Solver proxy: returns moves
- App shell → Solver proxy: requests solution
src/app/App.ts - Player → Webcam access: grants access
- Webcam access → Hand tracker: camera frames
- Hand tracker → Hand overlay: draws landmarks
- Gesture coordinator → Mode indicator: sets mode feedback
src/cv/ModeIndicator.ts