brepjs 12.2.12 → 12.4.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/2d/blueprints/Blueprint.d.ts +1 -1
- package/dist/2d/blueprints/Blueprint.d.ts.map +1 -1
- package/dist/2d.cjs +2 -2
- package/dist/2d.js +3 -3
- package/dist/{Blueprint-CX2oh-NE.cjs → Blueprint-CoFJDAQd.cjs} +6 -6
- package/dist/{Blueprint-BWAzjtvF.js → Blueprint-CtuUvzex.js} +6 -6
- package/dist/{boolean2D-G9edb4Pw.cjs → boolean2D-Dk-vLBdl.cjs} +8 -8
- package/dist/{boolean2D-B17ZPZ63.js → boolean2D-x2irapGj.js} +8 -8
- package/dist/{booleanFns-DQj7i7qb.cjs → booleanFns-BJjYqwJ5.cjs} +3 -3
- package/dist/{booleanFns-EsNGs4Zu.js → booleanFns-DtOkwLHI.js} +3 -3
- package/dist/brepjs.cjs +343 -35
- package/dist/brepjs.js +383 -75
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{cornerFinder-NbeO5KWC.cjs → cornerFinder-BESZIitp.cjs} +2 -2
- package/dist/{cornerFinder-57qxNypG.js → cornerFinder-FY38t0zq.js} +2 -2
- package/dist/{curveFns-BN9bWCIl.cjs → curveFns-Ch87sD5O.cjs} +1 -1
- package/dist/{curveFns-DRb_8jyd.js → curveFns-LRNGcHXh.js} +1 -1
- package/dist/{drawFns-Br57GZWI.cjs → drawFns-BEeoD1yO.cjs} +16 -16
- package/dist/{drawFns-DWTCgzlb.js → drawFns-D8QyY7cg.js} +16 -16
- package/dist/{faceFns-Dka8xvYk.js → faceFns-B6ebRh5I.js} +6 -2
- package/dist/{faceFns-Cfvj4nxx.cjs → faceFns-BLTEPBKq.cjs} +5 -1
- package/dist/{helpers-Cu_7Qo9J.cjs → helpers-DNzVfe-Z.cjs} +4 -4
- package/dist/{helpers-10HaneKK.js → helpers-DeFPsrcI.js} +4 -4
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/io.cjs +3 -3
- package/dist/io.js +3 -3
- package/dist/kernel/advancedOps.d.ts +2 -0
- package/dist/kernel/advancedOps.d.ts.map +1 -1
- package/dist/kernel/brepkitAdapter.d.ts +59 -0
- package/dist/kernel/brepkitAdapter.d.ts.map +1 -1
- package/dist/kernel/brepkitWasmTypes.d.ts +2 -2
- package/dist/kernel/brepkitWasmTypes.d.ts.map +1 -1
- package/dist/kernel/defaultAdapter.d.ts +35 -0
- package/dist/kernel/defaultAdapter.d.ts.map +1 -1
- package/dist/kernel/index.d.ts +2 -2
- package/dist/kernel/index.d.ts.map +1 -1
- package/dist/kernel/types.d.ts +85 -0
- package/dist/kernel/types.d.ts.map +1 -1
- package/dist/{loft-BDnb8toT.cjs → loft-DR1UN5uN.cjs} +4 -4
- package/dist/{loft-DTFP5fVL.js → loft-DsVv4yxU.js} +4 -4
- package/dist/{measurement-ypLLNq5y.cjs → measurement-DoYXRaKI.cjs} +2 -2
- package/dist/{measurement-9v764TRE.js → measurement-oWvhSVZG.js} +2 -2
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-xWim4bEU.cjs → meshFns-BU2l_yOm.cjs} +2 -2
- package/dist/{meshFns-B1FRGCo4.js → meshFns-HNwWuM4v.js} +2 -2
- package/dist/{operations-CLaaoj2N.cjs → operations-D-gTZNtM.cjs} +6 -6
- package/dist/{operations-C0597E2p.js → operations-D_3rrfrE.js} +6 -6
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/query.cjs +4 -4
- package/dist/query.js +5 -5
- package/dist/{shapeFns-Dim8UTHh.js → shapeFns-CbXxLvV_.js} +2 -2
- package/dist/{shapeFns-ZbzAD8yC.cjs → shapeFns-DHlLNHTn.cjs} +2 -2
- package/dist/{shapeTypes-BQGbhdgi.cjs → shapeTypes-7xEam9Ri.cjs} +124 -0
- package/dist/{shapeTypes-ByN4-0Hp.js → shapeTypes-CpSaBLDv.js} +124 -0
- package/dist/sketching.cjs +2 -2
- package/dist/sketching.js +2 -2
- package/dist/{solidBuilders-Bc6kgqJ9.js → solidBuilders-BXhh5hP2.js} +2 -2
- package/dist/{solidBuilders-CYEEZgiP.cjs → solidBuilders-BzfRBizW.cjs} +2 -2
- package/dist/{surfaceBuilders-CXarnCh8.cjs → surfaceBuilders-Be_ENWSA.cjs} +2 -2
- package/dist/{surfaceBuilders-Bdn7iqv5.js → surfaceBuilders-D7ZH2QNS.js} +2 -2
- package/dist/topology/adjacencyFns.d.ts.map +1 -1
- package/dist/topology/faceFns.d.ts +5 -0
- package/dist/topology/faceFns.d.ts.map +1 -1
- package/dist/{topology-CPYjaISY.cjs → topology-BHnY7Szr.cjs} +8 -8
- package/dist/{topology-Cq1j_bp1.js → topology-C1eZ86dI.js} +8 -8
- package/dist/topology.cjs +6 -6
- package/dist/topology.js +7 -7
- package/package.json +4 -4
package/dist/brepjs.cjs
CHANGED
|
@@ -45,35 +45,38 @@ var __callDispose = (stack, error, hasError) => {
|
|
|
45
45
|
return next();
|
|
46
46
|
};
|
|
47
47
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
48
|
-
const shapeTypes = require("./shapeTypes-
|
|
48
|
+
const shapeTypes = require("./shapeTypes-7xEam9Ri.cjs");
|
|
49
49
|
const errors = require("./errors-9fDehDNc.cjs");
|
|
50
50
|
const vecOps = require("./vecOps-CjRL1jau.cjs");
|
|
51
|
-
const Blueprint = require("./Blueprint-
|
|
52
|
-
const loft$2 = require("./loft-
|
|
53
|
-
const operations = require("./operations-
|
|
54
|
-
const boolean2D = require("./boolean2D-
|
|
51
|
+
const Blueprint = require("./Blueprint-CoFJDAQd.cjs");
|
|
52
|
+
const loft$2 = require("./loft-DR1UN5uN.cjs");
|
|
53
|
+
const operations = require("./operations-D-gTZNtM.cjs");
|
|
54
|
+
const boolean2D = require("./boolean2D-Dk-vLBdl.cjs");
|
|
55
55
|
const _2d = require("./2d.cjs");
|
|
56
|
-
const helpers = require("./helpers-
|
|
56
|
+
const helpers = require("./helpers-DNzVfe-Z.cjs");
|
|
57
57
|
const io = require("./io.cjs");
|
|
58
|
-
const drawFns = require("./drawFns-
|
|
58
|
+
const drawFns = require("./drawFns-BEeoD1yO.cjs");
|
|
59
59
|
const types = require("./types-CA_xrgDq.cjs");
|
|
60
60
|
const vectors = require("./vectors-TlfO1hu2.cjs");
|
|
61
|
-
const shapeFns = require("./shapeFns-
|
|
62
|
-
const booleanFns = require("./booleanFns-
|
|
63
|
-
const topology = require("./topology-
|
|
64
|
-
const curveFns = require("./curveFns-
|
|
65
|
-
const faceFns = require("./faceFns-
|
|
66
|
-
const meshFns = require("./meshFns-
|
|
67
|
-
const measurement = require("./measurement-
|
|
68
|
-
const surfaceBuilders = require("./surfaceBuilders-
|
|
61
|
+
const shapeFns = require("./shapeFns-DHlLNHTn.cjs");
|
|
62
|
+
const booleanFns = require("./booleanFns-BJjYqwJ5.cjs");
|
|
63
|
+
const topology = require("./topology-BHnY7Szr.cjs");
|
|
64
|
+
const curveFns = require("./curveFns-Ch87sD5O.cjs");
|
|
65
|
+
const faceFns = require("./faceFns-BLTEPBKq.cjs");
|
|
66
|
+
const meshFns = require("./meshFns-BU2l_yOm.cjs");
|
|
67
|
+
const measurement = require("./measurement-DoYXRaKI.cjs");
|
|
68
|
+
const surfaceBuilders = require("./surfaceBuilders-Be_ENWSA.cjs");
|
|
69
69
|
const query = require("./query.cjs");
|
|
70
|
-
const solidBuilders = require("./solidBuilders-
|
|
70
|
+
const solidBuilders = require("./solidBuilders-BzfRBizW.cjs");
|
|
71
71
|
const result = require("./result.cjs");
|
|
72
|
-
const cornerFinder = require("./cornerFinder-
|
|
72
|
+
const cornerFinder = require("./cornerFinder-BESZIitp.cjs");
|
|
73
73
|
const worker = require("./worker.cjs");
|
|
74
74
|
function supportsProjection(kernel) {
|
|
75
75
|
return "projectShape" in kernel;
|
|
76
76
|
}
|
|
77
|
+
function supportsConstraintSketch(kernel) {
|
|
78
|
+
return "sketchNew" in kernel && "sketchDof" in kernel;
|
|
79
|
+
}
|
|
77
80
|
function evaluateCurve2d(c, t) {
|
|
78
81
|
switch (c.__bk2d) {
|
|
79
82
|
case "line":
|
|
@@ -706,6 +709,9 @@ function dist3(x1, y1, z1, x2, y2, z2) {
|
|
|
706
709
|
const dx = x1 - x2, dy = y1 - y2, dz = z1 - z2;
|
|
707
710
|
return Math.sqrt(dx * dx + dy * dy + dz * dz);
|
|
708
711
|
}
|
|
712
|
+
function copyWasmBytes(bytes) {
|
|
713
|
+
return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength);
|
|
714
|
+
}
|
|
709
715
|
function translationMatrix(x, y, z) {
|
|
710
716
|
return [
|
|
711
717
|
1,
|
|
@@ -2037,7 +2043,7 @@ class BrepkitAdapter {
|
|
|
2037
2043
|
const deflection = options.tolerance || DEFAULT_DEFLECTION;
|
|
2038
2044
|
let result2;
|
|
2039
2045
|
if (bkHandle.type === "solid") {
|
|
2040
|
-
result2 = this.meshSolid(h, deflection);
|
|
2046
|
+
result2 = this.meshSolid(h, deflection, !!options.includeUVs);
|
|
2041
2047
|
} else if (bkHandle.type === "face") {
|
|
2042
2048
|
result2 = this.meshSingleFace(h, deflection, 0);
|
|
2043
2049
|
} else {
|
|
@@ -2988,8 +2994,10 @@ class BrepkitAdapter {
|
|
|
2988
2994
|
const id = this.bk.addHolesToFace(unwrap(face, "face"), wireIds);
|
|
2989
2995
|
return faceHandle(id);
|
|
2990
2996
|
}
|
|
2991
|
-
|
|
2992
|
-
|
|
2997
|
+
removeHolesFromFace(face) {
|
|
2998
|
+
const id = this.bk.removeHolesFromFace(unwrap(face, "face"));
|
|
2999
|
+
return faceHandle(id);
|
|
3000
|
+
}
|
|
2993
3001
|
makeFaceOnSurface(_surface, wire) {
|
|
2994
3002
|
return this.makeFace(wire, true);
|
|
2995
3003
|
}
|
|
@@ -3250,9 +3258,25 @@ class BrepkitAdapter {
|
|
|
3250
3258
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3251
3259
|
// Dispose
|
|
3252
3260
|
// ═══════════════════════════════════════════════════════════════════════
|
|
3253
|
-
|
|
3254
|
-
|
|
3255
|
-
|
|
3261
|
+
/**
|
|
3262
|
+
* Create an arena checkpoint. Returns checkpoint index.
|
|
3263
|
+
* Use {@link restoreCheckpoint} to roll back or {@link discardCheckpoint} to keep.
|
|
3264
|
+
*/
|
|
3265
|
+
checkpoint() {
|
|
3266
|
+
return this.bk.checkpoint();
|
|
3267
|
+
}
|
|
3268
|
+
/** Get the current number of active checkpoints. */
|
|
3269
|
+
checkpointCount() {
|
|
3270
|
+
return this.bk.checkpointCount();
|
|
3271
|
+
}
|
|
3272
|
+
/** Restore arena to a checkpoint, freeing all handles created after it. */
|
|
3273
|
+
restoreCheckpoint(cp) {
|
|
3274
|
+
this.bk.restore(cp);
|
|
3275
|
+
}
|
|
3276
|
+
/** Discard a checkpoint without restoring (keep all handles). */
|
|
3277
|
+
discardCheckpoint(cp) {
|
|
3278
|
+
this.bk.discardCheckpoint(cp);
|
|
3279
|
+
}
|
|
3256
3280
|
dispose(_handle) {
|
|
3257
3281
|
}
|
|
3258
3282
|
// ═══════════════════════════════════════════════════════════════════════
|
|
@@ -3879,22 +3903,62 @@ class BrepkitAdapter {
|
|
|
3879
3903
|
}
|
|
3880
3904
|
extractCurve2dFromEdge(edge, face) {
|
|
3881
3905
|
const eid = unwrap(edge, "edge");
|
|
3882
|
-
unwrap(face, "face");
|
|
3906
|
+
const fid = unwrap(face, "face");
|
|
3883
3907
|
const params = this.bk.getEdgeCurveParameters(eid);
|
|
3884
3908
|
const tMin = params[0] ?? 0;
|
|
3885
3909
|
const tMax = params[1] ?? 1;
|
|
3886
|
-
const
|
|
3887
|
-
const
|
|
3888
|
-
|
|
3889
|
-
|
|
3910
|
+
const BASE_N = 20;
|
|
3911
|
+
const MAX_N = 80;
|
|
3912
|
+
const REFINE_THRESHOLD = 0.05;
|
|
3913
|
+
const tValues = [];
|
|
3914
|
+
for (let i = 0; i <= BASE_N; i++) {
|
|
3915
|
+
tValues.push(tMin + (tMax - tMin) * i / BASE_N);
|
|
3916
|
+
}
|
|
3917
|
+
const evaluateUV = (t) => {
|
|
3890
3918
|
const pt = this.bk.evaluateEdgeCurve(eid, t);
|
|
3891
|
-
|
|
3919
|
+
const uv = this.bk.projectPointOnSurface(fid, pt[0], pt[1], pt[2]);
|
|
3920
|
+
return [uv[0], uv[1]];
|
|
3921
|
+
};
|
|
3922
|
+
const uvSamples = tValues.map((t) => ({
|
|
3923
|
+
t,
|
|
3924
|
+
uv: evaluateUV(t)
|
|
3925
|
+
}));
|
|
3926
|
+
let refinements = 0;
|
|
3927
|
+
while (uvSamples.length < MAX_N) {
|
|
3928
|
+
const insertions = [];
|
|
3929
|
+
for (let i = 0; i < uvSamples.length - 1; i++) {
|
|
3930
|
+
const a = uvSamples[i];
|
|
3931
|
+
const b = uvSamples[i + 1];
|
|
3932
|
+
const tMid = (a.t + b.t) / 2;
|
|
3933
|
+
const uvMid = evaluateUV(tMid);
|
|
3934
|
+
const interpU = (a.uv[0] + b.uv[0]) / 2;
|
|
3935
|
+
const interpV = (a.uv[1] + b.uv[1]) / 2;
|
|
3936
|
+
const deviation = Math.sqrt((uvMid[0] - interpU) ** 2 + (uvMid[1] - interpV) ** 2);
|
|
3937
|
+
if (deviation > REFINE_THRESHOLD) {
|
|
3938
|
+
insertions.push({ index: i + 1, t: tMid, uv: uvMid });
|
|
3939
|
+
}
|
|
3940
|
+
}
|
|
3941
|
+
if (insertions.length === 0) break;
|
|
3942
|
+
let budget = MAX_N - uvSamples.length;
|
|
3943
|
+
for (let j = insertions.length - 1; j >= 0 && budget > 0; j--) {
|
|
3944
|
+
const ins = insertions[j];
|
|
3945
|
+
uvSamples.splice(ins.index, 0, { t: ins.t, uv: ins.uv });
|
|
3946
|
+
budget--;
|
|
3947
|
+
}
|
|
3948
|
+
refinements++;
|
|
3949
|
+
if (refinements > 3) break;
|
|
3892
3950
|
}
|
|
3951
|
+
const uvPoints = uvSamples.map((s) => s.uv);
|
|
3893
3952
|
if (uvPoints.length >= 2) {
|
|
3894
3953
|
return this.makeBSpline2d(uvPoints);
|
|
3895
3954
|
}
|
|
3896
3955
|
const verts = this.bk.getEdgeVertices(eid);
|
|
3897
|
-
|
|
3956
|
+
if (verts.length >= 6) {
|
|
3957
|
+
const uv1 = this.bk.projectPointOnSurface(fid, verts[0], verts[1], verts[2]);
|
|
3958
|
+
const uv2 = this.bk.projectPointOnSurface(fid, verts[3], verts[4], verts[5]);
|
|
3959
|
+
return makeLine2d(uv1[0], uv1[1], uv2[0], uv2[1]);
|
|
3960
|
+
}
|
|
3961
|
+
throw new Error(`brepkit: extractCurve2dFromEdge: degenerate edge (${verts.length} coords)`);
|
|
3898
3962
|
}
|
|
3899
3963
|
buildCurves3d(_wire) {
|
|
3900
3964
|
}
|
|
@@ -4011,9 +4075,9 @@ class BrepkitAdapter {
|
|
|
4011
4075
|
return result2;
|
|
4012
4076
|
}
|
|
4013
4077
|
/** Tessellate a solid with per-face groups for brepjs mesh format. */
|
|
4014
|
-
meshSolid(solidId, deflection) {
|
|
4078
|
+
meshSolid(solidId, deflection, includeUVs) {
|
|
4015
4079
|
try {
|
|
4016
|
-
return this.meshSolidGrouped(solidId, deflection);
|
|
4080
|
+
return this.meshSolidGrouped(solidId, deflection, includeUVs);
|
|
4017
4081
|
} catch (e) {
|
|
4018
4082
|
console.warn(
|
|
4019
4083
|
`brepkit: tessellateSolidGrouped failed (solidId=${solidId}), falling back to per-face:`,
|
|
@@ -4025,8 +4089,11 @@ class BrepkitAdapter {
|
|
|
4025
4089
|
/**
|
|
4026
4090
|
* Batch tessellation via `tessellateSolidGrouped` — single WASM call for
|
|
4027
4091
|
* all faces. Falls back to `meshSolidPerFace` on error.
|
|
4092
|
+
*
|
|
4093
|
+
* When `includeUVs` is true, makes an additional `tessellateSolidUV` call
|
|
4094
|
+
* to populate real surface parametrization coordinates.
|
|
4028
4095
|
*/
|
|
4029
|
-
meshSolidGrouped(solidId, deflection) {
|
|
4096
|
+
meshSolidGrouped(solidId, deflection, includeUVs) {
|
|
4030
4097
|
const json = this.bk.tessellateSolidGrouped(solidId, deflection);
|
|
4031
4098
|
const data = JSON.parse(json);
|
|
4032
4099
|
const faceIds = toArray(this.bk.getSolidFaces(solidId));
|
|
@@ -4047,12 +4114,26 @@ class BrepkitAdapter {
|
|
|
4047
4114
|
faceHash: faceIds[i] ?? 0
|
|
4048
4115
|
});
|
|
4049
4116
|
}
|
|
4117
|
+
let uvs = new Float32Array(0);
|
|
4118
|
+
if (includeUVs) {
|
|
4119
|
+
const expectedUvLen = data.positions.length / 3 * 2;
|
|
4120
|
+
try {
|
|
4121
|
+
const uvJson = this.bk.tessellateSolidUV(solidId, deflection);
|
|
4122
|
+
const uvData = JSON.parse(uvJson);
|
|
4123
|
+
if (uvData.uvs.length === expectedUvLen) {
|
|
4124
|
+
uvs = new Float32Array(uvData.uvs);
|
|
4125
|
+
} else {
|
|
4126
|
+
uvs = new Float32Array(expectedUvLen);
|
|
4127
|
+
}
|
|
4128
|
+
} catch {
|
|
4129
|
+
uvs = new Float32Array(expectedUvLen);
|
|
4130
|
+
}
|
|
4131
|
+
}
|
|
4050
4132
|
return {
|
|
4051
4133
|
vertices: new Float32Array(data.positions),
|
|
4052
4134
|
normals: new Float32Array(data.normals),
|
|
4053
4135
|
triangles: new Uint32Array(data.indices),
|
|
4054
|
-
|
|
4055
|
-
uvs: new Float32Array(0),
|
|
4136
|
+
uvs,
|
|
4056
4137
|
faceGroups
|
|
4057
4138
|
};
|
|
4058
4139
|
}
|
|
@@ -4336,6 +4417,231 @@ class BrepkitAdapter {
|
|
|
4336
4417
|
}
|
|
4337
4418
|
return { point: [0, 0, 0], normal };
|
|
4338
4419
|
}
|
|
4420
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4421
|
+
// Constraint sketch solver (brepkit-only capability)
|
|
4422
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4423
|
+
/** Create a new constraint sketch. Returns an opaque sketch handle. */
|
|
4424
|
+
sketchNew() {
|
|
4425
|
+
return this.bk.sketchNew();
|
|
4426
|
+
}
|
|
4427
|
+
/** Add a point to a constraint sketch. Returns the point index. */
|
|
4428
|
+
sketchAddPoint(sketch, x, y, fixed) {
|
|
4429
|
+
return this.bk.sketchAddPoint(sketch, x, y, fixed);
|
|
4430
|
+
}
|
|
4431
|
+
/** Add a constraint to a sketch (JSON-encoded constraint descriptor). */
|
|
4432
|
+
sketchAddConstraint(sketch, constraintJson) {
|
|
4433
|
+
this.bk.sketchAddConstraint(sketch, constraintJson);
|
|
4434
|
+
}
|
|
4435
|
+
/**
|
|
4436
|
+
* Solve sketch constraints. Returns a JSON result with solved point positions.
|
|
4437
|
+
* @param maxIterations — solver iteration limit (e.g. 100)
|
|
4438
|
+
* @param tolerance — convergence tolerance (e.g. 1e-10)
|
|
4439
|
+
*/
|
|
4440
|
+
sketchSolve(sketch, maxIterations, tolerance) {
|
|
4441
|
+
return this.bk.sketchSolve(sketch, maxIterations, tolerance);
|
|
4442
|
+
}
|
|
4443
|
+
/** Get degrees of freedom remaining in a solved or partially-constrained sketch. */
|
|
4444
|
+
sketchDof(sketch) {
|
|
4445
|
+
return this.bk.sketchDof(sketch);
|
|
4446
|
+
}
|
|
4447
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4448
|
+
// Extended I/O formats
|
|
4449
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4450
|
+
export3MF(shape2, tolerance) {
|
|
4451
|
+
const solidId = unwrapSolidOrThrow(shape2, "export3MF");
|
|
4452
|
+
return copyWasmBytes(this.bk.export3mf(solidId, tolerance));
|
|
4453
|
+
}
|
|
4454
|
+
exportGLB(shape2, tolerance) {
|
|
4455
|
+
const solidId = unwrapSolidOrThrow(shape2, "exportGLB");
|
|
4456
|
+
return copyWasmBytes(this.bk.exportGlb(solidId, tolerance));
|
|
4457
|
+
}
|
|
4458
|
+
exportOBJ(shape2, tolerance) {
|
|
4459
|
+
const solidId = unwrapSolidOrThrow(shape2, "exportOBJ");
|
|
4460
|
+
return copyWasmBytes(this.bk.exportObj(solidId, tolerance));
|
|
4461
|
+
}
|
|
4462
|
+
exportPLY(shape2, tolerance) {
|
|
4463
|
+
const solidId = unwrapSolidOrThrow(shape2, "exportPLY");
|
|
4464
|
+
return copyWasmBytes(this.bk.exportPly(solidId, tolerance));
|
|
4465
|
+
}
|
|
4466
|
+
import3MF(data) {
|
|
4467
|
+
const result2 = toArray(this.bk.import3mf(new Uint8Array(data)));
|
|
4468
|
+
return result2.map((id) => solidHandle(id));
|
|
4469
|
+
}
|
|
4470
|
+
importOBJ(data) {
|
|
4471
|
+
const result2 = this.bk.importObj(new Uint8Array(data));
|
|
4472
|
+
return solidHandle(result2);
|
|
4473
|
+
}
|
|
4474
|
+
importGLB(data) {
|
|
4475
|
+
const result2 = this.bk.importGlb(new Uint8Array(data));
|
|
4476
|
+
return solidHandle(result2);
|
|
4477
|
+
}
|
|
4478
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4479
|
+
// Advanced modeling
|
|
4480
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4481
|
+
filletVariable(shape2, spec) {
|
|
4482
|
+
const solidId = unwrapSolidOrThrow(shape2, "filletVariable");
|
|
4483
|
+
return solidHandle(this.bk.filletVariable(solidId, spec));
|
|
4484
|
+
}
|
|
4485
|
+
helicalSweep(profile, axisOrigin, axisDirection, radius, pitch, turns) {
|
|
4486
|
+
const profileId = unwrap(profile, "face");
|
|
4487
|
+
return solidHandle(
|
|
4488
|
+
this.bk.helicalSweep(
|
|
4489
|
+
profileId,
|
|
4490
|
+
axisOrigin[0],
|
|
4491
|
+
axisOrigin[1],
|
|
4492
|
+
axisOrigin[2],
|
|
4493
|
+
axisDirection[0],
|
|
4494
|
+
axisDirection[1],
|
|
4495
|
+
axisDirection[2],
|
|
4496
|
+
radius,
|
|
4497
|
+
pitch,
|
|
4498
|
+
turns
|
|
4499
|
+
)
|
|
4500
|
+
);
|
|
4501
|
+
}
|
|
4502
|
+
sweepWithOptions(profile, pathEdge, contactMode, scaleValues, segments) {
|
|
4503
|
+
const profileId = unwrap(profile, "face");
|
|
4504
|
+
const pathId = unwrap(pathEdge, "edge");
|
|
4505
|
+
return solidHandle(
|
|
4506
|
+
this.bk.sweepWithOptions(profileId, pathId, contactMode, scaleValues, segments)
|
|
4507
|
+
);
|
|
4508
|
+
}
|
|
4509
|
+
draft(shape2, faces, pullDirection, neutralPlane, angleDeg) {
|
|
4510
|
+
const solidId = unwrapSolidOrThrow(shape2, "draft");
|
|
4511
|
+
const faceIds = faces.map((f) => unwrap(f, "face"));
|
|
4512
|
+
return solidHandle(
|
|
4513
|
+
this.bk.draft(
|
|
4514
|
+
solidId,
|
|
4515
|
+
faceIds,
|
|
4516
|
+
pullDirection[0],
|
|
4517
|
+
pullDirection[1],
|
|
4518
|
+
pullDirection[2],
|
|
4519
|
+
neutralPlane[0],
|
|
4520
|
+
neutralPlane[1],
|
|
4521
|
+
neutralPlane[2],
|
|
4522
|
+
angleDeg
|
|
4523
|
+
)
|
|
4524
|
+
);
|
|
4525
|
+
}
|
|
4526
|
+
defeature(shape2, faces) {
|
|
4527
|
+
const solidId = unwrapSolidOrThrow(shape2, "defeature");
|
|
4528
|
+
const faceIds = faces.map((f) => unwrap(f, "face"));
|
|
4529
|
+
return solidHandle(this.bk.defeature(solidId, faceIds));
|
|
4530
|
+
}
|
|
4531
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4532
|
+
// Feature detection
|
|
4533
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4534
|
+
detectSmallFeatures(shape2, areaThreshold, tolerance) {
|
|
4535
|
+
const solidId = unwrapSolidOrThrow(shape2, "detectSmallFeatures");
|
|
4536
|
+
return Array.from(this.bk.detectSmallFeatures(solidId, areaThreshold, tolerance)).map(
|
|
4537
|
+
(id) => faceHandle(id)
|
|
4538
|
+
);
|
|
4539
|
+
}
|
|
4540
|
+
recognizeFeatures(shape2, tolerance) {
|
|
4541
|
+
const solidId = unwrapSolidOrThrow(shape2, "recognizeFeatures");
|
|
4542
|
+
return this.bk.recognizeFeatures(solidId, tolerance);
|
|
4543
|
+
}
|
|
4544
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4545
|
+
// Mesh boolean
|
|
4546
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4547
|
+
meshBoolean(positionsA, indicesA, positionsB, indicesB, op, tolerance) {
|
|
4548
|
+
const mesh2 = this.bk.meshBoolean(positionsA, indicesA, positionsB, indicesB, op, tolerance);
|
|
4549
|
+
return {
|
|
4550
|
+
vertices: new Float32Array(mesh2.positions),
|
|
4551
|
+
normals: new Float32Array(mesh2.normals),
|
|
4552
|
+
triangles: new Uint32Array(mesh2.indices),
|
|
4553
|
+
uvs: new Float32Array(0),
|
|
4554
|
+
faceGroups: [{ start: 0, count: mesh2.indices.length, faceHash: 0 }]
|
|
4555
|
+
};
|
|
4556
|
+
}
|
|
4557
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4558
|
+
// Topology queries
|
|
4559
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4560
|
+
edgeToFaceMap(shape2) {
|
|
4561
|
+
const solidId = unwrapSolidOrThrow(shape2, "edgeToFaceMap");
|
|
4562
|
+
return this.bk.edgeToFaceMap(solidId);
|
|
4563
|
+
}
|
|
4564
|
+
sharedEdges(faceA, faceB) {
|
|
4565
|
+
const aId = unwrap(faceA, "face");
|
|
4566
|
+
const bId = unwrap(faceB, "face");
|
|
4567
|
+
return Array.from(this.bk.sharedEdges(aId, bId)).map((id) => edgeHandle(id));
|
|
4568
|
+
}
|
|
4569
|
+
adjacentFaces(shape2, face) {
|
|
4570
|
+
const solidId = unwrapSolidOrThrow(shape2, "adjacentFaces");
|
|
4571
|
+
const faceId = unwrap(face, "face");
|
|
4572
|
+
return Array.from(this.bk.adjacentFaces(solidId, faceId)).map((id) => faceHandle(id));
|
|
4573
|
+
}
|
|
4574
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4575
|
+
// NURBS curve operations
|
|
4576
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4577
|
+
curveDegreeElevate(edge, elevateBy) {
|
|
4578
|
+
const edgeId = unwrap(edge, "edge");
|
|
4579
|
+
return edgeHandle(this.bk.curveDegreeElevate(edgeId, elevateBy));
|
|
4580
|
+
}
|
|
4581
|
+
curveKnotInsert(edge, knot, times) {
|
|
4582
|
+
const edgeId = unwrap(edge, "edge");
|
|
4583
|
+
return edgeHandle(this.bk.curveKnotInsert(edgeId, knot, times));
|
|
4584
|
+
}
|
|
4585
|
+
curveKnotRemove(edge, knot, tolerance) {
|
|
4586
|
+
const edgeId = unwrap(edge, "edge");
|
|
4587
|
+
return edgeHandle(this.bk.curveKnotRemove(edgeId, knot, tolerance));
|
|
4588
|
+
}
|
|
4589
|
+
curveSplit(edge, param) {
|
|
4590
|
+
const edgeId = unwrap(edge, "edge");
|
|
4591
|
+
const result2 = this.bk.curveSplit(edgeId, param);
|
|
4592
|
+
return [edgeHandle(result2[0]), edgeHandle(result2[1])];
|
|
4593
|
+
}
|
|
4594
|
+
approximateSurfaceLspia(coords, rows, cols, degreeU, degreeV, numCpsU, numCpsV, tolerance, maxIterations) {
|
|
4595
|
+
return faceHandle(
|
|
4596
|
+
this.bk.approximateSurfaceLspia(
|
|
4597
|
+
coords,
|
|
4598
|
+
rows,
|
|
4599
|
+
cols,
|
|
4600
|
+
degreeU,
|
|
4601
|
+
degreeV,
|
|
4602
|
+
numCpsU,
|
|
4603
|
+
numCpsV,
|
|
4604
|
+
tolerance,
|
|
4605
|
+
maxIterations
|
|
4606
|
+
)
|
|
4607
|
+
);
|
|
4608
|
+
}
|
|
4609
|
+
untrimFace(face, samplesPerCurve, interiorSamples) {
|
|
4610
|
+
const faceId = unwrap(face, "face");
|
|
4611
|
+
return faceHandle(this.bk.untrimFace(faceId, samplesPerCurve, interiorSamples));
|
|
4612
|
+
}
|
|
4613
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4614
|
+
// Validation / Repair
|
|
4615
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4616
|
+
mergeCoincidentVertices(shape2, tolerance) {
|
|
4617
|
+
const solidId = unwrapSolidOrThrow(shape2, "mergeCoincidentVertices");
|
|
4618
|
+
return this.bk.mergeCoincidentVertices(solidId, tolerance);
|
|
4619
|
+
}
|
|
4620
|
+
removeDegenerateEdges(shape2, tolerance) {
|
|
4621
|
+
const solidId = unwrapSolidOrThrow(shape2, "removeDegenerateEdges");
|
|
4622
|
+
return this.bk.removeDegenerateEdges(solidId, tolerance);
|
|
4623
|
+
}
|
|
4624
|
+
fixFaceOrientations(shape2) {
|
|
4625
|
+
const solidId = unwrapSolidOrThrow(shape2, "fixFaceOrientations");
|
|
4626
|
+
return this.bk.fixFaceOrientations(solidId);
|
|
4627
|
+
}
|
|
4628
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4629
|
+
// Classification
|
|
4630
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4631
|
+
classifyPointRobust(shape2, point, tolerance) {
|
|
4632
|
+
const solidId = unwrapSolidOrThrow(shape2, "classifyPointRobust");
|
|
4633
|
+
return this.bk.classifyPointRobust(solidId, point[0], point[1], point[2], tolerance);
|
|
4634
|
+
}
|
|
4635
|
+
classifyPointWinding(shape2, point, tolerance) {
|
|
4636
|
+
const solidId = unwrapSolidOrThrow(shape2, "classifyPointWinding");
|
|
4637
|
+
return this.bk.classifyPointWinding(solidId, point[0], point[1], point[2], tolerance);
|
|
4638
|
+
}
|
|
4639
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4640
|
+
// Batch execution
|
|
4641
|
+
// ═══════════════════════════════════════════════════════════════════════
|
|
4642
|
+
executeBatch(json) {
|
|
4643
|
+
return this.bk.executeBatch(json);
|
|
4644
|
+
}
|
|
4339
4645
|
}
|
|
4340
4646
|
function multiplyMatrices(a, b) {
|
|
4341
4647
|
const result2 = new Array(16).fill(0);
|
|
@@ -7222,6 +7528,7 @@ exports.normalAt = faceFns.normalAt;
|
|
|
7222
7528
|
exports.outerWire = faceFns.outerWire;
|
|
7223
7529
|
exports.pointOnSurface = faceFns.pointOnSurface;
|
|
7224
7530
|
exports.projectPointOnFace = faceFns.projectPointOnFace;
|
|
7531
|
+
exports.removeHolesFromFace = faceFns.removeHolesFromFace;
|
|
7225
7532
|
exports.shapeType = faceFns.shapeType;
|
|
7226
7533
|
exports.uvBounds = faceFns.uvBounds;
|
|
7227
7534
|
exports.uvCoordinates = faceFns.uvCoordinates;
|
|
@@ -7322,6 +7629,7 @@ exports.simplify = simplify;
|
|
|
7322
7629
|
exports.slice = slice;
|
|
7323
7630
|
exports.solveAssembly = solveAssembly;
|
|
7324
7631
|
exports.split = split;
|
|
7632
|
+
exports.supportsConstraintSketch = supportsConstraintSketch;
|
|
7325
7633
|
exports.supportsProjection = supportsProjection;
|
|
7326
7634
|
exports.surfaceFromGrid = surfaceFromGrid;
|
|
7327
7635
|
exports.surfaceFromImage = surfaceFromImage;
|