A 3D home page that shows something in two seconds
· 6 min read · João Ramires
Cloudflare’s speed test of my home page from Iowa timed out. The test from North Virginia finished, and it reported 160 seconds of blocking time on mobile, which means the browser was too busy to answer anything for most of that run. Real visitors had it better, but not by much: the weekly review agent from my last article measured 15 seconds, at the 75th percentile, before the page’s main content showed up. It called that the biggest problem on the site, and it was right.
My home page is a 3D room, and the room is slow to start. On a slowed processor and network it needed 7 to 14 seconds before the page showed its main content. Now the title card is plain HTML and paints in about 2 seconds, with the room building behind it, and on computers with no graphics card the page skips the room and opens the text version of the site. This is how each part works, what I measured, and what is still slow.
What was wrong
The room is built with three.js, in one of three art styles: pixel, inked or photoreal. Before, the page drew its first real content, the intro card with my name and the Enter button, only after the room had downloaded, built its world in one block and compiled its shaders. The browser can’t paint what the script hasn’t made yet, so the slowest part of the page decided when anything appeared.
To measure it I used the main-content time that web.dev calls Largest Contentful Paint (LCP), on a slowed processor and network, and took the middle of 3 runs for each case. A coding agent made the changes below and ran those measurements. I decide what to fix and read what it changes.
How the page loads now
The card moved into the page’s HTML. The room’s script finds that card, takes it over, and never redraws it.
flowchart TD
A[HTML arrives; the head script picks the style and fonts] --> C[Title card paints]
C --> D[Software-rendering check]
D --> E[three.js and the style's look download]
E --> F[Room builds]
F --> G[First frame: shaders compile]
G --> H[Enter starts the room]
From first byte to the room
Four changes make this work:
The card is HTML.Home.astro writes the card, my name, the clock line and a disabled Enter button into the page, and a short inline script fills in the time. The room’s code adopts the same node when it is ready, so the card never flickers or doubles.
The head script preloads the room’s fonts. It runs before the first paint, picks the art style, and asks for that style’s room fonts. Before, it asked for the fonts of the text version, which the room doesn’t use.
Enter pressed early is remembered. Someone can click or press Enter while the card shows and the room is still loading, so a small listener in the page records that, and the room starts at once when it is ready.
The loading text was cream on a cream page. For a while the page was admirably quiet about how slow it was. I fixed the colors.
The result, on that slowed profile:
Style and viewport
Main content before
After
pixel, desktop
7.5 s
1.8 s
inked, desktop
9.4 s
1.8 s
photoreal, desktop
14.0 s
2.1 s
photoreal, phone
12.3 s
2.2 s
Layout shift (CLS, also defined on web.dev) stayed under 0.01. After the launch I opened the live site in desktop Chrome and saw first paint at 0.69 s, with the card visible and the room behind it inside 6 s.
The card from the live site on a slowed processor and network, photoreal style. On the left it has just painted; on the right the Enter button is filling while the room builds behind it.
Computers with no graphics card
Some browsers have no usable graphics card, so they draw 3D on the processor. Chrome does this with SwiftShader. I ran the page that way in a slowed Lighthouse-like setup, and a single frame took 0.2 to 0.6 seconds in pixel, 1.7 to 2.1 seconds in inked, and 3.6 to 4.3 seconds in photoreal. Before the check described below, the main content showed at 9, 11 and 36 seconds, and the page never went idle, so clicks waited. This is what Cloudflare’s scheduled speed test from the US had been choking on: it timed out.
The obvious test was the first one I tried. Ask for a WebGL context with failIfMajorPerformanceCaveat: true, and the browser refuses when it would be slow. On SwiftShader it still hands back a context, so that test tells you nothing.
What works is the renderer’s name. The page reads it through the WEBGL_debug_renderer_info extension and matches the names of software renderers: SwiftShader, llvmpipe, softpipe, lavapipe, Microsoft Basic Render Driver and similar.
The hard part was when to run it. Creating a first context took about 1.9 to 2.3 seconds on SwiftShader and about 240 ms on a real GPU. On a GPU that is cold-start time the room pays anyway, but the card shouldn’t wait for it, and my first version, which ran the check in the head script, delayed first paint by about 200 ms on the GPU path. I dropped that version.
The current one works in three steps:
The head script only reads a saved answer, which the browser keeps for a week.
With no saved answer, main.ts runs the check one frame after first paint, before three.js downloads, and saves the result.
On software rendering, the page removes the room, opens the text version with a short note, and offers “Enter the room anyway”. That choice is remembered, and the visit is counted as soft-gl, so I can see how many visitors land there.
A visitor who asks for the room by link, who chose it before, or who opens a deep link skips the check. For everyone else on a GPU, first paint stayed where it was: 133 to 157 ms with the check, against 121 to 163 ms with the saved answer, 6 runs each.
The Enter button fills with real progress
At 2 seconds the button still can’t start the room, and a disabled button with no sign of life looks broken. So the button fills like a bar, driven by where the load really is.
The room’s boot code calls a hook, __load(mark, next, seconds), at each stage change: mark is how far the load really is, next is where the running stage ends, and seconds is how long that stage takes on a slow phone. I set the weights from slowed runs (Slow 4G, 4× CPU) in all three styles:
Stage
Share of the fill
software-rendering check
3%
code, look and fonts downloaded
45%
room built
32%
first frame, with the shader compile
20%
The page sets one CSS transition toward just short of the next mark. A CSS transform runs on the compositor, so the fill keeps moving while the main thread is busy building the room. It never goes backward and never shows full before the room is ready, because only the room’s ready signal, ui.ready(), finishes it.
Screen readers hear “Loading the room, 40%” in steps of 20%, and with reduced motion on, the fill jumps instead of gliding. First paint did not change: 2,316 ms against 2,276 ms on a slowed phone, 3 runs each.
What is still slow
On that slowed profile, building the room took about 1.5 seconds in pixel and inked, and up to about 8 seconds in photoreal. The first frame took about 1.6 seconds or more.
The honest limit is photoreal. The build runs as one synchronous block, so the fill stands still for a few seconds while the main thread is busy, and a bar that stands still for that long reads as a hang. Splitting the build into pieces that yield to the browser is the next step.
What I’d tell someone building the same
Paint real content from HTML first. Let the heavy part fill in behind it.
Don’t trust failIfMajorPerformanceCaveat. Read the renderer’s name.
Keep any check off the first paint’s path, and save its answer.
Remember a click that comes too early.
Fill a progress bar from real stages, and weigh them from measured runs.