This course teaches you how to build powerful debug interfaces for your Three.js projects using the lil-gui library.
You will learn
A debug UI is a graphical control panel that lets you adjust parameters of your Three.js scene in real-time. Instead of repeatedly changing values in code, saving, and reloading to see the effect, a debug UI allows immediate adjustments during runtime.
Common uses include:
The course uses lil-gui
, a popular UI library included with Three.js that creates a simple control panel with various controls. It replaces the older, no-longer-supported dat.GUI library.
// Import lil-gui
import GUI from 'three/examples/jsm/libs/lil-gui.module.min.js';
// Create a new GUI instance
const gui = new GUI();
// Optional: Configure GUI width
// gui = new GUI({ width: 600 });
The fundamental pattern for adding controls is:
gui.add(object, 'propertyName', minValue, maxValue, stepValue);
Where:
object
is what you want to modify (like mesh, material, light)propertyName
is the string name of the property to controlminValue
and maxValue
define the slider range (optional)stepValue
defines increments (optional)Example for controlling position:
// Add a slider for X position between -5 and 5
gui.add(mesh.position, 'x', -5, 5);
// Add sliders for Y and Z positions
gui.add(mesh.position, 'y', -5, 5);
gui.add(mesh.position, 'z', -5, 5);
Unlock this course to access the video content, exercises, quiz, project code and more!
PURCHASE TO UNLOCK — $5