@willcgage/module-schematic 0.39.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +18 -20
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -20
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -569,25 +569,19 @@ function isTransitionTurnout(t) {
|
|
|
569
569
|
return t.onTrack === MAIN_TRACK_ID && t.divergeTrack === MAIN2_TRACK_ID || t.onTrack === MAIN2_TRACK_ID && t.divergeTrack === MAIN_TRACK_ID;
|
|
570
570
|
}
|
|
571
571
|
function main1Track(state) {
|
|
572
|
-
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
573
|
-
const isDouble = state.configA === "double" || state.configB === "double";
|
|
574
572
|
const sw = state.turnouts.find(isTransitionTurnout);
|
|
575
|
-
const
|
|
576
|
-
|
|
577
|
-
|
|
573
|
+
const legacyThroughMain2 = !!sw && sw.onTrack === MAIN2_TRACK_ID && sw.divergeTrack === MAIN_TRACK_ID;
|
|
574
|
+
const isDouble = state.configA === "double" || state.configB === "double";
|
|
575
|
+
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
576
|
+
if (!isDouble || bothDouble || !legacyThroughMain2) {
|
|
577
|
+
return { id: MAIN_TRACK_ID, role: "main", lane: 0, from: "A", to: "B" };
|
|
578
578
|
}
|
|
579
|
-
return state.configA === "double" ?
|
|
580
|
-
// Double at A: Main 1 runs from A and ends at the turnout.
|
|
581
|
-
{ id: MAIN_TRACK_ID, role: "main", lane, fromPos: 0, toPos: sw.pos }
|
|
582
|
-
) : (
|
|
583
|
-
// Double at B: Main 1 begins at the turnout and runs to B.
|
|
584
|
-
{ id: MAIN_TRACK_ID, role: "main", lane, fromPos: sw.pos, toPos: state.lengthInches }
|
|
585
|
-
);
|
|
579
|
+
return state.configA === "double" ? { id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: 0, toPos: sw.pos } : { id: MAIN_TRACK_ID, role: "main", lane: 0, fromPos: sw.pos, toPos: state.lengthInches };
|
|
586
580
|
}
|
|
587
581
|
function main2Track(state) {
|
|
588
582
|
const bothDouble = state.configA === "double" && state.configB === "double";
|
|
589
583
|
const sws = state.turnouts.filter((t) => isTransitionTurnout(t) && t.divergeTrack === MAIN2_TRACK_ID).sort((a, b) => a.pos - b.pos);
|
|
590
|
-
const lane = state.mainsSwapped ?
|
|
584
|
+
const lane = state.mainsSwapped ? -1 : 1;
|
|
591
585
|
const authored = state.main2Path.length >= 2 ? { path: state.main2Path } : {};
|
|
592
586
|
if (bothDouble || !sws.length) {
|
|
593
587
|
return { id: MAIN2_TRACK_ID, role: "main", lane, from: "A", to: "B", ...authored };
|
|
@@ -617,13 +611,17 @@ function buildTransition(state) {
|
|
|
617
611
|
id: swId,
|
|
618
612
|
name: "End of Double Track",
|
|
619
613
|
pos,
|
|
620
|
-
// The turnout sits ON the
|
|
621
|
-
//
|
|
622
|
-
//
|
|
623
|
-
//
|
|
624
|
-
onTrack:
|
|
625
|
-
divergeTrack:
|
|
626
|
-
|
|
614
|
+
// The turnout sits ON the through mainline (Main 1) and diverges TO Main 2,
|
|
615
|
+
// the second main being added to start the double track — the modeller's
|
|
616
|
+
// view of the junction, and the direction an owner authors it (Steve
|
|
617
|
+
// Branton, #131). Main 1 runs the full module; Main 2 is the branch.
|
|
618
|
+
onTrack: MAIN_TRACK_ID,
|
|
619
|
+
divergeTrack: MAIN2_TRACK_ID,
|
|
620
|
+
// Hand so the diverging leg lands on Main 2's side. Main 2 extends toward
|
|
621
|
+
// the double end (sign −1 west / +1 east) and sits above (+1) or, when the
|
|
622
|
+
// mains are swapped, below (−1). divergeSideForHand(left)=sign(toward),
|
|
623
|
+
// (right)=−sign(toward), so pick the hand whose side matches Main 2's (#131).
|
|
624
|
+
kind: (aDouble ? -1 : 1) === (state.mainsSwapped ? -1 : 1) ? "left" : "right"
|
|
627
625
|
};
|
|
628
626
|
const cpId = nextId("cp", state.controlPoints.map((c) => c.id));
|
|
629
627
|
const sig = (facing) => ({
|