Show HN:我制作了一个开源的乐高 AI 生成器
Show HN: Made an open-source Lego AI generator

原始链接: https://github.com/anteloc/ldraw-nova

**ldraw-nova** 是一个 Docker 化 Web 应用,使用 LDraw 引导 AI 智能体设计可构建且兼容乐高的 3D 模型。收到提示词后,智能体会研究文档、搜索真实零件和示例、规划子模型与几何结构、创建 JSON 规划和 Python 生成器,然后进行渲染、检查,并迭代修正碰撞、间隙、位置和美观等问题。 该项目表明,与直接编写 LDraw 数学代码相比,智能体通过 Python 生成器生成几何结构更加可靠。与查看已完成的模型相比,智能体从生成器代码中学习的效果也更好。 语义搜索使用 **jev-rerank** 和 TypeSafe 的 Jev 技术。如果未设置 `TYPESAFE_API_KEY`,系统会回退到全文搜索。交付内容包括 LDraw 源文件、3D 查看与播放、Meta Quest 3 VR 支持、渲染图像、包含元数据且可编辑的 Blender `.glb` 文件,以及智能体聊天记录和历史记录。 运行方法是将 **ldraw-nova** 和 **ldraw-nova-docker** 以匹配的 v0.6.0 标签并排克隆,使用 Docker Compose 构建并启动应用。VR 使用 8443 端口上的 HTTPS,8765 端口提供普通 HTTP 服务。目前面临的问题包括 VR 性能不佳、生成速度慢且成本高、对小型智能体的支持有限,以及在动物、科技类机器、飞船和说明书类搭建等复杂主题上的效果较弱。

首次在 Hacker News 发帖的用户 `antelocnova` 介绍了一款开源 AI 工具,可通过生成 LDraw 代码来创建可编辑的乐高 CAD 模型。经过大约一年的实验,创作者利用先进的 OpenAI 和 Claude 模型构建了一套 Python 工具集、智能体指令和文档,可生成 `.ldr` 和 `.mpd` 文件,并能在 LDView、LeoCAD 和 Studio 等工具中查看。该项目以 Docker 化 Web 应用的形式发布,支持 OpenAI、Claude 和 OpenRouter,作者邀请大家提供反馈。 一位评论者分享了此前关于利用大语言模型和受限零件清单来搭建乐高工具的研究,并认为 newer models 可能会有所改善。Hacker News moderator“dang”解释道,原先的 Show HN 帖子可能因新账号限制而被过滤;他恢复了该帖子,欢迎创作者,并鼓励社区参与。
相关文章

原文

Give an AI agent a model idea. Guide it, let it build it, and get an LDraw LEGO© model.

What you get when the building process finishes:

  • Its source code, in LDraw language.
  • Different views: 3D viewer, 3D player, VR interactive (Meta Quest 3), images...
  • Blender editable glTF file, in .glb format, metainfo as Blender's Custom Properties.
  • Chat history and agent thinking process.
  • and more... 👌

Take a look at the video:

Important

Tools used by agents in order to find suitable parts and example models take advantage of jev-rerank (I'm also the author). This is a semantic search tool with re-ranking backed by TypeSafe's Jev System One AI model.

  • If you have a TypeSafe API key (TYPESAFE_API_KEY), set its value on the web app's Settings section.
  • If you don't, reranking search will not work, and agents will resort to a FTS (Full Text Search) strategy as a fallback, which could (maybe) yield worse models.

Run ldraw-nova as a web app, with Docker. You need Git and Docker.

This web app will run dockerized, and to build the Docker image, two sibling repos are required:

1. Clone both repos side by side, at the same tag, so they work together:

git clone --branch v0.6.0 https://github.com/anteloc/ldraw-nova.git
git clone --branch v0.6.0 https://github.com/anteloc/ldraw-nova-docker.git

2. Build the Docker image. The first build takes a while and needs about 5 GB of disk space:

cd ldraw-nova-docker
docker compose build

3. Start the app:

4. Open it in your browser:

  • https://localhost:8443: needed for VR on Meta Quest 3. The certificate is self-signed, so accept the browser's warning the first time.
  • http://localhost:8765: plain HTTP, no certificate warnings. Use it if the self-signed certificate gets in the way. VR won't work over it.

Other devices on your network can reach the app by your computer's IP instead of localhost, e.g. https://192.168.1.20:8443 from a Quest 3. The app has no login, so only run it on networks you trust.

To stop it:

Well, to summarize: I did this in order to get agentic LLMs capable of designing buildable, physical things!

Finding LDraw, an assembly language (pun intended! 😜) that would be at the same time simple, low level, and executable in order to produce 3D CAD models, gave me the idea of experimenting with both ChatGPT and Claude in order to try and make them code in LDraw, same as they do with other programming languages.

To my surprise, even though this language is heavily focused on math (parts rotations, positioning...), which LLMs are usually bad at, agents did pretty well instead on initial tests, and subsequent projects also yielded good results, but never enough in order to consider generated models to be correct:

These three attempts, and quite some other experimentation, led me to the following conclusions:

💡 Conclusion 1: there is a minimum resistance path to geometry math for agents, i.e.:

  • Giving the agents tooling to generate LDraw sources would sidestep (evil!) geometry math
  • ... because they do way better at generating python code that produces math
  • ... than on producing math themselves!

💡 Conclusion 2:

  • Agents tend to do better when learning from python code that produces models
  • ... than from models themselves (LDraw's evil geometry, again...)

Then, the only thing left 🤔 was to create a python-based tooling with the required primitives, verbs, constructive vocabulary... so agents would learn by example and do similar things on their own.

Which proved to be really hard to get right, even if vibe coding it... until GPT-6 Astra and Claude Opus 5.5 arrived... and vibe-coded it right! 🚀🚀🚀

ldraw-nova provides the tools, examples and instructions an agent needs to design models with real LDraw parts.

The process is as follows:

  1. The agent takes a prompt.
  2. Reads instructions.md and related documents to LDraw language and LEGO© models building.
  3. Plans how to build the model: required parts, submodels to be created, aesthetics...
  4. Iteratively:
    1. Renders images from the model/submodel(s)
    2. Inspects them, adjusts positioning, aesthetics... and back to rendering
  5. ... until it considers the model finished and ready to deliver!

Provided tooling helps the agent in:

  • Finding suitable parts.
  • Also, example models and submodels to start with.
  • Collision and gaps detection for placing parts correctly.
  • Headless rendering for inspecting current results.
  • and more...

The agent doesn't actually start with placing parts, except for things like e.g. prototyping and learning by altering pre-existing example models.

The way it produces models is more like:

  • Collects the required information, from experimental results, docs and planning.
  • Builds one or more plans, that fully describe the model and submodels, including its geometry, like e.g. atlas-crane.plan.json
  • And with that plan, it creates one or more generator scripts like e.g. generate.py
  • ... that when executed, produce LDraw source file(s), a very specialized 3D CAD language.
  • ... like e.g. atlas-crane.mpd

To summarize, this is like:

  • an agent creating a generator
  • ... that produces a 3D model
  • ... in an assembly language named LDraw 🤯

A compiler of sorts, so to say 🤓

flowchart TD
    agent([agent]) -- produces --> plan[plan.json]
    plan -- interpretation --> gen[generator.py]
    gen -- execution --> model[model.mpd]

Loading

Agent's informational sources

These are some of the guides and references given to the agent in order to make it a builder:

Being this a first release, there are quite some things that still require some work:

  • VR on Meta Quest 3: model handling has many issues, performance issues.
  • Adapt for low-end agents: adapt current tooling, docs and instructions in order to improve usage by low-end models like e.g. Luna, Haiku, etc.
  • Expensive generation: currently, only expensive, high-end models, are currently capable of generating large-sized and correct models.
  • Improve efficiency: generative process is currently slow.
  • Add and improve more model families:
    • Humans and animals: minifigs
    • Technic models: machines, engines...
    • Spaceships: generated models are not very good
  • Building models from manuals: it partially works, better if page manuals are given as images.
  • Fine-grained inspection: for inspecting submodels and their step-by-step building processes.

COMING SOON

I'd like to thank the following:

  • The LDraw Community
  • LDView's Travis Cobbs (@tcobbs), and contributors.
  • LeoCAD's Leonardo Zide (@leozide), and contributors.
  • LDCad and Shadow Library, Roland Melkert.
  • ldraw.rs's Park Joon-Kyu (@segfault87), and contributors.
  • pyldraw3's Harold Martin (@hbmartin), and contributors.

... and thanks to all of the many other LDraw creators!

NOTE: For this work, I've used many LDraw models, libraries, tools, docs... from many sources.

There is a lot amazing people that generously contributed to this, even for decades, by generously donating their finest work to the public domain and open source community.

If you think you should be included on this section, please drop me an email!

LEGO(R) is a trademark of the LEGO Group of companies which does not sponsor, authorize or endorse this software.

联系我们 contact @ memedata.com