Page 1: Recap: Appearance by Shading and Texturing
Spring 2026 Sample Solution
So far, we’ve been using three.js to do 3D graphics programming.
This includes:
- Using transformations for the camera and objects to place objects in the world and figure out where they appear on the screen.
- Using collections of triangles (meshes) to create shapes.
- Using lights and materials to create surfaces that respond to lighting.
- Using texture maps to alter the appearance of objects, to make detailed colors, small geometric effects (bump maps), and some other effects.
- Using environment maps (a kind of texture) to create backgrounds and reflections.
Three took care of implementing all of this on top of the low-level API.
Low-Level APIs and Three.js
Up until now, we used the “legacy mode” of three.js which is built on top of the WebGL low-level API. However, most web browsers support the more modern WebGPU API. And three.js is moving in that direction. So we should move that way too.
First, we should test that WebGPU works:
If WebGPU does not work, you may want to update your web browser. For class, we will do everything with three.js which should be able to work around not having WebGPU.
We will need to use WebGL when we do GLSL programming later in the workbook. Otherwise, prefer to use the WebGPU backend (with WebGL fallback) when using three.js. This has become the default for workbooks (but we just switched for this workbook).
The class software framework has an option to switch. When you create the GrWorld object, you can specify webgpu:true (which is the default), or webgpu:false to force it to use WebGL. In the process of implementing this, we had to make another change: the constructor needs to be an async function (to create a WebGPU renderer); therefore, we cannot use the “standard” JavaScript constructor. Instead, we use a class function as the constructor:
1let world = await GrWorld.new({ webgpu: false });We’ll come back to this when we do shader programming.
What does this have to do with the hardware?
In working with three, we use a very specific set of abstractions:
- Transformations
- Triangles, with information tied to vertices
- Lights and materials that use a local lighting model
- Textures as the preferred way to create detail
- Environment maps as the way to get reflections and backgrounds
These choices are dictated to us because of the way that graphics hardware works. It was designed to support this set of abstractions very well.
Next: Page 2 - Practice: Cars