brepjs 7.2.0 → 7.4.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 +151 -81
- package/dist/2d/blueprints/blueprintFns.d.ts +33 -64
- package/dist/2d/blueprints/blueprintFns.d.ts.map +1 -1
- package/dist/2d/blueprints/boolean2dFns.d.ts +6 -3
- package/dist/2d/blueprints/boolean2dFns.d.ts.map +1 -1
- package/dist/2d.cjs +57 -13
- package/dist/2d.d.ts +6 -2
- package/dist/2d.d.ts.map +1 -1
- package/dist/2d.js +59 -15
- package/dist/{Blueprint-DCoXzdIm.cjs → Blueprint-3Dyu0OL6.cjs} +7 -7
- package/dist/{Blueprint-9Gdmj67R.js → Blueprint-DSHD89bZ.js} +7 -7
- package/dist/{boolean2D-9E0ZB4yu.cjs → boolean2D-BwOpOv6L.cjs} +9 -9
- package/dist/{boolean2D-BfpQtXOQ.js → boolean2D-CtyE2hK5.js} +9 -9
- package/dist/{booleanFns-7VTkk7ns.cjs → booleanFns-5KSbtLBU.cjs} +2 -2
- package/dist/{booleanFns-CZzbd4sX.js → booleanFns-DcxqLQSG.js} +2 -2
- package/dist/brepjs.cjs +95 -30
- package/dist/brepjs.js +134 -69
- package/dist/{cast-Bx3PuKsP.js → cast-D1s7Im9E.js} +1 -1
- package/dist/{cast-CQ7SKb6A.cjs → cast-DsxJk_F0.cjs} +1 -1
- package/dist/core/errors.d.ts +19 -8
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/kernelCall.d.ts +6 -0
- package/dist/core/kernelCall.d.ts.map +1 -1
- package/dist/core.cjs +2 -2
- package/dist/core.js +2 -2
- package/dist/{curveFns-DqT7DqLQ.cjs → curveFns-BilyYL_s.cjs} +1 -1
- package/dist/{curveFns-DFRn4NzJ.js → curveFns-CdVE4da7.js} +1 -1
- package/dist/{drawFns-jZkfPayI.cjs → drawFns-C6KQjmQj.cjs} +11 -11
- package/dist/{drawFns-CzYsisur.js → drawFns-CSbH7uoI.js} +11 -11
- package/dist/{errors-C7Inmd1n.cjs → errors-DK1VAdP4.cjs} +81 -17
- package/dist/{errors-EPHOk9hi.js → errors-wGhcJMpB.js} +82 -18
- package/dist/{faceFns-BOc1QawY.cjs → faceFns-B9if-FPW.cjs} +2 -2
- package/dist/{faceFns-SBxx55zv.js → faceFns-Bl6HHbqO.js} +2 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/io.cjs +3 -3
- package/dist/io.js +3 -3
- package/dist/{loft-BJHEEDu4.js → loft-BlNndTOR.js} +3 -3
- package/dist/{loft-Cz36k5dM.cjs → loft-Cc5E5pAf.cjs} +3 -3
- package/dist/{measurement-DqiOwyhS.cjs → measurement-BVdZ9cG3.cjs} +1 -1
- package/dist/{measurement-DZUawVj4.js → measurement-D75pyJi1.js} +10 -10
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +8 -8
- package/dist/{meshFns-OmRn9qly.cjs → meshFns-mVlogI3J.cjs} +1 -1
- package/dist/{meshFns-BanGVcaW.js → meshFns-p_kv--PW.js} +1 -1
- package/dist/operations/api.d.ts +4 -4
- package/dist/operations/api.d.ts.map +1 -1
- package/dist/operations/exporterFns.d.ts +4 -2
- package/dist/operations/exporterFns.d.ts.map +1 -1
- package/dist/operations/exporters.d.ts +3 -3
- package/dist/operations/exporters.d.ts.map +1 -1
- package/dist/operations/extrude.d.ts +6 -4
- package/dist/operations/extrude.d.ts.map +1 -1
- package/dist/operations/extrudeFns.d.ts +3 -3
- package/dist/operations/extrudeFns.d.ts.map +1 -1
- package/dist/operations/extrudeUtils.d.ts +3 -1
- package/dist/operations/extrudeUtils.d.ts.map +1 -1
- package/dist/operations/loft.d.ts +2 -2
- package/dist/operations/loft.d.ts.map +1 -1
- package/dist/operations/loftFns.d.ts +4 -2
- package/dist/operations/loftFns.d.ts.map +1 -1
- package/dist/{operations-C6ry44Xe.js → operations-CEV-gqkX.js} +5 -5
- package/dist/{operations-IwYUx4V_.cjs → operations-SRN-mfTx.cjs} +5 -5
- package/dist/operations.cjs +2 -2
- package/dist/operations.d.ts +3 -3
- package/dist/operations.d.ts.map +1 -1
- package/dist/operations.js +2 -2
- package/dist/{query-CMkm1olv.js → query-D7XclvBZ.js} +6 -6
- package/dist/{query-Dd1h9qFw.cjs → query-DkcMfh6j.cjs} +6 -6
- package/dist/query.cjs +1 -1
- package/dist/query.js +1 -1
- package/dist/result.cjs +1 -1
- package/dist/result.js +2 -2
- package/dist/{shapeFns-GaYcQL6U.js → shapeFns-BpCPVHFT.js} +2 -2
- package/dist/{shapeFns-Df3OAlpp.cjs → shapeFns-DjsWo98C.cjs} +2 -2
- package/dist/{shapeHelpers-XCWxPN_X.cjs → shapeHelpers-BBSVHPGk.cjs} +3 -3
- package/dist/{shapeHelpers-DL3Kro2n.js → shapeHelpers-C4QIp7u5.js} +3 -3
- package/dist/sketching/CompoundSketch.d.ts +2 -2
- package/dist/sketching/CompoundSketch.d.ts.map +1 -1
- package/dist/sketching/Sketch.d.ts +4 -4
- package/dist/sketching/Sketch.d.ts.map +1 -1
- package/dist/sketching/Sketcher.d.ts +3 -3
- package/dist/sketching/Sketcher.d.ts.map +1 -1
- package/dist/sketching/Sketcher2d.d.ts +3 -3
- package/dist/sketching/Sketcher2d.d.ts.map +1 -1
- package/dist/sketching/cannedSketches.d.ts +2 -2
- package/dist/sketching/cannedSketches.d.ts.map +1 -1
- package/dist/sketching/draw.d.ts +3 -3
- package/dist/sketching/draw.d.ts.map +1 -1
- package/dist/sketching/sketchFns.d.ts +5 -5
- package/dist/sketching/sketchFns.d.ts.map +1 -1
- package/dist/sketching/sketchLib.d.ts +2 -2
- package/dist/sketching/sketchLib.d.ts.map +1 -1
- package/dist/sketching/sketcherlib.d.ts +6 -4
- package/dist/sketching/sketcherlib.d.ts.map +1 -1
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.d.ts +2 -2
- package/dist/sketching.d.ts.map +1 -1
- package/dist/sketching.js +2 -2
- package/dist/topology/api.d.ts +4 -3
- package/dist/topology/api.d.ts.map +1 -1
- package/dist/topology/index.d.ts +1 -1
- package/dist/topology/index.d.ts.map +1 -1
- package/dist/topology/modifierFns.d.ts.map +1 -1
- package/dist/topology/primitiveFns.d.ts +3 -3
- package/dist/topology/primitiveFns.d.ts.map +1 -1
- package/dist/topology/shapeHelpers.d.ts +2 -2
- package/dist/topology/shapeHelpers.d.ts.map +1 -1
- package/dist/topology/shapeModifiers.d.ts +3 -1
- package/dist/topology/shapeModifiers.d.ts.map +1 -1
- package/dist/topology/wrapperFns.d.ts +12 -5
- package/dist/topology/wrapperFns.d.ts.map +1 -1
- package/dist/{topology-q7nA7fzs.js → topology-BEMrS4WZ.js} +7 -7
- package/dist/{topology-CzVovLTs.cjs → topology-Bb1W3SyF.cjs} +7 -7
- package/dist/topology.cjs +7 -7
- package/dist/topology.js +7 -7
- package/dist/{vectors-Bhj7KHrb.js → vectors-CBuaMeZv.js} +1 -1
- package/dist/{vectors-CCdx6erh.cjs → vectors-ChWEZPwy.cjs} +1 -1
- package/dist/vectors.cjs +1 -1
- package/dist/vectors.js +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -1,122 +1,194 @@
|
|
|
1
1
|
# brepjs
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
CAD modeling for JavaScript. Build 3D geometry with code.
|
|
4
|
+
|
|
4
5
|
[](https://www.npmjs.com/package/brepjs)
|
|
6
|
+
[](https://github.com/andymai/brepjs/actions/workflows/ci.yml)
|
|
5
7
|
[](./LICENSE)
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
**[Docs](https://andymai.github.io/brepjs/)** · **[Examples](./examples/)** · **[Cheat Sheet](./docs/cheat-sheet.md)** · **[Getting Started](./docs/getting-started.md)**
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
```typescript
|
|
12
|
+
import { box, cut, cylinder, fillet, edgeFinder, exportSTEP, unwrap } from 'brepjs/quick';
|
|
13
|
+
|
|
14
|
+
const b = box(30, 20, 10);
|
|
15
|
+
const hole = cylinder(5, 15, { at: [15, 10, -2] });
|
|
16
|
+
const drilled = unwrap(cut(b, hole));
|
|
17
|
+
|
|
18
|
+
const edges = edgeFinder().inDirection('Z').findAll(drilled);
|
|
19
|
+
const part = unwrap(fillet(drilled, edges, 1.5));
|
|
20
|
+
|
|
21
|
+
const step = unwrap(exportSTEP(part));
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Why brepjs?
|
|
25
|
+
|
|
26
|
+
Most CAD libraries for the web are mesh-based — they work with triangles, not real geometry. brepjs gives you boundary representation (B-Rep) modeling powered by OpenCascade's WASM build. That means exact geometry, proper booleans, fillets that actually work, and export to formats that real CAD software can open.
|
|
27
|
+
|
|
28
|
+
Use it for parametric modeling, 3D configurators, CAD file processing, or anywhere you need solid geometry in JavaScript.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
10
31
|
|
|
11
32
|
```bash
|
|
12
33
|
npm install brepjs brepjs-opencascade
|
|
13
34
|
```
|
|
14
35
|
|
|
15
|
-
|
|
36
|
+
`brepjs/quick` auto-initializes the WASM kernel via top-level await (ESM only). For CJS or manual control:
|
|
16
37
|
|
|
17
38
|
```typescript
|
|
18
39
|
import opencascade from 'brepjs-opencascade';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
makeBox,
|
|
22
|
-
makeCylinder,
|
|
23
|
-
cutShape,
|
|
24
|
-
translateShape,
|
|
25
|
-
measureVolume,
|
|
26
|
-
exportSTEP,
|
|
27
|
-
unwrap,
|
|
28
|
-
} from 'brepjs';
|
|
29
|
-
|
|
30
|
-
// Initialize the WASM kernel
|
|
40
|
+
import { initFromOC } from 'brepjs';
|
|
41
|
+
|
|
31
42
|
const oc = await opencascade();
|
|
32
43
|
initFromOC(oc);
|
|
44
|
+
```
|
|
33
45
|
|
|
34
|
-
|
|
35
|
-
const box = makeBox([0, 0, 0], [50, 30, 20]);
|
|
36
|
-
const cylinder = translateShape(makeCylinder(8, 25), [25, 15, -2]);
|
|
46
|
+
## Features
|
|
37
47
|
|
|
38
|
-
|
|
39
|
-
const withHole = unwrap(cutShape(box, cylinder));
|
|
48
|
+
**Modeling** — `box`, `cylinder`, `sphere`, `cone`, `torus`, `ellipsoid` plus `extrude`, `revolve`, `loft`, `sweep` from 2D sketches
|
|
40
49
|
|
|
41
|
-
|
|
42
|
-
const moved = translateShape(withHole, [100, 0, 0]);
|
|
50
|
+
**Booleans** — `fuse`, `cut`, `intersect`, `section`, `split`, `slice` with batch variants `fuseAll`, `cutAll`
|
|
43
51
|
|
|
44
|
-
|
|
45
|
-
console.log('Volume:', measureVolume(moved), 'mm³');
|
|
52
|
+
**Modifiers** — `fillet`, `chamfer`, `shell`, `offset`, `thicken` on any solid
|
|
46
53
|
|
|
47
|
-
|
|
48
|
-
const stepBlob = unwrap(exportSTEP(moved));
|
|
49
|
-
```
|
|
54
|
+
**Sketching** — `draw`, `drawRectangle`, `drawCircle`, `Sketcher`, `sketchCircle`, `sketchHelix` for 2D-to-3D workflows
|
|
50
55
|
|
|
51
|
-
|
|
56
|
+
**Queries** — `edgeFinder`, `faceFinder`, `wireFinder`, `vertexFinder` with composable filters like `.inDirection('Z')`, `.ofCurveType('CIRCLE')`, `.ofLength(10)`
|
|
52
57
|
|
|
53
|
-
|
|
58
|
+
**Measurement** — `measureVolume`, `measureArea`, `measureLength`, `measureDistance`, `checkInterference`
|
|
54
59
|
|
|
55
|
-
|
|
56
|
-
npm run example examples/hello-world.ts
|
|
57
|
-
```
|
|
60
|
+
**Import/Export** — STEP, STL, IGES, glTF/GLB, DXF, 3MF, OBJ, SVG. Assembly export with colors and names via `exportAssemblySTEP`
|
|
58
61
|
|
|
59
|
-
|
|
60
|
-
- **[basic-primitives.ts](./examples/basic-primitives.ts)** — Primitives and boolean operations
|
|
61
|
-
- **[mechanical-part.ts](./examples/mechanical-part.ts)** — Bracket with holes and slots
|
|
62
|
-
- **[2d-to-3d.ts](./examples/2d-to-3d.ts)** — Sketch to extrusion workflow
|
|
63
|
-
- **[parametric-part.ts](./examples/parametric-part.ts)** — Configurable flanged pipe fitting
|
|
64
|
-
- **[threejs-rendering.ts](./examples/threejs-rendering.ts)** — Mesh data for Three.js/WebGL
|
|
65
|
-
- **[import-export.ts](./examples/import-export.ts)** — Load, modify, export files
|
|
66
|
-
- **[text-engraving.ts](./examples/text-engraving.ts)** — Engrave text on shapes
|
|
67
|
-
|
|
68
|
-
## Gallery
|
|
69
|
-
|
|
70
|
-
<p align="center">
|
|
71
|
-
<img src="docs/images/examples/hello-world.svg" alt="Box" width="120" />
|
|
72
|
-
<img src="docs/images/examples/boolean-ops.svg" alt="Boolean cut" width="120" />
|
|
73
|
-
<img src="docs/images/examples/bracket.svg" alt="Bracket" width="120" />
|
|
74
|
-
<img src="docs/images/examples/2d-profile.svg" alt="2D profile" width="120" />
|
|
75
|
-
<img src="docs/images/examples/pipe-fitting.svg" alt="Pipe fitting" width="120" />
|
|
76
|
-
</p>
|
|
77
|
-
<p align="center"><em>Box · Boolean cut · Bracket · 2D profile · Pipe fitting — see <a href="./examples/">examples/</a></em></p>
|
|
62
|
+
**Rendering** — `mesh` and `toBufferGeometryData` for Three.js / WebGL integration
|
|
78
63
|
|
|
79
|
-
|
|
64
|
+
**Text** — `loadFont`, `drawText`, `sketchText` for text outlines and engraving
|
|
80
65
|
|
|
81
|
-
|
|
82
|
-
- **[B-Rep Concepts](./docs/concepts.md)** — Vertices, edges, faces, solids explained for JS developers
|
|
83
|
-
- **[Which API?](./docs/which-api.md)** — Sketcher vs functional API vs Drawing — when to use each
|
|
84
|
-
- **[Architecture](./docs/architecture.md)** — Layer diagram and module overview
|
|
85
|
-
- **[Memory Management](./docs/memory-management.md)** — Resource cleanup patterns
|
|
86
|
-
- **[Error Reference](./docs/errors.md)** — Error codes and recovery
|
|
87
|
-
- **[Performance](./docs/performance.md)** — Optimization best practices
|
|
88
|
-
- **[Compatibility](./docs/compatibility.md)** — Tested environments
|
|
66
|
+
**Healing** — `autoHeal`, `healSolid`, `healFace`, `isValid` for fixing imported geometry
|
|
89
67
|
|
|
90
|
-
|
|
68
|
+
**Patterns** — `linearPattern`, `circularPattern` for arraying shapes
|
|
69
|
+
|
|
70
|
+
**Assemblies** — `createAssemblyNode`, `addChild`, `walkAssembly`, `collectShapes` for hierarchical models
|
|
71
|
+
|
|
72
|
+
**Workers** — `createWorkerClient`, `createWorkerHandler` for off-main-thread operations
|
|
73
|
+
|
|
74
|
+
**History** — `createHistory`, `addStep`, `undoLast`, `replayHistory` for parametric undo/replay
|
|
91
75
|
|
|
92
|
-
|
|
76
|
+
## A Larger Example
|
|
93
77
|
|
|
78
|
+
A flanged pipe with bolt holes — showing booleans, shelling, fillets, and finders:
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
import {
|
|
82
|
+
cylinder, fuse, cut, shell, fillet, rotate,
|
|
83
|
+
faceFinder, edgeFinder, measureVolume, unwrap,
|
|
84
|
+
} from 'brepjs/quick';
|
|
85
|
+
|
|
86
|
+
// Tube + flanges
|
|
87
|
+
const tube = cylinder(15, 100);
|
|
88
|
+
const body = unwrap(fuse(unwrap(fuse(tube, cylinder(30, 5))), cylinder(30, 5, { at: [0, 0, 95] })));
|
|
89
|
+
|
|
90
|
+
// Hollow out — find top face, shell to 2mm walls
|
|
91
|
+
const topFaces = faceFinder().parallelTo('XY').atDistance(100, [0, 0, 0]).findAll(body);
|
|
92
|
+
const hollowed = unwrap(shell(body, topFaces, 2));
|
|
93
|
+
|
|
94
|
+
// Fillet the tube-to-flange transitions
|
|
95
|
+
const filletEdges = edgeFinder().ofCurveType('CIRCLE').ofLength(2 * Math.PI * 15).findAll(hollowed);
|
|
96
|
+
let result = unwrap(fillet(hollowed, filletEdges, 3));
|
|
97
|
+
|
|
98
|
+
// Bolt holes around each flange
|
|
99
|
+
for (let i = 0; i < 6; i++) {
|
|
100
|
+
const angle = 60 * i;
|
|
101
|
+
const hole = rotate(cylinder(3, 10, { at: [22, 0, -2] }), angle, { axis: [0, 0, 1] });
|
|
102
|
+
result = unwrap(cut(result, hole));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
console.log('Volume:', measureVolume(result), 'mm³');
|
|
94
106
|
```
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
107
|
+
|
|
108
|
+
## Examples
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm run example examples/hello-world.ts
|
|
99
112
|
```
|
|
100
113
|
|
|
101
|
-
|
|
114
|
+
| Example | What it does |
|
|
115
|
+
|---|---|
|
|
116
|
+
| [hello-world.ts](./examples/hello-world.ts) | Create a box, measure it, export it |
|
|
117
|
+
| [basic-primitives.ts](./examples/basic-primitives.ts) | Primitives and boolean operations |
|
|
118
|
+
| [mechanical-part.ts](./examples/mechanical-part.ts) | Bracket with holes, slots, and SVG drawings |
|
|
119
|
+
| [2d-to-3d.ts](./examples/2d-to-3d.ts) | Sketch a profile, extrude to 3D |
|
|
120
|
+
| [parametric-part.ts](./examples/parametric-part.ts) | Configurable flanged pipe fitting |
|
|
121
|
+
| [threejs-rendering.ts](./examples/threejs-rendering.ts) | Generate mesh data for Three.js |
|
|
122
|
+
| [browser-viewer.ts](./examples/browser-viewer.ts) | Standalone HTML viewer with orbit controls |
|
|
123
|
+
| [import-export.ts](./examples/import-export.ts) | Load, modify, and re-export STEP files |
|
|
124
|
+
| [text-engraving.ts](./examples/text-engraving.ts) | Engrave text on a solid shape |
|
|
125
|
+
|
|
126
|
+
## Imports
|
|
127
|
+
|
|
128
|
+
Everything is available from the top level:
|
|
102
129
|
|
|
103
|
-
|
|
130
|
+
```typescript
|
|
131
|
+
import { box, translate, fuse, exportSTEP } from 'brepjs';
|
|
132
|
+
```
|
|
104
133
|
|
|
105
|
-
|
|
134
|
+
Sub-path imports for tree-shaking:
|
|
106
135
|
|
|
107
136
|
```typescript
|
|
108
|
-
import {
|
|
137
|
+
import { box, fuse, fillet } from 'brepjs/topology';
|
|
109
138
|
import { importSTEP, exportSTEP } from 'brepjs/io';
|
|
110
139
|
import { measureVolume } from 'brepjs/measurement';
|
|
140
|
+
import { edgeFinder, faceFinder } from 'brepjs/query';
|
|
141
|
+
import { sketchCircle, draw } from 'brepjs/sketching';
|
|
142
|
+
import { createAssemblyNode } from 'brepjs/operations';
|
|
111
143
|
```
|
|
112
144
|
|
|
113
|
-
|
|
145
|
+
## Error Handling
|
|
146
|
+
|
|
147
|
+
Operations that can fail return a `Result` instead of throwing:
|
|
114
148
|
|
|
115
149
|
```typescript
|
|
116
|
-
|
|
117
|
-
|
|
150
|
+
const result = fuse(a, b);
|
|
151
|
+
|
|
152
|
+
if (isOk(result)) {
|
|
153
|
+
const fused = result.value;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Or throw on failure
|
|
157
|
+
const fused = unwrap(fuse(a, b));
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Architecture
|
|
161
|
+
|
|
162
|
+
Four layers with enforced import boundaries (imports flow downward only):
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
Layer 3 sketching/, text/, projection/ High-level API
|
|
166
|
+
Layer 2 topology/, operations/, 2d/ ... Domain logic
|
|
167
|
+
Layer 1 core/ Types, memory, errors
|
|
168
|
+
Layer 0 kernel/, utils/ WASM bindings
|
|
118
169
|
```
|
|
119
170
|
|
|
171
|
+
## Documentation
|
|
172
|
+
|
|
173
|
+
- [API Reference](https://andymai.github.io/brepjs/) — Searchable TypeDoc reference
|
|
174
|
+
- [Getting Started](./docs/getting-started.md) — Install to first part
|
|
175
|
+
- [B-Rep Concepts](./docs/concepts.md) — Vertices, edges, faces, solids
|
|
176
|
+
- [Cheat Sheet](./docs/cheat-sheet.md) — Single-page reference for common operations
|
|
177
|
+
- [Which API?](./docs/which-api.md) — Sketcher vs functional vs Drawing
|
|
178
|
+
- [Function Lookup](./docs/function-lookup.md) — Alphabetical index of every export
|
|
179
|
+
- [Memory Management](./docs/memory-management.md) — Resource cleanup patterns
|
|
180
|
+
- [Error Reference](./docs/errors.md) — Error codes and recovery
|
|
181
|
+
- [Architecture](./docs/architecture.md) — Layer diagram and module overview
|
|
182
|
+
- [Performance](./docs/performance.md) — Optimization tips
|
|
183
|
+
- [Compatibility](./docs/compatibility.md) — Tested environments
|
|
184
|
+
|
|
185
|
+
## Packages
|
|
186
|
+
|
|
187
|
+
| Package | Description |
|
|
188
|
+
|---|---|
|
|
189
|
+
| [brepjs](https://www.npmjs.com/package/brepjs) | Core library |
|
|
190
|
+
| [brepjs-opencascade](https://www.npmjs.com/package/brepjs-opencascade) | OpenCascade WASM build |
|
|
191
|
+
|
|
120
192
|
## Projects Using brepjs
|
|
121
193
|
|
|
122
194
|
- [Gridfinity Layout Tool](https://github.com/andymai/gridfinity-layout-tool) — Web-based layout generator for Gridfinity storage systems
|
|
@@ -125,16 +197,14 @@ const moved = translateShape(makeBox([0, 0, 0], [10, 10, 10]), [5, 0, 0]);
|
|
|
125
197
|
|
|
126
198
|
```bash
|
|
127
199
|
npm install
|
|
128
|
-
npm run build # Build library
|
|
200
|
+
npm run build # Build library (ES + CJS)
|
|
129
201
|
npm run test # Run tests
|
|
130
|
-
npm run typecheck #
|
|
131
|
-
npm run lint #
|
|
132
|
-
npm run
|
|
202
|
+
npm run typecheck # TypeScript strict check
|
|
203
|
+
npm run lint # ESLint
|
|
204
|
+
npm run format:check # Prettier
|
|
133
205
|
```
|
|
134
206
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
See [CONTRIBUTING.md](./CONTRIBUTING.md) for development guidelines.
|
|
207
|
+
See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines.
|
|
138
208
|
|
|
139
209
|
## License
|
|
140
210
|
|
|
@@ -10,79 +10,48 @@ import { ScaleMode } from '../curves.js';
|
|
|
10
10
|
* @see {@link Blueprint} constructor.
|
|
11
11
|
*/
|
|
12
12
|
export declare function createBlueprint(curves: Blueprint['curves']): Blueprint;
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
*/
|
|
13
|
+
/** Get the axis-aligned bounding box of a 2D blueprint. */
|
|
14
|
+
export declare function getBounds2D(bp: Blueprint): BoundingBox2d;
|
|
15
|
+
/** Get the winding direction of a 2D blueprint. */
|
|
16
|
+
export declare function getOrientation2D(bp: Blueprint): 'clockwise' | 'counterClockwise';
|
|
17
|
+
/** Test whether a 2D point lies strictly inside a blueprint. */
|
|
18
|
+
export declare function isInside2D(bp: Blueprint, point: Point2D): boolean;
|
|
19
|
+
/** Convert a 2D blueprint to an SVG path d attribute string. */
|
|
20
|
+
export declare function toSVGPathD(bp: Blueprint): string;
|
|
21
|
+
/** Translate a 2D blueprint by the given x and y distances. */
|
|
22
|
+
export declare function translate2D(bp: Blueprint, dx: number, dy: number): Blueprint;
|
|
23
|
+
/** Rotate a 2D blueprint by the given angle in degrees. */
|
|
24
|
+
export declare function rotate2D(bp: Blueprint, angle: number, center?: Point2D): Blueprint;
|
|
25
|
+
/** Uniformly scale a 2D blueprint by a factor around a center point. */
|
|
26
|
+
export declare function scale2D(bp: Blueprint, factor: number, center?: Point2D): Blueprint;
|
|
27
|
+
/** Mirror a 2D blueprint across a point or plane. */
|
|
28
|
+
export declare function mirror2D(bp: Blueprint, centerOrDirection: Point2D, origin?: Point2D, mode?: 'center' | 'plane'): Blueprint;
|
|
29
|
+
/** Stretch a 2D blueprint along a direction by a given ratio. */
|
|
30
|
+
export declare function stretch2D(bp: Blueprint, ratio: number, direction: Point2D, origin?: Point2D): Blueprint;
|
|
31
|
+
/** Project a blueprint onto a 3D plane, producing sketch data. */
|
|
32
|
+
export declare function sketch2DOnPlane(bp: Blueprint, inputPlane?: PlaneName | Plane, origin?: PointInput | number): any;
|
|
33
|
+
/** Map a blueprint onto a 3D face's UV surface, producing sketch data. */
|
|
34
|
+
export declare function sketch2DOnFace(bp: Blueprint, face: Face, scaleMode?: ScaleMode): any;
|
|
35
|
+
/** @deprecated Use getBounds2D instead. Will be removed in v8.0.0. */
|
|
18
36
|
export declare function blueprintBoundingBox(bp: Blueprint): BoundingBox2d;
|
|
19
|
-
/**
|
|
20
|
-
* Get the winding direction of a blueprint (`'clockwise'` or `'counterClockwise'`).
|
|
21
|
-
*
|
|
22
|
-
* @see {@link Blueprint.orientation}
|
|
23
|
-
*/
|
|
37
|
+
/** @deprecated Use getOrientation2D instead. Will be removed in v8.0.0. */
|
|
24
38
|
export declare function blueprintOrientation(bp: Blueprint): 'clockwise' | 'counterClockwise';
|
|
25
|
-
/**
|
|
26
|
-
* Translate a blueprint by the given x and y distances.
|
|
27
|
-
*
|
|
28
|
-
* @returns A new translated Blueprint.
|
|
29
|
-
* @see {@link Blueprint.translate}
|
|
30
|
-
*/
|
|
39
|
+
/** @deprecated Use translate2D instead. Will be removed in v8.0.0. */
|
|
31
40
|
export declare function translateBlueprint(bp: Blueprint, dx: number, dy: number): Blueprint;
|
|
32
|
-
/**
|
|
33
|
-
* Rotate a blueprint by the given angle in degrees.
|
|
34
|
-
*
|
|
35
|
-
* @param center - Center of rotation (defaults to the origin).
|
|
36
|
-
* @returns A new rotated Blueprint.
|
|
37
|
-
* @see {@link Blueprint.rotate}
|
|
38
|
-
*/
|
|
41
|
+
/** @deprecated Use rotate2D instead. Will be removed in v8.0.0. */
|
|
39
42
|
export declare function rotateBlueprint(bp: Blueprint, angle: number, center?: Point2D): Blueprint;
|
|
40
|
-
/**
|
|
41
|
-
* Uniformly scale a blueprint by a factor around a center point.
|
|
42
|
-
*
|
|
43
|
-
* @param center - Center of scaling (defaults to the bounding box center).
|
|
44
|
-
* @returns A new scaled Blueprint.
|
|
45
|
-
* @see {@link Blueprint.scale}
|
|
46
|
-
*/
|
|
43
|
+
/** @deprecated Use scale2D instead. Will be removed in v8.0.0. */
|
|
47
44
|
export declare function scaleBlueprint(bp: Blueprint, factor: number, center?: Point2D): Blueprint;
|
|
48
|
-
/**
|
|
49
|
-
* Mirror a blueprint across a point or plane.
|
|
50
|
-
*
|
|
51
|
-
* @param mode - `'center'` for point symmetry, `'plane'` for reflection across an axis.
|
|
52
|
-
* @returns A new mirrored Blueprint.
|
|
53
|
-
* @see {@link Blueprint.mirror}
|
|
54
|
-
*/
|
|
45
|
+
/** @deprecated Use mirror2D instead. Will be removed in v8.0.0. */
|
|
55
46
|
export declare function mirrorBlueprint(bp: Blueprint, centerOrDirection: Point2D, origin?: Point2D, mode?: 'center' | 'plane'): Blueprint;
|
|
56
|
-
/**
|
|
57
|
-
* Stretch a blueprint along a direction by a given ratio.
|
|
58
|
-
*
|
|
59
|
-
* @returns A new stretched Blueprint.
|
|
60
|
-
* @see {@link Blueprint.stretch}
|
|
61
|
-
*/
|
|
47
|
+
/** @deprecated Use stretch2D instead. Will be removed in v8.0.0. */
|
|
62
48
|
export declare function stretchBlueprint(bp: Blueprint, ratio: number, direction: Point2D, origin?: Point2D): Blueprint;
|
|
63
|
-
/**
|
|
64
|
-
* Convert a blueprint to an SVG path `d` attribute string.
|
|
65
|
-
*
|
|
66
|
-
* @see {@link Blueprint.toSVGPathD}
|
|
67
|
-
*/
|
|
49
|
+
/** @deprecated Use toSVGPathD instead. Will be removed in v8.0.0. */
|
|
68
50
|
export declare function blueprintToSVGPathD(bp: Blueprint): string;
|
|
69
|
-
/**
|
|
70
|
-
* Test whether a 2D point lies strictly inside the blueprint.
|
|
71
|
-
*
|
|
72
|
-
* @returns `true` if the point is inside (boundary points return `false`).
|
|
73
|
-
* @see {@link Blueprint.isInside}
|
|
74
|
-
*/
|
|
51
|
+
/** @deprecated Use isInside2D instead. Will be removed in v8.0.0. */
|
|
75
52
|
export declare function blueprintIsInside(bp: Blueprint, point: Point2D): boolean;
|
|
76
|
-
/**
|
|
77
|
-
* Project a blueprint onto a 3D plane, producing sketch data.
|
|
78
|
-
*
|
|
79
|
-
* @see {@link Blueprint.sketchOnPlane}
|
|
80
|
-
*/
|
|
53
|
+
/** @deprecated Use sketch2DOnPlane instead. Will be removed in v8.0.0. */
|
|
81
54
|
export declare function sketchBlueprintOnPlane(bp: Blueprint, inputPlane?: PlaneName | Plane, origin?: PointInput | number): any;
|
|
82
|
-
/**
|
|
83
|
-
* Map a blueprint onto a 3D face's UV surface, producing sketch data.
|
|
84
|
-
*
|
|
85
|
-
* @see {@link Blueprint.sketchOnFace}
|
|
86
|
-
*/
|
|
55
|
+
/** @deprecated Use sketch2DOnFace instead. Will be removed in v8.0.0. */
|
|
87
56
|
export declare function sketchBlueprintOnFace(bp: Blueprint, face: Face, scaleMode?: ScaleMode): any;
|
|
88
57
|
//# sourceMappingURL=blueprintFns.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blueprintFns.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/blueprintFns.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AACjE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AACrD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAE9C;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,QAAQ,CAAC,GAAG,SAAS,CAEtE;AAED
|
|
1
|
+
{"version":3,"file":"blueprintFns.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/blueprintFns.ts"],"names":[],"mappings":"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"}
|
|
@@ -5,18 +5,20 @@ import { Shape2D } from './boolean2D.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Compute the boolean union of two 2D shapes.
|
|
7
7
|
*
|
|
8
|
+
* @deprecated Use fuse2D instead. Will be removed in v8.0.0.
|
|
8
9
|
* @returns The fused shape, or `null` if the result is empty.
|
|
9
10
|
* @see {@link fuse2D}
|
|
10
11
|
*
|
|
11
12
|
* @example
|
|
12
13
|
* ```ts
|
|
13
|
-
* const union =
|
|
14
|
+
* const union = fuse2D(circle, rectangle);
|
|
14
15
|
* ```
|
|
15
16
|
*/
|
|
16
17
|
export declare function fuseBlueprint2D(a: Blueprint | CompoundBlueprint | Blueprints, b: Blueprint | CompoundBlueprint | Blueprints): Shape2D;
|
|
17
18
|
/**
|
|
18
19
|
* Compute the boolean difference of two 2D shapes (base minus tool).
|
|
19
20
|
*
|
|
21
|
+
* @deprecated Use cut2D instead. Will be removed in v8.0.0.
|
|
20
22
|
* @param base - The shape to cut from.
|
|
21
23
|
* @param tool - The shape to subtract.
|
|
22
24
|
* @returns The remaining shape, or `null` if nothing remains.
|
|
@@ -24,19 +26,20 @@ export declare function fuseBlueprint2D(a: Blueprint | CompoundBlueprint | Bluep
|
|
|
24
26
|
*
|
|
25
27
|
* @example
|
|
26
28
|
* ```ts
|
|
27
|
-
* const withHole =
|
|
29
|
+
* const withHole = cut2D(outerRect, innerCircle);
|
|
28
30
|
* ```
|
|
29
31
|
*/
|
|
30
32
|
export declare function cutBlueprint2D(base: Blueprint | CompoundBlueprint | Blueprints, tool: Blueprint | CompoundBlueprint | Blueprints): Shape2D;
|
|
31
33
|
/**
|
|
32
34
|
* Compute the boolean intersection of two 2D shapes.
|
|
33
35
|
*
|
|
36
|
+
* @deprecated Use intersect2D instead. Will be removed in v8.0.0.
|
|
34
37
|
* @returns The overlapping region, or `null` if the shapes do not overlap.
|
|
35
38
|
* @see {@link intersect2D}
|
|
36
39
|
*
|
|
37
40
|
* @example
|
|
38
41
|
* ```ts
|
|
39
|
-
* const overlap =
|
|
42
|
+
* const overlap = intersect2D(circle, rectangle);
|
|
40
43
|
* ```
|
|
41
44
|
*/
|
|
42
45
|
export declare function intersectBlueprint2D(a: Blueprint | CompoundBlueprint | Blueprints, b: Blueprint | CompoundBlueprint | Blueprints): Shape2D;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"boolean2dFns.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/boolean2dFns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAA8B,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE1E
|
|
1
|
+
{"version":3,"file":"boolean2dFns.d.ts","sourceRoot":"","sources":["../../../src/2d/blueprints/boolean2dFns.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,SAAS,MAAM,gBAAgB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,iBAAiB,CAAC;AAC9C,OAAO,KAAK,iBAAiB,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAA8B,KAAK,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE1E;;;;;;;;;;;GAWG;AACH,wBAAgB,eAAe,CAC7B,CAAC,EAAE,SAAS,GAAG,iBAAiB,GAAG,UAAU,EAC7C,CAAC,EAAE,SAAS,GAAG,iBAAiB,GAAG,UAAU,GAC5C,OAAO,CAET;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,SAAS,GAAG,iBAAiB,GAAG,UAAU,EAChD,IAAI,EAAE,SAAS,GAAG,iBAAiB,GAAG,UAAU,GAC/C,OAAO,CAET;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,SAAS,GAAG,iBAAiB,GAAG,UAAU,EAC7C,CAAC,EAAE,SAAS,GAAG,iBAAiB,GAAG,UAAU,GAC5C,OAAO,CAET"}
|
package/dist/2d.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
|
-
const Blueprint = require("./Blueprint-
|
|
4
|
-
const boolean2D = require("./boolean2D-
|
|
3
|
+
const Blueprint = require("./Blueprint-3Dyu0OL6.cjs");
|
|
4
|
+
const boolean2D = require("./boolean2D-BwOpOv6L.cjs");
|
|
5
5
|
function reverseCurve(curve) {
|
|
6
6
|
const cloned = curve.clone();
|
|
7
7
|
cloned.reverse();
|
|
@@ -34,38 +34,71 @@ function curve2dDistanceFrom(curve, point) {
|
|
|
34
34
|
function createBlueprint(curves) {
|
|
35
35
|
return new Blueprint.Blueprint(curves);
|
|
36
36
|
}
|
|
37
|
-
function
|
|
37
|
+
function getBounds2D(bp) {
|
|
38
38
|
return bp.boundingBox;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function getOrientation2D(bp) {
|
|
41
41
|
return bp.orientation;
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function isInside2D(bp, point) {
|
|
44
|
+
return bp.isInside(point);
|
|
45
|
+
}
|
|
46
|
+
function toSVGPathD(bp) {
|
|
47
|
+
return bp.toSVGPathD();
|
|
48
|
+
}
|
|
49
|
+
function translate2D(bp, dx, dy) {
|
|
44
50
|
return bp.translate(dx, dy);
|
|
45
51
|
}
|
|
46
|
-
function
|
|
52
|
+
function rotate2D(bp, angle, center) {
|
|
47
53
|
return bp.rotate(angle, center);
|
|
48
54
|
}
|
|
49
|
-
function
|
|
55
|
+
function scale2D(bp, factor, center) {
|
|
50
56
|
return bp.scale(factor, center);
|
|
51
57
|
}
|
|
52
|
-
function
|
|
58
|
+
function mirror2D(bp, centerOrDirection, origin, mode) {
|
|
53
59
|
return bp.mirror(centerOrDirection, origin, mode);
|
|
54
60
|
}
|
|
55
|
-
function
|
|
61
|
+
function stretch2D(bp, ratio, direction, origin) {
|
|
56
62
|
return bp.stretch(ratio, direction, origin);
|
|
57
63
|
}
|
|
64
|
+
function sketch2DOnPlane(bp, inputPlane, origin) {
|
|
65
|
+
return bp.sketchOnPlane(inputPlane, origin);
|
|
66
|
+
}
|
|
67
|
+
function sketch2DOnFace(bp, face, scaleMode) {
|
|
68
|
+
return bp.sketchOnFace(face, scaleMode);
|
|
69
|
+
}
|
|
70
|
+
function blueprintBoundingBox(bp) {
|
|
71
|
+
return getBounds2D(bp);
|
|
72
|
+
}
|
|
73
|
+
function blueprintOrientation(bp) {
|
|
74
|
+
return getOrientation2D(bp);
|
|
75
|
+
}
|
|
76
|
+
function translateBlueprint(bp, dx, dy) {
|
|
77
|
+
return translate2D(bp, dx, dy);
|
|
78
|
+
}
|
|
79
|
+
function rotateBlueprint(bp, angle, center) {
|
|
80
|
+
return rotate2D(bp, angle, center);
|
|
81
|
+
}
|
|
82
|
+
function scaleBlueprint(bp, factor, center) {
|
|
83
|
+
return scale2D(bp, factor, center);
|
|
84
|
+
}
|
|
85
|
+
function mirrorBlueprint(bp, centerOrDirection, origin, mode) {
|
|
86
|
+
return mirror2D(bp, centerOrDirection, origin, mode);
|
|
87
|
+
}
|
|
88
|
+
function stretchBlueprint(bp, ratio, direction, origin) {
|
|
89
|
+
return stretch2D(bp, ratio, direction, origin);
|
|
90
|
+
}
|
|
58
91
|
function blueprintToSVGPathD(bp) {
|
|
59
|
-
return
|
|
92
|
+
return toSVGPathD(bp);
|
|
60
93
|
}
|
|
61
94
|
function blueprintIsInside(bp, point) {
|
|
62
|
-
return bp
|
|
95
|
+
return isInside2D(bp, point);
|
|
63
96
|
}
|
|
64
97
|
function sketchBlueprintOnPlane(bp, inputPlane, origin) {
|
|
65
|
-
return bp
|
|
98
|
+
return sketch2DOnPlane(bp, inputPlane, origin);
|
|
66
99
|
}
|
|
67
100
|
function sketchBlueprintOnFace(bp, face, scaleMode) {
|
|
68
|
-
return bp
|
|
101
|
+
return sketch2DOnFace(bp, face, scaleMode);
|
|
69
102
|
}
|
|
70
103
|
function fuseBlueprint2D(a, b) {
|
|
71
104
|
return boolean2D.fuse2D(a, b);
|
|
@@ -106,12 +139,23 @@ exports.curve2dSplitAt = curve2dSplitAt;
|
|
|
106
139
|
exports.curve2dTangentAt = curve2dTangentAt;
|
|
107
140
|
exports.cutBlueprint2D = cutBlueprint2D;
|
|
108
141
|
exports.fuseBlueprint2D = fuseBlueprint2D;
|
|
142
|
+
exports.getBounds2D = getBounds2D;
|
|
143
|
+
exports.getOrientation2D = getOrientation2D;
|
|
109
144
|
exports.intersectBlueprint2D = intersectBlueprint2D;
|
|
145
|
+
exports.isInside2D = isInside2D;
|
|
146
|
+
exports.mirror2D = mirror2D;
|
|
110
147
|
exports.mirrorBlueprint = mirrorBlueprint;
|
|
111
148
|
exports.reverseCurve = reverseCurve;
|
|
149
|
+
exports.rotate2D = rotate2D;
|
|
112
150
|
exports.rotateBlueprint = rotateBlueprint;
|
|
151
|
+
exports.scale2D = scale2D;
|
|
113
152
|
exports.scaleBlueprint = scaleBlueprint;
|
|
153
|
+
exports.sketch2DOnFace = sketch2DOnFace;
|
|
154
|
+
exports.sketch2DOnPlane = sketch2DOnPlane;
|
|
114
155
|
exports.sketchBlueprintOnFace = sketchBlueprintOnFace;
|
|
115
156
|
exports.sketchBlueprintOnPlane = sketchBlueprintOnPlane;
|
|
157
|
+
exports.stretch2D = stretch2D;
|
|
116
158
|
exports.stretchBlueprint = stretchBlueprint;
|
|
159
|
+
exports.toSVGPathD = toSVGPathD;
|
|
160
|
+
exports.translate2D = translate2D;
|
|
117
161
|
exports.translateBlueprint = translateBlueprint;
|
package/dist/2d.d.ts
CHANGED
|
@@ -3,13 +3,17 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @example
|
|
5
5
|
* ```typescript
|
|
6
|
-
* import { createBlueprint,
|
|
6
|
+
* import { createBlueprint, fuse2D, Blueprint } from 'brepjs/2d';
|
|
7
|
+
*
|
|
8
|
+
* // Clean 2D API (recommended)
|
|
9
|
+
* const translated = translate2D(bp, 10, 20);
|
|
10
|
+
* const union = fuse2D(bp1, bp2);
|
|
7
11
|
* ```
|
|
8
12
|
*/
|
|
9
13
|
export { default as Blueprint } from './2d/blueprints/Blueprint.js';
|
|
10
14
|
export { default as CompoundBlueprint } from './2d/blueprints/CompoundBlueprint.js';
|
|
11
15
|
export { default as Blueprints } from './2d/blueprints/Blueprints.js';
|
|
12
|
-
export { createBlueprint, blueprintBoundingBox, blueprintOrientation, translateBlueprint, rotateBlueprint, scaleBlueprint, mirrorBlueprint, stretchBlueprint, blueprintToSVGPathD, blueprintIsInside, sketchBlueprintOnPlane, sketchBlueprintOnFace, } from './2d/blueprints/blueprintFns.js';
|
|
16
|
+
export { createBlueprint, getBounds2D, getOrientation2D, isInside2D, toSVGPathD, translate2D, rotate2D, scale2D, mirror2D, stretch2D, sketch2DOnPlane, sketch2DOnFace, blueprintBoundingBox, blueprintOrientation, translateBlueprint, rotateBlueprint, scaleBlueprint, mirrorBlueprint, stretchBlueprint, blueprintToSVGPathD, blueprintIsInside, sketchBlueprintOnPlane, sketchBlueprintOnFace, } from './2d/blueprints/blueprintFns.js';
|
|
13
17
|
export { fuseBlueprint2D, cutBlueprint2D, intersectBlueprint2D, } from './2d/blueprints/boolean2dFns.js';
|
|
14
18
|
export { fuseBlueprints, cutBlueprints, intersectBlueprints, } from './2d/blueprints/booleanOperations.js';
|
|
15
19
|
export { fuse2D, cut2D, intersect2D, type Shape2D } from './2d/blueprints/boolean2D.js';
|
package/dist/2d.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"2d.d.ts","sourceRoot":"","sources":["../src/2d.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"2d.d.ts","sourceRoot":"","sources":["../src/2d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AACpF,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAItE,OAAO,EACL,eAAe,EAEf,WAAW,EACX,gBAAgB,EAChB,UAAU,EACV,UAAU,EACV,WAAW,EACX,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,SAAS,EACT,eAAe,EACf,cAAc,EAEd,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,cAAc,EACd,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,qBAAqB,GACtB,MAAM,iCAAiC,CAAC;AAIzC,OAAO,EAEL,eAAe,EACf,cAAc,EACd,oBAAoB,GACrB,MAAM,iCAAiC,CAAC;AAEzC,OAAO,EACL,cAAc,EACd,aAAa,EACb,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAIxF,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,wBAAwB,CAAC;AAIhC,OAAO,EAAE,KAAK,OAAO,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,MAAM,qCAAqC,CAAC;AACpG,YAAY,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC"}
|