Technology

3D on the web without the slowdown: how I sped up my model of Prague

Tiles and culling, lighter trees, a cheaper material, a still image by default. What I changed on my own website and what it means if you commission 3D.

On my home page, a camera flies over a low-poly model of Prague along the Royal Route: from the Powder Tower through Old Town Square and across Charles Bridge up to Prague Castle. I built the model from OpenStreetMap data (© OpenStreetMap contributors).

It looks light, but the first version drew the entire city in every frame, including hundreds of thousands of triangles that weren’t even in view. The goal of the work was clear: the same picture with far less work per frame, so that the flight runs smoothly on weaker integrated graphics too and doesn’t drain the battery for nothing.

Here is what I changed, what the measurements showed, and what anyone commissioning 3D or other interactive work for a website can take from it.

The default is a picture, not 3D

The most important decision wasn’t a technical one. Each of the four stops has a pre-rendered still, and the section is complete without 3D. The live model only replaces the picture, and only where it makes sense: on a device with a real graphics processor, on a wider screen, and only if the visitor hasn’t asked their system to reduce motion or save data.

The model also isn’t downloaded when the page opens. Rendering starts roughly 900 pixels before the visitor scrolls to the section, but never before the page has finished loading. After the changes I regenerated the stills from the new scene, so the switch from picture to live model happens without a jump.

Draw only what’s visible

I split the model into an 8 × 8 grid of tiles, each roughly 375 metres across, containing terrain, buildings and trees. Every tile has its own bounding sphere, so the three.js library can tell which tiles are outside the camera’s view and skips drawing them entirely. The technical term is frustum culling. Shared elements, such as the model’s base, the embankments, the bridges and the landmarks, stay in one common part.

Triangles drawn at each stop, before and after the changes (including the lighter trees described below):

  • Powder Tower: from 801,386 to 66,656,
  • Old Town Square: from 801,812 to 80,333,
  • Charles Bridge: from 802,886 to 131,436,
  • Prague Castle: from 804,692 to 113,064.

There is a price. The number of draw calls rose from 15 to between 32 and 59, because each visible tile is drawn separately. I’ll show where that showed up in the measurements.

Trees were most of the work

The analysis showed that trees made up 69% of all triangles: 547,000 out of 797,000. Each tree crown was a polyhedron with 80 faces. I replaced it with a 20-faced icosahedron and kept spherical normals, so the crowns still look soft, like foam trees on an architectural model. I rejected a sharply faceted version after a visual comparison.

That alone cut the whole model from 797,000 to 387,000 triangles, before any culling.

A cheaper material, the same picture

The scene originally used a physically based material (MeshStandardMaterial) that also calculates reflections. But with surface roughness of 0.92 to 0.96 and zero metalness, the reflection simply wasn’t visible. I switched to the simpler MeshLambertMaterial, which has the same diffuse component.

Working out the colour of each pixel is now several times cheaper. The average difference in the image is 1.4 to 2.2 out of 255 possible levels. For a sense of scale: 255 is the difference between black and white.

Small things that add up

  • 16-bit indices. Every tile has fewer than 65,536 vertices, so indices half the size are enough. The graphics card uploads and reads half as much index data. I also stopped transferring an unused data buffer from the worker thread where the geometry is prepared.
  • Anti-aliasing only where it’s needed. On displays with double or higher pixel density, the tiny pixels smooth the edges by themselves. Multisampling (MSAA) also quadrupled the memory traffic of every frame there, so I only enable it below that density.
  • A warm-up over four frames. Before the flight, the terrain and water, the city, the trees and finally the route and markers are prepared in turn. The shadow pass covers the whole model, so tiles outside the view are uploaded to the graphics card too, and nothing new has to be added during the flight.

Safeguards for weaker devices

A frame governor

When eight slow frames appear while the camera is moving, meaning below roughly 28 frames per second, the rendering pixel density drops by 0.5, for example from 2× to 1.5×, and never below 1×. It doesn’t go back up. A display limited to 30 Hz, for instance in power-saving mode, doesn’t fall below that threshold, so the image stays sharp.

Detecting software rendering

Some computers have no usable graphics hardware, and the browser then renders 3D on the processor, using software renderers such as SwiftShader or llvmpipe. The site checks for this in two ways. It creates the WebGL context with the failIfMajorPerformanceCaveat flag, which tells the browser not to create one if there is no hardware graphics or system performance is low. It also checks the renderer’s name. Without real graphics hardware, the 3D doesn’t start by itself. The stills remain, along with a “Show the model in 3D” button for anyone who really wants it.

What the measurements showed

I measured with a script that flies through all the stops and back at 1440 × 900 (6 seconds, one step per frame). Once on Apple M1 graphics, and once in SwiftShader. SwiftShader stands in for weak integrated graphics here: it computes everything on the processor, so every triangle and every pixel shows up in the timings.

  • Apple M1, at 1× and 2× density: 60 frames per second both before and after. Here performance is capped by the display’s refresh rate, so this measurement can’t show any headroom.
  • SwiftShader, 1×: the median frame time fell from 317–400 ms (about 3 frames per second) to 133–150 ms (7–8 frames per second).
  • SwiftShader, 2×: after eight slow frames, the governor reduced the density from 2× to 1.5×.
  • First frame on M1: 258–332 ms before and 283–345 ms after, within the noise.
  • First frame in SwiftShader: slowed from 1.4–1.5 s to 2.0–2.1 s.

That last point is the price of the tiles. During the warm-up they mean around 170 draw calls in the shadow pass, and a software renderer pays for every one of them. I accepted it because 3D no longer starts by itself in software mode.

The limits of these measurements: one machine and headless Chrome. SwiftShader isn’t a physical device and its timings vary with processor load and temperature, so I measured before and after back to back.

What to take from this if you’re commissioning 3D

3D and interactive elements can bring a website to life, but they can just as easily slow it down. Whoever builds them, these questions are worth asking up front:

  • What does a visitor see without 3D? The page should be complete without it, with a still image or a video.
  • When is the model downloaded? Not when the page opens. 3D shouldn’t hold up the content a visitor needs to see straight away, or hurt the core metrics described in the article on website speed and Core Web Vitals.
  • What was it tested on? “It runs on my laptop” isn’t enough. Ask for measurements on a weak device or a stand-in for one, with the limitations stated.
  • What happens when performance isn’t enough? Does it lower the resolution, switch to images, and respect requests to reduce motion and save data?
  • How much does the scene draw? The number of triangles and draw calls in a typical view is a useful figure. On my model, culling what’s off-screen and simplifying a repeated element, the trees, saved the most triangles.
  • How is the look protected? Optimisation should come with a visual before-and-after comparison, not just better numbers.
  • Are the results honest? A good measurement also shows what got worse, and explains why it’s worth it.

If you’re planning 3D or another interactive element and want it to be fast, get in touch. Such an element is usually part of a business website; whether a ready-made template can handle it or a custom build pays off is covered in custom website or template, and the working together page and the article how a website gets built describe how a project runs.

Update, 12 November 2026: The Prague model now has a cinematic look (golden hour, haze, the Vltava with boats, lamps along the route and billboards) and widens to the full width of the page as you scroll. The techniques in this article still apply. The terrain is now split into coarser blocks, and at full width the rendering resolution is capped at 1.5×, so the flight stays smooth.

Read next

All articles

Custom website or template and WordPress? How to decide

Custom website vs. template or WordPress: when a ready-made site is enough, when custom pays off, a comparison table and questions to ask first.

How a website gets built, step by step, and how long it takes

How a website gets built: four steps from brief to launch, what is needed from you, what affects how long it takes and what follows launch.

Contact

Tell me what you need solved.

Calling is quickest. You can prepare a few sentences about your project here and send them as a text.You can prepare a few sentences about your project here, copy them and have them at hand when you call. No finished brief needed.

Contact form

Your message

No commitment. The website sends nothing. Your messages app opens with the text for me; you send it.The text is copied; then call me or text it to the same number.

I use your details only to reply and to discuss working together. How I handle your data

Jiří BejčekI read every message myself.

Get in touch