@bitbybit-dev/jscad 1.2.0 → 1.3.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/jscad-generated.js +10 -27484
- package/lib/api/inputs/jscad-inputs.d.ts +562 -263
- package/lib/api/inputs/jscad-inputs.js +483 -213
- package/lib/api/jscad-service.d.ts +94 -19
- package/lib/api/jscad-service.js +94 -19
- package/lib/api/services/jscad-booleans.d.ts +81 -23
- package/lib/api/services/jscad-booleans.js +84 -24
- package/lib/api/services/jscad-colors.d.ts +14 -5
- package/lib/api/services/jscad-colors.js +14 -5
- package/lib/api/services/jscad-expansions.d.ts +29 -8
- package/lib/api/services/jscad-expansions.js +33 -16
- package/lib/api/services/jscad-extrusions.d.ts +50 -14
- package/lib/api/services/jscad-extrusions.js +50 -14
- package/lib/api/services/jscad-hulls.d.ts +42 -10
- package/lib/api/services/jscad-hulls.js +45 -11
- package/lib/api/services/jscad-path.d.ts +85 -25
- package/lib/api/services/jscad-path.js +85 -25
- package/lib/api/services/jscad-polygon.d.ts +105 -35
- package/lib/api/services/jscad-polygon.js +105 -35
- package/lib/api/services/jscad-shapes.d.ts +190 -62
- package/lib/api/services/jscad-shapes.js +193 -64
- package/lib/api/services/jscad-text.d.ts +38 -11
- package/lib/api/services/jscad-text.js +38 -11
- package/package.json +7 -7
|
@@ -11,8 +11,13 @@ import { JSCADHulls } from "./services/jscad-hulls";
|
|
|
11
11
|
import { JSCADColors } from "./services/jscad-colors";
|
|
12
12
|
import * as JSCAD from "@jscad/modeling";
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* The entry point to the JSCAD kernel, a mesh-based solid modeler with three kinds of geometry: a
|
|
15
|
+
* solid, held as a closed set of polygons; a flat 2D shape, held as a region in the XY plane; and a
|
|
16
|
+
* 2D path, an open or closed polyline in that plane. `shapes` and `polygon` build them, `booleans`,
|
|
17
|
+
* `extrusions`, `expansions` and `hulls` combine and grow them, `text` writes with them and
|
|
18
|
+
* `colors` tints them. Flat shapes live in the XY plane and extrude along Z. The methods on the
|
|
19
|
+
* service itself convert solids to mesh data, move them with matrices and write STL, DXF and 3MF
|
|
20
|
+
* files. Credit to the JSCAD community for the kernel.
|
|
16
21
|
*/
|
|
17
22
|
export declare class Jscad {
|
|
18
23
|
private jscad;
|
|
@@ -28,66 +33,136 @@ export declare class Jscad {
|
|
|
28
33
|
private point;
|
|
29
34
|
constructor(jscad: typeof JSCAD);
|
|
30
35
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
36
|
+
* Turns a solid into a list of triangles, each given as three points, with the solid's own
|
|
37
|
+
* transform already applied.
|
|
38
|
+
*
|
|
39
|
+
* A flat 2D shape is given a tiny thickness first so it has faces at all. An entity with no
|
|
40
|
+
* polygons gives an empty list.
|
|
41
|
+
* @param inputs - The solid or 2D shape
|
|
42
|
+
* @returns The triangles as lists of three points
|
|
34
43
|
* @group conversions
|
|
35
44
|
* @shortname to polygon points
|
|
36
45
|
* @drawable false
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const cube = await bitbybit.jscad.shapes.cube({ center: [0, 0, 0], size: 10 });
|
|
49
|
+
* const triangles = await bitbybit.jscad.toPolygonPoints({ mesh: cube });
|
|
50
|
+
* ```
|
|
37
51
|
*/
|
|
38
52
|
toPolygonPoints(inputs: Inputs.JSCAD.MeshDto): Base.Mesh3;
|
|
53
|
+
/**
|
|
54
|
+
* Turns several solids into mesh data, one entry per solid in the same order, as `shapeToMesh`
|
|
55
|
+
* does for one.
|
|
56
|
+
* @param inputs - The solids or 2D shapes
|
|
57
|
+
* @returns One mesh data entry per input, in the same order
|
|
58
|
+
*/
|
|
39
59
|
shapesToMeshes(inputs: Inputs.JSCAD.MeshesDto): Inputs.JSCAD.JSCADMeshData[];
|
|
60
|
+
/**
|
|
61
|
+
* Turns a solid into plain mesh data: flat position, normal and index lists plus the solid's
|
|
62
|
+
* own transform matrix, the form a renderer draws from.
|
|
63
|
+
*
|
|
64
|
+
* Polygons with more than three points are split into triangles as a fan; a flat 2D shape is
|
|
65
|
+
* given a tiny thickness first so it has faces at all.
|
|
66
|
+
* @param inputs - The solid or 2D shape
|
|
67
|
+
* @returns The positions, normals, indices and transform of the mesh
|
|
68
|
+
*/
|
|
40
69
|
shapeToMesh(inputs: Inputs.JSCAD.MeshDto): Inputs.JSCAD.JSCADMeshData;
|
|
41
70
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
71
|
+
* Moves, rotates or scales several solids with the same transformation, giving new solids in
|
|
72
|
+
* the same order.
|
|
73
|
+
*
|
|
74
|
+
* `transformation` is one 4x4 matrix, a list of matrices applied in order, or a list of such
|
|
75
|
+
* lists; a flat 2D shape or a path throws an error.
|
|
76
|
+
* @param inputs - The solids and the transformation
|
|
77
|
+
* @returns The transformed solids, in the same order
|
|
45
78
|
* @group transforms
|
|
46
79
|
* @shortname transform solids
|
|
47
80
|
* @drawable true
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const translation = bitbybit.transforms.translationXYZ({ translation: [10, 0, 0] });
|
|
84
|
+
* const moved = await bitbybit.jscad.transformSolids({ meshes: [cube, sphere], transformation: translation });
|
|
85
|
+
* ```
|
|
48
86
|
*/
|
|
49
87
|
transformSolids(inputs: Inputs.JSCAD.TransformSolidsDto): Inputs.JSCAD.JSCADEntity[];
|
|
50
88
|
/**
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
89
|
+
* Moves, rotates or scales a solid with a transformation, giving a new solid.
|
|
90
|
+
*
|
|
91
|
+
* `transformation` is one 4x4 matrix, a list of matrices applied in order, or a list of such
|
|
92
|
+
* lists; a flat 2D shape or a path throws an error.
|
|
93
|
+
* @param inputs - The solid and the transformation
|
|
94
|
+
* @returns The transformed solid
|
|
54
95
|
* @group transforms
|
|
55
96
|
* @shortname transform solid
|
|
56
97
|
* @drawable true
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const rotation = bitbybit.transforms.rotationCenterAxis({ angle: 45, axis: [0, 1, 0], center: [0, 0, 0] });
|
|
101
|
+
* const turned = await bitbybit.jscad.transformSolid({ mesh: cube, transformation: rotation });
|
|
102
|
+
* ```
|
|
57
103
|
*/
|
|
58
104
|
transformSolid(inputs: Inputs.JSCAD.TransformSolidDto): Inputs.JSCAD.JSCADEntity;
|
|
59
105
|
/**
|
|
60
|
-
*
|
|
61
|
-
*
|
|
106
|
+
* Writes a solid as a binary STL file, the common format for 3D printing, and downloads it in
|
|
107
|
+
* the browser as `fileName` plus `.stl`.
|
|
108
|
+
* @param inputs - The solid and the file name
|
|
109
|
+
* @returns The STL file as a blob; the asynchronous API starts the download instead and returns nothing
|
|
62
110
|
* @group io
|
|
63
111
|
* @shortname solid to stl
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* await bitbybit.jscad.downloadSolidSTL({ mesh: cube, fileName: "cube" });
|
|
115
|
+
* ```
|
|
64
116
|
*/
|
|
65
117
|
downloadSolidSTL(inputs: Inputs.JSCAD.DownloadSolidDto): {
|
|
66
118
|
blob: Blob;
|
|
67
119
|
};
|
|
68
120
|
/**
|
|
69
|
-
*
|
|
70
|
-
*
|
|
121
|
+
* Writes several solids into one binary STL file and downloads it in the browser as `fileName`
|
|
122
|
+
* plus `.stl`.
|
|
123
|
+
* @param inputs - The solids and the file name
|
|
124
|
+
* @returns The STL file as a blob; the asynchronous API starts the download instead and returns nothing
|
|
71
125
|
* @group io
|
|
72
126
|
* @shortname solids to stl
|
|
127
|
+
* @example
|
|
128
|
+
* ```typescript
|
|
129
|
+
* await bitbybit.jscad.downloadSolidsSTL({ meshes: [cube, sphere], fileName: "parts" });
|
|
130
|
+
* ```
|
|
73
131
|
*/
|
|
74
132
|
downloadSolidsSTL(inputs: Inputs.JSCAD.DownloadSolidsDto): {
|
|
75
133
|
blob: Blob;
|
|
76
134
|
};
|
|
77
135
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
136
|
+
* Writes a solid, a 2D shape, a path or a list of them as a DXF drawing file and downloads it
|
|
137
|
+
* in the browser as `fileName` plus `.dxf`.
|
|
138
|
+
*
|
|
139
|
+
* `options` is passed to the DXF writer as it is and can stay out.
|
|
140
|
+
* @param inputs - The geometry, the file name and the optional writer options
|
|
141
|
+
* @returns The DXF file as a blob; the asynchronous API starts the download instead and returns nothing
|
|
80
142
|
* @group io
|
|
81
143
|
* @shortname geometry to dxf
|
|
144
|
+
* @example
|
|
145
|
+
* ```typescript
|
|
146
|
+
* const circle = await bitbybit.jscad.polygon.circle({ center: [0, 0], radius: 5, segments: 32 });
|
|
147
|
+
* await bitbybit.jscad.downloadGeometryDxf({ geometry: circle, fileName: "circle", options: {} });
|
|
148
|
+
* ```
|
|
82
149
|
*/
|
|
83
150
|
downloadGeometryDxf(inputs: Inputs.JSCAD.DownloadGeometryDto): {
|
|
84
151
|
blob: Blob;
|
|
85
152
|
};
|
|
86
153
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
154
|
+
* Writes a solid, a 2D shape, a path or a list of them as a 3MF file, a modern 3D printing
|
|
155
|
+
* format, and downloads it in the browser as `fileName` plus `.3mf`.
|
|
156
|
+
*
|
|
157
|
+
* `options` is passed to the 3MF writer as it is and can stay out.
|
|
158
|
+
* @param inputs - The geometry, the file name and the optional writer options
|
|
159
|
+
* @returns The 3MF file as a blob; the asynchronous API starts the download instead and returns nothing
|
|
89
160
|
* @group io
|
|
90
161
|
* @shortname geometry to 3mf
|
|
162
|
+
* @example
|
|
163
|
+
* ```typescript
|
|
164
|
+
* await bitbybit.jscad.downloadGeometry3MF({ geometry: [cube, sphere], fileName: "parts", options: {} });
|
|
165
|
+
* ```
|
|
91
166
|
*/
|
|
92
167
|
downloadGeometry3MF(inputs: Inputs.JSCAD.DownloadGeometryDto): {
|
|
93
168
|
blob: Blob;
|
package/lib/api/jscad-service.js
CHANGED
|
@@ -11,8 +11,13 @@ import { JSCADText } from "./services/jscad-text";
|
|
|
11
11
|
import { JSCADHulls } from "./services/jscad-hulls";
|
|
12
12
|
import { JSCADColors } from "./services/jscad-colors";
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
14
|
+
* The entry point to the JSCAD kernel, a mesh-based solid modeler with three kinds of geometry: a
|
|
15
|
+
* solid, held as a closed set of polygons; a flat 2D shape, held as a region in the XY plane; and a
|
|
16
|
+
* 2D path, an open or closed polyline in that plane. `shapes` and `polygon` build them, `booleans`,
|
|
17
|
+
* `extrusions`, `expansions` and `hulls` combine and grow them, `text` writes with them and
|
|
18
|
+
* `colors` tints them. Flat shapes live in the XY plane and extrude along Z. The methods on the
|
|
19
|
+
* service itself convert solids to mesh data, move them with matrices and write STL, DXF and 3MF
|
|
20
|
+
* files. Credit to the JSCAD community for the kernel.
|
|
16
21
|
*/
|
|
17
22
|
export class Jscad {
|
|
18
23
|
constructor(jscad) {
|
|
@@ -39,12 +44,21 @@ export class Jscad {
|
|
|
39
44
|
this.jscad = jscad;
|
|
40
45
|
}
|
|
41
46
|
/**
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
47
|
+
* Turns a solid into a list of triangles, each given as three points, with the solid's own
|
|
48
|
+
* transform already applied.
|
|
49
|
+
*
|
|
50
|
+
* A flat 2D shape is given a tiny thickness first so it has faces at all. An entity with no
|
|
51
|
+
* polygons gives an empty list.
|
|
52
|
+
* @param inputs - The solid or 2D shape
|
|
53
|
+
* @returns The triangles as lists of three points
|
|
45
54
|
* @group conversions
|
|
46
55
|
* @shortname to polygon points
|
|
47
56
|
* @drawable false
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const cube = await bitbybit.jscad.shapes.cube({ center: [0, 0, 0], size: 10 });
|
|
60
|
+
* const triangles = await bitbybit.jscad.toPolygonPoints({ mesh: cube });
|
|
61
|
+
* ```
|
|
48
62
|
*/
|
|
49
63
|
toPolygonPoints(inputs) {
|
|
50
64
|
const meshData = this.shapeToMesh({ mesh: inputs.mesh });
|
|
@@ -75,11 +89,26 @@ export class Jscad {
|
|
|
75
89
|
}
|
|
76
90
|
return polygons;
|
|
77
91
|
}
|
|
92
|
+
/**
|
|
93
|
+
* Turns several solids into mesh data, one entry per solid in the same order, as `shapeToMesh`
|
|
94
|
+
* does for one.
|
|
95
|
+
* @param inputs - The solids or 2D shapes
|
|
96
|
+
* @returns One mesh data entry per input, in the same order
|
|
97
|
+
*/
|
|
78
98
|
shapesToMeshes(inputs) {
|
|
79
99
|
return inputs.meshes.map(mesh => {
|
|
80
100
|
return this.shapeToMesh(Object.assign(Object.assign({}, inputs), { mesh }));
|
|
81
101
|
});
|
|
82
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* Turns a solid into plain mesh data: flat position, normal and index lists plus the solid's
|
|
105
|
+
* own transform matrix, the form a renderer draws from.
|
|
106
|
+
*
|
|
107
|
+
* Polygons with more than three points are split into triangles as a fan; a flat 2D shape is
|
|
108
|
+
* given a tiny thickness first so it has faces at all.
|
|
109
|
+
* @param inputs - The solid or 2D shape
|
|
110
|
+
* @returns The positions, normals, indices and transform of the mesh
|
|
111
|
+
*/
|
|
83
112
|
shapeToMesh(inputs) {
|
|
84
113
|
let polygons = [];
|
|
85
114
|
if (this.legacyPolygons(inputs.mesh)) {
|
|
@@ -137,12 +166,21 @@ export class Jscad {
|
|
|
137
166
|
};
|
|
138
167
|
}
|
|
139
168
|
/**
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
169
|
+
* Moves, rotates or scales several solids with the same transformation, giving new solids in
|
|
170
|
+
* the same order.
|
|
171
|
+
*
|
|
172
|
+
* `transformation` is one 4x4 matrix, a list of matrices applied in order, or a list of such
|
|
173
|
+
* lists; a flat 2D shape or a path throws an error.
|
|
174
|
+
* @param inputs - The solids and the transformation
|
|
175
|
+
* @returns The transformed solids, in the same order
|
|
143
176
|
* @group transforms
|
|
144
177
|
* @shortname transform solids
|
|
145
178
|
* @drawable true
|
|
179
|
+
* @example
|
|
180
|
+
* ```typescript
|
|
181
|
+
* const translation = bitbybit.transforms.translationXYZ({ translation: [10, 0, 0] });
|
|
182
|
+
* const moved = await bitbybit.jscad.transformSolids({ meshes: [cube, sphere], transformation: translation });
|
|
183
|
+
* ```
|
|
146
184
|
*/
|
|
147
185
|
transformSolids(inputs) {
|
|
148
186
|
const solidsToTransform = inputs.meshes;
|
|
@@ -151,12 +189,20 @@ export class Jscad {
|
|
|
151
189
|
});
|
|
152
190
|
}
|
|
153
191
|
/**
|
|
154
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
192
|
+
* Moves, rotates or scales a solid with a transformation, giving a new solid.
|
|
193
|
+
*
|
|
194
|
+
* `transformation` is one 4x4 matrix, a list of matrices applied in order, or a list of such
|
|
195
|
+
* lists; a flat 2D shape or a path throws an error.
|
|
196
|
+
* @param inputs - The solid and the transformation
|
|
197
|
+
* @returns The transformed solid
|
|
157
198
|
* @group transforms
|
|
158
199
|
* @shortname transform solid
|
|
159
200
|
* @drawable true
|
|
201
|
+
* @example
|
|
202
|
+
* ```typescript
|
|
203
|
+
* const rotation = bitbybit.transforms.rotationCenterAxis({ angle: 45, axis: [0, 1, 0], center: [0, 0, 0] });
|
|
204
|
+
* const turned = await bitbybit.jscad.transformSolid({ mesh: cube, transformation: rotation });
|
|
205
|
+
* ```
|
|
160
206
|
*/
|
|
161
207
|
transformSolid(inputs) {
|
|
162
208
|
const transformation = inputs.transformation;
|
|
@@ -179,10 +225,16 @@ export class Jscad {
|
|
|
179
225
|
return transformedMesh;
|
|
180
226
|
}
|
|
181
227
|
/**
|
|
182
|
-
*
|
|
183
|
-
*
|
|
228
|
+
* Writes a solid as a binary STL file, the common format for 3D printing, and downloads it in
|
|
229
|
+
* the browser as `fileName` plus `.stl`.
|
|
230
|
+
* @param inputs - The solid and the file name
|
|
231
|
+
* @returns The STL file as a blob; the asynchronous API starts the download instead and returns nothing
|
|
184
232
|
* @group io
|
|
185
233
|
* @shortname solid to stl
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* await bitbybit.jscad.downloadSolidSTL({ mesh: cube, fileName: "cube" });
|
|
237
|
+
* ```
|
|
186
238
|
*/
|
|
187
239
|
downloadSolidSTL(inputs) {
|
|
188
240
|
const rawData = this.jscad.STLSERIALIZER.serialize({ binary: true }, inputs.mesh);
|
|
@@ -190,10 +242,16 @@ export class Jscad {
|
|
|
190
242
|
return { blob: madeBlob };
|
|
191
243
|
}
|
|
192
244
|
/**
|
|
193
|
-
*
|
|
194
|
-
*
|
|
245
|
+
* Writes several solids into one binary STL file and downloads it in the browser as `fileName`
|
|
246
|
+
* plus `.stl`.
|
|
247
|
+
* @param inputs - The solids and the file name
|
|
248
|
+
* @returns The STL file as a blob; the asynchronous API starts the download instead and returns nothing
|
|
195
249
|
* @group io
|
|
196
250
|
* @shortname solids to stl
|
|
251
|
+
* @example
|
|
252
|
+
* ```typescript
|
|
253
|
+
* await bitbybit.jscad.downloadSolidsSTL({ meshes: [cube, sphere], fileName: "parts" });
|
|
254
|
+
* ```
|
|
197
255
|
*/
|
|
198
256
|
downloadSolidsSTL(inputs) {
|
|
199
257
|
const rawData = this.jscad.STLSERIALIZER.serialize({ binary: true }, ...inputs.meshes);
|
|
@@ -201,10 +259,19 @@ export class Jscad {
|
|
|
201
259
|
return { blob: madeBlob };
|
|
202
260
|
}
|
|
203
261
|
/**
|
|
204
|
-
*
|
|
205
|
-
*
|
|
262
|
+
* Writes a solid, a 2D shape, a path or a list of them as a DXF drawing file and downloads it
|
|
263
|
+
* in the browser as `fileName` plus `.dxf`.
|
|
264
|
+
*
|
|
265
|
+
* `options` is passed to the DXF writer as it is and can stay out.
|
|
266
|
+
* @param inputs - The geometry, the file name and the optional writer options
|
|
267
|
+
* @returns The DXF file as a blob; the asynchronous API starts the download instead and returns nothing
|
|
206
268
|
* @group io
|
|
207
269
|
* @shortname geometry to dxf
|
|
270
|
+
* @example
|
|
271
|
+
* ```typescript
|
|
272
|
+
* const circle = await bitbybit.jscad.polygon.circle({ center: [0, 0], radius: 5, segments: 32 });
|
|
273
|
+
* await bitbybit.jscad.downloadGeometryDxf({ geometry: circle, fileName: "circle", options: {} });
|
|
274
|
+
* ```
|
|
208
275
|
*/
|
|
209
276
|
downloadGeometryDxf(inputs) {
|
|
210
277
|
const options = inputs.options ? inputs.options : {};
|
|
@@ -213,10 +280,18 @@ export class Jscad {
|
|
|
213
280
|
return { blob: madeBlob };
|
|
214
281
|
}
|
|
215
282
|
/**
|
|
216
|
-
*
|
|
217
|
-
*
|
|
283
|
+
* Writes a solid, a 2D shape, a path or a list of them as a 3MF file, a modern 3D printing
|
|
284
|
+
* format, and downloads it in the browser as `fileName` plus `.3mf`.
|
|
285
|
+
*
|
|
286
|
+
* `options` is passed to the 3MF writer as it is and can stay out.
|
|
287
|
+
* @param inputs - The geometry, the file name and the optional writer options
|
|
288
|
+
* @returns The 3MF file as a blob; the asynchronous API starts the download instead and returns nothing
|
|
218
289
|
* @group io
|
|
219
290
|
* @shortname geometry to 3mf
|
|
291
|
+
* @example
|
|
292
|
+
* ```typescript
|
|
293
|
+
* await bitbybit.jscad.downloadGeometry3MF({ geometry: [cube, sphere], fileName: "parts", options: {} });
|
|
294
|
+
* ```
|
|
220
295
|
*/
|
|
221
296
|
downloadGeometry3MF(inputs) {
|
|
222
297
|
const options = inputs.options ? inputs.options : {};
|
|
@@ -1,73 +1,131 @@
|
|
|
1
1
|
import * as Inputs from "../inputs/jscad-inputs";
|
|
2
2
|
import * as JSCAD from "@jscad/modeling";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Combining JSCAD geometry: union fuses, subtract cuts and intersect keeps the overlap, in a
|
|
5
|
+
* two-input form and a many-input form. All inputs of one call must be of the same kind, either
|
|
6
|
+
* solids or flat 2D shapes, or the kernel throws an error; a path cannot be combined. Every method
|
|
7
|
+
* gives new geometry and leaves the inputs as they are.
|
|
6
8
|
*/
|
|
7
9
|
export declare class JSCADBooleans {
|
|
8
10
|
private readonly jscad;
|
|
9
11
|
constructor(jscad: typeof JSCAD);
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
13
|
+
* Keeps only the volume or area that all the inputs share, dropping everything else.
|
|
14
|
+
*
|
|
15
|
+
* The inputs must all be solids or all be 2D shapes; an empty result is possible when they do
|
|
16
|
+
* not overlap.
|
|
17
|
+
* @param inputs - The solids or 2D shapes to intersect
|
|
18
|
+
* @returns The shared part as one solid or 2D shape
|
|
14
19
|
* @group boolean
|
|
15
20
|
* @shortname intersect
|
|
16
21
|
* @drawable true
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const common = await bitbybit.jscad.booleans.intersect({ meshes: [cube, sphere] });
|
|
25
|
+
* ```
|
|
17
26
|
*/
|
|
18
27
|
intersect(inputs: Inputs.JSCAD.BooleanObjectsDto): Inputs.JSCAD.JSCADEntity;
|
|
19
28
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
29
|
+
* Cuts every later input out of the first one, leaving what remains of the first.
|
|
30
|
+
*
|
|
31
|
+
* The inputs must all be solids or all be 2D shapes; the order matters, the first is the one
|
|
32
|
+
* being cut.
|
|
33
|
+
* @param inputs - The geometry to cut from, first, followed by the geometry to cut with
|
|
34
|
+
* @returns The first input minus the others
|
|
23
35
|
* @group boolean
|
|
24
36
|
* @shortname subtract
|
|
25
37
|
* @drawable true
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const holed = await bitbybit.jscad.booleans.subtract({ meshes: [cube, cylinder1, cylinder2] });
|
|
41
|
+
* ```
|
|
26
42
|
*/
|
|
27
43
|
subtract(inputs: Inputs.JSCAD.BooleanObjectsDto): Inputs.JSCAD.JSCADEntity;
|
|
28
44
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
45
|
+
* Fuses all the inputs into one solid or one 2D shape, merging where they overlap and keeping
|
|
46
|
+
* separate parts as one entity.
|
|
47
|
+
*
|
|
48
|
+
* The inputs must all be solids or all be 2D shapes.
|
|
49
|
+
* @param inputs - The solids or 2D shapes to fuse
|
|
50
|
+
* @returns The fused solid or 2D shape
|
|
32
51
|
* @group boolean
|
|
33
52
|
* @shortname union
|
|
34
53
|
* @drawable true
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const fused = await bitbybit.jscad.booleans.union({ meshes: [cube, sphere] });
|
|
57
|
+
* ```
|
|
35
58
|
*/
|
|
36
59
|
union(inputs: Inputs.JSCAD.BooleanObjectsDto): Inputs.JSCAD.JSCADEntity;
|
|
37
60
|
/**
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
* @
|
|
61
|
+
* Keeps only the volume or area that `first` and `second` share, the two-input form of
|
|
62
|
+
* `intersect`.
|
|
63
|
+
* @param inputs - The two solids or two 2D shapes
|
|
64
|
+
* @returns The shared part
|
|
41
65
|
* @group boolean
|
|
42
66
|
* @shortname intersect two
|
|
43
67
|
* @drawable true
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const common = await bitbybit.jscad.booleans.intersectTwo({ first: cube, second: sphere });
|
|
71
|
+
* ```
|
|
44
72
|
*/
|
|
45
73
|
intersectTwo(inputs: Inputs.JSCAD.BooleanTwoObjectsDto): Inputs.JSCAD.JSCADEntity;
|
|
46
74
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @param inputs
|
|
49
|
-
* @returns
|
|
75
|
+
* Cuts `second` out of `first`, the two-input form of `subtract`.
|
|
76
|
+
* @param inputs - The geometry to cut from and the geometry to cut with
|
|
77
|
+
* @returns The first input minus the second
|
|
50
78
|
* @group boolean
|
|
51
79
|
* @shortname subtract two
|
|
52
80
|
* @drawable true
|
|
81
|
+
* @example
|
|
82
|
+
* ```typescript
|
|
83
|
+
* const holed = await bitbybit.jscad.booleans.subtractTwo({ first: cube, second: sphere });
|
|
84
|
+
* ```
|
|
53
85
|
*/
|
|
54
86
|
subtractTwo(inputs: Inputs.JSCAD.BooleanTwoObjectsDto): Inputs.JSCAD.JSCADEntity;
|
|
55
87
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param inputs
|
|
58
|
-
* @returns
|
|
88
|
+
* Fuses `first` and `second` into one, the two-input form of `union`.
|
|
89
|
+
* @param inputs - The two solids or two 2D shapes
|
|
90
|
+
* @returns The fused solid or 2D shape
|
|
59
91
|
* @group boolean
|
|
60
92
|
* @shortname union two
|
|
61
93
|
* @drawable true
|
|
94
|
+
* @example
|
|
95
|
+
* ```typescript
|
|
96
|
+
* const fused = await bitbybit.jscad.booleans.unionTwo({ first: cube, second: sphere });
|
|
97
|
+
* ```
|
|
62
98
|
*/
|
|
63
99
|
unionTwo(inputs: Inputs.JSCAD.BooleanTwoObjectsDto): Inputs.JSCAD.JSCADEntity;
|
|
64
100
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* @
|
|
101
|
+
* Cuts every entry of `meshes` out of `from`, leaving what remains of `from`; the same as
|
|
102
|
+
* `subtract` with the base geometry named separately.
|
|
103
|
+
* @param inputs - The geometry to cut from and the list of geometry to cut with
|
|
104
|
+
* @returns The base geometry minus the others
|
|
68
105
|
* @group boolean
|
|
69
106
|
* @shortname subtract from
|
|
70
107
|
* @drawable true
|
|
108
|
+
* @example
|
|
109
|
+
* ```typescript
|
|
110
|
+
* const holed = await bitbybit.jscad.booleans.subtractFrom({ from: cube, meshes: [cylinder1, cylinder2] });
|
|
111
|
+
* ```
|
|
71
112
|
*/
|
|
72
113
|
subtractFrom(inputs: Inputs.JSCAD.BooleanObjectsFromDto): Inputs.JSCAD.JSCADEntity;
|
|
114
|
+
/**
|
|
115
|
+
* Sweeps each later solid over the whole surface of the running result and fuses everything it
|
|
116
|
+
* passes through, so the first solid grows by the shape of the others - the Minkowski sum,
|
|
117
|
+
* which is how a solid is rounded or padded by a sphere.
|
|
118
|
+
*
|
|
119
|
+
* Solids only; a 2D shape or a path throws an error.
|
|
120
|
+
* @param inputs - The solids to sum, at least two
|
|
121
|
+
* @returns The grown solid
|
|
122
|
+
* @group minkowski
|
|
123
|
+
* @shortname minkowski sum
|
|
124
|
+
* @drawable true
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* const padded = await bitbybit.jscad.booleans.minkowskiSum({ meshes: [cube, sphere] });
|
|
128
|
+
* ```
|
|
129
|
+
*/
|
|
130
|
+
minkowskiSum(inputs: Inputs.JSCAD.MinkowskiSumDto): Inputs.JSCAD.JSCADEntity;
|
|
73
131
|
}
|