Command Palette

Search for a command to run...

Hectal
Phase 3: three.js Foundations
3D Web · Exercise 4 of 5 PreviousNext
Intermediate

Draw only when something changed

This page redraws 60 times a second even though nothing moves. Use a dirty flag so it draws once at the start and again only when you click the canvas.

A click (a pointerdown) must turn the box a quarter turn (π / 2 around y) and cause a new frame.

What Check tests

  1. The scene is drawn at least once
  2. While nothing changes, at most 3 frames are drawn in 400 ms
  3. A pointerdown draws a new frame
  4. The box turned a quarter turn

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.