AIFeed

面向 AI 智能体的 1.2 MB 纯 Rust 无头 Blender 重写版

Translation(model translation, not the source's own text)

标题:1.2 MB 纯 Rust 重写的无头 Blender,专为 AI 智能体打造

正文:

Forma

一个约 1.7 MB 原生 / 约 0.8 MB WASM 的纯 Rust 无头 3D 多面体建模引擎,专为 AI 智能体打造——提供 CLI、WASM 和 MCP 服务器。

Forma——专为 AI 智能体打造的纯 Rust 重写版无头 Blender
Forma——专为 AI 智能体打造的纯 Rust 重写版无头 Blender

Forma 用一个纯 Rust 二进制替代了无头 Blender 面向 AI 智能体的 3D 网格建模、布尔运算和工作室预览工作流——以紧凑的声明式管道语言(Forma-Pipe)、语义化边/面选择器、默认严格的流形 CSG 布尔运算、事务性快照以及内置的零 GPU 工作室渲染器,取代了 953 MB 的桌面技术栈和脆弱的 bpy 脚本。

指标原版无头 Blender 5.3(bpy)Forma提升
冷启动评估 + GLB 导出1,306.8 ms15.3 ms 8 模型套件(3.9 ms 批量法兰)约 77×–89× 更快
完成 Token 数(12 模型平均)总计 294,661总计 84,551少 3.49×(最高 15.5×)
通过率(12 模型 / 9 实验室)79.1%(bpy)95.5% – 100%+16.4 个百分点
二进制 / 安装体积953 MB约 1.7–1.8 MB 原生(约 0.8–0.99 MB WASM)约 530× 更小
峰值内存 RSS223 MB约 6–14 MB(6.1 MB macOS / 13.5 MB Linux)约 16×–36× 更少 RAM
MCP 工具 Schema 预算—900 o200k tokens(4 个工具,Native = WASM)融合单轮评估+输出[]

特性

  • 声明式 Forma-Pipe 语言:以语义化选择器(vertical、top_rim、bottom_rim、outer_rim、top、sides)干净地串联图元与操作(box | bevel | shell | cut)——零脆弱的整数顶点索引。
  • 快速、水密的纯 Rust 内核:双精度多面体网格内核(水密流形多边形/三角形)、BVH 局部化布尔运算并自动批量分块与多孔模式回退、Link-Condition 共面网格简化、保环倒角、壳/实体化、考虑折痕的 Catmull-Clark 细分曲面、pipe、loft(segs 8..128)、螺旋螺纹、sweep、text3d,以及 pattern_linear/pattern_radial。
  • 空间约束、查询与确定性工艺 Lint:关系式放置(| on(base)、| align(axis, min|center|max, val))、BVH 加速的 3D 间隙检测 clearance(a, b)、2D 截面 section(part, z) 环/面积查询、欧拉亏格(g)诊断,以及 forma lint / --critique / MCP inspect({ lint: true })(零 ML 权重的工艺检查 + 成对装配接触图:INTERSECTING、CONTACT、NEAR_GAP、DISJOINT;在干净构建上不产生额外 token)。
  • 零 GPU 渲染与蓝图:内置 4 视图(quad)或单视图(front|back|right|left|top|iso)工作室 PNG 渲染器,具备无分支 SSAO-lite + 深度轮廓 + L1 流式纯 Rust Deflate 压缩(约 2.8 ms 内生成约 20–75 KB PNG),外加带尺寸标注的 1200×900 矢量 SVG 技术蓝图(forma draw)。
  • 通用导入、简化与导出:纯 Rust 的 .glb(glTF 2.0 Y-up)、.obj 和 .stl 导入器(load("item.glb"))、保持拓扑的 QEM 网格简化(| decimate(0.5))、原生 .glb(PBR + LSCM/三平面 UV)、多面 ISO 10303-21 .step(水密平面面实体;无解析圆柱/NURBS)、.3mf、.stl、.obj、.svg、.png 和 .blend(通过可选的 Blender 桥接)。用 units("mm")(或 forma eval --unit mm;默认米)声明模型单位,.3mf/.step 会携带它,.glb 会缩放为米。
  • 可选无头服务器(forma-server):独立的可选 HTTP/1.1 worker crate(cargo build --release -p forma-server,紧凑静态二进制,< 5 MB 临时 Dockerfile),对核心 forma CLI、forma-mcp 或 forma-3d npm/WASM 包零影响。

快速开始

选项 1——通过 npm 零安装(跨平台 WASM)


        npx -y forma-3d eval --strict --out flange.glb --render flange.png --draw flange.svg <<'EOF'
flange = box(4, 2, 0.4)
  | mat("brushed_steel", color=(0.55, 0.68, 0.85), metallic=0.9, roughness=0.25)
  | cut(cyl(0.5, 1))
  | cut(cyl(0.25, 1), at=[(-1.4,-0.5,0), (-1.4,0.5,0), (1.4,-0.5,0), (1.4,0.5,0)])
section(flange, 0.0)
EOF
      

选项 2——构建原生 Rust 二进制(约 1.7–1.8 MB)


        git clone https://github.com/wrong-nebula/forma.git
cd forma
cargo build --release
./target/release/forma eval --strict --out flange.glb --render flange.png --draw flange.svg <<'EOF'
flange = box(4, 2, 0.4)
  | mat("brushed_steel", color=(0.55, 0.68, 0.85), metallic=0.9, roughness=0.25)
  | cut(cyl(0.5, 1))
  | cut(cyl(0.25, 1), at=[(-1.4,-0.5,0), (-1.4,0.5,0), (1.4,-0.5,0), (1.4,0.5,0)])
section(flange, 0.0)
EOF
      
内置纯 Rust 四视图工作室渲染
内置纯 Rust 四视图工作室渲染

面向 AI Agent

Forma 专为 Agent 直接使用而设计,支持通过 MCP、CLI、Agent Skills 或 GBNF 约束解码接入:

  • LLM Agent Skill:SKILL.md
  • 机器可读索引:llms.txt
  • 完整 Agent 集成指南:AGENTS.md
  • 约束解码语法:grammar/forma_pipe.gbnf(forma spec --gbnf)

MCP 服务器配置(forma-mcp / npx -p forma-3d forma-3d-mcp)

将 Forma 的 MCP 服务器(4 个工具:eval、inspect、tx、export —— 总计 900 o200k tokens,支持融合式 eval(out=[])、批量 export(paths=[])、命名视图、inspect(part/lint)、delta-first observe()、staleness sync:,以及可选的 --log JSONL 会话日志,覆盖原生与 WASM)添加到任意 MCP 客户端:


        {
  "mcpServers": {
    "forma": {
      "command": "npx",
      "args": ["-y", "-p", "forma-3d", "forma-3d-mcp"]
    }
  }
}
      

或直接从任何支持 shell 的 Agent 中调用:


        forma spec                                                # ~485-token language reference
forma eval --strict --critique --out out.glb script.forma # transactional eval + 0-tok clean critique
forma lint --json script.forma                            # Layer A geometric lint + contact graph
forma render --out preview.png script.forma               # 4-view studio PNG (~2.8 ms, zero GPU)
forma draw --out blueprint.svg script.forma               # dimensioned vector engineering blueprint
      

npm 包(forma-3d)

npm version
npm version

在 macOS、Linux、Windows 或 JavaScript/TypeScript 中,直接从 npm(npmjs.com/package/forma-3d)安装或运行 Forma 的零依赖 WebAssembly 引擎:


        npm install forma-3d          # JS/TS ESM + WASM library + CLI + MCP server
npx -y forma-3d eval --strict --out part.glb script.forma
npx -y -p forma-3d forma-3d-mcp  # stdio MCP server
      

        import { evalPipe, exportMesh, renderPng } from "forma-3d";

const obs = await evalPipe(`flange = box(4, 2, 0.4) | cut(cyl(0.5, 1))`, { strict: true });
const glb = await exportMesh(`flange = box(4, 2, 0.4) | cut(cyl(0.5, 1))`, "glb");
const png = await renderPng(`flange = box(4, 2, 0.4) | cut(cyl(0.5, 1))`, 512);
      

Forma 的运行环境(边缘、云端、Agent VM 与气隙沙箱)

由于 wasm/forma.wasm 是一个约 0.8 MB 的零导入 WebAssembly 模块(零 WASI、零顶层 node:* 导入),而静态 Linux 构建是约 1.3 MB 的 LTO musl 二进制文件(无 GPU,约 6–14 MB RAM),Forma 几乎可以在任何地方运行:

环境提供方 / 运行时运行方式
边缘与浏览器Cloudflare Workers、Vercel Edge、Netlify Edge、Deno Deploy、Supabase Edge Functions、Fastly Compute、Chrome/Safari/Firefox在 Cloudflare Workers 上零样板( workerd 自动导入 forma.wasm );其他环境使用 forma-3d/edge + forma-3d/forma.wasm (或 fetch() )
无服务器与容器AWS Lambda( x86_64 与 Graviton aarch64 )、ECS/Fargate、App Runner、Cloudflare Containers、Google Cloud Run、Fly.io、Azure、Railway、Render在 Node 运行时上 npm install forma-3d ,或使用静态 musl 二进制,或使用 < 5 MB 的 FROM scratch Dockerfile( forma-server )
Agent 虚拟机与 Notebookboat.dev 、Modal、E2B、Daytona、Google Colab、Kaggle、Codespaces、Gitpodnpx -y forma-3d 、 cargo build --release ,或静态 Linux 二进制
无网络沙箱ChatGPT VM(Code Interpreter / Custom GPTs)、气隙隔离的 AWS Lambda 与容器从 GitHub Releases 上传 forma-sandbox-linux-x86_64.zip (静态 forma + 零依赖 sandbox/forma.py + SKILL.md )

Cloudflare Workers / Edge / 浏览器

forma-3d 没有任何顶层 node:* 导入。在 Cloudflare Workers 上, workerd 导出条件会自动选择 lib/workerd.mjs (它会静态导入 ../wasm/forma.wasm ,以匹配 Wrangler 内置的 CompiledWasm 规则,并在 isolate 发生 trap 时自动恢复缓存的 WASM 实例):


        // Cloudflare Worker (zero boilerplate, no nodejs_compat required)
import { exportMesh } from "forma-3d";

export default {
  async fetch(req) {
    const glb = await exportMesh(await req.text(), "glb", { strict: true });
    return new Response(glb, { headers: { "content-type": "model/gltf-binary" } });
  },
};
      

        // Vercel Edge / Netlify Edge / Fastly (import ends in .wasm to match bundler rules)
import formaWasm from "forma-3d/forma.wasm";
import { exportMesh } from "forma-3d";
const glb = await exportMesh("a = box(1, 1, 1)", "glb", { wasm: formaWasm });

// Browser / Web Worker
import { loadForma } from "forma-3d/edge";
const engine = await loadForma(fetch("/forma.wasm"));
      

无网络沙箱(ChatGPT VM 与 AWS Lambda Python)

GitHub Releases 包含静态 x86_64-unknown-linux-musl 与 aarch64-unknown-linux-musl 二进制(forma CLI 与 forma-server),以及一个单文件离线套件(forma-sandbox-linux-x86_64.zip,内含 forma、sandbox/forma.py 与 SKILL.md)。当挂载在 noexec 卷(例如 ChatGPT VM 中的 /mnt/data)上时,sandbox/forma.py 会自动将二进制复制到 /tmp/forma 并执行 chmod +x:


        import sys, zipfile
zipfile.ZipFile("/mnt/data/forma-sandbox-linux-x86_64.zip").extractall("/tmp/forma_kit")
sys.path.insert(0, "/tmp/forma_kit")
import forma

print(forma.eval_pipe(
    "flange = box(4, 2, 0.4) | cut(cyl(0.5, 1))",
    out="/mnt/data/flange.glb",
    render="/mnt/data/flange.png",
))
      

文档

从文档中心(docs/README.md)开始,或直接跳转到某篇指南:

目标指南
逐步构建你的第一个水密 3D 零件教程:构建你的第一个水密 3D 零件
连接 Claude Code、Cursor、Codex、ChatGPT VM 或本地 LLM如何连接 AI agents(MCP、CLI、GBNF 与沙箱)
在 Node.js、Cloudflare Workers、Edge 或浏览器中嵌入 forma-3d如何在 JS、Edge 与浏览器中嵌入 forma-3d
部署 forma-server 、Docker、AWS Lambda 或离线沙箱如何部署 Forma(HTTP、Docker、云与沙箱)
以 mm / in 为单位创作,或修复并简化现有网格如何使用单位并处理现有网格
CLI 标志、退出码,以及原生与 WASM 的一致性参考:CLI( forma 与 forma-3d )
Forma-Pipe 、 Forma-DSL 、单位与格式矩阵参考:语言、单位与格式
MCP schema、JS/TS/Edge API,以及 HTTP 端点与限制参考:MCP、JS/TS/Edge 与 HTTP API
设计理念、6-crate 工作区与事务性内核为什么存在 Forma · 架构

基准测试

文章标题:1.2 MB 纯 Rust 重写的无头 Blender,专为 AI 智能体打造

正文: 所有模型均在原版无头 Blender 5.3.0(bpy)与 Forma(Forma-Pipe)上进行了头对头评估,覆盖 6 个跨类别精确尺寸任务(flange_plate、pipe_tee、beveled_enclosure、hex_nut、subdiv_mug、pedestal_bowl),并使用 trimesh + scipy 独立验证(Chamfer 距离、Hausdorff-99、广义缠绕数体积 IoU、水密/0 非流形检查,以及 16 层平面可切片性)。

12 模型基准测试结果:Forma 对比原版 Blender 5.3
12 模型基准测试结果:Forma 对比原版 Blender 5.3

1. 跨实验室结果 — 9 个实验室的 12 个模型(低推理)

模型bpy 通过率(P@1 / P@3)Forma 通过率(P@1 / P@3)bpy Token 数(API / Comp)Forma Token 数(API / Comp)bpy 平均 IoUForma 平均 IoUComp Token 缩减
anthropic/claude-opus-5.54/6 · 6/66/6 · 6/615,139 / 9,3336,140 / 7310.9730.98012.77×
anthropic/claude-haiku-5.54/6 · 5/63/6 · 6/6 *36,296 / 25,81518,159 / 8,4740.8070.9783.05×
google/gemini-4-neon4/6 · 6/65/6 · 6/628,447 / 20,86712,938 / 7,3880.9700.9742.82×
google/gemini-4-hydrogen3/6 · 5/65/6 · 6/627,794 / 18,29710,157 / 5,0200.8180.9893.64×
openai/gpt-6.2-astra4/6 · 6/64/6 · 6/69,914 / 5,7876,798 / 9500.9700.9786.09×
openai/gpt-6.2-sol4/6 · 6/64/6 · 6/610,333 / 6,2397,126 / 1,2430.9680.9725.02×
qwen/qwen4-max2/6 · 4/64/6 · 6/643,265 / 36,82719,161 / 12,1330.6510.9653.04×
z-ai/glm-5.45/6 · 6/63/6 · 6/69,380 / 6,15111,632 / 2,6960.9600.9852.28×
x-ai/grok-4.75/6 · 6/64/6 · 6/688,001 / 76,39730,024 / 14,5580.9660.9725.25×
deepseek/deepseek-v4.1-flash1/6 · 1/63/6 · 4/661,812 / 56,59937,825 / 29,1200.1670.6611.94×
tencent/hy4-flash ( none )1/6 · 1/63/6 · 5/652,799 / 22,07910,497 / 1,5740.1590.92414.03×
mistralai/mistral-large-4-0 †0/1 · 1/11/1 · 1/112,666 / 10,2701,331 / 6641.0001.00015.47×
汇总(67 组配对试验)55.2% · 79.1%67.2% · 95.5%395,846 / 294,661171,788 / 84,5510.7680.9443.49×

*在后续 v0.2+ 保留环的倒角修复后,claude-haiku-5.5 提升至 6/6(100%)Pass@1(10,920 API Token),且所有 4 个重新测试的模型均达到 24/24(100%)Pass@2(0.980 平均 IoU)。†在上游提供商返回 HTTP 400 之前完成了 1 个配对任务(flange_plate:1-shot Forma 对比 3 轮 bpy)。

2. 推理强度缩放(claude-haiku-5.5、gpt-6.2-sol、gemini-4-hydrogen、qwen4-max)

推理级别配对任务数bpy Pass@3Forma Pass@3bpy API / 成本Forma API / 成本bpy IoUForma IoU成本缩减
none1283.3%91.7%53,812 / $0.10022,453 / $0.0120.7920.9258.57×
low2483.3%100.0%117,688 / $0.40254,603 / $0.1320.8110.9763.05×
medium2483.3%100.0%178,275 / $0.69356,488 / $0.2020.8340.9753.44×
high2483.3%95.8%269,423 / $1.28580,107 / $0.3260.8640.9413.95×

3. 完整 12 任务套件汇总(4 个模型家族,144 次试验)

指标原版 Blender 5.3( bpy )Forma( Forma-Pipe )增益
Pass@1 / Pass@368.8% / 85.4%81.2% / 97.9%+12.5 pp
代码 Token 中位数( o200k )644115缩短 5.60×
平均体积 IoU0.84210.9814+0.1393
全部 12 个规范网格(构建 + .glb )~15,600 ms总计 61.2 ms( 5.1 ms/网格 )12/12 WT=ok NM=0
模糊测试与确定性—2.46 s 内 11,000 次操作( 0.22 ms/操作 )0 次 panic · 0 个 NaN · 字节级一致的 .glb

4. 智能体工作流与 100 场景多样化压力矩阵(原生 + WASM + trimesh)

文章标题:1.2 MB pure-Rust rewrite of headless Blender built for AI agents

正文: 在 100 个多样化的 3D 模型与装配体上验证,覆盖 um/mm/cm/in/m/ft 尺度、1–30 个零件、7 种导出格式和 7 个渲染视图(bench/stress_matrix_100.py):

指标基线(main)优化后提升
通过率与跨 ISA 一致性(Native = WASM = trimesh)—100 / 100 PASS0 失败,WT=ok NM=0
MCP 工具轮次中位数(100 个场景)6.01.0减少 5.0×(融合 eval(out=[]))
MCP 响应 Token 总数(100 个场景)172,71182,510-52.2%
大型场景(>=10 个零件,Token 中位数)5,5311,922-64.9%
增量编辑(delta-first observe(),中位数)609 tok166 tok-77.8%
单零件 inspect(part=...)(中位数)637 tok110 tok-82.4%
8 模型 CSG 内核套件(perf_bench,5 次运行中位数)24.11 ms15.25 ms快 1.58×(subdiv_mug 2.45×)
512×512 四视图工作室渲染(render_512px)4.67 ms2.81 ms快 1.66×(-39.8%)
Layer A forma lint(28 模型 Track D 套件)—0% FPR · 100% Recall干净 --critique 上 0 额外 Token

完整日志与方法论:docs/EXTENDED_BENCHMARK_REPORT.md · docs/VERIFICATION_REPORT.md · bench/results/stress_matrix_100.json。

贡献与路线图

欢迎贡献!从这里开始:

  • 贡献者指南:CONTRIBUTING.md — 构建/测试命令、crate 布局、不可妥协的二进制/Token/流形预算,以及设计评审流程。
  • 公开路线图:ROADMAP.md — 当前可用功能、计划中的核心改进、可选的零膨胀插件,以及配套应用的边界。
  • 蓝图与 RFC:contribute/ — forma-print(3D 打印 DFM 与多色 .3mf)、forma-ue(UE5 / OpenUSD)、craftsmanship 和 retopo 的详细规格。

许可证

GNU General Public License v3.0 or later(GPL-3.0-or-later)— 见 LICENSE。

The translation is machine-generated and individual terms may be off. Nothing is rewritten or cut; the original is authoritative.

Published by HN AI
This site only summarises and aggregates; copyright stays with the original author. Headlines and summaries follow the source — where they differ, the original wins.
Read the original ↗