oneshotlm
Compare all models on this prompt →

Rubik's Cube · gpt-5-mini

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 · 4 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
**Implementing orbit camera controls**

I’m thinking about how to implement orbit camera controls. We could either create simple orbit controls ourselves or see if THREE.OrbitControls would work since we only have three.min.js but not the OrbitControls file.

I’ll need to implement mouse drag for orbits, track spherical coordinates, and use the wheel for zooming. Oh, right-click might be involved, too. For clicks, I'll distinguish between face rotation and dragging based on movement, using pointer events. 

Also, there's the scramble button to animate moves and face stickers for the small cubes.**Designing cube geometry and materials**

I’m planning to use BoxGeometry and create a material array. For the interior faces, I’ll use black, while the exterior faces might have colored stickers. Maybe I could add a black background to the edges with a colored square on top?

A simpler option is to create a cube with six materials, using MeshStandardMaterial for the outward-facing faces. I think I'll render outer faces with colored materials and dark gray for the inner ones, adding a thin sticker plane to enhance the appearance.

For rotation, I'll determine the rotation axis using face normals. Transforming the normal to world direction from the camera could simplify this.**Enhancing raycasting approach**

I’m thinking about a better approach for handling raycasting. When we get the face index and object, I can extract the face normal from the object's geometry. Then I can convert it to world space using the object's world matrix.

Next, I need to find the closest axis: x, y, or z. I’d calculate the layer coordinate by rounding the cubie position along that axis. This allows me to group cubies with similar positions into a temporary THREE.Object3D. I should ensure that the center for rotating animations is at zero on other coordinates, which simplifies the process for standard cubes. If the group requires a pivot at the center of a layer, I’ll adjust the pivot accordingly.**Refining cube rotation logic**

I’m considering how to group cubies under a parent while managing rotation effectively. I can set the group's position to the world origin and rotate around the axis through that point. However, for a layer at x=1, the pivot should match the layer position rather than the origin to achieve proper center rotation.

A simpler way could be to set the group's position to (layerCoord, 0, 0), effectively offsetting it. I should convert each cubie's world position to local space using group.worldToLocal and adjust their positions accordingly before adding them to the group.**Implementing cube rotation mechanics**

To implement cube rotation, I’ll create a pivot object at the layer's position and add selected cubies to it, allowing for easy rotation. After rotating the pivot, I’ll reattach the cubies to the main cube, adjusting their positions accordingly.

I’ll ensure to maintain their world transforms during this process. For rotation, I aim to choose the appropriate axis and direction, rotating them around that axis with a smooth animation. I'll also integrate raycasting for interaction and ensure that stickers on the cubies rotate with them. Finally, I’ll setup orbit controls around the origin for better camera management.**Choosing layer coordinates and cubie positions**

To determine the layer coordinate, I’ll use the cubie's position in cubeRoot coordinates, which can be accessed with mesh.position since there are no transformations on cubeRoot. The layer coordinate will be calculated by rounding the position along the chosen axis divided by spacing, which I’m setting to about 1.1 for positioning.

Instead of rounding, I think storing coordinate indices in userData when creating cubies might help maintain their positions accurately. After rotation, I’ll round the coordinates to update the userData indices. I’ll also create a move queue for preventing overlapping rotations and implement a scramble button. Time to produce the index.html write call!
write index.html (12583 bytes)
toolResult

Successfully wrote 12583 bytes to index.html

assistant

I created index.html in the current directory. It loads the provided three.min.js and renders an interactive 3D Rubik's Cube with: - Orbit-drag camera (drag to orbit, wheel to zoom) - Click a face to rotate that layer 90° clockwise; Shift+click to rotate counterclockwise - Scramble button to apply a sequence of random moves - Visual stickers with standard colors and smooth rotation animations Open index.html in a browser (served or via file://) to use it. If you want additional features (undo, move notation display, keyboard controls, better snapping, or improved lighting/shading), tell me which and I'll add them.

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

modelgpt-5-mini
vendorOpenAI
harnesspi-agent
generated2026-07-22

EVALUATION

2/5 working

Dark, low-contrast Rubik's Cube; drag orbits and wheel zooms extremely close, but colors/lighting are barely 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.1%
on drag3.4%
on wheel18.6%
on enter + space0.0%
on arrow keys0.0%
on w/a/s/d0.0%
frame spread8.9 / 255
console errors0
js errors none

METRICS

runtime90.5s
tokens in4.0k
tokens out6.6k
cached2.2k
cost / run$0.0144