From Test-Scratch-Wiki
![]() |
This article or section may not have content matching Scratch Wiki editing standards. Please improve it according to Scratch Wiki:Guidelines. Reason: Uses way too much first person |
![]() |
Please expand this article or section. You can help by adding more information if you are an editor. More information might be found in a section of the talk page. |
How Does 3D Work In Scratch?
Scratch is mostly intended for 2d projects, but it is possible to create a 3d effect with scratch. You can do this by projecting a point that uses the dimensions x, y, and z to find its position.
Making The Main Script
First of all, we will need to make some custom blocks. Here they are:
define Reset define Draw
Afterwards, make this script,
when green flag clicked set pen color to (pick random (1) to (100)) Reset :: custom forever clear Draw :: custom change [delta v] by (1) end
The script above is the loop that will start everything up in the project.
Getting the Variables Ready
Next you will need to get the variables ready. With the Reset :: custom
custom block make this script:
define Reset set [angle v] to [0] set [A v] to [220] set [B v] to [160] set [r1 v] to (pick random (1) to (100)) set [r2 v] to (pick random (1) to (100)) set [delta v] to (pick random (1) to (90))a go to x: ((A) * ([sin v] of (((angle) * (r1)) + (delta)))) y: ((B) * ([cos v] of (((angle) * (r2)) + (delta))) pen down set pen size to (50)
The Reset block will also make a pattern, so it will be useful.
![]() | For easier access, make the r1 and r2 variables sliders. |
Creating the Draw Script
The following script will be very complicated since it will use a lot of math. The reason for that is because the script also shades what it'll draw.
Next, we will need to make a very complicated script. We will use the Draw :: custom
custom block to make it.
define Draw show clear pen down repeat (360) go to x: ((A) * ([sin v] of (((angle) * (r1)) + (delta)))) y: ((B) * ([cos v] of ((angle) * (r2)) set pen size to ([abs v] of ((((1000) - ((A) * ([sin v] of (((angle) * (r1)) + (delta))))) - ((B) * ([cos v] of ((angle) * (r2))))) / (150))) set pen shade to ((-0.5) * (((A) * ([sin v] of (((angle) * (r1)) + (delta)))) - ((B) * ([cos v] of ((angle) * (r2)))) change [angle v] by (1) move (10) steps