Lesson goal: 3d graphics the depth

Previous: Introduction to 3D graphics | Home | Next: 3D graphics and the camera

In the last lesson you saw how to draw spheres using three dimemsional coordinates. In this lesson, we wanted to be sure you understand the z-coordinate, and how it give you the added element of "depth" in your graphics.

Let's again use scene3d() and sphere() to draw, but let's move a single sphere up and down along the z-axis.

Try these two tests:

Test #1: Start by drawing a sphere at (0,0,80) with a radius of 5. Then change the 80 to -80, as in (0,0,-80). What do you notice?

Test #2: Try drawing two spheres, like this:
  1. Draw a sphere at (0,0,50) with a radius of 10 in a red color (ff0000).
  2. Keeping the code in place for that sphere, draw another sphere at (10,0,30) with a radius of 10, in a green color (00ff00).
What do you see? Do you see the "depth" that 3D graphics offers?

Now you try. Try running through these two tests, so you can see the depth and perspective given by 3d graphics.

Type your code here:


See your results here: