/ concept-collection / mesh-studio
Sign in
concept-collection / mesh-studio
mesh-studio / README.md
82 lines · 3.4 KBPreviewCodeBlameHistoryRaw
1# mesh-studio
3A browser playground for **producing surface meshes with different tools and
4inspecting them interactively in 3D** ([three.js](https://threejs.org/)). This
5is a proof-of-concept; the first mesh-producing tool wired in is
6[OpenCASCADE.js](https://ocjs.org/) (the OCCT CAD kernel compiled to WebAssembly).
8Everything runs client-side — no server, no uploads.
10## What's interesting here
12CAD B-rep faces are not triangles: each face carries an underlying **NURBS
13(rational B-spline) surface** — a piecewise polynomial in two parameters. That
14is exactly the "high-order mesh / polynomials on faces" idea. mesh-studio
15extracts those polynomial patches (control points, weights, knots, degree)
16*alongside* the triangulation, so you can:
18- shade the tessellated surface, or view its **wireframe**;
19- see each face's **control net** (the polynomial's control polygon) and its
20 **isocurves** (constant-parameter curves sampled on the true surface);
21- drag a **resolution** slider to re-tessellate the same NURBS faces from
22 coarse-and-faceted to smooth;
23- click a face to read its **degree, pole count, knot structure** and whether it
24 is rational or purely polynomial.
26## Sources (v1)
28- **Built-in primitives** generated in-browser: sphere, torus, cylinder, cone,
29 box, rounded box (free-form fillet faces), and the classic OCCT "bottle".
30- **Random CAD model**: downloads a random real-world model from
31 [abc-step-1000](https://concept-collection.github.io/abc-step-1000/), a
32 rehosted slice of the [ABC dataset](https://deep-geometry.github.io/abc-dataset/)
33 of CAD models (Koch et al., CVPR 2019).
34- **STEP / IGES import**: open a `.step`/`.stp` or `.iges`/`.igs` file — OCCT
35 reads it natively.
37## Export
39- **OBJ / PLY / STL** — the current triangulation.
40- **NURBS patches (JSON)** — the polynomial-native representation (degrees,
41 poles, weights, knots per face).
42- **STEP** — the B-rep (original bytes for an imported file; re-written from the
43 kernel for primitives).
45## Internal model
47The internal representation is deliberately broader than a triangle mesh so more
48tools can plug in later. A `SurfaceModel` is a list of **patches**, and a patch
49is a discriminated union (`src/model/types.ts`). v1 emits `nurbs` patches (each
50carrying both a triangulation and the B-spline surface); `linear`, `lagrange`
51and `parametric` kinds are reserved growth points for future tools.
53## Develop
55```sh
56npm install
57npm run dev # http://localhost:5173
58npm run build # tsc -b && vite build (bundles the ~30 MB OCCT wasm as an asset)
59npm run lint
60```
62The OpenCASCADE runtime (~30 MB WASM) is loaded lazily on the first source
63action, not at page load.
65## Layout
67```
68src/
69 occ/ OpenCASCADE integration (all OCCT calls confined here)
70 loader.ts lazy singleton initOpenCascade({ mainWasm })
71 primitives.ts BRepPrimAPI shape builders + the tutorial bottle
72 importCad.ts STEP/IGES readers via Emscripten FS
73 exportCad.ts STEPControl_Writer
74 extract.ts shape -> SurfaceModel: BRepMesh triangulation + NURBS extraction
75 model/ types.ts (SurfaceModel/Patch) + tessellate.ts (pure geometry helpers)
76 render/ SurfaceView.tsx (plain three.js) + palette.ts
77 export/ meshWriters.ts (OBJ/PLY/STL) + nurbsJson.ts
78 sources.ts registry of built-in primitives
79 App.tsx sidebar UI + viewport
80```
82Part of the [concept-collection](https://github.com/concept-collection) org.
moveopenescclose