← cad viewer

CAD viewer · #11

STL and OBJ: the mesh-mode tradeoffs

The viewer now accepts .stl and .obj alongside STEP/IGES/BREP — there's a tetrahedron STL sample button if you want to try it. Loading was the easy half: STLLoader and OBJLoader run on the main thread (no OCCT, no worker), and a small refactor extracted displayMeshes() so both paths feed the same part/edge/section pipeline.

What a mesh file doesn't have

STEP gives you topology — named solids, B-rep faces, edges that exist as curves. STL gives you triangle soup; OBJ gives you soup with materials. Everything the viewer does that depends on structure has to degrade deliberately:

STEP / IGES / BREP

B-rep topology

  • Parts panelnamed solids
  • Edge linesface-boundary chains
  • Face pickingB-rep faces
  • Edge lengthchain polylines
  • Section capsmesh-level fill
  • Measurementstwo-point

STL / OBJ

triangle soup

  • Parts panelone entry per mesh
  • Edge linesangle heuristic
  • Face pickingno B-rep data
  • Edge lengthno topology
  • Section capsmesh-level anyway
  • Measurementstwo-point

✓ works◦ degraded✕ unavailable

The map is the honest version of the feature: a mesh file puts the viewer in mesh mode, and the UI says so rather than silently doing nothing ("edge length needs B-rep topology" beats a dead click).

Why bother

STL is everywhere a STEP file isn't — 3D printing, scan output, simulation meshes. A viewer that refuses mesh files refuses the format half the internet actually sends around. And the honest split is itself the product decision: B-rep features light up when the data supports them and degrade with an explanation when it doesn't — the alternative is pretending a soup of triangles has faces.

The pipeline, final form

Five formats, two ingest paths, one display path:

step/iges/brep → worker → OCCT WASM → meshes + faces + edge chains ┐
stl/obj        → main thread → three loaders → meshes             ┴→ displayMeshes

This is the last item on the original roadmap — section caps, edge measurement, mesh formats all shipped today. The viewer went from "load a file and spin it" to a genuinely useful inspection tool in eleven posts.