@meshinspector/meshlib 3.1.3-337 → 3.1.4-297
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 +64 -18
- package/bindings.d.mts +1696 -163
- package/index.d.mts +11 -174
- package/meshlib.mjs +123 -136
- package/meshlib.node.mjs +151 -160
- package/meshlib.node.wasm +0 -0
- package/meshlib.wasm +0 -0
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -1,189 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* TypeScript surface for @meshinspector/meshlib (this file is the package's `types` entry).
|
|
3
3
|
*
|
|
4
|
-
* `bindings.d.mts
|
|
5
|
-
*
|
|
6
|
-
* typed there, and re-exported unchanged by the `export *` below.
|
|
4
|
+
* Everything that crosses the JS boundary is precisely typed in `bindings.d.mts`, generated from the
|
|
5
|
+
* embind registry by Emscripten's `--emit-tsd`, and re-exported unchanged by the `export *` below.
|
|
7
6
|
*
|
|
8
|
-
* This
|
|
9
|
-
*
|
|
10
|
-
* typed-array converters, the `val` parameters, and the progress-callback setter.
|
|
11
|
-
*
|
|
12
|
-
* Mechanism: an exported local declaration shadows the same-named `export *` re-export, so the
|
|
13
|
-
* aliases below refine the generated ones. `MeshLibModule` `Omit`s the dynamic members from the
|
|
14
|
-
* generated module type and re-adds them with precise signatures. Everything references
|
|
15
|
-
* `Base.<name>`, so if a refined name ever drifts from the bindings the reference fails to
|
|
16
|
-
* resolve and `tsc` errors here instead of shipping a wrong type.
|
|
7
|
+
* This file adds only what `--emit-tsd` cannot generate: the default-export factory under its real
|
|
8
|
+
* name with typed options.
|
|
17
9
|
*
|
|
18
10
|
* The specifier `./bindings.mjs` resolves (type-only) to `bindings.d.mts`; there is no runtime
|
|
19
|
-
* `bindings.mjs` and none is needed —
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
* Refined instance types apply when a value is typed via the exported type — e.g.
|
|
23
|
-
* `ml.VertCoords.fromArray(a)` or `const m: Mesh = ...`. A value reached only through an
|
|
24
|
-
* un-refined return chain may still surface `any` at the deepest instance call; annotate with
|
|
25
|
-
* the exported type to recover precision.
|
|
11
|
+
* `bindings.mjs` and none is needed — the actual runtime exports come from `meshlib.mjs` (the package
|
|
12
|
+
* `exports.import`).
|
|
26
13
|
*/
|
|
27
|
-
import type
|
|
14
|
+
import type { MainModule } from './bindings.mjs';
|
|
28
15
|
|
|
29
16
|
export * from './bindings.mjs';
|
|
30
17
|
|
|
31
|
-
// ---- Result shapes (built as emscripten::val objects by the bindings) --------------------
|
|
32
|
-
|
|
33
|
-
export interface PointOnFace {
|
|
34
|
-
face: number;
|
|
35
|
-
point: Base.Vector3f;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export interface MeshTriPoint {
|
|
39
|
-
e: number;
|
|
40
|
-
bary: { a: number; b: number };
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export interface MeshProjectionResult {
|
|
44
|
-
proj: PointOnFace;
|
|
45
|
-
mtp: MeshTriPoint;
|
|
46
|
-
distSq: number;
|
|
47
|
-
valid: boolean;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export interface SignedMeshProjectionResult {
|
|
51
|
-
proj: PointOnFace;
|
|
52
|
-
mtp: MeshTriPoint;
|
|
53
|
-
dist: number;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export interface MeshDistanceResult {
|
|
57
|
-
a: PointOnFace;
|
|
58
|
-
b: PointOnFace;
|
|
59
|
-
distSq: number;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export interface CutMeshResult {
|
|
63
|
-
resultCut: Uint32Array[];
|
|
64
|
-
fbsWithContourIntersections: Base.FaceBitSet;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export interface ComponentsMapResult {
|
|
68
|
-
map: Face2RegionMap;
|
|
69
|
-
numRegions: number;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
export interface LargeByAreaRegionsResult {
|
|
73
|
-
faces: Base.FaceBitSet;
|
|
74
|
-
numRegions: number;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export interface GridMinMax {
|
|
78
|
-
min: number;
|
|
79
|
-
max: number;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// The MeshComponents::FaceIncidence enum, taken from a sibling method's signature so the exact
|
|
83
|
-
// generated enum-type name never has to be guessed.
|
|
84
|
-
type FaceIncidence = Parameters<Base.MainModule['MeshComponents']['getComponent']>[2];
|
|
85
|
-
|
|
86
|
-
// ---- Refined instance types --------------------------------------------------------------
|
|
87
|
-
// A local `export` shadows the same-named `export *` re-export from the generated base.
|
|
88
|
-
|
|
89
|
-
type WithToArray<T, A> = Omit<T, 'toArray'> & { toArray(): A };
|
|
90
|
-
type WithToIndices<T> = Omit<T, 'toIndices'> & { toIndices(): Uint32Array };
|
|
91
|
-
|
|
92
|
-
export type VertCoords = WithToArray<Base.VertCoords, Float32Array>;
|
|
93
|
-
export type FaceNormals = WithToArray<Base.FaceNormals, Float32Array>;
|
|
94
|
-
export type Triangulation = WithToArray<Base.Triangulation, Uint32Array>;
|
|
95
|
-
export type VertMap = WithToArray<Base.VertMap, Uint32Array>;
|
|
96
|
-
export type FaceMap = WithToArray<Base.FaceMap, Uint32Array>;
|
|
97
|
-
export type Face2RegionMap = WithToArray<Base.Face2RegionMap, Uint32Array>;
|
|
98
|
-
export type VertColors = WithToArray<Base.VertColors, Uint8Array>;
|
|
99
|
-
|
|
100
|
-
export type BitSet = WithToIndices<Base.BitSet>;
|
|
101
|
-
export type FaceBitSet = WithToIndices<Base.FaceBitSet>;
|
|
102
|
-
export type VertBitSet = WithToIndices<Base.VertBitSet>;
|
|
103
|
-
export type EdgeBitSet = WithToIndices<Base.EdgeBitSet>;
|
|
104
|
-
export type UndirectedEdgeBitSet = WithToIndices<Base.UndirectedEdgeBitSet>;
|
|
105
|
-
|
|
106
|
-
export type MeshTopology = Omit<Base.MeshTopology, 'getTriangulation'> & {
|
|
107
|
-
getTriangulation(): Triangulation;
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export type Mesh = Omit<Base.Mesh, 'points' | 'topology' | 'toTriPoint'> & {
|
|
111
|
-
readonly points: VertCoords;
|
|
112
|
-
readonly topology: MeshTopology;
|
|
113
|
-
toTriPoint( f: number, p: Base.Vector3f ): MeshTriPoint;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export type SelfIntersectionsSettings = Omit<Base.SelfIntersectionsSettings, 'callback'> & {
|
|
117
|
-
// setter accepts a JS callback; embind emits the getter, so the base sees only `any`.
|
|
118
|
-
callback: ( progress: number ) => boolean;
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
// ---- Refined module surface --------------------------------------------------------------
|
|
122
|
-
|
|
123
|
-
type WithFromArray<M, A, R> = Omit<M, 'fromArray'> & { fromArray( array: A ): R };
|
|
124
|
-
// The bitset module members carry a nullary constructor; `Omit` drops construct signatures, so
|
|
125
|
-
// re-add `new()` alongside the refined `fromIndices` to keep `new ml.FaceBitSet()` working.
|
|
126
|
-
type WithFromIndices<M, R> = Omit<M, 'fromIndices'> & {
|
|
127
|
-
new(): R;
|
|
128
|
-
fromIndices( indices: readonly number[] | Uint32Array ): R;
|
|
129
|
-
};
|
|
130
|
-
|
|
131
|
-
// Static `fromArray` converters (module-side); return the refined instance types above.
|
|
132
|
-
type Converters = {
|
|
133
|
-
VertCoords: WithFromArray<Base.MainModule['VertCoords'], Float32Array, VertCoords>;
|
|
134
|
-
FaceNormals: WithFromArray<Base.MainModule['FaceNormals'], Float32Array, FaceNormals>;
|
|
135
|
-
Triangulation: WithFromArray<Base.MainModule['Triangulation'], Uint32Array, Triangulation>;
|
|
136
|
-
VertMap: WithFromArray<Base.MainModule['VertMap'], Uint32Array, VertMap>;
|
|
137
|
-
FaceMap: WithFromArray<Base.MainModule['FaceMap'], Uint32Array, FaceMap>;
|
|
138
|
-
Face2RegionMap: WithFromArray<Base.MainModule['Face2RegionMap'], Uint32Array, Face2RegionMap>;
|
|
139
|
-
VertColors: WithFromArray<Base.MainModule['VertColors'], Uint8Array, VertColors>;
|
|
140
|
-
BitSet: WithFromIndices<Base.MainModule['BitSet'], BitSet>;
|
|
141
|
-
FaceBitSet: WithFromIndices<Base.MainModule['FaceBitSet'], FaceBitSet>;
|
|
142
|
-
VertBitSet: WithFromIndices<Base.MainModule['VertBitSet'], VertBitSet>;
|
|
143
|
-
EdgeBitSet: WithFromIndices<Base.MainModule['EdgeBitSet'], EdgeBitSet>;
|
|
144
|
-
UndirectedEdgeBitSet: WithFromIndices<Base.MainModule['UndirectedEdgeBitSet'], UndirectedEdgeBitSet>;
|
|
145
|
-
};
|
|
146
|
-
|
|
147
|
-
// Top-level free functions that return / accept a raw `val`.
|
|
148
|
-
type Functions = {
|
|
149
|
-
findProjection( pt: Base.Vector3f, m: Base.Mesh ): MeshProjectionResult;
|
|
150
|
-
findSignedDistance( pt: Base.Vector3f, m: Base.Mesh ): SignedMeshProjectionResult | null;
|
|
151
|
-
findDistance( a: Base.Mesh, b: Base.Mesh ): MeshDistanceResult;
|
|
152
|
-
cutMesh( mesh: Base.Mesh, contours: Base.OneMeshContours, params: Base.CutMeshParameters ): CutMeshResult;
|
|
153
|
-
cutMeshByProjection( mesh: Base.Mesh, contours: readonly Float32Array[], settings: Base.CutByProjectionSettings ): Uint32Array[];
|
|
154
|
-
findRightBoundary( topology: Base.MeshTopology ): Uint32Array[];
|
|
155
|
-
fillHoles( mesh: Base.Mesh, edges: readonly number[] | Uint32Array, params: Base.FillHoleParams ): void;
|
|
156
|
-
evalGridMinMax( grid: Base.FloatGrid ): GridMinMax;
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
// Tag-struct module-classes with `val`-returning static methods.
|
|
160
|
-
type ModuleClasses = {
|
|
161
|
-
MeshComponents: Omit<Base.MainModule['MeshComponents'], 'getAllComponents' | 'getAllComponentsMap' | 'getLargeByAreaRegions'> & {
|
|
162
|
-
getAllComponents( m: Base.Mesh, inc: FaceIncidence ): Base.FaceBitSet[];
|
|
163
|
-
getAllComponentsMap( m: Base.Mesh, inc: FaceIncidence ): ComponentsMapResult;
|
|
164
|
-
getLargeByAreaRegions( m: Base.Mesh, face2RegionMap: Base.Face2RegionMap, numRegions: number, minArea: number ): LargeByAreaRegionsResult;
|
|
165
|
-
};
|
|
166
|
-
VoxelsLoad: Omit<Base.MainModule['VoxelsLoad'], 'fromAnySupportedFormat'> & {
|
|
167
|
-
fromAnySupportedFormat( path: string ): Base.VdbVolume[];
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// Deliberately left as generated (`any`): the `MultiwayICP` constructor's `val` argument — its
|
|
172
|
-
// module member is a construct signature, which `Omit` cannot target without dropping any other
|
|
173
|
-
// statics; refine as a follow-up if a precise `MeshOrPointsXf[]` input is wanted.
|
|
174
|
-
|
|
175
|
-
export type MeshLibModule =
|
|
176
|
-
Omit<Base.MainModule, keyof Converters | keyof Functions | keyof ModuleClasses>
|
|
177
|
-
& Converters
|
|
178
|
-
& Functions
|
|
179
|
-
& ModuleClasses;
|
|
180
|
-
|
|
181
18
|
/** Options for the module factory (the Emscripten `Module` object). All optional. */
|
|
182
19
|
export interface CreateMeshLibOptions {
|
|
183
20
|
/**
|
|
184
|
-
* Resolve the URL of a runtime file — most importantly the sidecar `.wasm`. Bundlers
|
|
185
|
-
* pass this pointing at
|
|
186
|
-
* README.
|
|
21
|
+
* Resolve the URL of a runtime file — most importantly the sidecar `.wasm`. Bundlers that do
|
|
22
|
+
* not emit the wasm on their own should pass this pointing at an asset-URL import of the wasm;
|
|
23
|
+
* see "Using with bundlers" in the README.
|
|
187
24
|
*/
|
|
188
25
|
locateFile?: ( path: string, scriptDirectory: string ) => string;
|
|
189
26
|
/** Multi-threaded build only: URL or Blob of the main script, so pthread workers can load it. */
|
|
@@ -192,5 +29,5 @@ export interface CreateMeshLibOptions {
|
|
|
192
29
|
printErr?: ( text: string ) => void;
|
|
193
30
|
}
|
|
194
31
|
|
|
195
|
-
declare function createMeshLib( options?: CreateMeshLibOptions ): Promise<
|
|
32
|
+
declare function createMeshLib( options?: CreateMeshLibOptions ): Promise<MainModule>;
|
|
196
33
|
export default createMeshLib;
|