@bitbybit-dev/manifold 1.2.0-rc.2 → 1.3.0-rc.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
@@ -4,8 +4,12 @@ import { Manifold } from "./services/manifold/manifold";
4
4
  import { CrossSection } from "./services/cross-section/cross-section";
5
5
  import { Mesh } from "./services/mesh/mesh";
6
6
  /**
7
- * Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
8
- * Thanks Manifold community for developing this kernel
7
+ * The entry point to the Manifold kernel, a fast mesh-based solid modeler: `manifold` builds and
8
+ * changes solids, `crossSection` handles the flat outlines they are extruded and revolved from, and
9
+ * `mesh` reads the triangle data. Manifold works on triangle meshes rather than exact curves, so
10
+ * booleans are quick and always watertight, and it keeps its own Z axis as up: extrusions grow
11
+ * along Z and slices are parallel to the XY plane. The methods on the service itself turn solids
12
+ * and cross-sections into plain mesh data for drawing.
9
13
  */
10
14
  export declare class ManifoldService {
11
15
  plugins: any;
@@ -15,30 +19,52 @@ export declare class ManifoldService {
15
19
  mesh: Mesh;
16
20
  constructor(wasm: Manifold3D.ManifoldToplevel);
17
21
  /**
18
- * Decomposes manifold or cross section shape into a mesh or simple polygons
19
- * @param inputs Manifold shape or cross section
20
- * @returns Decomposed mesh definition or simple polygons
22
+ * Turns a solid into plain mesh data, or a cross-section into its polygons, ready for drawing
23
+ * or export.
24
+ *
25
+ * `normalIdx` names the vertex property channel that holds normals, when the solid carries
26
+ * them.
27
+ * @param inputs - The solid or cross-section and the optional normal channel
28
+ * @returns The mesh data of a solid, or the polygons of a cross-section
21
29
  * @group decompose
22
30
  * @shortname decompose m or cs
23
31
  * @drawable false
32
+ * @example
33
+ * ```typescript
34
+ * const mesh = await bitbybit.manifold.decomposeManifoldOrCrossSection({ manifoldOrCrossSection: cube });
35
+ * ```
24
36
  */
25
37
  decomposeManifoldOrCrossSection(inputs: Inputs.Manifold.DecomposeManifoldOrCrossSectionDto<Manifold3D.Manifold | Manifold3D.CrossSection>): Manifold3D.Mesh | Manifold3D.SimplePolygon[];
26
38
  /**
27
- * Turns manifold shape into a collection of polygon points representing the mesh.
28
- * @param inputs Manifold shape
29
- * @returns polygon points
39
+ * Turns a solid into a list of triangles, each three points, the same form
40
+ * `shapes.fromPolygonPoints` reads back.
41
+ *
42
+ * An empty solid gives an empty list.
43
+ * @param inputs - The solid
44
+ * @returns One list of three points per triangle
30
45
  * @group decompose
31
46
  * @shortname to polygon points
32
47
  * @drawable false
48
+ * @example
49
+ * ```typescript
50
+ * const triangles = await bitbybit.manifold.toPolygonPoints({ manifold: cube });
51
+ * ```
33
52
  */
34
53
  toPolygonPoints(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): Inputs.Base.Mesh3;
35
54
  /**
36
- * Decomposes manifold or cross section shape into a mesh or simple polygons
37
- * @param inputs Manifold shapes or cross sections
38
- * @returns Decomposed mesh definitions or a list of simple polygons
55
+ * Turns several solids into mesh data, or cross-sections into polygons, as
56
+ * `decomposeManifoldOrCrossSection` does for one.
57
+ *
58
+ * `normalIdx` gives one normal channel per shape.
59
+ * @param inputs - The solids or cross-sections and the optional normal channels
60
+ * @returns One mesh or polygon list per shape, in the same order
39
61
  * @group decompose
40
62
  * @shortname decompose m's or cs's
41
63
  * @drawable false
64
+ * @example
65
+ * ```typescript
66
+ * const meshes = await bitbybit.manifold.decomposeManifoldsOrCrossSections({ manifoldsOrCrossSections: [cube, sphere] });
67
+ * ```
42
68
  */
43
69
  decomposeManifoldsOrCrossSections(inputs: Inputs.Manifold.DecomposeManifoldsOrCrossSectionsDto<Manifold3D.Manifold | Manifold3D.CrossSection>): (Manifold3D.Mesh | Manifold3D.SimplePolygon[])[];
44
70
  }
@@ -3,8 +3,12 @@ import { CrossSection } from "./services/cross-section/cross-section";
3
3
  import { Mesh } from "./services/mesh/mesh";
4
4
  import { BaseBitByBit } from "../base";
5
5
  /**
6
- * Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
7
- * Thanks Manifold community for developing this kernel
6
+ * The entry point to the Manifold kernel, a fast mesh-based solid modeler: `manifold` builds and
7
+ * changes solids, `crossSection` handles the flat outlines they are extruded and revolved from, and
8
+ * `mesh` reads the triangle data. Manifold works on triangle meshes rather than exact curves, so
9
+ * booleans are quick and always watertight, and it keeps its own Z axis as up: extrusions grow
10
+ * along Z and slices are parallel to the XY plane. The methods on the service itself turn solids
11
+ * and cross-sections into plain mesh data for drawing.
8
12
  */
9
13
  export class ManifoldService {
10
14
  constructor(wasm) {
@@ -14,12 +18,20 @@ export class ManifoldService {
14
18
  this.mesh = new Mesh(wasm);
15
19
  }
16
20
  /**
17
- * Decomposes manifold or cross section shape into a mesh or simple polygons
18
- * @param inputs Manifold shape or cross section
19
- * @returns Decomposed mesh definition or simple polygons
21
+ * Turns a solid into plain mesh data, or a cross-section into its polygons, ready for drawing
22
+ * or export.
23
+ *
24
+ * `normalIdx` names the vertex property channel that holds normals, when the solid carries
25
+ * them.
26
+ * @param inputs - The solid or cross-section and the optional normal channel
27
+ * @returns The mesh data of a solid, or the polygons of a cross-section
20
28
  * @group decompose
21
29
  * @shortname decompose m or cs
22
30
  * @drawable false
31
+ * @example
32
+ * ```typescript
33
+ * const mesh = await bitbybit.manifold.decomposeManifoldOrCrossSection({ manifoldOrCrossSection: cube });
34
+ * ```
23
35
  */
24
36
  decomposeManifoldOrCrossSection(inputs) {
25
37
  if (inputs.manifoldOrCrossSection.getMesh) {
@@ -30,12 +42,19 @@ export class ManifoldService {
30
42
  }
31
43
  }
32
44
  /**
33
- * Turns manifold shape into a collection of polygon points representing the mesh.
34
- * @param inputs Manifold shape
35
- * @returns polygon points
45
+ * Turns a solid into a list of triangles, each three points, the same form
46
+ * `shapes.fromPolygonPoints` reads back.
47
+ *
48
+ * An empty solid gives an empty list.
49
+ * @param inputs - The solid
50
+ * @returns One list of three points per triangle
36
51
  * @group decompose
37
52
  * @shortname to polygon points
38
53
  * @drawable false
54
+ * @example
55
+ * ```typescript
56
+ * const triangles = await bitbybit.manifold.toPolygonPoints({ manifold: cube });
57
+ * ```
39
58
  */
40
59
  toPolygonPoints(inputs) {
41
60
  if (typeof inputs.manifold.getMesh === "function") {
@@ -79,12 +98,19 @@ export class ManifoldService {
79
98
  }
80
99
  }
81
100
  /**
82
- * Decomposes manifold or cross section shape into a mesh or simple polygons
83
- * @param inputs Manifold shapes or cross sections
84
- * @returns Decomposed mesh definitions or a list of simple polygons
101
+ * Turns several solids into mesh data, or cross-sections into polygons, as
102
+ * `decomposeManifoldOrCrossSection` does for one.
103
+ *
104
+ * `normalIdx` gives one normal channel per shape.
105
+ * @param inputs - The solids or cross-sections and the optional normal channels
106
+ * @returns One mesh or polygon list per shape, in the same order
85
107
  * @group decompose
86
108
  * @shortname decompose m's or cs's
87
109
  * @drawable false
110
+ * @example
111
+ * ```typescript
112
+ * const meshes = await bitbybit.manifold.decomposeManifoldsOrCrossSections({ manifoldsOrCrossSections: [cube, sphere] });
113
+ * ```
88
114
  */
89
115
  decomposeManifoldsOrCrossSections(inputs) {
90
116
  return inputs.manifoldsOrCrossSections.map((manifoldOrCrossSection, index) => {
@@ -1,91 +1,128 @@
1
1
  import * as Inputs from "../../inputs/manifold-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
+ * Combining Manifold cross-sections: fusing, cutting and intersecting two or many flat outlines at
5
+ * once. The two-shape and many-shape forms give the same results and exist for convenience; every
6
+ * method returns a new cross-section and leaves the inputs as they are.
6
7
  */
7
8
  export declare class CrossSectionBooleans {
8
9
  private manifold;
9
10
  constructor(wasm: Manifold3D.ManifoldToplevel);
10
11
  /**
11
- * Subtract two cross sections
12
- * @param inputs two cross sections
13
- * @returns subtracted cross section
12
+ * Cuts the second cross-section out of the first, leaving what remains of the first.
13
+ * @param inputs - The cross-section to cut from and the one to cut with
14
+ * @returns The first minus the second
14
15
  * @group a to b
15
16
  * @shortname subtract
16
17
  * @drawable true
18
+ * @example
19
+ * ```typescript
20
+ * const ring = await bitbybit.manifold.crossSection.booleans.subtract({ crossSection1: outerDisc, crossSection2: innerDisc });
21
+ * ```
17
22
  */
18
23
  subtract(inputs: Inputs.Manifold.TwoCrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
19
24
  /**
20
- * Add two cross sections
21
- * @param inputs two cross sections
22
- * @returns unioned cross section
25
+ * Fuses two cross-sections into one outline, holes and all.
26
+ * @param inputs - The two cross-sections
27
+ * @returns The fused cross-section
23
28
  * @group a to b
24
29
  * @shortname add
25
30
  * @drawable true
31
+ * @example
32
+ * ```typescript
33
+ * const fused = await bitbybit.manifold.crossSection.booleans.add({ crossSection1: square, crossSection2: disc });
34
+ * ```
26
35
  */
27
36
  add(inputs: Inputs.Manifold.TwoCrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
28
37
  /**
29
- * Intersect two cross sections
30
- * @param inputs two cross sections
31
- * @returns intersected cross section
38
+ * Keeps only the area two cross-sections share, dropping everything else.
39
+ * @param inputs - The two cross-sections
40
+ * @returns The shared area
32
41
  * @group a to b
33
42
  * @shortname intersect
34
43
  * @drawable true
44
+ * @example
45
+ * ```typescript
46
+ * const common = await bitbybit.manifold.crossSection.booleans.intersect({ crossSection1: square, crossSection2: disc });
47
+ * ```
35
48
  */
36
49
  intersect(inputs: Inputs.Manifold.TwoCrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
37
50
  /**
38
- * Difference of two cross sections
39
- * @param inputs two cross sections
40
- * @returns difference of two cross sections
51
+ * Cuts the second cross-section out of the first, the same as `subtract`.
52
+ * @param inputs - The cross-section to cut from and the one to cut with
53
+ * @returns The first minus the second
41
54
  * @group 2 cross sections
42
55
  * @shortname difference 2 cs
43
56
  * @drawable true
57
+ * @example
58
+ * ```typescript
59
+ * const ring = await bitbybit.manifold.crossSection.booleans.differenceTwo({ crossSection1: outerDisc, crossSection2: innerDisc });
60
+ * ```
44
61
  */
45
62
  differenceTwo(inputs: Inputs.Manifold.TwoCrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
46
63
  /**
47
- * Union of two cross sections
48
- * @param inputs two cross sections
49
- * @returns union of two cross sections
64
+ * Fuses two cross-sections into one, the same as `add`.
65
+ * @param inputs - The two cross-sections
66
+ * @returns The fused cross-section
50
67
  * @group 2 cross sections
51
68
  * @shortname union 2 cs
52
69
  * @drawable true
70
+ * @example
71
+ * ```typescript
72
+ * const fused = await bitbybit.manifold.crossSection.booleans.unionTwo({ crossSection1: square, crossSection2: disc });
73
+ * ```
53
74
  */
54
75
  unionTwo(inputs: Inputs.Manifold.TwoCrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
55
76
  /**
56
- * Intersection of two cross sections
57
- * @param inputs two shapes
58
- * @returns intersection of two cross sections
77
+ * Keeps only the area two cross-sections share, the same as `intersect`.
78
+ * @param inputs - The two cross-sections
79
+ * @returns The shared area
59
80
  * @group 2 cross sections
60
81
  * @shortname intersect 2 cs
61
82
  * @drawable true
83
+ * @example
84
+ * ```typescript
85
+ * const common = await bitbybit.manifold.crossSection.booleans.intersectionTwo({ crossSection1: square, crossSection2: disc });
86
+ * ```
62
87
  */
63
88
  intersectionTwo(inputs: Inputs.Manifold.TwoCrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
64
89
  /**
65
- * Difference of multiple cross sections
66
- * @param inputs multiple cross sections
67
- * @returns difference of cross sections
90
+ * Cuts every further cross-section in the list out of the first one.
91
+ * @param inputs - The cross-sections, the first being the one cut from
92
+ * @returns The first minus all the others
68
93
  * @group multiple
69
94
  * @shortname diff cross sections
70
95
  * @drawable true
96
+ * @example
97
+ * ```typescript
98
+ * const plate = await bitbybit.manifold.crossSection.booleans.difference({ crossSections: [square, hole1, hole2] });
99
+ * ```
71
100
  */
72
101
  difference(inputs: Inputs.Manifold.CrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
73
102
  /**
74
- * Union of multiple cross sections
75
- * @param inputs multiple cross sections
76
- * @returns union of two cross sections
103
+ * Fuses all the cross-sections in a list into one.
104
+ * @param inputs - The cross-sections
105
+ * @returns The fused cross-section
77
106
  * @group multiple
78
107
  * @shortname union cross sections
79
108
  * @drawable true
109
+ * @example
110
+ * ```typescript
111
+ * const fused = await bitbybit.manifold.crossSection.booleans.union({ crossSections: [square, disc, rectangle] });
112
+ * ```
80
113
  */
81
114
  union(inputs: Inputs.Manifold.CrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
82
115
  /**
83
- * Intersection of multiple cross sections
84
- * @param inputs two cross sections
85
- * @returns intersection of multiple cross sections
116
+ * Keeps only the area all the cross-sections in a list share.
117
+ * @param inputs - The cross-sections
118
+ * @returns The area common to all of them
86
119
  * @group multiple
87
120
  * @shortname intersection cross sections
88
121
  * @drawable true
122
+ * @example
123
+ * ```typescript
124
+ * const common = await bitbybit.manifold.crossSection.booleans.intersection({ crossSections: [square, disc] });
125
+ * ```
89
126
  */
90
127
  intersection(inputs: Inputs.Manifold.CrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
91
128
  }
@@ -1,51 +1,68 @@
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
+ * Combining Manifold cross-sections: fusing, cutting and intersecting two or many flat outlines at
3
+ * once. The two-shape and many-shape forms give the same results and exist for convenience; every
4
+ * method returns a new cross-section and leaves the inputs as they are.
4
5
  */
5
6
  export class CrossSectionBooleans {
6
7
  constructor(wasm) {
7
8
  this.manifold = wasm;
8
9
  }
9
10
  /**
10
- * Subtract two cross sections
11
- * @param inputs two cross sections
12
- * @returns subtracted cross section
11
+ * Cuts the second cross-section out of the first, leaving what remains of the first.
12
+ * @param inputs - The cross-section to cut from and the one to cut with
13
+ * @returns The first minus the second
13
14
  * @group a to b
14
15
  * @shortname subtract
15
16
  * @drawable true
17
+ * @example
18
+ * ```typescript
19
+ * const ring = await bitbybit.manifold.crossSection.booleans.subtract({ crossSection1: outerDisc, crossSection2: innerDisc });
20
+ * ```
16
21
  */
17
22
  subtract(inputs) {
18
23
  return inputs.crossSection1.subtract(inputs.crossSection2);
19
24
  }
20
25
  /**
21
- * Add two cross sections
22
- * @param inputs two cross sections
23
- * @returns unioned cross section
26
+ * Fuses two cross-sections into one outline, holes and all.
27
+ * @param inputs - The two cross-sections
28
+ * @returns The fused cross-section
24
29
  * @group a to b
25
30
  * @shortname add
26
31
  * @drawable true
32
+ * @example
33
+ * ```typescript
34
+ * const fused = await bitbybit.manifold.crossSection.booleans.add({ crossSection1: square, crossSection2: disc });
35
+ * ```
27
36
  */
28
37
  add(inputs) {
29
38
  return inputs.crossSection1.add(inputs.crossSection2);
30
39
  }
31
40
  /**
32
- * Intersect two cross sections
33
- * @param inputs two cross sections
34
- * @returns intersected cross section
41
+ * Keeps only the area two cross-sections share, dropping everything else.
42
+ * @param inputs - The two cross-sections
43
+ * @returns The shared area
35
44
  * @group a to b
36
45
  * @shortname intersect
37
46
  * @drawable true
47
+ * @example
48
+ * ```typescript
49
+ * const common = await bitbybit.manifold.crossSection.booleans.intersect({ crossSection1: square, crossSection2: disc });
50
+ * ```
38
51
  */
39
52
  intersect(inputs) {
40
53
  return inputs.crossSection1.intersect(inputs.crossSection2);
41
54
  }
42
55
  /**
43
- * Difference of two cross sections
44
- * @param inputs two cross sections
45
- * @returns difference of two cross sections
56
+ * Cuts the second cross-section out of the first, the same as `subtract`.
57
+ * @param inputs - The cross-section to cut from and the one to cut with
58
+ * @returns The first minus the second
46
59
  * @group 2 cross sections
47
60
  * @shortname difference 2 cs
48
61
  * @drawable true
62
+ * @example
63
+ * ```typescript
64
+ * const ring = await bitbybit.manifold.crossSection.booleans.differenceTwo({ crossSection1: outerDisc, crossSection2: innerDisc });
65
+ * ```
49
66
  */
50
67
  differenceTwo(inputs) {
51
68
  const { CrossSection } = this.manifold;
@@ -53,12 +70,16 @@ export class CrossSectionBooleans {
53
70
  return difference(inputs.crossSection1, inputs.crossSection2);
54
71
  }
55
72
  /**
56
- * Union of two cross sections
57
- * @param inputs two cross sections
58
- * @returns union of two cross sections
73
+ * Fuses two cross-sections into one, the same as `add`.
74
+ * @param inputs - The two cross-sections
75
+ * @returns The fused cross-section
59
76
  * @group 2 cross sections
60
77
  * @shortname union 2 cs
61
78
  * @drawable true
79
+ * @example
80
+ * ```typescript
81
+ * const fused = await bitbybit.manifold.crossSection.booleans.unionTwo({ crossSection1: square, crossSection2: disc });
82
+ * ```
62
83
  */
63
84
  unionTwo(inputs) {
64
85
  const { CrossSection } = this.manifold;
@@ -66,12 +87,16 @@ export class CrossSectionBooleans {
66
87
  return union(inputs.crossSection1, inputs.crossSection2);
67
88
  }
68
89
  /**
69
- * Intersection of two cross sections
70
- * @param inputs two shapes
71
- * @returns intersection of two cross sections
90
+ * Keeps only the area two cross-sections share, the same as `intersect`.
91
+ * @param inputs - The two cross-sections
92
+ * @returns The shared area
72
93
  * @group 2 cross sections
73
94
  * @shortname intersect 2 cs
74
95
  * @drawable true
96
+ * @example
97
+ * ```typescript
98
+ * const common = await bitbybit.manifold.crossSection.booleans.intersectionTwo({ crossSection1: square, crossSection2: disc });
99
+ * ```
75
100
  */
76
101
  intersectionTwo(inputs) {
77
102
  const { CrossSection } = this.manifold;
@@ -79,12 +104,16 @@ export class CrossSectionBooleans {
79
104
  return intersection(inputs.crossSection1, inputs.crossSection2);
80
105
  }
81
106
  /**
82
- * Difference of multiple cross sections
83
- * @param inputs multiple cross sections
84
- * @returns difference of cross sections
107
+ * Cuts every further cross-section in the list out of the first one.
108
+ * @param inputs - The cross-sections, the first being the one cut from
109
+ * @returns The first minus all the others
85
110
  * @group multiple
86
111
  * @shortname diff cross sections
87
112
  * @drawable true
113
+ * @example
114
+ * ```typescript
115
+ * const plate = await bitbybit.manifold.crossSection.booleans.difference({ crossSections: [square, hole1, hole2] });
116
+ * ```
88
117
  */
89
118
  difference(inputs) {
90
119
  const { CrossSection } = this.manifold;
@@ -92,12 +121,16 @@ export class CrossSectionBooleans {
92
121
  return difference(inputs.crossSections);
93
122
  }
94
123
  /**
95
- * Union of multiple cross sections
96
- * @param inputs multiple cross sections
97
- * @returns union of two cross sections
124
+ * Fuses all the cross-sections in a list into one.
125
+ * @param inputs - The cross-sections
126
+ * @returns The fused cross-section
98
127
  * @group multiple
99
128
  * @shortname union cross sections
100
129
  * @drawable true
130
+ * @example
131
+ * ```typescript
132
+ * const fused = await bitbybit.manifold.crossSection.booleans.union({ crossSections: [square, disc, rectangle] });
133
+ * ```
101
134
  */
102
135
  union(inputs) {
103
136
  const { CrossSection } = this.manifold;
@@ -105,12 +138,16 @@ export class CrossSectionBooleans {
105
138
  return union(inputs.crossSections);
106
139
  }
107
140
  /**
108
- * Intersection of multiple cross sections
109
- * @param inputs two cross sections
110
- * @returns intersection of multiple cross sections
141
+ * Keeps only the area all the cross-sections in a list share.
142
+ * @param inputs - The cross-sections
143
+ * @returns The area common to all of them
111
144
  * @group multiple
112
145
  * @shortname intersection cross sections
113
146
  * @drawable true
147
+ * @example
148
+ * ```typescript
149
+ * const common = await bitbybit.manifold.crossSection.booleans.intersection({ crossSections: [square, disc] });
150
+ * ```
114
151
  */
115
152
  intersection(inputs) {
116
153
  const { CrossSection } = this.manifold;
@@ -1,54 +1,75 @@
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 cross-sections: area, emptiness, vertex and contour counts and the bounding
5
+ * rectangle. Nothing here changes the cross-section.
6
6
  */
7
7
  export declare class CrossSectionEvaluate {
8
8
  constructor(_wasm: Manifold3D.ManifoldToplevel);
9
9
  /**
10
- * Get area of cross section
11
- * @param inputs cross section
12
- * @returns area of cross section
10
+ * Measures the area of a cross-section, in square model units, holes excluded.
11
+ * @param inputs - The cross-section
12
+ * @returns The area
13
13
  * @group basic
14
14
  * @shortname area
15
15
  * @drawable false
16
+ * @example
17
+ * ```typescript
18
+ * const area = await bitbybit.manifold.crossSection.evaluate.area({ crossSection: outline });
19
+ * ```
16
20
  */
17
21
  area(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): number;
18
22
  /**
19
- * Check if cross section is empty
20
- * @param inputs cross section
21
- * @returns boolean indicating emptyness
23
+ * Tells whether a cross-section has no contours at all.
24
+ * @param inputs - The cross-section
25
+ * @returns True when the cross-section is empty
22
26
  * @group basic
23
27
  * @shortname is empty
24
28
  * @drawable false
29
+ * @example
30
+ * ```typescript
31
+ * const empty = await bitbybit.manifold.crossSection.evaluate.isEmpty({ crossSection: outline });
32
+ * ```
25
33
  */
26
34
  isEmpty(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): boolean;
27
35
  /**
28
- * Get number of vertices in cross section
29
- * @param inputs cross section
30
- * @returns number of vertices of cross section
36
+ * Counts the vertices of a cross-section over all its contours.
37
+ * @param inputs - The cross-section
38
+ * @returns The number of vertices
31
39
  * @group basic
32
40
  * @shortname num vert
33
41
  * @drawable false
42
+ * @example
43
+ * ```typescript
44
+ * const vertices = await bitbybit.manifold.crossSection.evaluate.numVert({ crossSection: outline });
45
+ * ```
34
46
  */
35
47
  numVert(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): number;
36
48
  /**
37
- * Get number of contours in cross section
38
- * @param inputs cross section
39
- * @returns number of contour of cross section
49
+ * Counts the contours of a cross-section: its outer outlines and its holes.
50
+ * @param inputs - The cross-section
51
+ * @returns The number of contours
40
52
  * @group basic
41
53
  * @shortname num contour
42
54
  * @drawable false
55
+ * @example
56
+ * ```typescript
57
+ * const contours = await bitbybit.manifold.crossSection.evaluate.numContour({ crossSection: plate });
58
+ * ```
43
59
  */
44
60
  numContour(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): number;
45
61
  /**
46
- * Get the bounds of the contour as a rectangle. Output is given in two vec2 points in the array. First array is the min point and second array is the max point.
47
- * @param inputs cross section
48
- * @returns bounds of cross section
62
+ * Finds the rectangle around a cross-section as two 2D points: the minimum corner, then the
63
+ * maximum corner.
64
+ * @param inputs - The cross-section
65
+ * @returns The minimum corner and the maximum corner
49
66
  * @group basic
50
67
  * @shortname bounds
51
68
  * @drawable false
69
+ * @example
70
+ * ```typescript
71
+ * const [min, max] = await bitbybit.manifold.crossSection.evaluate.bounds({ crossSection: outline });
72
+ * ```
52
73
  */
53
74
  bounds(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): Inputs.Base.Vector2[];
54
75
  }