@code3d/core 0.0.1-alpha.7 → 0.0.1-alpha.8
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/README.md +42 -1
- package/bld/chunks/{chunk-TCMEEKWL.js → chunk-EWPRWRLV.js} +2 -2
- package/bld/chunks/{chunk-VHSPHJ5F.js → chunk-HSU2FH3L.js} +3 -3
- package/bld/chunks/{chunk-4WLVDYUJ.js → chunk-MICNLFBF.js} +401 -76
- package/bld/chunks/chunk-MICNLFBF.js.map +7 -0
- package/bld/chunks/{chunk-C3AJ6WNB.js → chunk-OAVABPL5.js} +2 -2
- package/bld/library/index.d.ts +2 -2
- package/bld/library/index.d.ts.map +1 -1
- package/bld/library/index.js +3 -1
- package/bld/library/loft.d.ts.map +1 -1
- package/bld/library/replicad.js +2 -2
- package/bld/library/runtime.d.ts +57 -2
- package/bld/library/runtime.d.ts.map +1 -1
- package/bld/library/topology.d.ts +4 -2
- package/bld/library/topology.d.ts.map +1 -1
- package/bld/node/index.js +5 -3
- package/bld/node/replicad.js +4 -4
- package/bld/tooling/index.d.ts +1 -1
- package/bld/tooling/index.d.ts.map +1 -1
- package/bld/tooling/index.js +2 -2
- package/package.json +1 -1
- package/src/library/index.ts +3 -0
- package/src/library/loft.ts +5 -1
- package/src/library/runtime.ts +491 -37
- package/src/library/shell.ts +3 -3
- package/src/library/topology.ts +24 -15
- package/src/tooling/index.ts +1 -0
- package/bld/chunks/chunk-4WLVDYUJ.js.map +0 -7
- /package/bld/chunks/{chunk-TCMEEKWL.js.map → chunk-EWPRWRLV.js.map} +0 -0
- /package/bld/chunks/{chunk-VHSPHJ5F.js.map → chunk-HSU2FH3L.js.map} +0 -0
- /package/bld/chunks/{chunk-C3AJ6WNB.js.map → chunk-OAVABPL5.js.map} +0 -0
|
@@ -1109,9 +1109,9 @@ function sketchCurveClosestParameter(curve, position2) {
|
|
|
1109
1109
|
);
|
|
1110
1110
|
if (curve.kind === "circle") return sketchPositiveAngle(angle) / tau;
|
|
1111
1111
|
const sign3 = Math.sign(curve.sweep), sweep = Math.abs(curve.sweep);
|
|
1112
|
-
const
|
|
1113
|
-
if (
|
|
1114
|
-
return
|
|
1112
|
+
const distance4 = sketchPositiveAngle(sign3 * (angle - curve.start));
|
|
1113
|
+
if (distance4 <= sweep) return sweep ? distance4 / sweep : 0;
|
|
1114
|
+
return distance4 - sweep < tau - distance4 ? 1 : 0;
|
|
1115
1115
|
}
|
|
1116
1116
|
__name(sketchCurveClosestParameter, "sketchCurveClosestParameter");
|
|
1117
1117
|
function sketchCurveBounds(curve) {
|
|
@@ -2433,15 +2433,15 @@ function endpointPolicy(problem, point3, scope) {
|
|
|
2433
2433
|
controls.delete(point3);
|
|
2434
2434
|
if (controls.size) return { kind: "endpoint", anchors: [...controls] };
|
|
2435
2435
|
const graph = neighbors(problem);
|
|
2436
|
-
const
|
|
2437
|
-
for (const [p, d] of
|
|
2436
|
+
const distance4 = /* @__PURE__ */ new Map([[point3, 0]]);
|
|
2437
|
+
for (const [p, d] of distance4)
|
|
2438
2438
|
for (const next of graph[p])
|
|
2439
|
-
if (scope.has(next) && !
|
|
2439
|
+
if (scope.has(next) && !distance4.has(next)) distance4.set(next, d + 1);
|
|
2440
2440
|
let farthest = -1, max12 = 0;
|
|
2441
2441
|
for (const p of scope)
|
|
2442
|
-
if ((
|
|
2442
|
+
if ((distance4.get(p) ?? 0) > max12) {
|
|
2443
2443
|
farthest = p;
|
|
2444
|
-
max12 =
|
|
2444
|
+
max12 = distance4.get(p);
|
|
2445
2445
|
}
|
|
2446
2446
|
return { kind: "endpoint", anchors: farthest < 0 ? [] : [farthest] };
|
|
2447
2447
|
}
|
|
@@ -3112,22 +3112,22 @@ function nearestPoint(point3, geometry) {
|
|
|
3112
3112
|
case "ellipse": {
|
|
3113
3113
|
const y = cross2(geometry.normal, geometry.major);
|
|
3114
3114
|
const x0 = dot(delta, geometry.major), y0 = dot(delta, y);
|
|
3115
|
-
const
|
|
3115
|
+
const distance4 = /* @__PURE__ */ __name((angle2) => (geometry.radius * Math.cos(angle2) - x0) ** 2 + (geometry.minorRadius * Math.sin(angle2) - y0) ** 2, "distance");
|
|
3116
3116
|
const step = Math.PI / 16, candidates2 = [];
|
|
3117
3117
|
for (let i = 0; i < 32; i++) {
|
|
3118
3118
|
const angle2 = i * step;
|
|
3119
|
-
if (
|
|
3119
|
+
if (distance4(angle2) > distance4(angle2 - step) || distance4(angle2) > distance4(angle2 + step))
|
|
3120
3120
|
continue;
|
|
3121
3121
|
let lower = angle2 - step, upper = angle2 + step;
|
|
3122
3122
|
for (let iteration = 0; iteration < 64; iteration++) {
|
|
3123
3123
|
const a = lower + (upper - lower) * 0.3819660112501051, b = upper - (upper - lower) * 0.3819660112501051;
|
|
3124
|
-
if (
|
|
3124
|
+
if (distance4(a) < distance4(b)) upper = b;
|
|
3125
3125
|
else lower = a;
|
|
3126
3126
|
}
|
|
3127
3127
|
candidates2.push((lower + upper) / 2);
|
|
3128
3128
|
}
|
|
3129
3129
|
const angle = candidates2.reduce(
|
|
3130
|
-
(best, angle2) =>
|
|
3130
|
+
(best, angle2) => distance4(angle2) < distance4(best) ? angle2 : best,
|
|
3131
3131
|
candidates2[0]
|
|
3132
3132
|
);
|
|
3133
3133
|
return addVectors(
|
|
@@ -3300,8 +3300,8 @@ function filletEdges(shape, source, radius, edgeIds) {
|
|
|
3300
3300
|
return modifyEdges("fillet", shape, source, radius, edgeIds);
|
|
3301
3301
|
}
|
|
3302
3302
|
__name(filletEdges, "filletEdges");
|
|
3303
|
-
function chamferEdges(shape, source,
|
|
3304
|
-
return modifyEdges("chamfer", shape, source,
|
|
3303
|
+
function chamferEdges(shape, source, distance4, edgeIds) {
|
|
3304
|
+
return modifyEdges("chamfer", shape, source, distance4, edgeIds);
|
|
3305
3305
|
}
|
|
3306
3306
|
__name(chamferEdges, "chamferEdges");
|
|
3307
3307
|
function booleanWithTopology(left, right, operation) {
|
|
@@ -3528,7 +3528,7 @@ function modifyEdges(kind, shape, source, amount, requestedIds) {
|
|
|
3528
3528
|
return {
|
|
3529
3529
|
shape: result,
|
|
3530
3530
|
topology: transferShapeTopology(
|
|
3531
|
-
[{ shape, topology: source,
|
|
3531
|
+
[{ shape, topology: source, namespace: "preserve" }],
|
|
3532
3532
|
result,
|
|
3533
3533
|
builder
|
|
3534
3534
|
),
|
|
@@ -3603,15 +3603,18 @@ function transferShapeTopology(inputs, output, history) {
|
|
|
3603
3603
|
const transfer = /* @__PURE__ */ __name((kind) => {
|
|
3604
3604
|
const originals = [];
|
|
3605
3605
|
const results = topologyShapes(output, kind);
|
|
3606
|
+
let nextId = 1;
|
|
3606
3607
|
try {
|
|
3607
3608
|
const candidates2 = inputs.flatMap((input, inputIndex) => {
|
|
3608
3609
|
const shapes = topologyShapes(input.shape, kind);
|
|
3609
3610
|
originals.push(shapes);
|
|
3610
3611
|
const source = input.topology[topologyMetadata[kind].plural];
|
|
3611
3612
|
assertTopologyLength(kind, shapes, source);
|
|
3613
|
+
if (input.namespace === "preserve")
|
|
3614
|
+
nextId = Math.max(nextId, source.nextId);
|
|
3612
3615
|
return shapes.map((shape, index) => {
|
|
3613
3616
|
const id = source.ids[index];
|
|
3614
|
-
const inherited2 = input.
|
|
3617
|
+
const inherited2 = typeof input.namespace === "number" ? inheritedTopologyId(input.namespace, id) : input.namespace === "preserve" || typeof id !== "number" ? id : void 0;
|
|
3615
3618
|
const unchanged = matchingOutputShapes(shape.wrapped, results);
|
|
3616
3619
|
if (unchanged.length) return { id: inherited2, matches: unchanged };
|
|
3617
3620
|
if (typeof history !== "function") {
|
|
@@ -3648,10 +3651,8 @@ function transferShapeTopology(inputs, output, history) {
|
|
|
3648
3651
|
inherited.set(index, candidate.id);
|
|
3649
3652
|
}
|
|
3650
3653
|
}
|
|
3651
|
-
|
|
3652
|
-
return stableTopology(
|
|
3653
|
-
results.map((_, index) => inherited.get(index) ?? nextId++)
|
|
3654
|
-
);
|
|
3654
|
+
const ids = results.map((_, index) => inherited.get(index) ?? nextId++);
|
|
3655
|
+
return stableTopology(ids, nextId);
|
|
3655
3656
|
} finally {
|
|
3656
3657
|
originals.forEach(deleteShapes);
|
|
3657
3658
|
deleteShapes(results);
|
|
@@ -3710,11 +3711,14 @@ function stableGroupIds(kind, shapes, topology, kernelIds) {
|
|
|
3710
3711
|
}
|
|
3711
3712
|
__name(stableGroupIds, "stableGroupIds");
|
|
3712
3713
|
function initialTopology(shapes) {
|
|
3713
|
-
return stableTopology(
|
|
3714
|
+
return stableTopology(
|
|
3715
|
+
shapes.map((_, index) => index + 1),
|
|
3716
|
+
shapes.length + 1
|
|
3717
|
+
);
|
|
3714
3718
|
}
|
|
3715
3719
|
__name(initialTopology, "initialTopology");
|
|
3716
|
-
function stableTopology(ids) {
|
|
3717
|
-
return { ids };
|
|
3720
|
+
function stableTopology(ids, nextId) {
|
|
3721
|
+
return { ids, nextId };
|
|
3718
3722
|
}
|
|
3719
3723
|
__name(stableTopology, "stableTopology");
|
|
3720
3724
|
function shapeTopology(vertices, edges, surfaces) {
|
|
@@ -3815,7 +3819,11 @@ function loftWithTopology(sections, spine, ruled) {
|
|
|
3815
3819
|
ruled,
|
|
3816
3820
|
holes.map((wires) => wires[0])
|
|
3817
3821
|
);
|
|
3818
|
-
return booleanWithTopology(
|
|
3822
|
+
return booleanWithTopology(
|
|
3823
|
+
{ ...outer, namespace: "intermediate" },
|
|
3824
|
+
{ ...inner, namespace: "intermediate" },
|
|
3825
|
+
"cut"
|
|
3826
|
+
);
|
|
3819
3827
|
} finally {
|
|
3820
3828
|
inner?.shape.delete();
|
|
3821
3829
|
outer?.shape.delete();
|
|
@@ -6053,7 +6061,7 @@ function openShell(shape, topology, thickness, removedIds, sourceVolume) {
|
|
|
6053
6061
|
return {
|
|
6054
6062
|
shape: result,
|
|
6055
6063
|
topology: transferShapeTopology(
|
|
6056
|
-
[{ shape, topology,
|
|
6064
|
+
[{ shape, topology, namespace: "preserve" }],
|
|
6057
6065
|
result,
|
|
6058
6066
|
builder
|
|
6059
6067
|
)
|
|
@@ -6129,7 +6137,7 @@ function closedShell(shape, topology, thickness, sourceVolume) {
|
|
|
6129
6137
|
return {
|
|
6130
6138
|
shape: result,
|
|
6131
6139
|
topology: transferShapeTopology(
|
|
6132
|
-
[{ shape, topology,
|
|
6140
|
+
[{ shape, topology, namespace: "preserve" }],
|
|
6133
6141
|
result,
|
|
6134
6142
|
cut2
|
|
6135
6143
|
)
|
|
@@ -20281,6 +20289,7 @@ function inspectSurface(face) {
|
|
|
20281
20289
|
__name(inspectSurface, "inspectSurface");
|
|
20282
20290
|
|
|
20283
20291
|
// packages/core/src/library/runtime.ts
|
|
20292
|
+
var observeDistance;
|
|
20284
20293
|
function isAxisSelection(pivot2) {
|
|
20285
20294
|
return pivot2.kind === "axisLine" || pivot2.kind === "axisEdge";
|
|
20286
20295
|
}
|
|
@@ -20296,10 +20305,16 @@ __name(mapSelectionReference, "mapSelectionReference");
|
|
|
20296
20305
|
var activeRelate;
|
|
20297
20306
|
var valueTraces = /* @__PURE__ */ new WeakMap();
|
|
20298
20307
|
var operationTraces = /* @__PURE__ */ new WeakMap();
|
|
20299
|
-
function beginModelEvaluation(checkCancelled) {
|
|
20308
|
+
function beginModelEvaluation(checkCancelled, distanceObserver) {
|
|
20300
20309
|
valueTraces = /* @__PURE__ */ new WeakMap();
|
|
20301
20310
|
operationTraces = /* @__PURE__ */ new WeakMap();
|
|
20302
|
-
|
|
20311
|
+
const previous = observeDistance;
|
|
20312
|
+
observeDistance = distanceObserver;
|
|
20313
|
+
const finish = beginKernelOperationEvaluation(checkCancelled);
|
|
20314
|
+
return () => {
|
|
20315
|
+
observeDistance = previous;
|
|
20316
|
+
finish();
|
|
20317
|
+
};
|
|
20303
20318
|
}
|
|
20304
20319
|
__name(beginModelEvaluation, "beginModelEvaluation");
|
|
20305
20320
|
function valueTrace(value) {
|
|
@@ -20727,10 +20742,10 @@ function rotationPointReference(point3) {
|
|
|
20727
20742
|
return reference;
|
|
20728
20743
|
}
|
|
20729
20744
|
__name(rotationPointReference, "rotationPointReference");
|
|
20730
|
-
function
|
|
20745
|
+
function straightAxisReference(axis, operation = "axisLine()") {
|
|
20731
20746
|
const reference = anchorReference(axis);
|
|
20732
20747
|
if (reference.kind !== "line")
|
|
20733
|
-
throw new Error(
|
|
20748
|
+
throw new Error(`${operation} requires an axis or straight edge.`);
|
|
20734
20749
|
const geometry = reference.topology?.source[modelGeometry]()?.value ?? (reference.whole && isModelObject(reference.model) ? reference.model[modelGeometry]()?.value : void 0);
|
|
20735
20750
|
if (geometry) {
|
|
20736
20751
|
const straight = reference.topology ? withTopologyShape(
|
|
@@ -20741,12 +20756,12 @@ function rotationAxisReference(axis) {
|
|
|
20741
20756
|
) : geometry.shape.geomType === "LINE";
|
|
20742
20757
|
if (!straight)
|
|
20743
20758
|
throw new Error(
|
|
20744
|
-
|
|
20759
|
+
`${operation} requires a straight axis; curved edges do not define one axis.`
|
|
20745
20760
|
);
|
|
20746
20761
|
}
|
|
20747
20762
|
return reference;
|
|
20748
20763
|
}
|
|
20749
|
-
__name(
|
|
20764
|
+
__name(straightAxisReference, "straightAxisReference");
|
|
20750
20765
|
var PivotRotation = class extends RelationExpression {
|
|
20751
20766
|
/** @internal */
|
|
20752
20767
|
constructor(chain, selection, previous) {
|
|
@@ -20862,7 +20877,7 @@ __name(axisEdge, "axisEdge");
|
|
|
20862
20877
|
function axisLine(axis) {
|
|
20863
20878
|
return new AxisChain(new TransformationRotation(), {
|
|
20864
20879
|
kind: "axisLine",
|
|
20865
|
-
axis:
|
|
20880
|
+
axis: straightAxisReference(axis)
|
|
20866
20881
|
});
|
|
20867
20882
|
}
|
|
20868
20883
|
__name(axisLine, "axisLine");
|
|
@@ -21753,33 +21768,64 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
21753
21768
|
operation
|
|
21754
21769
|
);
|
|
21755
21770
|
}
|
|
21756
|
-
/**
|
|
21757
|
-
|
|
21771
|
+
/**
|
|
21772
|
+
* Measure finite geometry in this model's local frame, or in relativeTo's frame.
|
|
21773
|
+
* An explicit reference includes solved placement and nested group occurrences.
|
|
21774
|
+
* Empty groups have no finite bounds.
|
|
21775
|
+
*/
|
|
21776
|
+
bounds(relativeTo) {
|
|
21777
|
+
const target = relativeTo === void 0 ? this : requireModelObject(relativeTo, "bounds requires a reference model.");
|
|
21778
|
+
const transform = target.localFrames([this])[0];
|
|
21779
|
+
const [minimum, maximum] = this[referenceBounds](
|
|
21780
|
+
this.relationAnchorReference(),
|
|
21781
|
+
transform
|
|
21782
|
+
);
|
|
21783
|
+
return {
|
|
21784
|
+
minimum,
|
|
21785
|
+
maximum,
|
|
21786
|
+
size: [
|
|
21787
|
+
maximum[0] - minimum[0],
|
|
21788
|
+
maximum[1] - minimum[1],
|
|
21789
|
+
maximum[2] - minimum[2]
|
|
21790
|
+
]
|
|
21791
|
+
};
|
|
21792
|
+
}
|
|
21793
|
+
/**
|
|
21794
|
+
* Model-origin coordinates in relativeTo's local frame, including placement.
|
|
21795
|
+
* This model's origin in its own frame is always [0, 0, 0], even for point models.
|
|
21796
|
+
*/
|
|
21797
|
+
position(relativeTo) {
|
|
21798
|
+
const target = requireModelObject(
|
|
21799
|
+
relativeTo,
|
|
21800
|
+
"position requires a reference model."
|
|
21801
|
+
);
|
|
21802
|
+
return target.localFrames([this])[0].position;
|
|
21803
|
+
}
|
|
21804
|
+
/** Resolve source frames without losing nested occurrence positions. */
|
|
21805
|
+
localFrames(sources) {
|
|
21758
21806
|
const members = this.memberPoses();
|
|
21759
|
-
const external = sources.
|
|
21807
|
+
const external = sources.filter((model) => !members.has(model));
|
|
21760
21808
|
const context = external.length ? _ModelObject.createSolveContext([this, ...external]) : void 0;
|
|
21761
21809
|
return sources.map((source) => {
|
|
21762
|
-
const
|
|
21763
|
-
const {
|
|
21764
|
-
kind,
|
|
21765
|
-
transform: frame,
|
|
21766
|
-
topology,
|
|
21767
|
-
members: nested,
|
|
21768
|
-
bound,
|
|
21769
|
-
facing
|
|
21770
|
-
} = source instanceof _ModelObject ? source.exposedElement() : reference;
|
|
21771
|
-
const memberPose = members.get(reference.model);
|
|
21810
|
+
const memberPose = members.get(source);
|
|
21772
21811
|
if (memberPose === null)
|
|
21773
21812
|
throw new Error(
|
|
21774
21813
|
"The point or element belongs to multiple occurrences. Expose it through the intended child model's named reference."
|
|
21775
21814
|
);
|
|
21776
|
-
|
|
21777
|
-
|
|
21778
|
-
|
|
21779
|
-
|
|
21815
|
+
return memberPose ?? relativeTransform(source.solvePose(context), this.solvePose(context));
|
|
21816
|
+
});
|
|
21817
|
+
}
|
|
21818
|
+
/** Resolve both own and occurrence references into this model's local frame. */
|
|
21819
|
+
localElements(sources) {
|
|
21820
|
+
const references2 = sources.map(anchorReference);
|
|
21821
|
+
const transforms = this.localFrames(
|
|
21822
|
+
references2.map((reference) => reference.model)
|
|
21823
|
+
);
|
|
21824
|
+
return sources.map((source, index) => {
|
|
21825
|
+
const { kind, transform, topology, parts, members, bound, facing } = source instanceof _ModelObject ? source.exposedElement() : references2[index];
|
|
21780
21826
|
return transformElement(
|
|
21781
|
-
{ kind, transform
|
|
21782
|
-
|
|
21827
|
+
{ kind, transform, topology, parts, members, bound, facing },
|
|
21828
|
+
transforms[index]
|
|
21783
21829
|
);
|
|
21784
21830
|
});
|
|
21785
21831
|
}
|
|
@@ -21821,7 +21867,11 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
21821
21867
|
/** @internal */
|
|
21822
21868
|
exposedElement() {
|
|
21823
21869
|
if (this.kind === "group")
|
|
21824
|
-
return {
|
|
21870
|
+
return {
|
|
21871
|
+
...this.geometryAnchor,
|
|
21872
|
+
parts: this.geometryParts(),
|
|
21873
|
+
members: this.elements
|
|
21874
|
+
};
|
|
21825
21875
|
const geometry = this.requireGeometry().value;
|
|
21826
21876
|
const kind = this.kind === "face" ? "surface" : this.kind;
|
|
21827
21877
|
const selection = kind === "solid" ? { kind } : {
|
|
@@ -22026,14 +22076,14 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
22026
22076
|
storedOperation("scaled", [{ model: this, role: "source", index: 0 }])
|
|
22027
22077
|
);
|
|
22028
22078
|
}
|
|
22029
|
-
extrude(
|
|
22079
|
+
extrude(distance4 = 10) {
|
|
22030
22080
|
if (this.kind !== "face")
|
|
22031
22081
|
throw new Error("extrude requires a single face model.");
|
|
22032
|
-
if (!Number.isFinite(
|
|
22082
|
+
if (!Number.isFinite(distance4) || distance4 === 0)
|
|
22033
22083
|
throw new Error("Extrusion distance must be finite and non-zero.");
|
|
22034
22084
|
const source = this.requireGeometry();
|
|
22035
22085
|
const direction = rotateVector(
|
|
22036
|
-
[0,
|
|
22086
|
+
[0, distance4, 0],
|
|
22037
22087
|
this.geometryAnchor.transform.quaternion
|
|
22038
22088
|
);
|
|
22039
22089
|
const geometry = evaluateSolidGeometry(
|
|
@@ -22044,7 +22094,7 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
22044
22094
|
{
|
|
22045
22095
|
shape: source.value.shape,
|
|
22046
22096
|
topology: source.value.topology,
|
|
22047
|
-
|
|
22097
|
+
namespace: 1
|
|
22048
22098
|
},
|
|
22049
22099
|
direction
|
|
22050
22100
|
)
|
|
@@ -22111,8 +22161,8 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
22111
22161
|
})
|
|
22112
22162
|
);
|
|
22113
22163
|
}
|
|
22114
|
-
chamfer(
|
|
22115
|
-
assertPositive("distance",
|
|
22164
|
+
chamfer(distance4 = 1, edgeIds) {
|
|
22165
|
+
assertPositive("distance", distance4);
|
|
22116
22166
|
const source = this.requireSolidGeometry();
|
|
22117
22167
|
const selectedEdgeIds = resolveEdgeSelection(
|
|
22118
22168
|
source.value.topology.edges,
|
|
@@ -22120,13 +22170,13 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
22120
22170
|
);
|
|
22121
22171
|
const geometry = evaluateSolidGeometry(
|
|
22122
22172
|
"chamfer",
|
|
22123
|
-
[
|
|
22173
|
+
[distance4, selectedEdgeIds],
|
|
22124
22174
|
[source],
|
|
22125
22175
|
() => {
|
|
22126
22176
|
const result = chamferEdges(
|
|
22127
22177
|
source.value.shape,
|
|
22128
22178
|
source.value.topology,
|
|
22129
|
-
|
|
22179
|
+
distance4,
|
|
22130
22180
|
selectedEdgeIds
|
|
22131
22181
|
);
|
|
22132
22182
|
return { shape: result.shape, topology: result.topology };
|
|
@@ -22440,12 +22490,12 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
22440
22490
|
{
|
|
22441
22491
|
shape: geometry.value.shape,
|
|
22442
22492
|
topology: geometry.value.topology,
|
|
22443
|
-
|
|
22493
|
+
namespace: otherIndex === 0 ? 1 : "intermediate"
|
|
22444
22494
|
},
|
|
22445
22495
|
{
|
|
22446
22496
|
shape: operand.value,
|
|
22447
22497
|
topology: otherGeometry.value.topology,
|
|
22448
|
-
|
|
22498
|
+
namespace: otherIndex + 2
|
|
22449
22499
|
},
|
|
22450
22500
|
operation
|
|
22451
22501
|
);
|
|
@@ -22494,6 +22544,176 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
22494
22544
|
}
|
|
22495
22545
|
return members;
|
|
22496
22546
|
}
|
|
22547
|
+
/** Finite members in this value's saved local assembly, without re-solving children. */
|
|
22548
|
+
geometryParts(transform = identityRigidTransform) {
|
|
22549
|
+
if (this.geometry)
|
|
22550
|
+
return [{ source: this, selection: { kind: "solid" }, transform, scale: 1 }];
|
|
22551
|
+
return this.children.flatMap(
|
|
22552
|
+
(child) => child.geometryParts(
|
|
22553
|
+
composeTransforms(transform, child.solvePose(this.assembly))
|
|
22554
|
+
)
|
|
22555
|
+
);
|
|
22556
|
+
}
|
|
22557
|
+
/** @internal */
|
|
22558
|
+
static distance(a, b, axis) {
|
|
22559
|
+
const left = anchorReference(a), right = anchorReference(b);
|
|
22560
|
+
const axisReference = axis !== void 0 && typeof axis !== "string" && !Array.isArray(axis) ? straightAxisReference(axis, "distance() axis") : void 0;
|
|
22561
|
+
const context = _ModelObject.createSolveContext([
|
|
22562
|
+
left.model,
|
|
22563
|
+
right.model,
|
|
22564
|
+
...axisReference ? [axisReference.model] : []
|
|
22565
|
+
]);
|
|
22566
|
+
const topologyParts = /* @__PURE__ */ __name((reference) => reference.topology ? [reference.topology] : reference.parts ?? (reference.whole && reference.model instanceof _ModelObject ? reference.model.geometryParts() : void 0), "topologyParts");
|
|
22567
|
+
const parts = /* @__PURE__ */ __name((reference) => {
|
|
22568
|
+
const pose = reference.model.solvePose(context);
|
|
22569
|
+
const frame = composeTransforms(pose, reference.transform);
|
|
22570
|
+
if (reference.kind === "point") return [{ points: [frame.position] }];
|
|
22571
|
+
const topology = topologyParts(reference);
|
|
22572
|
+
if (topology)
|
|
22573
|
+
return topology.map((part) => ({
|
|
22574
|
+
geometry: part.source.requireGeometry(),
|
|
22575
|
+
selection: part.selection,
|
|
22576
|
+
scale: part.scale,
|
|
22577
|
+
transform: composeTransforms(pose, part.transform)
|
|
22578
|
+
}));
|
|
22579
|
+
if (reference.bound) {
|
|
22580
|
+
const [x, z] = reference.bound.size;
|
|
22581
|
+
const corners = x === 0 && z === 0 ? [origin] : x === 0 ? [
|
|
22582
|
+
[0, 0, -z / 2],
|
|
22583
|
+
[0, 0, z / 2]
|
|
22584
|
+
] : z === 0 ? [
|
|
22585
|
+
[-x / 2, 0, 0],
|
|
22586
|
+
[x / 2, 0, 0]
|
|
22587
|
+
] : [
|
|
22588
|
+
[-x / 2, 0, -z / 2],
|
|
22589
|
+
[x / 2, 0, -z / 2],
|
|
22590
|
+
[x / 2, 0, z / 2],
|
|
22591
|
+
[-x / 2, 0, z / 2]
|
|
22592
|
+
];
|
|
22593
|
+
return [
|
|
22594
|
+
{
|
|
22595
|
+
points: corners.map(
|
|
22596
|
+
(point3) => composeTransforms(frame, translation(point3)).position
|
|
22597
|
+
)
|
|
22598
|
+
}
|
|
22599
|
+
];
|
|
22600
|
+
}
|
|
22601
|
+
throw new Error(
|
|
22602
|
+
"distance() requires finite geometry or a point; select an edge or face instead of an infinite axis or plane."
|
|
22603
|
+
);
|
|
22604
|
+
}, "parts");
|
|
22605
|
+
const first = parts(left), second = parts(right);
|
|
22606
|
+
if (!first.length || !second.length)
|
|
22607
|
+
throw new Error("distance() cannot measure an empty group.");
|
|
22608
|
+
const record = /* @__PURE__ */ __name((result, direction2) => {
|
|
22609
|
+
if (observeDistance) {
|
|
22610
|
+
const operands = [left, right].map((reference) => {
|
|
22611
|
+
const topology = topologyParts(reference);
|
|
22612
|
+
const elements = topology && reference.kind !== "point" ? topology.map(
|
|
22613
|
+
(part) => snapshotElements({
|
|
22614
|
+
[reference.name]: {
|
|
22615
|
+
...reference,
|
|
22616
|
+
topology: part,
|
|
22617
|
+
members: void 0
|
|
22618
|
+
}
|
|
22619
|
+
})[0]
|
|
22620
|
+
) : [
|
|
22621
|
+
snapshotElements({
|
|
22622
|
+
[reference.name]: { ...reference, members: void 0 }
|
|
22623
|
+
})[0]
|
|
22624
|
+
];
|
|
22625
|
+
return { nodeId: reference.model.nodeId, elements };
|
|
22626
|
+
});
|
|
22627
|
+
observeDistance(
|
|
22628
|
+
{
|
|
22629
|
+
...result,
|
|
22630
|
+
axis: direction2,
|
|
22631
|
+
axisName: typeof axis === "string" ? axis : void 0,
|
|
22632
|
+
operands,
|
|
22633
|
+
placements: [...context.poses].map(([model, pose]) => ({
|
|
22634
|
+
nodeId: model.nodeId,
|
|
22635
|
+
transform: toTransform(pose)
|
|
22636
|
+
}))
|
|
22637
|
+
},
|
|
22638
|
+
[...context.poses.keys()]
|
|
22639
|
+
);
|
|
22640
|
+
}
|
|
22641
|
+
return result.value;
|
|
22642
|
+
}, "record");
|
|
22643
|
+
if (axis === void 0) {
|
|
22644
|
+
let result;
|
|
22645
|
+
for (const a2 of first)
|
|
22646
|
+
for (const b2 of second) {
|
|
22647
|
+
const candidate = "points" in a2 && a2.points.length === 1 && "points" in b2 && b2.points.length === 1 ? {
|
|
22648
|
+
value: Math.hypot(
|
|
22649
|
+
...a2.points[0].map((value, i) => value - b2.points[0][i])
|
|
22650
|
+
),
|
|
22651
|
+
start: a2.points[0],
|
|
22652
|
+
end: b2.points[0]
|
|
22653
|
+
} : distanceBetweenParts(a2, b2).value;
|
|
22654
|
+
if (!result || candidate.value < result.value) result = candidate;
|
|
22655
|
+
if (result.value === 0) return record(result);
|
|
22656
|
+
}
|
|
22657
|
+
return record(result);
|
|
22658
|
+
}
|
|
22659
|
+
const direction = axisReference ? rotateVector(
|
|
22660
|
+
[0, 1, 0],
|
|
22661
|
+
composeTransforms(
|
|
22662
|
+
axisReference.model.solvePose(context),
|
|
22663
|
+
axisReference.transform
|
|
22664
|
+
).quaternion
|
|
22665
|
+
) : typeof axis === "string" ? distanceAxes[axis] : axis;
|
|
22666
|
+
assertFiniteVector("distance() axis", direction);
|
|
22667
|
+
const magnitude = Math.hypot(...direction);
|
|
22668
|
+
if (magnitude === 0) throw new Error("distance() axis must be non-zero.");
|
|
22669
|
+
const normalized = direction.map(
|
|
22670
|
+
(value) => value / magnitude
|
|
22671
|
+
);
|
|
22672
|
+
const project = invertTransform(frameFromYAxis(origin, normalized));
|
|
22673
|
+
const projectedBounds = /* @__PURE__ */ __name((parts2) => {
|
|
22674
|
+
const bounds = parts2.map((part) => {
|
|
22675
|
+
if ("points" in part)
|
|
22676
|
+
return pointBounds(
|
|
22677
|
+
part.points.map(
|
|
22678
|
+
(point3) => composeTransforms(project, translation(point3)).position
|
|
22679
|
+
)
|
|
22680
|
+
);
|
|
22681
|
+
return evaluateSnapshotQuery(
|
|
22682
|
+
boundsQuery(
|
|
22683
|
+
part.geometry,
|
|
22684
|
+
composeTransforms(project, part.transform),
|
|
22685
|
+
part.selection,
|
|
22686
|
+
part.scale
|
|
22687
|
+
)
|
|
22688
|
+
);
|
|
22689
|
+
});
|
|
22690
|
+
return [
|
|
22691
|
+
[0, 1, 2].map(
|
|
22692
|
+
(i) => Math.min(...bounds.map((value) => value[0][i]))
|
|
22693
|
+
),
|
|
22694
|
+
[0, 1, 2].map(
|
|
22695
|
+
(i) => Math.max(...bounds.map((value) => value[1][i]))
|
|
22696
|
+
)
|
|
22697
|
+
];
|
|
22698
|
+
}, "projectedBounds");
|
|
22699
|
+
const aBounds = projectedBounds(first), bBounds = projectedBounds(second);
|
|
22700
|
+
const [aMin, aMax] = [aBounds[0][1], aBounds[1][1]], [bMin, bMax] = [bBounds[0][1], bBounds[1][1]];
|
|
22701
|
+
const overlap2 = (Math.max(aMin, bMin) + Math.min(aMax, bMax)) / 2;
|
|
22702
|
+
const [start, end] = bMin > aMax ? [aMax, bMin] : aMin > bMax ? [aMin, bMax] : [overlap2, overlap2];
|
|
22703
|
+
const center = [0, 1, 2].map(
|
|
22704
|
+
(i) => (Math.max(aBounds[0][i], bBounds[0][i]) + Math.min(aBounds[1][i], bBounds[1][i])) / 2
|
|
22705
|
+
);
|
|
22706
|
+
const unproject = invertTransform(project);
|
|
22707
|
+
const at = /* @__PURE__ */ __name((y) => composeTransforms(unproject, translation([center[0], y, center[2]])).position, "at");
|
|
22708
|
+
return record(
|
|
22709
|
+
{
|
|
22710
|
+
value: Math.max(0, bMin - aMax, aMin - bMax),
|
|
22711
|
+
start: at(start),
|
|
22712
|
+
end: at(end)
|
|
22713
|
+
},
|
|
22714
|
+
normalized
|
|
22715
|
+
);
|
|
22716
|
+
}
|
|
22497
22717
|
/** Bounds of the selected finite geometry after a rigid transform. */
|
|
22498
22718
|
[referenceBoundsParts](reference, transform) {
|
|
22499
22719
|
if (reference.bound)
|
|
@@ -22525,6 +22745,15 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
22525
22745
|
)
|
|
22526
22746
|
];
|
|
22527
22747
|
}
|
|
22748
|
+
if (reference.parts)
|
|
22749
|
+
return reference.parts.map(
|
|
22750
|
+
(part) => boundsQuery(
|
|
22751
|
+
part.source.requireGeometry(),
|
|
22752
|
+
composeTransforms(transform, part.transform),
|
|
22753
|
+
part.selection,
|
|
22754
|
+
part.scale
|
|
22755
|
+
)
|
|
22756
|
+
);
|
|
22528
22757
|
return [{ bounds: super[referenceBounds](reference, transform) }];
|
|
22529
22758
|
}
|
|
22530
22759
|
/** Bounds of the selected finite geometry after a rigid transform. */
|
|
@@ -22604,7 +22833,7 @@ var ModelObject = class _ModelObject extends RelationObject {
|
|
|
22604
22833
|
);
|
|
22605
22834
|
}
|
|
22606
22835
|
edgeReference(id) {
|
|
22607
|
-
return { ...
|
|
22836
|
+
return { ...straightAxisReference(this.edge(id)), model: void 0 };
|
|
22608
22837
|
}
|
|
22609
22838
|
vertexPosition(id) {
|
|
22610
22839
|
return anchorReference(this.vertex(id)).transform.position;
|
|
@@ -22968,11 +23197,11 @@ function assertCoilClearance(radius, wireRadius, pitch, turns) {
|
|
|
22968
23197
|
else upper = middle;
|
|
22969
23198
|
}
|
|
22970
23199
|
const separation = Math.min(fullTurn * turns, (lower + upper) / 2);
|
|
22971
|
-
const
|
|
23200
|
+
const distance4 = Math.hypot(
|
|
22972
23201
|
2 * radius * Math.sin(separation / 2),
|
|
22973
23202
|
pitch * separation / fullTurn
|
|
22974
23203
|
);
|
|
22975
|
-
if (
|
|
23204
|
+
if (distance4 <= 2 * wireRadius) {
|
|
22976
23205
|
throw new Error(
|
|
22977
23206
|
"Coil turns must not touch or overlap; increase pitch or decrease wireRadius."
|
|
22978
23207
|
);
|
|
@@ -23165,12 +23394,16 @@ function group(children, name = "Group") {
|
|
|
23165
23394
|
});
|
|
23166
23395
|
}
|
|
23167
23396
|
__name(group, "group");
|
|
23397
|
+
function distance2(a, b, axis) {
|
|
23398
|
+
return ModelObject.distance(a, b, axis);
|
|
23399
|
+
}
|
|
23400
|
+
__name(distance2, "distance");
|
|
23168
23401
|
function union(operands) {
|
|
23169
23402
|
const { first, others } = booleanOperands("union", operands);
|
|
23170
23403
|
return first[combineModels]("fuse", others);
|
|
23171
23404
|
}
|
|
23172
23405
|
__name(union, "union");
|
|
23173
|
-
function extrude(face,
|
|
23406
|
+
function extrude(face, distance4 = 10) {
|
|
23174
23407
|
const faces = (Array.isArray(face) ? face : [face]).map(
|
|
23175
23408
|
(value) => requireModelKind(
|
|
23176
23409
|
value,
|
|
@@ -23178,7 +23411,7 @@ function extrude(face, distance3 = 10) {
|
|
|
23178
23411
|
"extrude requires a face model or an array of face models."
|
|
23179
23412
|
)
|
|
23180
23413
|
);
|
|
23181
|
-
const solids = faces.map((value) => value.extrude(
|
|
23414
|
+
const solids = faces.map((value) => value.extrude(distance4));
|
|
23182
23415
|
return Array.isArray(face) ? solids : solids[0];
|
|
23183
23416
|
}
|
|
23184
23417
|
__name(extrude, "extrude");
|
|
@@ -23278,6 +23511,83 @@ function relatedModelObjects(object) {
|
|
|
23278
23511
|
return object.relatedObjects();
|
|
23279
23512
|
}
|
|
23280
23513
|
__name(relatedModelObjects, "relatedModelObjects");
|
|
23514
|
+
var distanceAxes = { x: [1, 0, 0], y: [0, 1, 0], z: [0, 0, 1] };
|
|
23515
|
+
function withDistanceShape(part, visit) {
|
|
23516
|
+
if (!("points" in part))
|
|
23517
|
+
return withTransformedGeometry(part.geometry.value, part, visit);
|
|
23518
|
+
const points = part.points;
|
|
23519
|
+
if (points.length <= 2) {
|
|
23520
|
+
const shape = points.length === 1 ? makeVertex(toPoint(points[0])) : makeLine2(toPoint(points[0]), toPoint(points[1]));
|
|
23521
|
+
try {
|
|
23522
|
+
return visit(shape);
|
|
23523
|
+
} finally {
|
|
23524
|
+
shape.delete();
|
|
23525
|
+
}
|
|
23526
|
+
}
|
|
23527
|
+
const edges = [];
|
|
23528
|
+
let wire;
|
|
23529
|
+
let face;
|
|
23530
|
+
try {
|
|
23531
|
+
points.forEach(
|
|
23532
|
+
(point3, index) => edges.push(
|
|
23533
|
+
makeLine2(toPoint(point3), toPoint(points[(index + 1) % points.length]))
|
|
23534
|
+
)
|
|
23535
|
+
);
|
|
23536
|
+
wire = assembleWire(edges);
|
|
23537
|
+
face = makeFace(wire);
|
|
23538
|
+
return visit(face);
|
|
23539
|
+
} finally {
|
|
23540
|
+
face?.delete();
|
|
23541
|
+
wire?.delete();
|
|
23542
|
+
edges.forEach((edge) => edge.delete());
|
|
23543
|
+
}
|
|
23544
|
+
}
|
|
23545
|
+
__name(withDistanceShape, "withDistanceShape");
|
|
23546
|
+
var distanceBetweenParts = cachedArtifact(
|
|
23547
|
+
(a, b) => withDistanceShape(
|
|
23548
|
+
a,
|
|
23549
|
+
(left) => withDistanceShape(b, (right) => {
|
|
23550
|
+
const query = new (getOC12()).BRepExtrema_DistShapeShape();
|
|
23551
|
+
try {
|
|
23552
|
+
query.LoadS1(left.wrapped);
|
|
23553
|
+
query.LoadS2(right.wrapped);
|
|
23554
|
+
query.Perform();
|
|
23555
|
+
if (!query.IsDone())
|
|
23556
|
+
throw new Error("distance() could not measure these geometries.");
|
|
23557
|
+
const first = query.PointOnShape1(1), second = query.PointOnShape2(1);
|
|
23558
|
+
try {
|
|
23559
|
+
return {
|
|
23560
|
+
value: query.Value(),
|
|
23561
|
+
start: [first.X(), first.Y(), first.Z()],
|
|
23562
|
+
end: [second.X(), second.Y(), second.Z()]
|
|
23563
|
+
};
|
|
23564
|
+
} finally {
|
|
23565
|
+
first.delete();
|
|
23566
|
+
second.delete();
|
|
23567
|
+
}
|
|
23568
|
+
} finally {
|
|
23569
|
+
query.delete();
|
|
23570
|
+
}
|
|
23571
|
+
})
|
|
23572
|
+
),
|
|
23573
|
+
{
|
|
23574
|
+
key: /* @__PURE__ */ __name((a, b) => kernelOperationKey(
|
|
23575
|
+
"distance-witnesses",
|
|
23576
|
+
[a, b].map(
|
|
23577
|
+
(part) => "points" in part ? ["points", part.points] : [
|
|
23578
|
+
"shape",
|
|
23579
|
+
part.geometry.id,
|
|
23580
|
+
part.selection.kind,
|
|
23581
|
+
part.selection.kind === "solid" ? null : part.selection.id,
|
|
23582
|
+
part.transform.position,
|
|
23583
|
+
part.transform.quaternion,
|
|
23584
|
+
part.scale
|
|
23585
|
+
]
|
|
23586
|
+
),
|
|
23587
|
+
[a, b].flatMap((part) => "points" in part ? [] : [part.geometry])
|
|
23588
|
+
), "key")
|
|
23589
|
+
}
|
|
23590
|
+
);
|
|
23281
23591
|
function boundsQuery(geometry, transform, selection = { kind: "solid" }, scale3 = 1) {
|
|
23282
23592
|
return {
|
|
23283
23593
|
inputId: geometry.id,
|
|
@@ -23500,6 +23810,7 @@ var authoringApi = Object.freeze({
|
|
|
23500
23810
|
frustum,
|
|
23501
23811
|
regularPrism,
|
|
23502
23812
|
group,
|
|
23813
|
+
distance: distance2,
|
|
23503
23814
|
union,
|
|
23504
23815
|
cut,
|
|
23505
23816
|
intersect
|
|
@@ -23797,7 +24108,7 @@ function buildLoftGeometry(sections, spine, ruled) {
|
|
|
23797
24108
|
section.transform
|
|
23798
24109
|
),
|
|
23799
24110
|
topology: section.geometry.value.topology,
|
|
23800
|
-
|
|
24111
|
+
namespace: index + 1
|
|
23801
24112
|
});
|
|
23802
24113
|
}
|
|
23803
24114
|
if (spine) {
|
|
@@ -23877,6 +24188,10 @@ function axisAlignedBounds(bounds, transform) {
|
|
|
23877
24188
|
}
|
|
23878
24189
|
__name(axisAlignedBounds, "axisAlignedBounds");
|
|
23879
24190
|
function computeTransformedBounds(geometry, query) {
|
|
24191
|
+
return withTransformedGeometry(geometry, query, shapeBounds);
|
|
24192
|
+
}
|
|
24193
|
+
__name(computeTransformedBounds, "computeTransformedBounds");
|
|
24194
|
+
function withTransformedGeometry(geometry, query, visit) {
|
|
23880
24195
|
const { transform, selection, scale: scale3 } = query;
|
|
23881
24196
|
return withTopologyShape(
|
|
23882
24197
|
geometry.shape,
|
|
@@ -23887,7 +24202,7 @@ function computeTransformedBounds(geometry, query) {
|
|
|
23887
24202
|
try {
|
|
23888
24203
|
const moved = shapeWithTransform(scaled, transform);
|
|
23889
24204
|
try {
|
|
23890
|
-
return
|
|
24205
|
+
return visit(moved);
|
|
23891
24206
|
} finally {
|
|
23892
24207
|
moved.delete();
|
|
23893
24208
|
}
|
|
@@ -23897,7 +24212,7 @@ function computeTransformedBounds(geometry, query) {
|
|
|
23897
24212
|
}
|
|
23898
24213
|
);
|
|
23899
24214
|
}
|
|
23900
|
-
__name(
|
|
24215
|
+
__name(withTransformedGeometry, "withTransformedGeometry");
|
|
23901
24216
|
function pointBounds(points) {
|
|
23902
24217
|
if (!points.length)
|
|
23903
24218
|
throw new Error("Empty geometry has no directional bounds.");
|
|
@@ -23999,6 +24314,10 @@ function transformElement(element, transform) {
|
|
|
23999
24314
|
...element.topology,
|
|
24000
24315
|
transform: composeTransforms(transform, element.topology.transform)
|
|
24001
24316
|
} : void 0,
|
|
24317
|
+
parts: element.parts?.map((part) => ({
|
|
24318
|
+
...part,
|
|
24319
|
+
transform: composeTransforms(transform, part.transform)
|
|
24320
|
+
})),
|
|
24002
24321
|
members: element.members ? Object.fromEntries(
|
|
24003
24322
|
Object.entries(element.members).map(([name, member]) => [
|
|
24004
24323
|
name,
|
|
@@ -24023,6 +24342,11 @@ function scaleElement(element, factor) {
|
|
|
24023
24342
|
scale: element.topology.scale * factor,
|
|
24024
24343
|
transform: scaleFrame(element.topology.transform, factor)
|
|
24025
24344
|
} : void 0,
|
|
24345
|
+
parts: element.parts?.map((part) => ({
|
|
24346
|
+
...part,
|
|
24347
|
+
scale: part.scale * factor,
|
|
24348
|
+
transform: scaleFrame(part.transform, factor)
|
|
24349
|
+
})),
|
|
24026
24350
|
members: element.members ? scaleElements(element.members, factor) : void 0,
|
|
24027
24351
|
transform: {
|
|
24028
24352
|
...element.transform,
|
|
@@ -24990,7 +25314,7 @@ __name(solvedProblem, "solvedProblem");
|
|
|
24990
25314
|
|
|
24991
25315
|
// packages/core/src/library/sketch-regions.ts
|
|
24992
25316
|
var tau2 = 2 * Math.PI;
|
|
24993
|
-
var
|
|
25317
|
+
var distance3 = /* @__PURE__ */ __name((a, b) => Math.hypot(a[0] - b[0], a[1] - b[1]), "distance");
|
|
24994
25318
|
function sketchRegions(layers) {
|
|
24995
25319
|
const resolve = sketchPointResolver(layers);
|
|
24996
25320
|
const points = new Map(
|
|
@@ -25012,7 +25336,7 @@ function sketchRegions(layers) {
|
|
|
25012
25336
|
const vertices = [];
|
|
25013
25337
|
const vertex = /* @__PURE__ */ __name((position2, tolerance2) => {
|
|
25014
25338
|
const index = vertices.findIndex(
|
|
25015
|
-
(v) =>
|
|
25339
|
+
(v) => distance3(v.position, position2) <= Math.min(v.tolerance, tolerance2)
|
|
25016
25340
|
);
|
|
25017
25341
|
if (index >= 0) return index;
|
|
25018
25342
|
vertices.push({ position: position2, tolerance: tolerance2, edges: [] });
|
|
@@ -25042,7 +25366,7 @@ function sketchRegions(layers) {
|
|
|
25042
25366
|
) || contacts.some(
|
|
25043
25367
|
(c) => c.parameters.some((_, j) => {
|
|
25044
25368
|
const curve = j === 0 ? a.curve : b.curve;
|
|
25045
|
-
return curve.kind === "circle" ||
|
|
25369
|
+
return curve.kind === "circle" || distance3(c.position, sketchCurvePosition(curve, 0)) > sketchCurveTolerance(curve) && distance3(c.position, sketchCurvePosition(curve, 1)) > sketchCurveTolerance(curve);
|
|
25046
25370
|
})
|
|
25047
25371
|
))
|
|
25048
25372
|
throw new Error(
|
|
@@ -25117,7 +25441,7 @@ function overlap(a, b, intersections) {
|
|
|
25117
25441
|
if (a.kind === "line" || b.kind === "line") {
|
|
25118
25442
|
if (a.kind !== "line" || b.kind !== "line" || intersections.length < 2)
|
|
25119
25443
|
return false;
|
|
25120
|
-
} else if (
|
|
25444
|
+
} else if (distance3(a.center, b.center) > Math.min(sketchCurveTolerance(a), sketchCurveTolerance(b)) || Math.abs(a.radius - b.radius) > Math.min(sketchCurveTolerance(a), sketchCurveTolerance(b)))
|
|
25121
25445
|
return false;
|
|
25122
25446
|
const cuts = [0, ...intersections, 1].sort((a2, b2) => a2 - b2);
|
|
25123
25447
|
return cuts.slice(1).some(
|
|
@@ -25251,6 +25575,7 @@ export {
|
|
|
25251
25575
|
regularPrism,
|
|
25252
25576
|
primitiveConstructor,
|
|
25253
25577
|
group,
|
|
25578
|
+
distance2 as distance,
|
|
25254
25579
|
union,
|
|
25255
25580
|
extrude,
|
|
25256
25581
|
text,
|
|
@@ -25286,4 +25611,4 @@ export {
|
|
|
25286
25611
|
assertSketchDragConnections,
|
|
25287
25612
|
solveSketchSnapshot
|
|
25288
25613
|
};
|
|
25289
|
-
//# sourceMappingURL=chunk-
|
|
25614
|
+
//# sourceMappingURL=chunk-MICNLFBF.js.map
|