@bitbybit-dev/manifold 0.20.14 → 0.21.1
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/LICENSE +1 -1
- package/lib/api/inputs/manifold-inputs.d.ts +82 -2
- package/lib/api/inputs/manifold-inputs.js +120 -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.d.ts +8 -2
- package/lib/api/services/cross-section/cross-section.js +41 -1
- package/lib/base.d.ts +15 -0
- package/lib/base.js +16 -0
- package/package.json +3 -2
package/LICENSE
CHANGED
|
@@ -40,7 +40,7 @@ export declare namespace Manifold {
|
|
|
40
40
|
/**
|
|
41
41
|
* Provide options without default values
|
|
42
42
|
*/
|
|
43
|
-
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);
|
|
44
44
|
/**
|
|
45
45
|
* Manifold geometry
|
|
46
46
|
* @default undefined
|
|
@@ -88,12 +88,30 @@ export declare namespace Manifold {
|
|
|
88
88
|
* @default false
|
|
89
89
|
*/
|
|
90
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;
|
|
91
109
|
}
|
|
92
110
|
class DrawManifoldsOrCrossSectionsDto<T, M> {
|
|
93
111
|
/**
|
|
94
112
|
* Provide options without default values
|
|
95
113
|
*/
|
|
96
|
-
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);
|
|
97
115
|
/**
|
|
98
116
|
* Manifold geometry
|
|
99
117
|
* @default undefined
|
|
@@ -141,6 +159,24 @@ export declare namespace Manifold {
|
|
|
141
159
|
* @default false
|
|
142
160
|
*/
|
|
143
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;
|
|
144
180
|
}
|
|
145
181
|
class CreateFromMeshDto {
|
|
146
182
|
constructor(mesh?: DecomposedManifoldMeshDto);
|
|
@@ -156,6 +192,50 @@ export declare namespace Manifold {
|
|
|
156
192
|
*/
|
|
157
193
|
polygonPoints?: Base.Point3[][];
|
|
158
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
|
+
}
|
|
159
239
|
class CubeDto {
|
|
160
240
|
constructor(center?: boolean, size?: number);
|
|
161
241
|
/**
|
|
@@ -22,7 +22,7 @@ export var Manifold;
|
|
|
22
22
|
/**
|
|
23
23
|
* Provide options without default values
|
|
24
24
|
*/
|
|
25
|
-
constructor(manifoldOrCrossSection, faceOpacity, faceMaterial, faceColour, crossSectionColour, crossSectionWidth, crossSectionOpacity, computeNormals) {
|
|
25
|
+
constructor(manifoldOrCrossSection, faceOpacity, faceMaterial, faceColour, crossSectionColour, crossSectionWidth, crossSectionOpacity, computeNormals, drawTwoSided, backFaceColour, backFaceOpacity) {
|
|
26
26
|
/**
|
|
27
27
|
* Face opacity value between 0 and 1
|
|
28
28
|
* @default 1
|
|
@@ -59,6 +59,24 @@ export var Manifold;
|
|
|
59
59
|
* @default false
|
|
60
60
|
*/
|
|
61
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;
|
|
62
80
|
if (manifoldOrCrossSection !== undefined) {
|
|
63
81
|
this.manifoldOrCrossSection = manifoldOrCrossSection;
|
|
64
82
|
}
|
|
@@ -83,6 +101,15 @@ export var Manifold;
|
|
|
83
101
|
if (computeNormals !== undefined) {
|
|
84
102
|
this.computeNormals = computeNormals;
|
|
85
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
|
+
}
|
|
86
113
|
}
|
|
87
114
|
}
|
|
88
115
|
Manifold.DrawManifoldOrCrossSectionDto = DrawManifoldOrCrossSectionDto;
|
|
@@ -90,7 +117,7 @@ export var Manifold;
|
|
|
90
117
|
/**
|
|
91
118
|
* Provide options without default values
|
|
92
119
|
*/
|
|
93
|
-
constructor(manifoldsOrCrossSections, faceOpacity, faceMaterial, faceColour, crossSectionColour, crossSectionWidth, crossSectionOpacity, computeNormals) {
|
|
120
|
+
constructor(manifoldsOrCrossSections, faceOpacity, faceMaterial, faceColour, crossSectionColour, crossSectionWidth, crossSectionOpacity, computeNormals, drawTwoSided, backFaceColour, backFaceOpacity) {
|
|
94
121
|
/**
|
|
95
122
|
* Hex colour string for face colour
|
|
96
123
|
* @default #ff0000
|
|
@@ -127,6 +154,24 @@ export var Manifold;
|
|
|
127
154
|
* @default false
|
|
128
155
|
*/
|
|
129
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;
|
|
130
175
|
if (manifoldsOrCrossSections !== undefined) {
|
|
131
176
|
this.manifoldsOrCrossSections = manifoldsOrCrossSections;
|
|
132
177
|
}
|
|
@@ -151,6 +196,15 @@ export var Manifold;
|
|
|
151
196
|
if (computeNormals !== undefined) {
|
|
152
197
|
this.computeNormals = computeNormals;
|
|
153
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
|
+
}
|
|
154
208
|
}
|
|
155
209
|
}
|
|
156
210
|
Manifold.DrawManifoldsOrCrossSectionsDto = DrawManifoldsOrCrossSectionsDto;
|
|
@@ -170,6 +224,70 @@ export var Manifold;
|
|
|
170
224
|
}
|
|
171
225
|
}
|
|
172
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;
|
|
173
291
|
class CubeDto {
|
|
174
292
|
constructor(center, size) {
|
|
175
293
|
/**
|
|
@@ -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;
|
|
@@ -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
|
}
|
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.1",
|
|
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.3.2"
|
|
61
|
+
"manifold-3d": "3.3.2",
|
|
62
|
+
"@bitbybit-dev/base": "0.21.1"
|
|
62
63
|
},
|
|
63
64
|
"devDependencies": {
|
|
64
65
|
"shx":"0.4.0",
|