oneshotlm
Compare all models on this prompt →

Rubik's Cube · qwen3.7-flash

Using the pre-provided three.min.js (global THREE), render an interactive 3D Rubik's Cube with clickable face rotations, orbit-drag camera, and a scramble button.

⛨ sandboxed Open in new tab ↗
transcript · 18 messages
user

Using the pre-provided three.min.js (global THREE), render an interactive 3D Rubik's Cube with clickable face rotations, orbit-drag camera, and a scramble button.

assistant
thinking
The user wants me to build a 3D Rubik's Cube using three.min.js (already present in the directory) in a single index.html file. Let me first check what's available, then build it.

Key features needed:
1. Interactive 3D Rubik's Cube with proper colors
2. Clickable face rotations (click on faces to rotate them)
3. Orbit-drag camera (orbit controls - I'll need to implement this manually since we can only use three.min.js)
4. Scramble button
5. All self-contained in one HTML file

Let me first verify three.min.js exists.
bash {"command":"ls /tmp/ws/three.min.js"}
toolResult

/tmp/ws/three.min.js

assistant
thinking
Good, it exists. Now let me build the full Rubik's Cube app. I'll implement orbit controls manually (no OrbitControls addon), use raycasting for face clicks, and build a proper 3x3 cube with standard colors.
write /tmp/ws/index.html (14588 bytes)
toolResult

Successfully wrote 14588 bytes to /tmp/ws/index.html

assistant
thinking
Let me review the code and fix a few things. The orbit controls need to track currentRadius properly, and I should make sure the click-to-rotate logic works well. Let me also simplify and clean up some of the code for better reliability.

Now let me refine the implementation with more robust click detection and cleaner controls:

write /tmp/ws/index.html (13940 bytes)
toolResult

Successfully wrote 13940 bytes to /tmp/ws/index.html

assistant
thinking
Let me verify the file is there and looks correct.
bash {"command":"ls -la /tmp/ws/index.html && wc -l /tmp/ws/index.html"}
toolResult

-rw-r--r--. 1 node node 14080 Aug 1 17:57 /tmp/ws/index.html 395 /tmp/ws/index.html

assistant
thinking
The file is created. Let me also verify that three.min.js is still present and check for any obvious issues in the code by reading a quick portion of it.
bash {"command":"ls -la /tmp/ws/three.min.js /tmp/ws/index.html"}
toolResult

-rw-r--r--. 1 node node 14080 Aug 1 17:57 /tmp/ws/index.html -rw-r--r--. 1 node node 603445 Aug 1 17:56 /tmp/ws/three.min.js

assistant
thinking
Both files are present. Let me do a final review of the code to make sure there aren't any issues, particularly around the click-to-rotate direction mapping and the reset logic (disposal might cause issues if geometries are shared).

Let me clean up one small issue — `BoxGeometry` is shared across cubies so disposing it once would break others:

edit {"path":"/tmp/ws/index.html","edits":[{"oldText":" document.getElementById('resetBtn').addEventListener('click', () => {\n if (animating
toolResult

Successfully replaced 1 block(s) in /tmp/ws/index.html.

assistant
thinking
Good. Now let me verify the final file one more time to make sure everything looks correct, then I'm done.
read {"path":"/tmp/ws/index.html","limit":30}
toolResult

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>3D Rubik's Cube</title> <style> * { margin: 0; padding: 0; box-sizing: border-box; } body { overflow: hidden; background: #16213e; font-family: 'Segoe UI', system-ui, sans-serif; } canvas { display: block; } #ui { position: absolute; top: 20px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; z-index: 10; } button { background: rgba(255,255,255,0.08); color: #ddd; border: 1px solid rgba(255,255,255,0.2); padding: 10px 26px; border-radius: 8px; font-size: 14px; cursor: pointer; backdrop-filter: blur(12px); transition: all 0.2s; user-select: none; letter-spacing: 0.5px; } button:hover { background: rgba(255,255,255,0.2); color: #fff; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(0,0,0,0.3); } button:active { transform: translateY(0); } #moves { position: absolute; top: 72px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.75); font-size: 18px; font-weight: 600; min-height: 26px; text-align: center; pointer-events: none; transition: opacity 0.4s; } #info { position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%); color: rgba(255,255,255,0.35); font-size: 12px; text-align: center; [367 more lines in file. Use offset=31 to continue.]

assistant
thinking
Good. The file looks correct. Let me verify the structure is complete by checking the end of the file.
read {"offset":370,"path":"/tmp/ws/index.html"}
toolResult

else c.material?.dispose(); } cubies.length = 0; for (let x = -1; x <= 1; x++) for (let y = -1; y <= 1; y++) for (let z = -1; z <= 1; z++) makeCubie(x, y, z); flashMove("Reset ✓"); }); // ─── RENDER LOOP ─── (function loop() { requestAnimationFrame(loop); renderer.render(scene, camera); })(); // ─── RESIZE ─── window.addEventListener('resize', () => { camera.aspect = innerWidth / innerHeight; camera.updateProjectionMatrix(); renderer.setSize(innerWidth, innerHeight); }); })(); </script> </body> </html>

assistant
thinking
The file is complete and well-structured. Let me provide a summary for the user.

Done. **`/tmp/ws/index.html`** is ready — 395 lines, fully self-contained with: | Feature | Implementation | |---|---| | **3D Rubik's Cube** | 27 cubies with official colors (Red/Orange/White/Yellow/Green/Blue) + dark inner faces + edge wireframes | | **Click-to-Rotate** | Raycasting on face clicks → detects which face was clicked and normal → picks perpendicular rotation axis → smooth ease-out cubic animation | | **Orbit Camera** | Custom pointer-drag orbit control (left-mouse drag rotates around cube center) | | **Zoom** | Scroll wheel adjusts camera distance (clamped 3.5–15 units) | | **Scramble** | Random 20-move Singmaster sequence (`R/L/U/D/F/B` with ``, `'`, `2`) played back sequentially with animation queue | | **Reset** | Rebuilds the cube from scratch to solved state | **No external dependencies** — only `three.min.js` loaded locally via `<script src>`.

TAKE IT TO CODE

A single self-contained HTML file — copy it and open in any browser, or reuse the prompt with your own pi-agent run.

RUN

modelqwen3.7-flash
vendorQwen
harnesspi-agent
generated2026-08-01

EVALUATION

3/5 partial

3D Rubik's Cube renders and orbit-drag/wheel zoom works, but drag rotated view to a top-down white-only angle, no face rotation visible.

Vision grade · anthropic/claude-sonnet-5

MEASUREMENTS

Raw readings from the capture, not a verdict — the grade above is the only judgement. Percentages are how much of the screen changed; the measure under-reports sparse motion on a dark background.

idle motion0.0%
on click0.0%
on drag27.7%
on wheel13.3%
on enter + space0.0%
on arrow keys0.0%
on w/a/s/d0.0%
frame spread104.3 / 255
console errors0
js errors none

METRICS

runtime69.7s
tokens in43k
tokens out10k
cached38k
cost / run$0.0028