@willcgage/module-schematic 0.101.0 → 0.102.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 CHANGED
@@ -3246,6 +3246,35 @@ function docToGraph(doc, answers = {}, library = BUILT_IN_TRACK_PARTS) {
3246
3246
  notLaid.push({ id: branch.id, why: `turnout ${t.id} has no diverging end to leave from` });
3247
3247
  continue;
3248
3248
  }
3249
+ const farSw0 = turnouts.find(
3250
+ (o) => o.id !== t.id && o.divergeTrack === branch.id && laidTurnouts.has(o.id)
3251
+ );
3252
+ const farJoint0 = farSw0 ? (() => {
3253
+ const f = laidTurnouts.get(farSw0.id);
3254
+ return jointAt(f.piece, f.divergeId);
3255
+ })() : null;
3256
+ if (branch.role === "crossover" && farJoint0) {
3257
+ const dx = farJoint0.x - dj.x;
3258
+ const dy = farJoint0.y - dj.y;
3259
+ const len = Math.hypot(dx, dy);
3260
+ if (len > 1e-6) {
3261
+ pieces.push({
3262
+ id: `x-${branch.id}`,
3263
+ partId: flexId,
3264
+ x: dj.x,
3265
+ y: dj.y,
3266
+ rotationDeg: Math.atan2(dy, dx) * 180 / Math.PI,
3267
+ lengthInches: r3(len),
3268
+ ...branch.trackName ? { name: branch.trackName } : {}
3269
+ });
3270
+ } else {
3271
+ notLaid.push({
3272
+ id: branch.id,
3273
+ why: "this crossover's two turnouts meet at the same point, so there is no connector between them to lay"
3274
+ });
3275
+ }
3276
+ continue;
3277
+ }
3249
3278
  const branchY = laneOffsetAt(branch.lane ?? 0, 0);
3250
3279
  const curve = transition(branch.id, { x: dj.x, y: dj.y, headingDeg: dj.headingDeg }, branchY);
3251
3280
  let start = { x: dj.x, y: dj.y, headingDeg: dj.headingDeg };
@@ -3254,13 +3283,7 @@ function docToGraph(doc, answers = {}, library = BUILT_IN_TRACK_PARTS) {
3254
3283
  const e = jointAt(curve, "b");
3255
3284
  if (e) start = { x: e.x, y: e.y, headingDeg: e.headingDeg };
3256
3285
  }
3257
- const farSw = turnouts.find(
3258
- (o) => o.id !== t.id && o.divergeTrack === branch.id && laidTurnouts.has(o.id)
3259
- );
3260
- const farJoint = farSw ? (() => {
3261
- const f = laidTurnouts.get(farSw.id);
3262
- return jointAt(f.piece, f.divergeId);
3263
- })() : null;
3286
+ const farJoint = farJoint0;
3264
3287
  let endX = farJoint != null ? farJoint.x : Math.max(branch.fromPos ?? t.pos, branch.toPos ?? t.pos);
3265
3288
  let farCurve = null;
3266
3289
  if (farJoint) {