商业产业 Hacker News AI 2026-10-02T20:00 正文 ok 1147 words

Show HN:开源 LEGO AI 生成器,可让 Agent 生成 LDraw 模型

英文标题:🔶 Show HN: Made an open-source Lego AI generator

开源项目 ldraw-nova 让 AI Agent 根据自然语言需求设计可拼搭的 LEGO 模型,并输出 LDraw 源代码、Blender 可编辑的 `.glb` 文件、渲染视图及 Agent 过程记录。项目通过 Python 生成器脚本规避 LLM 直接处理复杂几何计算的弱点:Agent 先制定模型计划,再生成脚本,最终产出 LDraw 3D CAD 模型。用于检索零件和示例模型的语义搜索依赖 TypeSafe 的 Jev System One 与 `jev-rerank`,没有 TypeSafe API key 时会降级为全文搜索,模型质量可能下降。作者表示,目前大型且正确的模型仍主要需要高端、昂贵的模型生成,VR、生成效率、低端模型适配等功能仍待完善。
打开原文相关 2 · 机会 2
media411.2 KB media94.1 KB

中文

向 AI Agent 提供一个模型创意。引导它,让它进行构建,最终获得一个 LDraw LEGO© 模型。

构建流程完成后,你将得到:

  • 其使用 LDraw 语言 编写的 源代码。
  • **不同视图:**3D 查看器、3D 播放器、VR 交互体验(Meta Quest 3)、图片等。
  • 可由 Blender 编辑的 glTF 文件,格式为 .glb,元信息保存在 Blender 的自定义属性中。
  • 聊天记录和 Agent 思考过程。
  • 以及更多内容……👌

请观看:视频:ldraw-nova 演示

视频缩略图

重要提示

Agent 用于查找 合适零件和示例模型的 工具,利用了 jev-rerank(作者也是我)。这是一款具备重排序能力的语义搜索工具,由 TypeSafe 的 Jev System One AI 模型提供支持。

  • 如果你有 TypeSafe API key(TYPESAFE_API_KEY),请在 Web 应用的 Settings 页面中设置其值。
  • 如果没有,重排序搜索将无法工作,Agent 将回退使用 FTS(全文搜索)策略,这可能会产生质量更差的模型。

使用 Docker 将 ldraw-nova 作为 Web 应用运行。你需要安装 Git 和 Docker。

该 Web 应用将在 Docker 容器中运行;构建 Docker 镜像需要两个同级仓库:

1. 克隆两个仓库,并将它们放在同一目录层级,使用相同 tag,以便二者协同工作:

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. 构建 Docker 镜像。首次构建需要较长时间,并且约需 5 GB 磁盘空间:

cd ldraw-nova-docker
docker compose build

3. 启动应用:

4. 在浏览器中打开:

  • https://localhost:8443:Meta Quest 3 的 VR 功能需要使用此地址。证书为自签名证书,因此首次访问时请接受浏览器警告。
  • http://localhost:8765:纯 HTTP,不会出现证书警告。如果自签名证书造成阻碍,请使用此地址。VR 无法通过该地址运行。

网络中的其他设备可通过你电脑的 IP 地址而非 localhost 访问该应用,例如在 Quest 3 上访问 https://192.168.1.20:8443。该应用没有登录机制,因此仅应在可信网络中运行。

如需停止:

简而言之:我开发这个项目,是为了获得能够设计可实际搭建的实体物品的 Agentic LLM!

我发现 LDraw 这种汇编语言(双关语!😜)既简单、低层级,又可以执行以生成 3D CAD 模型。这让我想到,尝试让 ChatGPT 和 Claude 像编写其他编程语言一样,尝试编写 LDraw 代码。

令我惊讶的是,尽管这种语言高度依赖数学(零件旋转、定位等),而 LLM 通常并不擅长此类问题,Agent 在初步测试中的表现却相当不错;后续项目也产出了良好结果,但始终还不够,无法认为生成的模型是正确的:

这三次尝试以及其他大量实验,让我得出了以下结论:

💡 结论 1:Agent 在处理几何数学时存在一条阻力最小路径,即:

  • 为 Agent 提供生成 LDraw 源码的工具,可以绕开(邪恶的!)几何数学;
  • ……因为它们更擅长生成能够产生数学计算结果的 Python 代码;
  • ……而不是自己直接产生数学计算结果!

💡 结论 2:

  • Agent 从能够生成模型的 Python 代码中学习时,表现往往更好;
  • ……相比之下,直接从模型本身学习效果较差(又是 LDraw 那邪恶的几何学……)。

那么,唯一剩下的事 🤔,就是创建一套基于 Python 的工具,其中包括所需的原语、动词、构造词汇等,让 Agent 能够通过示例学习,并自行完成类似工作。

事实证明,这件事即使通过氛围编程(vibe coding)也很难做好……直到 GPT-6 Astra 和 Claude Opus 5.5 到来……并通过氛围编程把它做好了!🚀🚀🚀

ldraw-nova 提供了 Agent 使用真实 LDraw 零件设计模型所需的工具、示例和说明。

流程如下:

  1. Agent 接收一个提示词。
  2. 阅读instructions.md 及与 LDraw 语言和 LEGO© 模型构建相关的文档。
  3. 规划如何构建模型:所需零件、需要创建的子模型、美学设计等。
  4. 迭代执行:
    1. 从模型或子模型渲染图像。
    2. 检查图像,调整定位、美学效果等,然后再次渲染。
  5. ……直到它认为模型已完成并可交付!

提供的工具可帮助 Agent:

  • 查找合适的零件。
  • 查找可作为起点的示例模型和子模型。
  • 进行碰撞与间隙检测,以便正确放置零件。
  • 进行无头渲染,以检查当前结果。
  • 以及更多功能……

Agent 实际上并不会一开始就放置零件,除非是例如通过修改现有示例模型进行原型开发和学习之类的情况。

它生成模型的方式更像是:

  • 从实验结果、文档和规划中收集所需信息。
  • 制定一个或多个计划,完整描述模型和子模型,包括其几何结构,例如 atlas-crane.plan.json。
  • 根据该计划,创建一个或多个生成器脚本,例如 generate.py。
  • ……这些脚本执行后会生成 LDraw 源文件,即一种高度专门化的3D CAD 语言。
  • ……例如 atlas-crane.mpd。

概括来说,这就像:

  • 一个 Agent 创建一个生成器;
  • ……该生成器产生一个 3D 模型;
  • ……模型采用名为 LDraw 的汇编语言表示。🤯

可以说,这是一种编译器 🤓

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

加载中

Agent 的信息来源

以下是提供给 Agent、以使其成为构建者的一些指南和参考资料:

作为首个版本,仍有不少事项需要继续改进:

  • Meta Quest 3 上的 VR:模型处理存在许多问题,也有性能问题。
  • **适配低端 Agent:**调整现有工具、文档和说明,以改善 Luna、Haiku 等低端模型的使用体验。
  • 生成成本高:目前,只有昂贵的高端模型能够生成大型且正确的模型。
  • **提升效率:**当前生成流程较慢。
  • 增加并改进更多模型类别:
    • 人类和动物:人仔(minifigs)。
    • Technic 模型:机器、引擎等。
    • 宇宙飞船:当前生成的模型质量并不理想。
  • **根据说明书构建模型:**该功能可部分运行;如果将分页说明书作为图像提供,效果更好。
  • **细粒度检查:**用于检查子模型及其逐步构建过程。

即将推出

我想向以下贡献者致谢:

  • LDraw 社区
  • LDView 的 Travis Cobbs(@tcobbs)及贡献者。
  • LeoCAD 的 Leonardo Zide(@leozide)及贡献者。
  • LDCad 和 Shadow Library,以及 Roland Melkert。
  • ldraw.rs 的 Park Joon-Kyu(@segfault87)及贡献者。
  • pyldraw3 的 Harold Martin(@hbmartin)及贡献者。

……也感谢所有其他众多 LDraw 创作者!

**注意:**在这项工作中,我使用了来自众多来源的大量 LDraw 模型、库、工具和文档等。

有许多杰出的人士,数十年来一直通过将他们最好的作品慷慨捐赠给公有领域和开源社区,为此作出了贡献。

如果你认为自己应被列入此部分,请给我发送电子邮件!

LEGO(R) 是 LEGO Group 公司的商标;该公司并未赞助、授权或认可本软件。

English / 原文

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.