okgeometry-api 1.1.4 → 1.1.6
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 +7 -4
- package/dist/Mesh.d.ts.map +1 -1
- package/dist/Mesh.js +42 -13
- package/dist/Mesh.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.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 +3 -2
- package/src/Mesh.ts +70 -26
- package/src/index.ts +1 -0
- package/src/wasm-base64.ts +1 -1
- package/wasm/okgeometrycore.d.ts +1 -1
- package/wasm/okgeometrycore.js +2 -2
- package/wasm/okgeometrycore_bg.wasm +0 -0
- package/wasm/package.json +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,08kvDAA08kvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "okgeometry-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
4
4
|
"description": "Geometry engine API for AEC applications — NURBS, meshes, booleans, intersections. Powered by Rust/WASM.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,8 +17,9 @@
|
|
|
17
17
|
"wasm/"
|
|
18
18
|
],
|
|
19
19
|
"scripts": {
|
|
20
|
+
"build:wasm": "cd .. && wasm-pack build --target web --out-dir okgeometry-api/wasm",
|
|
20
21
|
"inline-wasm": "tsx scripts/inline-wasm.ts",
|
|
21
|
-
"build": "npm run inline-wasm && tsc",
|
|
22
|
+
"build": "npm run build:wasm && npm run inline-wasm && tsc",
|
|
22
23
|
"bench:boolean-manifold-baseline": "npm run build && tsx scripts/bench-boolean-manifold-baseline.ts",
|
|
23
24
|
"bench:boolean-replacement-heavy": "npm run build && tsx scripts/bench-boolean-replacement-heavy.ts",
|
|
24
25
|
"bench:boolean-deterministic": "npm run build && tsx scripts/bench-boolean-deterministic.ts",
|
package/src/Mesh.ts
CHANGED
|
@@ -104,10 +104,13 @@ export interface MeshBooleanDebugProbe {
|
|
|
104
104
|
resultHits: MeshDebugRayHit[];
|
|
105
105
|
}
|
|
106
106
|
|
|
107
|
+
export type MeshBooleanDebugProbeId =
|
|
108
|
+
"posX" | "negX" | "posY" | "negY" | "posZ" | "negZ";
|
|
109
|
+
|
|
107
110
|
export interface MeshBooleanDebugOptions {
|
|
108
111
|
rayPaddingScale?: number;
|
|
109
112
|
maxRayHits?: number;
|
|
110
|
-
probes?:
|
|
113
|
+
probes?: MeshBooleanDebugProbeId[];
|
|
111
114
|
}
|
|
112
115
|
|
|
113
116
|
export interface MeshBooleanDebugReport {
|
|
@@ -129,9 +132,14 @@ export class Mesh {
|
|
|
129
132
|
private _buffer: Float64Array;
|
|
130
133
|
private _vertexCount: number;
|
|
131
134
|
private _trustedBooleanInput: boolean;
|
|
132
|
-
private static readonly DEFAULT_BOOLEAN_DEBUG_PROBES:
|
|
133
|
-
"posX"
|
|
134
|
-
|
|
135
|
+
private static readonly DEFAULT_BOOLEAN_DEBUG_PROBES: MeshBooleanDebugProbeId[] = [
|
|
136
|
+
"posX",
|
|
137
|
+
"negX",
|
|
138
|
+
"posY",
|
|
139
|
+
"negY",
|
|
140
|
+
"posZ",
|
|
141
|
+
"negZ",
|
|
142
|
+
];
|
|
135
143
|
|
|
136
144
|
private static readonly DEFAULT_BOOLEAN_LIMITS: MeshBooleanLimits = {
|
|
137
145
|
maxInputFacesPerMesh: 120_000,
|
|
@@ -278,6 +286,28 @@ export class Mesh {
|
|
|
278
286
|
}));
|
|
279
287
|
}
|
|
280
288
|
|
|
289
|
+
private static uniqueDebugProbeIds(
|
|
290
|
+
probeIds: MeshBooleanDebugProbeId[],
|
|
291
|
+
): MeshBooleanDebugProbeId[] {
|
|
292
|
+
return [...new Set(probeIds)];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
private static buildInputBProbeOriginOffsets(
|
|
296
|
+
jitter: number,
|
|
297
|
+
): Record<MeshBooleanDebugProbeId, Vec3> {
|
|
298
|
+
const major = jitter;
|
|
299
|
+
const minor = jitter * 0.61803398875;
|
|
300
|
+
const micro = jitter * 0.38196601125;
|
|
301
|
+
return {
|
|
302
|
+
posX: new Vec3(0, minor, -major),
|
|
303
|
+
negX: new Vec3(0, -minor, major),
|
|
304
|
+
posY: new Vec3(major, 0, micro),
|
|
305
|
+
negY: new Vec3(-major, 0, -micro),
|
|
306
|
+
posZ: new Vec3(major, -minor, 0),
|
|
307
|
+
negZ: new Vec3(-major, minor, 0),
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
|
|
281
311
|
private static buildDirectionalDebugProbes(
|
|
282
312
|
inputA: Mesh,
|
|
283
313
|
inputB: Mesh,
|
|
@@ -286,12 +316,13 @@ export class Mesh {
|
|
|
286
316
|
pad: number,
|
|
287
317
|
maxDistance: number,
|
|
288
318
|
maxHits: number,
|
|
289
|
-
probeIds:
|
|
319
|
+
probeIds: MeshBooleanDebugProbeId[],
|
|
290
320
|
labelPrefix = "",
|
|
321
|
+
originOffsets?: Partial<Record<MeshBooleanDebugProbeId, Vec3>>,
|
|
291
322
|
): MeshBooleanDebugProbe[] {
|
|
292
323
|
const prefixed = (id: string) => (labelPrefix ? `${labelPrefix}:${id}` : id);
|
|
293
324
|
const probeSpecs: Record<
|
|
294
|
-
|
|
325
|
+
MeshBooleanDebugProbeId,
|
|
295
326
|
{ origin: Point; direction: Vec3 }
|
|
296
327
|
> = {
|
|
297
328
|
posX: {
|
|
@@ -322,14 +353,22 @@ export class Mesh {
|
|
|
322
353
|
|
|
323
354
|
return probeIds.map((id) => {
|
|
324
355
|
const spec = probeSpecs[id];
|
|
356
|
+
const originOffset = originOffsets?.[id];
|
|
357
|
+
const origin = originOffset
|
|
358
|
+
? new Point(
|
|
359
|
+
spec.origin.x + originOffset.x,
|
|
360
|
+
spec.origin.y + originOffset.y,
|
|
361
|
+
spec.origin.z + originOffset.z,
|
|
362
|
+
)
|
|
363
|
+
: spec.origin;
|
|
325
364
|
return {
|
|
326
365
|
label: prefixed(id),
|
|
327
|
-
origin
|
|
366
|
+
origin,
|
|
328
367
|
direction: spec.direction,
|
|
329
368
|
maxDistance,
|
|
330
|
-
inputAHits: Mesh.collectDebugHits(inputA,
|
|
331
|
-
inputBHits: Mesh.collectDebugHits(inputB,
|
|
332
|
-
resultHits: Mesh.collectDebugHits(result,
|
|
369
|
+
inputAHits: Mesh.collectDebugHits(inputA, origin, spec.direction, maxDistance, maxHits),
|
|
370
|
+
inputBHits: Mesh.collectDebugHits(inputB, origin, spec.direction, maxDistance, maxHits),
|
|
371
|
+
resultHits: Mesh.collectDebugHits(result, origin, spec.direction, maxDistance, maxHits),
|
|
333
372
|
};
|
|
334
373
|
});
|
|
335
374
|
}
|
|
@@ -367,9 +406,13 @@ export class Mesh {
|
|
|
367
406
|
: 0.25;
|
|
368
407
|
const pad = Math.max(1e-3, diag * padScale);
|
|
369
408
|
const maxHits = Mesh.clampDebugHitCount(options?.maxRayHits);
|
|
370
|
-
const
|
|
371
|
-
|
|
372
|
-
|
|
409
|
+
const sceneProbeIds = Mesh.uniqueDebugProbeIds(
|
|
410
|
+
options?.probes?.length
|
|
411
|
+
? options.probes
|
|
412
|
+
: Mesh.DEFAULT_BOOLEAN_DEBUG_PROBES,
|
|
413
|
+
);
|
|
414
|
+
const inputBProbeIds = Mesh.uniqueDebugProbeIds(sceneProbeIds.concat(["posZ", "negZ"]));
|
|
415
|
+
const inputBJitter = Math.max(1e-6, Math.min(pad * 0.1, boundsB.diagonal * 0.01));
|
|
373
416
|
const maxDistance = diag + pad * 2;
|
|
374
417
|
const sceneCenterProbes = Mesh.buildDirectionalDebugProbes(
|
|
375
418
|
inputA,
|
|
@@ -379,7 +422,7 @@ export class Mesh {
|
|
|
379
422
|
pad,
|
|
380
423
|
maxDistance,
|
|
381
424
|
maxHits,
|
|
382
|
-
|
|
425
|
+
sceneProbeIds,
|
|
383
426
|
);
|
|
384
427
|
const inputBCenterProbes = Mesh.buildDirectionalDebugProbes(
|
|
385
428
|
inputA,
|
|
@@ -389,8 +432,9 @@ export class Mesh {
|
|
|
389
432
|
pad,
|
|
390
433
|
maxDistance,
|
|
391
434
|
maxHits,
|
|
392
|
-
|
|
435
|
+
inputBProbeIds,
|
|
393
436
|
"inputB",
|
|
437
|
+
Mesh.buildInputBProbeOriginOffsets(inputBJitter),
|
|
394
438
|
);
|
|
395
439
|
return sceneCenterProbes.concat(inputBCenterProbes);
|
|
396
440
|
}
|
|
@@ -962,17 +1006,17 @@ export class Mesh {
|
|
|
962
1006
|
return Mesh.fromTrustedBuffer(wasm.mesh_create_box(width, height, depth));
|
|
963
1007
|
}
|
|
964
1008
|
|
|
965
|
-
/**
|
|
966
|
-
* Create a
|
|
967
|
-
* @param radius - Sphere radius
|
|
968
|
-
* @param segments -
|
|
969
|
-
* @param rings -
|
|
970
|
-
* @returns New Mesh representing the sphere
|
|
971
|
-
*/
|
|
972
|
-
static createSphere(radius: number, segments: number, rings: number): Mesh {
|
|
973
|
-
ensureInit();
|
|
974
|
-
return Mesh.fromTrustedBuffer(wasm.mesh_create_sphere(radius, segments, rings));
|
|
975
|
-
}
|
|
1009
|
+
/**
|
|
1010
|
+
* Create a geodesic sphere centered at origin, matching Manifold's sphere topology.
|
|
1011
|
+
* @param radius - Sphere radius
|
|
1012
|
+
* @param segments - Segment hint; rounded up internally to a multiple of 4
|
|
1013
|
+
* @param rings - Compatibility-only detail hint; the higher of `segments` and `rings` is used
|
|
1014
|
+
* @returns New Mesh representing the sphere
|
|
1015
|
+
*/
|
|
1016
|
+
static createSphere(radius: number, segments: number, rings: number): Mesh {
|
|
1017
|
+
ensureInit();
|
|
1018
|
+
return Mesh.fromTrustedBuffer(wasm.mesh_create_sphere(radius, segments, rings));
|
|
1019
|
+
}
|
|
976
1020
|
|
|
977
1021
|
/**
|
|
978
1022
|
* Create a cylinder centered at origin with axis along Y.
|
package/src/index.ts
CHANGED
|
@@ -36,6 +36,7 @@ export { NurbsSurface } from "./NurbsSurface.js";
|
|
|
36
36
|
export { Mesh, MeshBooleanExecutionError } from "./Mesh.js";
|
|
37
37
|
export type {
|
|
38
38
|
MeshBooleanOperation,
|
|
39
|
+
MeshBooleanDebugProbeId,
|
|
39
40
|
MeshBooleanDebugOptions,
|
|
40
41
|
MeshBooleanDebugProbe,
|
|
41
42
|
MeshBooleanDebugReport,
|