This is a 3D surfaced Rubik's cube--the FIRST EVER fully 3D realtime shaded object on Scratch.
It only works in the flash player, so make sure you use that for online viewing. I would highly suggest that you DOWNLOAD IT, because the blue and green faces don't render properly when you run it online. Plus, it's fun to download, run in fullscreen, and move around the mouse wildly while watching it trying to render all kinds of cube-like shapes xD
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 several complex 3D projection formulas to find the x and y coordinates of the vertices to make the cube wireframe appear 3-dimensional. It then connects these in order with the pen tool, creating a 3D wireframe, and draws the additional lines making it a Rubik's cube. To shade the sides, it must first know which sides are visible and which are hidden. It uses a complex rotational identification algorithm to find which sides are visible to the viewer based on the rotation and tilt of the cube. It then stores these in a list.
Finally, the 6 shading sprites identify which sides are supposed to be shaded and shade them using a parallelogram shading algorithm. The technique used to shade is a brute-force method, which speeds up the rendering speed indefinitely. How it works is that instead of using loop blocks such as forever, repeat until, or repeat (x), each repetition is programmed out into a huge script. This way, it runs the whole script instantly, instead of running all 51 repetitions at the rate of 40x per second. This makes the cube render theoretically in 1/40th of a second rather than 1.275 seconds. COME AT ME BRO
I used some scripts from my project "3D Object Wireframe."
This is the first of its kind on Scratch, and only took about 2 hours to make.
Thanks for watching and please leave a comment or press love it if you love it!