@bitbybit-dev/manifold 1.3.2 → 1.4.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.
@@ -1,4 +1,5 @@
1
1
  import * as Inputs from "../../inputs/manifold-inputs";
2
+ import { resolveDto } from "@bitbybit-dev/base";
2
3
  /**
3
4
  * The grid a vertex is snapped onto before it is used as a de-duplication key.
4
5
  *
@@ -118,9 +119,9 @@ export class ManifoldShapes {
118
119
  * ```
119
120
  */
120
121
  cube(inputs) {
122
+ const resolved = resolveDto(Inputs.Manifold.CubeDto, inputs);
121
123
  const { Manifold } = this.manifold;
122
- const { cube } = Manifold;
123
- return cube(inputs.size, inputs.center);
124
+ return Manifold.cube(resolved.size, resolved.center);
124
125
  }
125
126
  /**
126
127
  * Creates a sphere solid of the given radius, centered on the origin.
@@ -138,9 +139,9 @@ export class ManifoldShapes {
138
139
  * ```
139
140
  */
140
141
  sphere(inputs) {
142
+ const resolved = resolveDto(Inputs.Manifold.SphereDto, inputs);
141
143
  const { Manifold } = this.manifold;
142
- const { sphere } = Manifold;
143
- return sphere(inputs.radius, inputs.circularSegments);
144
+ return Manifold.sphere(resolved.radius, resolved.circularSegments);
144
145
  }
145
146
  /**
146
147
  * Creates a tetrahedron solid centered on the origin, with one corner at `[1, 1, 1]` and the
@@ -156,8 +157,7 @@ export class ManifoldShapes {
156
157
  */
157
158
  tetrahedron() {
158
159
  const { Manifold } = this.manifold;
159
- const { tetrahedron } = Manifold;
160
- return tetrahedron();
160
+ return Manifold.tetrahedron();
161
161
  }
162
162
  /**
163
163
  * Creates a cylinder solid standing along Z, or a cone when the top radius differs from the
@@ -177,8 +177,8 @@ export class ManifoldShapes {
177
177
  * ```
178
178
  */
179
179
  cylinder(inputs) {
180
+ const resolved = resolveDto(Inputs.Manifold.CylinderDto, inputs);
180
181
  const { Manifold } = this.manifold;
181
- const { cylinder } = Manifold;
182
- return cylinder(inputs.height, inputs.radiusLow, inputs.radiusHigh, inputs.circularSegments, inputs.center);
182
+ return Manifold.cylinder(resolved.height, resolved.radiusLow, resolved.radiusHigh, resolved.circularSegments, resolved.center);
183
183
  }
184
184
  }
@@ -1,3 +1,5 @@
1
+ import * as Inputs from "../../inputs/manifold-inputs";
2
+ import { resolveDto } from "@bitbybit-dev/base";
1
3
  /**
2
4
  * Moving, turning, scaling, mirroring and warping Manifold solids. The kernel combines transforms
3
5
  * lazily, so chaining them is cheap; angles are in degrees, and rotations turn about the origin, X
@@ -19,7 +21,8 @@ export class ManifoldTransforms {
19
21
  * ```
20
22
  */
21
23
  scale3D(inputs) {
22
- return inputs.manifold.scale(inputs.vector);
24
+ const resolved = resolveDto(Inputs.Manifold.Scale3DDto, inputs);
25
+ return resolved.manifold.scale(resolved.vector);
23
26
  }
24
27
  /**
25
28
  * Scales a solid by a factor per axis, about the origin; it takes the same inputs as `scale3D`,
@@ -35,7 +38,8 @@ export class ManifoldTransforms {
35
38
  * ```
36
39
  */
37
40
  scale(inputs) {
38
- return inputs.manifold.scale(inputs.vector);
41
+ const resolved = resolveDto(Inputs.Manifold.Scale3DDto, inputs);
42
+ return resolved.manifold.scale(resolved.vector);
39
43
  }
40
44
  /**
41
45
  * Mirrors a solid across the plane through the origin with the given normal.
@@ -52,7 +56,8 @@ export class ManifoldTransforms {
52
56
  * ```
53
57
  */
54
58
  mirror(inputs) {
55
- return inputs.manifold.mirror(inputs.normal);
59
+ const resolved = resolveDto(Inputs.Manifold.MirrorDto, inputs);
60
+ return resolved.manifold.mirror(resolved.normal);
56
61
  }
57
62
  /**
58
63
  * Moves a solid by a vector, in model units.
@@ -99,7 +104,8 @@ export class ManifoldTransforms {
99
104
  * ```
100
105
  */
101
106
  translateXYZ(inputs) {
102
- return inputs.manifold.translate(inputs.x, inputs.y, inputs.z);
107
+ const resolved = resolveDto(Inputs.Manifold.TranslateXYZDto, inputs);
108
+ return resolved.manifold.translate(resolved.x, resolved.y, resolved.z);
103
109
  }
104
110
  /**
105
111
  * Rotates a solid about the origin by Euler angles in degrees: first about X, then Y, then Z.
@@ -133,7 +139,8 @@ export class ManifoldTransforms {
133
139
  * ```
134
140
  */
135
141
  rotateXYZ(inputs) {
136
- return inputs.manifold.rotate(inputs.x, inputs.y, inputs.z);
142
+ const resolved = resolveDto(Inputs.Manifold.RotateXYZDto, inputs);
143
+ return resolved.manifold.rotate(resolved.x, resolved.y, resolved.z);
137
144
  }
138
145
  /**
139
146
  * Applies a 4x4 matrix to a solid.
@@ -1,3 +1,5 @@
1
+ import * as Inputs from "../../inputs";
2
+ import { resolveDto } from "@bitbybit-dev/base";
1
3
  /**
2
4
  * Reading Manifold mesh data: the position and extra properties of a vertex, the vertices of a
3
5
  * triangle, the tangent of a half-edge, the transform of a triangle run, and the counts of
@@ -19,7 +21,8 @@ export class MeshEvaluate {
19
21
  * ```
20
22
  */
21
23
  position(inputs) {
22
- const res = inputs.mesh.position(inputs.vertexIndex);
24
+ const resolved = resolveDto(Inputs.Manifold.MeshVertexIndexDto, inputs);
25
+ const res = resolved.mesh.position(resolved.vertexIndex);
23
26
  return [res[0], res[1], res[2]];
24
27
  }
25
28
  /**
@@ -35,7 +38,8 @@ export class MeshEvaluate {
35
38
  * ```
36
39
  */
37
40
  verts(inputs) {
38
- const res = inputs.mesh.verts(inputs.triangleIndex);
41
+ const resolved = resolveDto(Inputs.Manifold.MeshTriangleIndexDto, inputs);
42
+ const res = resolved.mesh.verts(resolved.triangleIndex);
39
43
  return [res[0], res[1], res[2]];
40
44
  }
41
45
  /**
@@ -55,7 +59,8 @@ export class MeshEvaluate {
55
59
  * ```
56
60
  */
57
61
  tangent(inputs) {
58
- const res = inputs.mesh.tangent(inputs.halfEdgeIndex);
62
+ const resolved = resolveDto(Inputs.Manifold.MeshHalfEdgeIndexDto, inputs);
63
+ const res = resolved.mesh.tangent(resolved.halfEdgeIndex);
59
64
  return [res[0], res[1], res[2], res[3]];
60
65
  }
61
66
  /**
@@ -72,7 +77,8 @@ export class MeshEvaluate {
72
77
  * ```
73
78
  */
74
79
  extras(inputs) {
75
- const res = inputs.mesh.extras(inputs.vertexIndex);
80
+ const resolved = resolveDto(Inputs.Manifold.MeshVertexIndexDto, inputs);
81
+ const res = resolved.mesh.extras(resolved.vertexIndex);
76
82
  return [...res];
77
83
  }
78
84
  /**
@@ -89,7 +95,8 @@ export class MeshEvaluate {
89
95
  * ```
90
96
  */
91
97
  transform(inputs) {
92
- const res = inputs.mesh.transform(inputs.triangleRunIndex);
98
+ const resolved = resolveDto(Inputs.Manifold.MeshTriangleRunIndexDto, inputs);
99
+ const res = resolved.mesh.transform(resolved.triangleRunIndex);
93
100
  return [...res];
94
101
  }
95
102
  /**
@@ -107,7 +114,8 @@ export class MeshEvaluate {
107
114
  * ```
108
115
  */
109
116
  backside(inputs) {
110
- return inputs.mesh.backside(inputs.triangleRunIndex);
117
+ const resolved = resolveDto(Inputs.Manifold.MeshTriangleRunIndexDto, inputs);
118
+ return resolved.mesh.backside(resolved.triangleRunIndex);
111
119
  }
112
120
  /**
113
121
  * Tells whether the first three extra property channels of one run of triangles hold vertex
@@ -123,7 +131,8 @@ export class MeshEvaluate {
123
131
  * ```
124
132
  */
125
133
  hasNormals(inputs) {
126
- return inputs.mesh.hasNormals(inputs.triangleRunIndex);
134
+ const resolved = resolveDto(Inputs.Manifold.MeshTriangleRunIndexDto, inputs);
135
+ return resolved.mesh.hasNormals(resolved.triangleRunIndex);
127
136
  }
128
137
  /**
129
138
  * Counts the property channels each vertex of a mesh carries; the position alone takes three.
package/lib/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from "./api/inputs";
2
2
  export * from "./api/manifold-service";
3
+ export * from "./api/dto-registry";
4
+ export * as Resolved from "./api/resolved-inputs";
package/lib/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from "./api/inputs";
2
2
  export * from "./api/manifold-service";
3
+ export * from "./api/dto-registry";
4
+ export * as Resolved from "./api/resolved-inputs";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bitbybit-dev/manifold",
3
- "version": "1.3.2",
3
+ "version": "1.4.0",
4
4
  "description": "Bit By Bit Developers Manifold based CAD Library to Program Geometry",
5
5
  "homepage": "https://docs.bitbybit.dev/classes/Bit.Manifold",
6
6
  "main": "index.js",
@@ -55,6 +55,6 @@
55
55
  "type": "module",
56
56
  "dependencies": {
57
57
  "manifold-3d": "3.5.3",
58
- "@bitbybit-dev/base": "1.3.2"
58
+ "@bitbybit-dev/base": "1.4.0"
59
59
  }
60
60
  }