Brickheart

Project background: a browser-based LEGO builder

: Written by a human with AI assistance.

1. Landscape

  • Mecabricks is a long-running browser tool. It uses three.js, has its own part and colour database and a .zmbx format, and runs a paid render farm. It imports LDraw but can't export to LDraw-compatible formats.
  • Danish Bricks Builder looks new and vibe-coded: likely Next.js on Vercel, closed source. It builds on LDraw geometry, Rebrickable data and the StableText2Brick dataset. Only 5,459 of its 63,560 catalogued parts have 3D geometry.
  • BrickLink Studio LEGO owned and tied the BrickLink marketplace, replacing LEGO Digital Designer. It's a desktop download.
  • Gap? a no-install browser tool that builds simple models reliably and exports clean LDR and parts lists.

2. Why the problem is hard

  • LDraw (1995, James Jessiman) describes finished models as part references with positions and rotations. It has no concept of connection. Its answer to placement was grid units (20 LDU stud pitch, 24 brick, 8 plate), applied by the editor.
  • Raw LDR is a poor language for a model to write: absolute coordinates, per-part origins, no connection data. Errors accumulate.
  • Connection data is the missing layer. Studio keeps binary .conn files, LDCad has a text-based shadow library on GitHub. LeoCAD mostly has grid snapping only.

3. Proposed approach

  1. Placement by relation, not coordinates. Say "attach part P to brick A at stud S, rotation r" and code computes the pose. This might stop positional drift. BrickNet's results support the idea: connectivity stays valid much longer than direct pose output.
  2. A grid-based part language (corner position in studs, layer, rotation), converted to LDR by script. A thin layer, not a new programming language.
  3. A validator on the whole model, not just the pair: connector pairing, collision, support.
  4. A state readout after each step (brick IDs, open studs).
  5. Output as standard .ldr.

4. Data

  • Connection table: generate by walking LDraw sub-files, finding stud.dat and the underside stud family and composing transforms, then cross-check against LDCad's shadow library and fix edge cases by hand.
  • BrickNet (Kulits et al.) is the most relevant prior work: typed connectors, graph-based placement, MIT-licensed code (parse, path-to-LDR, scoring). Its Blender-based render repo and mesh downloads are separate pieces.
  • Collision: boxes plus studs at first, meshes later if needed. Stud-in-tube overlaps must be excluded.

5. Scope

  • Excluded: modern Technic, Duplo, minifigures, which have multi-position holes, free parameters and hard collision.
  • Included: sets under 200 parts from Rebrickable with a simple palette.
  • Still need care: half-stud offsets, slopes, round parts, sideways studs, and printed parts mapped to a base part.

6. Risks and open questions

  • Real-world reliability: BrickNet models stayed collision-free for only about 20 steps, so the validator and retry loop are essential.
  • Editor features (snap UI, undo/redo, part browser), rendering and instruction maker.
  • LDraw has translation files for part names, so a multilingual layer is possible.