Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 6.1 — Loading Textures
3D Web · Example 3 of 3

One grey texel, two colour spaces

Both tiles use the same texel, 128 out of 255. The left one is told it is sRGB and shows 128. The right one is not told, and the maths treats 128 as a true amount of light: it shows 188, a washed-out look. The numbers are read back from the canvas.

A texture is a picture the GPU reads. TextureLoader fetches it, but the picture arrives later, it can fail, and a colour picture needs one extra line (colorSpace) or it looks washed out.

Change the code and press Run (Ctrl+Enter). Predict what will happen first, then break it on purpose and read what changes. Your edits are saved and match the lesson page.

Ready for more? This phase has 4 hands-on exercises with automatic checks.

Practice questions

Write the code in the editor, run it, then open the model answer to compare.

01

Write an async function loadColour(url) that returns a ready colour texture, or null when the file fails, and logs the failing URL.

02

A plane shows a photo that looks too bright. What do you check first?

Explain it without notes

01

A friend's texture is washed out and pale. What is the likely cause, and what is the one-line fix?

02

Why does loadAsync reject with an Event, and how do you find the real reason for a failed texture?

One grey texel, two colour spaces
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

SRGBColorSpace  texel 128 -> screen 128
NoColorSpace    texel 128 -> screen 188