Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 9.1 — Time-Based Animation
3D Web · Example 1 of 3

A wheel at a real speed

Look at the status bar: the fps changes with your machine, the wheel's speed does not. Change SPEED_KMH to 5, 60 or 0.

Animate by how much time has passed, not by how many frames have been drawn. A wheel then turns at omega = v / r radians a second on a 30 fps phone and on a 144 Hz monitor alike.

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 6 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 wheelStep(speedKmh, radius, delta) that returns the radians to add this frame. What does it return for 36 km/h, radius 0.35 and delta 1/60?

02

A tab is hidden for 30 seconds and shown again. With Timer.connect(document) and a clamp of 0.1, how far can the wheel jump on the first frame?

Explain it without notes

01

Why does rotation.z += 0.1 give different speeds on different screens, and how do you fix it?

02

A bike rolls at 18 km/h on wheels with a 0.35 m rolling radius. How fast should the wheel turn, in radians and in turns a second?

A wheel at a real speed
Press Run to see the page.
idle

Console

Nothing logged yet.

Expected console output

road speed: 5.556 m/s
wheel speed: 15.78 rad/s = 2.51 turns/s
one turn rolls the bike: 2.212 m