brepjs 2.0.0 → 2.0.2
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 +79 -20
- package/dist/brepjs.cjs +2013 -1860
- package/dist/brepjs.d.ts +175 -79
- package/dist/brepjs.js +2013 -1860
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -12,47 +12,106 @@ Web CAD library built on OpenCascade with a layered architecture and kernel abst
|
|
|
12
12
|
npm install brepjs brepjs-opencascade
|
|
13
13
|
```
|
|
14
14
|
|
|
15
|
-
##
|
|
15
|
+
## Quick Start
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
18
|
import opencascade from 'brepjs-opencascade';
|
|
19
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
setOC,
|
|
21
|
+
makeBox,
|
|
22
|
+
makeCylinder,
|
|
23
|
+
castShape,
|
|
24
|
+
fuseShapes,
|
|
25
|
+
cutShape,
|
|
26
|
+
translateShape,
|
|
27
|
+
fnMeasureVolume,
|
|
28
|
+
fnExportSTEP,
|
|
29
|
+
unwrap,
|
|
30
|
+
} from 'brepjs';
|
|
20
31
|
|
|
21
32
|
// Initialize the WASM kernel
|
|
22
33
|
const oc = await opencascade();
|
|
23
34
|
setOC(oc);
|
|
24
35
|
|
|
25
|
-
// Create
|
|
26
|
-
const box =
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
36
|
+
// Create primitive shapes
|
|
37
|
+
const box = castShape(makeBox([0, 0, 0], [50, 30, 20]).wrapped);
|
|
38
|
+
const cylinder = castShape(makeCylinder(8, 25).translate([25, 15, -2]).wrapped);
|
|
39
|
+
|
|
40
|
+
// Boolean operations
|
|
41
|
+
const withHole = unwrap(cutShape(box, cylinder));
|
|
42
|
+
|
|
43
|
+
// Transform
|
|
44
|
+
const moved = translateShape(withHole, [100, 0, 0]);
|
|
45
|
+
|
|
46
|
+
// Measure
|
|
47
|
+
console.log('Volume:', fnMeasureVolume(moved), 'mm³');
|
|
48
|
+
|
|
49
|
+
// Export
|
|
50
|
+
const stepBlob = unwrap(fnExportSTEP(moved));
|
|
33
51
|
```
|
|
34
52
|
|
|
53
|
+
## Examples
|
|
54
|
+
|
|
55
|
+
See the [examples/](./examples/) directory for complete workflows:
|
|
56
|
+
|
|
57
|
+
- **[basic-primitives.ts](./examples/basic-primitives.ts)** — Create shapes and boolean operations
|
|
58
|
+
- **[mechanical-part.ts](./examples/mechanical-part.ts)** — Build a bracket with holes
|
|
59
|
+
- **[2d-to-3d.ts](./examples/2d-to-3d.ts)** — Sketch to extrusion workflow
|
|
60
|
+
- **[import-export.ts](./examples/import-export.ts)** — Load, modify, export files
|
|
61
|
+
- **[text-engraving.ts](./examples/text-engraving.ts)** — Engrave text on shapes
|
|
62
|
+
|
|
63
|
+
## Documentation
|
|
64
|
+
|
|
65
|
+
- **[Architecture](./docs/architecture.md)** — Layer diagram and module overview
|
|
66
|
+
- **[Performance](./docs/performance.md)** — Optimization best practices
|
|
67
|
+
- **[Memory Management](./docs/memory-management.md)** — Resource cleanup patterns
|
|
68
|
+
- **[Error Reference](./docs/errors.md)** — Error codes and recovery
|
|
69
|
+
- **[Compatibility](./docs/compatibility.md)** — Tested environments
|
|
70
|
+
|
|
35
71
|
## Architecture
|
|
36
72
|
|
|
37
73
|
Four-layer architecture with enforced import boundaries:
|
|
38
74
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
75
|
+
```
|
|
76
|
+
Layer 3: sketching/, text/, projection/ (High-level API)
|
|
77
|
+
Layer 2: topology/, operations/, 2d/, ... (Domain)
|
|
78
|
+
Layer 1: core/ (Types, memory, errors)
|
|
79
|
+
Layer 0: kernel/, utils/ (WASM bindings)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
See [docs/architecture.md](./docs/architecture.md) for the full diagram.
|
|
83
|
+
|
|
84
|
+
## API Styles
|
|
85
|
+
|
|
86
|
+
brepjs supports two API styles:
|
|
87
|
+
|
|
88
|
+
**Functional API (recommended):**
|
|
89
|
+
```typescript
|
|
90
|
+
const box = castShape(makeBox([0, 0, 0], [10, 10, 10]).wrapped);
|
|
91
|
+
const moved = translateShape(box, [5, 0, 0]); // Returns new shape
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
**Legacy class API:**
|
|
95
|
+
```typescript
|
|
96
|
+
const box = makeBox([10, 10, 10]);
|
|
97
|
+
box.translate([5, 0, 0]); // Mutates in place
|
|
98
|
+
```
|
|
45
99
|
|
|
46
100
|
## Development
|
|
47
101
|
|
|
48
102
|
```bash
|
|
49
103
|
npm install
|
|
50
|
-
npm run build
|
|
51
|
-
npm run test
|
|
52
|
-
npm run typecheck
|
|
53
|
-
npm run lint
|
|
104
|
+
npm run build # Build library
|
|
105
|
+
npm run test # Run tests
|
|
106
|
+
npm run typecheck # Type check
|
|
107
|
+
npm run lint # Lint
|
|
108
|
+
npm run bench # Run benchmarks
|
|
54
109
|
```
|
|
55
110
|
|
|
111
|
+
## Contributing
|
|
112
|
+
|
|
113
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
|
|
114
|
+
|
|
56
115
|
## License
|
|
57
116
|
|
|
58
117
|
[Apache-2.0](./LICENSE)
|