Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 4.2 — Build the Bike from Shapes
3D Web · Example 2 of 2

Two ways to aim a tube between two points

Orange: quaternion. Blue (see-through, fatter): lookAt on a geometry laid along z. They end up in the same place, so the orange tube sits inside the blue one.

A bicycle is tubes, rings and a few blobs. You build the whole Lumen frame from cylinders, tori and a capsule, aim each tube between two points, group paired parts, and count what each part 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 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

Add a kickstand tube from the bottom bracket to (−0.2, 0, 0) with radius 0.012 and print how many triangles it adds.

02

Make tubeBetween refuse a zero-length tube: it should throw a helpful error naming the tube.

Explain it without notes

01

How do you place a cylinder so its two ends are exactly on two points?

02

Why are P.bottomBracket.clone().setZ(z) and not P.bottomBracket.setZ(z) used for the stays?

Two ways to aim a tube between two points
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

bottom bracket to head tube
  quaternion: (0.00, 0.30, 0.00) -> (0.47, 0.70, 0.00)
  lookAt:     (0.00, 0.30, 0.00) -> (0.47, 0.70, 0.00)
straight up
  quaternion: (0.00, 0.00, 0.00) -> (0.00, 1.00, 0.00)
  lookAt:     (0.00, 0.00, 0.00) -> (0.00, 1.00, 0.00)
straight down
  quaternion: (0.00, 1.00, 0.00) -> (0.00, 0.00, 0.00)
  lookAt:     (0.00, 1.00, 0.00) -> (0.00, 0.00, 0.00)
sideways, along z
  quaternion: (0.00, 0.50, -0.50) -> (0.00, 0.50, 0.50)
  lookAt:     (0.00, 0.50, -0.50) -> (0.00, 0.50, 0.50)
same point: length 0 - quaternion 0, 0, 0, 1