Skip to content
Yanko Ivanov
← Experiments

Pergola Calculator

How many posts, beams and rafters a timber pergola needs, in what size, with a cut list, a price and a 3D model you can turn.

· experiment · Astro · three.js · TypeScript · Eurocode 5 (the shape of it)

It lives right here in the garden: /experiments/pergola-calculator →

I am building a pergola next spring, and I would like to walk into the timber yard with a list instead of a feeling. This is the list-maker.

What goes in, what comes out

You give it the length and depth, the post height, how far apart the posts and rafters may be, how far the rafters stick out, the strength class of the timber, a roof (open slats or covered) and a snow load. It can stand on its own posts or lean on a wall.

Out comes the number of posts, beams, rafters and slats, the lightest section from a short list of common metric sizes that passes a check, a cut list, a list of boards to buy so the cuts fit, a rough price and a 3D model.

Typed dimensions are kept as typed. A span of 4.35 m stays 4.35 m; only the sliders move in steps.

The check

Rafters, beams and the wall ledger are treated as simply supported and checked for bending, shear and deflection. Posts are checked for compression and buckling. The load travels the way it does on the real thing: roof, rafters, beams, posts, each one picked after the one above it.

The numbers follow the shape of Eurocode 5: timber strength classes from EN 338, strength reduced for load duration and for sitting outdoors, partial safety factors on the loads, creep in the deflection. It is not a Eurocode design, and the page says so. It ignores several things that help (continuity over a support, a stiffer roof) and a few that hurt (wind, joints, footings), and it can only pick from the sizes in its list. When nothing in the list is strong enough it says that, in plain words, and still draws what it has.

Snow counts on open slats too unless you tick the box that says it falls through. Slats hold more snow than they look like they should.

The 3D model

The model is three.js, loaded only when it scrolls into view, so the page and the sums work without it and no other page on this site ever downloads it. It is about 136 KB compressed. It draws flat colours and outlines, takes its colours from whichever theme you picked for the site, and redraws only when something changes. A plain scroll over it scrolls the page; Ctrl and scroll, or a pinch, zooms. If your browser has no WebGL, the model is replaced by a sentence and everything else carries on.

Prices

The prices are placeholders, in euro. Type your yard’s over them. They stay in your browser, along with the last design you worked on. The design itself also lives in the link, so sending someone the address sends them the pergola.

Under the hood

The page is an Astro island in plain TypeScript with no backend. The sizing, the geometry, the cut-list packing and the costs are plain modules with unit tests, and the tests that matter for the check use numbers worked out by hand, so a changed constant shows up as a changed number rather than as a quiet drift.

Comments