Lesson goal: Draw with cubes

Previous: 3D graphics and the light source | Home | Next: Drawing lines in 3D

In a previous lesson, you did some drawing with spheres. You can also draw here with cubes (sort of like Minecraft...we guess).

Also, remember, you are coding now. You can use for-loops and such to draw lots of cubes; they don't have to be placed one at a time. See example #4.

cube(x,y,z,width,height,depth,"color")
Move the mouse over a dotted box for more information.

You can find a list of color codes here. The 3D drawing area will appear under your code-editor. You might have to scroll down to see it.

Now you try. Fill in a x,y,z and width, length, and height of your cube.

Type your code here:


See your results here:

This code will not run!

  • Fill in $(x,y,z)$ coordinates of the cube, then a width, length, and height. To start out, keep all numbers between 0 and 10 or so.

  • Also, your cube might just look like a square (as you are looking at it head-on). To see the cube, you'll have to move the camera and/or light source around a little bit.
Dismiss.
Show a friend, family member, or teacher what you've done!

Here is a share link to your code:

Does your code work? Want to run it on your iPhone?

Here's your code:

  1. Use [Control]-[C] (Windows) or [⌘]-[C] (MacOS) to copy your code.

  2. Paste it using [Control]-[V] (Windows) or [⌘]-[V] (MacOS) into this page

  3. Then click the "Use on iPhone" button that you'll see.