CPSC 424 Computer Graphics Fall 2025

CPSC 424 Lab 8: three.js Modeling

Due: Tue 11/4 at the start of lab

three.js provides a high-level scene graph for designing WebGL scenes. This is the first of two labs using three.js. It covers the core elements: cameras, lights, mesh objects using the standard geometries, modeling transforms, and materials (including image textures). The next lab will cover additional ways of building mesh objects, reflection, refraction, shadows, and custom shaders.

Successful completion of this lab means that you can use three.js to:

Collaboration and Use of AI

This is an individual lab. You may get technical help from others, but the effort and ideas that go into producing solutions should be yours.

You may use AI as outlined in the Use of AI policy — Copilot's inline coding suggestions, explain, fix, review and comment features but not code generation from English prompts. Also:

Handin

Hand in your work by copying your ~/cs424/lab8 folder into your handin folder (/classes/cs424/handin/username, where username is your username).

Check that the result is that your files are contained in /classes/cs424/handin/username/lab8 — if not, fix it!


Preliminaries

Setup

Make sure that all of the directories are named exactly as specified and end up at the same (top) level in your workspace directory. This is important so that the relative path names used to access common files remain the same so your program doesn't break when you hand it in.

Provided Code and Files

lab8.html is a template for a three.js program.

Reference

Your best reference sources are the slides from class (which pull out and organize the key points), the examples from class (which put all the pieces together), and the textbook. Chapter 5 covers three.js.


Exercises

Use the provided lab8.html as the starting point for this lab. This file sets up the structure for a three.js program with a trackball rotator (so the mouse can spin the camera around) as discussed in class. Note that running the program will result in a blank page and an error message in the console until a scene and camera have been created. (After that you should at least see a dark gray canvas.)

Requirements:

For extra credit, make an especially elaborate scene and/or animate your scene. (Particularly nice would be to animate something with a light, such as a car driving around with its headlights on.) See the two examples in section 5.1.6 in the textbook for how you can add animation. (Note that you don't need to add the "animate" checkbox to the webpage, though you can if you want.)