Skip to content

About

LDraw compatible GLB database

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Repository files navigation

ldr-db

The parts library the ldrawjs editor loads: every part of the LDraw parts library as a 3D model, a picture and a list of the places where it connects to others, with a catalog and the colour table. Published at https://ldrawjs.github.io/ldrawjs-db/.

Nothing here is written by hand. The files are made by ldrawjs-utils, and made again when the LDraw library has a new release. This page is the specification of their formats.

File
parts/<id>.glb One 3D model per part, as binary glTF 2.0.
thumbnails/<id>.png One 256 x 256 picture per part.
connectors/<id>.json Where each part connects to others: studs, holes, pins, clips.
catalog.json What parts exist, and how to find them.
colors.json The LDraw colour table.
manifest.json A report of the run that made the part files.
connectors-manifest.json A report of the run that made the connector files.

A part's <id> is its LDraw file name without .dat, in lowercase (3001, 3626cp01), and is the same in every folder.

The part files

Each part is a standard binary glTF 2.0 file. Anything that reads glTF can open one. A few conventions matter to a program that wants to place parts in a model and colour them:

  • Units and axes are baked in. LDraw measures in LDU (0.4 mm) with -Y up; the files are in metres with +Y up, and a part's front faces +Z. A point (x, y, z) of LDraw is at 0.0004 · (x, −y, −z). The part's own origin is kept.

  • Placing a part. An LDraw rotation matrix M becomes C · M · C with C = diag(1, −1, −1), and its position (x, y, z) becomes 0.0004 · (x, −y, −z).

  • Positions are integers. They are stored as 16-bit integers (KHR_mesh_quantization, the only extension used) on a grid of 1/128 LDU or, for parts that reach further than 256 LDU from their origin, a coarser power of two. The node's scale turns them into metres, so a reader must apply it. There is no translation on the node. Normals are normalised signed bytes.

  • Colours go by material name. Geometry is split by which colour it takes once the part is placed:

    Material Meaning
    ldraw:16 The colour the part is given.
    ldraw:24 The edge colour that goes with it.
    ldraw:<code> A colour fixed in the part: prints, multi-colour parts.
    ldraw:<code>:edge The edge colour that goes with a fixed colour.
    ldraw:0x2RRGGBB A fixed colour given directly as RGB.
  • One mesh, two kinds of primitive. Surfaces are triangles with positions, normals and indices. Edge lines are LINES primitives.

  • Faces whose direction LDraw does not vouch for are written twice, once each way, so every material can be single-sided.

  • Conditional lines are left out unless asked for with --conditional-lines. They would be about a third of each file, and a renderer with smooth shading does not need them.

  • Attribution travels with the file. asset.copyright holds the part's author and licence, and asset.extras.ldraw its original file name and description.

Every file passes the Khronos glTF validator without errors or warnings.

The catalog

catalog.json lists every part that has a part file, and how to find it.

{
  "version": 1,
  "source": "LDraw parts library, https://www.ldraw.org, CC BY 4.0",
  "libraryUpdate": "2026-10",
  "categories": ["Animal", "Antenna", "..."],
  "flags": { "pattern": 1, "sticker": 2, "internal": 4, "alias": 8, "physicalColour": 16, "thirdParty": 32, "shortcut": 64 },
  "parts": {
    "id": ["23714", "62575p01", "..."],
    "description": ["Animal Ant", "Animal Ant with Marbled Trans Brown Pattern", "..."],
    "category": [0, 0, "..."],
    "keywords": ["", "Bricklink 62575pb01, Jungle, Rebrickable 23714pat0001, set 7624, set 7626", "..."],
    "flags": [0, 1, "..."]
  },
  "aliases": { "10": "10a", "100": "3665" }
}
  • parts is column-oriented. Its five arrays have the same length, and the same index in each is the same part. Parts are in LDraw's own order: by description, with sizes in numeric order ("2 x 4" before "2 x 10").

  • id is the part's file name without .dat, in lowercase. It is the name of the part's files here (parts/<id>.glb, thumbnails/<id>.png, connectors/<id>.json) and what a model file calls the part.

  • description is LDraw's, tidied for reading: the padding inside sizes is removed ("Brick 2 x 4" becomes "Brick 2 x 4"), and so is the character LDraw puts in front to classify the part, which is in flags instead.

  • category is an index into categories, which is sorted by name. It is the part's !CATEGORY where it has one, and the first word of its description otherwise.

  • keywords is the part's !KEYWORDS, joined with ", ". Often ids used by other catalogs.

  • flags is a bit field. The meaning of each bit is in the top-level flags, so that a reader need not hard-code the numbers:

    Flag Bit Set for
    pattern 1 A printed part: "Pattern" in the description, or a pNN suffix on the id.
    sticker 2 A sticker, or a part with one applied: "Sticker" in the description, or a dNN suffix.
    internal 4 ~ in front: a piece of another part, or obsolete. Not for use by itself.
    alias 8 = in front, or an Alias type: another name for an existing part.
    physicalColour 16 _ in front, or a Physical_Colour type: a part fixed to one colour.
    thirdParty 32 | in front: not made by the original manufacturer.
    shortcut 64 A Shortcut type: several parts assembled into one.
  • aliases maps the ids of parts that were renamed (LDraw's "~Moved to" files) to their current ids. Such an id has no files of its own; a model that uses it means the part it leads to.

  • libraryUpdate is the newest LDraw release any of the parts belongs to, as year-number.

The colour table

colors.json is LDraw's colour table (LDConfig.ldr), sorted by code.

{
  "version": 1,
  "source": "LDConfig.ldr, LDraw parts library, https://www.ldraw.org, CC BY 4.0",
  "colors": [
    { "code": 0, "name": "Black", "value": "#1B2A34", "edge": "#808080", "finish": "solid" },
    { "code": 33, "name": "Trans Dark Blue", "value": "#0020A0", "edge": "#000B38", "finish": "solid", "alpha": 128 }
  ]
}
Field
code The LDraw colour code: what a model file gives a part, and the number in the material names of the part files (ldraw:<code>).
name LDraw's name, with spaces for its underscores.
value The colour, as #RRGGBB in sRGB.
edge The colour of the edge lines that go with it.
finish solid, chrome, pearlescent, rubber, metal or material (glitter, speckle and the like).
alpha 0 to 255, only on a colour that is see-through.
luminance 0 to 255, only on a colour that glows.

The thumbnails

thumbnails/<id>.png is one picture per part: 256 x 256 pixels, RGBA with a transparent background. The part is seen from the front, the right and above, without perspective, and fills the picture. It is drawn in a neutral light grey (#BFC4C8) where it takes the colour it is given; prints and other fixed colours are their own.

The connector files

connectors/<id>.json is the list for one part. Every part has a file; one with nothing known about it has an empty list. A 2 x 4 plate:

{
  "part": "3020",
  "license": "CC BY-SA 4.0. Made from the LDCad Shadow Library ...",
  "connectors": [
    { "kind": "cyl", "gender": "M", "caps": "A", "secs": [["R", 6, 4]], "pos": [-30, 0, -10], "grid": [4, 2, 20, 20] },
    { "kind": "cyl", "gender": "F", "caps": "B", "secs": [["R", 6, 4]], "pos": [-30, 8, -10], "grid": [4, 2, 20, 20] },
    { "kind": "cyl", "gender": "F", "caps": "A", "secs": [["R", 6, 4]], "pos": [-20, 4, 0], "grid": [3, 1, 20, 0],
      "ori": [1, 0, 0, 0, -1, 0, 0, 0, -1], "tube": true }
  ]
}
  • part is the part's id. license is there whenever the list is not empty.

  • Units and axes are LDraw's, not those of the GLB files: LDU, -Y up, relative to the part's origin. They are what a model file is written in.

  • pos and ori place a connector. ori is a rotation, nine numbers row by row as LDraw writes a matrix, and is left out when it is the identity. A shape runs from pos along the negative Y axis of its orientation: the stud above rises from the top of the plate, and the hole reaches up into it from the bottom. With "center": true the shape lies half to each side of pos instead.

  • grid is [countX, countZ, stepX, stepZ]: the connector repeated along its own X and Z axes, the first one at pos. A 48 x 48 baseplate is one line.

  • kind is one of:

    Kind Fields
    cyl gender, secs, caps A cylinder: M goes into F. Studs, pins, axles, bars, and the holes for them.
    clp radius, length A clip. It takes a bar: a male cylinder of its radius.
    fgr genderOfs, seq, radius The fingers of a hinge: the gender of the first, the width of each, the radius of their tips where given.
    gen gender, bounding, group Anything else. Fits only another of the same group. bounding is a rough size: ["box", x, y, z] (half sizes), ["cube", size], ["cyl", radius, length], ["sph", radius] or ["pnt"].
    sph gender, radius A ball, or the socket for one. The shadow library writes these as gen at present, so none are published.
  • secs is a cylinder's shape along its length, as [shape, radius, length] for each stretch: R round, A axle, S square; _L and L_ are a rim that gives way, belonging to the stretch before or after. A stud is [["R", 6, 4]]; the hole in a Technic beam is [["R", 8, 2], ["R", 6, 16], ["R", 8, 2]].

  • caps says which ends of a cylinder are closed: none, A (the end at pos), B (the far end) or two. For a hole this is what says where it is entered, and it is not always at pos: the ordinary holes above are closed at B and open at pos, on the underside of the plate; the third line is written from its closed end, 4 below the top, and opens at the far end, pos and four along the way it runs, which is the underside again. A hole with none is entered from either end.

  • tube marks the hole inside a tube under a part: the three tubes between the eight holes of the plate above. A stud fits in one, and the part then sits half a stud off, in both directions, from where its ordinary holes would put it. Such a hole has the shape of any other hole for a stud, so the mark is the only way to tell the two apart: to prefer the ordinary holes, or to leave the tubes out. A tube that the part has an ordinary hole for, opening at the same place, is written once, as that hole.

  • slide marks a connection the parts can slide along; group, where a connector has one, limits it to others of the same group; extra holds properties this tool does not know, as the shadow library wrote them ({"placement": "free"}). All three are left out when they do not apply.

  • A round cylinder has no turn of its own. LDraw files turn studs about their own axis every which way, which means nothing for a round shape. Such a connector is written in the one orientation that goes with the way it points, so an upright stud has no ori at all. Axles, square holes, clips and the rest keep the turn they were given.

Two parts join where a male and a female connector of matching shape are at the same place, on the same axis. A brick sits on another when the open end of its holes is at the pos of the other's studs. The files say where the connectors are; what fits what, how much play there is, and whether the parts then pass through each other, is for the program that uses them.

Coverage follows the shadow library. In the 2026-11 library 18,404 of 24,043 parts have at least one connector (every plate, 96% of bricks, 85% of Technic). A part the shadow library has no file for still has the studs its primitives give it, and the tubes under it, but not the ordinary holes underneath, which are written part by part. The tubes are not from the shadow library, which has them switched off; they are an addition of this project's, 25,738 of them in 4,142 parts.

The reports

Two files describe a run and are not needed to use the data.

manifest.json, from ldraw-to-glb:

Field
generator, source, libraryUpdate What made the files, from what, and from which LDraw release.
units, upAxis, ldrawUnitInMetres "metres", "+Y" and 0.0004: the space the part files are in.
parts By id: file, description (as LDraw writes it), bytes, triangles, vertices, lines, conditionalLines.
aliases The same map as in the catalog.
empty Parts with nothing to draw, by id, with their description. They have no files.
failed Parts that could not be converted, by id, with the reason.
problems Parts that were converted with something amiss, by id: missingFiles (references that lead nowhere) and unparsedLines.

connectors-manifest.json, from part-connectors:

Field
generator, sources, license What made the files, from what, and the licence they are under.
libraryUpdate, shadowCommit The LDraw release, and the commit of the shadow library.
units, upAxis "LDU" and "-Y": the space the connector files are in.
counts parts (files written), withConnectors, withoutConnectors, moved (renamed parts, which have no file), connectors (lines), places (what the lines stand for once their grids are counted out), placesByKind, and tubeHoles (how many of the places are holes inside tubes).
shadowFiles all, used, and the list of those unused: shadow files for parts the LDraw library no longer has.
additions The files that part-connectors/additions/ had lines for.
problems.failed Parts whose file could not be written, by id.
problems.unresolvedIncludes By file: the SNAP_INCL references that name no shadow file.
problems.unreadableLines By file (shadow/... or ldraw/...): the shadow lines that could not be read, with line numbers.
problems.snapsLostToReferences By the file the snaps were in: how many did not survive a reference, as scaled, mirrored or sheared.
problems.unknownToThisProgram Properties and names the format's description does not have, with counts.
problems.otherLdcadLines !LDCAD lines that are not about connecting, by name, with counts.

Licences

  • parts/, thumbnails/, catalog.json, colors.json and manifest.json are derived from the LDraw parts library, the work of the LDraw community, and are under CC BY 4.0. The attribution is written into every part file.
  • connectors/ and connectors-manifest.json are also derived from the LDCad Shadow Library by Roland Melkert and its contributors, with a few lines added to it in ldrawjs-utils, and are under CC BY-SA 4.0: anything made from them has to be shared under the same licence. Each file that has connectors says so.

LDraw™ is a trademark owned and licensed by the Jessiman Estate. This is an independent, community project. It is not affiliated with, sponsored by or endorsed by any toy manufacturer.

About

LDraw compatible GLB database

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Contributors

Languages