@bitbybit-dev/manifold 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/lib/api/inputs/manifold-inputs.d.ts +521 -224
- package/lib/api/inputs/manifold-inputs.js +380 -135
- package/lib/api/manifold-service.d.ts +37 -11
- package/lib/api/manifold-service.js +37 -11
- package/lib/api/services/cross-section/cross-section-booleans.d.ts +66 -29
- package/lib/api/services/cross-section/cross-section-booleans.js +66 -29
- package/lib/api/services/cross-section/cross-section-evaluate.d.ts +38 -17
- package/lib/api/services/cross-section/cross-section-evaluate.js +38 -17
- package/lib/api/services/cross-section/cross-section-operations.d.ts +73 -33
- package/lib/api/services/cross-section/cross-section-operations.js +73 -33
- package/lib/api/services/cross-section/cross-section-shapes.d.ts +38 -17
- package/lib/api/services/cross-section/cross-section-shapes.js +38 -17
- package/lib/api/services/cross-section/cross-section-transforms.d.ts +64 -29
- package/lib/api/services/cross-section/cross-section-transforms.js +64 -29
- package/lib/api/services/cross-section/cross-section.d.ts +81 -20
- package/lib/api/services/cross-section/cross-section.js +81 -20
- package/lib/api/services/manifold/manifold-booleans.d.ts +139 -43
- package/lib/api/services/manifold/manifold-booleans.js +143 -43
- package/lib/api/services/manifold/manifold-evaluate.d.ts +134 -59
- package/lib/api/services/manifold/manifold-evaluate.js +141 -59
- package/lib/api/services/manifold/manifold-operations.d.ts +195 -108
- package/lib/api/services/manifold/manifold-operations.js +197 -110
- package/lib/api/services/manifold/manifold-shapes.d.ts +64 -26
- package/lib/api/services/manifold/manifold-shapes.js +66 -28
- package/lib/api/services/manifold/manifold-transforms.d.ts +100 -38
- package/lib/api/services/manifold/manifold-transforms.js +100 -38
- package/lib/api/services/manifold/manifold.d.ts +25 -8
- package/lib/api/services/manifold/manifold.js +25 -8
- package/lib/api/services/mesh/mesh-evaluate.d.ts +103 -32
- package/lib/api/services/mesh/mesh-evaluate.js +108 -33
- package/lib/api/services/mesh/mesh-operations.d.ts +12 -15
- package/lib/api/services/mesh/mesh-operations.js +12 -15
- package/lib/api/services/mesh/mesh.d.ts +4 -2
- package/lib/api/services/mesh/mesh.js +4 -2
- package/package.json +3 -3
|
@@ -1,129 +1,225 @@
|
|
|
1
1
|
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
2
|
import * as Manifold3D from "manifold-3d";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Combining Manifold solids: fusing, cutting and intersecting two or many at once, and splitting a
|
|
5
|
+
* solid with another solid or a plane. Because the kernel works on closed triangle meshes, these
|
|
6
|
+
* are fast and always give a watertight result; the two-shape and many-shape forms give the same
|
|
7
|
+
* results and exist for convenience. Every method returns new solids and leaves the inputs as they
|
|
8
|
+
* are.
|
|
6
9
|
*/
|
|
7
10
|
export declare class ManifoldBooleans {
|
|
8
11
|
private manifold;
|
|
9
12
|
constructor(wasm: Manifold3D.ManifoldToplevel);
|
|
10
13
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
+
* Sweeps the second solid over the whole surface of the first and fuses everything it passes
|
|
15
|
+
* through, growing the first solid by the shape of the second - the Minkowski sum, which is
|
|
16
|
+
* how a solid is rounded or padded by a sphere.
|
|
17
|
+
* @param inputs - The solid to grow and the solid to sweep
|
|
18
|
+
* @returns The grown solid
|
|
19
|
+
* @group minkowski
|
|
20
|
+
* @shortname minkowski sum
|
|
21
|
+
* @drawable true
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* const padded = await bitbybit.manifold.manifold.booleans.minkowskiSum({ manifold1: cube, manifold2: sphere });
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
minkowskiSum(inputs: Inputs.Manifold.TwoManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
28
|
+
/**
|
|
29
|
+
* Sweeps the second solid over the whole surface of the first and cuts away everything it
|
|
30
|
+
* passes through, shrinking the first solid by the shape of the second - the Minkowski
|
|
31
|
+
* difference, the erosion that undoes a Minkowski sum.
|
|
32
|
+
* @param inputs - The solid to shrink and the solid to sweep
|
|
33
|
+
* @returns The shrunken solid
|
|
34
|
+
* @group minkowski
|
|
35
|
+
* @shortname minkowski difference
|
|
36
|
+
* @drawable true
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const eroded = await bitbybit.manifold.manifold.booleans.minkowskiDifference({ manifold1: cube, manifold2: sphere });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
minkowskiDifference(inputs: Inputs.Manifold.TwoManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
43
|
+
/**
|
|
44
|
+
* Cuts the second solid out of the first, leaving what remains of the first.
|
|
45
|
+
* @param inputs - The solid to cut from and the solid to cut with
|
|
46
|
+
* @returns The first solid minus the second
|
|
14
47
|
* @group a to b
|
|
15
48
|
* @shortname subtract
|
|
16
49
|
* @drawable true
|
|
50
|
+
* @example
|
|
51
|
+
* ```typescript
|
|
52
|
+
* const holed = await bitbybit.manifold.manifold.booleans.subtract({ manifold1: cube, manifold2: sphere });
|
|
53
|
+
* ```
|
|
17
54
|
*/
|
|
18
55
|
subtract(inputs: Inputs.Manifold.TwoManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
19
56
|
/**
|
|
20
|
-
*
|
|
21
|
-
* @param inputs two
|
|
22
|
-
* @returns
|
|
57
|
+
* Fuses two solids into one closed, watertight solid.
|
|
58
|
+
* @param inputs - The two solids
|
|
59
|
+
* @returns The fused solid
|
|
23
60
|
* @group a to b
|
|
24
61
|
* @shortname add
|
|
25
62
|
* @drawable true
|
|
63
|
+
* @example
|
|
64
|
+
* ```typescript
|
|
65
|
+
* const fused = await bitbybit.manifold.manifold.booleans.add({ manifold1: cube, manifold2: sphere });
|
|
66
|
+
* ```
|
|
26
67
|
*/
|
|
27
68
|
add(inputs: Inputs.Manifold.TwoManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
28
69
|
/**
|
|
29
|
-
*
|
|
30
|
-
* @param inputs two
|
|
31
|
-
* @returns
|
|
70
|
+
* Keeps only the volume two solids share, dropping everything else.
|
|
71
|
+
* @param inputs - The two solids
|
|
72
|
+
* @returns The shared volume
|
|
32
73
|
* @group a to b
|
|
33
74
|
* @shortname intersect
|
|
34
75
|
* @drawable true
|
|
76
|
+
* @example
|
|
77
|
+
* ```typescript
|
|
78
|
+
* const common = await bitbybit.manifold.manifold.booleans.intersect({ manifold1: cube, manifold2: sphere });
|
|
79
|
+
* ```
|
|
35
80
|
*/
|
|
36
81
|
intersect(inputs: Inputs.Manifold.TwoManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
37
82
|
/**
|
|
38
|
-
*
|
|
39
|
-
* @param inputs
|
|
40
|
-
* @returns
|
|
83
|
+
* Cuts the second solid out of the first, the same as `subtract`.
|
|
84
|
+
* @param inputs - The solid to cut from and the solid to cut with
|
|
85
|
+
* @returns The first solid minus the second
|
|
41
86
|
* @group 2 manifolds
|
|
42
87
|
* @shortname difference 2 manifolds
|
|
43
88
|
* @drawable true
|
|
89
|
+
* @example
|
|
90
|
+
* ```typescript
|
|
91
|
+
* const holed = await bitbybit.manifold.manifold.booleans.differenceTwo({ manifold1: cube, manifold2: sphere });
|
|
92
|
+
* ```
|
|
44
93
|
*/
|
|
45
94
|
differenceTwo(inputs: Inputs.Manifold.TwoManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
46
95
|
/**
|
|
47
|
-
*
|
|
48
|
-
* @param inputs two
|
|
49
|
-
* @returns
|
|
96
|
+
* Fuses two solids into one, the same as `add`.
|
|
97
|
+
* @param inputs - The two solids
|
|
98
|
+
* @returns The fused solid
|
|
50
99
|
* @group 2 manifolds
|
|
51
100
|
* @shortname union 2 manifolds
|
|
52
101
|
* @drawable true
|
|
102
|
+
* @example
|
|
103
|
+
* ```typescript
|
|
104
|
+
* const fused = await bitbybit.manifold.manifold.booleans.unionTwo({ manifold1: cube, manifold2: sphere });
|
|
105
|
+
* ```
|
|
53
106
|
*/
|
|
54
107
|
unionTwo(inputs: Inputs.Manifold.TwoManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
55
108
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param inputs two
|
|
58
|
-
* @returns
|
|
109
|
+
* Keeps only the volume two solids share, the same as `intersect`.
|
|
110
|
+
* @param inputs - The two solids
|
|
111
|
+
* @returns The shared volume
|
|
59
112
|
* @group 2 manifolds
|
|
60
113
|
* @shortname intersection 2 manifolds
|
|
61
114
|
* @drawable true
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const common = await bitbybit.manifold.manifold.booleans.intersectionTwo({ manifold1: cube, manifold2: sphere });
|
|
118
|
+
* ```
|
|
62
119
|
*/
|
|
63
120
|
intersectionTwo(inputs: Inputs.Manifold.TwoManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
64
121
|
/**
|
|
65
|
-
*
|
|
66
|
-
* @param inputs
|
|
67
|
-
* @returns
|
|
122
|
+
* Cuts every further solid in the list out of the first one.
|
|
123
|
+
* @param inputs - The solids, the first being the one cut from
|
|
124
|
+
* @returns The first solid minus all the others
|
|
68
125
|
* @group multiple
|
|
69
126
|
* @shortname difference manifolds
|
|
70
127
|
* @drawable true
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const holed = await bitbybit.manifold.manifold.booleans.difference({ manifolds: [cube, sphere, cylinder] });
|
|
131
|
+
* ```
|
|
71
132
|
*/
|
|
72
133
|
difference(inputs: Inputs.Manifold.ManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
73
134
|
/**
|
|
74
|
-
*
|
|
75
|
-
* @param inputs
|
|
76
|
-
* @returns
|
|
135
|
+
* Fuses all the solids in a list into one.
|
|
136
|
+
* @param inputs - The solids
|
|
137
|
+
* @returns The fused solid
|
|
77
138
|
* @group multiple
|
|
78
139
|
* @shortname union manifolds
|
|
79
140
|
* @drawable true
|
|
141
|
+
* @example
|
|
142
|
+
* ```typescript
|
|
143
|
+
* const fused = await bitbybit.manifold.manifold.booleans.union({ manifolds: [cube, sphere, cylinder] });
|
|
144
|
+
* ```
|
|
80
145
|
*/
|
|
81
146
|
union(inputs: Inputs.Manifold.ManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
82
147
|
/**
|
|
83
|
-
*
|
|
84
|
-
* @param inputs
|
|
85
|
-
* @returns
|
|
148
|
+
* Keeps only the volume all the solids in a list share.
|
|
149
|
+
* @param inputs - The solids
|
|
150
|
+
* @returns The volume common to all of them
|
|
86
151
|
* @group multiple
|
|
87
152
|
* @shortname intersection manifolds
|
|
88
153
|
* @drawable true
|
|
154
|
+
* @example
|
|
155
|
+
* ```typescript
|
|
156
|
+
* const common = await bitbybit.manifold.manifold.booleans.intersection({ manifolds: [cube, sphere] });
|
|
157
|
+
* ```
|
|
89
158
|
*/
|
|
90
159
|
intersection(inputs: Inputs.Manifold.ManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
91
160
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
161
|
+
* Cuts a solid with another solid and keeps both pieces: the part inside the cutter and the
|
|
162
|
+
* part outside it.
|
|
163
|
+
*
|
|
164
|
+
* Cheaper than an intersection followed by a subtraction when both are needed.
|
|
165
|
+
* @param inputs - The solid to split and the solid to cut with
|
|
166
|
+
* @returns Two solids: the part inside the cutter, then the part outside it
|
|
95
167
|
* @group split
|
|
96
168
|
* @shortname split
|
|
97
169
|
* @drawable true
|
|
170
|
+
* @example
|
|
171
|
+
* ```typescript
|
|
172
|
+
* const [inside, outside] = await bitbybit.manifold.manifold.booleans.split({ manifoldToSplit: cube, manifoldCutter: sphere });
|
|
173
|
+
* ```
|
|
98
174
|
*/
|
|
99
175
|
split(inputs: Inputs.Manifold.SplitManifoldsDto<Manifold3D.Manifold>): Manifold3D.Manifold[];
|
|
100
176
|
/**
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
177
|
+
* Cuts a solid with a plane and keeps both pieces.
|
|
178
|
+
*
|
|
179
|
+
* The plane is given by its normal and its distance from the origin along that normal; the
|
|
180
|
+
* first piece lies on the side the normal points to, the second on the other side.
|
|
181
|
+
* @param inputs - The solid, the plane normal and the plane's distance from the origin
|
|
182
|
+
* @returns Two solids: the part on the normal's side, then the rest
|
|
104
183
|
* @group split
|
|
105
184
|
* @shortname split by plane
|
|
106
185
|
* @drawable true
|
|
186
|
+
* @example
|
|
187
|
+
* ```typescript
|
|
188
|
+
* const [top, bottom] = await bitbybit.manifold.manifold.booleans.splitByPlane({ manifold: cube, normal: [0, 0, 1], originOffset: 0.5 });
|
|
189
|
+
* ```
|
|
107
190
|
*/
|
|
108
191
|
splitByPlane(inputs: Inputs.Manifold.SplitByPlaneDto<Manifold3D.Manifold>): Manifold3D.Manifold[];
|
|
109
192
|
/**
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
*
|
|
114
|
-
*
|
|
193
|
+
* Cuts a solid into slabs with several parallel planes, all with the same normal, at the given
|
|
194
|
+
* distances from the origin.
|
|
195
|
+
*
|
|
196
|
+
* Each cut keeps the part on the far side of the normal as a finished piece and carries the
|
|
197
|
+
* rest to the next distance, so the offsets should increase; n offsets give n + 1 pieces, empty
|
|
198
|
+
* ones dropped.
|
|
199
|
+
* @param inputs - The solid, the plane normal and the distances of the planes from the origin
|
|
200
|
+
* @returns The slabs, one more than the offsets given
|
|
115
201
|
* @group split
|
|
116
202
|
* @shortname split by plane on offsets
|
|
117
203
|
* @drawable true
|
|
204
|
+
* @example
|
|
205
|
+
* ```typescript
|
|
206
|
+
* const slabs = await bitbybit.manifold.manifold.booleans.splitByPlaneOnOffsets({ manifold: cube, normal: [0, 0, 1], originOffsets: [0.25, 0.5, 0.75] });
|
|
207
|
+
* ```
|
|
118
208
|
*/
|
|
119
209
|
splitByPlaneOnOffsets(inputs: Inputs.Manifold.SplitByPlaneOnOffsetsDto<Manifold3D.Manifold>): Manifold3D.Manifold[];
|
|
120
210
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
211
|
+
* Cuts a solid with a plane and keeps only the part on the side the normal points to.
|
|
212
|
+
*
|
|
213
|
+
* The plane is given by its normal and its distance from the origin along that normal.
|
|
214
|
+
* @param inputs - The solid, the plane normal and the plane's distance from the origin
|
|
215
|
+
* @returns The part of the solid on the normal's side
|
|
124
216
|
* @group trim
|
|
125
217
|
* @shortname trim by plane
|
|
126
218
|
* @drawable true
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* const half = await bitbybit.manifold.manifold.booleans.trimByPlane({ manifold: sphere, normal: [0, 0, 1], originOffset: 0 });
|
|
222
|
+
* ```
|
|
127
223
|
*/
|
|
128
224
|
trimByPlane(inputs: Inputs.Manifold.TrimByPlaneDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
129
225
|
}
|
|
@@ -1,51 +1,104 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Combining Manifold solids: fusing, cutting and intersecting two or many at once, and splitting a
|
|
3
|
+
* solid with another solid or a plane. Because the kernel works on closed triangle meshes, these
|
|
4
|
+
* are fast and always give a watertight result; the two-shape and many-shape forms give the same
|
|
5
|
+
* results and exist for convenience. Every method returns new solids and leaves the inputs as they
|
|
6
|
+
* are.
|
|
4
7
|
*/
|
|
5
8
|
export class ManifoldBooleans {
|
|
6
9
|
constructor(wasm) {
|
|
7
10
|
this.manifold = wasm;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
+
* Sweeps the second solid over the whole surface of the first and fuses everything it passes
|
|
14
|
+
* through, growing the first solid by the shape of the second - the Minkowski sum, which is
|
|
15
|
+
* how a solid is rounded or padded by a sphere.
|
|
16
|
+
* @param inputs - The solid to grow and the solid to sweep
|
|
17
|
+
* @returns The grown solid
|
|
18
|
+
* @group minkowski
|
|
19
|
+
* @shortname minkowski sum
|
|
20
|
+
* @drawable true
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* const padded = await bitbybit.manifold.manifold.booleans.minkowskiSum({ manifold1: cube, manifold2: sphere });
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
minkowskiSum(inputs) {
|
|
27
|
+
return inputs.manifold1.minkowskiSum(inputs.manifold2);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Sweeps the second solid over the whole surface of the first and cuts away everything it
|
|
31
|
+
* passes through, shrinking the first solid by the shape of the second - the Minkowski
|
|
32
|
+
* difference, the erosion that undoes a Minkowski sum.
|
|
33
|
+
* @param inputs - The solid to shrink and the solid to sweep
|
|
34
|
+
* @returns The shrunken solid
|
|
35
|
+
* @group minkowski
|
|
36
|
+
* @shortname minkowski difference
|
|
37
|
+
* @drawable true
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const eroded = await bitbybit.manifold.manifold.booleans.minkowskiDifference({ manifold1: cube, manifold2: sphere });
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
minkowskiDifference(inputs) {
|
|
44
|
+
return inputs.manifold1.minkowskiDifference(inputs.manifold2);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Cuts the second solid out of the first, leaving what remains of the first.
|
|
48
|
+
* @param inputs - The solid to cut from and the solid to cut with
|
|
49
|
+
* @returns The first solid minus the second
|
|
13
50
|
* @group a to b
|
|
14
51
|
* @shortname subtract
|
|
15
52
|
* @drawable true
|
|
53
|
+
* @example
|
|
54
|
+
* ```typescript
|
|
55
|
+
* const holed = await bitbybit.manifold.manifold.booleans.subtract({ manifold1: cube, manifold2: sphere });
|
|
56
|
+
* ```
|
|
16
57
|
*/
|
|
17
58
|
subtract(inputs) {
|
|
18
59
|
return inputs.manifold1.subtract(inputs.manifold2);
|
|
19
60
|
}
|
|
20
61
|
/**
|
|
21
|
-
*
|
|
22
|
-
* @param inputs two
|
|
23
|
-
* @returns
|
|
62
|
+
* Fuses two solids into one closed, watertight solid.
|
|
63
|
+
* @param inputs - The two solids
|
|
64
|
+
* @returns The fused solid
|
|
24
65
|
* @group a to b
|
|
25
66
|
* @shortname add
|
|
26
67
|
* @drawable true
|
|
68
|
+
* @example
|
|
69
|
+
* ```typescript
|
|
70
|
+
* const fused = await bitbybit.manifold.manifold.booleans.add({ manifold1: cube, manifold2: sphere });
|
|
71
|
+
* ```
|
|
27
72
|
*/
|
|
28
73
|
add(inputs) {
|
|
29
74
|
return inputs.manifold1.add(inputs.manifold2);
|
|
30
75
|
}
|
|
31
76
|
/**
|
|
32
|
-
*
|
|
33
|
-
* @param inputs two
|
|
34
|
-
* @returns
|
|
77
|
+
* Keeps only the volume two solids share, dropping everything else.
|
|
78
|
+
* @param inputs - The two solids
|
|
79
|
+
* @returns The shared volume
|
|
35
80
|
* @group a to b
|
|
36
81
|
* @shortname intersect
|
|
37
82
|
* @drawable true
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const common = await bitbybit.manifold.manifold.booleans.intersect({ manifold1: cube, manifold2: sphere });
|
|
86
|
+
* ```
|
|
38
87
|
*/
|
|
39
88
|
intersect(inputs) {
|
|
40
89
|
return inputs.manifold1.intersect(inputs.manifold2);
|
|
41
90
|
}
|
|
42
91
|
/**
|
|
43
|
-
*
|
|
44
|
-
* @param inputs
|
|
45
|
-
* @returns
|
|
92
|
+
* Cuts the second solid out of the first, the same as `subtract`.
|
|
93
|
+
* @param inputs - The solid to cut from and the solid to cut with
|
|
94
|
+
* @returns The first solid minus the second
|
|
46
95
|
* @group 2 manifolds
|
|
47
96
|
* @shortname difference 2 manifolds
|
|
48
97
|
* @drawable true
|
|
98
|
+
* @example
|
|
99
|
+
* ```typescript
|
|
100
|
+
* const holed = await bitbybit.manifold.manifold.booleans.differenceTwo({ manifold1: cube, manifold2: sphere });
|
|
101
|
+
* ```
|
|
49
102
|
*/
|
|
50
103
|
differenceTwo(inputs) {
|
|
51
104
|
const { Manifold } = this.manifold;
|
|
@@ -53,12 +106,16 @@ export class ManifoldBooleans {
|
|
|
53
106
|
return difference(inputs.manifold1, inputs.manifold2);
|
|
54
107
|
}
|
|
55
108
|
/**
|
|
56
|
-
*
|
|
57
|
-
* @param inputs two
|
|
58
|
-
* @returns
|
|
109
|
+
* Fuses two solids into one, the same as `add`.
|
|
110
|
+
* @param inputs - The two solids
|
|
111
|
+
* @returns The fused solid
|
|
59
112
|
* @group 2 manifolds
|
|
60
113
|
* @shortname union 2 manifolds
|
|
61
114
|
* @drawable true
|
|
115
|
+
* @example
|
|
116
|
+
* ```typescript
|
|
117
|
+
* const fused = await bitbybit.manifold.manifold.booleans.unionTwo({ manifold1: cube, manifold2: sphere });
|
|
118
|
+
* ```
|
|
62
119
|
*/
|
|
63
120
|
unionTwo(inputs) {
|
|
64
121
|
const { Manifold } = this.manifold;
|
|
@@ -66,12 +123,16 @@ export class ManifoldBooleans {
|
|
|
66
123
|
return union(inputs.manifold1, inputs.manifold2);
|
|
67
124
|
}
|
|
68
125
|
/**
|
|
69
|
-
*
|
|
70
|
-
* @param inputs two
|
|
71
|
-
* @returns
|
|
126
|
+
* Keeps only the volume two solids share, the same as `intersect`.
|
|
127
|
+
* @param inputs - The two solids
|
|
128
|
+
* @returns The shared volume
|
|
72
129
|
* @group 2 manifolds
|
|
73
130
|
* @shortname intersection 2 manifolds
|
|
74
131
|
* @drawable true
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* const common = await bitbybit.manifold.manifold.booleans.intersectionTwo({ manifold1: cube, manifold2: sphere });
|
|
135
|
+
* ```
|
|
75
136
|
*/
|
|
76
137
|
intersectionTwo(inputs) {
|
|
77
138
|
const { Manifold } = this.manifold;
|
|
@@ -79,12 +140,16 @@ export class ManifoldBooleans {
|
|
|
79
140
|
return intersection(inputs.manifold1, inputs.manifold2);
|
|
80
141
|
}
|
|
81
142
|
/**
|
|
82
|
-
*
|
|
83
|
-
* @param inputs
|
|
84
|
-
* @returns
|
|
143
|
+
* Cuts every further solid in the list out of the first one.
|
|
144
|
+
* @param inputs - The solids, the first being the one cut from
|
|
145
|
+
* @returns The first solid minus all the others
|
|
85
146
|
* @group multiple
|
|
86
147
|
* @shortname difference manifolds
|
|
87
148
|
* @drawable true
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const holed = await bitbybit.manifold.manifold.booleans.difference({ manifolds: [cube, sphere, cylinder] });
|
|
152
|
+
* ```
|
|
88
153
|
*/
|
|
89
154
|
difference(inputs) {
|
|
90
155
|
const { Manifold } = this.manifold;
|
|
@@ -92,12 +157,16 @@ export class ManifoldBooleans {
|
|
|
92
157
|
return difference(inputs.manifolds);
|
|
93
158
|
}
|
|
94
159
|
/**
|
|
95
|
-
*
|
|
96
|
-
* @param inputs
|
|
97
|
-
* @returns
|
|
160
|
+
* Fuses all the solids in a list into one.
|
|
161
|
+
* @param inputs - The solids
|
|
162
|
+
* @returns The fused solid
|
|
98
163
|
* @group multiple
|
|
99
164
|
* @shortname union manifolds
|
|
100
165
|
* @drawable true
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* const fused = await bitbybit.manifold.manifold.booleans.union({ manifolds: [cube, sphere, cylinder] });
|
|
169
|
+
* ```
|
|
101
170
|
*/
|
|
102
171
|
union(inputs) {
|
|
103
172
|
const { Manifold } = this.manifold;
|
|
@@ -105,12 +174,16 @@ export class ManifoldBooleans {
|
|
|
105
174
|
return union(inputs.manifolds);
|
|
106
175
|
}
|
|
107
176
|
/**
|
|
108
|
-
*
|
|
109
|
-
* @param inputs
|
|
110
|
-
* @returns
|
|
177
|
+
* Keeps only the volume all the solids in a list share.
|
|
178
|
+
* @param inputs - The solids
|
|
179
|
+
* @returns The volume common to all of them
|
|
111
180
|
* @group multiple
|
|
112
181
|
* @shortname intersection manifolds
|
|
113
182
|
* @drawable true
|
|
183
|
+
* @example
|
|
184
|
+
* ```typescript
|
|
185
|
+
* const common = await bitbybit.manifold.manifold.booleans.intersection({ manifolds: [cube, sphere] });
|
|
186
|
+
* ```
|
|
114
187
|
*/
|
|
115
188
|
intersection(inputs) {
|
|
116
189
|
const { Manifold } = this.manifold;
|
|
@@ -118,36 +191,57 @@ export class ManifoldBooleans {
|
|
|
118
191
|
return intersection(inputs.manifolds);
|
|
119
192
|
}
|
|
120
193
|
/**
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
194
|
+
* Cuts a solid with another solid and keeps both pieces: the part inside the cutter and the
|
|
195
|
+
* part outside it.
|
|
196
|
+
*
|
|
197
|
+
* Cheaper than an intersection followed by a subtraction when both are needed.
|
|
198
|
+
* @param inputs - The solid to split and the solid to cut with
|
|
199
|
+
* @returns Two solids: the part inside the cutter, then the part outside it
|
|
124
200
|
* @group split
|
|
125
201
|
* @shortname split
|
|
126
202
|
* @drawable true
|
|
203
|
+
* @example
|
|
204
|
+
* ```typescript
|
|
205
|
+
* const [inside, outside] = await bitbybit.manifold.manifold.booleans.split({ manifoldToSplit: cube, manifoldCutter: sphere });
|
|
206
|
+
* ```
|
|
127
207
|
*/
|
|
128
208
|
split(inputs) {
|
|
129
209
|
return inputs.manifoldToSplit.split(inputs.manifoldCutter);
|
|
130
210
|
}
|
|
131
211
|
/**
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
*
|
|
212
|
+
* Cuts a solid with a plane and keeps both pieces.
|
|
213
|
+
*
|
|
214
|
+
* The plane is given by its normal and its distance from the origin along that normal; the
|
|
215
|
+
* first piece lies on the side the normal points to, the second on the other side.
|
|
216
|
+
* @param inputs - The solid, the plane normal and the plane's distance from the origin
|
|
217
|
+
* @returns Two solids: the part on the normal's side, then the rest
|
|
135
218
|
* @group split
|
|
136
219
|
* @shortname split by plane
|
|
137
220
|
* @drawable true
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const [top, bottom] = await bitbybit.manifold.manifold.booleans.splitByPlane({ manifold: cube, normal: [0, 0, 1], originOffset: 0.5 });
|
|
224
|
+
* ```
|
|
138
225
|
*/
|
|
139
226
|
splitByPlane(inputs) {
|
|
140
227
|
return inputs.manifold.splitByPlane(inputs.normal, inputs.originOffset);
|
|
141
228
|
}
|
|
142
229
|
/**
|
|
143
|
-
*
|
|
144
|
-
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
230
|
+
* Cuts a solid into slabs with several parallel planes, all with the same normal, at the given
|
|
231
|
+
* distances from the origin.
|
|
232
|
+
*
|
|
233
|
+
* Each cut keeps the part on the far side of the normal as a finished piece and carries the
|
|
234
|
+
* rest to the next distance, so the offsets should increase; n offsets give n + 1 pieces, empty
|
|
235
|
+
* ones dropped.
|
|
236
|
+
* @param inputs - The solid, the plane normal and the distances of the planes from the origin
|
|
237
|
+
* @returns The slabs, one more than the offsets given
|
|
148
238
|
* @group split
|
|
149
239
|
* @shortname split by plane on offsets
|
|
150
240
|
* @drawable true
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* const slabs = await bitbybit.manifold.manifold.booleans.splitByPlaneOnOffsets({ manifold: cube, normal: [0, 0, 1], originOffsets: [0.25, 0.5, 0.75] });
|
|
244
|
+
* ```
|
|
151
245
|
*/
|
|
152
246
|
splitByPlaneOnOffsets(inputs) {
|
|
153
247
|
const pieces = [];
|
|
@@ -180,12 +274,18 @@ export class ManifoldBooleans {
|
|
|
180
274
|
return pieces;
|
|
181
275
|
}
|
|
182
276
|
/**
|
|
183
|
-
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
277
|
+
* Cuts a solid with a plane and keeps only the part on the side the normal points to.
|
|
278
|
+
*
|
|
279
|
+
* The plane is given by its normal and its distance from the origin along that normal.
|
|
280
|
+
* @param inputs - The solid, the plane normal and the plane's distance from the origin
|
|
281
|
+
* @returns The part of the solid on the normal's side
|
|
186
282
|
* @group trim
|
|
187
283
|
* @shortname trim by plane
|
|
188
284
|
* @drawable true
|
|
285
|
+
* @example
|
|
286
|
+
* ```typescript
|
|
287
|
+
* const half = await bitbybit.manifold.manifold.booleans.trimByPlane({ manifold: sphere, normal: [0, 0, 1], originOffset: 0 });
|
|
288
|
+
* ```
|
|
189
289
|
*/
|
|
190
290
|
trimByPlane(inputs) {
|
|
191
291
|
return inputs.manifold.asOriginal().trimByPlane(inputs.normal, inputs.originOffset);
|