Star 历史趋势
数据来源: GitHub API · 生成自 Stargazers.cn
README.md

Forma

A ~1.7 MB native / ~0.8 MB WASM pure-Rust headless 3D polyhedral modeling engine built for AI agents — CLI, WASM, and MCP server.

Forma — Pure-Rust Rewrite of Headless Blender for AI Agents

Forma replaces headless Blender's 3D mesh modeling, boolean, and studio-preview workflow for AI agents with a single pure-Rust binary—trading the 953 MB desktop stack and brittle bpy scripting for a compact declarative pipe language (Forma-Pipe), semantic edge/face selectors, strict-by-default manifold CSG booleans, transactional snapshots, and a built-in zero-GPU studio renderer.

MetricStock Headless Blender 5.3 (bpy)FormaImprovement
Cold-Start Eval + GLB Export1,306.8 ms16.9 ms (5.4 ms batch flange)~77×–89× faster
Completion Tokens (12-model avg)294,661 total84,551 total3.49× fewer (up to 15.5×)
Pass Rate (12 models / 9 labs)79.1% (bpy)95.5% – 100%+16.4 pp
Binary / Install Footprint953 MB~1.7–1.8 MB native (~0.8 MB WASM)~530× smaller
Peak Memory RSS223 MB~6–14 MB (6.1 MB macOS / 13.5 MB Linux)~16×–36× less RAM
MCP Tool Schema Budget—723 o200k tokens (4 tools)Strictly < 800

Features

  • Declarative Forma-Pipe Language: Chain primitives and ops cleanly (box | bevel | shell | cut) with semantic selectors (vertical, top_rim, bottom_rim, outer_rim, top, sides)—zero fragile integer vertex indices.
  • Fast, Watertight Pure-Rust Kernel: Double-precision polyhedral mesh kernel (watertight manifold polygons/triangles), BVH-localized booleans with automatic batch chunking & fallback for multi-hole patterns, Link-Condition coplanar mesh simplification, ring-preserving bevels, shell/solidify, crease-aware Catmull-Clark subsurf, pipe, loft (segs 8..128), helical thread, sweep, text3d, and pattern_linear/pattern_radial.
  • Spatial Constraints & Queries: Relational placement (| on(base), | align(axis, min|center|max, val)), exact 3D clearance(a, b), 2D section(part, z) loop/area queries, and Euler genus (g) diagnostics.
  • Zero-GPU Rendering & Blueprints: Built-in 4-view (Front / Right / Top / Iso) studio PNG renderer with SSAO-lite + depth silhouettes + pure-Rust Deflate compression (~20–75 KB PNG in ~4 ms), plus dimensioned 1200×900 vector SVG technical blueprints (forma draw).
  • Universal Import, Decimation & Export: Pure-Rust .glb (glTF 2.0 Y-up), .obj, and .stl importers (load("item.glb")), topology-preserving QEM mesh decimation (| decimate(0.5)), native .glb (PBR + LSCM/triplanar UVs), faceted ISO 10303-21 .step (watertight planar-face solid; no analytic cylinders/NURBS), .3mf, .stl, .obj, .svg, .png, and .blend (via optional Blender bridge). Declare your model unit with units("mm") (or forma eval --unit mm; default metres) and .3mf/.step carry it, .glb is scaled to metres.
  • Optional Headless Server (forma-server): Separate opt-in HTTP/1.1 worker crate (cargo build --release -p forma-server, compact static binary, < 5 MB scratch Dockerfile) with zero impact on the core forma CLI, forma-mcp, or forma-3d npm/WASM bundle.

Quickstart

Option 1 — Zero-Install via npm (Cross-Platform 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

Option 2 — Build Native Rust Binary (~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 script.forma

Built-In Pure-Rust 4-View Studio Renders


For AI Agents

Forma is designed for drop-in agent use via MCP, CLI, Agent Skills, or GBNF constrained decoding:

MCP Server Setup (forma-mcp / npx -p forma-3d forma-3d-mcp)

Add Forma's MCP server (4 tools: eval, inspect, tx, export — 723 o200k tokens total) to any MCP client:

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

Or invoke directly from any shell-capable agent:

forma spec                                       # ~485-token language reference
forma eval --strict --out out.glb script.forma   # transactional eval + ~100-tok spatial diff
forma render --out preview.png script.forma      # 4-view studio PNG (~4 ms, zero GPU)
forma draw --out blueprint.svg script.forma      # dimensioned vector engineering blueprint

npm Package (forma-3d)

npm version

Install or run Forma's zero-dependency WebAssembly engine directly from npm (npmjs.com/package/forma-3d) on macOS, Linux, Windows, or in JavaScript/TypeScript:

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);

Where Forma Runs (Edge, Cloud, Agent VMs & Air-Gapped Sandboxes)

Because wasm/forma.wasm is a ~0.8 MB zero-import WebAssembly module (zero WASI, zero top-level node:* imports) and the static Linux builds are ~1.3 MB LTO musl binaries (no GPU, ~6–14 MB RAM), Forma runs almost anywhere:

EnvironmentProviders / RuntimesHow to Run
Edge & BrowsersCloudflare Workers, Vercel Edge, Netlify Edge, Deno Deploy, Supabase Edge Functions, Fastly Compute, Chrome/Safari/FirefoxZero-boilerplate on Cloudflare Workers (workerd auto-imports forma.wasm); forma-3d/edge + forma-3d/forma.wasm (or fetch()) everywhere else
Serverless & ContainersAWS Lambda (x86_64 & Graviton aarch64), ECS/Fargate, App Runner, Cloudflare Containers, Google Cloud Run, Fly.io, Azure, Railway, Rendernpm install forma-3d on Node runtimes, static musl binary, or the < 5 MB FROM scratch Dockerfile (forma-server)
Agent VMs & Notebooksboat.dev, Modal, E2B, Daytona, Google Colab, Kaggle, Codespaces, Gitpodnpx -y forma-3d, cargo build --release, or static Linux binary
No-Network SandboxesChatGPT VM (Code Interpreter / Custom GPTs), air-gapped AWS Lambda & containersUpload forma-sandbox-linux-x86_64.zip from GitHub Releases (static forma + zero-dep sandbox/forma.py + SKILL.md)

Cloudflare Workers / Edge / Browsers

forma-3d has zero top-level node:* imports. On Cloudflare Workers, the workerd export condition automatically selects lib/workerd.mjs (which statically imports ../wasm/forma.wasm for Wrangler's built-in CompiledWasm rule and auto-recovers the cached WASM instance if an isolate ever traps):

// 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"));

No-Network Sandboxes (ChatGPT VM & AWS Lambda Python)

GitHub Releases include static x86_64-unknown-linux-musl and aarch64-unknown-linux-musl binaries (forma CLI and forma-server) plus a single-file offline kit (forma-sandbox-linux-x86_64.zip containing forma, sandbox/forma.py, and SKILL.md). sandbox/forma.py automatically copies the binary to /tmp/forma with chmod +x when mounted on a noexec volume (such as /mnt/data in ChatGPT's VM):

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",
))

Documentation

Start from the Documentation Hub (docs/README.md) or jump straight to a guide:

GoalGuide
Build your first watertight 3D part step by stepTutorial: Build your first watertight 3D part
Connect Claude Code, Cursor, Codex, ChatGPT VM, or local LLMsHow to connect AI agents (MCP, CLI, GBNF & Sandboxes)
Embed forma-3d in Node.js, Cloudflare Workers, Edge, or browsersHow to embed forma-3d in JS, Edge, and Browsers
Deploy forma-server, Docker, AWS Lambda, or offline sandboxesHow to deploy Forma (HTTP, Docker, Cloud & Sandboxes)
Author in mm/in or heal & decimate existing meshesHow to work with units and process existing meshes
CLI flags, exit codes, and native vs WASM parityReference: CLI (forma and forma-3d)
Forma-Pipe, Forma-DSL, units, and format matrixReference: Language, units, and formats
MCP schemas, JS/TS/Edge API, and HTTP endpoints & limitsReference: MCP, JS/TS/Edge, and HTTP APIs
Design rationale, 6-crate workspace, and transactional kernelWhy Forma exists · Architecture

Benchmarks

All models were evaluated head-to-head on stock headless Blender 5.3.0 (bpy) vs Forma (Forma-Pipe) across 6 cross-category exact-dimension tasks (flange_plate, pipe_tee, beveled_enclosure, hex_nut, subdiv_mug, pedestal_bowl), verified independently with trimesh + scipy (Chamfer distance, Hausdorff-99, Generalized Winding Number Volumetric IoU, watertight/0-non-manifold checks, and 16-layer planar sliceability).

12-Model Benchmark Results: Forma vs Stock Blender 5.3

1. Cross-Lab Results — 12 Models Across 9 Labs (low reasoning)

Modelbpy Pass (P@1 / P@3)Forma Pass (P@1 / P@3)bpy Tokens (API / Comp)Forma Tokens (API / Comp)bpy Mean IoUForma Mean IoUComp Token Reduction
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×
Aggregate (67 paired trials)55.2% · 79.1%67.2% · 95.5%395,846 / 294,661171,788 / 84,5510.7680.9443.49×

*On subsequent v0.2+ ring-preserving bevel fixes, claude-haiku-5.5 improved to 6/6 (100%) Pass@1 (10,920 API tokens) and all 4 re-tested models hit 24/24 (100%) Pass@2 (0.980 Mean IoU).
†Completed 1 paired task (flange_plate: 1-shot Forma vs 3-turn bpy) before upstream provider returned HTTP 400.

2. Reasoning-Effort Scaling (claude-haiku-5.5, gpt-6.2-sol, gemini-4-hydrogen, qwen4-max)

Reasoning LevelPaired Tasksbpy Pass@3Forma Pass@3bpy API / CostForma API / Costbpy IoUForma IoUCost Reduction
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. Full 12-Task Suite Summary (4 Model Families, 144 Trials)

MetricStock Blender 5.3 (bpy)Forma (Forma-Pipe)Gain
Pass@1 / Pass@368.8% / 85.4%81.2% / 97.9%+12.5 pp
Median Code Tokens (o200k)6441155.60× shorter
Mean Volumetric IoU0.84210.9814+0.1393
All 12 Canonical Meshes (build + .glb)~15,600 ms61.2 ms total (5.1 ms/mesh)12/12 WT=ok NM=0
Fuzz & Determinism—11,000 ops in 2.46 s (0.22 ms/op)0 panics · 0 NaNs · byte-identical .glb

Full logs and methodology: docs/EXTENDED_BENCHMARK_REPORT.md · docs/VERIFICATION_REPORT.md.


Contributing & Roadmap

Contributions are welcome! Start here:

  • Contributor Guide: CONTRIBUTING.md — build/test commands, crate layout, non-negotiable binary/token/manifold budgets, and design-review process.
  • Public Roadmap: ROADMAP.md — what works today, planned core improvements, opt-in zero-bloat addons, and companion-app boundaries.
  • Blueprints & RFCs: contribute/ — detailed specs for forma-print (3D printing DFM & multi-color .3mf), forma-ue (UE5 / OpenUSD), craftsmanship, and retopo.

License

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

关于 About

A 1.2 MB pure-Rust rewrite of headless Blender built for AI agents — 3D B-rep modeling engine, CLI, and MCP server
3d3mfai-agentscadgltfmcpruststep

语言 Languages

Rust63.6%
Python33.2%
JavaScript2.2%
Jupyter Notebook1.0%
Dockerfile0.1%

提交活跃度 Commit Activity

代码提交热力图
过去 52 周的开发活跃度
25
Total Commits
峰值: 25次/周
Less
More

核心贡献者 Contributors