Dev.to WebDev 🛠 Dev 👁 0 📖 2 min read

Building an Offline-First 2D/3D Contractor CAD & IRC Stair Calculator with TypeScript, Three.js, and IndexedDB

Most construction and DIY estimators on the web are either static text forms that spit out a single number or bloated cloud CRMs that refuse to load on a job site with zero cell signal. I built DraftYard to bridge that

Most construction and DIY estimators on the web are either static text forms that spit out a single number or bloated cloud CRMs that refuse to load on a job site with zero cell signal.

I built DraftYard to bridge that gap: an offline-first 2D/3D visual layout-to-bid workbench that runs 100% locally in the browser (PWA + IndexedDB) with zero login required.

Architecture Overview

DraftYard is structured as a TypeScript monorepo separating pure trade engineering math from visual rendering and local persistence:

  • core-math: Pure deterministic calculation engines with 1/16" imperial fraction parsing, commercial quarter-yard ready-mix rounding, short-load fee alerts, and residential building code validation.
  • model-3d: A parametric Three.js scene builder that renders structural framing, rebar grids, footings, and notched lumber in real time without hand-crafted static meshes.
  • local-db: Offline-first IndexedDB storage for projects, custom price books, and client quotes.

3 Interesting Engineering Problems We Solved

1. IRC R311.7.5 Code-Checked Stair Stringers & Heel Drop

A surprisingly common bug in web stair calculators is ignoring bottom tread thickness on notched 2x12 stringers. If you don't subtract the tread thickness from the bottom riser, the first step ends up 1" to 1.5" taller than every other step and fails inspection.

In our 2x12 Stair Stringer Calculator, the math engine computes total rise/run, enforces IRC R311.7.5 limits (max 7-3/4" riser, min 10" tread depth, 3/8" variance check), generates the exact 2D cut-layout notches, and extrudes the 3D stringer geometry using Three.js ExtrudeGeometry.

2. Batching Sloped Fence Geometry with InstancedMesh

A 200-foot privacy fence has hundreds of pickets, rails, posts, and underground concrete footings. Creating a separate Three.js mesh per picket tanks mobile frame rates.

For the Sloped Fence Calculator, we compute bay-by-bay terrain elevation for flat, stepped, and raked slopes, then batch all pickets into a single InstancedMesh draw call while calculating exact concrete bag counts per post hole.

3. Concrete Bags vs. Ready-Mix & Composite Deck Joist Rules

  • Concrete pours flip from DIY bags to ready-mix trucks around 1 to 1.5 cubic yards (or trigger a short-load fee below 3 yards). Our Concrete Bag Calculator computes 60-lb/80-lb bags, cubic yards, crushed gravel base tonnage, and #4 rebar grid spacing side-by-side.
  • Diagonal 45-degree composite decking requires tighter 12" on-center joists instead of 16" O.C. to prevent sagging, which our Composite Deck Calculator validates automatically while clipping diagonal boards cleanly inside deck bounds.

Open Reference & Try It Free

If you're interested in the underlying construction formulas (concrete yardage conversions, sloped fence geometry, IRC stair rules, and deck framing tables), I published a public cheat sheet on GitHub at draftyard/contractor-math-reference.

All 16 trade calculators are free to try with no account or signup at getdraftyard.com. Feedback from fellow devs, builders, and Three.js tinkerers is welcome!

📰 Read the original article on Dev.to WebDev

Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.