@willcgage/module-schematic 0.89.0 → 0.90.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 +80 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -1
- package/dist/index.d.ts +50 -1
- package/dist/index.js +79 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -2423,6 +2423,27 @@ declare function partGeometryGap(part: TrackPart): string | null;
|
|
|
2423
2423
|
* which you got.
|
|
2424
2424
|
*/
|
|
2425
2425
|
declare function partGeometry(part: TrackPart, library?: TrackPart[]): PartGeometry | null;
|
|
2426
|
+
/**
|
|
2427
|
+
* The SHAPE of every route through a placed piece, in MODULE inches — the
|
|
2428
|
+
* polyline a renderer draws.
|
|
2429
|
+
*
|
|
2430
|
+
* ⭐ The shape belongs to the PART, so it lives here rather than in either app's
|
|
2431
|
+
* canvas. A diverging route drawn as a straight chord from throat to diverging
|
|
2432
|
+
* end cuts the corner the closure actually turns; every renderer would have to
|
|
2433
|
+
* rebuild that curve, and they would drift.
|
|
2434
|
+
*
|
|
2435
|
+
* ⚠️ Each polyline ENDS EXACTLY ON ITS JOINTS, by construction — the samples in
|
|
2436
|
+
* between follow the closure, but the ends are the joint positions themselves.
|
|
2437
|
+
* Track that stops short of its own joint would draw a gap at a connection that
|
|
2438
|
+
* the graph considers made.
|
|
2439
|
+
*/
|
|
2440
|
+
declare function pieceRoutePaths(piece: TrackPiece, library?: TrackPart[]): {
|
|
2441
|
+
route: [string, string];
|
|
2442
|
+
points: {
|
|
2443
|
+
x: number;
|
|
2444
|
+
y: number;
|
|
2445
|
+
}[];
|
|
2446
|
+
}[];
|
|
2426
2447
|
/** Every part that can be PLACED on a board today, and every one that can only
|
|
2427
2448
|
* be named — with the reason. The gap list is the parts backlog. */
|
|
2428
2449
|
declare function partsPlaceable(library?: TrackPart[]): {
|
|
@@ -2520,6 +2541,34 @@ interface RouteSpan {
|
|
|
2520
2541
|
fromPos: number;
|
|
2521
2542
|
toPos: number;
|
|
2522
2543
|
}
|
|
2544
|
+
/** A piece moved into place against an open joint. */
|
|
2545
|
+
interface PieceSnap {
|
|
2546
|
+
/** The piece, rotated and translated so the two joints coincide. */
|
|
2547
|
+
piece: TrackPiece;
|
|
2548
|
+
/** The moving joint's key, and the open joint it was brought onto. */
|
|
2549
|
+
from: string;
|
|
2550
|
+
to: string;
|
|
2551
|
+
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Bring a piece being dragged onto the nearest OPEN joint of the others.
|
|
2554
|
+
*
|
|
2555
|
+
* ⛔ **ONLY OPEN JOINTS ARE CANDIDATES, and that is the ADR's standing rule
|
|
2556
|
+
* enforced where it can still be obeyed.** A joint already holding a connection
|
|
2557
|
+
* is not offered, so an owner cannot stack a third rail end on a joint at all —
|
|
2558
|
+
* rather than stacking it and having {@link buildTrackGraph} refuse all three
|
|
2559
|
+
* afterwards, with a piece silently outside the layout until they notice.
|
|
2560
|
+
*
|
|
2561
|
+
* The piece is ROTATED as well as moved: two ends meet when they are in the same
|
|
2562
|
+
* place and facing opposite ways, so the rotation falls out of the joint it is
|
|
2563
|
+
* brought to. That is what makes laying a curve out of straight pieces possible
|
|
2564
|
+
* without typing an angle.
|
|
2565
|
+
*
|
|
2566
|
+
* `withinInches` is a GRAB radius — how near counts as "meant it" — and is a
|
|
2567
|
+
* different thing from {@link JOINT_SNAP_INCHES}, which is how close two joints
|
|
2568
|
+
* must be to BE connected. This one is generous; that one is a hundredth of an
|
|
2569
|
+
* inch.
|
|
2570
|
+
*/
|
|
2571
|
+
declare function snapPiece(moving: TrackPiece, others: TrackPiece[], library?: TrackPart[], withinInches?: number): PieceSnap | null;
|
|
2523
2572
|
/** A route the walk found: a continuous run of pieces a train can travel. */
|
|
2524
2573
|
interface GraphRoute {
|
|
2525
2574
|
id: string;
|
|
@@ -2933,4 +2982,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
|
|
|
2933
2982
|
heading: number;
|
|
2934
2983
|
}>;
|
|
2935
2984
|
|
|
2936
|
-
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, 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 EndplateEdge, type EndplateEdgePose, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type GraphAnchor, type GraphConflict, type GraphConnection, type GraphDocInput, type GraphDocResult, type GraphRoute, type GraphTurnout, type GraphWalk, type ImportedPart, type IndustryLabelMode, type IndustrySpot, JOINT_SNAP_INCHES, type LanePinch, 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 OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, type PlacedJoint, RAIL_GAUGE_INCHES, type ResolvedAnchor, type ReturnLoopGeometry, type ReturnLoopShape, type RouteSpan, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackGraph, type TrackPart, type TrackPiece, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
|
|
2985
|
+
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, 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 EndplateEdge, type EndplateEdgePose, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type GraphAnchor, type GraphConflict, type GraphConnection, type GraphDocInput, type GraphDocResult, type GraphRoute, type GraphTurnout, type GraphWalk, type ImportedPart, type IndustryLabelMode, type IndustrySpot, JOINT_SNAP_INCHES, type LanePinch, 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 OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, type PieceSnap, type PlacedJoint, RAIL_GAUGE_INCHES, type ResolvedAnchor, type ReturnLoopGeometry, type ReturnLoopShape, type RouteSpan, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackGraph, type TrackPart, type TrackPiece, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
|
package/dist/index.d.ts
CHANGED
|
@@ -2423,6 +2423,27 @@ declare function partGeometryGap(part: TrackPart): string | null;
|
|
|
2423
2423
|
* which you got.
|
|
2424
2424
|
*/
|
|
2425
2425
|
declare function partGeometry(part: TrackPart, library?: TrackPart[]): PartGeometry | null;
|
|
2426
|
+
/**
|
|
2427
|
+
* The SHAPE of every route through a placed piece, in MODULE inches — the
|
|
2428
|
+
* polyline a renderer draws.
|
|
2429
|
+
*
|
|
2430
|
+
* ⭐ The shape belongs to the PART, so it lives here rather than in either app's
|
|
2431
|
+
* canvas. A diverging route drawn as a straight chord from throat to diverging
|
|
2432
|
+
* end cuts the corner the closure actually turns; every renderer would have to
|
|
2433
|
+
* rebuild that curve, and they would drift.
|
|
2434
|
+
*
|
|
2435
|
+
* ⚠️ Each polyline ENDS EXACTLY ON ITS JOINTS, by construction — the samples in
|
|
2436
|
+
* between follow the closure, but the ends are the joint positions themselves.
|
|
2437
|
+
* Track that stops short of its own joint would draw a gap at a connection that
|
|
2438
|
+
* the graph considers made.
|
|
2439
|
+
*/
|
|
2440
|
+
declare function pieceRoutePaths(piece: TrackPiece, library?: TrackPart[]): {
|
|
2441
|
+
route: [string, string];
|
|
2442
|
+
points: {
|
|
2443
|
+
x: number;
|
|
2444
|
+
y: number;
|
|
2445
|
+
}[];
|
|
2446
|
+
}[];
|
|
2426
2447
|
/** Every part that can be PLACED on a board today, and every one that can only
|
|
2427
2448
|
* be named — with the reason. The gap list is the parts backlog. */
|
|
2428
2449
|
declare function partsPlaceable(library?: TrackPart[]): {
|
|
@@ -2520,6 +2541,34 @@ interface RouteSpan {
|
|
|
2520
2541
|
fromPos: number;
|
|
2521
2542
|
toPos: number;
|
|
2522
2543
|
}
|
|
2544
|
+
/** A piece moved into place against an open joint. */
|
|
2545
|
+
interface PieceSnap {
|
|
2546
|
+
/** The piece, rotated and translated so the two joints coincide. */
|
|
2547
|
+
piece: TrackPiece;
|
|
2548
|
+
/** The moving joint's key, and the open joint it was brought onto. */
|
|
2549
|
+
from: string;
|
|
2550
|
+
to: string;
|
|
2551
|
+
}
|
|
2552
|
+
/**
|
|
2553
|
+
* Bring a piece being dragged onto the nearest OPEN joint of the others.
|
|
2554
|
+
*
|
|
2555
|
+
* ⛔ **ONLY OPEN JOINTS ARE CANDIDATES, and that is the ADR's standing rule
|
|
2556
|
+
* enforced where it can still be obeyed.** A joint already holding a connection
|
|
2557
|
+
* is not offered, so an owner cannot stack a third rail end on a joint at all —
|
|
2558
|
+
* rather than stacking it and having {@link buildTrackGraph} refuse all three
|
|
2559
|
+
* afterwards, with a piece silently outside the layout until they notice.
|
|
2560
|
+
*
|
|
2561
|
+
* The piece is ROTATED as well as moved: two ends meet when they are in the same
|
|
2562
|
+
* place and facing opposite ways, so the rotation falls out of the joint it is
|
|
2563
|
+
* brought to. That is what makes laying a curve out of straight pieces possible
|
|
2564
|
+
* without typing an angle.
|
|
2565
|
+
*
|
|
2566
|
+
* `withinInches` is a GRAB radius — how near counts as "meant it" — and is a
|
|
2567
|
+
* different thing from {@link JOINT_SNAP_INCHES}, which is how close two joints
|
|
2568
|
+
* must be to BE connected. This one is generous; that one is a hundredth of an
|
|
2569
|
+
* inch.
|
|
2570
|
+
*/
|
|
2571
|
+
declare function snapPiece(moving: TrackPiece, others: TrackPiece[], library?: TrackPart[], withinInches?: number): PieceSnap | null;
|
|
2523
2572
|
/** A route the walk found: a continuous run of pieces a train can travel. */
|
|
2524
2573
|
interface GraphRoute {
|
|
2525
2574
|
id: string;
|
|
@@ -2933,4 +2982,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
|
|
|
2933
2982
|
heading: number;
|
|
2934
2983
|
}>;
|
|
2935
2984
|
|
|
2936
|
-
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, 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 EndplateEdge, type EndplateEdgePose, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type GraphAnchor, type GraphConflict, type GraphConnection, type GraphDocInput, type GraphDocResult, type GraphRoute, type GraphTurnout, type GraphWalk, type ImportedPart, type IndustryLabelMode, type IndustrySpot, JOINT_SNAP_INCHES, type LanePinch, 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 OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, type PlacedJoint, RAIL_GAUGE_INCHES, type ResolvedAnchor, type ReturnLoopGeometry, type ReturnLoopShape, type RouteSpan, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackGraph, type TrackPart, type TrackPiece, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
|
|
2985
|
+
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, type BenchworkPoint, type BranchConnector, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, 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 EndplateEdge, type EndplateEdgePose, type EndplatePose, type EndplateTrackIssue, type EndplateWidthIssue, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type FlexPiece, type FlexPieceEnd, type FrogCasting, type GeometryType, type GraphAnchor, type GraphConflict, type GraphConnection, type GraphDocInput, type GraphDocResult, type GraphRoute, type GraphTurnout, type GraphWalk, type ImportedPart, type IndustryLabelMode, type IndustrySpot, JOINT_SNAP_INCHES, type LanePinch, 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 OccupiedSpan, type OutlineFace, PINCH_EASE_INCHES, type PartAngle, type PartDimension, type PartEnd, type PartExtent, type PartGeometry, type PartJoint, type PartJointRole, type PartSegment, type PieceSnap, type PlacedJoint, RAIL_GAUGE_INCHES, type ResolvedAnchor, type ReturnLoopGeometry, type ReturnLoopShape, type RouteSpan, type SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionEnd, type SectionEndAssessment, type SectionFootprint, type SectionJointAssessment, type SectionRelativePos, type SignalFacing, type SignalSide, type SpanOverhang, type StoredTrackPart, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, type TrackConfig, type TrackGraph, type TrackPart, type TrackPiece, type TrackRole, type TurnoutClosure, type TurnoutKind, type UsableCapacity, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
|
package/dist/index.js
CHANGED
|
@@ -2246,6 +2246,54 @@ function partGeometry(part, library = BUILT_IN_TRACK_PARTS) {
|
|
|
2246
2246
|
divergingEndMeasured: de.measured
|
|
2247
2247
|
};
|
|
2248
2248
|
}
|
|
2249
|
+
function pieceRoutePaths(piece, library = BUILT_IN_TRACK_PARTS) {
|
|
2250
|
+
const part = library.find((p) => p.id === piece.partId);
|
|
2251
|
+
if (!part) return [];
|
|
2252
|
+
const geo = partGeometry(part, library);
|
|
2253
|
+
if (!geo) return [];
|
|
2254
|
+
const joints = placedJoints([piece], library);
|
|
2255
|
+
const at = (id) => joints.find((j) => j.joint === id);
|
|
2256
|
+
const RAD = Math.PI / 180;
|
|
2257
|
+
const c = Math.cos(piece.rotationDeg * RAD);
|
|
2258
|
+
const s = Math.sin(piece.rotationDeg * RAD);
|
|
2259
|
+
const place = (x, y) => {
|
|
2260
|
+
const ly = piece.flipped ? -y : y;
|
|
2261
|
+
return { x: piece.x + x * c - ly * s, y: piece.y + x * s + ly * c };
|
|
2262
|
+
};
|
|
2263
|
+
const out = [];
|
|
2264
|
+
for (const route of geo.routes) {
|
|
2265
|
+
const a = at(route[0]);
|
|
2266
|
+
const b = at(route[1]);
|
|
2267
|
+
if (!a || !b) continue;
|
|
2268
|
+
const ends = [{ x: a.x, y: a.y }, { x: b.x, y: b.y }];
|
|
2269
|
+
const diverging = route.some((r) => r === "diverge" || r === "legA" || r === "legB");
|
|
2270
|
+
if (!diverging || part.kind === "flex") {
|
|
2271
|
+
out.push({ route, points: ends });
|
|
2272
|
+
continue;
|
|
2273
|
+
}
|
|
2274
|
+
const lead = part.lead?.inches ?? 0;
|
|
2275
|
+
const pts0 = part.pointsOffset?.inches ?? 0;
|
|
2276
|
+
const far = geo.joints.find((j) => j.id === route[1]) ?? geo.joints.find((j) => j.id === route[0]);
|
|
2277
|
+
if (!far || !(lead > 0)) {
|
|
2278
|
+
out.push({ route, points: ends });
|
|
2279
|
+
continue;
|
|
2280
|
+
}
|
|
2281
|
+
const isWye = part.kind === "wye";
|
|
2282
|
+
const closure = turnoutClosure(isWye ? part.frogNumber * 2 : part.frogNumber, {
|
|
2283
|
+
leadInches: lead
|
|
2284
|
+
});
|
|
2285
|
+
const mirror = route.includes("legB") ? -1 : 1;
|
|
2286
|
+
const pts = [place(0, 0), place(pts0, 0)];
|
|
2287
|
+
const steps = 12;
|
|
2288
|
+
for (let i = 1; i <= steps; i++) {
|
|
2289
|
+
const x = pts0 + (far.x - pts0) * i / steps;
|
|
2290
|
+
pts.push(place(x, mirror * closure.offsetAt(x - pts0)));
|
|
2291
|
+
}
|
|
2292
|
+
pts[pts.length - 1] = { x: b.x, y: b.y };
|
|
2293
|
+
out.push({ route, points: route[0] === "throat" ? pts : pts.slice().reverse() });
|
|
2294
|
+
}
|
|
2295
|
+
return out;
|
|
2296
|
+
}
|
|
2249
2297
|
function partsPlaceable(library = BUILT_IN_TRACK_PARTS) {
|
|
2250
2298
|
const placeable = [];
|
|
2251
2299
|
const blocked = [];
|
|
@@ -2330,6 +2378,36 @@ function buildTrackGraph(pieces, library = BUILT_IN_TRACK_PARTS, snapInches = JO
|
|
|
2330
2378
|
}
|
|
2331
2379
|
return { joints, connections, open, conflicts, unplaceable };
|
|
2332
2380
|
}
|
|
2381
|
+
function snapPiece(moving, others, library = BUILT_IN_TRACK_PARTS, withinInches = 0.5) {
|
|
2382
|
+
const mine = placedJoints([moving], library);
|
|
2383
|
+
if (!mine.length) return null;
|
|
2384
|
+
const graph = buildTrackGraph(others, library);
|
|
2385
|
+
const taken = new Set(graph.connections.flatMap((c2) => [c2.a, c2.b]));
|
|
2386
|
+
const open = graph.joints.filter((j) => !taken.has(j.key));
|
|
2387
|
+
let best = null;
|
|
2388
|
+
for (const m of mine)
|
|
2389
|
+
for (const t of open) {
|
|
2390
|
+
const d = Math.hypot(t.x - m.x, t.y - m.y);
|
|
2391
|
+
if (d <= withinInches && (!best || d < best.d)) best = { m, t, d };
|
|
2392
|
+
}
|
|
2393
|
+
if (!best) return null;
|
|
2394
|
+
const RAD = Math.PI / 180;
|
|
2395
|
+
const dRot = norm360(best.t.headingDeg + 180 - best.m.headingDeg);
|
|
2396
|
+
const c = Math.cos(dRot * RAD);
|
|
2397
|
+
const s = Math.sin(dRot * RAD);
|
|
2398
|
+
const ox = moving.x - best.m.x;
|
|
2399
|
+
const oy = moving.y - best.m.y;
|
|
2400
|
+
return {
|
|
2401
|
+
piece: {
|
|
2402
|
+
...moving,
|
|
2403
|
+
rotationDeg: norm360(moving.rotationDeg + dRot),
|
|
2404
|
+
x: best.t.x + ox * c - oy * s,
|
|
2405
|
+
y: best.t.y + ox * s + oy * c
|
|
2406
|
+
},
|
|
2407
|
+
from: best.m.key,
|
|
2408
|
+
to: best.t.key
|
|
2409
|
+
};
|
|
2410
|
+
}
|
|
2333
2411
|
function walkTrackGraph(graph, pieces, startAt, library = BUILT_IN_TRACK_PARTS) {
|
|
2334
2412
|
const byKey = new Map(graph.joints.map((j) => [j.key, j]));
|
|
2335
2413
|
const pieceById = new Map(pieces.map((p) => [p.id, p]));
|
|
@@ -3243,6 +3321,6 @@ function poseOverridesFromDoc(doc) {
|
|
|
3243
3321
|
return out;
|
|
3244
3322
|
}
|
|
3245
3323
|
|
|
3246
|
-
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, JOINT_SNAP_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, PINCH_EASE_INCHES, RAIL_GAUGE_INCHES, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
|
|
3324
|
+
export { ATLAS_CODE55_N, BUILT_IN_TRACK_PARTS, CLEARANCE_SPACING_INCHES, CODE55_RAIL_HEIGHT_INCHES, DEFAULT_FLEX_PART_ID, ENDPLATE_FASCIA_CLEAR_INCHES, ENDPLATE_LEAD_INCHES, FAST_TRACKS_N_ME55, FAST_TRACKS_N_ME55_CROSSOVERS, FLEX_TRACK_PARTS, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, JOINT_SNAP_INCHES, MAIN2_TRACK_ID, MAIN_TRACK_ID, N_CAR_LENGTH_INCHES, N_SCALE_RATIO, PINCH_EASE_INCHES, RAIL_GAUGE_INCHES, TIE_HALF_LENGTH_INCHES, TURNOUT_LEAD_INCHES_PER_FROG, WHOLE_MODULE_SECTION_ID, asModuleSchematic, assessSectionEnd, assessSectionJoint, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTrackGraph, buildTransition, carCapacity, checkEndplateWidth, clearancePointPastFrogInches, crossoverPinches, deriveEndplatePoses, deriveGraphDoc, divergeSideForHand, docToState, emptyEditorState, endplateCentreOffsetInches, endplateEdgePose, endplateFaceSegments, endplateLead, endplateTrackOffsetInches, endplateWidthInches, flexPartFor, flexParts, flexPieces, flexUsage, frogCasting, frogNumberFromName, fromSectionRelative, geometryTurnDegrees, graphToDoc, hasNoFarEndplate, importedPartToTrackPart, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, laneOffsetAt, leadInchesForSize, maxFlexPieceInches, mergeImportedParts, mergeStoredParts, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, parseXtpLibrary, partExtent, partExtentForSize, partGeometry, partGeometryGap, partOutlineAtFrog, partsPlaceable, pastFrogInchesForSize, pathLengthInches, pieceRoutePaths, placedJoints, poseNeedsManual, poseOverridesFromDoc, remapPos, resizeFlexPiece, resolveGraphAnchor, returnLoop, sampleBenchworkOutline, samplePartSegments, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionSpansOrWhole, sectionedCenterline, sectionedEndPose, sliceCenterline, snapPiece, spanOverhang, stateToDoc, storedPartToTrackPart, toSectionRelative, trackMeetsEndplateIssues, trackPart, trackPath, turnoutClosure, turnoutFacing, turnoutOccupiedSpan, turnoutPartForSize, usableCapacity, walkTrackGraph };
|
|
3247
3325
|
//# sourceMappingURL=index.js.map
|
|
3248
3326
|
//# sourceMappingURL=index.js.map
|