@willcgage/module-schematic 0.49.1 → 0.49.3
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.cjs +31 -23
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +31 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1078,7 +1078,12 @@ interface ReturnLoopGeometry {
|
|
|
1078
1078
|
declare function returnLoop(shape: ReturnLoopShape, opts: {
|
|
1079
1079
|
leadInches: number;
|
|
1080
1080
|
radius: number;
|
|
1081
|
+
/** Half-width of the board UNDER the loop track (the donut ring), inches. */
|
|
1081
1082
|
boardHalfWidth?: number;
|
|
1083
|
+
/** Half the endplate face width, inches. The lead/interface board is sized to
|
|
1084
|
+
* this so the benchwork is never narrower than the endplate (Free-moN §2.0);
|
|
1085
|
+
* the track crosses the endplate centred on a full-width board. */
|
|
1086
|
+
endplateHalfWidth?: number;
|
|
1082
1087
|
}): ReturnLoopGeometry;
|
|
1083
1088
|
interface ModuleGeometryInput {
|
|
1084
1089
|
lengthInches: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -1078,7 +1078,12 @@ interface ReturnLoopGeometry {
|
|
|
1078
1078
|
declare function returnLoop(shape: ReturnLoopShape, opts: {
|
|
1079
1079
|
leadInches: number;
|
|
1080
1080
|
radius: number;
|
|
1081
|
+
/** Half-width of the board UNDER the loop track (the donut ring), inches. */
|
|
1081
1082
|
boardHalfWidth?: number;
|
|
1083
|
+
/** Half the endplate face width, inches. The lead/interface board is sized to
|
|
1084
|
+
* this so the benchwork is never narrower than the endplate (Free-moN §2.0);
|
|
1085
|
+
* the track crosses the endplate centred on a full-width board. */
|
|
1086
|
+
endplateHalfWidth?: number;
|
|
1082
1087
|
}): ReturnLoopGeometry;
|
|
1083
1088
|
interface ModuleGeometryInput {
|
|
1084
1089
|
lengthInches: number;
|
package/dist/index.js
CHANGED
|
@@ -931,17 +931,24 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
|
931
931
|
trackB: x.tracks?.[1] ?? MAIN_TRACK_ID
|
|
932
932
|
})),
|
|
933
933
|
extraTracks,
|
|
934
|
-
turnouts: (d.turnouts ?? []).map((t) =>
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
934
|
+
turnouts: (d.turnouts ?? []).map((t) => {
|
|
935
|
+
let divergeTrack = t.divergeTrack;
|
|
936
|
+
if (divergeTrack === t.onTrack) {
|
|
937
|
+
if (t.onTrack === MAIN_TRACK_ID) divergeTrack = MAIN2_TRACK_ID;
|
|
938
|
+
else if (t.onTrack === MAIN2_TRACK_ID) divergeTrack = MAIN_TRACK_ID;
|
|
939
|
+
}
|
|
940
|
+
return {
|
|
941
|
+
id: t.id,
|
|
942
|
+
name: t.name ?? "",
|
|
943
|
+
pos: sc(t.pos),
|
|
944
|
+
onTrack: t.onTrack,
|
|
945
|
+
divergeTrack,
|
|
946
|
+
kind: t.kind ?? "right",
|
|
947
|
+
...t.size ? { size: t.size } : {},
|
|
948
|
+
...t.curved ? { curved: true } : {},
|
|
949
|
+
...t.flipped ? { flipped: true } : {}
|
|
950
|
+
};
|
|
951
|
+
}),
|
|
945
952
|
controlPoints: readControlPoints(d, sc),
|
|
946
953
|
industries: (d.industries ?? []).map((ind) => ({
|
|
947
954
|
id: ind.id,
|
|
@@ -1336,6 +1343,7 @@ function returnLoop(shape, opts) {
|
|
|
1336
1343
|
const L = Math.max(1, opts.leadInches);
|
|
1337
1344
|
const R = Math.max(1, opts.radius);
|
|
1338
1345
|
const hw = Math.min(opts.boardHalfWidth ?? 6, R - 1);
|
|
1346
|
+
const leadHalf = Math.max(hw, opts.endplateHalfWidth ?? hw);
|
|
1339
1347
|
const T = { x: L, y: 0 };
|
|
1340
1348
|
const r2 = (v) => Math.round(v * 100) / 100;
|
|
1341
1349
|
const rd = (pts) => pts.map((p) => ({ x: r2(p.x), y: r2(p.y) }));
|
|
@@ -1358,18 +1366,18 @@ function returnLoop(shape, opts) {
|
|
|
1358
1366
|
const legDir = (P) => Math.atan2(P.y - T.y, P.x - T.x);
|
|
1359
1367
|
const half = Math.abs((legDir(P1) - legDir(P2) + Math.PI) % (2 * Math.PI) - Math.PI) / 2;
|
|
1360
1368
|
const ringOuter = (rr) => {
|
|
1361
|
-
const xTop = C.x - Math.sqrt(Math.max(0, rr * rr - (
|
|
1362
|
-
const xBot = C.x - Math.sqrt(Math.max(0, rr * rr - (-
|
|
1363
|
-
const tTop = Math.atan2(
|
|
1364
|
-
const tBot = Math.atan2(-
|
|
1369
|
+
const xTop = C.x - Math.sqrt(Math.max(0, rr * rr - (leadHalf - C.y) ** 2));
|
|
1370
|
+
const xBot = C.x - Math.sqrt(Math.max(0, rr * rr - (-leadHalf - C.y) ** 2));
|
|
1371
|
+
const tTop = Math.atan2(leadHalf - C.y, xTop - C.x);
|
|
1372
|
+
const tBot = Math.atan2(-leadHalf - C.y, xBot - C.x);
|
|
1365
1373
|
let end = tBot;
|
|
1366
1374
|
while (end >= tTop) end -= 2 * Math.PI;
|
|
1367
1375
|
return [
|
|
1368
|
-
{ x: 0, y:
|
|
1369
|
-
{ x: xTop, y:
|
|
1376
|
+
{ x: 0, y: leadHalf },
|
|
1377
|
+
{ x: xTop, y: leadHalf },
|
|
1370
1378
|
...arc(C.x, C.y, rr, tTop, end, 48).slice(1, -1),
|
|
1371
|
-
{ x: xBot, y: -
|
|
1372
|
-
{ x: 0, y: -
|
|
1379
|
+
{ x: xBot, y: -leadHalf },
|
|
1380
|
+
{ x: 0, y: -leadHalf }
|
|
1373
1381
|
];
|
|
1374
1382
|
};
|
|
1375
1383
|
const Ri = R - hw;
|
|
@@ -1378,14 +1386,14 @@ function returnLoop(shape, opts) {
|
|
|
1378
1386
|
const xR = C.x + R + hw;
|
|
1379
1387
|
const yT = R + hw;
|
|
1380
1388
|
const outerSquare = [
|
|
1381
|
-
{ x: 0, y:
|
|
1382
|
-
{ x: xL, y:
|
|
1389
|
+
{ x: 0, y: leadHalf },
|
|
1390
|
+
{ x: xL, y: leadHalf },
|
|
1383
1391
|
{ x: xL, y: yT },
|
|
1384
1392
|
{ x: xR, y: yT },
|
|
1385
1393
|
{ x: xR, y: -yT },
|
|
1386
1394
|
{ x: xL, y: -yT },
|
|
1387
|
-
{ x: xL, y: -
|
|
1388
|
-
{ x: 0, y: -
|
|
1395
|
+
{ x: xL, y: -leadHalf },
|
|
1396
|
+
{ x: 0, y: -leadHalf }
|
|
1389
1397
|
];
|
|
1390
1398
|
const iHalf = (R - hw) / Math.SQRT2;
|
|
1391
1399
|
const holeSquare = iHalf > 2 ? [
|