Command Palette

Search for a command to run...

Hectal
Back to the lesson: Topic 10.4 — Loading, Empty and Error States
3D Web · Example 2 of 2

A deadline for a load that hangs

The slow "load" is a stand-in that takes 3 seconds; the deadline is 800 ms.

A model takes time to arrive and sometimes never does. The page must always say what is happening: loading (with progress when it can), an error in plain words with a Try again button, and a deadline for loads that hang.

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 an "empty" state to the first example's show() for a part that has no model yet, with the text "No 3D model for this part yet."

02

Write withTimeout() so it also clears its timer when the load wins.

Explain it without notes

01

Why can a loading bar not always show a percentage, and what should it show instead?

02

What should the visitor see, and what should the developer see, when a model fails to load?

A deadline for a load that hangs

Console

(nothing was printed)

Expected console output

fast load: the bike
slow load: timed out after 800 ms -> show the still picture and a Try again button