@bitbybit-dev/manifold 0.20.13 → 0.21.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 +146 -3
- package/lib/api/inputs/manifold-inputs.js +176 -2
- package/lib/api/manifold-service.d.ts +1 -0
- package/lib/api/manifold-service.js +3 -1
- package/lib/api/services/cross-section/cross-section-operations.js +3 -1
- package/lib/api/services/cross-section/cross-section-transforms.d.ts +1 -0
- package/lib/api/services/cross-section/cross-section-transforms.js +3 -0
- package/lib/api/services/cross-section/cross-section.d.ts +8 -2
- package/lib/api/services/cross-section/cross-section.js +41 -1
- package/lib/api/services/manifold/manifold-evaluate.d.ts +1 -0
- package/lib/api/services/manifold/manifold-evaluate.js +3 -0
- package/lib/api/services/manifold/manifold-operations.d.ts +2 -0
- package/lib/api/services/manifold/manifold-operations.js +6 -0
- package/lib/api/services/manifold/manifold-transforms.d.ts +1 -0
- package/lib/api/services/manifold/manifold-transforms.js +3 -0
- package/lib/base.d.ts +15 -0
- package/lib/base.js +16 -0
- package/package.json +3 -2
|
@@ -21,7 +21,8 @@ export declare namespace Manifold {
|
|
|
21
21
|
enum manifoldJoinTypeEnum {
|
|
22
22
|
square = "Square",
|
|
23
23
|
round = "Round",
|
|
24
|
-
miter = "Miter"
|
|
24
|
+
miter = "Miter",
|
|
25
|
+
bevel = "Bevel"
|
|
25
26
|
}
|
|
26
27
|
class DecomposedManifoldMeshDto {
|
|
27
28
|
numProp: number;
|
|
@@ -39,7 +40,7 @@ export declare namespace Manifold {
|
|
|
39
40
|
/**
|
|
40
41
|
* Provide options without default values
|
|
41
42
|
*/
|
|
42
|
-
constructor(manifoldOrCrossSection?: T, faceOpacity?: number, faceMaterial?: M, faceColour?: Base.Color, crossSectionColour?: Base.Color, crossSectionWidth?: number, crossSectionOpacity?: number, computeNormals?: boolean);
|
|
43
|
+
constructor(manifoldOrCrossSection?: T, faceOpacity?: number, faceMaterial?: M, faceColour?: Base.Color, crossSectionColour?: Base.Color, crossSectionWidth?: number, crossSectionOpacity?: number, computeNormals?: boolean, drawTwoSided?: boolean, backFaceColour?: Base.Color, backFaceOpacity?: number);
|
|
43
44
|
/**
|
|
44
45
|
* Manifold geometry
|
|
45
46
|
* @default undefined
|
|
@@ -87,12 +88,30 @@ export declare namespace Manifold {
|
|
|
87
88
|
* @default false
|
|
88
89
|
*/
|
|
89
90
|
computeNormals: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Draw two-sided faces with different colors for front and back. This helps visualize face orientation.
|
|
93
|
+
* @default true
|
|
94
|
+
*/
|
|
95
|
+
drawTwoSided: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Hex colour string for back face colour (negative side of the face). Only used when drawTwoSided is true.
|
|
98
|
+
* @default #0000ff
|
|
99
|
+
*/
|
|
100
|
+
backFaceColour: Base.Color;
|
|
101
|
+
/**
|
|
102
|
+
* Back face opacity value between 0 and 1. Only used when drawTwoSided is true.
|
|
103
|
+
* @default 1
|
|
104
|
+
* @minimum 0
|
|
105
|
+
* @maximum 1
|
|
106
|
+
* @step 0.1
|
|
107
|
+
*/
|
|
108
|
+
backFaceOpacity: number;
|
|
90
109
|
}
|
|
91
110
|
class DrawManifoldsOrCrossSectionsDto<T, M> {
|
|
92
111
|
/**
|
|
93
112
|
* Provide options without default values
|
|
94
113
|
*/
|
|
95
|
-
constructor(manifoldsOrCrossSections?: T[], faceOpacity?: number, faceMaterial?: M, faceColour?: Base.Color, crossSectionColour?: Base.Color, crossSectionWidth?: number, crossSectionOpacity?: number, computeNormals?: boolean);
|
|
114
|
+
constructor(manifoldsOrCrossSections?: T[], faceOpacity?: number, faceMaterial?: M, faceColour?: Base.Color, crossSectionColour?: Base.Color, crossSectionWidth?: number, crossSectionOpacity?: number, computeNormals?: boolean, drawTwoSided?: boolean, backFaceColour?: Base.Color, backFaceOpacity?: number);
|
|
96
115
|
/**
|
|
97
116
|
* Manifold geometry
|
|
98
117
|
* @default undefined
|
|
@@ -140,6 +159,24 @@ export declare namespace Manifold {
|
|
|
140
159
|
* @default false
|
|
141
160
|
*/
|
|
142
161
|
computeNormals: boolean;
|
|
162
|
+
/**
|
|
163
|
+
* Draw two-sided faces with different colors for front and back. This helps visualize face orientation.
|
|
164
|
+
* @default true
|
|
165
|
+
*/
|
|
166
|
+
drawTwoSided: boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Hex colour string for back face colour (negative side of the face). Only used when drawTwoSided is true.
|
|
169
|
+
* @default #0000ff
|
|
170
|
+
*/
|
|
171
|
+
backFaceColour: Base.Color;
|
|
172
|
+
/**
|
|
173
|
+
* Back face opacity value between 0 and 1. Only used when drawTwoSided is true.
|
|
174
|
+
* @default 1
|
|
175
|
+
* @minimum 0
|
|
176
|
+
* @maximum 1
|
|
177
|
+
* @step 0.1
|
|
178
|
+
*/
|
|
179
|
+
backFaceOpacity: number;
|
|
143
180
|
}
|
|
144
181
|
class CreateFromMeshDto {
|
|
145
182
|
constructor(mesh?: DecomposedManifoldMeshDto);
|
|
@@ -155,6 +192,50 @@ export declare namespace Manifold {
|
|
|
155
192
|
*/
|
|
156
193
|
polygonPoints?: Base.Point3[][];
|
|
157
194
|
}
|
|
195
|
+
class CrossSectionFromPolygonPointsDto {
|
|
196
|
+
constructor(points?: Base.Point3[], fillRule?: fillRuleEnum, removeDuplicates?: boolean, tolerance?: number);
|
|
197
|
+
/**
|
|
198
|
+
* Points describing a single polygon
|
|
199
|
+
*/
|
|
200
|
+
points: Base.Point3[];
|
|
201
|
+
/**
|
|
202
|
+
* Fill rule for polygon interpretation
|
|
203
|
+
* @default positive
|
|
204
|
+
*/
|
|
205
|
+
fillRule?: fillRuleEnum;
|
|
206
|
+
/**
|
|
207
|
+
* Remove consecutive duplicate points before creating polygon
|
|
208
|
+
* @default false
|
|
209
|
+
*/
|
|
210
|
+
removeDuplicates?: boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Tolerance for duplicate removal
|
|
213
|
+
* @default 1e-7
|
|
214
|
+
*/
|
|
215
|
+
tolerance?: number;
|
|
216
|
+
}
|
|
217
|
+
class CrossSectionFromPolygonsPointsDto {
|
|
218
|
+
constructor(polygonPoints?: Base.Point3[][], fillRule?: fillRuleEnum, removeDuplicates?: boolean, tolerance?: number);
|
|
219
|
+
/**
|
|
220
|
+
* Points describing multiple polygons
|
|
221
|
+
*/
|
|
222
|
+
polygonPoints: Base.Point3[][];
|
|
223
|
+
/**
|
|
224
|
+
* Fill rule for polygon interpretation
|
|
225
|
+
* @default positive
|
|
226
|
+
*/
|
|
227
|
+
fillRule?: fillRuleEnum;
|
|
228
|
+
/**
|
|
229
|
+
* Remove consecutive duplicate points before creating polygons
|
|
230
|
+
* @default false
|
|
231
|
+
*/
|
|
232
|
+
removeDuplicates?: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Tolerance for duplicate removal
|
|
235
|
+
* @default 1e-7
|
|
236
|
+
*/
|
|
237
|
+
tolerance?: number;
|
|
238
|
+
}
|
|
158
239
|
class CubeDto {
|
|
159
240
|
constructor(center?: boolean, size?: number);
|
|
160
241
|
/**
|
|
@@ -459,6 +540,44 @@ export declare namespace Manifold {
|
|
|
459
540
|
*/
|
|
460
541
|
normalIdx: number;
|
|
461
542
|
}
|
|
543
|
+
class ManifoldSimplifyDto<T> {
|
|
544
|
+
constructor(manifold?: T, tolerance?: number);
|
|
545
|
+
/**
|
|
546
|
+
* Manifold shape
|
|
547
|
+
*/
|
|
548
|
+
manifold: T;
|
|
549
|
+
/**
|
|
550
|
+
* The maximum distance between the original and simplified meshes.
|
|
551
|
+
* If not given or is less than the current tolerance, the current tolerance is used.
|
|
552
|
+
* The result will contain a subset of the original verts and all surfaces will have moved by less than tolerance.
|
|
553
|
+
* @default undefined
|
|
554
|
+
* @minimum 0
|
|
555
|
+
* @maximum Infinity
|
|
556
|
+
* @step 0.001
|
|
557
|
+
*/
|
|
558
|
+
tolerance?: number;
|
|
559
|
+
}
|
|
560
|
+
class ManifoldSetPropertiesDto<T> {
|
|
561
|
+
constructor(manifold?: T, numProp?: number, propFunc?: (newProp: number[], position: Base.Vector3, oldProp: number[]) => void);
|
|
562
|
+
/**
|
|
563
|
+
* Manifold shape
|
|
564
|
+
*/
|
|
565
|
+
manifold: T;
|
|
566
|
+
/**
|
|
567
|
+
* The new number of properties per vertex
|
|
568
|
+
* @default 3
|
|
569
|
+
* @minimum 3
|
|
570
|
+
* @maximum Infinity
|
|
571
|
+
* @step 1
|
|
572
|
+
*/
|
|
573
|
+
numProp: number;
|
|
574
|
+
/**
|
|
575
|
+
* A function that modifies the properties of a given vertex.
|
|
576
|
+
* Note: undefined behavior will result if you read past the number of input properties or write past the number of output properties.
|
|
577
|
+
* @default undefined
|
|
578
|
+
*/
|
|
579
|
+
propFunc: (newProp: number[], position: Base.Vector3, oldProp: number[]) => void;
|
|
580
|
+
}
|
|
462
581
|
class ManifoldSmoothOutDto<T> {
|
|
463
582
|
constructor(manifold?: T, minSharpAngle?: number, minSmoothness?: number);
|
|
464
583
|
/**
|
|
@@ -839,6 +958,18 @@ export declare namespace Manifold {
|
|
|
839
958
|
*/
|
|
840
959
|
transform: Base.TransformMatrix3x3;
|
|
841
960
|
}
|
|
961
|
+
class CrossSectionWarpDto<T> {
|
|
962
|
+
constructor(crossSection?: T, warpFunc?: (vert: Base.Vector2) => void);
|
|
963
|
+
/**
|
|
964
|
+
* Cross section
|
|
965
|
+
*/
|
|
966
|
+
crossSection: T;
|
|
967
|
+
/**
|
|
968
|
+
* A function that modifies a given vertex position
|
|
969
|
+
* @default undefined
|
|
970
|
+
*/
|
|
971
|
+
warpFunc: (vert: Base.Vector2) => void;
|
|
972
|
+
}
|
|
842
973
|
class MirrorDto<T> {
|
|
843
974
|
constructor(manifold?: T, normal?: Base.Vector3);
|
|
844
975
|
/**
|
|
@@ -997,6 +1128,18 @@ export declare namespace Manifold {
|
|
|
997
1128
|
*/
|
|
998
1129
|
transforms: Base.TransformMatrixes;
|
|
999
1130
|
}
|
|
1131
|
+
class ManifoldWarpDto<T> {
|
|
1132
|
+
constructor(manifold?: T, warpFunc?: (vert: Base.Vector3) => void);
|
|
1133
|
+
/**
|
|
1134
|
+
* Manifold shape
|
|
1135
|
+
*/
|
|
1136
|
+
manifold: T;
|
|
1137
|
+
/**
|
|
1138
|
+
* A function that modifies a given vertex position
|
|
1139
|
+
* @default undefined
|
|
1140
|
+
*/
|
|
1141
|
+
warpFunc: (vert: Base.Vector3) => void;
|
|
1142
|
+
}
|
|
1000
1143
|
class TwoCrossSectionsDto<T> {
|
|
1001
1144
|
constructor(crossSection1?: T, crossSection2?: T);
|
|
1002
1145
|
/**
|
|
@@ -13,6 +13,7 @@ export var Manifold;
|
|
|
13
13
|
manifoldJoinTypeEnum["square"] = "Square";
|
|
14
14
|
manifoldJoinTypeEnum["round"] = "Round";
|
|
15
15
|
manifoldJoinTypeEnum["miter"] = "Miter";
|
|
16
|
+
manifoldJoinTypeEnum["bevel"] = "Bevel";
|
|
16
17
|
})(manifoldJoinTypeEnum = Manifold.manifoldJoinTypeEnum || (Manifold.manifoldJoinTypeEnum = {}));
|
|
17
18
|
class DecomposedManifoldMeshDto {
|
|
18
19
|
}
|
|
@@ -21,7 +22,7 @@ export var Manifold;
|
|
|
21
22
|
/**
|
|
22
23
|
* Provide options without default values
|
|
23
24
|
*/
|
|
24
|
-
constructor(manifoldOrCrossSection, faceOpacity, faceMaterial, faceColour, crossSectionColour, crossSectionWidth, crossSectionOpacity, computeNormals) {
|
|
25
|
+
constructor(manifoldOrCrossSection, faceOpacity, faceMaterial, faceColour, crossSectionColour, crossSectionWidth, crossSectionOpacity, computeNormals, drawTwoSided, backFaceColour, backFaceOpacity) {
|
|
25
26
|
/**
|
|
26
27
|
* Face opacity value between 0 and 1
|
|
27
28
|
* @default 1
|
|
@@ -58,6 +59,24 @@ export var Manifold;
|
|
|
58
59
|
* @default false
|
|
59
60
|
*/
|
|
60
61
|
this.computeNormals = false;
|
|
62
|
+
/**
|
|
63
|
+
* Draw two-sided faces with different colors for front and back. This helps visualize face orientation.
|
|
64
|
+
* @default true
|
|
65
|
+
*/
|
|
66
|
+
this.drawTwoSided = true;
|
|
67
|
+
/**
|
|
68
|
+
* Hex colour string for back face colour (negative side of the face). Only used when drawTwoSided is true.
|
|
69
|
+
* @default #0000ff
|
|
70
|
+
*/
|
|
71
|
+
this.backFaceColour = "#0000ff";
|
|
72
|
+
/**
|
|
73
|
+
* Back face opacity value between 0 and 1. Only used when drawTwoSided is true.
|
|
74
|
+
* @default 1
|
|
75
|
+
* @minimum 0
|
|
76
|
+
* @maximum 1
|
|
77
|
+
* @step 0.1
|
|
78
|
+
*/
|
|
79
|
+
this.backFaceOpacity = 1;
|
|
61
80
|
if (manifoldOrCrossSection !== undefined) {
|
|
62
81
|
this.manifoldOrCrossSection = manifoldOrCrossSection;
|
|
63
82
|
}
|
|
@@ -82,6 +101,15 @@ export var Manifold;
|
|
|
82
101
|
if (computeNormals !== undefined) {
|
|
83
102
|
this.computeNormals = computeNormals;
|
|
84
103
|
}
|
|
104
|
+
if (drawTwoSided !== undefined) {
|
|
105
|
+
this.drawTwoSided = drawTwoSided;
|
|
106
|
+
}
|
|
107
|
+
if (backFaceColour !== undefined) {
|
|
108
|
+
this.backFaceColour = backFaceColour;
|
|
109
|
+
}
|
|
110
|
+
if (backFaceOpacity !== undefined) {
|
|
111
|
+
this.backFaceOpacity = backFaceOpacity;
|
|
112
|
+
}
|
|
85
113
|
}
|
|
86
114
|
}
|
|
87
115
|
Manifold.DrawManifoldOrCrossSectionDto = DrawManifoldOrCrossSectionDto;
|
|
@@ -89,7 +117,7 @@ export var Manifold;
|
|
|
89
117
|
/**
|
|
90
118
|
* Provide options without default values
|
|
91
119
|
*/
|
|
92
|
-
constructor(manifoldsOrCrossSections, faceOpacity, faceMaterial, faceColour, crossSectionColour, crossSectionWidth, crossSectionOpacity, computeNormals) {
|
|
120
|
+
constructor(manifoldsOrCrossSections, faceOpacity, faceMaterial, faceColour, crossSectionColour, crossSectionWidth, crossSectionOpacity, computeNormals, drawTwoSided, backFaceColour, backFaceOpacity) {
|
|
93
121
|
/**
|
|
94
122
|
* Hex colour string for face colour
|
|
95
123
|
* @default #ff0000
|
|
@@ -126,6 +154,24 @@ export var Manifold;
|
|
|
126
154
|
* @default false
|
|
127
155
|
*/
|
|
128
156
|
this.computeNormals = false;
|
|
157
|
+
/**
|
|
158
|
+
* Draw two-sided faces with different colors for front and back. This helps visualize face orientation.
|
|
159
|
+
* @default true
|
|
160
|
+
*/
|
|
161
|
+
this.drawTwoSided = true;
|
|
162
|
+
/**
|
|
163
|
+
* Hex colour string for back face colour (negative side of the face). Only used when drawTwoSided is true.
|
|
164
|
+
* @default #0000ff
|
|
165
|
+
*/
|
|
166
|
+
this.backFaceColour = "#0000ff";
|
|
167
|
+
/**
|
|
168
|
+
* Back face opacity value between 0 and 1. Only used when drawTwoSided is true.
|
|
169
|
+
* @default 1
|
|
170
|
+
* @minimum 0
|
|
171
|
+
* @maximum 1
|
|
172
|
+
* @step 0.1
|
|
173
|
+
*/
|
|
174
|
+
this.backFaceOpacity = 1;
|
|
129
175
|
if (manifoldsOrCrossSections !== undefined) {
|
|
130
176
|
this.manifoldsOrCrossSections = manifoldsOrCrossSections;
|
|
131
177
|
}
|
|
@@ -150,6 +196,15 @@ export var Manifold;
|
|
|
150
196
|
if (computeNormals !== undefined) {
|
|
151
197
|
this.computeNormals = computeNormals;
|
|
152
198
|
}
|
|
199
|
+
if (drawTwoSided !== undefined) {
|
|
200
|
+
this.drawTwoSided = drawTwoSided;
|
|
201
|
+
}
|
|
202
|
+
if (backFaceColour !== undefined) {
|
|
203
|
+
this.backFaceColour = backFaceColour;
|
|
204
|
+
}
|
|
205
|
+
if (backFaceOpacity !== undefined) {
|
|
206
|
+
this.backFaceOpacity = backFaceOpacity;
|
|
207
|
+
}
|
|
153
208
|
}
|
|
154
209
|
}
|
|
155
210
|
Manifold.DrawManifoldsOrCrossSectionsDto = DrawManifoldsOrCrossSectionsDto;
|
|
@@ -169,6 +224,70 @@ export var Manifold;
|
|
|
169
224
|
}
|
|
170
225
|
}
|
|
171
226
|
Manifold.FromPolygonPointsDto = FromPolygonPointsDto;
|
|
227
|
+
class CrossSectionFromPolygonPointsDto {
|
|
228
|
+
constructor(points, fillRule, removeDuplicates, tolerance) {
|
|
229
|
+
/**
|
|
230
|
+
* Fill rule for polygon interpretation
|
|
231
|
+
* @default positive
|
|
232
|
+
*/
|
|
233
|
+
this.fillRule = fillRuleEnum.positive;
|
|
234
|
+
/**
|
|
235
|
+
* Remove consecutive duplicate points before creating polygon
|
|
236
|
+
* @default false
|
|
237
|
+
*/
|
|
238
|
+
this.removeDuplicates = false;
|
|
239
|
+
/**
|
|
240
|
+
* Tolerance for duplicate removal
|
|
241
|
+
* @default 1e-7
|
|
242
|
+
*/
|
|
243
|
+
this.tolerance = 1e-7;
|
|
244
|
+
if (points !== undefined) {
|
|
245
|
+
this.points = points;
|
|
246
|
+
}
|
|
247
|
+
if (fillRule !== undefined) {
|
|
248
|
+
this.fillRule = fillRule;
|
|
249
|
+
}
|
|
250
|
+
if (removeDuplicates !== undefined) {
|
|
251
|
+
this.removeDuplicates = removeDuplicates;
|
|
252
|
+
}
|
|
253
|
+
if (tolerance !== undefined) {
|
|
254
|
+
this.tolerance = tolerance;
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
Manifold.CrossSectionFromPolygonPointsDto = CrossSectionFromPolygonPointsDto;
|
|
259
|
+
class CrossSectionFromPolygonsPointsDto {
|
|
260
|
+
constructor(polygonPoints, fillRule, removeDuplicates, tolerance) {
|
|
261
|
+
/**
|
|
262
|
+
* Fill rule for polygon interpretation
|
|
263
|
+
* @default positive
|
|
264
|
+
*/
|
|
265
|
+
this.fillRule = fillRuleEnum.positive;
|
|
266
|
+
/**
|
|
267
|
+
* Remove consecutive duplicate points before creating polygons
|
|
268
|
+
* @default false
|
|
269
|
+
*/
|
|
270
|
+
this.removeDuplicates = false;
|
|
271
|
+
/**
|
|
272
|
+
* Tolerance for duplicate removal
|
|
273
|
+
* @default 1e-7
|
|
274
|
+
*/
|
|
275
|
+
this.tolerance = 1e-7;
|
|
276
|
+
if (polygonPoints !== undefined) {
|
|
277
|
+
this.polygonPoints = polygonPoints;
|
|
278
|
+
}
|
|
279
|
+
if (fillRule !== undefined) {
|
|
280
|
+
this.fillRule = fillRule;
|
|
281
|
+
}
|
|
282
|
+
if (removeDuplicates !== undefined) {
|
|
283
|
+
this.removeDuplicates = removeDuplicates;
|
|
284
|
+
}
|
|
285
|
+
if (tolerance !== undefined) {
|
|
286
|
+
this.tolerance = tolerance;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
Manifold.CrossSectionFromPolygonsPointsDto = CrossSectionFromPolygonsPointsDto;
|
|
172
291
|
class CubeDto {
|
|
173
292
|
constructor(center, size) {
|
|
174
293
|
/**
|
|
@@ -535,6 +654,39 @@ export var Manifold;
|
|
|
535
654
|
}
|
|
536
655
|
}
|
|
537
656
|
Manifold.ManifoldSmoothByNormalsDto = ManifoldSmoothByNormalsDto;
|
|
657
|
+
class ManifoldSimplifyDto {
|
|
658
|
+
constructor(manifold, tolerance) {
|
|
659
|
+
if (manifold !== undefined) {
|
|
660
|
+
this.manifold = manifold;
|
|
661
|
+
}
|
|
662
|
+
if (tolerance !== undefined) {
|
|
663
|
+
this.tolerance = tolerance;
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
Manifold.ManifoldSimplifyDto = ManifoldSimplifyDto;
|
|
668
|
+
class ManifoldSetPropertiesDto {
|
|
669
|
+
constructor(manifold, numProp, propFunc) {
|
|
670
|
+
/**
|
|
671
|
+
* The new number of properties per vertex
|
|
672
|
+
* @default 3
|
|
673
|
+
* @minimum 3
|
|
674
|
+
* @maximum Infinity
|
|
675
|
+
* @step 1
|
|
676
|
+
*/
|
|
677
|
+
this.numProp = 3;
|
|
678
|
+
if (manifold !== undefined) {
|
|
679
|
+
this.manifold = manifold;
|
|
680
|
+
}
|
|
681
|
+
if (numProp !== undefined) {
|
|
682
|
+
this.numProp = numProp;
|
|
683
|
+
}
|
|
684
|
+
if (propFunc !== undefined) {
|
|
685
|
+
this.propFunc = propFunc;
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
Manifold.ManifoldSetPropertiesDto = ManifoldSetPropertiesDto;
|
|
538
690
|
class ManifoldSmoothOutDto {
|
|
539
691
|
constructor(manifold, minSharpAngle, minSmoothness) {
|
|
540
692
|
/**
|
|
@@ -935,6 +1087,17 @@ export var Manifold;
|
|
|
935
1087
|
}
|
|
936
1088
|
}
|
|
937
1089
|
Manifold.TransformCrossSectionDto = TransformCrossSectionDto;
|
|
1090
|
+
class CrossSectionWarpDto {
|
|
1091
|
+
constructor(crossSection, warpFunc) {
|
|
1092
|
+
if (crossSection !== undefined) {
|
|
1093
|
+
this.crossSection = crossSection;
|
|
1094
|
+
}
|
|
1095
|
+
if (warpFunc !== undefined) {
|
|
1096
|
+
this.warpFunc = warpFunc;
|
|
1097
|
+
}
|
|
1098
|
+
}
|
|
1099
|
+
}
|
|
1100
|
+
Manifold.CrossSectionWarpDto = CrossSectionWarpDto;
|
|
938
1101
|
class MirrorDto {
|
|
939
1102
|
constructor(manifold, normal) {
|
|
940
1103
|
/**
|
|
@@ -1120,6 +1283,17 @@ export var Manifold;
|
|
|
1120
1283
|
}
|
|
1121
1284
|
}
|
|
1122
1285
|
Manifold.TransformsDto = TransformsDto;
|
|
1286
|
+
class ManifoldWarpDto {
|
|
1287
|
+
constructor(manifold, warpFunc) {
|
|
1288
|
+
if (manifold !== undefined) {
|
|
1289
|
+
this.manifold = manifold;
|
|
1290
|
+
}
|
|
1291
|
+
if (warpFunc !== undefined) {
|
|
1292
|
+
this.warpFunc = warpFunc;
|
|
1293
|
+
}
|
|
1294
|
+
}
|
|
1295
|
+
}
|
|
1296
|
+
Manifold.ManifoldWarpDto = ManifoldWarpDto;
|
|
1123
1297
|
class TwoCrossSectionsDto {
|
|
1124
1298
|
constructor(crossSection1, crossSection2) {
|
|
1125
1299
|
if (crossSection1 !== undefined) {
|
|
@@ -7,6 +7,7 @@ export declare class ManifoldService {
|
|
|
7
7
|
plugins: any;
|
|
8
8
|
crossSection: CrossSection;
|
|
9
9
|
manifold: Manifold;
|
|
10
|
+
private base;
|
|
10
11
|
mesh: Mesh;
|
|
11
12
|
constructor(wasm: Manifold3D.ManifoldToplevel);
|
|
12
13
|
toPolygonPoints(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): Inputs.Base.Mesh3;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Manifold } from "./services/manifold/manifold";
|
|
2
2
|
import { CrossSection } from "./services/cross-section/cross-section";
|
|
3
3
|
import { Mesh } from "./services/mesh/mesh";
|
|
4
|
+
import { BaseBitByBit } from "../base";
|
|
4
5
|
// Worker make an instance of this class itself
|
|
5
6
|
export class ManifoldService {
|
|
6
7
|
constructor(wasm) {
|
|
7
|
-
this.
|
|
8
|
+
this.base = new BaseBitByBit();
|
|
9
|
+
this.crossSection = new CrossSection(wasm, this.base);
|
|
8
10
|
this.manifold = new Manifold(wasm);
|
|
9
11
|
this.mesh = new Mesh(wasm);
|
|
10
12
|
}
|
|
@@ -11,7 +11,9 @@ export class CrossSectionOperations {
|
|
|
11
11
|
revolve(inputs) {
|
|
12
12
|
const res = inputs.crossSection.revolve(inputs.circularSegments, inputs.revolveDegrees);
|
|
13
13
|
if (inputs.matchProfile) {
|
|
14
|
-
|
|
14
|
+
// Manifold revolves around Y-axis then sets it as Z-axis
|
|
15
|
+
// We need to rotate -90 degrees around X to make Y point up correctly
|
|
16
|
+
return res.rotate([-90, 0, 0]);
|
|
15
17
|
}
|
|
16
18
|
else {
|
|
17
19
|
return res;
|
|
@@ -10,4 +10,5 @@ export declare class CrossSectionTransforms {
|
|
|
10
10
|
translateXY(inputs: Inputs.Manifold.TranslateXYCrossSectionDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
|
|
11
11
|
rotate(inputs: Inputs.Manifold.RotateCrossSectionDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
|
|
12
12
|
transform(inputs: Inputs.Manifold.TransformCrossSectionDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
|
|
13
|
+
warp(inputs: Inputs.Manifold.CrossSectionWarpDto<Manifold3D.CrossSection>): Manifold3D.CrossSection;
|
|
13
14
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import * as Inputs from "../../inputs/
|
|
1
|
+
import * as Inputs from "../../inputs/inputs";
|
|
2
2
|
import * as Manifold3D from "manifold-3d";
|
|
3
3
|
import { CrossSectionShapes } from "./cross-section-shapes";
|
|
4
4
|
import { CrossSectionOperations } from "./cross-section-operations";
|
|
5
5
|
import { CrossSectionTransforms } from "./cross-section-transforms";
|
|
6
6
|
import { CrossSectionBooleans } from "./cross-section-booleans";
|
|
7
7
|
import { CrossSectionEvaluate } from "./cross-section-evaluate";
|
|
8
|
+
import { BaseBitByBit } from "../../../base";
|
|
8
9
|
export declare class CrossSection {
|
|
9
10
|
shapes: CrossSectionShapes;
|
|
10
11
|
operations: CrossSectionOperations;
|
|
@@ -12,9 +13,14 @@ export declare class CrossSection {
|
|
|
12
13
|
booleans: CrossSectionBooleans;
|
|
13
14
|
evaluate: CrossSectionEvaluate;
|
|
14
15
|
private manifold;
|
|
15
|
-
|
|
16
|
+
private base;
|
|
17
|
+
constructor(wasm: Manifold3D.ManifoldToplevel, base: BaseBitByBit);
|
|
18
|
+
crossSectionFromPoints(inputs: Inputs.Manifold.CrossSectionFromPolygonPointsDto): Manifold3D.CrossSection;
|
|
19
|
+
crossSectionFromPolygons(inputs: Inputs.Manifold.CrossSectionFromPolygonsPointsDto): Manifold3D.CrossSection;
|
|
16
20
|
crossSectionToPolygons(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): Manifold3D.SimplePolygon[];
|
|
21
|
+
crossSectionToPoints(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): Inputs.Base.Point3[][];
|
|
17
22
|
crossSectionsToPolygons(inputs: Inputs.Manifold.CrossSectionsDto<Manifold3D.CrossSection>): Manifold3D.SimplePolygon[][];
|
|
23
|
+
crossSectionsToPoints(inputs: Inputs.Manifold.CrossSectionsDto<Manifold3D.CrossSection>): number[][][][];
|
|
18
24
|
deleteCrossSection(inputs: Inputs.Manifold.CrossSectionDto<Manifold3D.CrossSection>): void;
|
|
19
25
|
deleteCrossSections(inputs: Inputs.Manifold.CrossSectionsDto<Manifold3D.CrossSection>): void;
|
|
20
26
|
}
|
|
@@ -4,17 +4,50 @@ import { CrossSectionTransforms } from "./cross-section-transforms";
|
|
|
4
4
|
import { CrossSectionBooleans } from "./cross-section-booleans";
|
|
5
5
|
import { CrossSectionEvaluate } from "./cross-section-evaluate";
|
|
6
6
|
export class CrossSection {
|
|
7
|
-
constructor(wasm) {
|
|
7
|
+
constructor(wasm, base) {
|
|
8
8
|
this.manifold = wasm;
|
|
9
|
+
this.base = base;
|
|
9
10
|
this.shapes = new CrossSectionShapes(wasm);
|
|
10
11
|
this.operations = new CrossSectionOperations(wasm);
|
|
11
12
|
this.transforms = new CrossSectionTransforms(wasm);
|
|
12
13
|
this.booleans = new CrossSectionBooleans(wasm);
|
|
13
14
|
this.evaluate = new CrossSectionEvaluate(wasm);
|
|
14
15
|
}
|
|
16
|
+
crossSectionFromPoints(inputs) {
|
|
17
|
+
let points = inputs.points;
|
|
18
|
+
// Remove consecutive duplicates if requested
|
|
19
|
+
if (inputs.removeDuplicates) {
|
|
20
|
+
points = this.base.point.removeConsecutiveDuplicates({
|
|
21
|
+
points,
|
|
22
|
+
checkFirstAndLast: true,
|
|
23
|
+
tolerance: inputs.tolerance || 1e-7
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
// Convert Base.Point3[] to SimplePolygon (array of 2D points [x, y])
|
|
27
|
+
const polygon = points.map(p => [p[0], p[1]]);
|
|
28
|
+
return this.manifold.CrossSection.ofPolygons([polygon], inputs.fillRule);
|
|
29
|
+
}
|
|
30
|
+
crossSectionFromPolygons(inputs) {
|
|
31
|
+
let polygonPoints = inputs.polygonPoints;
|
|
32
|
+
// Remove consecutive duplicates from each polygon if requested
|
|
33
|
+
if (inputs.removeDuplicates) {
|
|
34
|
+
polygonPoints = polygonPoints.map(polygon => this.base.point.removeConsecutiveDuplicates({
|
|
35
|
+
points: polygon,
|
|
36
|
+
checkFirstAndLast: true,
|
|
37
|
+
tolerance: inputs.tolerance || 1e-7
|
|
38
|
+
}));
|
|
39
|
+
}
|
|
40
|
+
// Convert Base.Point3[][] to SimplePolygon[] (array of 2D points [x, y])
|
|
41
|
+
const polygons = polygonPoints.map(polygon => polygon.map(p => [p[0], p[1]]));
|
|
42
|
+
return this.manifold.CrossSection.ofPolygons(polygons, inputs.fillRule);
|
|
43
|
+
}
|
|
15
44
|
crossSectionToPolygons(inputs) {
|
|
16
45
|
return inputs.crossSection.toPolygons();
|
|
17
46
|
}
|
|
47
|
+
crossSectionToPoints(inputs) {
|
|
48
|
+
const polygons = inputs.crossSection.toPolygons();
|
|
49
|
+
return polygons.map(polygon => polygon.map(point => [point[0], point[1], 0]));
|
|
50
|
+
}
|
|
18
51
|
crossSectionsToPolygons(inputs) {
|
|
19
52
|
return inputs.crossSections.map((crossSection) => {
|
|
20
53
|
return this.crossSectionToPolygons({
|
|
@@ -22,6 +55,13 @@ export class CrossSection {
|
|
|
22
55
|
});
|
|
23
56
|
});
|
|
24
57
|
}
|
|
58
|
+
crossSectionsToPoints(inputs) {
|
|
59
|
+
return inputs.crossSections.map((crossSection) => {
|
|
60
|
+
return this.crossSectionToPoints({
|
|
61
|
+
crossSection
|
|
62
|
+
});
|
|
63
|
+
});
|
|
64
|
+
}
|
|
25
65
|
deleteCrossSection(inputs) {
|
|
26
66
|
inputs.crossSection.delete();
|
|
27
67
|
}
|
|
@@ -16,4 +16,5 @@ export declare class ManifoldEvaluate {
|
|
|
16
16
|
genus(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
|
|
17
17
|
minGap(inputs: Inputs.Manifold.ManifoldsMinGapDto<Manifold3D.Manifold>): number;
|
|
18
18
|
originalID(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): number;
|
|
19
|
+
status(inputs: Inputs.Manifold.ManifoldDto<Manifold3D.Manifold>): string;
|
|
19
20
|
}
|
|
@@ -19,4 +19,6 @@ export declare class ManifoldOperations {
|
|
|
19
19
|
refine(inputs: Inputs.Manifold.ManifoldRefineDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
20
20
|
smoothOut(inputs: Inputs.Manifold.ManifoldSmoothOutDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
21
21
|
smoothByNormals(inputs: Inputs.Manifold.ManifoldSmoothByNormalsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
22
|
+
simplify(inputs: Inputs.Manifold.ManifoldSimplifyDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
23
|
+
setProperties(inputs: Inputs.Manifold.ManifoldSetPropertiesDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
22
24
|
}
|
|
@@ -56,4 +56,10 @@ export class ManifoldOperations {
|
|
|
56
56
|
smoothByNormals(inputs) {
|
|
57
57
|
return inputs.manifold.smoothByNormals(inputs.normalIdx);
|
|
58
58
|
}
|
|
59
|
+
simplify(inputs) {
|
|
60
|
+
return inputs.manifold.simplify(inputs.tolerance);
|
|
61
|
+
}
|
|
62
|
+
setProperties(inputs) {
|
|
63
|
+
return inputs.manifold.setProperties(inputs.numProp, inputs.propFunc);
|
|
64
|
+
}
|
|
59
65
|
}
|
|
@@ -13,4 +13,5 @@ export declare class ManifoldTransforms {
|
|
|
13
13
|
translateXYZ(inputs: Inputs.Manifold.TranslateXYZDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
14
14
|
transform(inputs: Inputs.Manifold.TransformDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
15
15
|
transforms(inputs: Inputs.Manifold.TransformsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
16
|
+
warp(inputs: Inputs.Manifold.ManifoldWarpDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
16
17
|
}
|
package/lib/base.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TextBitByBit, Point, GeometryHelper, Transforms, Vector, MathBitByBit, MeshBitByBit, Polyline, Line, Lists, IoBitByBit } from "@bitbybit-dev/base";
|
|
2
|
+
export declare class BaseBitByBit {
|
|
3
|
+
readonly geometryHelper: GeometryHelper;
|
|
4
|
+
readonly vector: Vector;
|
|
5
|
+
readonly math: MathBitByBit;
|
|
6
|
+
readonly transforms: Transforms;
|
|
7
|
+
readonly lists: Lists;
|
|
8
|
+
readonly point: Point;
|
|
9
|
+
readonly line: Line;
|
|
10
|
+
readonly polyline: Polyline;
|
|
11
|
+
readonly mesh: MeshBitByBit;
|
|
12
|
+
readonly textService: TextBitByBit;
|
|
13
|
+
readonly io: IoBitByBit;
|
|
14
|
+
constructor();
|
|
15
|
+
}
|
package/lib/base.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TextBitByBit, Point, GeometryHelper, Transforms, Vector, MathBitByBit, MeshBitByBit, Polyline, Line, Lists, IoBitByBit } from "@bitbybit-dev/base";
|
|
2
|
+
export class BaseBitByBit {
|
|
3
|
+
constructor() {
|
|
4
|
+
this.geometryHelper = new GeometryHelper();
|
|
5
|
+
this.math = new MathBitByBit();
|
|
6
|
+
this.vector = new Vector(this.math, this.geometryHelper);
|
|
7
|
+
this.transforms = new Transforms(this.vector, this.math);
|
|
8
|
+
this.lists = new Lists();
|
|
9
|
+
this.point = new Point(this.geometryHelper, this.transforms, this.vector, this.lists);
|
|
10
|
+
this.line = new Line(this.vector, this.point, this.geometryHelper);
|
|
11
|
+
this.polyline = new Polyline(this.vector, this.point, this.line, this.geometryHelper);
|
|
12
|
+
this.textService = new TextBitByBit(this.point);
|
|
13
|
+
this.mesh = new MeshBitByBit(this.vector, this.polyline);
|
|
14
|
+
this.io = new IoBitByBit();
|
|
15
|
+
}
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitbybit-dev/manifold",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.21.0",
|
|
4
4
|
"description": "Bit By Bit Developers Manifold based CAD Library to Program Geometry",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -58,7 +58,8 @@
|
|
|
58
58
|
"types": "./index.d.ts",
|
|
59
59
|
"type": "module",
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"manifold-3d": "3.
|
|
61
|
+
"manifold-3d": "3.3.2",
|
|
62
|
+
"@bitbybit-dev/base": "0.21.0"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"shx":"0.4.0",
|