okgeometry-api 1.1.20 → 1.1.22
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/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +48 -6
- package/dist/Mesh.js.map +1 -1
- package/dist/wasm-base64.d.ts +1 -1
- package/dist/wasm-base64.d.ts.map +1 -1
- package/dist/wasm-base64.js +1 -1
- package/dist/wasm-base64.js.map +1 -1
- package/package.json +1 -1
- package/src/Mesh.ts +84 -48
- package/src/wasm-base64.ts +1 -1
package/dist/wasm-base64.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm-base64.js","sourceRoot":"","sources":["../src/wasm-base64.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,
|
|
1
|
+
{"version":3,"file":"wasm-base64.js","sourceRoot":"","sources":["../src/wasm-base64.ts"],"names":[],"mappings":"AAAA,+BAA+B;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,0yquCAA0yquC,CAAC"}
|
package/package.json
CHANGED
package/src/Mesh.ts
CHANGED
|
@@ -181,12 +181,18 @@ export interface MeshBooleanReproOptions {
|
|
|
181
181
|
includeResult?: boolean;
|
|
182
182
|
debugOptions?: MeshBooleanDebugOptions;
|
|
183
183
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
184
|
+
|
|
185
|
+
function shouldFallbackFromWorkerFailure(error: unknown): boolean {
|
|
186
|
+
if (!error || typeof error !== "object") return false;
|
|
187
|
+
const code = "code" in error ? error.code : undefined;
|
|
188
|
+
return code === "worker_unavailable" || code === "worker_crashed" || code === "worker_protocol";
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Buffer-backed triangle mesh with GPU-ready accessors.
|
|
193
|
+
* All geometry lives in a Float64Array from WASM.
|
|
194
|
+
*
|
|
195
|
+
* Buffer format: [vertexCount, x1,y1,z1, ..., i1,i2,i3, ...]
|
|
190
196
|
*/
|
|
191
197
|
export class Mesh {
|
|
192
198
|
private _buffer: Float64Array;
|
|
@@ -1807,50 +1813,80 @@ export class Mesh {
|
|
|
1807
1813
|
/**
|
|
1808
1814
|
* Compute boolean union in a dedicated Web Worker (non-blocking).
|
|
1809
1815
|
* Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
|
|
1810
|
-
*/
|
|
1811
|
-
async unionAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1816
|
+
*/
|
|
1817
|
+
async unionAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
|
|
1818
|
+
try {
|
|
1819
|
+
const result = await runMeshBooleanInWorkerPool(
|
|
1820
|
+
"union",
|
|
1821
|
+
this._buffer,
|
|
1822
|
+
other._buffer,
|
|
1823
|
+
this._trustedBooleanInput,
|
|
1824
|
+
other._trustedBooleanInput,
|
|
1825
|
+
options,
|
|
1826
|
+
);
|
|
1827
|
+
return Mesh.fromTrustedBuffer(result);
|
|
1828
|
+
} catch (error) {
|
|
1829
|
+
if (!shouldFallbackFromWorkerFailure(error)) throw error;
|
|
1830
|
+
console.warn("Mesh.unionAsync worker failed; falling back to main-thread boolean.", error);
|
|
1831
|
+
return this.union(other, {
|
|
1832
|
+
allowUnsafe: options?.allowUnsafe ?? true,
|
|
1833
|
+
limits: options?.limits,
|
|
1834
|
+
debugForceFaceID: options?.debugForceFaceID,
|
|
1835
|
+
});
|
|
1836
|
+
}
|
|
1837
|
+
}
|
|
1822
1838
|
|
|
1823
|
-
/**
|
|
1824
|
-
* Compute boolean subtraction in a dedicated Web Worker (non-blocking).
|
|
1825
|
-
* Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
|
|
1826
|
-
*/
|
|
1827
|
-
async subtractAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1839
|
+
/**
|
|
1840
|
+
* Compute boolean subtraction in a dedicated Web Worker (non-blocking).
|
|
1841
|
+
* Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
|
|
1842
|
+
*/
|
|
1843
|
+
async subtractAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
|
|
1844
|
+
try {
|
|
1845
|
+
const result = await runMeshBooleanInWorkerPool(
|
|
1846
|
+
"subtraction",
|
|
1847
|
+
this._buffer,
|
|
1848
|
+
other._buffer,
|
|
1849
|
+
this._trustedBooleanInput,
|
|
1850
|
+
other._trustedBooleanInput,
|
|
1851
|
+
options,
|
|
1852
|
+
);
|
|
1853
|
+
return Mesh.fromTrustedBuffer(result);
|
|
1854
|
+
} catch (error) {
|
|
1855
|
+
if (!shouldFallbackFromWorkerFailure(error)) throw error;
|
|
1856
|
+
console.warn("Mesh.subtractAsync worker failed; falling back to main-thread boolean.", error);
|
|
1857
|
+
return this.subtract(other, {
|
|
1858
|
+
allowUnsafe: options?.allowUnsafe ?? true,
|
|
1859
|
+
limits: options?.limits,
|
|
1860
|
+
debugForceFaceID: options?.debugForceFaceID,
|
|
1861
|
+
});
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1838
1864
|
|
|
1839
|
-
/**
|
|
1840
|
-
* Compute boolean intersection in a dedicated Web Worker (non-blocking).
|
|
1841
|
-
* Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
|
|
1842
|
-
*/
|
|
1843
|
-
async intersectAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1865
|
+
/**
|
|
1866
|
+
* Compute boolean intersection in a dedicated Web Worker (non-blocking).
|
|
1867
|
+
* Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
|
|
1868
|
+
*/
|
|
1869
|
+
async intersectAsync(other: Mesh, options?: MeshBooleanAsyncOptions): Promise<Mesh> {
|
|
1870
|
+
try {
|
|
1871
|
+
const result = await runMeshBooleanInWorkerPool(
|
|
1872
|
+
"intersection",
|
|
1873
|
+
this._buffer,
|
|
1874
|
+
other._buffer,
|
|
1875
|
+
this._trustedBooleanInput,
|
|
1876
|
+
other._trustedBooleanInput,
|
|
1877
|
+
options,
|
|
1878
|
+
);
|
|
1879
|
+
return Mesh.fromTrustedBuffer(result);
|
|
1880
|
+
} catch (error) {
|
|
1881
|
+
if (!shouldFallbackFromWorkerFailure(error)) throw error;
|
|
1882
|
+
console.warn("Mesh.intersectAsync worker failed; falling back to main-thread boolean.", error);
|
|
1883
|
+
return this.intersect(other, {
|
|
1884
|
+
allowUnsafe: options?.allowUnsafe ?? true,
|
|
1885
|
+
limits: options?.limits,
|
|
1886
|
+
debugForceFaceID: options?.debugForceFaceID,
|
|
1887
|
+
});
|
|
1888
|
+
}
|
|
1889
|
+
}
|
|
1854
1890
|
|
|
1855
1891
|
// ── Intersection queries ───────────────────────────────────────
|
|
1856
1892
|
|