@willcgage/module-schematic 0.60.0 → 0.61.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 +41 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -3
- package/dist/index.d.ts +44 -3
- package/dist/index.js +41 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -394,6 +394,13 @@ declare function samplePath(pts: BenchworkPoint[], segsPerArc?: number): {
|
|
|
394
394
|
x: number;
|
|
395
395
|
y: number;
|
|
396
396
|
}[];
|
|
397
|
+
/**
|
|
398
|
+
* Arc length of an authored path, inches — the path's OWN length, independent of
|
|
399
|
+
* where it sits or which way it runs. A branch route to a third endplate (#181)
|
|
400
|
+
* has no meaningful extent along the module axis (a square 90° exit projects to
|
|
401
|
+
* zero), so its own length is the only honest measure of it.
|
|
402
|
+
*/
|
|
403
|
+
declare function pathLengthInches(path: BenchworkPoint[] | null | undefined): number;
|
|
397
404
|
/** Normalise an authored track path from a doc, or null if it isn't a real path
|
|
398
405
|
* (needs ≥ 2 valid points). Keeps per-vertex bulge. */
|
|
399
406
|
declare function trackPath(path: BenchworkPoint[] | null | undefined): BenchworkPoint[] | null;
|
|
@@ -951,13 +958,47 @@ interface DrawCrossover {
|
|
|
951
958
|
toPosFrac: number;
|
|
952
959
|
toLane: number;
|
|
953
960
|
}
|
|
954
|
-
/**
|
|
955
|
-
*
|
|
961
|
+
/**
|
|
962
|
+
* A route leaving the module at a third endplate (#170) — Main 3, whatever the
|
|
963
|
+
* owner labels it (#181). Drawn as an ELBOW: it diverges from its host main at
|
|
964
|
+
* `posFrac`, drops to its own `lane`, then runs to `endFrac` and ends at an
|
|
965
|
+
* endplate face.
|
|
966
|
+
*
|
|
967
|
+
* The run is the branch's OWN arc length laid along the strip, not its
|
|
968
|
+
* projection onto the module axis — a square 90° exit projects to zero, which
|
|
969
|
+
* is exactly the case that made branches invisible here. Straightening the
|
|
970
|
+
* route out at its true length is the same idiom this whole view applies to the
|
|
971
|
+
* main; `posFrac → endFrac` is therefore a real axis, and `lengthInches` maps
|
|
972
|
+
* onto it, so anything positioned along the branch has somewhere to draw.
|
|
973
|
+
*/
|
|
956
974
|
interface BranchConnector {
|
|
975
|
+
/** Endplate id — "C", "D", … */
|
|
957
976
|
id: string;
|
|
977
|
+
/** The endplate's label. MR draws no text (the destination depends on what's
|
|
978
|
+
* physically attached, so FD derives the panel label at runtime) — this is
|
|
979
|
+
* the owner's local name, for tooltips and FD's fallback. */
|
|
958
980
|
label: string;
|
|
981
|
+
/** The route's own name, from the track. */
|
|
982
|
+
name: string;
|
|
983
|
+
/** The branch track's id. */
|
|
984
|
+
trackId: string;
|
|
985
|
+
/** Whether the route IS a main (a diverging/split main) or a secondary
|
|
986
|
+
* branch line. Drives drawn weight, not geometry. */
|
|
987
|
+
kind: "branch" | "main";
|
|
988
|
+
/** Where it leaves its host main. */
|
|
959
989
|
posFrac: number;
|
|
990
|
+
/** The host track's lane — a branch need not leave Main 1. Renderers must
|
|
991
|
+
* start the diverge HERE, not at a hard-coded lane 0. */
|
|
992
|
+
fromLane: number;
|
|
993
|
+
/** Which side of the module it exits. */
|
|
960
994
|
side: "up" | "down";
|
|
995
|
+
/** The branch's own lane, signed by `side` and placed clear of every other
|
|
996
|
+
* lane (so it never collides) — already folded into laneMin/laneMax. */
|
|
997
|
+
lane: number;
|
|
998
|
+
/** Where the run ends, and the endplate face is drawn. */
|
|
999
|
+
endFrac: number;
|
|
1000
|
+
/** The route's own arc length, inches. */
|
|
1001
|
+
lengthInches: number;
|
|
961
1002
|
}
|
|
962
1003
|
/** An industry — draw a car-spot span beside its track's lane, on `side`, with
|
|
963
1004
|
* a name label + an optional car/length readout (#industries). */
|
|
@@ -1583,4 +1624,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
|
|
|
1583
1624
|
heading: number;
|
|
1584
1625
|
}>;
|
|
1585
1626
|
|
|
1586
|
-
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CODE55_RAIL_HEIGHT_INCHES, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FrogCasting, type GeometryType, type ImportedPart, type IndustryLabelMode, type IndustrySpot, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OutlineFace, type PartAngle, type PartDimension, type PartEnd, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SectionRelativePos, type SignalFacing, type SignalSide, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
|
|
1627
|
+
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CODE55_RAIL_HEIGHT_INCHES, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FrogCasting, type GeometryType, type ImportedPart, type IndustryLabelMode, type IndustrySpot, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OutlineFace, type PartAngle, type PartDimension, type PartEnd, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SectionRelativePos, type SignalFacing, type SignalSide, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
|
package/dist/index.d.ts
CHANGED
|
@@ -394,6 +394,13 @@ declare function samplePath(pts: BenchworkPoint[], segsPerArc?: number): {
|
|
|
394
394
|
x: number;
|
|
395
395
|
y: number;
|
|
396
396
|
}[];
|
|
397
|
+
/**
|
|
398
|
+
* Arc length of an authored path, inches — the path's OWN length, independent of
|
|
399
|
+
* where it sits or which way it runs. A branch route to a third endplate (#181)
|
|
400
|
+
* has no meaningful extent along the module axis (a square 90° exit projects to
|
|
401
|
+
* zero), so its own length is the only honest measure of it.
|
|
402
|
+
*/
|
|
403
|
+
declare function pathLengthInches(path: BenchworkPoint[] | null | undefined): number;
|
|
397
404
|
/** Normalise an authored track path from a doc, or null if it isn't a real path
|
|
398
405
|
* (needs ≥ 2 valid points). Keeps per-vertex bulge. */
|
|
399
406
|
declare function trackPath(path: BenchworkPoint[] | null | undefined): BenchworkPoint[] | null;
|
|
@@ -951,13 +958,47 @@ interface DrawCrossover {
|
|
|
951
958
|
toPosFrac: number;
|
|
952
959
|
toLane: number;
|
|
953
960
|
}
|
|
954
|
-
/**
|
|
955
|
-
*
|
|
961
|
+
/**
|
|
962
|
+
* A route leaving the module at a third endplate (#170) — Main 3, whatever the
|
|
963
|
+
* owner labels it (#181). Drawn as an ELBOW: it diverges from its host main at
|
|
964
|
+
* `posFrac`, drops to its own `lane`, then runs to `endFrac` and ends at an
|
|
965
|
+
* endplate face.
|
|
966
|
+
*
|
|
967
|
+
* The run is the branch's OWN arc length laid along the strip, not its
|
|
968
|
+
* projection onto the module axis — a square 90° exit projects to zero, which
|
|
969
|
+
* is exactly the case that made branches invisible here. Straightening the
|
|
970
|
+
* route out at its true length is the same idiom this whole view applies to the
|
|
971
|
+
* main; `posFrac → endFrac` is therefore a real axis, and `lengthInches` maps
|
|
972
|
+
* onto it, so anything positioned along the branch has somewhere to draw.
|
|
973
|
+
*/
|
|
956
974
|
interface BranchConnector {
|
|
975
|
+
/** Endplate id — "C", "D", … */
|
|
957
976
|
id: string;
|
|
977
|
+
/** The endplate's label. MR draws no text (the destination depends on what's
|
|
978
|
+
* physically attached, so FD derives the panel label at runtime) — this is
|
|
979
|
+
* the owner's local name, for tooltips and FD's fallback. */
|
|
958
980
|
label: string;
|
|
981
|
+
/** The route's own name, from the track. */
|
|
982
|
+
name: string;
|
|
983
|
+
/** The branch track's id. */
|
|
984
|
+
trackId: string;
|
|
985
|
+
/** Whether the route IS a main (a diverging/split main) or a secondary
|
|
986
|
+
* branch line. Drives drawn weight, not geometry. */
|
|
987
|
+
kind: "branch" | "main";
|
|
988
|
+
/** Where it leaves its host main. */
|
|
959
989
|
posFrac: number;
|
|
990
|
+
/** The host track's lane — a branch need not leave Main 1. Renderers must
|
|
991
|
+
* start the diverge HERE, not at a hard-coded lane 0. */
|
|
992
|
+
fromLane: number;
|
|
993
|
+
/** Which side of the module it exits. */
|
|
960
994
|
side: "up" | "down";
|
|
995
|
+
/** The branch's own lane, signed by `side` and placed clear of every other
|
|
996
|
+
* lane (so it never collides) — already folded into laneMin/laneMax. */
|
|
997
|
+
lane: number;
|
|
998
|
+
/** Where the run ends, and the endplate face is drawn. */
|
|
999
|
+
endFrac: number;
|
|
1000
|
+
/** The route's own arc length, inches. */
|
|
1001
|
+
lengthInches: number;
|
|
961
1002
|
}
|
|
962
1003
|
/** An industry — draw a car-spot span beside its track's lane, on `side`, with
|
|
963
1004
|
* a name label + an optional car/length readout (#industries). */
|
|
@@ -1583,4 +1624,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
|
|
|
1583
1624
|
heading: number;
|
|
1584
1625
|
}>;
|
|
1585
1626
|
|
|
1586
|
-
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CODE55_RAIL_HEIGHT_INCHES, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FrogCasting, type GeometryType, type ImportedPart, type IndustryLabelMode, type IndustrySpot, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OutlineFace, type PartAngle, type PartDimension, type PartEnd, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SectionRelativePos, type SignalFacing, type SignalSide, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
|
|
1627
|
+
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CODE55_RAIL_HEIGHT_INCHES, type DimensionSource, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FrogCasting, type GeometryType, type ImportedPart, type IndustryLabelMode, type IndustrySpot, MAIN2_TRACK_ID, MAIN_TRACK_ID, type ModuleFeatures, type ModuleFootprint, type ModuleFootprintInput, type ModuleGeometryInput, type ModuleSchematicDoc, type ModuleTrackRow, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, type OutlineFace, type PartAngle, type PartDimension, type PartEnd, type PartSegment, RAIL_GAUGE_INCHES, type ReturnLoopGeometry, type ReturnLoopShape, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SectionRelativePos, type SignalFacing, type SignalSide, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackPart, type TrackRole, type TurnoutClosure, type TurnoutKind, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
|
package/dist/index.js
CHANGED
|
@@ -115,6 +115,15 @@ function samplePath(pts, segsPerArc = 20) {
|
|
|
115
115
|
out.push({ x: pts[n - 1].x, y: pts[n - 1].y });
|
|
116
116
|
return out;
|
|
117
117
|
}
|
|
118
|
+
function pathLengthInches(path) {
|
|
119
|
+
const pts = trackPath(path);
|
|
120
|
+
if (!pts) return 0;
|
|
121
|
+
const poly = samplePath(pts);
|
|
122
|
+
let total = 0;
|
|
123
|
+
for (let i = 1; i < poly.length; i++)
|
|
124
|
+
total += Math.hypot(poly[i].x - poly[i - 1].x, poly[i].y - poly[i - 1].y);
|
|
125
|
+
return total;
|
|
126
|
+
}
|
|
118
127
|
function trackPath(path) {
|
|
119
128
|
const pts = (path ?? []).filter((p) => p && Number.isFinite(p.x) && Number.isFinite(p.y)).map((p) => ({
|
|
120
129
|
x: p.x,
|
|
@@ -1680,15 +1689,43 @@ function moduleFeatures(doc) {
|
|
|
1680
1689
|
laneA: trackLane.get(x.tracks?.[0] ?? "") ?? 0,
|
|
1681
1690
|
laneB: trackLane.get(x.tracks?.[1] ?? "") ?? 1
|
|
1682
1691
|
}));
|
|
1692
|
+
const main2Lane = trackLane.has(MAIN2_TRACK_ID) ? trackLane.get(MAIN2_TRACK_ID) : null;
|
|
1693
|
+
const baseLanes = [
|
|
1694
|
+
0,
|
|
1695
|
+
main2Lane ?? (doubleMain ? 1 : 0),
|
|
1696
|
+
...extraTracks.map((t) => t.lane),
|
|
1697
|
+
...signals.map((s) => s.lane),
|
|
1698
|
+
...crossings.flatMap((x) => [x.laneA, x.laneB]),
|
|
1699
|
+
...crossovers.flatMap((x) => [x.fromLane, x.toLane])
|
|
1700
|
+
];
|
|
1701
|
+
let upLane = Math.max(...baseLanes, 0);
|
|
1702
|
+
let downLane = Math.min(...baseLanes, 0);
|
|
1683
1703
|
const branchConnectors = doc.endplates.filter(
|
|
1684
1704
|
(e) => e.id !== "A" && e.id !== "B" && e.at && !!e.trackId && (doc.tracks ?? []).some((t) => t.id === e.trackId)
|
|
1685
1705
|
).map((e) => {
|
|
1706
|
+
const trk = (doc.tracks ?? []).find((t) => t.id === e.trackId);
|
|
1686
1707
|
const sw = (doc.turnouts ?? []).find((t) => t.divergeTrack === e.trackId);
|
|
1708
|
+
const startPos = sw ? sw.pos : e.at.pos;
|
|
1709
|
+
const side = e.at.side === "down" ? "down" : "up";
|
|
1710
|
+
const lane = side === "down" ? --downLane : ++upLane;
|
|
1711
|
+
const runInches = pathLengthInches(trk.path) || Math.abs(e.at.pos - startPos) || FREEMO_ENDPLATE_WIDTH_MIN_INCHES;
|
|
1712
|
+
const toB = e.at.pos >= startPos;
|
|
1713
|
+
const fits = (p) => p >= 0 && p <= len;
|
|
1714
|
+
const ahead = startPos + runInches;
|
|
1715
|
+
const behind = startPos - runInches;
|
|
1716
|
+
const endPos = toB && fits(ahead) ? ahead : !toB && fits(behind) ? behind : fits(toB ? behind : ahead) ? toB ? behind : ahead : ahead;
|
|
1687
1717
|
return {
|
|
1688
1718
|
id: e.id,
|
|
1689
1719
|
label: e.label ?? e.id,
|
|
1690
|
-
|
|
1691
|
-
|
|
1720
|
+
name: trk.trackName ?? "",
|
|
1721
|
+
trackId: trk.id,
|
|
1722
|
+
kind: e.kind === "main" ? "main" : "branch",
|
|
1723
|
+
posFrac: clampFrac(startPos),
|
|
1724
|
+
fromLane: sw ? trackLane.get(sw.onTrack) ?? 0 : 0,
|
|
1725
|
+
side,
|
|
1726
|
+
lane,
|
|
1727
|
+
endFrac: clampFrac(endPos),
|
|
1728
|
+
lengthInches: runInches
|
|
1692
1729
|
};
|
|
1693
1730
|
});
|
|
1694
1731
|
const industries = (doc.industries ?? []).flatMap((ind) => {
|
|
@@ -1713,15 +1750,7 @@ function moduleFeatures(doc) {
|
|
|
1713
1750
|
};
|
|
1714
1751
|
});
|
|
1715
1752
|
});
|
|
1716
|
-
const
|
|
1717
|
-
const allLanes = [
|
|
1718
|
-
0,
|
|
1719
|
-
main2Lane ?? (doubleMain ? 1 : 0),
|
|
1720
|
-
...extraTracks.map((t) => t.lane),
|
|
1721
|
-
...signals.map((s) => s.lane),
|
|
1722
|
-
...crossings.flatMap((x) => [x.laneA, x.laneB]),
|
|
1723
|
-
...crossovers.flatMap((x) => [x.fromLane, x.toLane])
|
|
1724
|
-
];
|
|
1753
|
+
const allLanes = [...baseLanes, ...branchConnectors.map((b) => b.lane)];
|
|
1725
1754
|
const loop = isLoopDoc(doc);
|
|
1726
1755
|
const main2 = doc.tracks.find((t) => t.id === MAIN2_TRACK_ID);
|
|
1727
1756
|
const main2Positioned = !!main2 && (main2.fromPos != null || main2.toPos != null) && !loop;
|
|
@@ -2012,6 +2041,6 @@ function poseOverridesFromDoc(doc) {
|
|
|
2012
2041
|
return out;
|
|
2013
2042
|
}
|
|
2014
2043
|
|
|
2015
|
-
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CODE55_RAIL_HEIGHT_INCHES, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, RAIL_GAUGE_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
|
|
2044
|
+
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CODE55_RAIL_HEIGHT_INCHES, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, RAIL_GAUGE_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateLead, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, leadInchesForSize, mergeImportedParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partOutlineAtFrog, pathLengthInches, poseNeedsManual, poseOverridesFromDoc, remapPos, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutPartForSize };
|
|
2016
2045
|
//# sourceMappingURL=index.js.map
|
|
2017
2046
|
//# sourceMappingURL=index.js.map
|