Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 3.4 — Object3D and Transforms
3D Web · Example 1 of 2

Hide it, shrink it, put it behind the camera

The status bar shows the draw calls too. Scale 0 still costs a draw call; a hidden object and an object behind the camera cost none.

Meshes, lights, cameras and groups are all Object3Ds with a position, rotation, scale and visibility. You learn add, remove, traverse and getObjectByName, and what happens when an object is hidden, scaled to 0, placed behind the camera or added twice.

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 5 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 a function findAll(root, namePrefix) that returns every object whose name starts with a prefix.

02

A model's parent is scene. Write the line that moves it to rack but keeps it where it is on screen.

Explain it without notes

01

What is the difference between visible = false, scene.remove(obj) and scale.set(0, 0, 0)?

02

What happens if you add the same mesh to two different groups?

Hide it, shrink it, put it behind the camera
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

three boxes                | draw calls: 3 | triangles: 36
blue.visible = false       | draw calls: 2 | triangles: 24
  scene still holds it: true
grey.scale = 0             | draw calls: 2 | triangles: 24
orange.position.z = 10     | draw calls: 1 | triangles: 12
  found by name: false | missing name gives: undefined
traverse visits 6 objects (the scene itself, 2 lights, 3 boxes)