@bitbybit-dev/manifold 1.1.1 → 1.2.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.
- package/README.md +14 -4
- package/index.js +0 -3
- package/lib/api/inputs/base-inputs.js +0 -1
- package/lib/api/inputs/manifold-inputs.d.ts +63 -23
- package/lib/api/inputs/manifold-inputs.js +114 -1
- package/lib/api/manifold-service.d.ts +30 -2
- package/lib/api/manifold-service.js +43 -22
- package/lib/api/services/cross-section/cross-section-booleans.d.ts +78 -2
- package/lib/api/services/cross-section/cross-section-booleans.js +86 -10
- package/lib/api/services/cross-section/cross-section-evaluate.d.ts +45 -2
- package/lib/api/services/cross-section/cross-section-evaluate.js +45 -2
- package/lib/api/services/cross-section/cross-section-operations.d.ts +71 -0
- package/lib/api/services/cross-section/cross-section-operations.js +71 -2
- package/lib/api/services/cross-section/cross-section-shapes.d.ts +39 -0
- package/lib/api/services/cross-section/cross-section-shapes.js +39 -0
- package/lib/api/services/cross-section/cross-section-transforms.d.ts +72 -2
- package/lib/api/services/cross-section/cross-section-transforms.js +72 -2
- package/lib/api/services/cross-section/cross-section.d.ts +53 -1
- package/lib/api/services/cross-section/cross-section.js +53 -5
- package/lib/api/services/index.js +1 -0
- package/lib/api/services/manifold/manifold-booleans.d.ts +116 -6
- package/lib/api/services/manifold/manifold-booleans.js +159 -48
- package/lib/api/services/manifold/manifold-evaluate.d.ts +133 -3
- package/lib/api/services/manifold/manifold-evaluate.js +135 -5
- package/lib/api/services/manifold/manifold-operations.d.ts +202 -1
- package/lib/api/services/manifold/manifold-operations.js +204 -3
- package/lib/api/services/manifold/manifold-shapes.d.ts +59 -0
- package/lib/api/services/manifold/manifold-shapes.js +78 -20
- package/lib/api/services/manifold/manifold-transforms.d.ts +97 -3
- package/lib/api/services/manifold/manifold-transforms.js +102 -6
- package/lib/api/services/manifold/manifold.d.ts +20 -0
- package/lib/api/services/manifold/manifold.js +20 -1
- package/lib/api/services/mesh/mesh-evaluate.d.ts +81 -3
- package/lib/api/services/mesh/mesh-evaluate.js +84 -6
- package/lib/api/services/mesh/mesh-operations.d.ts +24 -2
- package/lib/api/services/mesh/mesh-operations.js +24 -2
- package/lib/api/services/mesh/mesh.d.ts +4 -0
- package/lib/api/services/mesh/mesh.js +4 -1
- package/package.json +6 -45
- package/babel.config.cjs +0 -17
- package/babel.config.d.cts +0 -6
|
@@ -1,85 +1,143 @@
|
|
|
1
1
|
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
|
+
/**
|
|
3
|
+
* The grid a vertex is snapped onto before it is used as a de-duplication key.
|
|
4
|
+
*
|
|
5
|
+
* Vertices arriving from separate triangles of the same surface differ in the last bits after any
|
|
6
|
+
* floating-point arithmetic has touched them, and keying on the exact coordinates left every such
|
|
7
|
+
* pair as two vertices - which is what made a mesh built from polygon points non-watertight along a
|
|
8
|
+
* seam that looks closed. Snapping to a grid merges them.
|
|
9
|
+
*
|
|
10
|
+
* The value is absolute, not relative: it is chosen to be far above the noise of double arithmetic on
|
|
11
|
+
* ordinary CAD magnitudes and far below any distance a model means to express. Two vertices that
|
|
12
|
+
* genuinely sit closer together than this are merged, and two that straddle a grid boundary are not -
|
|
13
|
+
* that is inherent to snapping, and the alternative, a neighbourhood search, costs more than it is
|
|
14
|
+
* worth here.
|
|
15
|
+
*/
|
|
16
|
+
const VERTEX_MERGE_TOLERANCE = 1e-7;
|
|
17
|
+
/** Snaps a coordinate onto the merge grid, normalising a negative zero so it keys the same as zero. */
|
|
18
|
+
const quantize = (coordinate) => Math.round(coordinate / VERTEX_MERGE_TOLERANCE) || 0;
|
|
19
|
+
/**
|
|
20
|
+
* Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
|
|
21
|
+
* Thanks Manifold community for developing this kernel
|
|
22
|
+
*/
|
|
2
23
|
export class ManifoldShapes {
|
|
3
24
|
constructor(wasm) {
|
|
4
25
|
this.manifold = wasm;
|
|
5
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* Convert a Mesh into a Manifold, retaining its properties and merging only
|
|
29
|
+
* the positions according to the merge vectors. Will throw an error if the
|
|
30
|
+
* result is not an oriented 2-manifold. Will collapse degenerate triangles
|
|
31
|
+
* and unnecessary vertices.
|
|
32
|
+
*
|
|
33
|
+
* All fields are read, making this structure suitable for a lossless
|
|
34
|
+
* round-trip of data from manifoldToMesh(). For multi-material input, use
|
|
35
|
+
* reserveIDs() to set a unique originalID for each material, and sort the
|
|
36
|
+
* materials into triangle runs.
|
|
37
|
+
* @param inputs mesh definition
|
|
38
|
+
* @returns manifold
|
|
39
|
+
* @group create
|
|
40
|
+
* @shortname manifold from mesh
|
|
41
|
+
* @drawable true
|
|
42
|
+
*/
|
|
6
43
|
manifoldFromMesh(inputs) {
|
|
7
44
|
const { Manifold } = this.manifold;
|
|
8
45
|
return new Manifold(inputs.mesh);
|
|
9
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Create a Manifold from a set of polygon points describing triangles.
|
|
49
|
+
* @param inputs Polygon points
|
|
50
|
+
* @returns Manifold
|
|
51
|
+
* @group create
|
|
52
|
+
* @shortname from polygon points
|
|
53
|
+
* @drawable true
|
|
54
|
+
*/
|
|
10
55
|
fromPolygonPoints(inputs) {
|
|
11
56
|
const { Manifold } = this.manifold;
|
|
12
57
|
const polygons = inputs.polygonPoints;
|
|
13
|
-
// Map to store unique vertices and their assigned index.
|
|
14
|
-
// Key: string representation "x,y,z"
|
|
15
|
-
// Value: index in the unique vertex list
|
|
16
58
|
const vertexMap = new Map();
|
|
17
59
|
const uniqueVertexCoords = [];
|
|
18
60
|
const triangleIndices = [];
|
|
19
61
|
let vertexIndexCounter = 0;
|
|
20
|
-
// --- Iterate, Deduplicate, and Store Unique Vertices/Indices ---
|
|
21
62
|
for (const triangle of polygons) {
|
|
22
63
|
if (!triangle || triangle.length !== 3) {
|
|
23
64
|
console.warn(`Skipping invalid polygon data (expected 3 vertices): ${JSON.stringify(triangle)}`);
|
|
24
|
-
continue;
|
|
65
|
+
continue;
|
|
25
66
|
}
|
|
26
67
|
for (const point of triangle) {
|
|
27
68
|
if (!point || point.length !== 3 || point.some(isNaN)) {
|
|
28
|
-
// Handle potential malformed point data more robustly
|
|
29
69
|
console.warn(`Skipping invalid point data in triangle: ${JSON.stringify(point)}`);
|
|
30
|
-
// Let's throw an error for clearer failure:
|
|
31
70
|
throw new Error(`Invalid point data encountered: ${JSON.stringify(point)} in triangle ${JSON.stringify(triangle)}`);
|
|
32
71
|
}
|
|
33
|
-
|
|
34
|
-
// Using string concatenation is simple for exact matches.
|
|
35
|
-
// Be aware of potential floating-point precision issues if vertices
|
|
36
|
-
// might be *very* slightly different but should be treated as the same.
|
|
37
|
-
const vertexKey = `${point[0]},${point[1]},${point[2]}`;
|
|
72
|
+
const vertexKey = `${quantize(point[0])},${quantize(point[1])},${quantize(point[2])}`;
|
|
38
73
|
let index;
|
|
39
|
-
// Check if this vertex has already been seen
|
|
40
74
|
if (vertexMap.has(vertexKey)) {
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
42
75
|
index = vertexMap.get(vertexKey);
|
|
43
76
|
}
|
|
44
77
|
else {
|
|
45
|
-
// It's a new unique vertex
|
|
46
78
|
index = vertexIndexCounter;
|
|
47
79
|
vertexMap.set(vertexKey, index);
|
|
48
80
|
uniqueVertexCoords.push(point[0], point[1], point[2]);
|
|
49
81
|
vertexIndexCounter++;
|
|
50
82
|
}
|
|
51
|
-
// Add the index (either existing or new) to the triangle indices list
|
|
52
83
|
triangleIndices.push(index);
|
|
53
84
|
}
|
|
54
85
|
}
|
|
55
|
-
// --- Create TypedArrays ---
|
|
56
|
-
// Number of properties per vertex (x, y, z)
|
|
57
|
-
// If we had normals, UVs etc., this would be higher, we're not dealing with that here when making meshes from simple polygon points.
|
|
58
86
|
const numProp = 3;
|
|
59
87
|
const vertProperties = Float32Array.from(uniqueVertexCoords);
|
|
60
88
|
const triVerts = Uint32Array.from(triangleIndices);
|
|
61
|
-
// --- Populate the DTO ---
|
|
62
89
|
const meshDto = new Inputs.Manifold.DecomposedManifoldMeshDto();
|
|
63
90
|
meshDto.numProp = numProp;
|
|
64
91
|
meshDto.vertProperties = vertProperties;
|
|
65
92
|
meshDto.triVerts = triVerts;
|
|
66
93
|
return new Manifold(meshDto);
|
|
67
94
|
}
|
|
95
|
+
/**
|
|
96
|
+
* Create a 3D cube shape
|
|
97
|
+
* @param inputs Cube parameters
|
|
98
|
+
* @returns Cube solid
|
|
99
|
+
* @group primitives
|
|
100
|
+
* @shortname cube
|
|
101
|
+
* @drawable true
|
|
102
|
+
*/
|
|
68
103
|
cube(inputs) {
|
|
69
104
|
const { Manifold } = this.manifold;
|
|
70
105
|
const { cube } = Manifold;
|
|
71
106
|
return cube(inputs.size, inputs.center);
|
|
72
107
|
}
|
|
108
|
+
/**
|
|
109
|
+
* Create a 3D sphere shape
|
|
110
|
+
* @param inputs Sphere parameters
|
|
111
|
+
* @returns Sphere solid
|
|
112
|
+
* @group primitives
|
|
113
|
+
* @shortname sphere
|
|
114
|
+
* @drawable true
|
|
115
|
+
*/
|
|
73
116
|
sphere(inputs) {
|
|
74
117
|
const { Manifold } = this.manifold;
|
|
75
118
|
const { sphere } = Manifold;
|
|
76
119
|
return sphere(inputs.radius, inputs.circularSegments);
|
|
77
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* Create a 3D tetrahedron shape
|
|
123
|
+
* @returns Tetrahedron solid
|
|
124
|
+
* @group primitives
|
|
125
|
+
* @shortname tetrahedron
|
|
126
|
+
* @drawable true
|
|
127
|
+
*/
|
|
78
128
|
tetrahedron() {
|
|
79
129
|
const { Manifold } = this.manifold;
|
|
80
130
|
const { tetrahedron } = Manifold;
|
|
81
131
|
return tetrahedron();
|
|
82
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Create a 3D cylinder shape
|
|
135
|
+
* @param inputs Cylinder parameters
|
|
136
|
+
* @returns Cylinder solid
|
|
137
|
+
* @group primitives
|
|
138
|
+
* @shortname cylinder
|
|
139
|
+
* @drawable true
|
|
140
|
+
*/
|
|
83
141
|
cylinder(inputs) {
|
|
84
142
|
const { Manifold } = this.manifold;
|
|
85
143
|
const { cylinder } = Manifold;
|
|
@@ -1,17 +1,111 @@
|
|
|
1
1
|
import * as Inputs from "../../inputs/manifold-inputs";
|
|
2
2
|
import * as Manifold3D from "manifold-3d";
|
|
3
|
+
/**
|
|
4
|
+
* Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
|
|
5
|
+
* Thanks Manifold community for developing this kernel
|
|
6
|
+
*/
|
|
3
7
|
export declare class ManifoldTransforms {
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
constructor(_wasm: Manifold3D.ManifoldToplevel);
|
|
9
|
+
/**
|
|
10
|
+
* Scales a manifold shape with 3D vector
|
|
11
|
+
* @param inputs manifold and scale vector
|
|
12
|
+
* @returns Scaled manifold shape
|
|
13
|
+
* @group transforms
|
|
14
|
+
* @shortname scale 3d
|
|
15
|
+
* @drawable true
|
|
16
|
+
*/
|
|
6
17
|
scale3D(inputs: Inputs.Manifold.Scale3DDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
18
|
+
/**
|
|
19
|
+
* Scales a manifold shape with single factor
|
|
20
|
+
* @param inputs manifold and scale factor
|
|
21
|
+
* @returns Scaled manifold shape
|
|
22
|
+
* @group transforms
|
|
23
|
+
* @shortname scale uniform
|
|
24
|
+
* @drawable true
|
|
25
|
+
*/
|
|
7
26
|
scale(inputs: Inputs.Manifold.Scale3DDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
27
|
+
/**
|
|
28
|
+
* Mirrors a manifold shape over a plane defined by a normal vector
|
|
29
|
+
* @param inputs manifold and normal vector
|
|
30
|
+
* @returns Mirrored manifold shape
|
|
31
|
+
* @group transforms
|
|
32
|
+
* @shortname mirror
|
|
33
|
+
* @drawable true
|
|
34
|
+
*/
|
|
8
35
|
mirror(inputs: Inputs.Manifold.MirrorDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
36
|
+
/**
|
|
37
|
+
* Translates a manifold shape along the vector
|
|
38
|
+
* @param inputs manifold and trnaslation vector
|
|
39
|
+
* @returns Translated manifold shape
|
|
40
|
+
* @group transforms
|
|
41
|
+
* @shortname translate
|
|
42
|
+
* @drawable true
|
|
43
|
+
*/
|
|
9
44
|
translate(inputs: Inputs.Manifold.TranslateDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
45
|
+
/**
|
|
46
|
+
* Translates a manifold shape along by multiple vectors
|
|
47
|
+
* @param inputs manifold and trnaslation vectors
|
|
48
|
+
* @returns Translated manifold shapes
|
|
49
|
+
* @group multiple
|
|
50
|
+
* @shortname translate by vectors
|
|
51
|
+
* @drawable true
|
|
52
|
+
*/
|
|
10
53
|
translateByVectors(inputs: Inputs.Manifold.TranslateByVectorsDto<Manifold3D.Manifold>): Manifold3D.Manifold[];
|
|
54
|
+
/**
|
|
55
|
+
* Translates a manifold shape along x, y, z
|
|
56
|
+
* @param inputs manifold and trnaslation coordinates
|
|
57
|
+
* @returns Translated manifold shape
|
|
58
|
+
* @group transforms
|
|
59
|
+
* @shortname translate xyz
|
|
60
|
+
* @drawable true
|
|
61
|
+
*/
|
|
62
|
+
translateXYZ(inputs: Inputs.Manifold.TranslateXYZDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
63
|
+
/**
|
|
64
|
+
* Rotates a manifold shape along the vector containing euler angles
|
|
65
|
+
* @param inputs manifold and rotation vector
|
|
66
|
+
* @returns Rotated manifold shape
|
|
67
|
+
* @group transforms
|
|
68
|
+
* @shortname rotate
|
|
69
|
+
* @drawable true
|
|
70
|
+
*/
|
|
11
71
|
rotate(inputs: Inputs.Manifold.RotateDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
72
|
+
/**
|
|
73
|
+
* Rotates a manifold shape along the x y z euler angles
|
|
74
|
+
* @param inputs manifold and rotation eulers
|
|
75
|
+
* @returns Rotated manifold shape
|
|
76
|
+
* @group transforms
|
|
77
|
+
* @shortname rotate xyz
|
|
78
|
+
* @drawable true
|
|
79
|
+
*/
|
|
12
80
|
rotateXYZ(inputs: Inputs.Manifold.RotateXYZDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
13
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Transforms a manifold shape by using the 4x4 transformation matrix
|
|
83
|
+
* @param inputs manifold and transformation matrix
|
|
84
|
+
* @returns Transformed manifold shape
|
|
85
|
+
* @group matrix
|
|
86
|
+
* @shortname transform
|
|
87
|
+
* @drawable true
|
|
88
|
+
*/
|
|
14
89
|
transform(inputs: Inputs.Manifold.TransformDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
90
|
+
/**
|
|
91
|
+
* Transforms a manifold shape by using the 4x4 transformation matrixes
|
|
92
|
+
* @param inputs manifold and transformation matrixes
|
|
93
|
+
* @returns Transformed manifold shape
|
|
94
|
+
* @group matrix
|
|
95
|
+
* @shortname transforms
|
|
96
|
+
* @drawable true
|
|
97
|
+
*/
|
|
15
98
|
transforms(inputs: Inputs.Manifold.TransformsDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
99
|
+
/**
|
|
100
|
+
* Move the vertices of this Manifold (creating a new one) according to any
|
|
101
|
+
* arbitrary input function. It is easy to create a function that warps a
|
|
102
|
+
* geometrically valid object into one which overlaps, but that is not checked
|
|
103
|
+
* here, so it is up to the user to choose their function with discretion.
|
|
104
|
+
* @param inputs manifold and warp function
|
|
105
|
+
* @returns Warped manifold shape
|
|
106
|
+
* @group transforms
|
|
107
|
+
* @shortname warp
|
|
108
|
+
* @drawable true
|
|
109
|
+
*/
|
|
16
110
|
warp(inputs: Inputs.Manifold.ManifoldWarpDto<Manifold3D.Manifold>): Manifold3D.Manifold;
|
|
17
111
|
}
|
|
@@ -1,50 +1,146 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
|
|
3
|
+
* Thanks Manifold community for developing this kernel
|
|
4
|
+
*/
|
|
1
5
|
export class ManifoldTransforms {
|
|
2
|
-
constructor(
|
|
3
|
-
this.manifold = wasm;
|
|
6
|
+
constructor(_wasm) {
|
|
4
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* Scales a manifold shape with 3D vector
|
|
10
|
+
* @param inputs manifold and scale vector
|
|
11
|
+
* @returns Scaled manifold shape
|
|
12
|
+
* @group transforms
|
|
13
|
+
* @shortname scale 3d
|
|
14
|
+
* @drawable true
|
|
15
|
+
*/
|
|
5
16
|
scale3D(inputs) {
|
|
6
17
|
return inputs.manifold.scale(inputs.vector);
|
|
7
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* Scales a manifold shape with single factor
|
|
21
|
+
* @param inputs manifold and scale factor
|
|
22
|
+
* @returns Scaled manifold shape
|
|
23
|
+
* @group transforms
|
|
24
|
+
* @shortname scale uniform
|
|
25
|
+
* @drawable true
|
|
26
|
+
*/
|
|
8
27
|
scale(inputs) {
|
|
9
28
|
return inputs.manifold.scale(inputs.vector);
|
|
10
29
|
}
|
|
30
|
+
/**
|
|
31
|
+
* Mirrors a manifold shape over a plane defined by a normal vector
|
|
32
|
+
* @param inputs manifold and normal vector
|
|
33
|
+
* @returns Mirrored manifold shape
|
|
34
|
+
* @group transforms
|
|
35
|
+
* @shortname mirror
|
|
36
|
+
* @drawable true
|
|
37
|
+
*/
|
|
11
38
|
mirror(inputs) {
|
|
12
39
|
return inputs.manifold.mirror(inputs.normal);
|
|
13
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Translates a manifold shape along the vector
|
|
43
|
+
* @param inputs manifold and trnaslation vector
|
|
44
|
+
* @returns Translated manifold shape
|
|
45
|
+
* @group transforms
|
|
46
|
+
* @shortname translate
|
|
47
|
+
* @drawable true
|
|
48
|
+
*/
|
|
14
49
|
translate(inputs) {
|
|
15
50
|
return inputs.manifold.translate(inputs.vector);
|
|
16
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Translates a manifold shape along by multiple vectors
|
|
54
|
+
* @param inputs manifold and trnaslation vectors
|
|
55
|
+
* @returns Translated manifold shapes
|
|
56
|
+
* @group multiple
|
|
57
|
+
* @shortname translate by vectors
|
|
58
|
+
* @drawable true
|
|
59
|
+
*/
|
|
17
60
|
translateByVectors(inputs) {
|
|
18
61
|
return inputs.vectors.map(vector => {
|
|
19
62
|
return inputs.manifold.translate(vector);
|
|
20
63
|
});
|
|
21
64
|
}
|
|
65
|
+
/**
|
|
66
|
+
* Translates a manifold shape along x, y, z
|
|
67
|
+
* @param inputs manifold and trnaslation coordinates
|
|
68
|
+
* @returns Translated manifold shape
|
|
69
|
+
* @group transforms
|
|
70
|
+
* @shortname translate xyz
|
|
71
|
+
* @drawable true
|
|
72
|
+
*/
|
|
73
|
+
translateXYZ(inputs) {
|
|
74
|
+
return inputs.manifold.translate(inputs.x, inputs.y, inputs.z);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Rotates a manifold shape along the vector containing euler angles
|
|
78
|
+
* @param inputs manifold and rotation vector
|
|
79
|
+
* @returns Rotated manifold shape
|
|
80
|
+
* @group transforms
|
|
81
|
+
* @shortname rotate
|
|
82
|
+
* @drawable true
|
|
83
|
+
*/
|
|
22
84
|
rotate(inputs) {
|
|
23
85
|
return inputs.manifold.rotate(inputs.vector);
|
|
24
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Rotates a manifold shape along the x y z euler angles
|
|
89
|
+
* @param inputs manifold and rotation eulers
|
|
90
|
+
* @returns Rotated manifold shape
|
|
91
|
+
* @group transforms
|
|
92
|
+
* @shortname rotate xyz
|
|
93
|
+
* @drawable true
|
|
94
|
+
*/
|
|
25
95
|
rotateXYZ(inputs) {
|
|
26
96
|
return inputs.manifold.rotate(inputs.x, inputs.y, inputs.z);
|
|
27
97
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
98
|
+
/**
|
|
99
|
+
* Transforms a manifold shape by using the 4x4 transformation matrix
|
|
100
|
+
* @param inputs manifold and transformation matrix
|
|
101
|
+
* @returns Transformed manifold shape
|
|
102
|
+
* @group matrix
|
|
103
|
+
* @shortname transform
|
|
104
|
+
* @drawable true
|
|
105
|
+
*/
|
|
31
106
|
transform(inputs) {
|
|
32
107
|
return inputs.manifold.transform(inputs.transform);
|
|
33
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Transforms a manifold shape by using the 4x4 transformation matrixes
|
|
111
|
+
* @param inputs manifold and transformation matrixes
|
|
112
|
+
* @returns Transformed manifold shape
|
|
113
|
+
* @group matrix
|
|
114
|
+
* @shortname transforms
|
|
115
|
+
* @drawable true
|
|
116
|
+
*/
|
|
34
117
|
transforms(inputs) {
|
|
35
118
|
let currentShape = inputs.manifold;
|
|
36
|
-
//potentially leaks in betweens...
|
|
37
119
|
const transformedShapes = [];
|
|
38
120
|
inputs.transforms.forEach(transform => {
|
|
39
121
|
currentShape = currentShape.transform(transform);
|
|
40
122
|
transformedShapes.push(currentShape);
|
|
41
123
|
});
|
|
42
124
|
const res = transformedShapes.pop();
|
|
125
|
+
if (!res) {
|
|
126
|
+
throw new Error("At least one transform is required");
|
|
127
|
+
}
|
|
43
128
|
transformedShapes.forEach(shape => {
|
|
44
129
|
shape.delete();
|
|
45
130
|
});
|
|
46
131
|
return res;
|
|
47
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Move the vertices of this Manifold (creating a new one) according to any
|
|
135
|
+
* arbitrary input function. It is easy to create a function that warps a
|
|
136
|
+
* geometrically valid object into one which overlaps, but that is not checked
|
|
137
|
+
* here, so it is up to the user to choose their function with discretion.
|
|
138
|
+
* @param inputs manifold and warp function
|
|
139
|
+
* @returns Warped manifold shape
|
|
140
|
+
* @group transforms
|
|
141
|
+
* @shortname warp
|
|
142
|
+
* @drawable true
|
|
143
|
+
*/
|
|
48
144
|
warp(inputs) {
|
|
49
145
|
return inputs.manifold.warp(inputs.warpFunc);
|
|
50
146
|
}
|
|
@@ -5,6 +5,10 @@ import { ManifoldOperations } from "./manifold-operations";
|
|
|
5
5
|
import { ManifoldTransforms } from "./manifold-transforms";
|
|
6
6
|
import { ManifoldEvaluate } from "./manifold-evaluate";
|
|
7
7
|
import * as Inputs from "../../inputs";
|
|
8
|
+
/**
|
|
9
|
+
* Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
|
|
10
|
+
* Thanks Manifold community for developing this kernel
|
|
11
|
+
*/
|
|
8
12
|
export declare class Manifold {
|
|
9
13
|
plugins: any;
|
|
10
14
|
shapes: ManifoldShapes;
|
|
@@ -13,6 +17,22 @@ export declare class Manifold {
|
|
|
13
17
|
transforms: ManifoldTransforms;
|
|
14
18
|
evaluate: ManifoldEvaluate;
|
|
15
19
|
constructor(wasm: Manifold3D.ManifoldToplevel);
|
|
20
|
+
/**
|
|
21
|
+
* Turns manifold shape into a mesh
|
|
22
|
+
* @param inputs Manifold shape
|
|
23
|
+
* @returns Decomposed mesh definition
|
|
24
|
+
* @group meshing
|
|
25
|
+
* @shortname manifold to mesh
|
|
26
|
+
* @drawable false
|
|
27
|
+
*/
|
|
16
28
|
manifoldToMesh(inputs: Inputs.Manifold.ManifoldToMeshDto<Manifold3D.Manifold>): Manifold3D.Mesh;
|
|
29
|
+
/**
|
|
30
|
+
* Turns manifold shapes into meshes
|
|
31
|
+
* @param inputs Manifold shapes
|
|
32
|
+
* @returns Decomposed mesh definitions
|
|
33
|
+
* @group meshing
|
|
34
|
+
* @shortname manifolds to meshes
|
|
35
|
+
* @drawable false
|
|
36
|
+
*/
|
|
17
37
|
manifoldsToMeshes(inputs: Inputs.Manifold.ManifoldsToMeshesDto<Manifold3D.Manifold>): (Manifold3D.Mesh)[];
|
|
18
38
|
}
|
|
@@ -3,7 +3,10 @@ import { ManifoldBooleans } from "./manifold-booleans";
|
|
|
3
3
|
import { ManifoldOperations } from "./manifold-operations";
|
|
4
4
|
import { ManifoldTransforms } from "./manifold-transforms";
|
|
5
5
|
import { ManifoldEvaluate } from "./manifold-evaluate";
|
|
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
|
|
9
|
+
*/
|
|
7
10
|
export class Manifold {
|
|
8
11
|
constructor(wasm) {
|
|
9
12
|
this.shapes = new ManifoldShapes(wasm);
|
|
@@ -12,9 +15,25 @@ export class Manifold {
|
|
|
12
15
|
this.transforms = new ManifoldTransforms(wasm);
|
|
13
16
|
this.evaluate = new ManifoldEvaluate(wasm);
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Turns manifold shape into a mesh
|
|
20
|
+
* @param inputs Manifold shape
|
|
21
|
+
* @returns Decomposed mesh definition
|
|
22
|
+
* @group meshing
|
|
23
|
+
* @shortname manifold to mesh
|
|
24
|
+
* @drawable false
|
|
25
|
+
*/
|
|
15
26
|
manifoldToMesh(inputs) {
|
|
16
27
|
return inputs.manifold.getMesh(inputs.normalIdx);
|
|
17
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Turns manifold shapes into meshes
|
|
31
|
+
* @param inputs Manifold shapes
|
|
32
|
+
* @returns Decomposed mesh definitions
|
|
33
|
+
* @group meshing
|
|
34
|
+
* @shortname manifolds to meshes
|
|
35
|
+
* @drawable false
|
|
36
|
+
*/
|
|
18
37
|
manifoldsToMeshes(inputs) {
|
|
19
38
|
return inputs.manifolds.map((manifold, index) => {
|
|
20
39
|
const normalIdx = inputs.normalIdx ? inputs.normalIdx[index] : undefined;
|
|
@@ -1,15 +1,93 @@
|
|
|
1
1
|
import * as Inputs from "../../inputs";
|
|
2
2
|
import * as Manifold3D from "manifold-3d";
|
|
3
|
+
/**
|
|
4
|
+
* Contains various functions for Solid meshes from Manifold library https://github.com/elalish/manifold
|
|
5
|
+
* Thanks Manifold community for developing this kernel
|
|
6
|
+
*/
|
|
3
7
|
export declare class MeshEvaluate {
|
|
4
|
-
|
|
5
|
-
|
|
8
|
+
constructor(_wasm: Manifold3D.ManifoldToplevel);
|
|
9
|
+
/**
|
|
10
|
+
* Get position on mesh vertex index
|
|
11
|
+
* @param inputs mesh
|
|
12
|
+
* @returns point
|
|
13
|
+
* @group basic
|
|
14
|
+
* @shortname position
|
|
15
|
+
* @drawable true
|
|
16
|
+
*/
|
|
6
17
|
position(inputs: Inputs.Manifold.MeshVertexIndexDto<Manifold3D.Mesh>): Inputs.Base.Point3;
|
|
7
|
-
|
|
18
|
+
/**
|
|
19
|
+
* Gets the three vertex indices of this triangle in CCW order.
|
|
20
|
+
* @param inputs mesh
|
|
21
|
+
* @returns verts
|
|
22
|
+
* @group basic
|
|
23
|
+
* @shortname verts
|
|
24
|
+
* @drawable false
|
|
25
|
+
*/
|
|
8
26
|
verts(inputs: Inputs.Manifold.MeshTriangleIndexDto<Manifold3D.Mesh>): number[];
|
|
27
|
+
/**
|
|
28
|
+
* Gets the tangent vector starting at verts(tri)[j] pointing to the next
|
|
29
|
+
* Bezier point along the CCW edge. The fourth value is its weight.
|
|
30
|
+
* @param inputs mesh
|
|
31
|
+
* @returns tangent
|
|
32
|
+
* @group basic
|
|
33
|
+
* @shortname tangent
|
|
34
|
+
* @drawable true
|
|
35
|
+
*/
|
|
36
|
+
tangent(inputs: Inputs.Manifold.MeshHalfEdgeIndexDto<Manifold3D.Mesh>): number[];
|
|
37
|
+
/**
|
|
38
|
+
* Gets any other properties associated with this vertex.
|
|
39
|
+
* @param inputs mesh
|
|
40
|
+
* @returns extras
|
|
41
|
+
* @group basic
|
|
42
|
+
* @shortname extras
|
|
43
|
+
* @drawable false
|
|
44
|
+
*/
|
|
9
45
|
extras(inputs: Inputs.Manifold.MeshVertexIndexDto<Manifold3D.Mesh>): number[];
|
|
46
|
+
/**
|
|
47
|
+
* Gets the column-major 4x4 matrix transform from the original mesh to these
|
|
48
|
+
* related triangles.
|
|
49
|
+
* @param inputs mesh
|
|
50
|
+
* @returns transform matrix
|
|
51
|
+
* @group basic
|
|
52
|
+
* @shortname transform 4x4 matrix
|
|
53
|
+
* @drawable false
|
|
54
|
+
*/
|
|
10
55
|
transform(inputs: Inputs.Manifold.MeshTriangleRunIndexDto<Manifold3D.Mesh>): number[];
|
|
56
|
+
/**
|
|
57
|
+
* Number of properties per vertex, always >= 3.
|
|
58
|
+
* @param inputs mesh
|
|
59
|
+
* @returns number of properties
|
|
60
|
+
* @group basic
|
|
61
|
+
* @shortname number props
|
|
62
|
+
* @drawable false
|
|
63
|
+
*/
|
|
11
64
|
numProp(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): number;
|
|
65
|
+
/**
|
|
66
|
+
* Number of property vertices
|
|
67
|
+
* @param inputs mesh
|
|
68
|
+
* @returns number of vertices
|
|
69
|
+
* @group basic
|
|
70
|
+
* @shortname number vertices
|
|
71
|
+
* @drawable false
|
|
72
|
+
*/
|
|
12
73
|
numVert(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): number;
|
|
74
|
+
/**
|
|
75
|
+
* Get number of triangles on mesh
|
|
76
|
+
* @param inputs mesh
|
|
77
|
+
* @returns number of triangles
|
|
78
|
+
* @group basic
|
|
79
|
+
* @shortname number triangles
|
|
80
|
+
* @drawable false
|
|
81
|
+
*/
|
|
13
82
|
numTri(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): number;
|
|
83
|
+
/**
|
|
84
|
+
* Number of triangle runs. Each triangle run is a set of consecutive
|
|
85
|
+
* triangles that all come from the same instance of the same input mesh.
|
|
86
|
+
* @param inputs mesh
|
|
87
|
+
* @returns number of runs
|
|
88
|
+
* @group basic
|
|
89
|
+
* @shortname number runs
|
|
90
|
+
* @drawable false
|
|
91
|
+
*/
|
|
14
92
|
numRun(inputs: Inputs.Manifold.MeshDto<Manifold3D.Mesh>): number;
|
|
15
93
|
}
|