@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.
Files changed (35) hide show
  1. package/lib/api/inputs/manifold-inputs.d.ts +521 -224
  2. package/lib/api/inputs/manifold-inputs.js +380 -135
  3. package/lib/api/manifold-service.d.ts +37 -11
  4. package/lib/api/manifold-service.js +37 -11
  5. package/lib/api/services/cross-section/cross-section-booleans.d.ts +66 -29
  6. package/lib/api/services/cross-section/cross-section-booleans.js +66 -29
  7. package/lib/api/services/cross-section/cross-section-evaluate.d.ts +38 -17
  8. package/lib/api/services/cross-section/cross-section-evaluate.js +38 -17
  9. package/lib/api/services/cross-section/cross-section-operations.d.ts +73 -33
  10. package/lib/api/services/cross-section/cross-section-operations.js +73 -33
  11. package/lib/api/services/cross-section/cross-section-shapes.d.ts +38 -17
  12. package/lib/api/services/cross-section/cross-section-shapes.js +38 -17
  13. package/lib/api/services/cross-section/cross-section-transforms.d.ts +64 -29
  14. package/lib/api/services/cross-section/cross-section-transforms.js +64 -29
  15. package/lib/api/services/cross-section/cross-section.d.ts +81 -20
  16. package/lib/api/services/cross-section/cross-section.js +81 -20
  17. package/lib/api/services/manifold/manifold-booleans.d.ts +139 -43
  18. package/lib/api/services/manifold/manifold-booleans.js +143 -43
  19. package/lib/api/services/manifold/manifold-evaluate.d.ts +134 -59
  20. package/lib/api/services/manifold/manifold-evaluate.js +141 -59
  21. package/lib/api/services/manifold/manifold-operations.d.ts +195 -108
  22. package/lib/api/services/manifold/manifold-operations.js +197 -110
  23. package/lib/api/services/manifold/manifold-shapes.d.ts +64 -26
  24. package/lib/api/services/manifold/manifold-shapes.js +66 -28
  25. package/lib/api/services/manifold/manifold-transforms.d.ts +100 -38
  26. package/lib/api/services/manifold/manifold-transforms.js +100 -38
  27. package/lib/api/services/manifold/manifold.d.ts +25 -8
  28. package/lib/api/services/manifold/manifold.js +25 -8
  29. package/lib/api/services/mesh/mesh-evaluate.d.ts +103 -32
  30. package/lib/api/services/mesh/mesh-evaluate.js +108 -33
  31. package/lib/api/services/mesh/mesh-operations.d.ts +12 -15
  32. package/lib/api/services/mesh/mesh-operations.js +12 -15
  33. package/lib/api/services/mesh/mesh.d.ts +4 -2
  34. package/lib/api/services/mesh/mesh.js +4 -2
  35. package/package.json +3 -3
@@ -1,150 +1,225 @@
1
1
  import * as Inputs from "../../inputs";
2
2
  import * as Manifold3D from "manifold-3d";
3
3
  /**
4
- * Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
5
- * Thanks Manifold community for developing this kernel
4
+ * Measuring Manifold solids and reading their bookkeeping: surface area and volume, vertex,
5
+ * triangle and edge counts, the bounding box, the tolerance, the genus, the gap to another solid,
6
+ * and the id and status the kernel tracks for every solid. Nothing here changes the solid.
6
7
  */
7
8
  export declare class ManifoldEvaluate {
8
9
  constructor(_wasm: Manifold3D.ManifoldToplevel);
9
10
  /**
10
- * Get surface area of manifold
11
- * @param inputs manifold
12
- * @returns surface area of manifold
11
+ * Measures the total surface area of a solid, in square model units.
12
+ * @param inputs - The solid
13
+ * @returns The surface area
13
14
  * @group basic
14
15
  * @shortname surface area
15
16
  * @drawable false
17
+ * @example
18
+ * ```typescript
19
+ * const area = await bitbybit.manifold.manifold.evaluate.surfaceArea({ manifold: cube });
20
+ * ```
16
21
  */
17
22
  surfaceArea(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
18
23
  /**
19
- * Get volume of manifold
20
- * @param inputs manifold
21
- * @returns volume of manifold
24
+ * Measures the volume of a solid, in cubic model units.
25
+ * @param inputs - The solid
26
+ * @returns The volume
22
27
  * @group basic
23
28
  * @shortname volume
24
29
  * @drawable false
30
+ * @example
31
+ * ```typescript
32
+ * const volume = await bitbybit.manifold.manifold.evaluate.volume({ manifold: cube });
33
+ * ```
25
34
  */
26
35
  volume(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
27
36
  /**
28
- * Check if manifold contains triangles
29
- * @param inputs manifold
30
- * @returns boolean indicating emptyness
37
+ * Tells whether a solid has no triangles at all, as the result of an intersection of shapes
38
+ * that do not overlap would.
39
+ * @param inputs - The solid
40
+ * @returns True when the solid is empty
31
41
  * @group basic
32
42
  * @shortname is empty
33
43
  * @drawable false
44
+ * @example
45
+ * ```typescript
46
+ * const empty = await bitbybit.manifold.manifold.evaluate.isEmpty({ manifold: shape });
47
+ * ```
34
48
  */
35
49
  isEmpty(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): boolean;
36
50
  /**
37
- * Get number of vertices in manifold
38
- * @param inputs manifold
39
- * @returns number of vertices of manifold
51
+ * Counts the vertices of a solid's mesh, the corners its triangles share.
52
+ * @param inputs - The solid
53
+ * @returns The number of vertices
40
54
  * @group basic
41
55
  * @shortname num vert
42
56
  * @drawable false
57
+ * @example
58
+ * ```typescript
59
+ * const vertices = await bitbybit.manifold.manifold.evaluate.numVert({ manifold: shape });
60
+ * ```
43
61
  */
44
62
  numVert(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
45
63
  /**
46
- * Get number of triangles in manifold
47
- * @param inputs manifold
48
- * @returns number of triangles of manifold
64
+ * Counts the triangles of a solid's mesh, which is its whole surface.
65
+ * @param inputs - The solid
66
+ * @returns The number of triangles
49
67
  * @group basic
50
68
  * @shortname num triangles
51
69
  * @drawable false
70
+ * @example
71
+ * ```typescript
72
+ * const triangles = await bitbybit.manifold.manifold.evaluate.numTri({ manifold: shape });
73
+ * ```
52
74
  */
53
75
  numTri(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
54
76
  /**
55
- * Get number of edges in manifold
56
- * @param inputs manifold
57
- * @returns number of edges of manifold
77
+ * Counts the edges of a solid's mesh, each shared by two triangles.
78
+ * @param inputs - The solid
79
+ * @returns The number of edges
58
80
  * @group basic
59
81
  * @shortname num edges
60
82
  * @drawable false
83
+ * @example
84
+ * ```typescript
85
+ * const edges = await bitbybit.manifold.manifold.evaluate.numEdge({ manifold: shape });
86
+ * ```
61
87
  */
62
88
  numEdge(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
63
89
  /**
64
- * Get number of properties in manifold
65
- * @param inputs manifold
66
- * @returns number of properties of manifold
90
+ * Counts the property channels each vertex of a solid carries; the position alone takes three.
91
+ * @param inputs - The solid
92
+ * @returns The number of properties per vertex
67
93
  * @group basic
68
94
  * @shortname num prop
69
95
  * @drawable false
96
+ * @example
97
+ * ```typescript
98
+ * const channels = await bitbybit.manifold.manifold.evaluate.numProp({ manifold: shape });
99
+ * ```
70
100
  */
71
101
  numProp(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
72
102
  /**
73
- * The number of property vertices in the Manifold. This will always be >=
74
- * numVert, as some physical vertices may be duplicated to account for
75
- * different properties on different neighboring triangles.
76
- * @param inputs manifold
77
- * @returns number of properties of manifold
103
+ * Counts the property vertices of a solid, which is at least `numVert`: a vertex whose
104
+ * neighboring triangles carry different properties, such as a sharp edge with two normals, is
105
+ * stored more than once.
106
+ * @param inputs - The solid
107
+ * @returns The number of property vertices
78
108
  * @group basic
79
109
  * @shortname num prop vert
80
110
  * @drawable false
111
+ * @example
112
+ * ```typescript
113
+ * const propVertices = await bitbybit.manifold.manifold.evaluate.numPropVert({ manifold: shape });
114
+ * ```
81
115
  */
82
116
  numPropVert(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
83
117
  /**
84
- * Returns the axis-aligned bounding box of all the Manifold's vertices.
85
- * @param inputs manifold
86
- * @returns bounding box corner vectors of manifold
118
+ * Finds the axis-aligned box around every vertex of a solid.
119
+ * @param inputs - The solid
120
+ * @returns The minimum corner and the maximum corner
87
121
  * @group basic
88
122
  * @shortname bounding box
89
123
  * @drawable false
124
+ * @example
125
+ * ```typescript
126
+ * const [min, max] = await bitbybit.manifold.manifold.evaluate.boundingBox({ manifold: shape });
127
+ * ```
90
128
  */
91
129
  boundingBox(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): Inputs.Base.Vector3[];
92
130
  /**
93
- * Returns the tolerance of this Manifold's vertices, which tracks the
94
- * approximate rounding error over all the transforms and operations that have
95
- * led to this state. Any triangles that are colinear within this tolerance
96
- * are considered degenerate and removed. This is the value of &epsilon;
97
- * defining
98
- * [&epsilon;-valid](https://github.com/elalish/manifold/wiki/Manifold-Library#definition-of-%CE%B5-valid).
99
- * @param inputs manifold
100
- * @returns tolerance of manifold
131
+ * Reads the tolerance of a solid, the rounding error that has built up over the transforms and
132
+ * operations that made it.
133
+ *
134
+ * Triangles thinner than this are treated as degenerate and removed.
135
+ * @param inputs - The solid
136
+ * @returns The tolerance in model units
101
137
  * @group basic
102
138
  * @shortname tolerance
103
139
  * @drawable false
140
+ * @example
141
+ * ```typescript
142
+ * const tolerance = await bitbybit.manifold.manifold.evaluate.tolerance({ manifold: shape });
143
+ * ```
104
144
  */
105
145
  tolerance(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
106
146
  /**
107
- * The genus is a topological property of the manifold, representing the
108
- * number of handles. A sphere is 0, torus 1, etc. It is only meaningful for
109
- * a single mesh, so it is best to call Decompose() first.
110
- * @param inputs manifold
111
- * @returns genus of manifold
147
+ * Counts the holes through a solid, the way a ring has one and a sphere none.
148
+ *
149
+ * It only makes sense for a single connected piece, so run `operations.decompose` first on a
150
+ * solid made of several.
151
+ * @param inputs - The solid
152
+ * @returns The number of holes through the solid
112
153
  * @group basic
113
154
  * @shortname genus
114
155
  * @drawable false
156
+ * @example
157
+ * ```typescript
158
+ * const holes = await bitbybit.manifold.manifold.evaluate.genus({ manifold: shape });
159
+ * ```
115
160
  */
116
161
  genus(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
117
162
  /**
118
- * Returns the minimum gap between two manifolds. Returns a float between
119
- * 0 and searchLength.
120
- * @param inputs two manifolds and search length
121
- * @returns minimum
163
+ * Measures the smallest distance between two solids, searching no farther than `searchLength`.
164
+ *
165
+ * The result is between 0 and the search length.
166
+ * @param inputs - The two solids and how far to search, in model units
167
+ * @returns The smallest gap between them
122
168
  * @group basic
123
169
  * @shortname min gap
124
170
  * @drawable false
171
+ * @example
172
+ * ```typescript
173
+ * const gap = await bitbybit.manifold.manifold.evaluate.minGap({ manifold1: cube, manifold2: sphere, searchLength: 100 });
174
+ * ```
125
175
  */
126
176
  minGap(inputs: Inputs.Manifold.ManifoldsMinGapDto<Manifold3D.Manifold>): number;
127
177
  /**
128
- * If this mesh is an original, this returns its ID that can be referenced
129
- * by product manifolds. If this manifold is a product, this
130
- * returns -1.
131
- * @param inputs manifold
132
- * @returns original id of manifold
178
+ * Shoots a ray segment from one point to another and lists every place it crosses the surface
179
+ * of a solid, nearest first; an empty list when it misses.
180
+ *
181
+ * A hit carries the point, the normal there, the original face id and its distance along the
182
+ * segment as a fraction of the segment's length.
183
+ * @param inputs - The solid, the start and the end of the ray segment
184
+ * @returns The hits sorted by distance
185
+ * @group spatial
186
+ * @shortname ray cast
187
+ * @drawable false
188
+ * @example
189
+ * ```typescript
190
+ * const hits = await bitbybit.manifold.manifold.evaluate.rayCast({ manifold: shape, origin: [0, 10, 0], endpoint: [0, -10, 0] });
191
+ * ```
192
+ */
193
+ rayCast(inputs: Inputs.Manifold.RayCastDto<Manifold3D.Manifold>): Inputs.Manifold.RayHit[];
194
+ /**
195
+ * Reads the id of a solid that is an original, as `operations.asOriginal` or a freshly built
196
+ * solid makes it; a solid produced from others by an operation reports -1.
197
+ * @param inputs - The solid
198
+ * @returns The original id, or -1
133
199
  * @group basic
134
200
  * @shortname original id
135
201
  * @drawable false
202
+ * @example
203
+ * ```typescript
204
+ * const id = await bitbybit.manifold.manifold.evaluate.originalID({ manifold: shape });
205
+ * ```
136
206
  */
137
207
  originalID(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
138
208
  /**
139
- * Returns the reason for an input Mesh producing an empty Manifold. This
140
- * Status will carry on through operations like NaN propogation, ensuring an
141
- * errored mesh doesn't get mysteriously lost. Empty meshes may still show
142
- * NoError, for instance the intersection of non-overlapping meshes.
143
- * @param inputs manifold
144
- * @returns error status string (NoError, NotManifold, InvalidConstruction, etc.)
209
+ * Tells why a solid came out empty: `NoError`, or a reason such as `NotManifold` or
210
+ * `InvalidConstruction` when the mesh it was built from was not a closed surface.
211
+ *
212
+ * The status is carried through later operations, so a broken input does not get lost; an empty
213
+ * solid can still report `NoError`, as intersecting shapes that do not overlap does.
214
+ * @param inputs - The solid
215
+ * @returns The status name
145
216
  * @group basic
146
217
  * @shortname status
147
218
  * @drawable false
219
+ * @example
220
+ * ```typescript
221
+ * const status = await bitbybit.manifold.manifold.evaluate.status({ manifold: shape });
222
+ * ```
148
223
  */
149
224
  status(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): string;
150
225
  }
@@ -1,176 +1,258 @@
1
1
  /**
2
- * Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
3
- * Thanks Manifold community for developing this kernel
2
+ * Measuring Manifold solids and reading their bookkeeping: surface area and volume, vertex,
3
+ * triangle and edge counts, the bounding box, the tolerance, the genus, the gap to another solid,
4
+ * and the id and status the kernel tracks for every solid. Nothing here changes the solid.
4
5
  */
5
6
  export class ManifoldEvaluate {
6
7
  constructor(_wasm) {
7
8
  }
8
9
  /**
9
- * Get surface area of manifold
10
- * @param inputs manifold
11
- * @returns surface area of manifold
10
+ * Measures the total surface area of a solid, in square model units.
11
+ * @param inputs - The solid
12
+ * @returns The surface area
12
13
  * @group basic
13
14
  * @shortname surface area
14
15
  * @drawable false
16
+ * @example
17
+ * ```typescript
18
+ * const area = await bitbybit.manifold.manifold.evaluate.surfaceArea({ manifold: cube });
19
+ * ```
15
20
  */
16
21
  surfaceArea(inputs) {
17
22
  return inputs.manifold.surfaceArea();
18
23
  }
19
24
  /**
20
- * Get volume of manifold
21
- * @param inputs manifold
22
- * @returns volume of manifold
25
+ * Measures the volume of a solid, in cubic model units.
26
+ * @param inputs - The solid
27
+ * @returns The volume
23
28
  * @group basic
24
29
  * @shortname volume
25
30
  * @drawable false
31
+ * @example
32
+ * ```typescript
33
+ * const volume = await bitbybit.manifold.manifold.evaluate.volume({ manifold: cube });
34
+ * ```
26
35
  */
27
36
  volume(inputs) {
28
37
  return inputs.manifold.volume();
29
38
  }
30
39
  /**
31
- * Check if manifold contains triangles
32
- * @param inputs manifold
33
- * @returns boolean indicating emptyness
40
+ * Tells whether a solid has no triangles at all, as the result of an intersection of shapes
41
+ * that do not overlap would.
42
+ * @param inputs - The solid
43
+ * @returns True when the solid is empty
34
44
  * @group basic
35
45
  * @shortname is empty
36
46
  * @drawable false
47
+ * @example
48
+ * ```typescript
49
+ * const empty = await bitbybit.manifold.manifold.evaluate.isEmpty({ manifold: shape });
50
+ * ```
37
51
  */
38
52
  isEmpty(inputs) {
39
53
  return inputs.manifold.isEmpty();
40
54
  }
41
55
  /**
42
- * Get number of vertices in manifold
43
- * @param inputs manifold
44
- * @returns number of vertices of manifold
56
+ * Counts the vertices of a solid's mesh, the corners its triangles share.
57
+ * @param inputs - The solid
58
+ * @returns The number of vertices
45
59
  * @group basic
46
60
  * @shortname num vert
47
61
  * @drawable false
62
+ * @example
63
+ * ```typescript
64
+ * const vertices = await bitbybit.manifold.manifold.evaluate.numVert({ manifold: shape });
65
+ * ```
48
66
  */
49
67
  numVert(inputs) {
50
68
  return inputs.manifold.numVert();
51
69
  }
52
70
  /**
53
- * Get number of triangles in manifold
54
- * @param inputs manifold
55
- * @returns number of triangles of manifold
71
+ * Counts the triangles of a solid's mesh, which is its whole surface.
72
+ * @param inputs - The solid
73
+ * @returns The number of triangles
56
74
  * @group basic
57
75
  * @shortname num triangles
58
76
  * @drawable false
77
+ * @example
78
+ * ```typescript
79
+ * const triangles = await bitbybit.manifold.manifold.evaluate.numTri({ manifold: shape });
80
+ * ```
59
81
  */
60
82
  numTri(inputs) {
61
83
  return inputs.manifold.numTri();
62
84
  }
63
85
  /**
64
- * Get number of edges in manifold
65
- * @param inputs manifold
66
- * @returns number of edges of manifold
86
+ * Counts the edges of a solid's mesh, each shared by two triangles.
87
+ * @param inputs - The solid
88
+ * @returns The number of edges
67
89
  * @group basic
68
90
  * @shortname num edges
69
91
  * @drawable false
92
+ * @example
93
+ * ```typescript
94
+ * const edges = await bitbybit.manifold.manifold.evaluate.numEdge({ manifold: shape });
95
+ * ```
70
96
  */
71
97
  numEdge(inputs) {
72
98
  return inputs.manifold.numEdge();
73
99
  }
74
100
  /**
75
- * Get number of properties in manifold
76
- * @param inputs manifold
77
- * @returns number of properties of manifold
101
+ * Counts the property channels each vertex of a solid carries; the position alone takes three.
102
+ * @param inputs - The solid
103
+ * @returns The number of properties per vertex
78
104
  * @group basic
79
105
  * @shortname num prop
80
106
  * @drawable false
107
+ * @example
108
+ * ```typescript
109
+ * const channels = await bitbybit.manifold.manifold.evaluate.numProp({ manifold: shape });
110
+ * ```
81
111
  */
82
112
  numProp(inputs) {
83
113
  return inputs.manifold.numProp();
84
114
  }
85
115
  /**
86
- * The number of property vertices in the Manifold. This will always be >=
87
- * numVert, as some physical vertices may be duplicated to account for
88
- * different properties on different neighboring triangles.
89
- * @param inputs manifold
90
- * @returns number of properties of manifold
116
+ * Counts the property vertices of a solid, which is at least `numVert`: a vertex whose
117
+ * neighboring triangles carry different properties, such as a sharp edge with two normals, is
118
+ * stored more than once.
119
+ * @param inputs - The solid
120
+ * @returns The number of property vertices
91
121
  * @group basic
92
122
  * @shortname num prop vert
93
123
  * @drawable false
124
+ * @example
125
+ * ```typescript
126
+ * const propVertices = await bitbybit.manifold.manifold.evaluate.numPropVert({ manifold: shape });
127
+ * ```
94
128
  */
95
129
  numPropVert(inputs) {
96
130
  return inputs.manifold.numPropVert();
97
131
  }
98
132
  /**
99
- * Returns the axis-aligned bounding box of all the Manifold's vertices.
100
- * @param inputs manifold
101
- * @returns bounding box corner vectors of manifold
133
+ * Finds the axis-aligned box around every vertex of a solid.
134
+ * @param inputs - The solid
135
+ * @returns The minimum corner and the maximum corner
102
136
  * @group basic
103
137
  * @shortname bounding box
104
138
  * @drawable false
139
+ * @example
140
+ * ```typescript
141
+ * const [min, max] = await bitbybit.manifold.manifold.evaluate.boundingBox({ manifold: shape });
142
+ * ```
105
143
  */
106
144
  boundingBox(inputs) {
107
145
  const bounds = inputs.manifold.boundingBox();
108
146
  return [bounds.min, bounds.max];
109
147
  }
110
148
  /**
111
- * Returns the tolerance of this Manifold's vertices, which tracks the
112
- * approximate rounding error over all the transforms and operations that have
113
- * led to this state. Any triangles that are colinear within this tolerance
114
- * are considered degenerate and removed. This is the value of &epsilon;
115
- * defining
116
- * [&epsilon;-valid](https://github.com/elalish/manifold/wiki/Manifold-Library#definition-of-%CE%B5-valid).
117
- * @param inputs manifold
118
- * @returns tolerance of manifold
149
+ * Reads the tolerance of a solid, the rounding error that has built up over the transforms and
150
+ * operations that made it.
151
+ *
152
+ * Triangles thinner than this are treated as degenerate and removed.
153
+ * @param inputs - The solid
154
+ * @returns The tolerance in model units
119
155
  * @group basic
120
156
  * @shortname tolerance
121
157
  * @drawable false
158
+ * @example
159
+ * ```typescript
160
+ * const tolerance = await bitbybit.manifold.manifold.evaluate.tolerance({ manifold: shape });
161
+ * ```
122
162
  */
123
163
  tolerance(inputs) {
124
164
  return inputs.manifold.tolerance();
125
165
  }
126
166
  /**
127
- * The genus is a topological property of the manifold, representing the
128
- * number of handles. A sphere is 0, torus 1, etc. It is only meaningful for
129
- * a single mesh, so it is best to call Decompose() first.
130
- * @param inputs manifold
131
- * @returns genus of manifold
167
+ * Counts the holes through a solid, the way a ring has one and a sphere none.
168
+ *
169
+ * It only makes sense for a single connected piece, so run `operations.decompose` first on a
170
+ * solid made of several.
171
+ * @param inputs - The solid
172
+ * @returns The number of holes through the solid
132
173
  * @group basic
133
174
  * @shortname genus
134
175
  * @drawable false
176
+ * @example
177
+ * ```typescript
178
+ * const holes = await bitbybit.manifold.manifold.evaluate.genus({ manifold: shape });
179
+ * ```
135
180
  */
136
181
  genus(inputs) {
137
182
  return inputs.manifold.genus();
138
183
  }
139
184
  /**
140
- * Returns the minimum gap between two manifolds. Returns a float between
141
- * 0 and searchLength.
142
- * @param inputs two manifolds and search length
143
- * @returns minimum
185
+ * Measures the smallest distance between two solids, searching no farther than `searchLength`.
186
+ *
187
+ * The result is between 0 and the search length.
188
+ * @param inputs - The two solids and how far to search, in model units
189
+ * @returns The smallest gap between them
144
190
  * @group basic
145
191
  * @shortname min gap
146
192
  * @drawable false
193
+ * @example
194
+ * ```typescript
195
+ * const gap = await bitbybit.manifold.manifold.evaluate.minGap({ manifold1: cube, manifold2: sphere, searchLength: 100 });
196
+ * ```
147
197
  */
148
198
  minGap(inputs) {
149
199
  return inputs.manifold1.minGap(inputs.manifold2, inputs.searchLength);
150
200
  }
151
201
  /**
152
- * If this mesh is an original, this returns its ID that can be referenced
153
- * by product manifolds. If this manifold is a product, this
154
- * returns -1.
155
- * @param inputs manifold
156
- * @returns original id of manifold
202
+ * Shoots a ray segment from one point to another and lists every place it crosses the surface
203
+ * of a solid, nearest first; an empty list when it misses.
204
+ *
205
+ * A hit carries the point, the normal there, the original face id and its distance along the
206
+ * segment as a fraction of the segment's length.
207
+ * @param inputs - The solid, the start and the end of the ray segment
208
+ * @returns The hits sorted by distance
209
+ * @group spatial
210
+ * @shortname ray cast
211
+ * @drawable false
212
+ * @example
213
+ * ```typescript
214
+ * const hits = await bitbybit.manifold.manifold.evaluate.rayCast({ manifold: shape, origin: [0, 10, 0], endpoint: [0, -10, 0] });
215
+ * ```
216
+ */
217
+ rayCast(inputs) {
218
+ return inputs.manifold.rayCast(inputs.origin, inputs.endpoint).map((hit) => ({
219
+ faceID: hit.faceID,
220
+ distance: hit.distance,
221
+ position: [...hit.position],
222
+ normal: [...hit.normal],
223
+ }));
224
+ }
225
+ /**
226
+ * Reads the id of a solid that is an original, as `operations.asOriginal` or a freshly built
227
+ * solid makes it; a solid produced from others by an operation reports -1.
228
+ * @param inputs - The solid
229
+ * @returns The original id, or -1
157
230
  * @group basic
158
231
  * @shortname original id
159
232
  * @drawable false
233
+ * @example
234
+ * ```typescript
235
+ * const id = await bitbybit.manifold.manifold.evaluate.originalID({ manifold: shape });
236
+ * ```
160
237
  */
161
238
  originalID(inputs) {
162
239
  return inputs.manifold.originalID();
163
240
  }
164
241
  /**
165
- * Returns the reason for an input Mesh producing an empty Manifold. This
166
- * Status will carry on through operations like NaN propogation, ensuring an
167
- * errored mesh doesn't get mysteriously lost. Empty meshes may still show
168
- * NoError, for instance the intersection of non-overlapping meshes.
169
- * @param inputs manifold
170
- * @returns error status string (NoError, NotManifold, InvalidConstruction, etc.)
242
+ * Tells why a solid came out empty: `NoError`, or a reason such as `NotManifold` or
243
+ * `InvalidConstruction` when the mesh it was built from was not a closed surface.
244
+ *
245
+ * The status is carried through later operations, so a broken input does not get lost; an empty
246
+ * solid can still report `NoError`, as intersecting shapes that do not overlap does.
247
+ * @param inputs - The solid
248
+ * @returns The status name
171
249
  * @group basic
172
250
  * @shortname status
173
251
  * @drawable false
252
+ * @example
253
+ * ```typescript
254
+ * const status = await bitbybit.manifold.manifold.evaluate.status({ manifold: shape });
255
+ * ```
174
256
  */
175
257
  status(inputs) {
176
258
  return inputs.manifold.status();