Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 4.5 — UVs and Bounding Boxes
3D Web · Example 1 of 2

Four UV maps on one square

From the left: the whole picture, the right half, v flipped (the F upside down), and no uv attribute (one flat colour).

UV coordinates say where each vertex sits on a picture, so a flat image can wrap a 3D shape. Bounding boxes and spheres say how big and where a shape is, so you can centre it, fit the camera to it and let three.js skip it when it is off screen.

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

Make a UV set that tiles the picture 3 times across a square. Which numbers go in, and what must the texture's wrap mode be?

02

Write a function placeOnFloor(mesh) that moves a mesh so its lowest world point is at y = 0.

Explain it without notes

01

What are u and v, and what happens if a geometry has no uv attribute?

02

How would you put a loaded model's feet on the floor and its middle on the centre line?

Four UV maps on one square
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

whole picture            uv: 0 0 1 0 1 1 0 1
right half only          uv: 0.5 0 1 0 1 1 0.5 1
upside down (v flipped)  uv: 0 1 1 1 1 0 0 0
no uv attribute          uv: none