One triangle, one million triangles
The last line builds a sphere of about a million triangles. On a very old phone this example may take a moment to start. It is one draw call either way: a draw call is not a triangle.
Every 3D shape is a mesh of triangles joined at corner points called vertices. Triangles are used because three points are always flat, and the number of triangles is the first thing that decides how much a scene costs.
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.
A cylinder has 12 sides. Compute its triangles (sides plus two caps) and check with geometry.index.count / 3.
A designer's model has 2 million triangles and runs at 15 frames per second on a phone. Name two things you would try before asking for a new model.
Explain it without notes
Why does the GPU use triangles and not squares or other polygons?
A sphere has 32 segments around and 16 from top to bottom. How many triangles is that and how do you get the number?
Console
Nothing logged yet.Expected console output
1 triangle draw calls 1, triangles 1, geometry data 36 bytes
12 triangles (a box) draw calls 1, triangles 12, geometry data 840 bytes
960 triangles (default sphere) draw calls 1, triangles 960, geometry data 23,712 bytes
about 1,000,000 triangles draw calls 1, triangles 1001112, geometry data 28,099,136 bytes