Procedural Environment

Three.js lessons
/

Procedural Environment

Intermediate

Light & surfaces

Lesson 8 of 15

Light a reflective object with six generated cube-map faces instead of an external HDR image.

Create a self-contained studio-like reflection map and distinguish scene.environment from scene.background.

How this scene works

A CubeTexture contains faces in +X, −X, +Y, −Y, +Z, −Z order. These canvas faces use display colors and are marked sRGB. scene.environment supplies image-based lighting to standard materials, while scene.background only controls what appears behind the objects. Three.js prepares the environment for roughness-dependent reflections. This small LDR map is a teaching fixture, not a physically calibrated HDR studio. Cleanup releases the texture when the project reruns.

Procedural Environment

Ready to run

Helper snippet · Three.js 0.183.1 · WebGL

Loading draft

1 files · local only

Ctrl/Cmd+Enter: run · Ctrl/Cmd+F: find · Tab: leave editor
Run your code to start the scene.
Drag to orbit, scroll to zoom, right-drag to pan.
Drag: orbit · Scroll: zoom · Right-drag: pan

Make it your own

Assign the cube texture to scene.background too. Then change the +Y face to orange and increase roughness from 0.12 to 0.8 to observe how the reflection spreads.

Change one thing, run the scene, and compare. Pause animation to inspect the result; reset the example to return to its original code and files.

FAQ