@willcgage/module-schematic 0.32.0 → 0.33.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 +32 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.js +32 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -438,6 +438,19 @@ declare function sectionBreaksFromSections(doc: {
|
|
|
438
438
|
* a module like One Mile expressible: straight boards with two 24″ curved ones
|
|
439
439
|
* in the middle, which no single module-level geometry can describe (#108).
|
|
440
440
|
* Returns [] when the module has no sections with lengths. */
|
|
441
|
+
/** Where the chained boards finish, and on what heading — computed from the
|
|
442
|
+
* section geometry itself rather than read off the sampled polyline. A curve
|
|
443
|
+
* is sampled in steps, so the last chord lags the true tangent by half a step
|
|
444
|
+
* (a 90° board sampled 12 ways reads 86.25°). That error would land straight
|
|
445
|
+
* in endplate B's heading and throw off face-to-face snapping, so the exact
|
|
446
|
+
* value is accumulated here instead. Null when there are no sections. */
|
|
447
|
+
declare function sectionedEndPose(doc: {
|
|
448
|
+
sections?: SchematicSection[] | null;
|
|
449
|
+
} | null | undefined): {
|
|
450
|
+
x: number;
|
|
451
|
+
y: number;
|
|
452
|
+
heading: number;
|
|
453
|
+
} | null;
|
|
441
454
|
declare function sectionedCenterline(doc: {
|
|
442
455
|
sections?: SchematicSection[] | null;
|
|
443
456
|
} | null | undefined): BenchworkPoint[];
|
|
@@ -949,6 +962,10 @@ interface ModuleGeometryInput {
|
|
|
949
962
|
/** Half the spacing between the two tracks of a double endplate (Free-mo ≈ 1",
|
|
950
963
|
* Free-moN ≈ 9/16"). */
|
|
951
964
|
trackHalfSpacingInches?: number;
|
|
965
|
+
/** The module's sections. When present they define the module's real shape,
|
|
966
|
+
* so endplate B lands at the end of the CHAINED boards rather than where a
|
|
967
|
+
* single module-level geometry would have put it (#108). */
|
|
968
|
+
sections?: SchematicSection[] | null;
|
|
952
969
|
}
|
|
953
970
|
/** Signed turn a module applies to the through track (CCW/left positive). */
|
|
954
971
|
declare function geometryTurnDegrees(geometryType?: string | null, geometryDegrees?: number | null): number;
|
|
@@ -971,4 +988,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
|
|
|
971
988
|
heading: number;
|
|
972
989
|
}>;
|
|
973
990
|
|
|
974
|
-
export { type BenchworkPoint, type BranchConnector, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type GeometryType, 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 SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SignalFacing, type SignalSide, type TrackConfig, type TrackRole, type TurnoutKind, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionedCenterline, sliceCenterline, stateToDoc, trackPath };
|
|
991
|
+
export { type BenchworkPoint, type BranchConnector, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type GeometryType, 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 SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SignalFacing, type SignalSide, type TrackConfig, type TrackRole, type TurnoutKind, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, trackPath };
|
package/dist/index.d.ts
CHANGED
|
@@ -438,6 +438,19 @@ declare function sectionBreaksFromSections(doc: {
|
|
|
438
438
|
* a module like One Mile expressible: straight boards with two 24″ curved ones
|
|
439
439
|
* in the middle, which no single module-level geometry can describe (#108).
|
|
440
440
|
* Returns [] when the module has no sections with lengths. */
|
|
441
|
+
/** Where the chained boards finish, and on what heading — computed from the
|
|
442
|
+
* section geometry itself rather than read off the sampled polyline. A curve
|
|
443
|
+
* is sampled in steps, so the last chord lags the true tangent by half a step
|
|
444
|
+
* (a 90° board sampled 12 ways reads 86.25°). That error would land straight
|
|
445
|
+
* in endplate B's heading and throw off face-to-face snapping, so the exact
|
|
446
|
+
* value is accumulated here instead. Null when there are no sections. */
|
|
447
|
+
declare function sectionedEndPose(doc: {
|
|
448
|
+
sections?: SchematicSection[] | null;
|
|
449
|
+
} | null | undefined): {
|
|
450
|
+
x: number;
|
|
451
|
+
y: number;
|
|
452
|
+
heading: number;
|
|
453
|
+
} | null;
|
|
441
454
|
declare function sectionedCenterline(doc: {
|
|
442
455
|
sections?: SchematicSection[] | null;
|
|
443
456
|
} | null | undefined): BenchworkPoint[];
|
|
@@ -949,6 +962,10 @@ interface ModuleGeometryInput {
|
|
|
949
962
|
/** Half the spacing between the two tracks of a double endplate (Free-mo ≈ 1",
|
|
950
963
|
* Free-moN ≈ 9/16"). */
|
|
951
964
|
trackHalfSpacingInches?: number;
|
|
965
|
+
/** The module's sections. When present they define the module's real shape,
|
|
966
|
+
* so endplate B lands at the end of the CHAINED boards rather than where a
|
|
967
|
+
* single module-level geometry would have put it (#108). */
|
|
968
|
+
sections?: SchematicSection[] | null;
|
|
952
969
|
}
|
|
953
970
|
/** Signed turn a module applies to the through track (CCW/left positive). */
|
|
954
971
|
declare function geometryTurnDegrees(geometryType?: string | null, geometryDegrees?: number | null): number;
|
|
@@ -971,4 +988,4 @@ declare function poseOverridesFromDoc(doc: ModuleSchematicDoc): Record<string, {
|
|
|
971
988
|
heading: number;
|
|
972
989
|
}>;
|
|
973
990
|
|
|
974
|
-
export { type BenchworkPoint, type BranchConnector, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type GeometryType, 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 SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SignalFacing, type SignalSide, type TrackConfig, type TrackRole, type TurnoutKind, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionedCenterline, sliceCenterline, stateToDoc, trackPath };
|
|
991
|
+
export { type BenchworkPoint, type BranchConnector, type DrawCrossing, type DrawCrossover, type DrawIndustry, type DrawSignal, type DrawTrack, type DrawTurnout, type EditorBranch, type EditorControlPoint, type EditorCpSignal, type EditorCrossing, type EditorIndustry, type EditorState, type EditorTrack, type EditorTurnout, type EndplateBConfig, type EndplatePose, type EndplateWidthIssue, FREEMO_ENDPLATE_TRACK_FASCIA_CLEARANCE_INCHES, FREEMO_ENDPLATE_WIDTH_MIN_INCHES, FREEMO_ENDPLATE_WIDTH_RECOMMENDED_INCHES, FREEMO_TRACK_SPACING_INCHES, type GeometryType, 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 SchematicBlock, type SchematicControlPoint, type SchematicCrossing, type SchematicEndplate, type SchematicEndplateTrack, type SchematicIndustry, type SchematicSection, type SchematicSignal, type SchematicTrack, type SchematicTurnout, type SectionAdjacency, type SectionFootprint, type SignalFacing, type SignalSide, type TrackConfig, type TrackRole, type TurnoutKind, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, trackPath };
|
package/dist/index.js
CHANGED
|
@@ -209,6 +209,24 @@ function sectionBreaksFromSections(doc) {
|
|
|
209
209
|
const spans = sectionSpans(doc);
|
|
210
210
|
return spans.slice(0, -1).map((sp) => sp.toPos);
|
|
211
211
|
}
|
|
212
|
+
function sectionedEndPose(doc) {
|
|
213
|
+
const secs = moduleSections(doc).filter(
|
|
214
|
+
(sec) => typeof sec.lengthInches === "number" && sec.lengthInches > 0
|
|
215
|
+
);
|
|
216
|
+
if (!secs.length) return null;
|
|
217
|
+
let ox = 0;
|
|
218
|
+
let oy = 0;
|
|
219
|
+
let heading = 0;
|
|
220
|
+
for (const sec of secs) {
|
|
221
|
+
const local = sectionCenterlineLocal(sec);
|
|
222
|
+
const c = Math.cos(heading * DEG_FP);
|
|
223
|
+
const sn = Math.sin(heading * DEG_FP);
|
|
224
|
+
ox += local.endX * c - local.endY * sn;
|
|
225
|
+
oy += local.endX * sn + local.endY * c;
|
|
226
|
+
heading += local.endHeadingDeg;
|
|
227
|
+
}
|
|
228
|
+
return { x: ox, y: oy, heading };
|
|
229
|
+
}
|
|
212
230
|
function sectionedCenterline(doc) {
|
|
213
231
|
const secs = moduleSections(doc).filter(
|
|
214
232
|
(sec) => typeof sec.lengthInches === "number" && sec.lengthInches > 0
|
|
@@ -1281,7 +1299,19 @@ function deriveEndplatePoses(geo) {
|
|
|
1281
1299
|
})
|
|
1282
1300
|
);
|
|
1283
1301
|
const noB = geo.geometryType === "dead_end";
|
|
1284
|
-
|
|
1302
|
+
const end = sectionedEndPose({ sections: geo.sections });
|
|
1303
|
+
if (!noB && end) {
|
|
1304
|
+
poses.push(
|
|
1305
|
+
withOverride({
|
|
1306
|
+
id: "B",
|
|
1307
|
+
x: end.x,
|
|
1308
|
+
y: end.y,
|
|
1309
|
+
heading: norm360(end.heading),
|
|
1310
|
+
trackConfig: cfg(1),
|
|
1311
|
+
trackOffsets: offsetsFor(cfg(1), half)
|
|
1312
|
+
})
|
|
1313
|
+
);
|
|
1314
|
+
} else if (!noB) {
|
|
1285
1315
|
const turn = geometryTurnDegrees(geo.geometryType, geo.geometryDegrees);
|
|
1286
1316
|
let bx;
|
|
1287
1317
|
let by;
|
|
@@ -1342,6 +1372,6 @@ function poseOverridesFromDoc(doc) {
|
|
|
1342
1372
|
return out;
|
|
1343
1373
|
}
|
|
1344
1374
|
|
|
1345
|
-
export { 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, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionedCenterline, sliceCenterline, stateToDoc, trackPath };
|
|
1375
|
+
export { 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, asModuleSchematic, benchworkBand, benchworkOutline, buildCrossover, buildPassingSiding, buildTransition, carCapacity, checkEndplateWidth, deriveEndplatePoses, divergeSideForHand, docToState, emptyEditorState, endplateFaceSegments, endplateTrackOffsetFor, endplateTrackOffsetInches, endplateWidthInches, geometryTurnDegrees, inchesToScaleFeet, isLoopDoc, isTransitionTurnout, moduleCenterline, moduleFeatures, moduleFootprint, moduleLengthFromSections, moduleSections, nextId, poseNeedsManual, poseOverridesFromDoc, sampleBenchworkOutline, samplePath, scaleFeetToInches, sectionAdjacency, sectionBand, sectionBreaksFromSections, sectionComponents, sectionFootprints, sectionNeighbours, sectionSpans, sectionedCenterline, sectionedEndPose, sliceCenterline, stateToDoc, trackPath };
|
|
1346
1376
|
//# sourceMappingURL=index.js.map
|
|
1347
1377
|
//# sourceMappingURL=index.js.map
|