@meshinspector/meshlib 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 CHANGED
@@ -23,18 +23,25 @@ npm install @meshinspector/meshlib
23
23
  In the browser you can skip npm entirely and import the module directly:
24
24
 
25
25
  ```js
26
- // latest version
26
+ // latest release
27
27
  import createMeshLib from 'https://js.meshlib.io/meshlib/meshlib.mjs';
28
28
 
29
- // or pin a specific version
30
- import createMeshLib from 'https://js.meshlib.io/meshlib@1.2.3/meshlib.mjs';
29
+ // or pin a release — v1.2.3.456 is an example tag, not a real one
30
+ import createMeshLib from 'https://js.meshlib.io/meshlib@v1.2.3.456/meshlib.mjs';
31
31
  ```
32
32
 
33
+ To pin, take a real tag from the [releases page](https://github.com/MeshInspector/MeshLib/releases): it has a
34
+ leading `v` and four components, and is **not** the npm version — the tag `v1.2.3.456` would be npm `1.2.3-456`.
35
+ Pinned URLs are immutable, so a pin never changes under you; the unpinned path always serves the latest release.
36
+
33
37
  ## Usage
34
38
 
35
39
  The default export is an async factory. Await it once to get the module instance, then
36
40
  call MeshLib functions on it:
37
41
 
42
+ > `using` requires Node.js 24+ or a current browser. On older runtimes, call `.delete()`
43
+ > instead — see [Memory management](#memory-management).
44
+
38
45
  ```js
39
46
  import createMeshLib from '@meshinspector/meshlib';
40
47
 
@@ -58,34 +65,42 @@ console.log('volume =', mesh.volume()); // ~8
58
65
  // `using` frees these WebAssembly-backed objects automatically at the end of scope
59
66
  ```
60
67
 
61
- > `using` requires Node.js 24+ or a current browser. On older runtimes, call `.delete()`
62
- > instead — see [Memory management](#memory-management).
63
-
64
68
  ## Using with bundlers
65
69
 
66
- Bundlers (Vite, webpack, Rollup) hash and relocate the sidecar `meshlib.wasm`, so the module can't
67
- locate it on its own. Import the wasm as an asset URL and hand it to the loader via `locateFile`:
70
+ Vite 8 and webpack 5 resolve `meshlib.wasm` from the module and emit it as an asset, so a plain `import`
71
+ needs no configuration. For other bundlers, such as esbuild or Rollup, import the wasm as an asset URL
72
+ and hand it to the loader via `locateFile`:
68
73
 
69
74
  ```js
70
75
  import createMeshLib from '@meshinspector/meshlib';
71
- import wasmUrl from '@meshinspector/meshlib/meshlib.wasm?url';
76
+ import wasmUrl from '@meshinspector/meshlib/meshlib.wasm';
72
77
 
73
78
  const ml = await createMeshLib( { locateFile: () => wasmUrl } );
74
79
  ```
75
80
 
81
+ The bundler must treat `.wasm` files as static assets, so that the import resolves to the URL of the
82
+ emitted file; the option is usually called an asset or file loader. For example:
83
+
84
+ - **esbuild**: pass `--loader:.wasm=file`
85
+ - **Rollup**: add `@rollup/plugin-url` with `include: /\.wasm$/`
86
+ - **Parcel**: use the `url:` scheme on the import specifier: `import wasmUrl from 'url:@meshinspector/meshlib/meshlib.wasm';`
87
+
76
88
  ## TypeScript
77
89
 
78
90
  The package ships type definitions, so `createMeshLib` and the whole module API are typed with
79
- no extra setup:
91
+ minimal setup:
80
92
 
81
93
  ```ts
82
94
  import createMeshLib, { type Mesh } from '@meshinspector/meshlib';
83
95
 
84
96
  const ml = await createMeshLib();
85
- using mesh: Mesh = ml.Mesh.fromTriangles(coords, tris);
97
+ const mesh: Mesh = ml.Mesh.fromTriangles(coords, tris)!;
86
98
  const { valid, distSq } = ml.findProjection(point, mesh);
99
+ mesh.delete();
87
100
  ```
88
101
 
102
+ Also make sure to add `"type": "module"` to your package.json.
103
+
89
104
  ## Memory management
90
105
 
91
106
  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
- * @brief determines the method to compute distance sign
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
- * returns closed loop of region boundary starting from given region boundary edge (region faces on the right, and not-region faces or holes on the left); if more than two boundary edges connect in one vertex, then the function makes the most abrupt turn to left
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 should
22
- * pass this pointing at a `?url` import of the wasm; see "Using with Vite / bundlers" in the
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.mjs CHANGED
@@ -77,7 +77,7 @@ c.Bb.count.value+=1;c.Bb.uc=!1;return c},["delete"](){this.Bb.Db||gc(this);if(th
77
77
  const b=Symbol.dispose;b&&(a[b]=a["delete"])})();
78
78
  Object.assign(Bc.prototype,{td(a){this.kd&&(a=this.kd(a));return a},$c(a){this.bc?.(a)},Yb:Zb,Kb:function(a){function b(){return this.Hc?Ac(this.Gb.kc,{Lb:this.Gd,Db:c,Wb:this,Qb:a}):Ac(this.Gb.kc,{Lb:this,Db:a})}var c=this.td(a);if(!c)return this.$c(a),null;var d=zc(this.Gb,c);if(void 0!==d){if(0===d.Bb.count.value)return d.Bb.Db=c,d.Bb.Qb=a,d.clone();d=d.clone();this.$c(a);return d}d=this.Gb.sd(c);d=nc[d];if(!d)return b.call(this);d=this.Gc?d.od:d.pointerType;var e=xc(c,this.Gb,d.Gb);return null===
79
79
  e?b.call(this):this.Hc?Ac(d.Gb.kc,{Lb:d,Db:e,Wb:this,Qb:a}):Ac(d.Gb.kc,{Lb:d,Db:e})}});m.noExitRuntime&&(Ga=m.noExitRuntime);m.print&&(ja=m.print);m.printErr&&(ka=m.printErr);m.wasmBinary&&(la=m.wasmBinary);m.thisProgram&&(ca=m.thisProgram);if(m.preInit)for("function"==typeof m.preInit&&(m.preInit=[m.preInit]);0<m.preInit.length;)m.preInit.shift()();
80
- var sd={2076540:a=>{throw Error(a?C(t,a):"");}},Gc,td,Hc,X,La,Y,Z,ud,vd,Ma,wd,va,Ec,Pd={N:a=>{var b=new Ka(a);0==p[b.Db+12]&&(p[b.Db+12]=1,Ia--);p[b.Db+13]=0;Ha.push(b);vd(a);return wd(a)},La:()=>{X(0,0);var a=Ha.pop();ud(a.ad);Ja=0},b:()=>Na([]),e:a=>Na([a]),da:()=>{var a=Ha.pop();a||wa("no exception to throw");var b=a.ad;0==p[a.Db+13]&&(Ha.push(a),p[a.Db+13]=1,p[a.Db+12]=0,Ia++);Ja=b;throw Ja;},a:(a,b,c)=>{var d=new Ka(a);x[d.Db+16>>2]=0;x[d.Db+4>>2]=b;x[d.Db+8>>2]=c;Ja=a;Ia++;throw Ja;},h:a=>{Ja||=
80
+ var sd={2084732:a=>{throw Error(a?C(t,a):"");}},Gc,td,Hc,X,La,Y,Z,ud,vd,Ma,wd,va,Ec,Pd={N:a=>{var b=new Ka(a);0==p[b.Db+12]&&(p[b.Db+12]=1,Ia--);p[b.Db+13]=0;Ha.push(b);vd(a);return wd(a)},La:()=>{X(0,0);var a=Ha.pop();ud(a.ad);Ja=0},b:()=>Na([]),e:a=>Na([a]),da:()=>{var a=Ha.pop();a||wa("no exception to throw");var b=a.ad;0==p[a.Db+13]&&(Ha.push(a),p[a.Db+13]=1,p[a.Db+12]=0,Ia++);Ja=b;throw Ja;},a:(a,b,c)=>{var d=new Ka(a);x[d.Db+16>>2]=0;x[d.Db+4>>2]=b;x[d.Db+8>>2]=c;Ja=a;Ia++;throw Ja;},h:a=>{Ja||=
81
81
  a;throw Ja;},Fa:function(a,b){try{return a=a?C(t,a):"",Mb(a,b),0}catch(c){if("undefined"==typeof M||"ErrnoError"!==c.name)throw c;return-c.Ib}},Da:function(a,b){try{var c=K(a);Lb(c,c.node,b,!1);return 0}catch(d){if("undefined"==typeof M||"ErrnoError"!==d.name)throw d;return-d.Ib}},K:function(a,b,c){Tb=c;try{var d=K(a);switch(b){case 0:var e=N();if(0>e)break;for(;lb[e];)e++;return Cb(d,e).Pb;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=N(),d.flags|=e,0;case 12:return e=N(),v[e+0>>1]=
82
82
  2,0;case 13:case 14:return 0}return-28}catch(f){if("undefined"==typeof M||"ErrnoError"!==f.name)throw f;return-f.Ib}},Ca:function(a,b){try{var c=K(a),d=c.node,e=c.Fb.Xb;a=e?c:d;e??=d.Cb.Xb;Ab(e,63);var f=e(a);return Sb(b,f)}catch(g){if("undefined"==typeof M||"ErrnoError"!==g.name)throw g;return-g.Ib}},ya:function(a,b){b=-9007199254740992>b||9007199254740992<b?NaN:Number(b);try{if(isNaN(b))return-61;var c=K(a);if(0>b||0===(c.flags&2097155))throw new F(28);Nb(c,c.node,b);return 0}catch(d){if("undefined"==
83
83
  typeof M||"ErrnoError"!==d.name)throw d;return-d.Ib}},xa:function(a,b){try{if(0===b)return-28;var c=Za("/")+1;if(b<c)return-68;E("/",t,a,b);return c}catch(d){if("undefined"==typeof M||"ErrnoError"!==d.name)throw d;return-d.Ib}},oa:function(a,b,c){try{var d=K(a);if(!d.oc){var e=J(d.path,{vc:!0}).node;var f=Ab(e.Cb.Lc,54)(e);d.oc=f}a=0;var g=Pb(d,0,1),h=Math.floor(g/280),l=Math.min(d.oc.length,h+Math.floor(c/280));for(c=h;c<l;c++){var k=d.oc[c];if("."===k){var n=d.node.id;var r=4}else if(".."===k)n=
package/meshlib.node.mjs CHANGED
@@ -108,7 +108,7 @@ c.Cb.count.value+=1;c.Cb.Cc=!1;return c},["delete"](){this.Cb.Fb||dc(this);if(th
108
108
  const b=Symbol.dispose;b&&(a[b]=a["delete"])})();
109
109
  Object.assign(zc.prototype,{Wd(a){this.Cd&&(a=this.Cd(a));return a},qd(a){this.fc?.(a)},cc:Wb,Jb:function(a){function b(){return this.Nc?yc(this.Hb.oc,{Mb:this.ge,Fb:c,Yb:this,Vb:a}):yc(this.Hb.oc,{Mb:this,Fb:a})}var c=this.Wd(a);if(!c)return this.qd(a),null;var d=xc(this.Hb,c);if(void 0!==d){if(0===d.Cb.count.value)return d.Cb.Fb=c,d.Cb.Vb=a,d.clone();d=d.clone();this.qd(a);return d}d=this.Hb.Ud(c);d=kc[d];if(!d)return b.call(this);d=this.Mc?d.Md:d.pointerType;var e=vc(c,this.Hb,d.Hb);return null===
110
110
  e?b.call(this):this.Nc?yc(d.Hb.oc,{Mb:d,Fb:e,Yb:this,Vb:a}):yc(d.Hb.oc,{Mb:d,Fb:e})}});f.noExitRuntime&&(Fa=f.noExitRuntime);f.preloadPlugins&&(rb=f.preloadPlugins);f.print&&(ja=f.print);f.printErr&&(ka=f.printErr);f.wasmBinary&&(la=f.wasmBinary);f.thisProgram&&(ba=f.thisProgram);if(f.preInit)for("function"==typeof f.preInit&&(f.preInit=[f.preInit]);0<f.preInit.length;)f.preInit.shift()();
111
- var sd={2076540:a=>{throw Error(a?F(t,a):"");}},Ec,td,Fc,X,Ka,Y,Z,ud,vd,La,wd,va,Cc,Pd={N:a=>{var b=new Ja(a);0==p[b.Fb+12]&&(p[b.Fb+12]=1,Ha--);p[b.Fb+13]=0;Ga.push(b);vd(a);return wd(a)},La:()=>{X(0,0);var a=Ga.pop();ud(a.sd);Ia=0},b:()=>Ma([]),e:a=>Ma([a]),da:()=>{var a=Ga.pop();a||A("no exception to throw");var b=a.sd;0==p[a.Fb+13]&&(Ga.push(a),p[a.Fb+13]=1,p[a.Fb+12]=0,Ha++);Ia=b;throw Ia;},a:(a,b,c)=>{(new Ja(a)).Lc(b,c);Ia=a;Ha++;throw Ia;},h:a=>{Ia||=a;throw Ia;},Fa:function(a,b){try{return a=
111
+ var sd={2084732:a=>{throw Error(a?F(t,a):"");}},Ec,td,Fc,X,Ka,Y,Z,ud,vd,La,wd,va,Cc,Pd={N:a=>{var b=new Ja(a);0==p[b.Fb+12]&&(p[b.Fb+12]=1,Ha--);p[b.Fb+13]=0;Ga.push(b);vd(a);return wd(a)},La:()=>{X(0,0);var a=Ga.pop();ud(a.sd);Ia=0},b:()=>Ma([]),e:a=>Ma([a]),da:()=>{var a=Ga.pop();a||A("no exception to throw");var b=a.sd;0==p[a.Fb+13]&&(Ga.push(a),p[a.Fb+13]=1,p[a.Fb+12]=0,Ha++);Ia=b;throw Ia;},a:(a,b,c)=>{(new Ja(a)).Lc(b,c);Ia=a;Ha++;throw Ia;},h:a=>{Ia||=a;throw Ia;},Fa:function(a,b){try{return a=
112
112
  a?F(t,a):"",C.chmod(a,b),0}catch(c){if("undefined"==typeof C||"ErrnoError"!==c.name)throw c;return-c.Ib}},Da:function(a,b){try{return C.fchmod(a,b),0}catch(c){if("undefined"==typeof C||"ErrnoError"!==c.name)throw c;return-c.Ib}},K:function(a,b,c){Qb=c;try{var d=M(a);switch(b){case 0:var e=Rb();if(0>e)break;for(;C.streams[e];)e++;return Cb(d,e).fd;case 1:case 2:return 0;case 3:return d.flags;case 4:return e=Rb(),d.flags|=e,0;case 12:return e=Rb(),v[e+0>>1]=2,0;case 13:case 14:return 0}return-28}catch(g){if("undefined"==
113
113
  typeof C||"ErrnoError"!==g.name)throw g;return-g.Ib}},Ca:function(a,b){try{return Pb(b,C.fstat(a))}catch(c){if("undefined"==typeof C||"ErrnoError"!==c.name)throw c;return-c.Ib}},ya:function(a,b){b=-9007199254740992>b||9007199254740992<b?NaN:Number(b);try{if(isNaN(b))return-61;C.vd(a,b);return 0}catch(c){if("undefined"==typeof C||"ErrnoError"!==c.name)throw c;return-c.Ib}},xa:function(a,b){try{if(0===b)return-28;var c=C.cwd(),d=Ya(c)+1;if(b<d)return-68;G(c,t,a,b);return d}catch(e){if("undefined"==
114
114
  typeof C||"ErrnoError"!==e.name)throw e;return-e.Ib}},oa:function(a,b,c){try{var d=M(a);d.tc||(d.tc=C.readdir(d.path));a=0;var e=C.Nb(d,0,1),g=Math.floor(e/280),h=Math.min(d.tc.length,g+Math.floor(c/280));for(c=g;c<h;c++){var k=d.tc[c];if("."===k){var m=d.node.id;var l=4}else if(".."===k)m=C.Kb(d.path,{parent:!0}).node.id,l=4;else{try{var n=fb(d.node,k)}catch(q){if(28===q?.Ib)continue;throw q;}m=n.id;l=8192===(n.mode&61440)?2:I(n.mode)?4:40960===(n.mode&61440)?10:8}z[b+a>>3]=BigInt(m);z[b+a+8>>3]=
package/meshlib.node.wasm CHANGED
Binary file
package/meshlib.wasm CHANGED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meshinspector/meshlib",
3
- "version": "3.1.3-429",
3
+ "version": "3.1.4-297",
4
4
  "description": "MeshLib geometry library compiled to WebAssembly (single-threaded).",
5
5
  "type": "module",
6
6
  "main": "./meshlib.mjs",