brepkit-wasm 2.129.15 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,273 @@
1
+ <div align="center">
2
+
3
+ # brepkit
4
+
5
+ Solid modeling kernel for Rust and WebAssembly.
6
+
7
+ [![CI](https://github.com/andymai/brepkit/actions/workflows/ci.yml/badge.svg)](https://github.com/andymai/brepkit/actions/workflows/ci.yml)
8
+ [![crates.io](https://img.shields.io/crates/v/brepkit-operations?label=crates.io)](https://crates.io/crates/brepkit-operations)
9
+ [![npm](https://img.shields.io/npm/v/brepkit-wasm)](https://www.npmjs.com/package/brepkit-wasm)
10
+ [![Last release](https://img.shields.io/github/release-date/andymai/brepkit?label=last%20release)](https://github.com/andymai/brepkit/releases)
11
+ [![Commit activity](https://img.shields.io/github/commit-activity/m/andymai/brepkit?label=commits%2Fmonth)](https://github.com/andymai/brepkit/commits/main)
12
+ [![License: AGPL-3.0-only or commercial](https://img.shields.io/badge/License-AGPL--3.0%20%2F%20Commercial-blue.svg)](#license)
13
+ [![Rust 1.88+](https://img.shields.io/badge/rust-1.88%2B-orange.svg)](https://www.rust-lang.org/) [![unsafe denied](https://img.shields.io/badge/unsafe-denied-success.svg)](#why-a-cad-kernel)
14
+
15
+ **[Architecture](#architecture)** · **[Performance](#performance)** · **[Getting Started](#getting-started)** · **[Known Limitations](#known-limitations)** · **[Stability](./STABILITY.md)** · **[Contributing](./CONTRIBUTING.md)**
16
+
17
+ </div>
18
+
19
+ One exact-geometry engine, from Rust and from JavaScript. Cut a solid, measure it, export it.
20
+
21
+ ```rust
22
+ use brepkit_operations::primitives::{make_box, make_cylinder};
23
+ use brepkit_operations::boolean::{boolean, BooleanOp};
24
+ use brepkit_operations::measure::solid_volume;
25
+ use brepkit_io::step::write_step;
26
+ use brepkit_topology::Topology;
27
+
28
+ let mut topo = Topology::new();
29
+
30
+ // Primitives are anchored at the origin, so this cylinder rounds off the
31
+ // block's corner. Use `transform_solid` to place it somewhere else.
32
+ let block = make_box(&mut topo, 30.0, 20.0, 10.0)?;
33
+ let cutter = make_cylinder(&mut topo, 5.0, 15.0)?;
34
+ let notched = boolean(&mut topo, BooleanOp::Cut, block, cutter)?;
35
+
36
+ // Measure and export
37
+ let vol = solid_volume(&topo, notched, 0.1)?;
38
+ let step = write_step(&topo, &[notched])?;
39
+ ```
40
+
41
+ ```js
42
+ import { BrepKernel } from 'brepkit-wasm';
43
+
44
+ const kernel = new BrepKernel();
45
+
46
+ // Primitives are anchored at the origin, so this cylinder rounds off the
47
+ // block's corner. Use `transformSolid` to place it somewhere else.
48
+ const block = kernel.makeBox(30, 20, 10);
49
+ const cutter = kernel.makeCylinder(5, 15);
50
+ const notched = kernel.cut(block, cutter);
51
+
52
+ // Measure and export
53
+ const vol = kernel.volume(notched, 0.1);
54
+ const step = kernel.exportStep(notched); // Uint8Array
55
+ ```
56
+
57
+ ## Why a CAD kernel?
58
+
59
+ brepkit is a B-Rep solid modeling kernel written from scratch in Rust. It targets WebAssembly, so the same kernel runs in the browser and on the desktop. `unsafe` is denied by lint, as are `unwrap` and `panic`. Every public operation returns a `Result`.
60
+
61
+ It grew out of building [gridfinitylayouttool.com](https://gridfinitylayouttool.com), where the options for parametric CAD in the browser were proprietary or compiled from large C++ codebases.
62
+
63
+ The geometry is exact. Booleans run on analytic and NURBS surfaces and keep those surfaces through the operation, so a cylinder stays a cylinder instead of becoming a bag of triangles. That keeps face counts low and round-trips lossless.
64
+
65
+ ## Status
66
+
67
+ brepkit is in active development. Core modeling is solid. Each feature below is marked stable, beta, planned, or experimental, and [Known Limitations](#known-limitations) covers the gaps.
68
+
69
+ The table below rates *features*. For *API* stability per crate, and what the shared `2.x` version does and does not promise, see [STABILITY.md](./STABILITY.md).
70
+
71
+ | Category | Feature | Status |
72
+ | ----------------------- | ---------------------------------------------------------------------------- | ------------ |
73
+ | **Primitives** | Box, cylinder, cone, sphere, torus, ellipsoid | Stable |
74
+ | **Primitives** | Convex hull, Minkowski sum (convex inputs) | Stable |
75
+ | **Booleans** | Union, cut, intersect on plane, cylinder, cone, sphere, NURBS | Stable |
76
+ | **Booleans** | Batch fuse-all (disjoint-aware union) | Stable |
77
+ | **Booleans** | Torus booleans (box ± torus, coaxial torus) | Beta |
78
+ | **Modifiers** | Fillet (constant + variable radius), chamfer (walking engine) | Stable |
79
+ | **Modifiers** | Shell (hollow solid) | Stable |
80
+ | **Modifiers** | Offset face, offset solid, thicken, mirror, pattern | Stable |
81
+ | **Modifiers** | Draft (planar faces) | Beta |
82
+ | **Sweeps** | Extrude (planar + NURBS profiles) | Stable |
83
+ | **Sweeps** | Revolve, sweep, loft, pipe (planar profiles) | Stable |
84
+ | **Sweeps** | Helical sweep | Stable |
85
+ | **Sweeps** | Non-planar profiles for loft, sweep, pipe, revolve | Beta |
86
+ | **Construction** | Coons-patch face fill, sew, untrim | Stable |
87
+ | **Sectioning** | Cross-section faces, split by plane | Stable |
88
+ | **Measurement** | Bounding box, area, volume, center of mass | Stable |
89
+ | **Measurement** | Point-to-solid, solid-to-solid distance, point classification | Stable |
90
+ | **Drawing** | Hidden-line edge projection | Stable |
91
+ | **Geometry** | NURBS evaluation, derivatives, knot ops, fitting, projection | Stable |
92
+ | **Geometry** | Analytic intersections (plane × cylinder, cone, sphere exact; torus sampled) | Stable |
93
+ | **Geometry** | Surface-surface intersection (analytic + marching) | Stable |
94
+ | **Geometry** | Curve-curve intersection (Bezier clipping) | Stable |
95
+ | **Tessellation** | Adaptive deflection, CDT, analytic-surface optimization | Stable |
96
+ | **Repair** | Shape healing (wire, face, shell fixes), sewing, validation | Stable |
97
+ | **I/O** | STEP import/export (analytic-preserving round-trip) | Stable |
98
+ | **I/O** | STL, 3MF, OBJ, PLY, glTF (`.glb`) import/export | Stable |
99
+ | **I/O** | IGES import/export | Experimental |
100
+ | **Sketching** | 2D constraint solver (DogLeg) | Stable |
101
+ | **Feature Recognition** | Holes, pockets, chamfers, fillets | Beta |
102
+ | **Assemblies** | Hierarchy, transforms, bill of materials | Beta |
103
+ | **Evolution** | Face provenance through booleans | Beta |
104
+ | **Defeaturing** | Remove planar faces | Beta |
105
+ | **Rendering** | Offscreen wgpu render to image plus face-id buffer (`brepkit-render`) | Experimental |
106
+
107
+ ## Known Limitations
108
+
109
+ A few areas are still maturing. Worth knowing before you build on them:
110
+
111
+ - **Boolean fallback.** Most booleans run on an exact path that preserves analytic and NURBS surfaces. Hard configurations fall back to a mesh-based boolean: coincident-face contact, coaxial analytic surfaces, razor-thin geometry, or very high face counts. The fallback returns a usable, non-degenerate solid, but it tessellates the curved faces and is not guaranteed watertight.
112
+ - **Torus booleans.** Box-with-torus and coaxial-torus cases work and give correct volumes. General torus-to-torus and torus-with-other-surface intersections have known gaps and may fall back to meshing.
113
+ - **Non-planar profiles.** Loft, sweep, and pipe accept profiles with non-planar surfaces, and close non-planar section boundaries with bilinear caps for four-sided rings (boundaries with more than four edges, or holes on a non-planar section, are not yet supported). Revolve accepts non-planar profile surfaces; a full revolution takes any boundary, but a partial revolution still requires a planar boundary for its caps. The smooth, scaled/guided, and multi-section sweep variants accept non-planar profiles too; only the miter-corner variant still requires planar profiles (its bisector-plane joint faces would otherwise be non-planar).
114
+ - **IGES is experimental.** Export writes planar and NURBS surfaces but skips analytic surfaces and approximates circular and elliptical edges as polylines. Import reconstructs planar placeholder faces only. Use STEP for B-Rep exchange.
115
+ - **Inertia tensor.** Volume, area, bounding box, and center of mass are computed for any solid. A full inertia tensor exists only as closed-form formulas for analytic primitives and is not exposed through the modeling or WASM API.
116
+ - **Beta subsystems.** Feature recognition, assemblies, evolution tracking, and defeaturing work but are still maturing. Defeaturing handles planar faces only.
117
+
118
+ ## Scope
119
+
120
+ brepkit deliberately does not:
121
+
122
+ - **Bundle a viewport into the kernel.** The core emits exact geometry and tessellated meshes; camera, lighting, and shading belong to the caller (Three.js and the like). The optional `brepkit-render` crate provides offscreen wgpu rendering with a face-id buffer, for tests and headless verification, and is not required by any core operation.
123
+ - **Plan toolpaths or slice.** Export STEP, STL, or 3MF and pass the output to a CAM tool or slicer.
124
+ - **Model with meshes.** The kernel operates on exact B-Rep geometry. Subdivision surfaces, polygon meshes, and voxels are out of scope.
125
+ - **Provide a GUI.** brepkit is a library. Building a UI around it, like [gridfinitylayouttool.com](https://gridfinitylayouttool.com), is the application's job.
126
+ - **Simulate physics.** Measurement (volume, area, center of mass) is included. Stress analysis, collision detection, and dynamics are not.
127
+
128
+ ## Architecture
129
+
130
+ Layered Cargo workspace. Each crate depends only on the same or lower layers, and CI enforces the boundaries.
131
+
132
+ | Layer | Crate | What it does |
133
+ | ----- | -------------------- | --------------------------------------------------------------------------------------------------- |
134
+ | L0 | `brepkit-math` | Points, vectors, matrices, NURBS curves and surfaces, geometric predicates, CDT, convex hull |
135
+ | L1 | `brepkit-geometry` | Curve sampling (uniform, deflection, arc-length, curvature), extrema, analytic-to-NURBS conversion |
136
+ | L1 | `brepkit-topology` | Arena-allocated B-Rep: vertex, edge, wire, face, shell, solid, with an edge-to-face adjacency index |
137
+ | L2 | `brepkit-algo` | General Fuse boolean engine: pave filler, face classification, solid assembly |
138
+ | L2 | `brepkit-blend` | Walking-based fillet and chamfer with constant, variable, and custom radius laws |
139
+ | L2 | `brepkit-heal` | Shape healing: analysis, fixing, upgrading, sewing, tolerance management, configurable pipeline |
140
+ | L2 | `brepkit-check` | Point classification, validation, properties (volume, area, center of mass), distance |
141
+ | L2 | `brepkit-offset` | Solid offset and thickening via global face-face intersection |
142
+ | L2 | `brepkit-sketch` | 2D parametric constraint solver (GCS) using a DogLeg trust-region method |
143
+ | L3 | `brepkit-operations` | Booleans, fillet, chamfer, extrude, revolve, sweep, loft, shell, offset, measure, tessellation |
144
+ | L3 | `brepkit-io` | Import and export: STEP, IGES, STL, 3MF, OBJ, PLY, glTF |
145
+ | L4 | `brepkit-wasm` | JavaScript API via wasm-bindgen, with batch execution and checkpoint/restore |
146
+ | L4 | `brepkit-render` | Offscreen wgpu rendering to a color image plus a face-id buffer. Optional, nothing depends on it |
147
+
148
+ ## Performance
149
+
150
+ Median times from the [brepjs benchmark suite](https://github.com/andymai/brepjs/tree/main/benchmarks) (5 iterations, Node.js, Linux x86_64). WASM is single-threaded. Native benchmarks use criterion.
151
+
152
+ | Operation | brepkit (WASM) | OCCT (WASM) | Speedup | brepkit (native) |
153
+ | ------------------------ | -------------- | ----------- | ------- | ---------------- |
154
+ | fuse(box, box) (×10) | 0.5 ms | 43.7 ms | 87x | 122 µs |
155
+ | cut(box, cylinder) (×10) | 28.3 ms | 64.3 ms | 2.3x | 9.3 ms |
156
+ | box + chamfer | 0.2 ms | 5.4 ms | 27x | 46 µs |
157
+ | box + fillet | 0.3 ms | 6.2 ms | 21x | 127 µs |
158
+ | intersect(box, sphere) (×10) | 0.6 ms | 69.6 ms | 117x | 98 µs |
159
+ | multi-boolean (16 holes) | 4.7 ms | 30.1 ms | 6.4x | 2.8 ms |
160
+ | mesh sphere (tol=0.01) | 7.1 ms | 51.9 ms | 7.3x | 6.0 ms |
161
+ | volume (box) (×100) | 0.18 ms | 8.3 ms | 47x | 56 µs |
162
+ | exportSTEP (×10) | 0.9 ms | 14.3 ms | 16x | n/a |
163
+
164
+ Every quoted row is output-verified before timing is compared: fuse, chamfer, and sphere volumes match exactly; cut, fillet, and multi-boolean volumes agree within 0.004%; the intersect result matches the closed-form spherical-octant volume (pinned by a regression test). The sphere mesh densities are comparable at equal tolerance (9,800 triangles vs 10,176).
165
+
166
+ Booleans preserve analytic surfaces, so face counts stay low across chained operations. A nine-step compound boolean settles at 72 faces while a mesh-based approach would reach roughly 7,000. The same holds for blends: a straight edge filleted between two planar faces keeps an exact cylindrical wall rather than a NURBS approximation of one.
167
+
168
+ > The OCCT comparison uses [occt-wasm](https://www.npmjs.com/package/occt-wasm), an OpenCASCADE build compiled to WebAssembly. Both kernels run single-threaded in Node.js. Boolean and `exportSTEP` rows are timed as batches of ten operations. WASM figures are medians of `kernel-comparison.bench.test.ts` (5 iterations) against a local `cargo xtask wasm-build` package, hash-verified at the require path. Native figures: `cargo bench -p brepkit-operations --bench cad_operations`, except the mesh-sphere row, which is measured at the same parameters as the WASM row (`tessellate_solid_with_tolerance`, deflection 0.01, angular 0.1 rad) via `crates/operations/examples/perf_probe.rs` — the criterion suite's sphere case meshes per-face and is not comparable. Full benchmark source: [brepjs/benchmarks](https://github.com/andymai/brepjs/tree/main/benchmarks). Boolean and measurement rows measured 2026-08-07 on the released 2.129.13/2.129.14 packages (npm tarball overlay, hash-verified at the require path); the remaining rows are the 2026-08-06 measurements on brepkit main post-2.129.8.
169
+
170
+ ## Data Exchange
171
+
172
+ | Format | Type | Import | Export |
173
+ | ------------- | ----- | ------- | ------ |
174
+ | STEP | B-Rep | ✓ | ✓ |
175
+ | STL | Mesh | ✓ | ✓ |
176
+ | 3MF | Mesh | ✓ | ✓ |
177
+ | OBJ | Mesh | ✓ | ✓ |
178
+ | PLY | Mesh | ✓\* | ✓ |
179
+ | glTF (`.glb`) | Mesh | ✓ | ✓ |
180
+ | IGES | B-Rep | preview | lossy |
181
+
182
+ STEP preserves exact geometry on round-trip. Analytic surfaces (plane, cylinder, cone, sphere, torus) are written as native STEP surface entities rather than tessellated, and they read back to the same surface types. NURBS surfaces are preserved too, as are line, circle, ellipse, and NURBS edges.
183
+
184
+ Mesh formats export tessellated triangles. glTF is binary `.glb`, with no materials or scene graph. IGES is experimental, as described in [Known Limitations](#known-limitations).
185
+
186
+ \* PLY import is available in the Rust crate but is not yet exposed in the WASM API.
187
+
188
+ ## Getting Started
189
+
190
+ The Rust crates require Rust 1.88 or newer. The WASM package has no toolchain requirement.
191
+
192
+ ### As a WASM package
193
+
194
+ ```bash
195
+ npm install brepkit-wasm
196
+ ```
197
+
198
+ ```js
199
+ import { BrepKernel } from 'brepkit-wasm';
200
+
201
+ const kernel = new BrepKernel();
202
+ const solid = kernel.makeBox(10, 20, 30);
203
+ ```
204
+
205
+ For a higher-level TypeScript API, see [brepjs](https://github.com/andymai/brepjs).
206
+
207
+ ### As a Rust dependency
208
+
209
+ Requires Rust 1.88 or newer.
210
+
211
+ ```bash
212
+ cargo add brepkit-topology brepkit-operations
213
+ cargo add brepkit-io # optional: STEP, STL, 3MF, OBJ, PLY, glTF
214
+ ```
215
+
216
+ `brepkit-operations` is the entry point for modeling. It pulls in the geometry,
217
+ topology, and algorithm crates it needs, so most projects want it plus
218
+ `brepkit-topology`, which owns the `Topology` arena that every operation takes.
219
+ Add `brepkit-io` for import and export.
220
+
221
+ Every crate publishes at the same version from the same commit, so a single
222
+ minor line works across all of them. To depend on something more specific, the
223
+ [Architecture](#architecture) table lists what each crate does, and
224
+ [STABILITY.md](./STABILITY.md) says which are meant to be depended on directly.
225
+
226
+ ### Building from source
227
+
228
+ Requires Rust 1.88 or newer.
229
+
230
+ ```bash
231
+ cargo build --workspace
232
+ cargo test --workspace
233
+ cargo clippy --all-targets -- -D warnings
234
+ cargo fmt --all
235
+
236
+ # WASM (with I/O)
237
+ cargo build -p brepkit-wasm --target wasm32-unknown-unknown --release
238
+
239
+ # WASM (smaller, no I/O)
240
+ cargo build -p brepkit-wasm --target wasm32-unknown-unknown --release --no-default-features
241
+
242
+ # API docs
243
+ cargo doc --workspace --no-deps --open
244
+ ```
245
+
246
+ ## Roadmap
247
+
248
+ Broad directions, no dates.
249
+
250
+ - **Boolean robustness.** Harden torus and mixed-surface booleans, and shrink the set of inputs that fall back to meshing.
251
+ - **Sweep generalization.** Extend non-planar profile support to the miter-corner sweep, to section boundaries with more than four edges, and to partial revolutions with non-planar boundaries.
252
+ - **Parallel tessellation in WASM.** Native builds already parallelize per-face meshing. Bring it to the WASM target via threads.
253
+ - **Assembly metadata.** Colors, layers, materials, and PMI for richer data exchange.
254
+ - **Lossless IGES.** Real B-Rep import and analytic-surface export.
255
+ - **Documentation.** API reference, tutorials, and architectural guides.
256
+
257
+ ## Projects Using brepkit
258
+
259
+ - [brepjs](https://github.com/andymai/brepjs), CAD modeling for JavaScript.
260
+ - [Gridfinity Layout Tool](https://github.com/andymai/gridfinity-layout-tool), a web-based Gridfinity storage layout generator.
261
+
262
+ [Open a PR](https://github.com/andymai/brepkit/pulls) to add your project.
263
+
264
+ ## License
265
+
266
+ brepkit is dual-licensed:
267
+
268
+ - **[AGPL-3.0-only](./LICENSE)**: free for open-source use. You may use, modify, and redistribute brepkit, provided applications and network services built on it also make their source available under the AGPL.
269
+ - **[Commercial license](./COMMERCIAL-LICENSE.md)**: for embedding brepkit in proprietary products, sold by Collective Context, LLC. Contact [hi@andymai.com](mailto:hi@andymai.com).
270
+
271
+ Versions through 2.129.x were published under MIT OR Apache-2.0 and remain available under those terms. Versions 3.0.0 and later are AGPL-3.0-only with a commercial option.
272
+
273
+ Contributions require a signed [CLA](./.github/CLA.md); see [CONTRIBUTING](./CONTRIBUTING.md).
@@ -5202,13 +5202,13 @@ export function __wbg___wbindgen_debug_string_c25d447a39f5578f(arg0, arg1) {
5202
5202
  export function __wbg___wbindgen_throw_344f42d3211c4765(arg0, arg1) {
5203
5203
  throw new Error(getStringFromWasm0(arg0, arg1));
5204
5204
  }
5205
- export function __wbg_error_f6b8042e6c3f6107(arg0, arg1) {
5205
+ export function __wbg_error_b87951a6b006ac50(arg0, arg1) {
5206
5206
  console.error(getStringFromWasm0(arg0, arg1));
5207
5207
  }
5208
- export function __wbg_log_a6a8bfa44e097947(arg0, arg1) {
5208
+ export function __wbg_log_63743db7238c93da(arg0, arg1) {
5209
5209
  console.log(getStringFromWasm0(arg0, arg1));
5210
5210
  }
5211
- export function __wbg_warn_6fb310e4782b750d(arg0, arg1) {
5211
+ export function __wbg_warn_86afbbe8a5f6547a(arg0, arg1) {
5212
5212
  console.warn(getStringFromWasm0(arg0, arg1));
5213
5213
  }
5214
5214
  export function __wbindgen_cast_0000000000000001(arg0, arg1) {
Binary file
@@ -5216,13 +5216,13 @@ function __wbg_get_imports() {
5216
5216
  __wbg___wbindgen_throw_344f42d3211c4765: function(arg0, arg1) {
5217
5217
  throw new Error(getStringFromWasm0(arg0, arg1));
5218
5218
  },
5219
- __wbg_error_f6b8042e6c3f6107: function(arg0, arg1) {
5219
+ __wbg_error_b87951a6b006ac50: function(arg0, arg1) {
5220
5220
  console.error(getStringFromWasm0(arg0, arg1));
5221
5221
  },
5222
- __wbg_log_a6a8bfa44e097947: function(arg0, arg1) {
5222
+ __wbg_log_63743db7238c93da: function(arg0, arg1) {
5223
5223
  console.log(getStringFromWasm0(arg0, arg1));
5224
5224
  },
5225
- __wbg_warn_6fb310e4782b750d: function(arg0, arg1) {
5225
+ __wbg_warn_86afbbe8a5f6547a: function(arg0, arg1) {
5226
5226
  console.warn(getStringFromWasm0(arg0, arg1));
5227
5227
  },
5228
5228
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
package/package.json CHANGED
@@ -2,11 +2,11 @@
2
2
  "name": "brepkit-wasm",
3
3
  "type": "module",
4
4
  "description": "WebAssembly bindings for brepkit — browser-native B-Rep solid modeling",
5
- "version": "2.129.15",
6
- "license": "MIT OR Apache-2.0",
5
+ "version": "3.0.0",
6
+ "license": "AGPL-3.0-only",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/andymai/brepkit.git"
9
+ "url": "https://github.com/andymai/brepkit"
10
10
  },
11
11
  "files": [
12
12
  "brepkit_wasm_bg.wasm",
@@ -16,6 +16,7 @@
16
16
  "brepkit_wasm_node.cjs"
17
17
  ],
18
18
  "main": "brepkit_wasm_node.cjs",
19
+ "homepage": "https://github.com/andymai/brepkit",
19
20
  "types": "brepkit_wasm.d.ts",
20
21
  "sideEffects": [
21
22
  "./brepkit_wasm.js",