@meshinspector/meshlib-mt 3.1.3-429 → 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 +31 -14
- package/bindings.d.mts +3 -3
- package/index.d.mts +3 -3
- package/meshlib-mt.mjs +1 -1
- package/meshlib-mt.node.mjs +1 -1
- package/meshlib-mt.node.wasm +0 -0
- package/meshlib-mt.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,14 +20,21 @@ npm install @meshinspector/meshlib-mt
|
|
|
20
20
|
|
|
21
21
|
## Use from CDN
|
|
22
22
|
|
|
23
|
-
In the browser you can
|
|
23
|
+
In the browser you can load the module from the CDN instead of npm, but the browser refuses to run a worker
|
|
24
|
+
script from another origin, so pass the fetched module to the factory as a `Blob` and its worker pool starts
|
|
25
|
+
from a same-origin `blob:` URL:
|
|
24
26
|
|
|
25
27
|
```js
|
|
26
|
-
// latest
|
|
27
|
-
|
|
28
|
+
// latest release
|
|
29
|
+
const url = 'https://js.meshlib.io/meshlib-mt/meshlib-mt.mjs';
|
|
28
30
|
|
|
29
|
-
// or pin a
|
|
30
|
-
|
|
31
|
+
// or pin a release
|
|
32
|
+
// const url = 'https://js.meshlib.io/meshlib-mt@v1.2.3.456/meshlib-mt.mjs';
|
|
33
|
+
|
|
34
|
+
const { default: createMeshLib } = await import( url );
|
|
35
|
+
const blob = new Blob( [ await ( await fetch( url ) ).text() ], { type: 'text/javascript' } );
|
|
36
|
+
|
|
37
|
+
const ml = await createMeshLib( { mainScriptUrlOrBlob: blob } );
|
|
31
38
|
```
|
|
32
39
|
|
|
33
40
|
## Browser requirements: cross-origin isolation
|
|
@@ -65,6 +72,9 @@ export default {
|
|
|
65
72
|
The default export is an async factory. Await it once to get the module instance, then call
|
|
66
73
|
MeshLib functions on it:
|
|
67
74
|
|
|
75
|
+
> `using` requires Node.js 24+ or a current browser. On older runtimes, call `.delete()`
|
|
76
|
+
> instead — see [Memory management](#memory-management).
|
|
77
|
+
|
|
68
78
|
```js
|
|
69
79
|
import createMeshLib from '@meshinspector/meshlib-mt';
|
|
70
80
|
|
|
@@ -88,37 +98,44 @@ console.log('volume =', mesh.volume()); // ~8
|
|
|
88
98
|
// `using` frees these WebAssembly-backed objects automatically at the end of scope
|
|
89
99
|
```
|
|
90
100
|
|
|
91
|
-
> `using` requires Node.js 24+ or a current browser. On older runtimes, call `.delete()`
|
|
92
|
-
> instead — see [Memory management](#memory-management).
|
|
93
|
-
|
|
94
101
|
## Using with bundlers
|
|
95
102
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`locateFile`:
|
|
103
|
+
Vite 8 and webpack 5 resolve `meshlib-mt.wasm` from the module and emit it as an asset, so a plain `import`
|
|
104
|
+
needs no configuration. For other bundlers, such as esbuild or Rollup, import the wasm as an asset URL
|
|
105
|
+
and hand it to the loader via `locateFile`:
|
|
99
106
|
|
|
100
107
|
```js
|
|
101
108
|
import createMeshLib from '@meshinspector/meshlib-mt';
|
|
102
|
-
import wasmUrl from '@meshinspector/meshlib-mt/meshlib-mt.wasm
|
|
109
|
+
import wasmUrl from '@meshinspector/meshlib-mt/meshlib-mt.wasm';
|
|
103
110
|
|
|
104
111
|
const ml = await createMeshLib( { locateFile: () => wasmUrl } );
|
|
105
112
|
```
|
|
106
113
|
|
|
114
|
+
The bundler must treat `.wasm` files as static assets, so that the import resolves to the URL of the
|
|
115
|
+
emitted file; the option is usually called an asset or file loader. For example:
|
|
116
|
+
|
|
117
|
+
- **esbuild**: pass `--loader:.wasm=file`
|
|
118
|
+
- **Rollup**: add `@rollup/plugin-url` with `include: /\.wasm$/`
|
|
119
|
+
- **Parcel**: use the `url:` scheme on the import specifier: `import wasmUrl from 'url:@meshinspector/meshlib-mt/meshlib-mt.wasm';`
|
|
120
|
+
|
|
107
121
|
The page must also be [cross-origin isolated](#browser-requirements-cross-origin-isolation).
|
|
108
122
|
|
|
109
123
|
## TypeScript
|
|
110
124
|
|
|
111
125
|
The package ships type definitions, so `createMeshLib` and the whole module API are typed with
|
|
112
|
-
|
|
126
|
+
minimal setup:
|
|
113
127
|
|
|
114
128
|
```ts
|
|
115
129
|
import createMeshLib, { type Mesh } from '@meshinspector/meshlib-mt';
|
|
116
130
|
|
|
117
131
|
const ml = await createMeshLib();
|
|
118
|
-
|
|
132
|
+
const mesh: Mesh = ml.Mesh.fromTriangles(coords, tris)!;
|
|
119
133
|
const { valid, distSq } = ml.findProjection(point, mesh);
|
|
134
|
+
mesh.delete();
|
|
120
135
|
```
|
|
121
136
|
|
|
137
|
+
Also make sure to add `"type": "module"` to your package.json.
|
|
138
|
+
|
|
122
139
|
## Memory management
|
|
123
140
|
|
|
124
141
|
Values returned from the API (meshes, bit sets, settings, result objects, …) hold
|
package/bindings.d.mts
CHANGED
|
@@ -1245,7 +1245,7 @@ export interface OffsetParameters extends BaseShellParameters {
|
|
|
1245
1245
|
*/
|
|
1246
1246
|
memoryEfficient: boolean;
|
|
1247
1247
|
/**
|
|
1248
|
-
*
|
|
1248
|
+
* determines the method to compute distance sign; offsetMesh implementing OffsetMode::Smooth supports only Unsigned, OpenVDB and HoleWindingRule here
|
|
1249
1249
|
*/
|
|
1250
1250
|
signDetectionMode: SignDetectionMode;
|
|
1251
1251
|
}
|
|
@@ -1705,7 +1705,7 @@ interface EmbindModule {
|
|
|
1705
1705
|
*/
|
|
1706
1706
|
fromTriangles(vertexCoordinates: VertCoords, t: Triangulation): Mesh | null;
|
|
1707
1707
|
/**
|
|
1708
|
-
* construct mesh from vertex coordinates and a set of triangles with given ids; unlike simple fromTriangles() it tries to resolve non-manifold vertices by creating duplicate vertices
|
|
1708
|
+
* construct mesh from vertex coordinates and a set of triangles with given ids; unlike simple fromTriangles() it tries to resolve non-manifold vertices by creating duplicate vertices; `betterCont` (if given) selects the best triangle among several possible continuations during the duplication
|
|
1709
1709
|
*/
|
|
1710
1710
|
fromTrianglesDuplicatingNonManifoldVertices(vertexCoordinates: VertCoords, t: Triangulation): Mesh | null;
|
|
1711
1711
|
};
|
|
@@ -2270,7 +2270,7 @@ interface EmbindModule {
|
|
|
2270
2270
|
*/
|
|
2271
2271
|
getBoundaryVerts(topology: MeshTopology, region: FaceBitSet): VertBitSet;
|
|
2272
2272
|
/**
|
|
2273
|
-
*
|
|
2273
|
+
* @brief same as above, but writes the loop in `outLoop` (cleared first), so a caller tracking many loops one by one reuses its capacity
|
|
2274
2274
|
*/
|
|
2275
2275
|
trackRightBoundaryLoop(topology: MeshTopology, e0: number): Uint32Array;
|
|
2276
2276
|
/**
|
package/index.d.mts
CHANGED
|
@@ -18,9 +18,9 @@ export * from './bindings.mjs';
|
|
|
18
18
|
/** Options for the module factory (the Emscripten `Module` object). All optional. */
|
|
19
19
|
export interface CreateMeshLibOptions {
|
|
20
20
|
/**
|
|
21
|
-
* Resolve the URL of a runtime file — most importantly the sidecar `.wasm`. Bundlers
|
|
22
|
-
* pass this pointing at
|
|
23
|
-
* 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.
|
|
24
24
|
*/
|
|
25
25
|
locateFile?: ( path: string, scriptDirectory: string ) => string;
|
|
26
26
|
/** Multi-threaded build only: URL or Blob of the main script, so pthread workers can load it. */
|
package/meshlib-mt.mjs
CHANGED
|
@@ -150,7 +150,7 @@ c.Wb.count.value+=1;c.Wb.Rc=!1;return c},["delete"](){this.Wb.$b||qf(this);if(th
|
|
|
150
150
|
const b=Symbol.dispose;b&&(a[b]=a["delete"])})();
|
|
151
151
|
Object.assign(Mf.prototype,{Ud(a){this.Jd&&(a=this.Jd(a));return a},zd(a){this.yc?.(a)},tc:hf,ec:function(a){function b(){return this.dd?Lf(this.ac.Hc,{fc:this.ie,$b:c,rc:this,lc:a}):Lf(this.ac.Hc,{fc:this,$b:a})}var c=this.Ud(a);if(!c)return this.zd(a),null;var d=Kf(this.ac,c);if(void 0!==d){if(0===d.Wb.count.value)return d.Wb.$b=c,d.Wb.lc=a,d.clone();d=d.clone();this.zd(a);return d}d=this.ac.Td(c);d=xf[d];if(!d)return b.call(this);d=this.cd?d.Pd:d.pointerType;var e=If(c,this.ac,d.ac);return null===
|
|
152
152
|
e?b.call(this):this.dd?Lf(d.ac.Hc,{fc:d,$b:e,rc:this,lc:a}):Lf(d.ac.Hc,{fc:d,$b:e})}});n||(k.wasmMemory?pa=k.wasmMemory:pa=new WebAssembly.Memory({initial:(k.INITIAL_MEMORY||16777216)/65536,maximum:65536,shared:!0}),qa());k.noExitRuntime&&(Id=k.noExitRuntime);k.print&&(ja=k.print);k.printErr&&(p=k.printErr);k.wasmBinary&&(ka=k.wasmBinary);k.thisProgram&&(da=k.thisProgram);if(k.preInit)for("function"==typeof k.preInit&&(k.preInit=[k.preInit]);0<k.preInit.length;)k.preInit.shift()();
|
|
153
|
-
var og=[Hd,Jd,Yd,gb,hb,ib,jb,kb,lb,mb,nb,ob,pb,qb,rb,sb,tb,ub,vb,wb,xb,Bc,Cc,Ec,Fc,Gc,Hc,Ic],ng={
|
|
153
|
+
var og=[Hd,Jd,Yd,gb,hb,ib,jb,kb,lb,mb,nb,ob,pb,qb,rb,sb,tb,ub,vb,wb,xb,Bc,Cc,Ec,Fc,Gc,Hc,Ic],ng={2085260:a=>{throw Error(U(a));}},dd,Ba,ed,fd,gd,ya,Ea,hd,jd,kd,ld,H,md,nd,I,od,J,pd,qd,rd,sd,td,Ya;function Kc(a,b){var c=J();try{return L(a)(b)}catch(d){I(c);if(d!==d+0)throw d;H(1,0)}}function Xc(a,b,c,d){var e=J();try{L(a)(b,c,d)}catch(f){I(e);if(f!==f+0)throw f;H(1,0)}}function Oc(a,b,c,d,e){var f=J();try{return L(a)(b,c,d,e)}catch(g){I(f);if(g!==g+0)throw g;H(1,0)}}
|
|
154
154
|
function Pc(a,b,c,d,e,f){var g=J();try{return L(a)(b,c,d,e,f)}catch(h){I(g);if(h!==h+0)throw h;H(1,0)}}function Vc(a,b){var c=J();try{L(a)(b)}catch(d){I(c);if(d!==d+0)throw d;H(1,0)}}function Wc(a,b,c){var d=J();try{L(a)(b,c)}catch(e){I(d);if(e!==e+0)throw e;H(1,0)}}function Nc(a,b,c,d){var e=J();try{return L(a)(b,c,d)}catch(f){I(e);if(f!==f+0)throw f;H(1,0)}}function Mc(a,b,c){var d=J();try{return L(a)(b,c)}catch(e){I(d);if(e!==e+0)throw e;H(1,0)}}
|
|
155
155
|
function Uc(a){var b=J();try{L(a)()}catch(c){I(b);if(c!==c+0)throw c;H(1,0)}}function Lc(a,b,c){var d=J();try{return L(a)(b,c)}catch(e){I(d);if(e!==e+0)throw e;H(1,0)}}function Zc(a,b,c,d,e,f){var g=J();try{L(a)(b,c,d,e,f)}catch(h){I(g);if(h!==h+0)throw h;H(1,0)}}function Yc(a,b,c,d,e){var f=J();try{L(a)(b,c,d,e)}catch(g){I(f);if(g!==g+0)throw g;H(1,0)}}function Rc(a,b,c,d,e,f,g,h,m,l,q){var t=J();try{return L(a)(b,c,d,e,f,g,h,m,l,q)}catch(r){I(t);if(r!==r+0)throw r;H(1,0)}}
|
|
156
156
|
function Jc(a){var b=J();try{return L(a)()}catch(c){I(b);if(c!==c+0)throw c;H(1,0)}}function $c(a,b,c,d,e,f,g){var h=J();try{L(a)(b,c,d,e,f,g)}catch(m){I(h);if(m!==m+0)throw m;H(1,0)}}function Qc(a,b,c,d,e,f,g,h){var m=J();try{return L(a)(b,c,d,e,f,g,h)}catch(l){I(m);if(l!==l+0)throw l;H(1,0)}}function Sc(a,b){var c=J();try{return L(a)(b)}catch(d){I(c);if(d!==d+0)throw d;H(1,0)}}function Tc(a,b,c,d,e,f){var g=J();try{return L(a)(b,c,d,e,f)}catch(h){I(g);if(h!==h+0)throw h;H(1,0)}}
|
package/meshlib-mt.node.mjs
CHANGED
|
@@ -184,7 +184,7 @@ c.Xb.count.value+=1;c.Xb.Zc=!1;return c},["delete"](){this.Xb.ac||vf(this);if(th
|
|
|
184
184
|
const b=Symbol.dispose;b&&(a[b]=a["delete"])})();
|
|
185
185
|
Object.assign(Rf.prototype,{ve(a){this.ae&&(a=this.ae(a));return a},Pd(a){this.Dc?.(a)},zc:mf,dc:function(a){function b(){return this.ld?Qf(this.bc.Lc,{hc:this.Ie,ac:c,tc:this,qc:a}):Qf(this.bc.Lc,{hc:this,ac:a})}var c=this.ve(a);if(!c)return this.Pd(a),null;var d=Pf(this.bc,c);if(void 0!==d){if(0===d.Xb.count.value)return d.Xb.ac=c,d.Xb.qc=a,d.clone();d=d.clone();this.Pd(a);return d}d=this.bc.te(c);d=Cf[d];if(!d)return b.call(this);d=this.kd?d.le:d.pointerType;var e=Nf(c,this.bc,d.bc);return null===
|
|
186
186
|
e?b.call(this):this.ld?Qf(d.bc.Lc,{hc:d,ac:e,tc:this,qc:a}):Qf(d.bc.Lc,{hc:d,ac:e})}});q||(g.wasmMemory?ua=g.wasmMemory:ua=new WebAssembly.Memory({initial:(g.INITIAL_MEMORY||16777216)/65536,maximum:65536,shared:!0}),va());g.noExitRuntime&&(Ld=g.noExitRuntime);g.preloadPlugins&&(He=g.preloadPlugins);g.print&&(pa=g.print);g.printErr&&(u=g.printErr);g.wasmBinary&&(qa=g.wasmBinary);g.thisProgram&&(da=g.thisProgram);if(g.preInit)for("function"==typeof g.preInit&&(g.preInit=[g.preInit]);0<g.preInit.length;)g.preInit.shift()();
|
|
187
|
-
var sg=[Kd,Md,$d,hb,ib,jb,kb,lb,mb,nb,ob,pb,qb,rb,sb,tb,ub,vb,wb,xb,yb,Cc,Dc,Fc,Gc,Hc,Ic,Jc],rg={
|
|
187
|
+
var sg=[Kd,Md,$d,hb,ib,jb,kb,lb,mb,nb,ob,pb,qb,rb,sb,tb,ub,vb,wb,xb,yb,Cc,Dc,Fc,Gc,Hc,Ic,Jc],rg={2085260:a=>{throw Error(U(a));}},ed,Ha,fd,gd,hd,Ea,Ka,jd,kd,ld,md,H,nd,od,I,pd,J,qd,rd,sd,td,ud,Za;function Lc(a,b){var c=J();try{return L(a)(b)}catch(d){I(c);if(d!==d+0)throw d;H(1,0)}}function Yc(a,b,c,d){var e=J();try{L(a)(b,c,d)}catch(f){I(e);if(f!==f+0)throw f;H(1,0)}}function Pc(a,b,c,d,e){var f=J();try{return L(a)(b,c,d,e)}catch(h){I(f);if(h!==h+0)throw h;H(1,0)}}
|
|
188
188
|
function Qc(a,b,c,d,e,f){var h=J();try{return L(a)(b,c,d,e,f)}catch(k){I(h);if(k!==k+0)throw k;H(1,0)}}function Wc(a,b){var c=J();try{L(a)(b)}catch(d){I(c);if(d!==d+0)throw d;H(1,0)}}function Xc(a,b,c){var d=J();try{L(a)(b,c)}catch(e){I(d);if(e!==e+0)throw e;H(1,0)}}function Oc(a,b,c,d){var e=J();try{return L(a)(b,c,d)}catch(f){I(e);if(f!==f+0)throw f;H(1,0)}}function Nc(a,b,c){var d=J();try{return L(a)(b,c)}catch(e){I(d);if(e!==e+0)throw e;H(1,0)}}
|
|
189
189
|
function Vc(a){var b=J();try{L(a)()}catch(c){I(b);if(c!==c+0)throw c;H(1,0)}}function Mc(a,b,c){var d=J();try{return L(a)(b,c)}catch(e){I(d);if(e!==e+0)throw e;H(1,0)}}function $c(a,b,c,d,e,f){var h=J();try{L(a)(b,c,d,e,f)}catch(k){I(h);if(k!==k+0)throw k;H(1,0)}}function Zc(a,b,c,d,e){var f=J();try{L(a)(b,c,d,e)}catch(h){I(f);if(h!==h+0)throw h;H(1,0)}}function Sc(a,b,c,d,e,f,h,k,n,m,p){var r=J();try{return L(a)(b,c,d,e,f,h,k,n,m,p)}catch(t){I(r);if(t!==t+0)throw t;H(1,0)}}
|
|
190
190
|
function Kc(a){var b=J();try{return L(a)()}catch(c){I(b);if(c!==c+0)throw c;H(1,0)}}function ad(a,b,c,d,e,f,h){var k=J();try{L(a)(b,c,d,e,f,h)}catch(n){I(k);if(n!==n+0)throw n;H(1,0)}}function Rc(a,b,c,d,e,f,h,k){var n=J();try{return L(a)(b,c,d,e,f,h,k)}catch(m){I(n);if(m!==m+0)throw m;H(1,0)}}function Tc(a,b){var c=J();try{return L(a)(b)}catch(d){I(c);if(d!==d+0)throw d;H(1,0)}}function Uc(a,b,c,d,e,f){var h=J();try{return L(a)(b,c,d,e,f)}catch(k){I(h);if(k!==k+0)throw k;H(1,0)}}
|
package/meshlib-mt.node.wasm
CHANGED
|
Binary file
|
package/meshlib-mt.wasm
CHANGED
|
Binary file
|