/ concept-collection / mesh-studio
Sign in
concept-collection / mesh-studio
mesh-studio / CLAUDE.md
3.9 KBPreviewCodeBlameHistoryRaw

CLAUDE.md#

Tips for future agents working in this repo.

Architecture#

src/occ/       ALL OpenCASCADE.js access lives here. The rest of the app never
               touches OCCT — it only sees the SurfaceModel from src/model.
  loader.ts      initOpenCascade({ mainWasm: wasmUrl }) once; wasm imported with
                 `?url` so Vite emits it as a static asset. Lazy on first use.
  primitives.ts  BRepPrimAPI_* builders returning TopoDS_Shape.
  importCad.ts   STEP/IGES via FS.createDataFile + STEPControl_Reader/IGESControl_Reader.
  exportCad.ts   STEPControl_Writer -> bytes.
  extract.ts     shape -> SurfaceModel. Runs BRepMesh (triangulation, always) and
                 BRepBuilderAPI_NurbsConvert + Geom_BSplineSurface reads (per-face,
                 best-effort). retessellate() re-meshes at a new quality reusing NURBS.
src/model/     types.ts: SurfaceModel = list of Patch (discriminated union).
               v1 emits `nurbs` patches. tessellate.ts: pure geometry helpers
               (modelBounds, controlNet, mergeTriMeshes) — no three, no OCCT.
src/render/    SurfaceView.tsx: plain three.js, one mesh per patch (for picking),
               modes shaded/wire/net/iso. palette.ts: per-face colors.
src/export/    meshWriters.ts (OBJ/PLY/STL, dependency-free), nurbsJson.ts.
src/App.tsx    sidebar + viewport; keeps the OpenCascade instance and the
               (NURBS-converted) mesh shape in refs for re-tessellation.
src/abcDataset.ts  "Random CAD model" source: fetches index.json from
               https://concept-collection.github.io/abc-step-1000/ (first 1000
               ABC-dataset STEP files, gzip-served), picks a random file ≤2 MB,
               gunzips via DecompressionStream, hands bytes to importCadFile.

Key gotchas#

Verification#

Browser is the real verification surface (WASM). npm run build confirms TS + bundling (including the OCCT wasm asset). Then npm run dev and:

Not yet deployed to the org Pages site (same procedure as mesh-converter / mesh-pde-solver when ready).

moveopenescclose