brepjs 18.69.3 → 18.71.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.cjs +6 -6
- package/dist/2d.js +6 -6
- package/dist/{blueprint-DIQeD9xj.cjs → blueprint-jlSsZ0sZ.cjs} +5 -5
- package/dist/{blueprint-Dgl9IkCV.js → blueprint-qVw9ZkE4.js} +5 -5
- package/dist/{blueprintFns-BO44cqFY.cjs → blueprintFns-DsuY7gCu.cjs} +2 -2
- package/dist/{blueprintFns-sKzHcJ4U.js → blueprintFns-zLwbytjs.js} +2 -2
- package/dist/{blueprintSketcher-DbINWerx.js → blueprintSketcher-BRKbVgE2.js} +3 -3
- package/dist/{blueprintSketcher-BpOknLmX.cjs → blueprintSketcher-dZZ8e5ey.cjs} +3 -3
- package/dist/{boolean2D-DZcOTOSA.cjs → boolean2D-4E1kbwQx.cjs} +4 -4
- package/dist/{boolean2D-CreNaKXt.js → boolean2D-CANP43pN.js} +4 -4
- package/dist/{booleanFns-DvXg6a2Y.cjs → booleanFns-Bp_wYEwG.cjs} +4 -4
- package/dist/{booleanFns-0jDBFjAv.js → booleanFns-DYSaupiG.js} +4 -4
- package/dist/brepjs.cjs +375 -65
- package/dist/brepjs.js +372 -68
- package/dist/{cameraFns-Bwxq0IDz.js → cameraFns-BFRGMXSn.js} +2 -2
- package/dist/{cameraFns-CsGSVYgb.cjs → cameraFns-dRK1CnFi.cjs} +2 -2
- package/dist/core.cjs +1 -1
- package/dist/core.js +1 -1
- package/dist/{cornerFinder-ChltJ_ur.cjs → cornerFinder-CQPXY8Aw.cjs} +1 -1
- package/dist/{cornerFinder-fMf9-El_.js → cornerFinder-DcHCKoUh.js} +1 -1
- package/dist/{curveFns-BhTtS18d.js → curveFns-CXhOkKR4.js} +1 -1
- package/dist/{curveFns-CXytEfTr.cjs → curveFns-uPVW6eo-.cjs} +1 -1
- package/dist/{drawFns-Bzr38vZx.js → drawFns-ZqWpAG8b.js} +12 -12
- package/dist/{drawFns-Bn4vzbUr.cjs → drawFns-eMU4H__w.cjs} +12 -12
- package/dist/{extrudeFns-rnUgev_g.js → extrudeFns-CSy2C7WW.js} +1 -1
- package/dist/{extrudeFns-C0FsOXev.cjs → extrudeFns-CzQans6p.cjs} +1 -1
- package/dist/{faceFns-Dreo5ksY.js → faceFns-BBcrvY7r.js} +11 -3
- package/dist/{faceFns-FAZgMVCx.cjs → faceFns-CcLFCtg4.cjs} +16 -2
- package/dist/{helpers-D8ycrNeD.cjs → helpers-BmY5kO0w.cjs} +6 -6
- package/dist/{helpers--BMa_zB7.js → helpers-CxT3j8jG.js} +6 -6
- package/dist/{historyFns-mnmeZ0kB.cjs → historyFns-BEB2Yjld.cjs} +4 -4
- package/dist/{historyFns-CR0RejKJ.js → historyFns-ClLT60_V.js} +4 -4
- package/dist/{importFns-DRPQExAD.js → importFns-BNDWuBuq.js} +2 -2
- package/dist/{importFns-4mi5Ih46.cjs → importFns-DA0Klh7_.cjs} +2 -2
- package/dist/index.d.ts +2 -1
- package/dist/io.cjs +2 -2
- package/dist/io.js +2 -2
- package/dist/kernel/brepkit/geometryOps.d.ts +1 -0
- package/dist/kernel/interfaces/surfaceOps.d.ts +9 -0
- package/dist/kernel/occt/geometryQueryOps.d.ts +9 -0
- package/dist/kernel/occtWasm/occtWasmAdapter.cjs +1 -1
- package/dist/kernel/occtWasm/occtWasmAdapter.d.ts +4 -0
- package/dist/kernel/occtWasm/occtWasmAdapter.js +1 -1
- package/dist/kernel/occtWasm/surfaceOps.d.ts +17 -0
- package/dist/kernel/solverAdapter.d.ts +8 -7
- package/dist/{measureFns-BLEx4ZU3.js → measureFns-DAP8LjBB.js} +3 -3
- package/dist/{measureFns-CT0XaSOt.cjs → measureFns-zGABZl6o.cjs} +3 -3
- package/dist/measurement.cjs +1 -1
- package/dist/measurement.js +1 -1
- package/dist/{meshFns-lwgHYQ79.cjs → meshFns-CEGnFm33.cjs} +3 -3
- package/dist/{meshFns-B3MjIqk1.js → meshFns-D-nLiHvU.js} +3 -3
- package/dist/{occtWasmAdapter-BH7r2nTq.cjs → occtWasmAdapter-Crs07qIe.cjs} +67 -0
- package/dist/{occtWasmAdapter-C7FDeTaw.js → occtWasmAdapter-D0MtWZYO.js} +67 -0
- package/dist/operations/assemblyFns.d.ts +2 -0
- package/dist/operations/jointFns.d.ts +55 -0
- package/dist/operations.cjs +2 -2
- package/dist/operations.js +2 -2
- package/dist/{primitiveFns-DcZDTQ_R.js → primitiveFns-CDbe5gjc.js} +7 -7
- package/dist/{primitiveFns-DZmgvzvk.cjs → primitiveFns-CpkG8ZkI.cjs} +7 -7
- package/dist/projection.cjs +1 -1
- package/dist/projection.js +1 -1
- package/dist/query.cjs +2 -2
- package/dist/query.js +2 -2
- package/dist/{shapeFns-w1YoIn_p.cjs → shapeFns-CDHya-nt.cjs} +2 -2
- package/dist/{shapeFns-BnkizFjV.js → shapeFns-DVUNOG2I.js} +2 -2
- package/dist/shapeRef.cjs +1 -1
- package/dist/shapeRef.js +1 -1
- package/dist/{shapeRefFns-B3myHs0D.cjs → shapeRefFns-B1Tygk9V.cjs} +4 -4
- package/dist/{shapeRefFns-OVWdFOAC.js → shapeRefFns-CAJUDLTi.js} +4 -4
- package/dist/{shapeTypes-yCQ8z5Hc.js → shapeTypes-2cKwu2z4.js} +35 -1
- package/dist/{shapeTypes-BIlZar9m.cjs → shapeTypes-DRxArFIc.cjs} +35 -1
- package/dist/sketching.cjs +3 -3
- package/dist/sketching.js +3 -3
- package/dist/{solidBuilders-CPOTKI5i.js → solidBuilders-Bx3UdW91.js} +2 -2
- package/dist/{solidBuilders-dNhToZgl.cjs → solidBuilders-ibLq_9EK.cjs} +2 -2
- package/dist/{surfaceBuilders-CS1QccDv.js → surfaceBuilders-BtNrSolT.js} +2 -2
- package/dist/{surfaceBuilders-CzHPZtd3.cjs → surfaceBuilders-D2PBBoja.cjs} +2 -2
- package/dist/text.cjs +2 -2
- package/dist/text.js +2 -2
- package/dist/{textBlueprints-TG6AH06v.cjs → textBlueprints-COG8m1aE.cjs} +7 -7
- package/dist/{textBlueprints-B57ej88L.js → textBlueprints-HfRD4iNF.js} +7 -7
- package/dist/{textMetrics-Dag-YREs.cjs → textMetrics-CTSpUXtk.cjs} +1 -1
- package/dist/{textMetrics-BxtB3sjj.js → textMetrics-Zp8rzokO.js} +1 -1
- package/dist/topology/faceFns.d.ts +9 -0
- package/dist/topology/index.d.ts +1 -1
- package/dist/topology.cjs +8 -7
- package/dist/topology.d.ts +1 -1
- package/dist/topology.js +8 -8
- package/dist/{topologyQueryFns-BuWZAQ_o.cjs → topologyQueryFns-024l64sD.cjs} +1 -1
- package/dist/{topologyQueryFns-Bxdnl5Vt.js → topologyQueryFns-c2RQIcfW.js} +1 -1
- package/dist/utils/quaternion.d.ts +15 -0
- package/package.json +1 -1
package/dist/brepjs.cjs
CHANGED
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_textBlueprints = require("./textBlueprints-
|
|
3
|
-
const require_shapeTypes = require("./shapeTypes-
|
|
4
|
-
const require_occtWasmAdapter = require("./occtWasmAdapter-
|
|
2
|
+
const require_textBlueprints = require("./textBlueprints-COG8m1aE.cjs");
|
|
3
|
+
const require_shapeTypes = require("./shapeTypes-DRxArFIc.cjs");
|
|
4
|
+
const require_occtWasmAdapter = require("./occtWasmAdapter-Crs07qIe.cjs");
|
|
5
5
|
const require_vec3 = require("./vec3-CFwOI0ZI.cjs");
|
|
6
6
|
const require_errors = require("./errors-CXJtc4I7.cjs");
|
|
7
|
-
const require_topologyQueryFns = require("./topologyQueryFns-
|
|
7
|
+
const require_topologyQueryFns = require("./topologyQueryFns-024l64sD.cjs");
|
|
8
8
|
const require_constants = require("./constants-BOVyEYGH.cjs");
|
|
9
9
|
const require_types = require("./types-KjA8tY4Y.cjs");
|
|
10
10
|
const require_vecOps = require("./vecOps-CCnJt-yH.cjs");
|
|
11
11
|
const require_planeOps = require("./planeOps-BA4HfgQu.cjs");
|
|
12
|
-
const require_faceFns = require("./faceFns-
|
|
13
|
-
const require_shapeFns = require("./shapeFns-
|
|
14
|
-
const require_curveFns = require("./curveFns-
|
|
15
|
-
const require_meshFns = require("./meshFns-
|
|
12
|
+
const require_faceFns = require("./faceFns-CcLFCtg4.cjs");
|
|
13
|
+
const require_shapeFns = require("./shapeFns-CDHya-nt.cjs");
|
|
14
|
+
const require_curveFns = require("./curveFns-uPVW6eo-.cjs");
|
|
15
|
+
const require_meshFns = require("./meshFns-CEGnFm33.cjs");
|
|
16
16
|
const require_arrayAccess = require("./arrayAccess-e4H9cBfh.cjs");
|
|
17
|
-
const require_surfaceBuilders = require("./surfaceBuilders-
|
|
18
|
-
const require_booleanFns = require("./booleanFns-
|
|
19
|
-
const require_primitiveFns = require("./primitiveFns-
|
|
20
|
-
const require_historyFns = require("./historyFns-
|
|
21
|
-
const require_blueprintSketcher = require("./blueprintSketcher-
|
|
22
|
-
const require_helpers = require("./helpers-
|
|
23
|
-
const require_drawFns = require("./drawFns-
|
|
24
|
-
const require_solidBuilders = require("./solidBuilders-
|
|
25
|
-
const require_measureFns = require("./measureFns-
|
|
26
|
-
const require_cornerFinder = require("./cornerFinder-
|
|
27
|
-
const require_boolean2D = require("./boolean2D-
|
|
28
|
-
const require_blueprintFns = require("./blueprintFns-
|
|
29
|
-
const require_importFns = require("./importFns-
|
|
30
|
-
const require_extrudeFns = require("./extrudeFns-
|
|
31
|
-
const require_cameraFns = require("./cameraFns-
|
|
32
|
-
const require_textMetrics = require("./textMetrics-
|
|
33
|
-
const require_shapeRefFns = require("./shapeRefFns-
|
|
17
|
+
const require_surfaceBuilders = require("./surfaceBuilders-D2PBBoja.cjs");
|
|
18
|
+
const require_booleanFns = require("./booleanFns-Bp_wYEwG.cjs");
|
|
19
|
+
const require_primitiveFns = require("./primitiveFns-CpkG8ZkI.cjs");
|
|
20
|
+
const require_historyFns = require("./historyFns-BEB2Yjld.cjs");
|
|
21
|
+
const require_blueprintSketcher = require("./blueprintSketcher-dZZ8e5ey.cjs");
|
|
22
|
+
const require_helpers = require("./helpers-BmY5kO0w.cjs");
|
|
23
|
+
const require_drawFns = require("./drawFns-eMU4H__w.cjs");
|
|
24
|
+
const require_solidBuilders = require("./solidBuilders-ibLq_9EK.cjs");
|
|
25
|
+
const require_measureFns = require("./measureFns-zGABZl6o.cjs");
|
|
26
|
+
const require_cornerFinder = require("./cornerFinder-CQPXY8Aw.cjs");
|
|
27
|
+
const require_boolean2D = require("./boolean2D-4E1kbwQx.cjs");
|
|
28
|
+
const require_blueprintFns = require("./blueprintFns-DsuY7gCu.cjs");
|
|
29
|
+
const require_importFns = require("./importFns-DA0Klh7_.cjs");
|
|
30
|
+
const require_extrudeFns = require("./extrudeFns-CzQans6p.cjs");
|
|
31
|
+
const require_cameraFns = require("./cameraFns-dRK1CnFi.cjs");
|
|
32
|
+
const require_textMetrics = require("./textMetrics-CTSpUXtk.cjs");
|
|
33
|
+
const require_shapeRefFns = require("./shapeRefFns-B1Tygk9V.cjs");
|
|
34
34
|
const require_workerHandler = require("./workerHandler-CdlOTwJg.cjs");
|
|
35
35
|
//#region src/topology/shapeBooleans.ts
|
|
36
36
|
var BOPAlgo_GlueShift = 1;
|
|
@@ -2132,13 +2132,94 @@ function roof(w, options) {
|
|
|
2132
2132
|
}
|
|
2133
2133
|
}
|
|
2134
2134
|
//#endregion
|
|
2135
|
+
//#region src/utils/quaternion.ts
|
|
2136
|
+
function dot$1(a, b) {
|
|
2137
|
+
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
2138
|
+
}
|
|
2139
|
+
function cross$1(a, b) {
|
|
2140
|
+
return [
|
|
2141
|
+
a[1] * b[2] - a[2] * b[1],
|
|
2142
|
+
a[2] * b[0] - a[0] * b[2],
|
|
2143
|
+
a[0] * b[1] - a[1] * b[0]
|
|
2144
|
+
];
|
|
2145
|
+
}
|
|
2146
|
+
function normalize$1(a) {
|
|
2147
|
+
const l = Math.hypot(a[0], a[1], a[2]) || 1;
|
|
2148
|
+
return [
|
|
2149
|
+
a[0] / l,
|
|
2150
|
+
a[1] / l,
|
|
2151
|
+
a[2] / l
|
|
2152
|
+
];
|
|
2153
|
+
}
|
|
2154
|
+
/** A unit vector perpendicular to `v` (for the 180°/parallel degenerate cases). */
|
|
2155
|
+
function anyPerpendicular$1(v) {
|
|
2156
|
+
return normalize$1(cross$1(v, Math.abs(v[0]) < .9 ? [
|
|
2157
|
+
1,
|
|
2158
|
+
0,
|
|
2159
|
+
0
|
|
2160
|
+
] : [
|
|
2161
|
+
0,
|
|
2162
|
+
1,
|
|
2163
|
+
0
|
|
2164
|
+
]));
|
|
2165
|
+
}
|
|
2166
|
+
/** Rotate vector `v` by quaternion `q`. */
|
|
2167
|
+
function quatRotate(q, v) {
|
|
2168
|
+
const [w, x, y, z] = q;
|
|
2169
|
+
const tx = 2 * (y * v[2] - z * v[1]);
|
|
2170
|
+
const ty = 2 * (z * v[0] - x * v[2]);
|
|
2171
|
+
const tz = 2 * (x * v[1] - y * v[0]);
|
|
2172
|
+
return [
|
|
2173
|
+
v[0] + w * tx + (y * tz - z * ty),
|
|
2174
|
+
v[1] + w * ty + (z * tx - x * tz),
|
|
2175
|
+
v[2] + w * tz + (x * ty - y * tx)
|
|
2176
|
+
];
|
|
2177
|
+
}
|
|
2178
|
+
/** Quaternion for a rotation of `angle` radians about (unit-normalized) `axis`. */
|
|
2179
|
+
function quatFromAxisAngle(axis, angle) {
|
|
2180
|
+
const h = angle / 2;
|
|
2181
|
+
const s = Math.sin(h);
|
|
2182
|
+
const u = normalize$1(axis);
|
|
2183
|
+
return [
|
|
2184
|
+
Math.cos(h),
|
|
2185
|
+
u[0] * s,
|
|
2186
|
+
u[1] * s,
|
|
2187
|
+
u[2] * s
|
|
2188
|
+
];
|
|
2189
|
+
}
|
|
2190
|
+
/** Shortest-arc quaternion rotating unit vector `from` onto unit vector `to`. */
|
|
2191
|
+
function quatFromTo(from, to) {
|
|
2192
|
+
const a = normalize$1(from);
|
|
2193
|
+
const b = normalize$1(to);
|
|
2194
|
+
const d = dot$1(a, b);
|
|
2195
|
+
if (d >= .999999999) return [
|
|
2196
|
+
1,
|
|
2197
|
+
0,
|
|
2198
|
+
0,
|
|
2199
|
+
0
|
|
2200
|
+
];
|
|
2201
|
+
if (d <= -.999999999) return quatFromAxisAngle(anyPerpendicular$1(a), Math.PI);
|
|
2202
|
+
const c = cross$1(a, b);
|
|
2203
|
+
const len = Math.hypot(1 + d, c[0], c[1], c[2]) || 1;
|
|
2204
|
+
return [
|
|
2205
|
+
(1 + d) / len,
|
|
2206
|
+
c[0] / len,
|
|
2207
|
+
c[1] / len,
|
|
2208
|
+
c[2] / len
|
|
2209
|
+
];
|
|
2210
|
+
}
|
|
2211
|
+
//#endregion
|
|
2135
2212
|
//#region src/kernel/solverAdapter.ts
|
|
2136
2213
|
/**
|
|
2137
|
-
*
|
|
2138
|
-
|
|
2139
|
-
|
|
2140
|
-
*
|
|
2141
|
-
*
|
|
2214
|
+
* Constraint solver adapter — analytical solver for simple assembly mates.
|
|
2215
|
+
*/
|
|
2216
|
+
/**
|
|
2217
|
+
* Degrees of freedom each constraint leaves unresolved when it can't be applied
|
|
2218
|
+
* (entity-type mismatch or an unreachable reference). All four types now solve
|
|
2219
|
+
* for well-typed inputs; these counts only feed the diagnostic `dof` for the
|
|
2220
|
+
* unsupported cases.
|
|
2221
|
+
* coincident: 3 translational · concentric: 2 rotational + 2 translational = 4
|
|
2222
|
+
* distance: 1 translational · angle: 1 rotational
|
|
2142
2223
|
*/
|
|
2143
2224
|
var UNSUPPORTED_DOF = {
|
|
2144
2225
|
coincident: 3,
|
|
@@ -2159,51 +2240,162 @@ function add$1(a, b) {
|
|
|
2159
2240
|
a[2] + b[2]
|
|
2160
2241
|
];
|
|
2161
2242
|
}
|
|
2243
|
+
function sub(a, b) {
|
|
2244
|
+
return [
|
|
2245
|
+
a[0] - b[0],
|
|
2246
|
+
a[1] - b[1],
|
|
2247
|
+
a[2] - b[2]
|
|
2248
|
+
];
|
|
2249
|
+
}
|
|
2162
2250
|
function dot(a, b) {
|
|
2163
2251
|
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
|
2164
2252
|
}
|
|
2253
|
+
function cross(a, b) {
|
|
2254
|
+
return [
|
|
2255
|
+
a[1] * b[2] - a[2] * b[1],
|
|
2256
|
+
a[2] * b[0] - a[0] * b[2],
|
|
2257
|
+
a[0] * b[1] - a[1] * b[0]
|
|
2258
|
+
];
|
|
2259
|
+
}
|
|
2260
|
+
function scale$2(a, s) {
|
|
2261
|
+
return [
|
|
2262
|
+
a[0] * s,
|
|
2263
|
+
a[1] * s,
|
|
2264
|
+
a[2] * s
|
|
2265
|
+
];
|
|
2266
|
+
}
|
|
2267
|
+
function normalize(a) {
|
|
2268
|
+
const l = Math.hypot(a[0], a[1], a[2]) || 1;
|
|
2269
|
+
return [
|
|
2270
|
+
a[0] / l,
|
|
2271
|
+
a[1] / l,
|
|
2272
|
+
a[2] / l
|
|
2273
|
+
];
|
|
2274
|
+
}
|
|
2275
|
+
/** A unit vector perpendicular to `v` (for the parallel-normals degenerate case). */
|
|
2276
|
+
function anyPerpendicular(v) {
|
|
2277
|
+
return normalize(cross(v, Math.abs(v[0]) < .9 ? [
|
|
2278
|
+
1,
|
|
2279
|
+
0,
|
|
2280
|
+
0
|
|
2281
|
+
] : [
|
|
2282
|
+
0,
|
|
2283
|
+
1,
|
|
2284
|
+
0
|
|
2285
|
+
]));
|
|
2286
|
+
}
|
|
2287
|
+
/** Apply a pose (rotate then translate) to an entity's origin and any directions. */
|
|
2288
|
+
function transformEntity(e, pose) {
|
|
2289
|
+
const origin = add$1(quatRotate(pose.rotation, e.origin), pose.position);
|
|
2290
|
+
return {
|
|
2291
|
+
type: e.type,
|
|
2292
|
+
origin,
|
|
2293
|
+
...e.normal ? { normal: quatRotate(pose.rotation, e.normal) } : {},
|
|
2294
|
+
...e.direction ? { direction: quatRotate(pose.rotation, e.direction) } : {}
|
|
2295
|
+
};
|
|
2296
|
+
}
|
|
2165
2297
|
/**
|
|
2166
2298
|
* Position a dependent plane against an already-placed reference plane.
|
|
2167
2299
|
*
|
|
2168
|
-
*
|
|
2169
|
-
*
|
|
2170
|
-
*
|
|
2171
|
-
*
|
|
2172
|
-
* translation. `extra` is the gap for a distance mate (0 for coincident).
|
|
2173
|
-
* Rotation stays identity — coincident/distance produce pure translations;
|
|
2174
|
-
* Phase 1 rotational constraints will extend this.
|
|
2300
|
+
* `ref` is the reference entity already in world space. The dependent is at the
|
|
2301
|
+
* origin (a node is only solved once, while unplaced), so the returned position
|
|
2302
|
+
* is its absolute translation along the reference normal. `extra` is the gap for
|
|
2303
|
+
* a distance mate (0 for coincident). Plane mates don't reorient the dependent.
|
|
2175
2304
|
*/
|
|
2176
|
-
function solvePlanePair(ref,
|
|
2305
|
+
function solvePlanePair(ref, dep, extra) {
|
|
2177
2306
|
const n = ref.normal ?? [
|
|
2178
2307
|
0,
|
|
2179
2308
|
0,
|
|
2180
2309
|
1
|
|
2181
2310
|
];
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
|
-
|
|
2187
|
-
|
|
2311
|
+
return {
|
|
2312
|
+
position: scale$2(n, dot(n, sub(ref.origin, dep.origin)) + extra),
|
|
2313
|
+
rotation: IDENTITY_ROTATION
|
|
2314
|
+
};
|
|
2315
|
+
}
|
|
2316
|
+
/**
|
|
2317
|
+
* Concentric (axis-axis) mate: rotate the dependent so its axis is parallel to
|
|
2318
|
+
* the reference axis, then translate so the two axes are collinear (the
|
|
2319
|
+
* dependent's axis point is placed on the reference axis). `ref` is in world
|
|
2320
|
+
* space; the dependent is at the origin.
|
|
2321
|
+
*/
|
|
2322
|
+
function solveConcentric(ref, dep) {
|
|
2323
|
+
const dRef = ref.direction ?? [
|
|
2324
|
+
0,
|
|
2325
|
+
0,
|
|
2326
|
+
1
|
|
2327
|
+
];
|
|
2328
|
+
const rotation = quatFromTo(dep.direction ?? [
|
|
2329
|
+
0,
|
|
2330
|
+
0,
|
|
2331
|
+
1
|
|
2332
|
+
], dRef);
|
|
2333
|
+
const rotatedOrigin = quatRotate(rotation, dep.origin);
|
|
2334
|
+
return {
|
|
2335
|
+
position: sub(ref.origin, rotatedOrigin),
|
|
2336
|
+
rotation
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
/**
|
|
2340
|
+
* Angle mate: rotate the dependent so the angle between its (plane) normal and
|
|
2341
|
+
* the reference normal equals `angleRad`. Orientation-only — position is left at
|
|
2342
|
+
* the origin. `ref` is in world space; the dependent is at the origin.
|
|
2343
|
+
*/
|
|
2344
|
+
function solveAngle(ref, dep, angleRad) {
|
|
2345
|
+
const nRef = normalize(ref.normal ?? [
|
|
2346
|
+
0,
|
|
2347
|
+
0,
|
|
2348
|
+
1
|
|
2349
|
+
]);
|
|
2350
|
+
const nDep = normalize(dep.normal ?? [
|
|
2351
|
+
0,
|
|
2352
|
+
0,
|
|
2353
|
+
1
|
|
2354
|
+
]);
|
|
2355
|
+
const phi = Math.acos(Math.max(-1, Math.min(1, dot(nDep, nRef))));
|
|
2356
|
+
const c = cross(nDep, nRef);
|
|
2188
2357
|
return {
|
|
2189
2358
|
position: [
|
|
2190
|
-
|
|
2191
|
-
|
|
2192
|
-
|
|
2359
|
+
0,
|
|
2360
|
+
0,
|
|
2361
|
+
0
|
|
2193
2362
|
],
|
|
2194
|
-
rotation:
|
|
2363
|
+
rotation: quatFromAxisAngle(Math.hypot(c[0], c[1], c[2]) < 1e-9 ? anyPerpendicular(nDep) : c, phi - angleRad)
|
|
2195
2364
|
};
|
|
2196
2365
|
}
|
|
2366
|
+
/** Entity types each positioning constraint requires of (entityA, entityB). */
|
|
2367
|
+
var REQUIRED_ENTITIES = {
|
|
2368
|
+
coincident: "plane",
|
|
2369
|
+
distance: "plane",
|
|
2370
|
+
angle: "plane",
|
|
2371
|
+
concentric: "axis"
|
|
2372
|
+
};
|
|
2373
|
+
var POSITIONING_TYPES = new Set([
|
|
2374
|
+
"coincident",
|
|
2375
|
+
"distance",
|
|
2376
|
+
"angle",
|
|
2377
|
+
"concentric"
|
|
2378
|
+
]);
|
|
2379
|
+
/** Dispatch a positioning mate to its solver. `ref` is already in world space. */
|
|
2380
|
+
function solveMate(c, ref, dep) {
|
|
2381
|
+
switch (c.type) {
|
|
2382
|
+
case "concentric": return solveConcentric(ref, dep);
|
|
2383
|
+
case "angle": return solveAngle(ref, dep, (c.value ?? 0) * Math.PI / 180);
|
|
2384
|
+
case "distance": return solvePlanePair(ref, dep, c.value ?? 0);
|
|
2385
|
+
default: return solvePlanePair(ref, dep, 0);
|
|
2386
|
+
}
|
|
2387
|
+
}
|
|
2197
2388
|
/**
|
|
2198
2389
|
* Solve assembly constraints analytically.
|
|
2199
2390
|
*
|
|
2200
|
-
* Handles: fixed, coincident (plane-plane),
|
|
2201
|
-
* positioning mate, entityA is the
|
|
2202
|
-
* roots (nodes never positioned by a
|
|
2203
|
-
*
|
|
2204
|
-
* dependent against the reference's solved
|
|
2205
|
-
*
|
|
2206
|
-
*
|
|
2391
|
+
* Handles: fixed, coincident/distance (plane-plane), concentric (axis-axis), and
|
|
2392
|
+
* angle (plane-plane orientation). For a positioning mate, entityA is the
|
|
2393
|
+
* reference and entityB the dependent. Chain roots (nodes never positioned by a
|
|
2394
|
+
* mate) and explicit `fixed` nodes anchor at the origin; constraints then resolve
|
|
2395
|
+
* in topological order — each places its dependent against the reference's solved
|
|
2396
|
+
* pose (rotation included), so multi-body chains compose. Returns
|
|
2397
|
+
* `converged: false` with details for entity-type mismatches and any constraint
|
|
2398
|
+
* whose reference never resolves.
|
|
2207
2399
|
*/
|
|
2208
2400
|
function solveConstraints(nodes, constraints) {
|
|
2209
2401
|
const transforms = /* @__PURE__ */ new Map();
|
|
@@ -2216,17 +2408,17 @@ function solveConstraints(nodes, constraints) {
|
|
|
2216
2408
|
rotation: IDENTITY_ROTATION
|
|
2217
2409
|
});
|
|
2218
2410
|
const unsupported = [];
|
|
2219
|
-
const positioning = constraints.filter((c) => (c.type
|
|
2411
|
+
const positioning = constraints.filter((c) => POSITIONING_TYPES.has(c.type) && c.entityA && c.entityB);
|
|
2220
2412
|
const dependents = /* @__PURE__ */ new Set();
|
|
2221
2413
|
for (const c of positioning) if (c.entityB) dependents.add(c.entityB.node);
|
|
2222
2414
|
const placed = /* @__PURE__ */ new Set();
|
|
2223
2415
|
for (const node of nodes) if (!dependents.has(node)) placed.add(node);
|
|
2224
2416
|
for (const c of constraints) if (c.type === "fixed" && c.entityA) placed.add(c.entityA.node);
|
|
2225
|
-
for (const c of constraints) if (c.type === "concentric" || c.type === "angle") unsupported.push(c.type);
|
|
2226
2417
|
const pending = [];
|
|
2227
2418
|
for (const c of positioning) {
|
|
2228
2419
|
if (!c.entityA || !c.entityB) continue;
|
|
2229
|
-
|
|
2420
|
+
const required = REQUIRED_ENTITIES[c.type];
|
|
2421
|
+
if (c.entityA.entity.type !== required || c.entityB.entity.type !== required) {
|
|
2230
2422
|
unsupported.push(`${c.type}(${c.entityA.entity.type}-${c.entityB.entity.type})`);
|
|
2231
2423
|
continue;
|
|
2232
2424
|
}
|
|
@@ -2252,8 +2444,8 @@ function solveConstraints(nodes, constraints) {
|
|
|
2252
2444
|
],
|
|
2253
2445
|
rotation: IDENTITY_ROTATION
|
|
2254
2446
|
};
|
|
2255
|
-
const
|
|
2256
|
-
transforms.set(dep.node,
|
|
2447
|
+
const refWorld = transformEntity(ref.entity, refPose);
|
|
2448
|
+
transforms.set(dep.node, solveMate(c, refWorld, dep.entity));
|
|
2257
2449
|
placed.add(dep.node);
|
|
2258
2450
|
}
|
|
2259
2451
|
}
|
|
@@ -2270,11 +2462,27 @@ function solveConstraints(nodes, constraints) {
|
|
|
2270
2462
|
//#endregion
|
|
2271
2463
|
//#region src/operations/mateFns.ts
|
|
2272
2464
|
function extractEntity(mate) {
|
|
2273
|
-
if (mate.face)
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
|
|
2277
|
-
|
|
2465
|
+
if (mate.face) {
|
|
2466
|
+
const axis = require_faceFns.faceAxis(mate.face);
|
|
2467
|
+
if (axis) return {
|
|
2468
|
+
type: "axis",
|
|
2469
|
+
origin: axis.origin,
|
|
2470
|
+
direction: axis.direction
|
|
2471
|
+
};
|
|
2472
|
+
return {
|
|
2473
|
+
type: "plane",
|
|
2474
|
+
origin: require_faceFns.faceCenter(mate.face),
|
|
2475
|
+
normal: require_faceFns.normalAt(mate.face)
|
|
2476
|
+
};
|
|
2477
|
+
}
|
|
2478
|
+
if (mate.edge) {
|
|
2479
|
+
if (require_curveFns.getCurveType(mate.edge) === "LINE") return {
|
|
2480
|
+
type: "axis",
|
|
2481
|
+
origin: require_curveFns.curveStartPoint(mate.edge),
|
|
2482
|
+
direction: require_curveFns.curveTangentAt(mate.edge)
|
|
2483
|
+
};
|
|
2484
|
+
return null;
|
|
2485
|
+
}
|
|
2278
2486
|
if (mate.point) return {
|
|
2279
2487
|
type: "point",
|
|
2280
2488
|
origin: mate.point
|
|
@@ -2394,6 +2602,102 @@ function solveAssembly(assembly) {
|
|
|
2394
2602
|
}
|
|
2395
2603
|
}
|
|
2396
2604
|
//#endregion
|
|
2605
|
+
//#region src/operations/jointFns.ts
|
|
2606
|
+
var DEG2RAD$1 = Math.PI / 180;
|
|
2607
|
+
function clamp(value, min, max) {
|
|
2608
|
+
return Math.min(max, Math.max(min, value));
|
|
2609
|
+
}
|
|
2610
|
+
function unit(v) {
|
|
2611
|
+
const l = Math.hypot(v[0], v[1], v[2]) || 1;
|
|
2612
|
+
return [
|
|
2613
|
+
v[0] / l,
|
|
2614
|
+
v[1] / l,
|
|
2615
|
+
v[2] / l
|
|
2616
|
+
];
|
|
2617
|
+
}
|
|
2618
|
+
function makeJoint(type, parent, child, axis, opts, defMin, defMax) {
|
|
2619
|
+
const a = opts.min ?? defMin;
|
|
2620
|
+
const b = opts.max ?? defMax;
|
|
2621
|
+
const min = Math.min(a, b);
|
|
2622
|
+
const max = Math.max(a, b);
|
|
2623
|
+
return {
|
|
2624
|
+
type,
|
|
2625
|
+
parent,
|
|
2626
|
+
child,
|
|
2627
|
+
axis: {
|
|
2628
|
+
origin: axis.origin,
|
|
2629
|
+
direction: unit(axis.direction)
|
|
2630
|
+
},
|
|
2631
|
+
min,
|
|
2632
|
+
max,
|
|
2633
|
+
value: clamp(opts.value ?? 0, min, max)
|
|
2634
|
+
};
|
|
2635
|
+
}
|
|
2636
|
+
/** A revolute (hinge) joint — the child rotates about `axis` by `value` degrees. */
|
|
2637
|
+
function revoluteJoint(parent, child, axis, opts = {}) {
|
|
2638
|
+
return makeJoint("revolute", parent, child, axis, opts, -180, 180);
|
|
2639
|
+
}
|
|
2640
|
+
/**
|
|
2641
|
+
* A prismatic (slider) joint — the child translates along `axis` by `value`
|
|
2642
|
+
* units. Only `axis.direction` is used; `axis.origin` is ignored (a pure
|
|
2643
|
+
* translation has no anchor point), unlike a revolute joint which rotates about
|
|
2644
|
+
* the axis line through `origin`.
|
|
2645
|
+
*/
|
|
2646
|
+
function prismaticJoint(parent, child, axis, opts = {}) {
|
|
2647
|
+
return makeJoint("prismatic", parent, child, axis, opts, 0, 100);
|
|
2648
|
+
}
|
|
2649
|
+
/** Return a copy of `joint` with its drivable parameter set (clamped to range). */
|
|
2650
|
+
function setJointValue(joint, value) {
|
|
2651
|
+
return {
|
|
2652
|
+
...joint,
|
|
2653
|
+
value: clamp(value, joint.min, joint.max)
|
|
2654
|
+
};
|
|
2655
|
+
}
|
|
2656
|
+
/**
|
|
2657
|
+
* The child's local rigid transform (relative to the parent) for a joint value.
|
|
2658
|
+
* Defaults to the joint's stored value; an explicit value is clamped to range.
|
|
2659
|
+
*
|
|
2660
|
+
* - **revolute**: rotation of `value` degrees about the axis line. Rotating
|
|
2661
|
+
* about a line through `origin` is `p ↦ R·p + (origin − R·origin)`.
|
|
2662
|
+
* - **prismatic**: translation of `value` units along the axis direction.
|
|
2663
|
+
*/
|
|
2664
|
+
function jointTransform(joint, value = joint.value) {
|
|
2665
|
+
const v = clamp(value, joint.min, joint.max);
|
|
2666
|
+
const dir = unit(joint.axis.direction);
|
|
2667
|
+
if (joint.type === "prismatic") return {
|
|
2668
|
+
position: [
|
|
2669
|
+
dir[0] * v,
|
|
2670
|
+
dir[1] * v,
|
|
2671
|
+
dir[2] * v
|
|
2672
|
+
],
|
|
2673
|
+
rotation: [
|
|
2674
|
+
1,
|
|
2675
|
+
0,
|
|
2676
|
+
0,
|
|
2677
|
+
0
|
|
2678
|
+
]
|
|
2679
|
+
};
|
|
2680
|
+
const rotation = quatFromAxisAngle(dir, v * DEG2RAD$1);
|
|
2681
|
+
const o = joint.axis.origin;
|
|
2682
|
+
const ro = quatRotate(rotation, o);
|
|
2683
|
+
return {
|
|
2684
|
+
position: [
|
|
2685
|
+
o[0] - ro[0],
|
|
2686
|
+
o[1] - ro[1],
|
|
2687
|
+
o[2] - ro[2]
|
|
2688
|
+
],
|
|
2689
|
+
rotation
|
|
2690
|
+
};
|
|
2691
|
+
}
|
|
2692
|
+
/** Attach a joint to an assembly node. Returns a new node (immutable). */
|
|
2693
|
+
function addJoint(assembly, joint) {
|
|
2694
|
+
const existing = assembly.joints ?? [];
|
|
2695
|
+
return {
|
|
2696
|
+
...assembly,
|
|
2697
|
+
joints: [...existing, joint]
|
|
2698
|
+
};
|
|
2699
|
+
}
|
|
2700
|
+
//#endregion
|
|
2397
2701
|
//#region src/measurement/interferenceFns.ts
|
|
2398
2702
|
/**
|
|
2399
2703
|
* Interference detection between shapes.
|
|
@@ -6192,6 +6496,7 @@ exports.Sketcher = require_drawFns.Sketcher;
|
|
|
6192
6496
|
exports.Sketches = require_textBlueprints.Sketches;
|
|
6193
6497
|
exports.addChild = require_historyFns.addChild;
|
|
6194
6498
|
exports.addHoles = require_primitiveFns.addHoles;
|
|
6499
|
+
exports.addJoint = addJoint;
|
|
6195
6500
|
exports.addMate = addMate;
|
|
6196
6501
|
exports.addStep = require_historyFns.addStep;
|
|
6197
6502
|
exports.adjacentFaces = require_primitiveFns.adjacentFaces;
|
|
@@ -6362,6 +6667,7 @@ exports.exportThreeMF = require_importFns.exportThreeMF;
|
|
|
6362
6667
|
exports.extrude = extrude;
|
|
6363
6668
|
exports.extrudeAll = require_extrudeFns.extrudeAll;
|
|
6364
6669
|
exports.face = require_primitiveFns.face;
|
|
6670
|
+
exports.faceAxis = require_faceFns.faceAxis;
|
|
6365
6671
|
exports.faceCenter = require_faceFns.faceCenter;
|
|
6366
6672
|
exports.faceFinder = require_helpers.faceFinder;
|
|
6367
6673
|
exports.faceGeomType = require_faceFns.faceGeomType;
|
|
@@ -6508,6 +6814,7 @@ exports.iterSolids = require_topologyQueryFns.iterSolids;
|
|
|
6508
6814
|
exports.iterTopo = require_faceFns.iterTopo;
|
|
6509
6815
|
exports.iterVertices = require_topologyQueryFns.iterVertices;
|
|
6510
6816
|
exports.iterWires = require_topologyQueryFns.iterWires;
|
|
6817
|
+
exports.jointTransform = jointTransform;
|
|
6511
6818
|
exports.kernelCall = require_topologyQueryFns.kernelCall;
|
|
6512
6819
|
exports.kernelCallRaw = require_topologyQueryFns.kernelCallRaw;
|
|
6513
6820
|
exports.kernelCallScoped = require_topologyQueryFns.kernelCallScoped;
|
|
@@ -6602,6 +6909,7 @@ Object.defineProperty(exports, "primitives", {
|
|
|
6602
6909
|
return primitives_exports;
|
|
6603
6910
|
}
|
|
6604
6911
|
});
|
|
6912
|
+
exports.prismaticJoint = prismaticJoint;
|
|
6605
6913
|
exports.projectEdges = require_cameraFns.projectEdges;
|
|
6606
6914
|
exports.projectPointOnFace = require_faceFns.projectPointOnFace;
|
|
6607
6915
|
Object.defineProperty(exports, "query", {
|
|
@@ -6633,6 +6941,7 @@ exports.resolveDirection = require_types.resolveDirection;
|
|
|
6633
6941
|
exports.resolvePlane = require_planeOps.resolvePlane;
|
|
6634
6942
|
exports.resolveRef = require_shapeRefFns.resolveRef;
|
|
6635
6943
|
exports.reverseCurve = require_blueprintFns.reverseCurve;
|
|
6944
|
+
exports.revoluteJoint = revoluteJoint;
|
|
6636
6945
|
exports.revolve = revolve;
|
|
6637
6946
|
exports.roof = roof;
|
|
6638
6947
|
exports.rotate = rotate;
|
|
@@ -6661,6 +6970,7 @@ exports.sdfTorus = torus;
|
|
|
6661
6970
|
exports.section = section;
|
|
6662
6971
|
exports.sectionToFace = sectionToFace;
|
|
6663
6972
|
exports.serializeHistory = require_historyFns.serializeHistory;
|
|
6973
|
+
exports.setJointValue = setJointValue;
|
|
6664
6974
|
exports.setShapeOrigin = require_shapeFns.setShapeOrigin;
|
|
6665
6975
|
exports.setTagMetadata = require_shapeFns.setTagMetadata;
|
|
6666
6976
|
exports.sewShells = require_primitiveFns.sewShells;
|