@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.cjs
CHANGED
|
@@ -933,17 +933,24 @@ function docToState(doc, fallbackLength, moduleTracks = []) {
|
|
|
933
933
|
trackB: x.tracks?.[1] ?? MAIN_TRACK_ID
|
|
934
934
|
})),
|
|
935
935
|
extraTracks,
|
|
936
|
-
turnouts: (d.turnouts ?? []).map((t) =>
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
936
|
+
turnouts: (d.turnouts ?? []).map((t) => {
|
|
937
|
+
let divergeTrack = t.divergeTrack;
|
|
938
|
+
if (divergeTrack === t.onTrack) {
|
|
939
|
+
if (t.onTrack === MAIN_TRACK_ID) divergeTrack = MAIN2_TRACK_ID;
|
|
940
|
+
else if (t.onTrack === MAIN2_TRACK_ID) divergeTrack = MAIN_TRACK_ID;
|
|
941
|
+
}
|
|
942
|
+
return {
|
|
943
|
+
id: t.id,
|
|
944
|
+
name: t.name ?? "",
|
|
945
|
+
pos: sc(t.pos),
|
|
946
|
+
onTrack: t.onTrack,
|
|
947
|
+
divergeTrack,
|
|
948
|
+
kind: t.kind ?? "right",
|
|
949
|
+
...t.size ? { size: t.size } : {},
|
|
950
|
+
...t.curved ? { curved: true } : {},
|
|
951
|
+
...t.flipped ? { flipped: true } : {}
|
|
952
|
+
};
|
|
953
|
+
}),
|
|
947
954
|
controlPoints: readControlPoints(d, sc),
|
|
948
955
|
industries: (d.industries ?? []).map((ind) => ({
|
|
949
956
|
id: ind.id,
|
|
@@ -1338,6 +1345,7 @@ function returnLoop(shape, opts) {
|
|
|
1338
1345
|
const L = Math.max(1, opts.leadInches);
|
|
1339
1346
|
const R = Math.max(1, opts.radius);
|
|
1340
1347
|
const hw = Math.min(opts.boardHalfWidth ?? 6, R - 1);
|
|
1348
|
+
const leadHalf = Math.max(hw, opts.endplateHalfWidth ?? hw);
|
|
1341
1349
|
const T = { x: L, y: 0 };
|
|
1342
1350
|
const r2 = (v) => Math.round(v * 100) / 100;
|
|
1343
1351
|
const rd = (pts) => pts.map((p) => ({ x: r2(p.x), y: r2(p.y) }));
|
|
@@ -1360,18 +1368,18 @@ function returnLoop(shape, opts) {
|
|
|
1360
1368
|
const legDir = (P) => Math.atan2(P.y - T.y, P.x - T.x);
|
|
1361
1369
|
const half = Math.abs((legDir(P1) - legDir(P2) + Math.PI) % (2 * Math.PI) - Math.PI) / 2;
|
|
1362
1370
|
const ringOuter = (rr) => {
|
|
1363
|
-
const xTop = C.x - Math.sqrt(Math.max(0, rr * rr - (
|
|
1364
|
-
const xBot = C.x - Math.sqrt(Math.max(0, rr * rr - (-
|
|
1365
|
-
const tTop = Math.atan2(
|
|
1366
|
-
const tBot = Math.atan2(-
|
|
1371
|
+
const xTop = C.x - Math.sqrt(Math.max(0, rr * rr - (leadHalf - C.y) ** 2));
|
|
1372
|
+
const xBot = C.x - Math.sqrt(Math.max(0, rr * rr - (-leadHalf - C.y) ** 2));
|
|
1373
|
+
const tTop = Math.atan2(leadHalf - C.y, xTop - C.x);
|
|
1374
|
+
const tBot = Math.atan2(-leadHalf - C.y, xBot - C.x);
|
|
1367
1375
|
let end = tBot;
|
|
1368
1376
|
while (end >= tTop) end -= 2 * Math.PI;
|
|
1369
1377
|
return [
|
|
1370
|
-
{ x: 0, y:
|
|
1371
|
-
{ x: xTop, y:
|
|
1378
|
+
{ x: 0, y: leadHalf },
|
|
1379
|
+
{ x: xTop, y: leadHalf },
|
|
1372
1380
|
...arc(C.x, C.y, rr, tTop, end, 48).slice(1, -1),
|
|
1373
|
-
{ x: xBot, y: -
|
|
1374
|
-
{ x: 0, y: -
|
|
1381
|
+
{ x: xBot, y: -leadHalf },
|
|
1382
|
+
{ x: 0, y: -leadHalf }
|
|
1375
1383
|
];
|
|
1376
1384
|
};
|
|
1377
1385
|
const Ri = R - hw;
|
|
@@ -1380,14 +1388,14 @@ function returnLoop(shape, opts) {
|
|
|
1380
1388
|
const xR = C.x + R + hw;
|
|
1381
1389
|
const yT = R + hw;
|
|
1382
1390
|
const outerSquare = [
|
|
1383
|
-
{ x: 0, y:
|
|
1384
|
-
{ x: xL, y:
|
|
1391
|
+
{ x: 0, y: leadHalf },
|
|
1392
|
+
{ x: xL, y: leadHalf },
|
|
1385
1393
|
{ x: xL, y: yT },
|
|
1386
1394
|
{ x: xR, y: yT },
|
|
1387
1395
|
{ x: xR, y: -yT },
|
|
1388
1396
|
{ x: xL, y: -yT },
|
|
1389
|
-
{ x: xL, y: -
|
|
1390
|
-
{ x: 0, y: -
|
|
1397
|
+
{ x: xL, y: -leadHalf },
|
|
1398
|
+
{ x: 0, y: -leadHalf }
|
|
1391
1399
|
];
|
|
1392
1400
|
const iHalf = (R - hw) / Math.SQRT2;
|
|
1393
1401
|
const holeSquare = iHalf > 2 ? [
|