okgeometry-api 0.5.9 → 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.
@@ -14,16 +14,18 @@ interface PoolAcquireOptions {
14
14
  workerFactory?: () => Worker;
15
15
  }
16
16
 
17
- interface BooleanJob {
18
- id: number;
19
- operation: MeshBooleanOperation;
20
- options: MeshBooleanOptions;
17
+ interface BooleanJob {
18
+ id: number;
19
+ operation: MeshBooleanOperation;
20
+ options: MeshBooleanOptions;
21
21
  onProgress?: (event: MeshBooleanProgressEvent) => void;
22
22
  signal?: AbortSignal;
23
- timeoutMs?: number;
24
- bufferA: ArrayBuffer;
25
- bufferB: ArrayBuffer;
26
- cancelView?: Int32Array;
23
+ timeoutMs?: number;
24
+ bufferA: ArrayBuffer;
25
+ bufferB: ArrayBuffer;
26
+ trustedInputA: boolean;
27
+ trustedInputB: boolean;
28
+ cancelView?: Int32Array;
27
29
  timeoutToken?: number;
28
30
  abortHandler?: () => void;
29
31
  resolve: (value: Float64Array) => void;
@@ -102,12 +104,14 @@ export class MeshBooleanWorkerPool {
102
104
  return this.disposed;
103
105
  }
104
106
 
105
- run(
106
- operation: MeshBooleanOperation,
107
- bufferA: Float64Array,
108
- bufferB: Float64Array,
109
- options?: MeshBooleanAsyncOptions,
110
- ): Promise<Float64Array> {
107
+ run(
108
+ operation: MeshBooleanOperation,
109
+ bufferA: Float64Array,
110
+ bufferB: Float64Array,
111
+ trustedInputA: boolean,
112
+ trustedInputB: boolean,
113
+ options?: MeshBooleanAsyncOptions,
114
+ ): Promise<Float64Array> {
111
115
  if (this.disposed) {
112
116
  return Promise.reject(
113
117
  new MeshBooleanExecutionError(
@@ -123,19 +127,21 @@ export class MeshBooleanWorkerPool {
123
127
  const job: BooleanJob = {
124
128
  id: jobId,
125
129
  operation,
126
- options: {
127
- allowUnsafe: options?.allowUnsafe ?? true,
128
- limits: options?.limits,
129
- backend: options?.backend,
130
- },
130
+ options: {
131
+ allowUnsafe: options?.allowUnsafe ?? true,
132
+ limits: options?.limits,
133
+ debugForceFaceID: options?.debugForceFaceID,
134
+ },
131
135
  onProgress: options?.onProgress,
132
136
  signal: options?.signal,
133
137
  timeoutMs: options?.timeoutMs,
134
- bufferA: new Float64Array(bufferA).buffer,
135
- bufferB: new Float64Array(bufferB).buffer,
136
- cancelView: createCancellationView(),
137
- resolve,
138
- reject,
138
+ bufferA: new Float64Array(bufferA).buffer,
139
+ bufferB: new Float64Array(bufferB).buffer,
140
+ trustedInputA,
141
+ trustedInputB,
142
+ cancelView: createCancellationView(),
143
+ resolve,
144
+ reject,
139
145
  };
140
146
 
141
147
  if (job.signal?.aborted) {
@@ -246,11 +252,13 @@ export class MeshBooleanWorkerPool {
246
252
  const request: MeshBooleanWorkerRequest = {
247
253
  kind: "mesh-boolean-request",
248
254
  jobId: job.id,
249
- operation: job.operation,
250
- bufferA: job.bufferA,
251
- bufferB: job.bufferB,
252
- cancelBuffer: job.cancelView?.buffer as SharedArrayBuffer | undefined,
253
- options: job.options,
255
+ operation: job.operation,
256
+ bufferA: job.bufferA,
257
+ bufferB: job.bufferB,
258
+ trustedInputA: job.trustedInputA,
259
+ trustedInputB: job.trustedInputB,
260
+ cancelBuffer: job.cancelView?.buffer as SharedArrayBuffer | undefined,
261
+ options: job.options,
254
262
  };
255
263
 
256
264
  try {
@@ -467,15 +475,17 @@ export function disposeMeshBooleanWorkerPools(): void {
467
475
  customPoolStores.clear();
468
476
  }
469
477
 
470
- export function runMeshBooleanInWorkerPool(
471
- operation: MeshBooleanOperation,
472
- bufferA: Float64Array,
473
- bufferB: Float64Array,
474
- options?: MeshBooleanAsyncOptions,
475
- ): Promise<Float64Array> {
476
- const pool = getMeshBooleanWorkerPool({
477
- workerFactory: options?.workerFactory,
478
- size: options?.poolSize,
479
- });
480
- return pool.run(operation, bufferA, bufferB, options);
481
- }
478
+ export function runMeshBooleanInWorkerPool(
479
+ operation: MeshBooleanOperation,
480
+ bufferA: Float64Array,
481
+ bufferB: Float64Array,
482
+ trustedInputA: boolean,
483
+ trustedInputB: boolean,
484
+ options?: MeshBooleanAsyncOptions,
485
+ ): Promise<Float64Array> {
486
+ const pool = getMeshBooleanWorkerPool({
487
+ workerFactory: options?.workerFactory,
488
+ size: options?.poolSize,
489
+ });
490
+ return pool.run(operation, bufferA, bufferB, trustedInputA, trustedInputB, options);
491
+ }
@@ -1,27 +1,26 @@
1
- export type MeshBooleanOperation = "union" | "subtraction" | "intersection";
2
- export type MeshBooleanBackend = "nextgen";
3
-
4
- export interface MeshBooleanLimits {
5
- maxInputFacesPerMesh: number;
1
+ export type MeshBooleanOperation = "union" | "subtraction" | "intersection";
2
+
3
+ export interface MeshBooleanLimits {
4
+ maxInputFacesPerMesh: number;
6
5
  maxCombinedInputFaces: number;
7
6
  maxFaceProduct: number;
8
7
  }
9
8
 
10
- export interface MeshBooleanOptions {
11
- /**
12
- * Override one or more safety limits for this operation.
13
- */
14
- limits?: Partial<MeshBooleanLimits>;
15
- /**
16
- * Skip safety limits and force boolean execution.
17
- */
18
- allowUnsafe?: boolean;
19
- /**
20
- * Boolean backend selector.
21
- * Defaults to "nextgen" (strict closed-solid topology contract).
22
- */
23
- backend?: MeshBooleanBackend;
24
- }
9
+ export interface MeshBooleanOptions {
10
+ /**
11
+ * Override one or more safety limits for this operation.
12
+ */
13
+ limits?: Partial<MeshBooleanLimits>;
14
+ /**
15
+ * Skip safety limits and force boolean execution.
16
+ */
17
+ allowUnsafe?: boolean;
18
+ /**
19
+ * Debug-only: force explicit per-triangle face IDs through the Boolean3 path.
20
+ * This is only intended for parity investigation.
21
+ */
22
+ debugForceFaceID?: boolean;
23
+ }
25
24
 
26
25
  export type MeshBooleanErrorCode =
27
26
  | "worker_unavailable"
@@ -69,17 +68,19 @@ export interface MeshBooleanAsyncOptions extends MeshBooleanOptions {
69
68
  onProgress?: (event: MeshBooleanProgressEvent) => void;
70
69
  }
71
70
 
72
- export interface MeshBooleanWorkerRequest {
73
- kind: "mesh-boolean-request";
74
- jobId: number;
75
- operation: MeshBooleanOperation;
76
- bufferA: ArrayBuffer;
77
- bufferB: ArrayBuffer;
78
- /**
79
- * Optional shared cancellation flag (index 0: 0=running, 1=cancel requested).
80
- * When present, kernel loops can cooperatively abort without waiting for
81
- * worker message handling.
82
- */
71
+ export interface MeshBooleanWorkerRequest {
72
+ kind: "mesh-boolean-request";
73
+ jobId: number;
74
+ operation: MeshBooleanOperation;
75
+ bufferA: ArrayBuffer;
76
+ bufferB: ArrayBuffer;
77
+ trustedInputA?: boolean;
78
+ trustedInputB?: boolean;
79
+ /**
80
+ * Optional shared cancellation flag (index 0: 0=running, 1=cancel requested).
81
+ * When present, kernel loops can cooperatively abort without waiting for
82
+ * worker message handling.
83
+ */
83
84
  cancelBuffer?: SharedArrayBuffer;
84
85
  options: MeshBooleanOptions;
85
86
  }
@@ -114,13 +114,17 @@ workerScope.addEventListener("message", async (event: MessageEvent<MeshBooleanWo
114
114
 
115
115
  workerGlobal.__okgeometryBooleanCancelFlag = cancelView ?? null;
116
116
 
117
- const meshA = Mesh.fromBuffer(new Float64Array(message.bufferA));
118
- const meshB = Mesh.fromBuffer(new Float64Array(message.bufferB));
119
- const options = {
120
- allowUnsafe: message.options.allowUnsafe ?? true,
121
- limits: message.options.limits,
122
- backend: message.options.backend,
123
- };
117
+ const meshA = Mesh.fromBuffer(new Float64Array(message.bufferA), {
118
+ trustedBooleanInput: message.trustedInputA,
119
+ });
120
+ const meshB = Mesh.fromBuffer(new Float64Array(message.bufferB), {
121
+ trustedBooleanInput: message.trustedInputB,
122
+ });
123
+ const options = {
124
+ allowUnsafe: message.options.allowUnsafe ?? true,
125
+ limits: message.options.limits,
126
+ debugForceFaceID: message.options.debugForceFaceID,
127
+ };
124
128
 
125
129
  let result: Mesh;
126
130
  if (message.operation === "union") {