Command Palette

Search for a command to run...

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

Load, upload, and the colour-space line

The slab turns while you look at the status bar: the texture count rises only after the first frame. Concrete photo: Poly Haven, CC0.

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?

Load, upload, and the colour-space line
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

before load: textures in GPU memory = 1
loaded: true | size: 1024 x 1024
colorSpace right after load: ""
textures in GPU memory (not used yet): 1
textures in GPU memory after the first frame: 2