← cad viewer

CAD viewer · #3

Parts panel, edge lines, and the CAD look

Second milestone shipped. The viewer at /viewer now does more than spin a mesh.

Parts panel

STEP files aren't just geometry — they carry product structure: solid names, assembly names, units. occt-import-js exposes the names per mesh, so the viewer now shows a parts panel with:

  • every solid in the file, by name (falling back to Part N for unnamed bodies)
  • per-part visibility toggles, plus hide-all/show-all
  • click a part name and the camera frames just that part — the cheap version of "zoom to selected" every CAD tool has

The assembly sample in the drop zone is a real multi-part file if you want to see it work.

Edge lines

A shaded mesh looks like a game asset; a shaded mesh with edge outlines looks like CAD. Each part now renders a THREE.EdgesGeometry overlay — line segments only where the surface bends past 30°, so smooth curves stay clean and hard edges pop:

const group = new THREE.Group();
group.add(solid);
group.add(new THREE.LineSegments(
  new THREE.EdgesGeometry(geometry, 30),
  edgeMaterial,
));
modelGroup.add(group);

The teal is deliberate.

One honest caveat: EdgesGeometry approximates edges from the triangle mesh, not from the B-rep. On coarse tessellations you can see edges where a "real" edge isn't — a tighter linearDeflection fixes it at the cost of more triangles. Proper B-rep edge extraction is on the long list.

Also in this release

  • IGES and BREP support — the OCCT binding reads all three formats; the viewer dispatches on extension
  • Sample files — three buttons in the drop zone so you can try it with no file handy
  • IGES sample exercises a different reader path entirely

Next up on the board: section plane (clipping along an axis — almost free in Three.js), then face picking using the brep_faces mapping OCCT returns.