ScratchData LogoScratchData
Back to wwjd3's profile

Realtime Surfaced 3D Cube

WWwwjd3•Created August 11, 2011
Realtime Surfaced 3D Cube
793
609
72729 views
View on Scratch

Description

This is a 3D surfaced Rubik's cube--among the first ever fully 3D realtime shaded objects on Scratch. How to use it: -Click the mouse to rotate the cube. -It will constantly render in realtime as a 3D surfaced cube. How it works: It uses 3D projection formulas to find x and y coordinates for a 3-dimensional wireframe of the cube. It then connects these vertices with the pen tool and adds the lines in between that make it a Rubik's cube. To shade the sides, it must first know which sides are visible and which are hidden. The visible sides are worked out based on the rotation and tilt of the cube and stored in a list. Then, 6 shading sprites fill in the visible sides with a parallelogram shading algorithm. They use a brute-force method that can be called "loop unrolling". Instead of shading with many pen strokes in a loop block (such as forever, repeat until, etc), each pen stroke is explicitly programmed out in one giant long script. The whole "unrolled loop" then runs instantly, instead of with a minor delay between each pen stroke. This reduces the render time of the cube dramatically, from ~1.25 sec to (at best) 1/40th of a second--fast enough to render in realtime. I used some scripts from my project "3D Object Wireframe." Thanks for watching and please leave a comment or press love it if you love it!

Project Details

Project ID1973319
CreatedAugust 11, 2011
Last ModifiedOctober 18, 2019
SharedAugust 11, 2011
Visibilityvisible
CommentsAllowed

Remix Information

Parent ProjectView Parent
Root ProjectView Root