Command Palette

Search for a command to run...

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

Four ways a load can go (and one that returns too early)

Real results from this page: a wrong folder, a file that is not a picture and another website all reject with an Event of type error. The last line shows load() returning before the picture exists.

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?

Four ways a load can go (and one that returns too early)
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

right path    | ok: 1024x1024
wrong folder  | failed: Event error
not an image  | failed: Event error
other website | failed: Event error
load() returns at once | image so far: null | isTexture: true