Code directory README
common/
- shared ES modules (MV.mjs, initShaders*.mjs, …)
- the most recent version of the threeJS code that is compatible with textbook examples in Chapter 9: three-r124.min.js
experimental
- programs written with help from claude.ai
experimental/built/
experimental/standalone/
textbook-classic/
- textbook code as published on interactivecomputergraphics.com with minimal changes: classic-style scripts, no build
- subdirectories 02, 03, .., 11 correspond to the chapters with code examples
- run from the in the chosen directory (source can be viewed through your browser, all files used will be linked to the and can be followed from there)
Module index
common/
| File |
Description |
globals.mjs |
Bridge for the unmodified textbook code: exposes the modern helpers as the globals the old scripts expect. |
initShadersHTML.mjs |
Provides functions to initialize a simple two file shader from HTML script tags Alex Clarke 2026: |
initShadersJS.mjs |
Provides functions to initialize a simple two file shader from JavaScript strings Alex Clarke 2026: |
initShadersXHR.mjs |
Provides functions to initialize a simple two file shader from external GLSL files loaded with an HTTP Request. |
MV.mjs |
(no header comment) |
uofrGraphics.mjs |
(no header comment) |
vertices.mjs |
Control vertices of the patches forming the Utah teapot |
experimental/built/bump-map-explorer/
Source for bump-map-explorer (read-only copies): browse all files · download .zip
experimental/built/chaos-dragon/
Source for chaos-dragon (read-only copies): browse all files · download .zip
| File |
Description |
chaosgame.mjs |
DOM-free renderer for a two-map chaos game. |
ifs.mjs |
the mathematics of the chaos game. |
main.mjs |
the controller. |
experimental/built/chaos-dragon/test/
| File |
Description |
smoke.mjs |
node test/smoke.mjs (needs: npm install jsdom) Runs the REAL main.mjs against app.html in jsdom, with: * the REAL ../common/initShadersJS.mjs (so run i… |
verify.mjs |
node test/verify.mjs Maths checks plus a ChaosGame run against a recording mock of WebGL2. |
experimental/built/colour-cube/
Source for colour-cube (read-only copies): browse all files · download .zip
| File |
Description |
cube.mjs |
A DOM-free renderer for a unit colour cube. |
main.mjs |
Controller: owns the canvas and GL context, loads the shader files, drives the render loop, and tracks the current viewing mode. |
matrix.mjs |
A tiny, dependency-free set of 4x4 matrix helpers. |
experimental/built/diffusion-cube/
Source for diffusion-cube (read-only copies): browse all files · download .zip
| File |
Description |
gl-utils.mjs |
Small WebGL2 helpers. |
main.mjs |
Controller: the only module that touches the DOM. |
math.mjs |
Minimal column-major mat4 helpers (same layout WebGL expects). |
scene.mjs |
Cube + sphere meshes that sample the simulation’s trail texture. |
sim.mjs |
GPU particle diffusion with ping-pong textures. |
experimental/built/diffusion-explorer/
Source for diffusion-explorer (read-only copies): browse all files · download .zip
| File |
Description |
examples.mjs |
The diffusion explorer’s menu, and how a side-by-side comparison splits the settings between its two simulations. |
honolulu256.mjs |
Honolulu elevation data from the textbook’s honolulu256.js, as an ES module. |
main.mjs |
(no header comment) |
seeds.mjs |
Starting images for the diffusion explorer, a CPU reference for every update rule in shaders/step.frag, and the measurements the page reports. |
experimental/built/gouraud-v-phong/
Source for gouraud-v-phong (read-only copies): browse all files · download .zip
| File |
Description |
main.mjs |
(no header comment) |
experimental/built/indexed-square/
Source for indexed-square (read-only copies): browse all files · download .zip
| File |
Description |
main.mjs |
(no header comment) |
experimental/built/light-view-explorer/
Source for light-view-explorer (read-only copies): browse all files · download .zip
| File |
Description |
examples.mjs |
The light-view explorer’s menu and comparisons. |
lightMath.mjs |
The light-view explorer’s pure logic: the scene of shadowMap.js (a cube, a triangle) plus a floor, the light’s and the projector’s matrices, the slide of pro… |
main.mjs |
(no header comment) |
experimental/built/model-view-projection/
Source for model-view-projection (read-only copies): browse all files · download .zip
| File |
Description |
geometry.mjs |
DOM-free mesh builders. |
main.mjs |
Controller: owns the DOM, the five WebGL2 contexts and the frame loop. |
matrixUtil.mjs |
Small helpers that sit beside Common/MV.mjs. |
pipeline.mjs |
Composes M, V and P from the interface state, using the student’s functions. |
renderer.mjs |
DOM-free renderer for one WebGL2 context. |
state.mjs |
All interface state lives in one plain object. |
student.mjs |
STUDENT FILE: this is the only file you need to edit. |
ui.mjs |
The interface: one table describes every control; buildPanel() makes the DOM from it and syncControls() keeps it in step with the state object. |
views.mjs |
What each canvas shows. |
experimental/built/picking-explorer/
Source for picking-explorer (read-only copies): browse all files · download .zip
| File |
Description |
examples.mjs |
The picking explorer’s menu. |
main.mjs |
(no header comment) |
pickMath.mjs |
The picking explorer’s pure logic: the scenes, the cube mesh with a face index per vertex, ID encodings, a CPU ray cast to check the GPU against, the pick ma… |
experimental/built/reflection-explorer/
Source for reflection-explorer (read-only copies): browse all files · download .zip
| File |
Description |
environments.mjs |
Procedural cube-map environments, and the cube-map face conventions they depend on. |
examples.mjs |
The explorer’s menu. |
main.mjs |
(no header comment) |
meshes.mjs |
Mesh generators: non-indexed triangles, positions and unit normals as vec3. |
reflectMath.mjs |
The explorer’s pure logic: matrices, orbiting objects, and which settings each half of a split view uses. |
experimental/built/shader-stages/
Source for shader-stages (read-only copies): browse all files · download .zip
experimental/built/shading-comparisons/
Source for shading-comparisons (read-only copies): browse all files · download .zip
experimental/built/shading-comparisons/lib/
| File |
Description |
common.mjs |
Single adapter to the shared common/ modules. |
CompareApp.mjs |
Two-canvas comparison harness. |
costModel.mjs |
Informal cost model: count the expensive operations in each shader stage by reading the shader source itself, weight them, and multiply by how many times the… |
frameMath.mjs |
Per-frame maths for the two scenes (sphere, cube). |
LitMeshPane.mjs |
One canvas + one WebGL2 context + one lit-mesh program. |
meshes.mjs |
Mesh generators (typed arrays, non-indexed triangles). |
scenes.mjs |
A scene bundles everything that differs between the sphere demos and the cube demo: default state, controls, animation, mesh and per-frame uniforms. |
shaderSources.mjs |
Loads the shader files with fetch(), so the pages work from any web server (a plain static host, Vite dev, or a Vite build). |
experimental/built/svg-zoomer/
Source for svg-zoomer (read-only copies): browse all files · download .zip
| File |
Description |
main.mjs |
Controller for the vector-vs-raster zoom demo. |
zoomer.mjs |
A DOM-free renderer that draws one texture across a full-canvas quad and can magnify it toward a focus point. |