@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,29 +1,42 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Changing Manifold solids beyond booleans: wrapping them in a convex hull, slicing and projecting
|
|
3
|
+
* them into cross-sections, refining and smoothing their meshes, simplifying them, composing and
|
|
4
|
+
* decomposing them, and computing normals and curvature into vertex property channels. A property
|
|
5
|
+
* channel is one number per vertex stored on the mesh, such as the three channels of a normal.
|
|
6
|
+
* Every method returns a new solid.
|
|
4
7
|
*/
|
|
5
8
|
export class ManifoldOperations {
|
|
6
9
|
constructor(wasm) {
|
|
7
10
|
this.manifold = wasm;
|
|
8
11
|
}
|
|
9
12
|
/**
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* @
|
|
13
|
+
* Wraps a solid in its convex hull, the smallest shape without dents that contains it, like
|
|
14
|
+
* shrink-wrap pulled tight over it.
|
|
15
|
+
* @param inputs - The solid
|
|
16
|
+
* @returns The convex hull
|
|
13
17
|
* @group hulls
|
|
14
18
|
* @shortname convex hull
|
|
15
19
|
* @drawable true
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* const wrapped = await bitbybit.manifold.manifold.operations.hull({ manifold: shape });
|
|
23
|
+
* ```
|
|
16
24
|
*/
|
|
17
25
|
hull(inputs) {
|
|
18
26
|
return inputs.manifold.hull();
|
|
19
27
|
}
|
|
20
28
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @
|
|
29
|
+
* Wraps points, solids or a mix of both in one convex hull, the smallest shape without dents
|
|
30
|
+
* that contains them all.
|
|
31
|
+
* @param inputs - The points and solids to wrap
|
|
32
|
+
* @returns The convex hull
|
|
24
33
|
* @group hulls
|
|
25
34
|
* @shortname hull points
|
|
26
35
|
* @drawable true
|
|
36
|
+
* @example
|
|
37
|
+
* ```typescript
|
|
38
|
+
* const wrapped = await bitbybit.manifold.manifold.operations.hullPoints({ points: [[0, 0, 0], [10, 0, 0], [0, 10, 0], [0, 0, 10]] });
|
|
39
|
+
* ```
|
|
27
40
|
*/
|
|
28
41
|
hullPoints(inputs) {
|
|
29
42
|
const { Manifold } = this.manifold;
|
|
@@ -31,49 +44,73 @@ export class ManifoldOperations {
|
|
|
31
44
|
return hull(inputs.points);
|
|
32
45
|
}
|
|
33
46
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* @
|
|
47
|
+
* Cuts a solid with a plane parallel to the XY plane at the given Z height and returns the flat
|
|
48
|
+
* section as a cross-section.
|
|
49
|
+
*
|
|
50
|
+
* A height at the bottom of the solid's bounding box gives its bottom faces; a height at the
|
|
51
|
+
* top gives an empty cross-section.
|
|
52
|
+
* @param inputs - The solid and the Z height of the cut
|
|
53
|
+
* @returns The section as a cross-section
|
|
40
54
|
* @group cross sections
|
|
41
55
|
* @shortname slice
|
|
42
56
|
* @drawable true
|
|
57
|
+
* @example
|
|
58
|
+
* ```typescript
|
|
59
|
+
* const section = await bitbybit.manifold.manifold.operations.slice({ manifold: sphere, height: 2 });
|
|
60
|
+
* ```
|
|
43
61
|
*/
|
|
44
62
|
slice(inputs) {
|
|
45
63
|
return inputs.manifold.slice(inputs.height);
|
|
46
64
|
}
|
|
47
65
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @
|
|
66
|
+
* Flattens a solid onto the XY plane and returns its outline as a cross-section, like its
|
|
67
|
+
* shadow under a light straight above.
|
|
68
|
+
* @param inputs - The solid
|
|
69
|
+
* @returns The outline as a cross-section
|
|
51
70
|
* @group cross sections
|
|
52
71
|
* @shortname project
|
|
53
72
|
* @drawable true
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const shadow = await bitbybit.manifold.manifold.operations.project({ manifold: shape });
|
|
76
|
+
* ```
|
|
54
77
|
*/
|
|
55
78
|
project(inputs) {
|
|
56
79
|
return inputs.manifold.project();
|
|
57
80
|
}
|
|
58
81
|
/**
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
82
|
+
* Gives a solid a new tolerance, the rounding error it is allowed to carry, and simplifies its
|
|
83
|
+
* mesh when the tolerance grows.
|
|
84
|
+
*
|
|
85
|
+
* Triangles thinner than the tolerance are treated as degenerate and removed.
|
|
86
|
+
* @param inputs - The solid and the tolerance in model units
|
|
87
|
+
* @returns The solid with the new tolerance
|
|
63
88
|
* @group basic
|
|
64
89
|
* @shortname set tolerance
|
|
65
90
|
* @drawable false
|
|
91
|
+
* @example
|
|
92
|
+
* ```typescript
|
|
93
|
+
* const coarser = await bitbybit.manifold.manifold.operations.setTolerance({ manifold: shape, tolerance: 0.01 });
|
|
94
|
+
* ```
|
|
66
95
|
*/
|
|
67
96
|
setTolerance(inputs) {
|
|
68
97
|
return inputs.manifold.setTolerance(inputs.tolerance);
|
|
69
98
|
}
|
|
70
99
|
/**
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
100
|
+
* Reserves a run of `count` unique mesh ids and returns the first, for marking sets of
|
|
101
|
+
* triangles that can be found again after later operations.
|
|
102
|
+
*
|
|
103
|
+
* Assign them to a mesh's `runOriginalID` before building a solid from it, for instance to keep
|
|
104
|
+
* several materials apart.
|
|
105
|
+
* @param inputs - How many ids to reserve
|
|
106
|
+
* @returns The first of the reserved ids; the rest follow in sequence
|
|
74
107
|
* @group basic
|
|
75
108
|
* @shortname reserve id
|
|
76
109
|
* @drawable false
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* const firstId = await bitbybit.manifold.manifold.operations.reserveIds({ count: 2 });
|
|
113
|
+
* ```
|
|
77
114
|
*/
|
|
78
115
|
reserveIds(inputs) {
|
|
79
116
|
const { Manifold } = this.manifold;
|
|
@@ -81,184 +118,234 @@ export class ManifoldOperations {
|
|
|
81
118
|
return reserveIDs(inputs.count);
|
|
82
119
|
}
|
|
83
120
|
/**
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* meaning it will now be referenced by its descendants instead of the meshes
|
|
87
|
-
* it was built from, allowing you to differentiate the copies when applying
|
|
88
|
-
* your properties to the final result.
|
|
121
|
+
* Makes a copy of a solid that counts as a new original, so the copy can carry its own vertex
|
|
122
|
+
* properties, such as a different UV mapping, and be told apart from what it was built from.
|
|
89
123
|
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* construct a new manifold.
|
|
95
|
-
* @param inputs manifold
|
|
96
|
-
* @returns original manifold
|
|
124
|
+
* Coplanar faces are merged and the edges between them collapsed on the way; keep the mesh
|
|
125
|
+
* route instead when those edges must stay.
|
|
126
|
+
* @param inputs - The solid
|
|
127
|
+
* @returns The copy marked as an original
|
|
97
128
|
* @group basic
|
|
98
129
|
* @shortname as original
|
|
99
130
|
* @drawable true
|
|
131
|
+
* @example
|
|
132
|
+
* ```typescript
|
|
133
|
+
* const original = await bitbybit.manifold.manifold.operations.asOriginal({ manifold: shape });
|
|
134
|
+
* ```
|
|
100
135
|
*/
|
|
101
136
|
asOriginal(inputs) {
|
|
102
137
|
return inputs.manifold.asOriginal();
|
|
103
138
|
}
|
|
104
139
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
* @
|
|
140
|
+
* Packs several solids into one, the inverse of `decompose`.
|
|
141
|
+
*
|
|
142
|
+
* Solids that overlap are fused, as a boolean union would; solids kept apart stay separate
|
|
143
|
+
* pieces of the one result.
|
|
144
|
+
* @param inputs - The solids to pack together
|
|
145
|
+
* @returns One solid holding all of them
|
|
110
146
|
* @group composition
|
|
111
147
|
* @shortname compose
|
|
112
148
|
* @drawable true
|
|
149
|
+
* @example
|
|
150
|
+
* ```typescript
|
|
151
|
+
* const packed = await bitbybit.manifold.manifold.operations.compose({ manifolds: [cube, sphere] });
|
|
152
|
+
* ```
|
|
113
153
|
*/
|
|
114
154
|
compose(inputs) {
|
|
115
155
|
const { Manifold } = this.manifold;
|
|
116
|
-
const {
|
|
117
|
-
return
|
|
156
|
+
const { union } = Manifold;
|
|
157
|
+
return union(inputs.manifolds);
|
|
118
158
|
}
|
|
119
159
|
/**
|
|
120
|
-
*
|
|
121
|
-
*
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
* @
|
|
125
|
-
* @returns decomposed manifold shapes
|
|
160
|
+
* Splits a solid into its separate, unconnected pieces, the inverse of `compose`.
|
|
161
|
+
*
|
|
162
|
+
* A solid that is all one piece comes back as a list of one copy.
|
|
163
|
+
* @param inputs - The solid
|
|
164
|
+
* @returns The separate pieces
|
|
126
165
|
* @group composition
|
|
127
166
|
* @shortname decompose
|
|
128
167
|
* @drawable true
|
|
168
|
+
* @example
|
|
169
|
+
* ```typescript
|
|
170
|
+
* const pieces = await bitbybit.manifold.manifold.operations.decompose({ manifold: packed });
|
|
171
|
+
* ```
|
|
129
172
|
*/
|
|
130
173
|
decompose(inputs) {
|
|
131
174
|
return inputs.manifold.decompose();
|
|
132
175
|
}
|
|
133
176
|
/**
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
177
|
+
* Computes a normal for every vertex from the mesh and stores it in three property channels
|
|
178
|
+
* starting at `normalIdx`.
|
|
179
|
+
*
|
|
180
|
+
* Edges sharper than `minSharpAngle`, in degrees, keep separate normals on each side and stay
|
|
181
|
+
* crisp; at 0 every triangle keeps its own normal. Flat faces of several triangles stay flat.
|
|
182
|
+
* @param inputs - The solid, the first normal channel and the sharp angle in degrees
|
|
183
|
+
* @returns The solid with normals stored
|
|
138
184
|
* @group adjustments
|
|
139
185
|
* @shortname calculate normals
|
|
140
186
|
* @drawable true
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* const withNormals = await bitbybit.manifold.manifold.operations.calculateNormals({ manifold: shape, normalIdx: 0, minSharpAngle: 60 });
|
|
190
|
+
* ```
|
|
141
191
|
*/
|
|
142
192
|
calculateNormals(inputs) {
|
|
143
193
|
return inputs.manifold.calculateNormals(inputs.normalIdx, inputs.minSharpAngle);
|
|
144
194
|
}
|
|
145
195
|
/**
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
152
|
-
* @
|
|
153
|
-
* @returns manifold with calculated curvature
|
|
196
|
+
* Computes how strongly the surface bends at every vertex and stores it in property channels:
|
|
197
|
+
* Gaussian curvature at `gaussianIdx`, mean curvature at `meanIdx`.
|
|
198
|
+
*
|
|
199
|
+
* Curvature is the inverse of the bending radius, positive where the surface is convex and
|
|
200
|
+
* negative where it is concave; an index below 0 skips that channel.
|
|
201
|
+
* @param inputs - The solid and the two channels to store into
|
|
202
|
+
* @returns The solid with curvature stored
|
|
154
203
|
* @group adjustments
|
|
155
204
|
* @shortname calculate curvature
|
|
156
205
|
* @drawable true
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* const withCurvature = await bitbybit.manifold.manifold.operations.calculateCurvature({ manifold: shape, gaussianIdx: 0, meanIdx: 1 });
|
|
209
|
+
* ```
|
|
157
210
|
*/
|
|
158
211
|
calculateCurvature(inputs) {
|
|
159
212
|
return inputs.manifold.calculateCurvature(inputs.gaussianIdx, inputs.meanIdx);
|
|
160
213
|
}
|
|
161
214
|
/**
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
*
|
|
168
|
-
* @
|
|
169
|
-
* @returns refined manifold
|
|
215
|
+
* Adds triangles to a smoothed solid until every point of its mesh lies within `tolerance` of
|
|
216
|
+
* the smooth surface, so tightly curved regions get more triangles than flat ones.
|
|
217
|
+
*
|
|
218
|
+
* Only a solid that was smoothed with `smoothOut` or `smoothByNormals` changes; any other comes
|
|
219
|
+
* back as a copy.
|
|
220
|
+
* @param inputs - The solid and the tolerance in model units
|
|
221
|
+
* @returns The refined solid
|
|
170
222
|
* @group adjustments
|
|
171
223
|
* @shortname refine to tolerance
|
|
172
224
|
* @drawable true
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* const finer = await bitbybit.manifold.manifold.operations.refineToTolerance({ manifold: smoothed, tolerance: 0.01 });
|
|
228
|
+
* ```
|
|
173
229
|
*/
|
|
174
230
|
refineToTolerance(inputs) {
|
|
175
231
|
return inputs.manifold.refineToTolerance(inputs.tolerance);
|
|
176
232
|
}
|
|
177
233
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
*
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
*
|
|
184
|
-
* @
|
|
185
|
-
* @returns refined manifold
|
|
234
|
+
* Adds triangles to a solid by splitting every edge into pieces of roughly the given length,
|
|
235
|
+
* adding inner vertices to keep the triangles even.
|
|
236
|
+
*
|
|
237
|
+
* On a solid smoothed with `smoothOut` or `smoothByNormals` the new vertices move onto the
|
|
238
|
+
* smooth surface; otherwise the surface stays as it is.
|
|
239
|
+
* @param inputs - The solid and the target edge length in model units
|
|
240
|
+
* @returns The refined solid
|
|
186
241
|
* @group adjustments
|
|
187
242
|
* @shortname refine to length
|
|
188
243
|
* @drawable true
|
|
244
|
+
* @example
|
|
245
|
+
* ```typescript
|
|
246
|
+
* const finer = await bitbybit.manifold.manifold.operations.refineToLength({ manifold: smoothed, length: 0.5 });
|
|
247
|
+
* ```
|
|
189
248
|
*/
|
|
190
249
|
refineToLength(inputs) {
|
|
191
250
|
return inputs.manifold.refineToLength(inputs.length);
|
|
192
251
|
}
|
|
193
252
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
*
|
|
197
|
-
*
|
|
198
|
-
*
|
|
199
|
-
*
|
|
200
|
-
* @
|
|
201
|
-
* @returns refined manifold
|
|
253
|
+
* Adds triangles to a solid by splitting every edge into `number` pieces; with 2, each triangle
|
|
254
|
+
* becomes four.
|
|
255
|
+
*
|
|
256
|
+
* On a solid smoothed with `smoothOut` or `smoothByNormals` the new vertices move onto the
|
|
257
|
+
* smooth surface; otherwise the new triangles stay flat.
|
|
258
|
+
* @param inputs - The solid and how many pieces to split each edge into
|
|
259
|
+
* @returns The refined solid
|
|
202
260
|
* @group adjustments
|
|
203
261
|
* @shortname refine
|
|
204
262
|
* @drawable true
|
|
263
|
+
* @example
|
|
264
|
+
* ```typescript
|
|
265
|
+
* const finer = await bitbybit.manifold.manifold.operations.refine({ manifold: smoothed, number: 2 });
|
|
266
|
+
* ```
|
|
205
267
|
*/
|
|
206
268
|
refine(inputs) {
|
|
207
269
|
return inputs.manifold.refine(inputs.number);
|
|
208
270
|
}
|
|
209
271
|
/**
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
*
|
|
213
|
-
*
|
|
214
|
-
*
|
|
215
|
-
*
|
|
272
|
+
* Marks a solid for smoothing by working out tangents from its triangles, so a later `refine`
|
|
273
|
+
* or `refineToLength` bends the new triangles into a smooth surface.
|
|
274
|
+
*
|
|
275
|
+
* Edges sharper than `minSharpAngle`, in degrees, stay sharp; `minSmoothness` above 0 rounds
|
|
276
|
+
* those a little, and 1 smooths everything. The geometry itself does not change until it is
|
|
277
|
+
* refined.
|
|
278
|
+
* @param inputs - The solid, the sharp angle in degrees and the smoothness of sharp edges
|
|
279
|
+
* @returns The solid with smoothing tangents
|
|
216
280
|
* @group adjustments
|
|
217
281
|
* @shortname smooth out
|
|
218
282
|
* @drawable true
|
|
283
|
+
* @example
|
|
284
|
+
* ```typescript
|
|
285
|
+
* const smoothed = await bitbybit.manifold.manifold.operations.smoothOut({ manifold: cube, minSharpAngle: 60, minSmoothness: 0 });
|
|
286
|
+
* const rounded = await bitbybit.manifold.manifold.operations.refineToLength({ manifold: smoothed, length: 0.5 });
|
|
287
|
+
* ```
|
|
219
288
|
*/
|
|
220
289
|
smoothOut(inputs) {
|
|
221
290
|
return inputs.manifold.smoothOut(inputs.minSharpAngle, inputs.minSmoothness);
|
|
222
291
|
}
|
|
223
292
|
/**
|
|
224
|
-
*
|
|
225
|
-
*
|
|
226
|
-
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* @
|
|
293
|
+
* Marks a solid for smoothing using the normals stored in its vertex properties, so a later
|
|
294
|
+
* `refine` or `refineToLength` bends the new triangles into a smooth surface.
|
|
295
|
+
*
|
|
296
|
+
* `normalIdx` is the first of the three normal channels, as `calculateNormals` stores them;
|
|
297
|
+
* where the normals on a vertex disagree the edge stays sharp.
|
|
298
|
+
* @param inputs - The solid and the first normal channel
|
|
299
|
+
* @returns The solid with smoothing tangents
|
|
230
300
|
* @group adjustments
|
|
231
301
|
* @shortname smooth by normals
|
|
232
302
|
* @drawable true
|
|
303
|
+
* @example
|
|
304
|
+
* ```typescript
|
|
305
|
+
* const smoothed = await bitbybit.manifold.manifold.operations.smoothByNormals({ manifold: withNormals, normalIdx: 0 });
|
|
306
|
+
* ```
|
|
233
307
|
*/
|
|
234
308
|
smoothByNormals(inputs) {
|
|
235
309
|
return inputs.manifold.smoothByNormals(inputs.normalIdx);
|
|
236
310
|
}
|
|
237
311
|
/**
|
|
238
|
-
*
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
*
|
|
242
|
-
*
|
|
312
|
+
* Removes vertices from a solid's mesh while keeping every surface within `tolerance` of where
|
|
313
|
+
* it was, to cut the triangle count.
|
|
314
|
+
*
|
|
315
|
+
* The result keeps a subset of the original vertices; the solid's own tolerance value stays
|
|
316
|
+
* unchanged.
|
|
317
|
+
* @param inputs - The solid and how far surfaces may move, in model units
|
|
318
|
+
* @returns The simplified solid
|
|
243
319
|
* @group adjustments
|
|
244
320
|
* @shortname simplify
|
|
245
321
|
* @drawable true
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* const lighter = await bitbybit.manifold.manifold.operations.simplify({ manifold: shape, tolerance: 0.05 });
|
|
325
|
+
* ```
|
|
246
326
|
*/
|
|
247
327
|
simplify(inputs) {
|
|
248
328
|
return inputs.manifold.simplify(inputs.tolerance);
|
|
249
329
|
}
|
|
250
330
|
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
254
|
-
*
|
|
255
|
-
* past the
|
|
256
|
-
* properties
|
|
257
|
-
* @
|
|
258
|
-
* @returns manifold with updated properties
|
|
331
|
+
* Rewrites the vertex properties of a solid with a function that receives each vertex's
|
|
332
|
+
* position and old properties and fills in the new ones.
|
|
333
|
+
*
|
|
334
|
+
* `numProp` sets how many properties each vertex has afterwards, so channels can be added or
|
|
335
|
+
* dropped; reading past the old count or writing past the new one is undefined.
|
|
336
|
+
* @param inputs - The solid, the new property count and the function that fills the properties
|
|
337
|
+
* @returns The solid with the new properties
|
|
259
338
|
* @group adjustments
|
|
260
339
|
* @shortname set properties
|
|
261
340
|
* @drawable true
|
|
341
|
+
* @example
|
|
342
|
+
* ```typescript
|
|
343
|
+
* const colored = await bitbybit.manifold.manifold.operations.setProperties({
|
|
344
|
+
* manifold: shape,
|
|
345
|
+
* numProp: 3,
|
|
346
|
+
* propFunc: (newProp, position) => { newProp[0] = position[0]; newProp[1] = position[1]; newProp[2] = position[2]; },
|
|
347
|
+
* });
|
|
348
|
+
* ```
|
|
262
349
|
*/
|
|
263
350
|
setProperties(inputs) {
|
|
264
351
|
return inputs.manifold.setProperties(inputs.numProp, inputs.propFunc);
|
|
@@ -1,71 +1,109 @@
|
|
|
1
1
|
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
2
|
import * as Manifold3D from "manifold-3d";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* Building Manifold solids: the cube, sphere, cylinder and tetrahedron primitives, and solids from
|
|
5
|
+
* triangle meshes or lists of triangles. The kernel keeps Z as its up axis, so a cylinder stands
|
|
6
|
+
* along Z and a cube's `size` runs along X, Y and Z; every solid comes back as a closed triangle
|
|
7
|
+
* mesh.
|
|
6
8
|
*/
|
|
7
9
|
export declare class ManifoldShapes {
|
|
8
10
|
private manifold;
|
|
9
11
|
constructor(wasm: Manifold3D.ManifoldToplevel);
|
|
10
12
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* result is not an oriented 2-manifold. Will collapse degenerate triangles
|
|
14
|
-
* and unnecessary vertices.
|
|
13
|
+
* Builds a solid from plain mesh data, the form `manifoldToMesh` hands out, so a mesh can make
|
|
14
|
+
* a round trip through other tools.
|
|
15
15
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* @param inputs mesh definition
|
|
21
|
-
* @returns manifold
|
|
16
|
+
* The mesh must be closed and consistently oriented, or an error is thrown; degenerate
|
|
17
|
+
* triangles and unneeded vertices are removed on the way in.
|
|
18
|
+
* @param inputs - The mesh data
|
|
19
|
+
* @returns The solid
|
|
22
20
|
* @group create
|
|
23
21
|
* @shortname manifold from mesh
|
|
24
22
|
* @drawable true
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* const solid = await bitbybit.manifold.manifold.shapes.manifoldFromMesh({ mesh });
|
|
26
|
+
* ```
|
|
25
27
|
*/
|
|
26
28
|
manifoldFromMesh(inputs: Inputs.Manifold.CreateFromMeshDto): Manifold3D.Manifold;
|
|
27
29
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
30
|
+
* Builds a solid from a list of triangles, each given as three points, merging points that
|
|
31
|
+
* coincide.
|
|
32
|
+
*
|
|
33
|
+
* The triangles must form a closed, consistently oriented surface; entries that are not three
|
|
34
|
+
* points are skipped, and points with missing coordinates throw an error.
|
|
35
|
+
* @param inputs - The triangles as lists of three points
|
|
36
|
+
* @returns The solid
|
|
31
37
|
* @group create
|
|
32
38
|
* @shortname from polygon points
|
|
33
39
|
* @drawable true
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const solid = await bitbybit.manifold.manifold.shapes.fromPolygonPoints({ polygonPoints: triangles });
|
|
43
|
+
* ```
|
|
34
44
|
*/
|
|
35
45
|
fromPolygonPoints(inputs: Inputs.Manifold.FromPolygonPointsDto): Manifold3D.Manifold;
|
|
36
46
|
/**
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
47
|
+
* Creates a cube solid with the given side length.
|
|
48
|
+
*
|
|
49
|
+
* With `center` true the cube is centered on the origin; otherwise its corner sits on the origin
|
|
50
|
+
* and it extends along the positive axes.
|
|
51
|
+
* @param inputs - The side length and whether to center it
|
|
52
|
+
* @returns The box solid
|
|
40
53
|
* @group primitives
|
|
41
54
|
* @shortname cube
|
|
42
55
|
* @drawable true
|
|
56
|
+
* @example
|
|
57
|
+
* ```typescript
|
|
58
|
+
* const box = await bitbybit.manifold.manifold.shapes.cube({ size: 10, center: true });
|
|
59
|
+
* ```
|
|
43
60
|
*/
|
|
44
61
|
cube(inputs: Inputs.Manifold.CubeDto): Manifold3D.Manifold;
|
|
45
62
|
/**
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
63
|
+
* Creates a sphere solid of the given radius, centered on the origin.
|
|
64
|
+
*
|
|
65
|
+
* `circularSegments` is the number of segments around the sphere; it is rounded up to a
|
|
66
|
+
* multiple of four, since the sphere is built by refining an octahedron.
|
|
67
|
+
* @param inputs - The radius and the number of segments around the sphere
|
|
68
|
+
* @returns The sphere solid
|
|
49
69
|
* @group primitives
|
|
50
70
|
* @shortname sphere
|
|
51
71
|
* @drawable true
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* const ball = await bitbybit.manifold.manifold.shapes.sphere({ radius: 5, circularSegments: 32 });
|
|
75
|
+
* ```
|
|
52
76
|
*/
|
|
53
77
|
sphere(inputs: Inputs.Manifold.SphereDto): Manifold3D.Manifold;
|
|
54
78
|
/**
|
|
55
|
-
*
|
|
56
|
-
*
|
|
79
|
+
* Creates a tetrahedron solid centered on the origin, with one corner at `[1, 1, 1]` and the
|
|
80
|
+
* others placed symmetrically.
|
|
81
|
+
* @returns The tetrahedron solid
|
|
57
82
|
* @group primitives
|
|
58
83
|
* @shortname tetrahedron
|
|
59
84
|
* @drawable true
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const tetra = await bitbybit.manifold.manifold.shapes.tetrahedron();
|
|
88
|
+
* ```
|
|
60
89
|
*/
|
|
61
90
|
tetrahedron(): Manifold3D.Manifold;
|
|
62
91
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
92
|
+
* Creates a cylinder solid standing along Z, or a cone when the top radius differs from the
|
|
93
|
+
* bottom one.
|
|
94
|
+
*
|
|
95
|
+
* `radiusLow` is the bottom radius and must be above 0, `radiusHigh` the top radius, which may
|
|
96
|
+
* be 0 for a point; `circularSegments` sets how round the sides are. `center` centers the
|
|
97
|
+
* cylinder on the origin instead of standing it on it.
|
|
98
|
+
* @param inputs - The height, the bottom and top radii, the number of segments and whether to center it
|
|
99
|
+
* @returns The cylinder or cone solid
|
|
66
100
|
* @group primitives
|
|
67
101
|
* @shortname cylinder
|
|
68
102
|
* @drawable true
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* const cone = await bitbybit.manifold.manifold.shapes.cylinder({ height: 10, radiusLow: 4, radiusHigh: 1, circularSegments: 32, center: false });
|
|
106
|
+
* ```
|
|
69
107
|
*/
|
|
70
108
|
cylinder(inputs: Inputs.Manifold.CylinderDto): Manifold3D.Manifold;
|
|
71
109
|
}
|