okgeometry-api 0.5.8 → 1.0.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/dist/Mesh.d.ts +21 -3
- package/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +114 -41
- package/dist/Mesh.js.map +1 -1
- package/dist/mesh-boolean.pool.d.ts +2 -2
- package/dist/mesh-boolean.pool.d.ts.map +1 -1
- package/dist/mesh-boolean.pool.js +8 -4
- package/dist/mesh-boolean.pool.js.map +1 -1
- package/dist/mesh-boolean.protocol.d.ts +5 -4
- package/dist/mesh-boolean.protocol.d.ts.map +1 -1
- package/dist/mesh-boolean.protocol.js.map +1 -1
- package/dist/mesh-boolean.worker.d.ts.map +1 -1
- package/dist/mesh-boolean.worker.js +7 -3
- package/dist/mesh-boolean.worker.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 +9 -6
- package/src/Mesh.ts +219 -115
- package/src/mesh-boolean.pool.ts +51 -41
- package/src/mesh-boolean.protocol.ts +32 -31
- package/src/mesh-boolean.worker.ts +11 -7
- package/src/wasm-base64.ts +1 -1
- package/wasm/README.md +2 -0
- package/wasm/okgeometrycore.d.ts +81 -36
- package/wasm/okgeometrycore.js +145 -60
- package/wasm/okgeometrycore_bg.wasm +0 -0
- package/wasm/okgeometrycore_bg.wasm.d.ts +6 -3
- package/wasm/package.json +1 -1
package/dist/Mesh.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import type { SweepableCurve, RotationAxis } from "./types.js";
|
|
|
6
6
|
import { MeshBooleanExecutionError } from "./mesh-boolean.protocol.js";
|
|
7
7
|
import type { MeshBooleanAsyncOptions, MeshBooleanOptions } from "./mesh-boolean.protocol.js";
|
|
8
8
|
export { MeshBooleanExecutionError };
|
|
9
|
-
export type { MeshBooleanAsyncOptions,
|
|
9
|
+
export type { MeshBooleanAsyncOptions, MeshBooleanLimits, MeshBooleanOptions, MeshBooleanErrorCode, MeshBooleanErrorPayload, MeshBooleanProgressEvent, } from "./mesh-boolean.protocol.js";
|
|
10
10
|
export interface PlanarRectangle {
|
|
11
11
|
corners: [Point, Point, Point, Point];
|
|
12
12
|
width: number;
|
|
@@ -33,12 +33,17 @@ export interface PlanarArc {
|
|
|
33
33
|
export declare class Mesh {
|
|
34
34
|
private _buffer;
|
|
35
35
|
private _vertexCount;
|
|
36
|
+
private _trustedBooleanInput;
|
|
36
37
|
private static readonly DEFAULT_BOOLEAN_LIMITS;
|
|
38
|
+
private static readonly TOPOLOGY_METRICS_CACHE_FACE_THRESHOLD;
|
|
37
39
|
private _positionBuffer;
|
|
38
40
|
private _indexBuffer;
|
|
39
41
|
private _vertices;
|
|
40
42
|
private _faces;
|
|
41
43
|
private _edgeVertexPairs;
|
|
44
|
+
private _topologyMetricsCache;
|
|
45
|
+
private _isClosedVolumeCache;
|
|
46
|
+
private _rawBoundsCache;
|
|
42
47
|
private constructor();
|
|
43
48
|
/**
|
|
44
49
|
* Configure default size for the shared boolean worker pool.
|
|
@@ -89,7 +94,11 @@ export declare class Mesh {
|
|
|
89
94
|
* @param buffer - Float64Array in mesh buffer format
|
|
90
95
|
* @returns New Mesh instance
|
|
91
96
|
*/
|
|
92
|
-
static fromBuffer(buffer: Float64Array
|
|
97
|
+
static fromBuffer(buffer: Float64Array, options?: {
|
|
98
|
+
trustedBooleanInput?: boolean;
|
|
99
|
+
}): Mesh;
|
|
100
|
+
private static fromTrustedBuffer;
|
|
101
|
+
get trustedBooleanInput(): boolean;
|
|
93
102
|
/**
|
|
94
103
|
* Build an axis-aligned rectangle on a plane basis from opposite corners.
|
|
95
104
|
* The resulting corners are ordered [p0, p1, p2, p3] and form a closed loop.
|
|
@@ -276,7 +285,7 @@ export declare class Mesh {
|
|
|
276
285
|
*/
|
|
277
286
|
scaleXYZ(sx: number, sy: number, sz: number): Mesh;
|
|
278
287
|
private runBoolean;
|
|
279
|
-
|
|
288
|
+
static encodeBooleanOperationToken(operation: "union" | "subtraction" | "intersection", a: Mesh, b: Mesh, options?: MeshBooleanOptions): string;
|
|
280
289
|
/**
|
|
281
290
|
* Compute boolean union with another mesh.
|
|
282
291
|
* @param other - Mesh to union with
|
|
@@ -420,6 +429,15 @@ export declare class Mesh {
|
|
|
420
429
|
* Returns true when no welded topological boundary edges are found.
|
|
421
430
|
*/
|
|
422
431
|
isClosedVolume(): boolean;
|
|
432
|
+
/**
|
|
433
|
+
* Return welded-edge topology metrics for this triangulated mesh.
|
|
434
|
+
* `boundaryEdges`: edges referenced by exactly one triangle.
|
|
435
|
+
* `nonManifoldEdges`: edges referenced by more than two triangles.
|
|
436
|
+
*/
|
|
437
|
+
topologyMetrics(): {
|
|
438
|
+
boundaryEdges: number;
|
|
439
|
+
nonManifoldEdges: number;
|
|
440
|
+
};
|
|
423
441
|
/**
|
|
424
442
|
* Odd/even point containment test against a closed mesh.
|
|
425
443
|
* Uses majority vote across multiple ray directions for robustness.
|
package/dist/Mesh.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Mesh.d.ts","sourceRoot":"","sources":["../src/Mesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAOzC,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAQ/D,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AACvE,OAAO,KAAK,EACV,uBAAuB,
|
|
1
|
+
{"version":3,"file":"Mesh.d.ts","sourceRoot":"","sources":["../src/Mesh.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAA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,KAAK,CAAC;QAAC,MAAM,EAAE,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAwB7E;;OAEG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI;IAYtD;;;OAGG;IACH,cAAc,IAAI,OAAO;IAuBzB;;;;OAIG;IACH,eAAe,IAAI;QAAE,aAAa,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAA;KAAE;IAsBtE;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,OAAO;IAKpC;;OAEG;IACH,uBAAuB,CAAC,aAAa,EAAE,MAAM,GAAG;QAAE,QAAQ,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI;IAexF;;;OAGG;IACH,gBAAgB,CAAC,YAAY,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,KAAK,GAAG;QAAE,QAAQ,EAAE,KAAK,CAAC;QAAC,MAAM,EAAE,IAAI,CAAA;KAAE,GAAG,IAAI;IAsBjG;;;OAGG;IACH,KAAK,IAAI,MAAM;CAIhB"}
|
package/dist/Mesh.js
CHANGED
|
@@ -12,6 +12,7 @@ import { pointsToCoords, parsePolylineBuffer as parsePolylineBuf } from "./Buffe
|
|
|
12
12
|
import { configureDefaultMeshBooleanWorkerPool, disposeMeshBooleanWorkerPools, runMeshBooleanInWorkerPool, } from "./mesh-boolean.pool.js";
|
|
13
13
|
import { MeshBooleanExecutionError } from "./mesh-boolean.protocol.js";
|
|
14
14
|
import * as wasm from "../wasm/okgeometrycore_bg.js";
|
|
15
|
+
import { mesh_topology_metrics } from "../wasm/okgeometrycore.js";
|
|
15
16
|
export { MeshBooleanExecutionError };
|
|
16
17
|
/**
|
|
17
18
|
* Buffer-backed triangle mesh with GPU-ready accessors.
|
|
@@ -20,15 +21,19 @@ export { MeshBooleanExecutionError };
|
|
|
20
21
|
* Buffer format: [vertexCount, x1,y1,z1, ..., i1,i2,i3, ...]
|
|
21
22
|
*/
|
|
22
23
|
export class Mesh {
|
|
23
|
-
constructor(buffer) {
|
|
24
|
+
constructor(buffer, trustedBooleanInput = false) {
|
|
24
25
|
// Lazy caches
|
|
25
26
|
this._positionBuffer = null;
|
|
26
27
|
this._indexBuffer = null;
|
|
27
28
|
this._vertices = null;
|
|
28
29
|
this._faces = null;
|
|
29
30
|
this._edgeVertexPairs = null;
|
|
31
|
+
this._topologyMetricsCache = null;
|
|
32
|
+
this._isClosedVolumeCache = null;
|
|
33
|
+
this._rawBoundsCache = undefined;
|
|
30
34
|
this._buffer = buffer;
|
|
31
35
|
this._vertexCount = buffer.length > 0 ? buffer[0] : 0;
|
|
36
|
+
this._trustedBooleanInput = trustedBooleanInput;
|
|
32
37
|
}
|
|
33
38
|
/**
|
|
34
39
|
* Configure default size for the shared boolean worker pool.
|
|
@@ -51,8 +56,12 @@ export class Mesh {
|
|
|
51
56
|
};
|
|
52
57
|
}
|
|
53
58
|
static computeRawBounds(mesh) {
|
|
54
|
-
if (mesh.
|
|
59
|
+
if (mesh._rawBoundsCache !== undefined)
|
|
60
|
+
return mesh._rawBoundsCache;
|
|
61
|
+
if (mesh._vertexCount <= 0) {
|
|
62
|
+
mesh._rawBoundsCache = null;
|
|
55
63
|
return null;
|
|
64
|
+
}
|
|
56
65
|
const data = mesh._buffer;
|
|
57
66
|
const limit = 1 + mesh._vertexCount * 3;
|
|
58
67
|
let minX = data[1];
|
|
@@ -78,7 +87,9 @@ export class Mesh {
|
|
|
78
87
|
if (z > maxZ)
|
|
79
88
|
maxZ = z;
|
|
80
89
|
}
|
|
81
|
-
|
|
90
|
+
const bounds = { minX, minY, minZ, maxX, maxY, maxZ };
|
|
91
|
+
mesh._rawBoundsCache = bounds;
|
|
92
|
+
return bounds;
|
|
82
93
|
}
|
|
83
94
|
static boundsOverlap(a, b, eps = 1e-9) {
|
|
84
95
|
if (!a || !b)
|
|
@@ -104,10 +115,12 @@ export class Mesh {
|
|
|
104
115
|
return Math.min(1e-4, Math.max(1e-9, scale * 1e-6));
|
|
105
116
|
}
|
|
106
117
|
static cloneMesh(mesh) {
|
|
107
|
-
return Mesh.fromBuffer(new Float64Array(mesh._buffer)
|
|
118
|
+
return Mesh.fromBuffer(new Float64Array(mesh._buffer), {
|
|
119
|
+
trustedBooleanInput: mesh._trustedBooleanInput,
|
|
120
|
+
});
|
|
108
121
|
}
|
|
109
122
|
static emptyMesh() {
|
|
110
|
-
return Mesh.
|
|
123
|
+
return Mesh.fromTrustedBuffer(new Float64Array(0));
|
|
111
124
|
}
|
|
112
125
|
// ── GPU-ready buffers ──────────────────────────────────────────
|
|
113
126
|
/**
|
|
@@ -145,7 +158,10 @@ export class Mesh {
|
|
|
145
158
|
}
|
|
146
159
|
/** Number of triangular faces in this mesh */
|
|
147
160
|
get faceCount() {
|
|
148
|
-
|
|
161
|
+
const start = 1 + this._vertexCount * 3;
|
|
162
|
+
if (this._buffer.length <= start)
|
|
163
|
+
return 0;
|
|
164
|
+
return Math.floor((this._buffer.length - start) / 3);
|
|
149
165
|
}
|
|
150
166
|
// ── High-level accessors (lazy) ────────────────────────────────
|
|
151
167
|
/**
|
|
@@ -189,8 +205,14 @@ export class Mesh {
|
|
|
189
205
|
* @param buffer - Float64Array in mesh buffer format
|
|
190
206
|
* @returns New Mesh instance
|
|
191
207
|
*/
|
|
192
|
-
static fromBuffer(buffer) {
|
|
193
|
-
return new Mesh(buffer);
|
|
208
|
+
static fromBuffer(buffer, options) {
|
|
209
|
+
return new Mesh(buffer, options?.trustedBooleanInput ?? false);
|
|
210
|
+
}
|
|
211
|
+
static fromTrustedBuffer(buffer) {
|
|
212
|
+
return new Mesh(buffer, true);
|
|
213
|
+
}
|
|
214
|
+
get trustedBooleanInput() {
|
|
215
|
+
return this._trustedBooleanInput;
|
|
194
216
|
}
|
|
195
217
|
/**
|
|
196
218
|
* Build an axis-aligned rectangle on a plane basis from opposite corners.
|
|
@@ -415,7 +437,7 @@ export class Mesh {
|
|
|
415
437
|
ensureInit();
|
|
416
438
|
const coords = pointsToCoords(pts);
|
|
417
439
|
const buf = wasm.mesh_patch_from_points(coords);
|
|
418
|
-
return
|
|
440
|
+
return Mesh.fromTrustedBuffer(buf);
|
|
419
441
|
}
|
|
420
442
|
/**
|
|
421
443
|
* Create an axis-aligned box centered at origin.
|
|
@@ -426,7 +448,7 @@ export class Mesh {
|
|
|
426
448
|
*/
|
|
427
449
|
static createBox(width, height, depth) {
|
|
428
450
|
ensureInit();
|
|
429
|
-
return
|
|
451
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_create_box(width, height, depth));
|
|
430
452
|
}
|
|
431
453
|
/**
|
|
432
454
|
* Create a UV sphere centered at origin.
|
|
@@ -437,7 +459,7 @@ export class Mesh {
|
|
|
437
459
|
*/
|
|
438
460
|
static createSphere(radius, segments, rings) {
|
|
439
461
|
ensureInit();
|
|
440
|
-
return
|
|
462
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_create_sphere(radius, segments, rings));
|
|
441
463
|
}
|
|
442
464
|
/**
|
|
443
465
|
* Create a cylinder centered at origin with axis along Y.
|
|
@@ -448,7 +470,7 @@ export class Mesh {
|
|
|
448
470
|
*/
|
|
449
471
|
static createCylinder(radius, height, segments) {
|
|
450
472
|
ensureInit();
|
|
451
|
-
return
|
|
473
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_create_cylinder(radius, height, segments));
|
|
452
474
|
}
|
|
453
475
|
/**
|
|
454
476
|
* Create a regular prism centered at origin.
|
|
@@ -459,7 +481,7 @@ export class Mesh {
|
|
|
459
481
|
*/
|
|
460
482
|
static createPrism(radius, height, sides) {
|
|
461
483
|
ensureInit();
|
|
462
|
-
return
|
|
484
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_create_prism(radius, height, sides));
|
|
463
485
|
}
|
|
464
486
|
/**
|
|
465
487
|
* Create a cone centered at origin with apex at top.
|
|
@@ -470,7 +492,7 @@ export class Mesh {
|
|
|
470
492
|
*/
|
|
471
493
|
static createCone(radius, height, segments) {
|
|
472
494
|
ensureInit();
|
|
473
|
-
return
|
|
495
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_create_cone(radius, height, segments));
|
|
474
496
|
}
|
|
475
497
|
/**
|
|
476
498
|
* Import a mesh from OBJ format string.
|
|
@@ -479,7 +501,7 @@ export class Mesh {
|
|
|
479
501
|
*/
|
|
480
502
|
static fromOBJ(objString) {
|
|
481
503
|
ensureInit();
|
|
482
|
-
return
|
|
504
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_import_obj(objString));
|
|
483
505
|
}
|
|
484
506
|
/**
|
|
485
507
|
* Loft through multiple circles to create a surface of revolution.
|
|
@@ -502,7 +524,7 @@ export class Mesh {
|
|
|
502
524
|
data[off + 5] = c.normal?.z ?? 0;
|
|
503
525
|
data[off + 6] = c.radius;
|
|
504
526
|
}
|
|
505
|
-
return
|
|
527
|
+
return Mesh.fromTrustedBuffer(wasm.loft_circles(data, segments, caps));
|
|
506
528
|
}
|
|
507
529
|
/**
|
|
508
530
|
* Loft through multiple polylines to create a ruled surface.
|
|
@@ -521,7 +543,7 @@ export class Mesh {
|
|
|
521
543
|
parts.push(p.x, p.y, p.z);
|
|
522
544
|
}
|
|
523
545
|
}
|
|
524
|
-
return
|
|
546
|
+
return Mesh.fromTrustedBuffer(wasm.loft_polylines(new Float64Array(parts), segments, caps));
|
|
525
547
|
}
|
|
526
548
|
/**
|
|
527
549
|
* Sweep a profile polyline along a path polyline.
|
|
@@ -532,7 +554,7 @@ export class Mesh {
|
|
|
532
554
|
*/
|
|
533
555
|
static sweep(profilePoints, pathPoints, caps = false) {
|
|
534
556
|
ensureInit();
|
|
535
|
-
return
|
|
557
|
+
return Mesh.fromTrustedBuffer(wasm.sweep_polylines(pointsToCoords(profilePoints), pointsToCoords(pathPoints), caps));
|
|
536
558
|
}
|
|
537
559
|
/**
|
|
538
560
|
* Compute a stable planar normal from ordered curve points.
|
|
@@ -550,7 +572,7 @@ export class Mesh {
|
|
|
550
572
|
static extrudePlanarCurve(points, normal, height, closed) {
|
|
551
573
|
ensureInit();
|
|
552
574
|
const buf = wasm.mesh_extrude_planar_curve(pointsToCoords(points), normal.x, normal.y, normal.z, height, closed);
|
|
553
|
-
return Mesh.
|
|
575
|
+
return Mesh.fromTrustedBuffer(buf);
|
|
554
576
|
}
|
|
555
577
|
/**
|
|
556
578
|
* Shift a closed cutter profile slightly opposite to travel direction and
|
|
@@ -583,7 +605,7 @@ export class Mesh {
|
|
|
583
605
|
ensureInit();
|
|
584
606
|
const profileData = Mesh.encodeCurve(profile);
|
|
585
607
|
const pathData = Mesh.encodeCurve(path);
|
|
586
|
-
return
|
|
608
|
+
return Mesh.fromTrustedBuffer(wasm.sweep_curves(profileData, pathData, segments, segments, caps));
|
|
587
609
|
}
|
|
588
610
|
/** Encode a curve into the WASM format for sweep_curves. */
|
|
589
611
|
static encodeCurve(curve) {
|
|
@@ -667,7 +689,7 @@ export class Mesh {
|
|
|
667
689
|
static mergeMeshes(meshes) {
|
|
668
690
|
ensureInit();
|
|
669
691
|
const packed = Mesh.packMeshes(meshes);
|
|
670
|
-
return Mesh.
|
|
692
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_merge(packed));
|
|
671
693
|
}
|
|
672
694
|
/**
|
|
673
695
|
* Raycast against many meshes and return all hits sorted by distance.
|
|
@@ -736,7 +758,7 @@ export class Mesh {
|
|
|
736
758
|
*/
|
|
737
759
|
translate(offset) {
|
|
738
760
|
ensureInit();
|
|
739
|
-
return
|
|
761
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_translate(this._vertexCount, this._buffer, offset.x, offset.y, offset.z));
|
|
740
762
|
}
|
|
741
763
|
/**
|
|
742
764
|
* Rotate this mesh around an axis.
|
|
@@ -753,7 +775,7 @@ export class Mesh {
|
|
|
753
775
|
.rotate(dir, angleRadians)
|
|
754
776
|
.translate(new Vec3(c.x, c.y, c.z));
|
|
755
777
|
}
|
|
756
|
-
return
|
|
778
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_rotate(this._vertexCount, this._buffer, axis.x, axis.y, axis.z, angleRadians));
|
|
757
779
|
}
|
|
758
780
|
/**
|
|
759
781
|
* Scale this mesh uniformly.
|
|
@@ -762,7 +784,7 @@ export class Mesh {
|
|
|
762
784
|
*/
|
|
763
785
|
scale(factor) {
|
|
764
786
|
ensureInit();
|
|
765
|
-
return
|
|
787
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_scale(this._vertexCount, this._buffer, factor, factor, factor));
|
|
766
788
|
}
|
|
767
789
|
/**
|
|
768
790
|
* Scale this mesh non-uniformly along each axis.
|
|
@@ -773,7 +795,7 @@ export class Mesh {
|
|
|
773
795
|
*/
|
|
774
796
|
scaleXYZ(sx, sy, sz) {
|
|
775
797
|
ensureInit();
|
|
776
|
-
return
|
|
798
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_scale(this._vertexCount, this._buffer, sx, sy, sz));
|
|
777
799
|
}
|
|
778
800
|
runBoolean(other, operation, invoke, options) {
|
|
779
801
|
const faceCountA = this.faceCount;
|
|
@@ -825,10 +847,17 @@ export class Mesh {
|
|
|
825
847
|
if (!Number.isFinite(vertexCount) || vertexCount < 0) {
|
|
826
848
|
throw new Error(`Boolean ${operation} failed and returned a corrupt mesh buffer.`);
|
|
827
849
|
}
|
|
828
|
-
return Mesh.
|
|
850
|
+
return Mesh.fromTrustedBuffer(result);
|
|
829
851
|
}
|
|
830
|
-
static
|
|
831
|
-
|
|
852
|
+
static encodeBooleanOperationToken(operation, a, b, options) {
|
|
853
|
+
const tokens = [operation];
|
|
854
|
+
if (a._trustedBooleanInput && b._trustedBooleanInput) {
|
|
855
|
+
tokens.push("trustedInput");
|
|
856
|
+
}
|
|
857
|
+
if (options?.debugForceFaceID) {
|
|
858
|
+
tokens.push("forceFaceID");
|
|
859
|
+
}
|
|
860
|
+
return tokens.join("@");
|
|
832
861
|
}
|
|
833
862
|
// ── Booleans ───────────────────────────────────────────────────
|
|
834
863
|
/**
|
|
@@ -839,7 +868,7 @@ export class Mesh {
|
|
|
839
868
|
*/
|
|
840
869
|
union(other, options) {
|
|
841
870
|
ensureInit();
|
|
842
|
-
const operationToken = Mesh.
|
|
871
|
+
const operationToken = Mesh.encodeBooleanOperationToken("union", this, other, options);
|
|
843
872
|
return this.runBoolean(other, "union", () => wasm.mesh_boolean_operation(this._vertexCount, this._buffer, other._vertexCount, other._buffer, operationToken), options);
|
|
844
873
|
}
|
|
845
874
|
/**
|
|
@@ -850,7 +879,7 @@ export class Mesh {
|
|
|
850
879
|
*/
|
|
851
880
|
subtract(other, options) {
|
|
852
881
|
ensureInit();
|
|
853
|
-
const operationToken = Mesh.
|
|
882
|
+
const operationToken = Mesh.encodeBooleanOperationToken("subtraction", this, other, options);
|
|
854
883
|
return this.runBoolean(other, "subtraction", () => wasm.mesh_boolean_operation(this._vertexCount, this._buffer, other._vertexCount, other._buffer, operationToken), options);
|
|
855
884
|
}
|
|
856
885
|
/**
|
|
@@ -861,7 +890,7 @@ export class Mesh {
|
|
|
861
890
|
*/
|
|
862
891
|
intersect(other, options) {
|
|
863
892
|
ensureInit();
|
|
864
|
-
const operationToken = Mesh.
|
|
893
|
+
const operationToken = Mesh.encodeBooleanOperationToken("intersection", this, other, options);
|
|
865
894
|
return this.runBoolean(other, "intersection", () => wasm.mesh_boolean_operation(this._vertexCount, this._buffer, other._vertexCount, other._buffer, operationToken), options);
|
|
866
895
|
}
|
|
867
896
|
/**
|
|
@@ -869,24 +898,24 @@ export class Mesh {
|
|
|
869
898
|
* Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
|
|
870
899
|
*/
|
|
871
900
|
async unionAsync(other, options) {
|
|
872
|
-
const result = await runMeshBooleanInWorkerPool("union", this._buffer, other._buffer, options);
|
|
873
|
-
return Mesh.
|
|
901
|
+
const result = await runMeshBooleanInWorkerPool("union", this._buffer, other._buffer, this._trustedBooleanInput, other._trustedBooleanInput, options);
|
|
902
|
+
return Mesh.fromTrustedBuffer(result);
|
|
874
903
|
}
|
|
875
904
|
/**
|
|
876
905
|
* Compute boolean subtraction in a dedicated Web Worker (non-blocking).
|
|
877
906
|
* Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
|
|
878
907
|
*/
|
|
879
908
|
async subtractAsync(other, options) {
|
|
880
|
-
const result = await runMeshBooleanInWorkerPool("subtraction", this._buffer, other._buffer, options);
|
|
881
|
-
return Mesh.
|
|
909
|
+
const result = await runMeshBooleanInWorkerPool("subtraction", this._buffer, other._buffer, this._trustedBooleanInput, other._trustedBooleanInput, options);
|
|
910
|
+
return Mesh.fromTrustedBuffer(result);
|
|
882
911
|
}
|
|
883
912
|
/**
|
|
884
913
|
* Compute boolean intersection in a dedicated Web Worker (non-blocking).
|
|
885
914
|
* Defaults to allowUnsafe=true so high-poly jobs can run off the UI thread.
|
|
886
915
|
*/
|
|
887
916
|
async intersectAsync(other, options) {
|
|
888
|
-
const result = await runMeshBooleanInWorkerPool("intersection", this._buffer, other._buffer, options);
|
|
889
|
-
return Mesh.
|
|
917
|
+
const result = await runMeshBooleanInWorkerPool("intersection", this._buffer, other._buffer, this._trustedBooleanInput, other._trustedBooleanInput, options);
|
|
918
|
+
return Mesh.fromTrustedBuffer(result);
|
|
890
919
|
}
|
|
891
920
|
// ── Intersection queries ───────────────────────────────────────
|
|
892
921
|
/**
|
|
@@ -916,7 +945,7 @@ export class Mesh {
|
|
|
916
945
|
*/
|
|
917
946
|
applyMatrix(matrix) {
|
|
918
947
|
ensureInit();
|
|
919
|
-
return
|
|
948
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_apply_matrix(this._vertexCount, this._buffer, new Float64Array(matrix)));
|
|
920
949
|
}
|
|
921
950
|
/**
|
|
922
951
|
* Evaluate a point on the mesh surface at parametric coordinates.
|
|
@@ -1098,17 +1127,60 @@ export class Mesh {
|
|
|
1098
1127
|
extrudeFace(faceIndex, distance) {
|
|
1099
1128
|
ensureInit();
|
|
1100
1129
|
if (!Number.isFinite(faceIndex) || faceIndex < 0) {
|
|
1101
|
-
return Mesh.fromBuffer(new Float64Array(this._buffer)
|
|
1130
|
+
return Mesh.fromBuffer(new Float64Array(this._buffer), {
|
|
1131
|
+
trustedBooleanInput: this._trustedBooleanInput,
|
|
1132
|
+
});
|
|
1102
1133
|
}
|
|
1103
|
-
return Mesh.
|
|
1134
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_extrude_face(this._vertexCount, this._buffer, Math.floor(faceIndex), distance));
|
|
1104
1135
|
}
|
|
1105
1136
|
/**
|
|
1106
1137
|
* Check if this triangulated mesh represents a closed volume.
|
|
1107
1138
|
* Returns true when no welded topological boundary edges are found.
|
|
1108
1139
|
*/
|
|
1109
1140
|
isClosedVolume() {
|
|
1141
|
+
if (this._isClosedVolumeCache !== null) {
|
|
1142
|
+
return this._isClosedVolumeCache;
|
|
1143
|
+
}
|
|
1144
|
+
if (this._topologyMetricsCache) {
|
|
1145
|
+
const closedFromMetrics = this._topologyMetricsCache.boundaryEdges === 0;
|
|
1146
|
+
this._isClosedVolumeCache = closedFromMetrics;
|
|
1147
|
+
return closedFromMetrics;
|
|
1148
|
+
}
|
|
1149
|
+
ensureInit();
|
|
1150
|
+
if (this.faceCount >= Mesh.TOPOLOGY_METRICS_CACHE_FACE_THRESHOLD) {
|
|
1151
|
+
const metrics = this.topologyMetrics();
|
|
1152
|
+
const closedFromMetrics = metrics.boundaryEdges === 0;
|
|
1153
|
+
this._isClosedVolumeCache = closedFromMetrics;
|
|
1154
|
+
return closedFromMetrics;
|
|
1155
|
+
}
|
|
1156
|
+
const closed = wasm.mesh_is_closed_volume(this._vertexCount, this._buffer);
|
|
1157
|
+
this._isClosedVolumeCache = closed;
|
|
1158
|
+
return closed;
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Return welded-edge topology metrics for this triangulated mesh.
|
|
1162
|
+
* `boundaryEdges`: edges referenced by exactly one triangle.
|
|
1163
|
+
* `nonManifoldEdges`: edges referenced by more than two triangles.
|
|
1164
|
+
*/
|
|
1165
|
+
topologyMetrics() {
|
|
1166
|
+
if (this._topologyMetricsCache) {
|
|
1167
|
+
return {
|
|
1168
|
+
boundaryEdges: this._topologyMetricsCache.boundaryEdges,
|
|
1169
|
+
nonManifoldEdges: this._topologyMetricsCache.nonManifoldEdges,
|
|
1170
|
+
};
|
|
1171
|
+
}
|
|
1110
1172
|
ensureInit();
|
|
1111
|
-
|
|
1173
|
+
const metrics = mesh_topology_metrics(this._vertexCount, this._buffer);
|
|
1174
|
+
const boundaryEdges = Math.floor(metrics[0] ?? 0);
|
|
1175
|
+
const nonManifoldEdges = Math.floor(metrics[1] ?? 0);
|
|
1176
|
+
this._topologyMetricsCache = { boundaryEdges, nonManifoldEdges };
|
|
1177
|
+
if (this._isClosedVolumeCache === null) {
|
|
1178
|
+
this._isClosedVolumeCache = boundaryEdges === 0;
|
|
1179
|
+
}
|
|
1180
|
+
return {
|
|
1181
|
+
boundaryEdges,
|
|
1182
|
+
nonManifoldEdges,
|
|
1183
|
+
};
|
|
1112
1184
|
}
|
|
1113
1185
|
/**
|
|
1114
1186
|
* Odd/even point containment test against a closed mesh.
|
|
@@ -1162,4 +1234,5 @@ Mesh.DEFAULT_BOOLEAN_LIMITS = {
|
|
|
1162
1234
|
maxCombinedInputFaces: 180000,
|
|
1163
1235
|
maxFaceProduct: 500000000,
|
|
1164
1236
|
};
|
|
1237
|
+
Mesh.TOPOLOGY_METRICS_CACHE_FACE_THRESHOLD = 20000;
|
|
1165
1238
|
//# sourceMappingURL=Mesh.js.map
|