Skip to navigation
3D Generation from STL Files — Working Notes
31.10.26
# 3D Generation from STL Files — Working Notes ## 1. LLM vs 3D generative model - An LLM trains on **text tokens**. STL files are geometry — not usable for an LLM. - What you can build from 300k STLs is a **3D generative model**. - If you want an "LLM" angle: caption each STL, then fine-tune a language model on the captions — a text model *about* the models, not a model of geometry. ## 2. STL basics - **Point / vertex** — one `(x, y, z)` coordinate. - **Triangle / face** — three vertices connected; the surface tile. - **Facet** — STL's word for one triangle (normal + 3 vertices). Facet ≡ triangle in STL. - **Mesh** — thousands of triangles stitched edge-to-edge. - STL stores geometry only: no colour, no units, no construction history. ``` facet normal 0 0 1 outer loop vertex 0 0 0 vertex 1 0 0 vertex 0 1 0 endloop endfacet ``` ## 3. Why triangles - Always planar (3 points define a plane; a quad can bend). - Can be split/joined without changing the surface. - Simple math for normals, lighting, hit-testing. - GPUs draw triangles natively. ## 4. Triangle count - Binary STL: `(file size − 84) / 50` = triangles (84-byte header + 50 bytes per triangle). - ASCII STL: `grep -c "facet normal" file.stl`. - `len(trimesh.load("x.stl").faces)`. - `admesh` prints `Number of facets`. - MeshLab / Blender / f3d show it in the UI. ## 5. More triangles? - Tradeoff, not "more is better". - Too few → visible faceting (bad for jewelry). - Enough → smooth at printer resolution. - Too many → bigger files, slower slicing, no visible gain, messier meshes. - Ceiling = output resolution: FDM ~0.4 mm nozzle / 0.1–0.2 mm layers; resin ~25–50 µm pixels. - Prefer **adaptive** tessellation and clean topology. ## 6. Repair: admesh vs trimesh - **admesh** — C CLI, STL-focused: fixes normals, fills holes, drops unconnected/degenerate facets, prints edge stats. GPL-2.0, in Debian. - **trimesh** — Python, broader: same repairs (`fix_normals`, `fill_holes`, `remove_degenerate_faces`, `process`) + formats, transforms, sampling, booleans, scenes. MIT. - For 300k files, drive with trimesh; admesh as pre-clean/fallback. ## 7. Pipeline 1. **Audit** — parse check (binary/ASCII, header, triangle count), dedupe (vertex hash + render hash), watertightness (each edge shared by 2 triangles), scale outliers (bbox histogram), degenerates (zero-area, duplicates, flipped normals). 2. **Normalize** — load with trimesh, merge vertices, fix winding, centre at bbox centre, scale max extent = 1, canonical orientation (PCA or fixed up-axis), export one format. 3. **Representation** — choose point cloud / voxel-SDF / multi-view / mesh tokens. 4. **Train / fine-tune** — fine-tune an open base model, don't train from zero. 5. **Evaluate** — sample generations, check domain fit. ## 8. Representations - **Point cloud** (easiest): `mesh.sample(20000)` → `(N, 3)` tensor (+ normals optional) → `.npy`/`.npz`/`.ply`. Loses connectivity; re-mesh with Poisson. - **Voxel / SDF grid**: 64³ or 128³ occupancy or signed distance. Heavier, smoother. - **Multi-view renders**: 12–24 turntable views per STL → image→3D models. Reuses pretrained models. - **Mesh tokens**: serialise triangles into tokens (MeshGPT). Needs a custom tokenizer. Hardest. ## 9. Free / open base models - Point-E (OpenAI) — MIT — point clouds - Shap-E (OpenAI) — MIT — implicit → mesh - TRELLIS (Microsoft) — MIT — mesh/3D assets - TripoSR (Stability AI + Tripo) — MIT — image → 3D - InstantMesh — Apache-2.0 — image → mesh - One-2-3-45 — MIT — image → 3D - Zero123 / Zero123-XL — MIT — image → novel views - LGM — open — gaussian splats - Hunyuan3D (Tencent) — free weights, community license - Stable Fast 3D — free weights, Stability community license Commercial, not open: Meshy, Tripo, Rodin. ## 10. Practical notes - You don't need to be a 3D/jewelry designer: audit/normalize is a script over all 300k, not manual work. - Preview by sampling: headless thumbnails (trimesh + pyrender, `f3d --output`) into a grid; outliers pop out. - Fix by rule, log failures — don't hand-fix. - 300k STLs is a real dataset; quality (watertight, manifold, consistent orientation) matters more than count. - GPU cost: point clouds ≪ voxels ≪ mesh tokens. ## 11. Open-source stack - OpenSCAD (GPL) — parametric CAD - admesh (GPL) — STL repair - trimesh (MIT) — batch audit/normalize/sampling - pymeshlab / MeshLab (GPL) — repair/inspection - Open3D (MIT) — programmatic viewer/processing - f3d — fast STL viewer - PrusaSlicer / Cura / Bambu Studio — print preview - Blender — visual/rendered look ## Bottom line Start with **point clouds**, fine-tune **Point-E / Shap-E / TRELLIS**, and put the effort into **audit + normalize** — that is where the dataset's value lives.
Reply
Anonymous
Information Epoch 1793785834
Solving the next 5% probably costs more than the previous 90%.
Home
Notebook
Contact us