Step 8. Paint the cube

The cube is "painted" with a solid color. It would be nice to paint it with a JPEG or PNG image.

Insert the following code at the top of the program:

var img;

function preload() 
   img = loadImage ( '/uploads/starter/earth.1.jpg' );

Put the following code inside the "draw" function. Remove the line that makes the cube a solid color, and insert this line instead:


You will now get something like the following:

Tweet this step: