@tweakcad/occt-wasm 0.0.0-stage → 5.16.0-tweakcad.1

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 CHANGED
@@ -1,3 +1,518 @@
1
- # Temporary Holding Version
1
+ <div align="center">
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ # occt-wasm
4
+
5
+ [![npm](https://img.shields.io/npm/v/occt-wasm)](https://www.npmjs.com/package/occt-wasm)
6
+ [![Crates.io](https://img.shields.io/crates/v/occt-wasm.svg)](https://crates.io/crates/occt-wasm)
7
+ [![CI](https://github.com/andymai/occt-wasm/actions/workflows/ci.yml/badge.svg)](https://github.com/andymai/occt-wasm/actions/workflows/ci.yml)
8
+ [![Last release](https://img.shields.io/github/release-date/andymai/occt-wasm?label=last%20release)](https://github.com/andymai/occt-wasm/releases)
9
+ [![Commit activity](https://img.shields.io/github/commit-activity/m/andymai/occt-wasm?label=commits%2Fmonth)](https://github.com/andymai/occt-wasm/commits/main)
10
+ [![License](https://img.shields.io/badge/tooling-MIT%20OR%20Apache--2.0-blue.svg)](#license) [![WASM License](https://img.shields.io/badge/wasm%20output-LGPL--2.1--only-blue.svg)](#license)
11
+
12
+ [OpenCascade](https://github.com/Open-Cascade-SAS/OCCT) V8 compiled to WebAssembly with a clean TypeScript API.
13
+
14
+ Smaller bundles, branded types, arena-based memory, and modern tooling.
15
+
16
+ </div>
17
+
18
+ > **Looking for a higher-level CAD library?** [brepjs](https://github.com/andymai/brepjs) builds on occt-wasm with a friendlier API for parametric modeling, sketching, and production CAD applications. Use occt-wasm directly when you need full control over OCCT operations.
19
+
20
+ ## Highlights
21
+
22
+ - **~4.5 MB brotli** -- roughly 2x smaller than opencascade.js
23
+ - **Comprehensive API** -- primitives, booleans, sweeps, XCAF assemblies, curves, surfaces, STEP/STL/glTF/BREP I/O, topology, shape evolution tracking
24
+ - **Arena-based API** -- u32 shape handles, no manual `.delete()`, `Symbol.dispose` support
25
+ - **TypeScript-first** -- branded `ShapeHandle`, union types for shapes/surfaces/curves, structured returns
26
+ - **Structured error handling** -- `OcctErrorCode` enum for programmatic `switch/case` instead of string parsing
27
+ - **Web Worker support** -- `OcctWorker` class for off-main-thread CAD operations via [Comlink](https://github.com/GoogleChromeLabs/comlink)
28
+ - **Modern browser targets** -- WASM SIMD, tail calls, wasm-exceptions
29
+
30
+ ## Scope
31
+
32
+ To set expectations, this library deliberately does not:
33
+
34
+ - **Provide a higher-level CAD modeling API** — parametric sketching, constraints, feature trees, and ergonomic modeling belong in [brepjs](https://github.com/andymai/brepjs), which wraps occt-wasm for that purpose
35
+ - **Manage memory automatically beyond arena handles** — shapes are freed when the kernel is disposed or you call `release()`; there is no per-shape garbage collection
36
+ - **Support non-WASM-SIMD browsers** — the build requires WASM SIMD (baseline `-msimd128`), tail calls, and wasm exceptions, so it needs a recent engine (see [Browser Compatibility](#browser-compatibility)). Relaxed-SIMD is intentionally not used: some Safari/iOS WebKit builds fail to compile relaxed-SIMD modules, and it made geometry non-reproducible across CPUs
37
+ - **Include OCCT visualization or display modules** — TKV3d, TKHLR (except the HLR facade), and the AIS interactive context are excluded; bring your own renderer (Three.js, Babylon.js, etc.)
38
+ - **Support IGES import/export** -- TKDEIGES is excluded from the link; use STEP for interchange
39
+
40
+ ## Install
41
+
42
+ ```bash
43
+ npm install occt-wasm
44
+ ```
45
+
46
+ ## Quick Start
47
+
48
+ ```typescript check
49
+ import { OcctKernel } from "occt-wasm";
50
+
51
+ // Recommended: deterministic cleanup via Symbol.dispose
52
+ {
53
+ using kernel = await OcctKernel.init();
54
+
55
+ // Primitives
56
+ const box = kernel.makeBox(20, 20, 20);
57
+ const cyl = kernel.makeCylinder(8, 30);
58
+
59
+ // Modeling -- fillet takes a solid, so round the box before combining
60
+ const edges = kernel.getSubShapes(box, "edge");
61
+ const filleted = kernel.fillet(box, edges.slice(0, 4), 2.0);
62
+
63
+ // Booleans
64
+ const fused = kernel.fuse(filleted, cyl);
65
+
66
+ // Tessellation -> Three.js / Babylon.js
67
+ const mesh = kernel.tessellate(fused);
68
+ // mesh.positions (Float32Array), mesh.normals, mesh.indices
69
+
70
+ // Edge overlay that shares vertices with that mesh (falls back to
71
+ // curve sampling for edges that were never meshed)
72
+ const outline = kernel.wireframe(fused, { source: "triangulation" });
73
+
74
+ // STEP I/O
75
+ const step = kernel.exportStep(fused);
76
+ const reimported = kernel.importStep(step);
77
+
78
+ // Query
79
+ const vol = kernel.getVolume(fused);
80
+ const bbox = kernel.getBoundingBox(fused);
81
+ const com = kernel.getCenterOfMass(fused);
82
+
83
+ // kernel is disposed at end of block
84
+ }
85
+ ```
86
+
87
+ > **Boolean results are compounds.** OCCT's `BRepAlgoAPI` operations wrap their
88
+ > output in a `TopoDS_Compound` — a boolean can produce several disjoint solids.
89
+ > The operations that downcast to a solid (`fillet`, `chamfer`, `filletVariable`,
90
+ > `filletBatch`, `healSolid`) reject one, so unwrap first:
91
+ >
92
+ > ```typescript check kernel,fused
93
+ > const [solid] = kernel.getSubShapes(fused, "solid");
94
+ > if (!solid) throw new Error("boolean produced no solid");
95
+ > ```
96
+ >
97
+ > **Not every edge is filletable.** Seam and degenerate edges are not, so on a
98
+ > shape you didn't build yourself, select edges by geometry rather than by index.
99
+ > The `slice(0, 4)` above is safe only because all 12 edges of a plain box round
100
+ > cleanly — on the box-plus-cylinder fusion, only 13 of 20 edges do.
101
+
102
+ ## Rust Crate
103
+
104
+ The same OCCT WASM is available as a [Rust crate](https://crates.io/crates/occt-wasm) for native targets (servers, CLIs, build scripts) — no C++ toolchain required:
105
+
106
+ ```toml
107
+ [dependencies]
108
+ occt-wasm = "7"
109
+ ```
110
+
111
+ ```rust
112
+ use occt_wasm::OcctKernel;
113
+
114
+ let mut kernel = OcctKernel::new()?;
115
+ let box_shape = kernel.make_box(10.0, 20.0, 30.0)?;
116
+ let sphere = kernel.make_sphere(8.0)?;
117
+ let fused = kernel.fuse(box_shape, sphere)?;
118
+ let mesh = kernel.tessellate(fused, 0.1, 0.5)?;
119
+ let step = kernel.export_step(fused)?;
120
+ ```
121
+
122
+ The crate embeds a brotli-compressed WASM binary (~4.7 MB) and runs it via [wasmtime](https://wasmtime.dev/). Same 170+ facade methods as the TS API. See [`crate/README.md`](./crate/README.md) and [docs.rs/occt-wasm](https://docs.rs/occt-wasm) for full details.
123
+
124
+ ## Initialization
125
+
126
+ By default, `OcctKernel.init()` auto-locates the `.wasm` file next to the JS module. You can also provide explicit paths or pre-loaded binaries:
127
+
128
+ ```typescript check
129
+ import { OcctKernel } from "occt-wasm";
130
+
131
+ // Auto-detect (browser, Node.js, or Worker):
132
+ const kernel = await OcctKernel.init();
133
+
134
+ // ...or point at an explicit URL / path:
135
+ await OcctKernel.init({ wasm: "/assets/occt-wasm.wasm" });
136
+
137
+ // ...or hand over a pre-fetched binary, skipping the fetch:
138
+ const binary = await fetch("/occt-wasm.wasm").then((r) => r.arrayBuffer());
139
+ await OcctKernel.init({ wasm: binary });
140
+ await OcctKernel.init({ wasm: new Uint8Array(binary) });
141
+
142
+ // ...or pass the Emscripten glue you loaded yourself, for hosts where init()'s
143
+ // own import of ./occt-wasm.js cannot resolve (e.g. a bundled Web Worker):
144
+ const glueUrl: string = "/occt/occt-wasm.js";
145
+ const { default: createModule } = await import(/* webpackIgnore: true */ glueUrl);
146
+ await OcctKernel.init({ createModule, wasm: "/occt/occt-wasm.wasm" });
147
+ ```
148
+
149
+ ## Error Handling
150
+
151
+ All errors are instances of `OcctError` with a structured `code` field for programmatic handling:
152
+
153
+ ```typescript check kernel,a,b
154
+ import { OcctError, OcctErrorCode } from "occt-wasm";
155
+
156
+ try {
157
+ kernel.fuse(a, b);
158
+ } catch (e) {
159
+ if (e instanceof OcctError) {
160
+ switch (e.code) {
161
+ case OcctErrorCode.BooleanFailed:
162
+ // retry with simpler geometry
163
+ break;
164
+ case OcctErrorCode.InvalidShapeId:
165
+ // shape was already released
166
+ break;
167
+ case OcctErrorCode.KernelError:
168
+ // OCCT internal error (Standard_Failure)
169
+ console.error(e.message);
170
+ break;
171
+ }
172
+ }
173
+ }
174
+ ```
175
+
176
+ Available error codes:
177
+
178
+ | Code | When |
179
+ | -------------------- | ----------------------------------------------- |
180
+ | `ConstructionFailed` | `Build()`/`IsDone()` returned false |
181
+ | `BooleanFailed` | Boolean operation (fuse/cut/common/etc.) failed |
182
+ | `InvalidShapeId` | Shape ID not found in the arena |
183
+ | `InvalidLabelId` | XCAF label ID not found |
184
+ | `TessellationFailed` | Meshing operation failed |
185
+ | `ImportExportFailed` | STEP/STL/BREP I/O error |
186
+ | `HealingFailed` | Shape repair failed |
187
+ | `DocumentClosed` | Operation on a closed XCAF document |
188
+ | `KernelError` | OCCT `Standard_Failure` (unclassified) |
189
+ | `Unknown` | Error from outside the kernel |
190
+
191
+ A fillet or chamfer that OCCT cannot build also sets `faultyEdges` to the edges, as passed in, whose contour failed. The raw message carries the same list as a ` [faulty edges: 3,7]` suffix.
192
+
193
+ ```typescript check kernel,a
194
+ import { OcctError } from "occt-wasm";
195
+
196
+ const edges = kernel.getSubShapes(a, "edge");
197
+ try {
198
+ kernel.fillet(a, edges, 3);
199
+ } catch (e) {
200
+ if (e instanceof OcctError && e.faultyEdges) {
201
+ // retry without e.faultyEdges, or with a smaller radius on them
202
+ }
203
+ }
204
+ ```
205
+
206
+ > **`OcctWorker` is the exception.** Comlink serializes a thrown error down to
207
+ > `{ message, name, stack }`, so an error crossing the worker boundary arrives
208
+ > as a plain `Error`: the message survives intact, but `code`, `operation`, and
209
+ > `instanceof OcctError` do not. Match on `e.message` there, or do the
210
+ > `switch (e.code)` inside the worker.
211
+
212
+ ## Named Enums
213
+
214
+ Sweep, offset, and boolean operations use self-documenting enums instead of opaque numbers:
215
+
216
+ ```typescript check kernel,profile,spine,wire,shape,face,base,tool1,tool2
217
+ import { TransitionMode, JoinType, BooleanOp, BooleanGlue } from "occt-wasm";
218
+
219
+ // Sweep with round-corner transitions
220
+ kernel.sweep(profile, spine, TransitionMode.RoundCorner);
221
+
222
+ // Offset wire with arc joins
223
+ kernel.offsetWire2D(wire, 2.0, JoinType.Arc);
224
+
225
+ // Hollow a solid through one face; Intersection keeps the inner corners
226
+ // at concave edges sharp where Arc would round them
227
+ kernel.shell(shape, [face], 2.0, 1e-6, JoinType.Intersection);
228
+
229
+ // Boolean pipeline
230
+ kernel.booleanPipeline(base, [BooleanOp.Cut, BooleanOp.Fuse], [tool1, tool2]);
231
+
232
+ // One boolean against several tools, glued where the operands share faces
233
+ kernel.booleanOp(BooleanOp.Fuse, [base], [tool1, tool2], { glue: BooleanGlue.Shift });
234
+ ```
235
+
236
+ Numeric values (0, 1, 2) are still accepted for backwards compatibility.
237
+
238
+ ## Type Predicates
239
+
240
+ Convenience methods for checking shape topology:
241
+
242
+ ```typescript check kernel,shape
243
+ if (kernel.isSolid(shape)) {
244
+ /* ... */
245
+ }
246
+ if (kernel.isFace(shape)) {
247
+ /* ... */
248
+ }
249
+ if (kernel.isEdge(shape)) {
250
+ /* ... */
251
+ }
252
+ if (kernel.isWire(shape)) {
253
+ /* ... */
254
+ }
255
+ if (kernel.isVertex(shape)) {
256
+ /* ... */
257
+ }
258
+ if (kernel.isShell(shape)) {
259
+ /* ... */
260
+ }
261
+ if (kernel.isCompound(shape)) {
262
+ /* ... */
263
+ }
264
+ ```
265
+
266
+ ## Web Workers
267
+
268
+ For browser apps, heavy CAD operations can block the main thread. `OcctWorker` runs a full kernel in a Web Worker with the same API:
269
+
270
+ ```typescript check edge
271
+ import { OcctWorker } from "occt-wasm/worker";
272
+
273
+ // Spawn a worker with its own kernel
274
+ const worker = await OcctWorker.spawn({ wasm: "/occt-wasm.wasm" });
275
+
276
+ // Same API, every call returns a Promise
277
+ const box = await worker.makeBox(10, 20, 30);
278
+ const cyl = await worker.makeCylinder(5, 40);
279
+ const fused = await worker.fuse(box, cyl);
280
+ const mesh = await worker.tessellate(fused);
281
+ console.log(`${mesh.triangleCount} triangles`);
282
+
283
+ // Access the full kernel via .kernel for less common methods
284
+ const nurbs = await worker.kernel.getNurbsCurveData(edge);
285
+
286
+ // Clean up
287
+ worker.terminate();
288
+ ```
289
+
290
+ The worker helper uses [Comlink](https://github.com/GoogleChromeLabs/comlink) (~1.2 KB gzipped) for transparent RPC. Each worker has its own WASM instance and arena -- shape handles are local to the worker.
291
+
292
+ ## XCAF Assemblies
293
+
294
+ Create assembly documents with colors, names, and component hierarchies. Colors are sRGB components in [0, 1], as in CSS (`#808080` is `128 / 255`), and names may be any Unicode text:
295
+
296
+ ```typescript check kernel,box,gear,stepData
297
+ // Factory method auto-injects Emscripten FS for glTF export
298
+ const doc = kernel.createXCAFDocument();
299
+
300
+ const housing = doc.addShape(box, { name: "housing", color: [0.8, 0.2, 0.1] });
301
+ doc.addChild(housing, gear, {
302
+ name: "gear-1",
303
+ location: { tx: 10, tz: 5 },
304
+ color: [0.5, 0.5, 0.5],
305
+ });
306
+
307
+ // Export
308
+ const step = doc.exportSTEP(); // preserves colors/names
309
+ const stepInches = doc.exportSTEP({ unit: "inch" }); // same geometry, written in inches
310
+ const stepAp242 = doc.exportSTEP({ schema: "AP242" }); // AP203, AP214 (default) or AP242
311
+ const glb = doc.exportGLTF(); // binary glTF (.glb) bytes
312
+ doc.close();
313
+
314
+ // Import with preserved metadata
315
+ const imported = kernel.importXCAFFromSTEP(stepData);
316
+ ```
317
+
318
+ Walking an imported assembly: each component is a placed reference to a prototype label (a part or sub-assembly). Resolve it with `getReferredLabel` to reach the prototype's name, named sub-shapes and children. To author the same structure, add a compound with `doc.addShape(compound, { assembly: true })`.
319
+
320
+ ```typescript check doc
321
+ import type { LabelTag } from "occt-wasm";
322
+
323
+ function walk(label: LabelTag, depth = 0): void {
324
+ const info = doc.getLabelInfo(label);
325
+ console.log(`${" ".repeat(depth)}${info.name}`);
326
+ const proto = doc.getReferredLabel(label) ?? label;
327
+ for (const sub of doc.getSubShapes(proto)) {
328
+ console.log(`${" ".repeat(depth + 1)}(${doc.getLabelInfo(sub).name})`);
329
+ }
330
+ for (const child of doc.getChildren(proto)) walk(child, depth + 1);
331
+ }
332
+ for (const root of doc.getRoots()) walk(root);
333
+ ```
334
+
335
+ `getLocation(label)` returns a component's placement as a 3x4 matrix in the layout `kernel.transform` accepts, so a prototype's geometry can be tessellated once and instanced per component.
336
+
337
+ ## Bundler Configuration
338
+
339
+ ### Vite
340
+
341
+ ```typescript
342
+ // vite.config.ts
343
+ export default defineConfig({
344
+ optimizeDeps: {
345
+ exclude: ["occt-wasm"], // Don't pre-bundle WASM
346
+ },
347
+ build: {
348
+ target: "esnext", // Required for WASM features
349
+ },
350
+ });
351
+ ```
352
+
353
+ ### Webpack 5
354
+
355
+ ```javascript
356
+ // webpack.config.js
357
+ module.exports = {
358
+ experiments: { asyncWebAssembly: true },
359
+ module: {
360
+ rules: [{ test: /\.wasm$/, type: "asset/resource" }],
361
+ },
362
+ };
363
+ ```
364
+
365
+ Webpack bundles the Emscripten glue and emits `occt-wasm.wasm` as a hashed
366
+ asset, rewriting the URL it is loaded from. No manual copy step is needed, and
367
+ `OcctKernel.init()` finds the binary without a `wasm` option.
368
+
369
+ ### Next.js
370
+
371
+ No configuration needed, under either Turbopack or webpack. Both emit the
372
+ `.wasm` into `_next/static` and rewrite the URL. Initialize from a client
373
+ component (`"use client"`) so the kernel loads in the browser rather than
374
+ during SSR:
375
+
376
+ ```javascript
377
+ "use client";
378
+ import { useEffect } from "react";
379
+
380
+ export default function Viewer() {
381
+ useEffect(() => {
382
+ (async () => {
383
+ const { OcctKernel } = await import("occt-wasm");
384
+ const kernel = await OcctKernel.init();
385
+ // ...
386
+ })();
387
+ }, []);
388
+ }
389
+ ```
390
+
391
+ ### Node.js
392
+
393
+ ```typescript check
394
+ // Works out of the box with Node.js 18+
395
+ import { OcctKernel } from "occt-wasm";
396
+ const kernel = await OcctKernel.init();
397
+ ```
398
+
399
+ ## API Reference
400
+
401
+ Generate full docs locally: `cd ts && npm run docs` (TypeDoc output).
402
+
403
+ | Category | What's covered |
404
+ | ---------------- | -------------------------------------------------------------------------------------------------------------- |
405
+ | **Primitives** | Box, cylinder, sphere, cone, torus, ellipsoid, rectangle, half-space |
406
+ | **Booleans** | Fuse, cut, common, intersect, section (by shape or plane) + multi-shape variants, intersection cells |
407
+ | **Modeling** | Extrude, revolve, fillet and chamfer (per-edge radii/distances, tapered fillets), shell, offset, multi-face draft |
408
+ | **Sweeps** | Pipe, loft, sweep, oriented sweep (fixed/Frenet/up-axis/auxiliary), draft prism, extrusion laws |
409
+ | **Construction** | Vertices, edges (line/arc/circle/ellipse/bezier/helix), wires, faces, solids, compounds, sewing |
410
+ | **Transforms** | Translate, rotate, scale, mirror, align to bounding box, 3x4 matrix, linear/circular patterns |
411
+ | **Topology** | Shape type queries, type predicates, sub-shape extraction, adjacency, hash codes |
412
+ | **Tessellation** | Triangle meshes (absolute or relative deflection), wireframe polylines (curve-sampled or mesh-aligned), per-face groups, batched meshing |
413
+ | **I/O** | STEP (choice of length unit and AP203/AP214/AP242 protocol), STL (ASCII + binary), BREP (text + binary) import/export |
414
+ | **Query** | Bounding box, volume, surface area, length, center of mass, inertia tensor, point-in-solid, curvature |
415
+ | **Surfaces** | Type, exact parameters, normal, UV bounds, point classification, B-spline construction |
416
+ | **Curves** | Type, exact parameters, point/tangent eval, parameters, NURBS data, interpolation (incl. clamped tangents), project point |
417
+ | **Projection** | Hidden line removal (HLR), multiview SVG render (Front/Top/Right/Iso) |
418
+ | **Modifiers** | Thicken, defeature, reverse, simplify, variable fillet, 2D wire offset |
419
+ | **Evolution** | Face and edge history for extrude, revolve, pipe, sweep, loft, fuse, cut, fillet, chamfer, draft, shell, offset, thicken, unify, and the transforms |
420
+ | **XCAF** | Assembly documents with colors, names, component hierarchies, STEP/glTF export |
421
+ | **Healing** | Fix shape, unify domain, heal solid/face/wire, fix orientations, remove degenerate edges |
422
+ | **Batch** | Multi-shape translate, chained boolean pipeline |
423
+
424
+ ## Architecture
425
+
426
+ ```
427
+ OCCT V8.0.1 C++ (git submodule)
428
+ -> emcmake cmake (static libs)
429
+ -> C++ facade (OcctKernel class, arena-based u32 IDs)
430
+ -> Embind bindings
431
+ -> emcc link (-O3, -flto, -fwasm-exceptions, SIMD) -> .wasm
432
+ -> wasm-opt -O4 --converge --gufa -> dist/
433
+ ```
434
+
435
+ Built with Rust xtask (`cargo xtask build`), tested with Vitest.
436
+
437
+ ## Size & Performance
438
+
439
+ Compared against other OCCT-to-WASM builds (all include STEP, XCAF, glTF):
440
+
441
+ | Build | brotli |
442
+ | ------------------ | ------- |
443
+ | **occt-wasm** | ~4.5 MB |
444
+ | opencascade.js | ~9 MB |
445
+ | brepjs-opencascade | ~5 MB |
446
+
447
+ Run benchmarks locally: `npx tsx test/benchmark.ts`
448
+
449
+ ## Development
450
+
451
+ ### Building from Source
452
+
453
+ ```bash
454
+ # Prerequisites: Rust 1.95+, emsdk 5.0.3
455
+ git clone --recurse-submodules https://github.com/andymai/occt-wasm
456
+ cd occt-wasm
457
+ npm install && cd ts && npm install && cd ..
458
+
459
+ cargo xtask build # Build OCCT + facade -> WASM
460
+ cargo xtask test # Run tests
461
+
462
+ # View the Three.js example
463
+ node scripts/static-server.mjs
464
+ # Open http://localhost:3000/examples/three-js/
465
+ ```
466
+
467
+ ### Docker Build
468
+
469
+ No local emsdk or Rust needed -- everything runs in the container.
470
+
471
+ ```bash
472
+ npm run docker:build # Build image (OCCT layer cached after first run)
473
+ npm run docker:dist # Build + copy dist/ artifacts to host
474
+ ```
475
+
476
+ ## Browser Compatibility
477
+
478
+ occt-wasm requires modern browsers with WASM SIMD, tail calls, and exception
479
+ handling. WASM **tail calls** are the newest and therefore binding requirement —
480
+ they gate the minimum versions below. The versions listed are the lowest
481
+ combinations verified to load the kernel:
482
+
483
+ | Browser | Minimum (verified) | Notes |
484
+ | ------- | ------------------ | ------------------------------------------- |
485
+ | Chrome | 114+ | Tail calls landed in 112; 114 is verified |
486
+ | Edge | 114+ | Same engine as Chrome |
487
+ | Safari | 17.2+ | Earliest WebKit verified to load the kernel |
488
+ | Firefox | 121+ | Tail calls shipped in 121; 146 is verified |
489
+
490
+ Node.js 22+ is recommended (tail calls via V8). Node.js 18+ works if your V8 version supports the required WASM features.
491
+
492
+ ## Known Limitations
493
+
494
+ These are upstream OCCT V8.0.1 issues, not occt-wasm bugs:
495
+
496
+ - **IGES** -- TKDEIGES excluded from link; no IGES import/export
497
+ - **Zero-length extrusion** -- WASM exception escapes JS catch boundary (1 test skip)
498
+ - **Single WASM thread** -- each kernel instance is single-threaded; use `OcctWorker` (see above) to move work off the main thread
499
+
500
+ These will be addressed as upstream OCCT and browser support improve.
501
+
502
+ OCCT V8.0.1 (2026-07) resolved several upstream hangs and crashes that
503
+ affected modeling here: an infinite-loop guard in the boolean section
504
+ algorithm, crash guards in chamfer construction (`ChFi3d_Builder`) and
505
+ `BRep_Tool::CurveOnPlane`, null-pcurve guards in `UnifySameDomain`, and
506
+ an infinite-loop guard in the STEP writer.
507
+
508
+ ## Contributing
509
+
510
+ This project is open source. Bug reports and feature requests are welcome via GitHub Issues. For pull requests, please open an issue first to discuss the change.
511
+
512
+ ## License
513
+
514
+ **Build tooling** (xtask, scripts, TypeScript wrapper): MIT OR Apache-2.0
515
+
516
+ **Compiled WASM output**: LGPL-2.1-only (inherits from [OCCT](https://dev.opencascade.org/resources/download))
517
+
518
+ The LGPL requires that end users can replace the LGPL component. For web applications, this is satisfied by loading the `.wasm` file from a URL (which users can override via `OcctKernel.init({ wasm: '...' })`). If you ship a desktop app with the WASM embedded, consult the [LGPL-2.1 FAQ](https://www.gnu.org/licenses/old-licenses/lgpl-2.1.html).
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A 5x7 bitmap face, enough for the labels the renderers draw: view names,
3
+ * the XYZ gnomon and the "100 x 60 x 40 (XxYxZ)" footer.
4
+ *
5
+ * Shipping a face as data keeps the PNG renderer free of a font file and of
6
+ * any system font lookup, so a caller who embeds this in a single-file binary
7
+ * gets the same picture everywhere. Characters with no glyph render as a gap.
8
+ *
9
+ * Each row is five bits, most significant bit leftmost.
10
+ *
11
+ * @module
12
+ */
13
+ export declare const GLYPH_W = 5;
14
+ export declare const GLYPH_H = 7;
15
+ export declare const FONT_5X7: Record<string, number[]>;
16
+ //# sourceMappingURL=font5x7.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"font5x7.d.ts","sourceRoot":"","sources":["../src/font5x7.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,OAAO,IAAI,CAAC;AACzB,eAAO,MAAM,OAAO,IAAI,CAAC;AAEzB,eAAO,MAAM,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAiD7C,CAAC"}
@@ -0,0 +1,65 @@
1
+ /**
2
+ * A 5x7 bitmap face, enough for the labels the renderers draw: view names,
3
+ * the XYZ gnomon and the "100 x 60 x 40 (XxYxZ)" footer.
4
+ *
5
+ * Shipping a face as data keeps the PNG renderer free of a font file and of
6
+ * any system font lookup, so a caller who embeds this in a single-file binary
7
+ * gets the same picture everywhere. Characters with no glyph render as a gap.
8
+ *
9
+ * Each row is five bits, most significant bit leftmost.
10
+ *
11
+ * @module
12
+ */
13
+ export const GLYPH_W = 5;
14
+ export const GLYPH_H = 7;
15
+ export const FONT_5X7 = {
16
+ ' ': [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b00000],
17
+ '(': [0b00110, 0b01000, 0b10000, 0b10000, 0b10000, 0b01000, 0b00110],
18
+ ')': [0b01100, 0b00010, 0b00001, 0b00001, 0b00001, 0b00010, 0b01100],
19
+ '.': [0b00000, 0b00000, 0b00000, 0b00000, 0b00000, 0b01100, 0b01100],
20
+ '0': [0b01110, 0b10001, 0b10011, 0b10101, 0b11001, 0b10001, 0b01110],
21
+ '1': [0b00100, 0b01100, 0b00100, 0b00100, 0b00100, 0b00100, 0b01110],
22
+ '2': [0b01110, 0b10001, 0b00001, 0b00010, 0b00100, 0b01000, 0b11111],
23
+ '3': [0b11111, 0b00010, 0b00100, 0b00010, 0b00001, 0b10001, 0b01110],
24
+ '4': [0b00010, 0b00110, 0b01010, 0b10010, 0b11111, 0b00010, 0b00010],
25
+ '5': [0b11111, 0b10000, 0b11110, 0b00001, 0b00001, 0b10001, 0b01110],
26
+ '6': [0b00110, 0b01000, 0b10000, 0b11110, 0b10001, 0b10001, 0b01110],
27
+ '7': [0b11111, 0b00001, 0b00010, 0b00100, 0b01000, 0b01000, 0b01000],
28
+ '8': [0b01110, 0b10001, 0b10001, 0b01110, 0b10001, 0b10001, 0b01110],
29
+ '9': [0b01110, 0b10001, 0b10001, 0b01111, 0b00001, 0b00010, 0b01100],
30
+ 'A': [0b01110, 0b10001, 0b10001, 0b11111, 0b10001, 0b10001, 0b10001],
31
+ 'B': [0b11110, 0b10001, 0b10001, 0b11110, 0b10001, 0b10001, 0b11110],
32
+ 'F': [0b11111, 0b10000, 0b10000, 0b11110, 0b10000, 0b10000, 0b10000],
33
+ 'I': [0b01110, 0b00100, 0b00100, 0b00100, 0b00100, 0b00100, 0b01110],
34
+ 'L': [0b10000, 0b10000, 0b10000, 0b10000, 0b10000, 0b10000, 0b11111],
35
+ 'R': [0b11110, 0b10001, 0b10001, 0b11110, 0b10100, 0b10010, 0b10001],
36
+ 'T': [0b11111, 0b00100, 0b00100, 0b00100, 0b00100, 0b00100, 0b00100],
37
+ 'X': [0b10001, 0b10001, 0b01010, 0b00100, 0b01010, 0b10001, 0b10001],
38
+ 'Y': [0b10001, 0b10001, 0b01010, 0b00100, 0b00100, 0b00100, 0b00100],
39
+ 'Z': [0b11111, 0b00001, 0b00010, 0b00100, 0b01000, 0b10000, 0b11111],
40
+ 'a': [0b00000, 0b00000, 0b01110, 0b00001, 0b01111, 0b10001, 0b01111],
41
+ 'c': [0b00000, 0b00000, 0b01110, 0b10000, 0b10000, 0b10001, 0b01110],
42
+ 'e': [0b00000, 0b00000, 0b01110, 0b10001, 0b11111, 0b10000, 0b01110],
43
+ 'f': [0b00110, 0b01001, 0b01000, 0b11100, 0b01000, 0b01000, 0b01000],
44
+ 'g': [0b00000, 0b00000, 0b01111, 0b10001, 0b01111, 0b00001, 0b01110],
45
+ 'h': [0b10000, 0b10000, 0b10110, 0b11001, 0b10001, 0b10001, 0b10001],
46
+ 'i': [0b00100, 0b00000, 0b01100, 0b00100, 0b00100, 0b00100, 0b01110],
47
+ 'k': [0b10000, 0b10000, 0b10010, 0b10100, 0b11000, 0b10100, 0b10010],
48
+ 'm': [0b00000, 0b00000, 0b11010, 0b10101, 0b10101, 0b10101, 0b10101],
49
+ 'n': [0b00000, 0b00000, 0b10110, 0b11001, 0b10001, 0b10001, 0b10001],
50
+ 'o': [0b00000, 0b00000, 0b01110, 0b10001, 0b10001, 0b10001, 0b01110],
51
+ 'p': [0b00000, 0b00000, 0b11110, 0b10001, 0b11110, 0b10000, 0b10000],
52
+ 'r': [0b00000, 0b00000, 0b10110, 0b11001, 0b10000, 0b10000, 0b10000],
53
+ 's': [0b00000, 0b00000, 0b01111, 0b10000, 0b01110, 0b00001, 0b11110],
54
+ 't': [0b01000, 0b01000, 0b11100, 0b01000, 0b01000, 0b01001, 0b00110],
55
+ 'u': [0b00000, 0b00000, 0b10001, 0b10001, 0b10001, 0b10011, 0b01101],
56
+ 'v': [0b00000, 0b00000, 0b10001, 0b10001, 0b10001, 0b01010, 0b00100],
57
+ 'w': [0b00000, 0b00000, 0b10101, 0b10101, 0b10101, 0b10101, 0b01010],
58
+ 'x': [0b00000, 0b00000, 0b10001, 0b01010, 0b00100, 0b01010, 0b10001],
59
+ 'y': [0b00000, 0b00000, 0b10001, 0b10001, 0b01111, 0b00001, 0b01110],
60
+ '×': [0b00000, 0b10001, 0b01010, 0b00100, 0b01010, 0b10001, 0b00000],
61
+ '-': [0b00000, 0b00000, 0b00000, 0b11111, 0b00000, 0b00000, 0b00000],
62
+ ',': [0b00000, 0b00000, 0b00000, 0b00000, 0b01100, 0b01100, 0b01000],
63
+ ':': [0b00000, 0b01100, 0b01100, 0b00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