@tscircuit/core 0.0.2115 → 0.0.2117
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/index.d.ts +187 -53
- package/dist/index.js +372 -99
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -27,6 +27,7 @@ __export(components_exports, {
|
|
|
27
27
|
AssemblyMotor: () => AssemblyMotor,
|
|
28
28
|
AssemblyPart: () => AssemblyPart,
|
|
29
29
|
AssemblyPrintedPart: () => AssemblyPrintedPart,
|
|
30
|
+
AssemblyReferenceSurface: () => AssemblyReferenceSurface,
|
|
30
31
|
AssemblyScreen: () => AssemblyScreen,
|
|
31
32
|
AssemblySubassembly: () => AssemblySubassembly,
|
|
32
33
|
AutoroutingPhase: () => AutoroutingPhase,
|
|
@@ -14772,6 +14773,30 @@ var matchesAssemblyIdentity = (component, path) => {
|
|
|
14772
14773
|
return true;
|
|
14773
14774
|
};
|
|
14774
14775
|
|
|
14776
|
+
// lib/components/primitive-components/get-part-reference-surfaces.ts
|
|
14777
|
+
import {
|
|
14778
|
+
resolveReferencePlanes
|
|
14779
|
+
} from "jscad-planner";
|
|
14780
|
+
var getPartReferenceSurfaces = (part) => {
|
|
14781
|
+
const model = part._parsedProps.cadModel;
|
|
14782
|
+
const authored = part.componentName === "AssemblyPrintedPart" ? part.printedPartPlan?.referencePlanes ?? (model && typeof model === "object" && "jscad" in model ? resolveReferencePlanes(model.jscad).referencePlanes : []) : [];
|
|
14783
|
+
const surfaces = [
|
|
14784
|
+
...authored,
|
|
14785
|
+
...part.children.filter(
|
|
14786
|
+
(child) => child.componentName === "AssemblyReferenceSurface"
|
|
14787
|
+
).map((child) => child.referenceFrame)
|
|
14788
|
+
];
|
|
14789
|
+
const names = /* @__PURE__ */ new Set();
|
|
14790
|
+
for (const surface of surfaces) {
|
|
14791
|
+
if (names.has(surface.name))
|
|
14792
|
+
throw new Error(
|
|
14793
|
+
`Part "${part.name}" has duplicate reference surface "${surface.name}"`
|
|
14794
|
+
);
|
|
14795
|
+
names.add(surface.name);
|
|
14796
|
+
}
|
|
14797
|
+
return surfaces;
|
|
14798
|
+
};
|
|
14799
|
+
|
|
14775
14800
|
// lib/components/primitive-components/get-assembly-scope-components.ts
|
|
14776
14801
|
var getAssemblyScope = (component) => {
|
|
14777
14802
|
let ancestor = component.parent;
|
|
@@ -14789,9 +14814,19 @@ var getComponentsInAssemblyScope = (component) => {
|
|
|
14789
14814
|
};
|
|
14790
14815
|
|
|
14791
14816
|
// lib/components/primitive-components/resolve-printed-part-mounts.ts
|
|
14792
|
-
var isMountablePart = (part) => part.componentName === "AssemblyMotor" || part.componentName === "AssemblyPrintedPart";
|
|
14817
|
+
var isMountablePart = (part) => part.componentName === "AssemblyMotor" || part.componentName === "AssemblyPart" || part.componentName === "AssemblyPrintedPart";
|
|
14793
14818
|
var isPrintedPart = (part) => part.componentName === "AssemblyPrintedPart";
|
|
14819
|
+
var isMotor = (part) => part.componentName === "AssemblyMotor";
|
|
14794
14820
|
var identity7 = () => [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
|
|
14821
|
+
var getMountTransformPlacement = (world) => {
|
|
14822
|
+
const bottom = world[10] < 0;
|
|
14823
|
+
const sign = bottom ? -1 : 1;
|
|
14824
|
+
return {
|
|
14825
|
+
position: { x: world[12], y: world[13], z: world[14] },
|
|
14826
|
+
pcbRotation: Math.atan2(sign * world[1], sign * world[0]) * 180 / Math.PI,
|
|
14827
|
+
layer: bottom ? "bottom" : "top"
|
|
14828
|
+
};
|
|
14829
|
+
};
|
|
14795
14830
|
var faceMatrix = ({
|
|
14796
14831
|
origin,
|
|
14797
14832
|
normal,
|
|
@@ -14806,14 +14841,12 @@ var faceMatrix = ({
|
|
|
14806
14841
|
);
|
|
14807
14842
|
};
|
|
14808
14843
|
var getFace = (part, faceName) => {
|
|
14809
|
-
if (
|
|
14810
|
-
const face = part.
|
|
14844
|
+
if (!isMotor(part)) {
|
|
14845
|
+
const face = getPartReferenceSurfaces(part).find(
|
|
14811
14846
|
(face2) => face2.name === faceName
|
|
14812
14847
|
);
|
|
14813
14848
|
if (!face)
|
|
14814
|
-
throw new Error(
|
|
14815
|
-
`Printed part "${part.name}" has no reference face "${faceName}"`
|
|
14816
|
-
);
|
|
14849
|
+
throw new Error(`Part "${part.name}" has no reference face "${faceName}"`);
|
|
14817
14850
|
return face;
|
|
14818
14851
|
}
|
|
14819
14852
|
if (faceName !== "backface" && faceName !== "frontface")
|
|
@@ -14845,9 +14878,21 @@ var findTarget = (owner, selector, parts) => {
|
|
|
14845
14878
|
const part = matches[0];
|
|
14846
14879
|
return { part, face: getFace(part, faceName) };
|
|
14847
14880
|
};
|
|
14848
|
-
var rootOrientation = (part) => {
|
|
14881
|
+
var rootOrientation = (part, placement) => {
|
|
14849
14882
|
const result = identity7();
|
|
14850
14883
|
if (isPrintedPart(part)) return result;
|
|
14884
|
+
if (!isMotor(part)) {
|
|
14885
|
+
if (!placement)
|
|
14886
|
+
throw new Error(`Part "${part.name}" has no inherited placement`);
|
|
14887
|
+
mat4.translate(result, result, [
|
|
14888
|
+
placement.position.x,
|
|
14889
|
+
placement.position.y,
|
|
14890
|
+
placement.position.z
|
|
14891
|
+
]);
|
|
14892
|
+
mat4.rotateZ(result, result, placement.pcbRotation * Math.PI / 180);
|
|
14893
|
+
if (placement.layer === "bottom") mat4.rotateY(result, result, Math.PI);
|
|
14894
|
+
return result;
|
|
14895
|
+
}
|
|
14851
14896
|
switch (part._parsedProps.shaftFacingDirection) {
|
|
14852
14897
|
case "x+":
|
|
14853
14898
|
return mat4.rotateY(result, result, Math.PI / 2);
|
|
@@ -14877,9 +14922,25 @@ var resolvePrintedPartMounts = (component) => {
|
|
|
14877
14922
|
);
|
|
14878
14923
|
const existing = transforms.get(part);
|
|
14879
14924
|
if (existing) return existing;
|
|
14880
|
-
let world
|
|
14925
|
+
let world;
|
|
14881
14926
|
let root = part;
|
|
14882
|
-
|
|
14927
|
+
const parent = part.componentName === "AssemblyPart" ? findParentAssembly(part) : void 0;
|
|
14928
|
+
if (parent && isMountablePart(parent)) {
|
|
14929
|
+
world = [...resolvePart(parent, [...path, part])];
|
|
14930
|
+
root = roots.get(parent);
|
|
14931
|
+
} else {
|
|
14932
|
+
const placement = part.componentName === "AssemblyPart" ? resolveInheritedAssemblyPlacement(
|
|
14933
|
+
part,
|
|
14934
|
+
[],
|
|
14935
|
+
(target) => {
|
|
14936
|
+
const targetWorld = resolvePart(target, [...path, part]);
|
|
14937
|
+
root = roots.get(target);
|
|
14938
|
+
return getMountTransformPlacement(targetWorld);
|
|
14939
|
+
}
|
|
14940
|
+
) : void 0;
|
|
14941
|
+
world = rootOrientation(part, placement);
|
|
14942
|
+
}
|
|
14943
|
+
if ((isMotor(part) || isPrintedPart(part)) && part._parsedProps.mountedTo) {
|
|
14883
14944
|
const { part: target, face } = findTarget(
|
|
14884
14945
|
part,
|
|
14885
14946
|
part._parsedProps.mountedTo,
|
|
@@ -14904,7 +14965,7 @@ var resolvePrintedPartMounts = (component) => {
|
|
|
14904
14965
|
};
|
|
14905
14966
|
for (const part of parts) resolvePart(part);
|
|
14906
14967
|
const motorMountRoots = new Set(
|
|
14907
|
-
parts.filter((part) =>
|
|
14968
|
+
parts.filter((part) => isMotor(part) && part._parsedProps.mountedTo).map((part) => roots.get(part))
|
|
14908
14969
|
);
|
|
14909
14970
|
const anchoredRoots = /* @__PURE__ */ new Set();
|
|
14910
14971
|
for (const board of scoped.filter(
|
|
@@ -14922,7 +14983,7 @@ var resolvePrintedPartMounts = (component) => {
|
|
|
14922
14983
|
`Assembly "${root.name}" has multiple mounted boards; only one board may determine its placement`
|
|
14923
14984
|
);
|
|
14924
14985
|
anchoredRoots.add(root);
|
|
14925
|
-
if (
|
|
14986
|
+
if (isMotor(root) && !["z+", "z-"].includes(root._parsedProps.shaftFacingDirection ?? "z+"))
|
|
14926
14987
|
throw new Error(
|
|
14927
14988
|
`Board "${board.name}" cannot mount to motor "${root.name}" facing ${root._parsedProps.shaftFacingDirection}: rotated PCB boards are not yet supported`
|
|
14928
14989
|
);
|
|
@@ -14995,7 +15056,7 @@ var boardMountsToPrintedPart = (board) => {
|
|
|
14995
15056
|
if (!selector) return false;
|
|
14996
15057
|
const partName = selector.slice(0, selector.lastIndexOf("."));
|
|
14997
15058
|
return getComponentsInAssemblyScope(board).some(
|
|
14998
|
-
(part) => part.componentName === "AssemblyPrintedPart" && matchesAssemblyIdentity(part, partName)
|
|
15059
|
+
(part) => (part.componentName === "AssemblyPrintedPart" || part.componentName === "AssemblyPart") && matchesAssemblyIdentity(part, partName)
|
|
14999
15060
|
);
|
|
15000
15061
|
};
|
|
15001
15062
|
|
|
@@ -15050,17 +15111,32 @@ var findParentAssembly = (component) => {
|
|
|
15050
15111
|
return void 0;
|
|
15051
15112
|
};
|
|
15052
15113
|
var resolveAssemblyPlacement = (component, path = []) => {
|
|
15053
|
-
if (component
|
|
15114
|
+
if (path.includes(component)) {
|
|
15115
|
+
throw new Error(
|
|
15116
|
+
`Assembly attachment cycle: ${[...path, component].map((item) => item.name).join(" -> ")}`
|
|
15117
|
+
);
|
|
15118
|
+
}
|
|
15119
|
+
if (component.componentName === "AssemblyPrintedPart" || component.componentName === "AssemblyPart") {
|
|
15054
15120
|
const part = component;
|
|
15055
15121
|
const { transforms, subcircuitId } = resolvePrintedPartMounts(part);
|
|
15056
15122
|
const transform = transforms.get(part);
|
|
15123
|
+
if (part.componentName === "AssemblyPart")
|
|
15124
|
+
return {
|
|
15125
|
+
...getMountTransformPlacement(transform),
|
|
15126
|
+
worldTransform: Math.abs(Math.abs(transform[10]) - 1) > 1e-6 ? transform : void 0,
|
|
15127
|
+
subcircuit_id: subcircuitId
|
|
15128
|
+
};
|
|
15057
15129
|
return {
|
|
15130
|
+
worldTransform: transform,
|
|
15058
15131
|
position: { x: transform[12], y: transform[13], z: transform[14] },
|
|
15059
15132
|
pcbRotation: 0,
|
|
15060
15133
|
layer: "top",
|
|
15061
15134
|
subcircuit_id: subcircuitId
|
|
15062
15135
|
};
|
|
15063
15136
|
}
|
|
15137
|
+
return resolveInheritedAssemblyPlacement(component, path);
|
|
15138
|
+
};
|
|
15139
|
+
var resolveInheritedAssemblyPlacement = (component, path = [], resolvePartPlacement) => {
|
|
15064
15140
|
if (path.includes(component)) {
|
|
15065
15141
|
throw new Error(
|
|
15066
15142
|
`Assembly attachment cycle: ${[...path, component].map((item) => item.name).join(" -> ")}`
|
|
@@ -15073,6 +15149,14 @@ var resolveAssemblyPlacement = (component, path = []) => {
|
|
|
15073
15149
|
) : findParentAssembly(component);
|
|
15074
15150
|
if (!target)
|
|
15075
15151
|
return { position: { x: 0, y: 0, z: 0 }, pcbRotation: 0, layer: "top" };
|
|
15152
|
+
if (resolvePartPlacement && (target.componentName === "AssemblyPart" || target.componentName === "AssemblyPrintedPart"))
|
|
15153
|
+
return resolvePartPlacement(target);
|
|
15154
|
+
if (resolvePartPlacement && isPositionedAssembly(target))
|
|
15155
|
+
return resolveInheritedAssemblyPlacement(
|
|
15156
|
+
target,
|
|
15157
|
+
nextPath,
|
|
15158
|
+
resolvePartPlacement
|
|
15159
|
+
);
|
|
15076
15160
|
if (isPositionedAssembly(target))
|
|
15077
15161
|
return resolveAssemblyPlacement(target, nextPath);
|
|
15078
15162
|
const db2 = component.root.db;
|
|
@@ -15201,6 +15285,20 @@ var resolveAssemblyModelUrl = (modelUrl) => {
|
|
|
15201
15285
|
import { normalizeDegrees as normalizeDegrees4 } from "@tscircuit/math-utils";
|
|
15202
15286
|
import { cadModelBase, point3 } from "@tscircuit/props";
|
|
15203
15287
|
import { rotation } from "circuit-json";
|
|
15288
|
+
import { mat4 as mat42, vec3 as vec32 } from "gl-matrix";
|
|
15289
|
+
|
|
15290
|
+
// lib/components/primitive-components/get-assembly-euler-angles.ts
|
|
15291
|
+
var getAssemblyEulerAngles = (transform) => {
|
|
15292
|
+
const y2 = Math.asin(Math.max(-1, Math.min(1, -transform[2])));
|
|
15293
|
+
const angles = Math.abs(Math.cos(y2)) > 1e-8 ? [
|
|
15294
|
+
Math.atan2(transform[6], transform[10]),
|
|
15295
|
+
y2,
|
|
15296
|
+
Math.atan2(transform[1], transform[0])
|
|
15297
|
+
] : [0, y2, Math.atan2(-transform[4], transform[5])];
|
|
15298
|
+
return angles.map((angle) => angle === 0 ? 0 : angle);
|
|
15299
|
+
};
|
|
15300
|
+
|
|
15301
|
+
// lib/components/primitive-components/render-assembly-cad-model.ts
|
|
15204
15302
|
import {
|
|
15205
15303
|
applyToPoint as applyToPoint29,
|
|
15206
15304
|
compose as compose8,
|
|
@@ -15226,6 +15324,28 @@ var renderAssemblyCadModel = (owner, model, placement) => {
|
|
|
15226
15324
|
z: rotation.parse(authoredRotation.z)
|
|
15227
15325
|
};
|
|
15228
15326
|
const assetUrl = (url) => constructAssetUrl(url, owner.root?.platform?.projectBaseUrl);
|
|
15327
|
+
let mountedPosition;
|
|
15328
|
+
let mountedRotation;
|
|
15329
|
+
if (placement.worldTransform) {
|
|
15330
|
+
const point6 = vec32.transformMat4(
|
|
15331
|
+
[0, 0, 0],
|
|
15332
|
+
[offset.x, offset.y, offset.z + (base.zOffsetFromSurface ?? 0)],
|
|
15333
|
+
placement.worldTransform
|
|
15334
|
+
);
|
|
15335
|
+
mountedPosition = { x: point6[0], y: point6[1], z: point6[2] };
|
|
15336
|
+
const frame = [...placement.worldTransform];
|
|
15337
|
+
mat42.rotateZ(frame, frame, rotationOffset.z * Math.PI / 180);
|
|
15338
|
+
mat42.rotateY(frame, frame, rotationOffset.y * Math.PI / 180);
|
|
15339
|
+
mat42.rotateX(frame, frame, rotationOffset.x * Math.PI / 180);
|
|
15340
|
+
const angles = getAssemblyEulerAngles(frame).map(
|
|
15341
|
+
(angle) => angle * 180 / Math.PI
|
|
15342
|
+
);
|
|
15343
|
+
mountedRotation = {
|
|
15344
|
+
x: angles[0],
|
|
15345
|
+
y: angles[1],
|
|
15346
|
+
z: normalizeDegrees4(angles[2])
|
|
15347
|
+
};
|
|
15348
|
+
}
|
|
15229
15349
|
const urls = typeof model === "string" ? { footprinter_string: model } : {
|
|
15230
15350
|
model_stl_url: "stlUrl" in model ? assetUrl(model.stlUrl) : void 0,
|
|
15231
15351
|
model_obj_url: "objUrl" in model ? assetUrl(model.objUrl) : void 0,
|
|
@@ -15238,13 +15358,13 @@ var renderAssemblyCadModel = (owner, model, placement) => {
|
|
|
15238
15358
|
};
|
|
15239
15359
|
const cad = owner.root.db.cad_component.insert({
|
|
15240
15360
|
...urls,
|
|
15241
|
-
position: {
|
|
15361
|
+
position: mountedPosition ?? {
|
|
15242
15362
|
...xy2,
|
|
15243
15363
|
z: placement.position.z + (bottom ? -1 : 1) * (offset.z + (base.zOffsetFromSurface ?? 0))
|
|
15244
15364
|
},
|
|
15245
15365
|
// Same CAD Euler convention as NormalComponent.doInitialCadModelRender:
|
|
15246
15366
|
// bottom flips Y and negates the board-plane Z angle.
|
|
15247
|
-
rotation: {
|
|
15367
|
+
rotation: mountedRotation ?? {
|
|
15248
15368
|
x: rotationOffset.x,
|
|
15249
15369
|
y: (bottom ? 180 : 0) + rotationOffset.y,
|
|
15250
15370
|
z: normalizeDegrees4(
|
|
@@ -15253,6 +15373,7 @@ var renderAssemblyCadModel = (owner, model, placement) => {
|
|
|
15253
15373
|
},
|
|
15254
15374
|
layer: placement.layer,
|
|
15255
15375
|
source_component_id: owner.source_component_id,
|
|
15376
|
+
color: owner.componentName === "AssemblyPrintedPart" ? owner._parsedProps.color : void 0,
|
|
15256
15377
|
subcircuit_id: placement.subcircuit_id,
|
|
15257
15378
|
model_origin_position: base.modelOriginPosition ?? { x: 0, y: 0, z: 0 },
|
|
15258
15379
|
model_unit_to_mm_scale_factor: base.modelUnitToMmScale ?? 1,
|
|
@@ -102101,9 +102222,36 @@ var getAlignedSharedEndpointRailPath = ({
|
|
|
102101
102222
|
if (donorPath.length < 3 || branchPath.length < 4) return null;
|
|
102102
102223
|
const donorDepartureAxis = getSegmentAxis4(donorPath[0], donorPath[1]);
|
|
102103
102224
|
const branchDepartureAxis = getSegmentAxis4(branchPath[0], branchPath[1]);
|
|
102104
|
-
if (!donorDepartureAxis ||
|
|
102225
|
+
if (!donorDepartureAxis || !branchDepartureAxis) {
|
|
102105
102226
|
return null;
|
|
102106
102227
|
}
|
|
102228
|
+
if (donorDepartureAxis !== branchDepartureAxis) {
|
|
102229
|
+
if (!nearlyEqual(donorPath[0].x, branchPath[0].x) || !nearlyEqual(donorPath[0].y, branchPath[0].y)) {
|
|
102230
|
+
return null;
|
|
102231
|
+
}
|
|
102232
|
+
const branchRailAxis2 = getSegmentAxis4(branchPath[1], branchPath[2]);
|
|
102233
|
+
const donorRailAxis2 = getSegmentAxis4(donorPath[1], donorPath[2]);
|
|
102234
|
+
if (branchRailAxis2 !== donorDepartureAxis || donorRailAxis2 !== branchDepartureAxis || getPinFacingAxis(sharedPin) !== branchDepartureAxis || !isCoordinateOnPinFacingSide({
|
|
102235
|
+
coordinate: branchPath[1][branchDepartureAxis],
|
|
102236
|
+
axis: branchDepartureAxis,
|
|
102237
|
+
pin: sharedPin
|
|
102238
|
+
})) {
|
|
102239
|
+
return null;
|
|
102240
|
+
}
|
|
102241
|
+
const donorDirection = donorPath[1][donorDepartureAxis] - donorPath[0][donorDepartureAxis];
|
|
102242
|
+
const branchDirection = branchPath[2][branchRailAxis2] - branchPath[1][branchRailAxis2];
|
|
102243
|
+
if (Math.sign(donorDirection) === Math.sign(branchDirection)) return null;
|
|
102244
|
+
const railCoordinateAxis2 = branchRailAxis2 === "x" ? "y" : "x";
|
|
102245
|
+
const candidateFromShared2 = simplifyPath([
|
|
102246
|
+
branchPath[0],
|
|
102247
|
+
{
|
|
102248
|
+
...branchPath[2],
|
|
102249
|
+
[railCoordinateAxis2]: donorPath[0][railCoordinateAxis2]
|
|
102250
|
+
},
|
|
102251
|
+
...branchPath.slice(3)
|
|
102252
|
+
]);
|
|
102253
|
+
return branchTrace.pins[0].pinId === sharedPin.pinId ? candidateFromShared2 : candidateFromShared2.reverse();
|
|
102254
|
+
}
|
|
102107
102255
|
const donorDeparture = donorPath[1][donorDepartureAxis] - donorPath[0][donorDepartureAxis];
|
|
102108
102256
|
const branchDeparture = branchPath[1][branchDepartureAxis] - branchPath[0][branchDepartureAxis];
|
|
102109
102257
|
if (Math.sign(donorDeparture) !== Math.sign(branchDeparture)) return null;
|
|
@@ -102425,6 +102573,48 @@ var getAlignedPerpendicularEndpointBusPath = ({
|
|
|
102425
102573
|
]);
|
|
102426
102574
|
return branchStartsAtSharedPin ? candidate : candidate.reverse();
|
|
102427
102575
|
};
|
|
102576
|
+
var traceCollidesWithObstacles = ({
|
|
102577
|
+
trace,
|
|
102578
|
+
obstacles
|
|
102579
|
+
}) => findFirstCollision(trace.tracePath, obstacles, {
|
|
102580
|
+
excludeRectsForSegment: (segmentIndex) => new Set(
|
|
102581
|
+
obstacles.filter(
|
|
102582
|
+
(obstacle) => obstacle.kind === "chip" && trace.pins.some(
|
|
102583
|
+
(pin) => obstacle.chipId === pin.chipId && [
|
|
102584
|
+
trace.tracePath[segmentIndex],
|
|
102585
|
+
trace.tracePath[segmentIndex + 1]
|
|
102586
|
+
].some(
|
|
102587
|
+
(point6) => nearlyEqual(point6.x, pin.x) && nearlyEqual(point6.y, pin.y)
|
|
102588
|
+
)
|
|
102589
|
+
) && segmentOverlapsRectBoundary(
|
|
102590
|
+
trace.tracePath[segmentIndex],
|
|
102591
|
+
trace.tracePath[segmentIndex + 1],
|
|
102592
|
+
obstacle
|
|
102593
|
+
)
|
|
102594
|
+
)
|
|
102595
|
+
)
|
|
102596
|
+
}) !== null;
|
|
102597
|
+
var getPathLengthInsideRect = ({
|
|
102598
|
+
path,
|
|
102599
|
+
rect
|
|
102600
|
+
}) => path.slice(1).reduce((length8, point6, index2) => {
|
|
102601
|
+
const previous = path[index2];
|
|
102602
|
+
if (nearlyEqual(previous.x, point6.x)) {
|
|
102603
|
+
if (previous.x < rect.minX || previous.x > rect.maxX) return length8;
|
|
102604
|
+
return length8 + Math.max(
|
|
102605
|
+
0,
|
|
102606
|
+
Math.min(Math.max(previous.y, point6.y), rect.maxY) - Math.max(Math.min(previous.y, point6.y), rect.minY)
|
|
102607
|
+
);
|
|
102608
|
+
}
|
|
102609
|
+
if (nearlyEqual(previous.y, point6.y)) {
|
|
102610
|
+
if (previous.y < rect.minY || previous.y > rect.maxY) return length8;
|
|
102611
|
+
return length8 + Math.max(
|
|
102612
|
+
0,
|
|
102613
|
+
Math.min(Math.max(previous.x, point6.x), rect.maxX) - Math.max(Math.min(previous.x, point6.x), rect.minX)
|
|
102614
|
+
);
|
|
102615
|
+
}
|
|
102616
|
+
return length8;
|
|
102617
|
+
}, 0);
|
|
102428
102618
|
var candidateIsClear = ({
|
|
102429
102619
|
candidateTrace,
|
|
102430
102620
|
originalTrace,
|
|
@@ -102436,30 +102626,24 @@ var candidateIsClear = ({
|
|
|
102436
102626
|
preserveExistingObstacleContact = false
|
|
102437
102627
|
}) => {
|
|
102438
102628
|
const obstacles = getObstacleRects(inputProblem);
|
|
102439
|
-
if (!preserveExistingObstacleContact &&
|
|
102629
|
+
if (!preserveExistingObstacleContact && traceCollidesWithObstacles({ trace: candidateTrace, obstacles }))
|
|
102440
102630
|
return false;
|
|
102441
|
-
const pathLengthInsideRect = (path, rect) => path.slice(1).reduce((length8, point6, index2) => {
|
|
102442
|
-
const previous = path[index2];
|
|
102443
|
-
if (nearlyEqual(previous.x, point6.x)) {
|
|
102444
|
-
if (previous.x < rect.minX || previous.x > rect.maxX) return length8;
|
|
102445
|
-
return length8 + Math.max(
|
|
102446
|
-
0,
|
|
102447
|
-
Math.min(Math.max(previous.y, point6.y), rect.maxY) - Math.max(Math.min(previous.y, point6.y), rect.minY)
|
|
102448
|
-
);
|
|
102449
|
-
}
|
|
102450
|
-
if (nearlyEqual(previous.y, point6.y)) {
|
|
102451
|
-
if (previous.y < rect.minY || previous.y > rect.maxY) return length8;
|
|
102452
|
-
return length8 + Math.max(
|
|
102453
|
-
0,
|
|
102454
|
-
Math.min(Math.max(previous.x, point6.x), rect.maxX) - Math.max(Math.min(previous.x, point6.x), rect.minX)
|
|
102455
|
-
);
|
|
102456
|
-
}
|
|
102457
|
-
return length8;
|
|
102458
|
-
}, 0);
|
|
102459
102631
|
for (const obstacle of preserveExistingObstacleContact ? obstacles : []) {
|
|
102460
|
-
if (!
|
|
102632
|
+
if (!traceCollidesWithObstacles({
|
|
102633
|
+
trace: candidateTrace,
|
|
102634
|
+
obstacles: [obstacle]
|
|
102635
|
+
}))
|
|
102461
102636
|
continue;
|
|
102462
|
-
if (!
|
|
102637
|
+
if (!traceCollidesWithObstacles({
|
|
102638
|
+
trace: originalTrace,
|
|
102639
|
+
obstacles: [obstacle]
|
|
102640
|
+
}) || getPathLengthInsideRect({
|
|
102641
|
+
path: candidateTrace.tracePath,
|
|
102642
|
+
rect: obstacle
|
|
102643
|
+
}) > getPathLengthInsideRect({
|
|
102644
|
+
path: originalTrace.tracePath,
|
|
102645
|
+
rect: obstacle
|
|
102646
|
+
}) + 1e-6)
|
|
102463
102647
|
return false;
|
|
102464
102648
|
}
|
|
102465
102649
|
const otherNetTraces = traces.filter(
|
|
@@ -118103,7 +118287,7 @@ function Group_getRoutingPhasePlans(group) {
|
|
|
118103
118287
|
var package_default = {
|
|
118104
118288
|
name: "@tscircuit/core",
|
|
118105
118289
|
type: "module",
|
|
118106
|
-
version: "0.0.
|
|
118290
|
+
version: "0.0.2116",
|
|
118107
118291
|
types: "dist/index.d.ts",
|
|
118108
118292
|
main: "dist/index.js",
|
|
118109
118293
|
module: "dist/index.js",
|
|
@@ -118162,9 +118346,9 @@ var package_default = {
|
|
|
118162
118346
|
"@tscircuit/miniflex": "^0.0.4",
|
|
118163
118347
|
"@tscircuit/modelprinter": "^0.0.18",
|
|
118164
118348
|
"@tscircuit/ngspice-spice-engine": "^0.0.20",
|
|
118165
|
-
"@tscircuit/props": "^0.0.
|
|
118349
|
+
"@tscircuit/props": "^0.0.697",
|
|
118166
118350
|
"@tscircuit/schematic-match-adapt": "^0.0.18",
|
|
118167
|
-
"@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.
|
|
118351
|
+
"@tscircuit/schematic-trace-solver": "https://jscdn.tscircuit.com/@tscircuit/schematic-trace-solver/0.0.229.tgz",
|
|
118168
118352
|
"@tscircuit/solver-utils": "^0.0.16",
|
|
118169
118353
|
"@tscircuit/soup-util": "^0.0.41",
|
|
118170
118354
|
"@tscircuit/via-stitch-solver": "github:tscircuit/via-stitch-solver#64f2ac7781b795bdc0d74ba411988e60767fa653",
|
|
@@ -118178,10 +118362,10 @@ var package_default = {
|
|
|
118178
118362
|
"bun-match-svg": "0.0.12",
|
|
118179
118363
|
"calculate-elbow": "^0.0.12",
|
|
118180
118364
|
"chokidar-cli": "^3.0.0",
|
|
118181
|
-
"circuit-json": "^0.0.
|
|
118365
|
+
"circuit-json": "^0.0.525",
|
|
118182
118366
|
"circuit-json-to-bpc": "^0.0.13",
|
|
118183
118367
|
"circuit-json-to-connectivity-map": "^0.0.33",
|
|
118184
|
-
"circuit-json-to-gltf": "^0.0.
|
|
118368
|
+
"circuit-json-to-gltf": "^0.0.151",
|
|
118185
118369
|
"circuit-json-to-spice": "^0.0.45",
|
|
118186
118370
|
"circuit-to-svg": "^0.0.445",
|
|
118187
118371
|
concurrently: "^9.1.2",
|
|
@@ -118246,8 +118430,8 @@ var package_default = {
|
|
|
118246
118430
|
},
|
|
118247
118431
|
overrides: {
|
|
118248
118432
|
"@tscircuit/circuit-json-util": "^0.0.119",
|
|
118249
|
-
"@tscircuit/props": "^0.0.
|
|
118250
|
-
"circuit-json": "^0.0.
|
|
118433
|
+
"@tscircuit/props": "^0.0.697",
|
|
118434
|
+
"circuit-json": "^0.0.525",
|
|
118251
118435
|
"@tscircuit/cableprinter": "^0.0.6"
|
|
118252
118436
|
}
|
|
118253
118437
|
};
|
|
@@ -130360,7 +130544,7 @@ import { assemblyMotorProps } from "@tscircuit/props";
|
|
|
130360
130544
|
|
|
130361
130545
|
// lib/components/primitive-components/resolve-assembly-motor-rotation.ts
|
|
130362
130546
|
import { normalizeDegrees as normalizeDegrees10 } from "@tscircuit/math-utils";
|
|
130363
|
-
import { mat4 as
|
|
130547
|
+
import { mat4 as mat43, vec3 as vec33 } from "gl-matrix";
|
|
130364
130548
|
|
|
130365
130549
|
// lib/components/primitive-components/resolve-board-mount-rotation-anchor.ts
|
|
130366
130550
|
var resolveBoardMountRotationAnchor = (board) => {
|
|
@@ -130421,14 +130605,14 @@ var resolveAssemblyMotorRotation = (motor, placement) => {
|
|
|
130421
130605
|
if (!board || !input) return alignment;
|
|
130422
130606
|
const bottom = placement.layer === "bottom";
|
|
130423
130607
|
const sign = bottom ? -1 : 1;
|
|
130424
|
-
const orientation2 =
|
|
130425
|
-
|
|
130426
|
-
|
|
130608
|
+
const orientation2 = mat43.create();
|
|
130609
|
+
mat43.rotateX(orientation2, orientation2, radians(alignment.x));
|
|
130610
|
+
mat43.rotateY(
|
|
130427
130611
|
orientation2,
|
|
130428
130612
|
orientation2,
|
|
130429
130613
|
radians(alignment.y + (bottom ? 180 : 0))
|
|
130430
130614
|
);
|
|
130431
|
-
|
|
130615
|
+
mat43.rotateZ(orientation2, orientation2, radians(sign * placement.pcbRotation));
|
|
130432
130616
|
const expression = input.startsWith("calc(") ? input.match(
|
|
130433
130617
|
/^calc\(\s*(.*?)\s*(?:([+-])\s*((?:\d+(?:\.\d*)?|\.\d+))\s*(degcw|degccw))?\s*\)$/
|
|
130434
130618
|
) : [input, input];
|
|
@@ -130454,23 +130638,23 @@ var resolveAssemblyMotorRotation = (motor, placement) => {
|
|
|
130454
130638
|
const clockwiseAngle = radians(
|
|
130455
130639
|
(expression[2] === "-" ? -1 : 1) * Number(expression[3] ?? 0) * (expression[4] === "degccw" ? -1 : 1)
|
|
130456
130640
|
);
|
|
130457
|
-
const anchor =
|
|
130458
|
-
|
|
130641
|
+
const anchor = vec33.normalize(
|
|
130642
|
+
vec33.create(),
|
|
130459
130643
|
resolveBoardMountRotationAnchor(board)
|
|
130460
130644
|
);
|
|
130461
|
-
const shaft =
|
|
130462
|
-
const turn =
|
|
130463
|
-
const target =
|
|
130464
|
-
const motorDirection =
|
|
130465
|
-
|
|
130645
|
+
const shaft = vec33.transformMat4(vec33.create(), [0, 0, 1], orientation2);
|
|
130646
|
+
const turn = mat43.fromRotation(mat43.create(), -clockwiseAngle, shaft);
|
|
130647
|
+
const target = vec33.transformMat4(vec33.create(), anchor, turn);
|
|
130648
|
+
const motorDirection = vec33.transformMat4(
|
|
130649
|
+
vec33.create(),
|
|
130466
130650
|
[direction.direction.x, direction.direction.y, direction.direction.z],
|
|
130467
130651
|
orientation2
|
|
130468
130652
|
);
|
|
130469
130653
|
const spin = Math.atan2(
|
|
130470
|
-
|
|
130471
|
-
|
|
130654
|
+
vec33.dot(shaft, vec33.cross(vec33.create(), motorDirection, target)),
|
|
130655
|
+
vec33.dot(motorDirection, target)
|
|
130472
130656
|
);
|
|
130473
|
-
|
|
130657
|
+
mat43.rotateZ(orientation2, orientation2, spin);
|
|
130474
130658
|
const pitch = Math.asin(Math.max(-1, Math.min(1, orientation2[8])));
|
|
130475
130659
|
const nonsingular = Math.abs(orientation2[8]) < 0.999999;
|
|
130476
130660
|
const roll = nonsingular ? Math.atan2(-orientation2[9], orientation2[10]) : Math.atan2(orientation2[6], orientation2[5]);
|
|
@@ -130684,6 +130868,49 @@ var AssemblySubassembly = class extends PrimitiveComponent2 {
|
|
|
130684
130868
|
// lib/components/primitive-components/AssemblyPart.ts
|
|
130685
130869
|
import { assemblyPartProps } from "@tscircuit/props";
|
|
130686
130870
|
import { isValidElement as isValidElement5 } from "react";
|
|
130871
|
+
|
|
130872
|
+
// lib/components/primitive-components/render-part-reference-surfaces.ts
|
|
130873
|
+
import { mat3, vec3 as vec34 } from "gl-matrix";
|
|
130874
|
+
var renderPartReferenceSurfaces = (part) => {
|
|
130875
|
+
const surfaces = getPartReferenceSurfaces(part);
|
|
130876
|
+
if (!surfaces.length) return;
|
|
130877
|
+
const { transforms, subcircuitId } = resolvePrintedPartMounts(part);
|
|
130878
|
+
const world = transforms.get(part);
|
|
130879
|
+
const rotation5 = mat3.fromMat4(mat3.create(), world);
|
|
130880
|
+
const toPoint = (vector3) => ({
|
|
130881
|
+
x: vector3[0],
|
|
130882
|
+
y: vector3[1],
|
|
130883
|
+
z: vector3[2]
|
|
130884
|
+
});
|
|
130885
|
+
for (const surface of surfaces) {
|
|
130886
|
+
const child = part.children.find(
|
|
130887
|
+
(child2) => child2.componentName === "AssemblyReferenceSurface" && child2.name === surface.name
|
|
130888
|
+
);
|
|
130889
|
+
part.root.db.cad_reference_surface.insert({
|
|
130890
|
+
source_component_id: part.source_component_id,
|
|
130891
|
+
name: surface.name,
|
|
130892
|
+
shape: "rect",
|
|
130893
|
+
center: toPoint(vec34.transformMat4(vec34.create(), surface.origin, world)),
|
|
130894
|
+
normal: toPoint(
|
|
130895
|
+
vec34.normalize(
|
|
130896
|
+
vec34.create(),
|
|
130897
|
+
vec34.transformMat3(vec34.create(), surface.normal, rotation5)
|
|
130898
|
+
)
|
|
130899
|
+
),
|
|
130900
|
+
x_axis: toPoint(
|
|
130901
|
+
vec34.normalize(
|
|
130902
|
+
vec34.create(),
|
|
130903
|
+
vec34.transformMat3(vec34.create(), surface.xAxis, rotation5)
|
|
130904
|
+
)
|
|
130905
|
+
),
|
|
130906
|
+
width: child?._parsedProps.width,
|
|
130907
|
+
height: child?._parsedProps.height,
|
|
130908
|
+
subcircuit_id: subcircuitId
|
|
130909
|
+
});
|
|
130910
|
+
}
|
|
130911
|
+
};
|
|
130912
|
+
|
|
130913
|
+
// lib/components/primitive-components/AssemblyPart.ts
|
|
130687
130914
|
var AssemblyPart = class extends PrimitiveComponent2 {
|
|
130688
130915
|
isAssemblyDeviceContainer = true;
|
|
130689
130916
|
get config() {
|
|
@@ -130697,6 +130924,7 @@ var AssemblyPart = class extends PrimitiveComponent2 {
|
|
|
130697
130924
|
this.add(createInstanceFromReactElement(this.props.cadModel));
|
|
130698
130925
|
}
|
|
130699
130926
|
doInitialSourceRender() {
|
|
130927
|
+
getPartReferenceSurfaces(this);
|
|
130700
130928
|
this.source_component_id = this.root.db.source_component.insert({
|
|
130701
130929
|
// Circuit JSON currently represents generic assembly geometry as subassembly.
|
|
130702
130930
|
ftype: "subassembly",
|
|
@@ -130706,6 +130934,7 @@ var AssemblyPart = class extends PrimitiveComponent2 {
|
|
|
130706
130934
|
}
|
|
130707
130935
|
doInitialCadModelRender() {
|
|
130708
130936
|
if (!this.root || this.root.pcbDisabled || !this.source_component_id) return;
|
|
130937
|
+
renderPartReferenceSurfaces(this);
|
|
130709
130938
|
const model = resolveAssemblyModel(this._parsedProps) ?? this._parsedProps.cadModel;
|
|
130710
130939
|
if (model && !(typeof model === "object" && "type" in model)) {
|
|
130711
130940
|
this.cad_component_id = renderAssemblyCadModel(
|
|
@@ -130717,6 +130946,46 @@ var AssemblyPart = class extends PrimitiveComponent2 {
|
|
|
130717
130946
|
}
|
|
130718
130947
|
};
|
|
130719
130948
|
|
|
130949
|
+
// lib/components/primitive-components/AssemblyReferenceSurface.ts
|
|
130950
|
+
import { assemblyReferenceSurfaceProps } from "@tscircuit/props";
|
|
130951
|
+
var AssemblyReferenceSurface = class extends PrimitiveComponent2 {
|
|
130952
|
+
get config() {
|
|
130953
|
+
return {
|
|
130954
|
+
componentName: "AssemblyReferenceSurface",
|
|
130955
|
+
zodProps: assemblyReferenceSurfaceProps
|
|
130956
|
+
};
|
|
130957
|
+
}
|
|
130958
|
+
doInitialSourceRender() {
|
|
130959
|
+
if (this.parent?.componentName !== "AssemblyPart" && this.parent?.componentName !== "AssemblyPrintedPart")
|
|
130960
|
+
throw new Error(
|
|
130961
|
+
`Reference surface "${this.name}" must be a child of assembly.part or assembly.printedpart`
|
|
130962
|
+
);
|
|
130963
|
+
}
|
|
130964
|
+
/** Part-local frame, right-handed XYZ in mm: origin is a point, normal and
|
|
130965
|
+
* xAxis are unit directions. XY faces +Z, XZ faces +Y, YZ faces +X.
|
|
130966
|
+
* XZ's second tangent is -Z so its tangent basis remains right-handed.
|
|
130967
|
+
*/
|
|
130968
|
+
get referenceFrame() {
|
|
130969
|
+
const {
|
|
130970
|
+
name,
|
|
130971
|
+
plane,
|
|
130972
|
+
normalDirection,
|
|
130973
|
+
centerXOffset,
|
|
130974
|
+
centerYOffset,
|
|
130975
|
+
centerZOffset
|
|
130976
|
+
} = this._parsedProps;
|
|
130977
|
+
const sign = normalDirection.endsWith("-") ? -1 : 1;
|
|
130978
|
+
const normal = plane === "xy" ? [0, 0, sign] : plane === "xz" ? [0, sign, 0] : [sign, 0, 0];
|
|
130979
|
+
const xAxis = plane === "yz" ? [0, 1, 0] : [1, 0, 0];
|
|
130980
|
+
return {
|
|
130981
|
+
name,
|
|
130982
|
+
origin: [centerXOffset, centerYOffset, centerZOffset],
|
|
130983
|
+
normal,
|
|
130984
|
+
xAxis
|
|
130985
|
+
};
|
|
130986
|
+
}
|
|
130987
|
+
};
|
|
130988
|
+
|
|
130720
130989
|
// lib/components/primitive-components/EnclosureCutoutAperture/EnclosureCutoutAperture.ts
|
|
130721
130990
|
import { enclosureCutoutApertureProps } from "@tscircuit/props";
|
|
130722
130991
|
|
|
@@ -133266,7 +133535,7 @@ import { isValidElement as isValidElement6 } from "react";
|
|
|
133266
133535
|
import { assemblyPrintedPartProps } from "@tscircuit/props";
|
|
133267
133536
|
import { renderToJscadPlan } from "jscad-fiber/headless";
|
|
133268
133537
|
import {
|
|
133269
|
-
resolveReferencePlanes
|
|
133538
|
+
resolveReferencePlanes as resolveReferencePlanes2
|
|
133270
133539
|
} from "jscad-planner";
|
|
133271
133540
|
var AssemblyPrintedPart = class extends PrimitiveComponent2 {
|
|
133272
133541
|
isAssemblyDeviceContainer = true;
|
|
@@ -133284,7 +133553,7 @@ var AssemblyPrintedPart = class extends PrimitiveComponent2 {
|
|
|
133284
133553
|
get printedPartPlan() {
|
|
133285
133554
|
if (!this._parsedProps.jscad) return void 0;
|
|
133286
133555
|
if (!this.compiledJscad || this.compiledJscadInput !== this._parsedProps.jscad) {
|
|
133287
|
-
const { geometry, referencePlanes } =
|
|
133556
|
+
const { geometry, referencePlanes } = resolveReferencePlanes2(
|
|
133288
133557
|
renderToJscadPlan(this._parsedProps.jscad)
|
|
133289
133558
|
);
|
|
133290
133559
|
if (!geometry)
|
|
@@ -133302,20 +133571,24 @@ var AssemblyPrintedPart = class extends PrimitiveComponent2 {
|
|
|
133302
133571
|
}
|
|
133303
133572
|
doInitialSourceRender() {
|
|
133304
133573
|
this.printedPartPlan;
|
|
133574
|
+
getPartReferenceSurfaces(this);
|
|
133305
133575
|
this.source_component_id = this.root.db.source_component.insert({
|
|
133306
133576
|
ftype: "printedpart",
|
|
133307
|
-
name: this.name
|
|
133577
|
+
name: this.name,
|
|
133578
|
+
color: this._parsedProps.color,
|
|
133579
|
+
material: this._parsedProps.material
|
|
133308
133580
|
}).source_component_id;
|
|
133309
133581
|
}
|
|
133310
133582
|
doInitialCadModelRender() {
|
|
133311
133583
|
if (!this.root || this.root.pcbDisabled || !this.source_component_id) return;
|
|
133584
|
+
renderPartReferenceSurfaces(this);
|
|
133312
133585
|
const plan = this.printedPartPlan;
|
|
133313
133586
|
if (!plan) {
|
|
133314
133587
|
let model = resolveAssemblyModel(this._parsedProps) ?? this._parsedProps.cadModel;
|
|
133315
133588
|
const placement = resolveAssemblyPlacement(this);
|
|
133316
133589
|
if (!model || typeof model === "object" && "type" in model) return;
|
|
133317
133590
|
if (typeof model === "object" && "jscad" in model) {
|
|
133318
|
-
const { geometry } =
|
|
133591
|
+
const { geometry } = resolveReferencePlanes2(
|
|
133319
133592
|
model.jscad
|
|
133320
133593
|
);
|
|
133321
133594
|
if (!geometry)
|
|
@@ -133329,12 +133602,7 @@ var AssemblyPrintedPart = class extends PrimitiveComponent2 {
|
|
|
133329
133602
|
}
|
|
133330
133603
|
const { transforms, subcircuitId } = resolvePrintedPartMounts(this);
|
|
133331
133604
|
const transform = transforms.get(this);
|
|
133332
|
-
const
|
|
133333
|
-
const angles = Math.abs(Math.cos(y2)) > 1e-8 ? [
|
|
133334
|
-
Math.atan2(transform[6], transform[10]),
|
|
133335
|
-
y2,
|
|
133336
|
-
Math.atan2(transform[1], transform[0])
|
|
133337
|
-
] : [0, y2, Math.atan2(-transform[4], transform[5])];
|
|
133605
|
+
const angles = getAssemblyEulerAngles(transform);
|
|
133338
133606
|
this.cad_component_id = renderAssemblyCadModel(
|
|
133339
133607
|
this,
|
|
133340
133608
|
{
|
|
@@ -133843,15 +134111,15 @@ function parseCableString(cableString) {
|
|
|
133843
134111
|
}
|
|
133844
134112
|
|
|
133845
134113
|
// lib/components/primitive-components/resolve-assembly-cable.ts
|
|
133846
|
-
import { vec3 as
|
|
134114
|
+
import { vec3 as vec38 } from "gl-matrix";
|
|
133847
134115
|
|
|
133848
134116
|
// lib/components/primitive-components/resolve-assembly-cable-endpoint.ts
|
|
133849
134117
|
import { getJstMotorConnector } from "@tscircuit/modelprinter";
|
|
133850
|
-
import { mat4 as
|
|
134118
|
+
import { mat4 as mat44, vec3 as vec36 } from "gl-matrix";
|
|
133851
134119
|
import { selectAll as selectAll3 } from "css-select";
|
|
133852
134120
|
|
|
133853
134121
|
// lib/components/primitive-components/resolve-assembly-cable-pin1-position.ts
|
|
133854
|
-
import { vec3 as
|
|
134122
|
+
import { vec3 as vec35 } from "gl-matrix";
|
|
133855
134123
|
function resolveAssemblyCablePin1Position(cable, connector, matingCenter, outward) {
|
|
133856
134124
|
const db2 = cable.root.db;
|
|
133857
134125
|
const pins = db2.source_port.list().flatMap((sourcePort) => {
|
|
@@ -133876,10 +134144,10 @@ function resolveAssemblyCablePin1Position(cable, connector, matingCenter, outwar
|
|
|
133876
134144
|
}),
|
|
133877
134145
|
{ x: 0, y: 0 }
|
|
133878
134146
|
);
|
|
133879
|
-
const offset =
|
|
133880
|
-
const axis =
|
|
133881
|
-
|
|
133882
|
-
if (
|
|
134147
|
+
const offset = vec35.fromValues(pin1.x - center.x, pin1.y - center.y, 0);
|
|
134148
|
+
const axis = vec35.normalize(vec35.create(), [outward.x, outward.y, outward.z]);
|
|
134149
|
+
vec35.scaleAndAdd(offset, offset, axis, -vec35.dot(offset, axis));
|
|
134150
|
+
if (vec35.length(offset) < 1e-6) return void 0;
|
|
133883
134151
|
return {
|
|
133884
134152
|
x: matingCenter.x + offset[0],
|
|
133885
134153
|
y: matingCenter.y + offset[1],
|
|
@@ -133908,33 +134176,33 @@ function resolveAssemblyCableEndpoint(cable, selector, cableConnector) {
|
|
|
133908
134176
|
const faceMount = resolveMotorFaceMount(motor);
|
|
133909
134177
|
const placement = faceMount ? { position: faceMount.position, pcbRotation: 0, layer: "top" } : resolveAssemblyMotorPlacement(motor);
|
|
133910
134178
|
const offset = faceMount?.rotation ?? resolveAssemblyMotorRotation(motor, placement);
|
|
133911
|
-
const orientation2 =
|
|
134179
|
+
const orientation2 = mat44.create();
|
|
133912
134180
|
const bottom = placement.layer === "bottom";
|
|
133913
|
-
|
|
133914
|
-
|
|
134181
|
+
mat44.rotateX(orientation2, orientation2, offset.x * Math.PI / 180);
|
|
134182
|
+
mat44.rotateY(
|
|
133915
134183
|
orientation2,
|
|
133916
134184
|
orientation2,
|
|
133917
134185
|
(offset.y + (bottom ? 180 : 0)) * Math.PI / 180
|
|
133918
134186
|
);
|
|
133919
|
-
|
|
134187
|
+
mat44.rotateZ(
|
|
133920
134188
|
orientation2,
|
|
133921
134189
|
orientation2,
|
|
133922
134190
|
(bottom ? -1 : 1) * (placement.pcbRotation + offset.z) * Math.PI / 180
|
|
133923
134191
|
);
|
|
133924
134192
|
const reference = motor.motorReferencePoints.wireside;
|
|
133925
|
-
const direction2 =
|
|
133926
|
-
|
|
134193
|
+
const direction2 = vec36.transformMat4(
|
|
134194
|
+
vec36.create(),
|
|
133927
134195
|
[reference.direction.x, reference.direction.y, reference.direction.z],
|
|
133928
134196
|
orientation2
|
|
133929
134197
|
);
|
|
133930
|
-
const point6 =
|
|
133931
|
-
|
|
134198
|
+
const point6 = vec36.transformMat4(
|
|
134199
|
+
vec36.create(),
|
|
133932
134200
|
[reference.position.x, reference.position.y, reference.position.z],
|
|
133933
134201
|
orientation2
|
|
133934
134202
|
);
|
|
133935
134203
|
const halfPinSpan = (motorConnector.pinCount - 1) * motorConnector.pitch / 2;
|
|
133936
|
-
const pin1Offset =
|
|
133937
|
-
|
|
134204
|
+
const pin1Offset = vec36.transformMat4(
|
|
134205
|
+
vec36.create(),
|
|
133938
134206
|
[
|
|
133939
134207
|
reference.direction.y * halfPinSpan,
|
|
133940
134208
|
-reference.direction.x * halfPinSpan,
|
|
@@ -133983,12 +134251,12 @@ function resolveAssemblyCableEndpoint(cable, selector, cableConnector) {
|
|
|
133983
134251
|
const board = connector._getBoard();
|
|
133984
134252
|
const layer = pcb.layer === "bottom" ? "bottom" : "top";
|
|
133985
134253
|
const inferredCenter = pcb.cable_insertion_center ?? pcb.center;
|
|
133986
|
-
const inferredDirection =
|
|
134254
|
+
const inferredDirection = vec36.normalize(vec36.create(), [
|
|
133987
134255
|
inferredCenter.x - pcb.center.x,
|
|
133988
134256
|
inferredCenter.y - pcb.center.y,
|
|
133989
134257
|
0
|
|
133990
134258
|
]);
|
|
133991
|
-
const direction = connector._getPcbComponentInsertionAxisDirection(layer, pcb.rotation) ?? (props.standard === "usb_c" &&
|
|
134259
|
+
const direction = connector._getPcbComponentInsertionAxisDirection(layer, pcb.rotation) ?? (props.standard === "usb_c" && vec36.length(inferredDirection) > 0 ? { x: inferredDirection[0], y: inferredDirection[1], z: 0 } : { x: 0, y: 0, z: layer === "bottom" ? -1 : 1 });
|
|
133992
134260
|
const center = Math.abs(direction.z) > 0.5 ? pcb.center : inferredCenter;
|
|
133993
134261
|
const sign = layer === "bottom" ? -1 : 1;
|
|
133994
134262
|
const height = !props.standard && cableConnector ? Math.abs(direction.z) > 0.5 ? cableConnector.bodyDepth : cableConnector.bodyHeight / 2 : Math.abs(direction.z) > 0.5 ? props.standard === "jst_ph" ? 6 : props.standard === "jst_sh" ? 4.25 : 1.5 : props.standard === "usb_c" ? 1.5 : props.standard === "jst_sh" ? 1.4 : 2.25;
|
|
@@ -134012,7 +134280,7 @@ function resolveAssemblyCableEndpoint(cable, selector, cableConnector) {
|
|
|
134012
134280
|
}
|
|
134013
134281
|
|
|
134014
134282
|
// lib/components/primitive-components/infer-assembly-cable-path.ts
|
|
134015
|
-
import { vec3 as
|
|
134283
|
+
import { vec3 as vec37 } from "gl-matrix";
|
|
134016
134284
|
function inferAssemblyCablePath({
|
|
134017
134285
|
from,
|
|
134018
134286
|
to,
|
|
@@ -134022,26 +134290,26 @@ function inferAssemblyCablePath({
|
|
|
134022
134290
|
const distance27 = Math.hypot(to.x - from.x, to.y - from.y, to.z - from.z);
|
|
134023
134291
|
if (distance27 < 1e-6)
|
|
134024
134292
|
throw new Error("Cable wire exits must be at different positions");
|
|
134025
|
-
const chord =
|
|
134026
|
-
const routeNormal =
|
|
134293
|
+
const chord = vec37.fromValues(to.x - from.x, to.y - from.y, to.z - from.z);
|
|
134294
|
+
const routeNormal = vec37.cross(vec37.create(), chord, [
|
|
134027
134295
|
fromDirection.x,
|
|
134028
134296
|
fromDirection.y,
|
|
134029
134297
|
fromDirection.z
|
|
134030
134298
|
]);
|
|
134031
|
-
if (
|
|
134032
|
-
|
|
134299
|
+
if (vec37.length(routeNormal) < 1e-6) {
|
|
134300
|
+
vec37.cross(
|
|
134033
134301
|
routeNormal,
|
|
134034
134302
|
chord,
|
|
134035
134303
|
Math.abs(chord[2]) / distance27 > 0.95 ? [0, 1, 0] : [0, 0, 1]
|
|
134036
134304
|
);
|
|
134037
134305
|
}
|
|
134038
|
-
const archDirection =
|
|
134039
|
-
|
|
134040
|
-
|
|
134306
|
+
const archDirection = vec37.normalize(
|
|
134307
|
+
vec37.create(),
|
|
134308
|
+
vec37.cross(vec37.create(), routeNormal, chord)
|
|
134041
134309
|
);
|
|
134042
134310
|
const archSide = from.z < 0 && to.z < 0 ? -1 : 1;
|
|
134043
134311
|
if (archDirection[2] * archSide < 0)
|
|
134044
|
-
|
|
134312
|
+
vec37.scale(archDirection, archDirection, -1);
|
|
134045
134313
|
const clearance = Math.min(25, Math.max(8, distance27 / 3));
|
|
134046
134314
|
const controlA = {
|
|
134047
134315
|
x: from.x + fromDirection.x * clearance,
|
|
@@ -134112,8 +134380,8 @@ function resolveAssemblyCable(cable) {
|
|
|
134112
134380
|
);
|
|
134113
134381
|
const definition = fromDefinition;
|
|
134114
134382
|
const endpointExit = (position, direction, depth) => {
|
|
134115
|
-
const exit =
|
|
134116
|
-
|
|
134383
|
+
const exit = vec38.scaleAndAdd(
|
|
134384
|
+
vec38.create(),
|
|
134117
134385
|
[position.x, position.y, position.z],
|
|
134118
134386
|
[direction.x, direction.y, direction.z],
|
|
134119
134387
|
depth
|
|
@@ -134192,6 +134460,9 @@ var analog = {
|
|
|
134192
134460
|
|
|
134193
134461
|
// lib/namespaced-elements/assembly.ts
|
|
134194
134462
|
var assembly = {
|
|
134463
|
+
referencesurface: createNamespacedElement(
|
|
134464
|
+
"assembly.referencesurface"
|
|
134465
|
+
),
|
|
134195
134466
|
part: createNamespacedElement("assembly.part"),
|
|
134196
134467
|
cable: createNamespacedElement("assembly.cable"),
|
|
134197
134468
|
printedpart: createNamespacedElement(
|
|
@@ -134448,6 +134719,7 @@ extendCatalogue({
|
|
|
134448
134719
|
"assembly.device": AssemblyDevice,
|
|
134449
134720
|
"assembly.motor": AssemblyMotor,
|
|
134450
134721
|
"assembly.part": AssemblyPart,
|
|
134722
|
+
"assembly.referencesurface": AssemblyReferenceSurface,
|
|
134451
134723
|
"assembly.printedpart": AssemblyPrintedPart,
|
|
134452
134724
|
"assembly.screen": AssemblyScreen,
|
|
134453
134725
|
"assembly.subassembly": AssemblySubassembly,
|
|
@@ -134477,6 +134749,7 @@ export {
|
|
|
134477
134749
|
AssemblyMotor,
|
|
134478
134750
|
AssemblyPart,
|
|
134479
134751
|
AssemblyPrintedPart,
|
|
134752
|
+
AssemblyReferenceSurface,
|
|
134480
134753
|
AssemblyScreen,
|
|
134481
134754
|
AssemblySubassembly,
|
|
134482
134755
|
AutoroutingPhase,
|