@willcgage/module-schematic 0.101.0 → 0.103.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 +49 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +49 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3212,7 +3212,25 @@ function docToGraph(doc, answers = {}, library = BUILT_IN_TRACK_PARTS) {
|
|
|
3212
3212
|
);
|
|
3213
3213
|
return out;
|
|
3214
3214
|
};
|
|
3215
|
-
const turnoutsOn = (trackId, hostY) =>
|
|
3215
|
+
const turnoutsOn = (trackId, hostY) => {
|
|
3216
|
+
const laid = turnouts.filter((t) => t.onTrack === trackId && chosen.has(t.id)).map((t) => layTurnout(t, hostY)).sort((a, b) => a.span.fromPos - b.span.fromPos);
|
|
3217
|
+
const clashed = /* @__PURE__ */ new Set();
|
|
3218
|
+
for (let i = 1; i < laid.length; i += 1) {
|
|
3219
|
+
const prev = laid[i - 1];
|
|
3220
|
+
const cur = laid[i];
|
|
3221
|
+
if (cur.span.fromPos < prev.span.toPos - 1e-6) {
|
|
3222
|
+
clashed.add(prev.t.id);
|
|
3223
|
+
clashed.add(cur.t.id);
|
|
3224
|
+
const gap = Math.abs(cur.t.pos - prev.t.pos);
|
|
3225
|
+
const body = prev.span.toPos - prev.span.fromPos;
|
|
3226
|
+
notLaid.push({
|
|
3227
|
+
id: cur.t.divergeTrack,
|
|
3228
|
+
why: `${prev.t.name || prev.t.id} and ${cur.t.name || cur.t.id} are ${gap.toFixed(1)}\u2033 apart on the same track, but the turnout chosen is ${body.toFixed(1)}\u2033 long \u2014 their mouldings would overlap, which is why this is sold as one assembly rather than two turnouts`
|
|
3229
|
+
});
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
return laid.filter((l) => !clashed.has(l.t.id));
|
|
3233
|
+
};
|
|
3216
3234
|
const main = trackById.get(MAIN_TRACK_ID) ?? tracks.find((t) => t.role === "main");
|
|
3217
3235
|
if (!main) return refuse("this module's document has no mainline to convert");
|
|
3218
3236
|
const mains = [main, ...tracks.filter((t) => t.role === "main" && t.id !== main.id)];
|
|
@@ -3244,6 +3262,35 @@ function docToGraph(doc, answers = {}, library = BUILT_IN_TRACK_PARTS) {
|
|
|
3244
3262
|
notLaid.push({ id: branch.id, why: `turnout ${t.id} has no diverging end to leave from` });
|
|
3245
3263
|
continue;
|
|
3246
3264
|
}
|
|
3265
|
+
const farSw0 = turnouts.find(
|
|
3266
|
+
(o) => o.id !== t.id && o.divergeTrack === branch.id && laidTurnouts.has(o.id)
|
|
3267
|
+
);
|
|
3268
|
+
const farJoint0 = farSw0 ? (() => {
|
|
3269
|
+
const f = laidTurnouts.get(farSw0.id);
|
|
3270
|
+
return jointAt(f.piece, f.divergeId);
|
|
3271
|
+
})() : null;
|
|
3272
|
+
if (branch.role === "crossover" && farJoint0) {
|
|
3273
|
+
const dx = farJoint0.x - dj.x;
|
|
3274
|
+
const dy = farJoint0.y - dj.y;
|
|
3275
|
+
const len = Math.hypot(dx, dy);
|
|
3276
|
+
if (len > 1e-6) {
|
|
3277
|
+
pieces.push({
|
|
3278
|
+
id: `x-${branch.id}`,
|
|
3279
|
+
partId: flexId,
|
|
3280
|
+
x: dj.x,
|
|
3281
|
+
y: dj.y,
|
|
3282
|
+
rotationDeg: Math.atan2(dy, dx) * 180 / Math.PI,
|
|
3283
|
+
lengthInches: r3(len),
|
|
3284
|
+
...branch.trackName ? { name: branch.trackName } : {}
|
|
3285
|
+
});
|
|
3286
|
+
} else {
|
|
3287
|
+
notLaid.push({
|
|
3288
|
+
id: branch.id,
|
|
3289
|
+
why: "this crossover's two turnouts meet at the same point, so there is no connector between them to lay"
|
|
3290
|
+
});
|
|
3291
|
+
}
|
|
3292
|
+
continue;
|
|
3293
|
+
}
|
|
3247
3294
|
const branchY = laneOffsetAt(branch.lane ?? 0, 0);
|
|
3248
3295
|
const curve = transition(branch.id, { x: dj.x, y: dj.y, headingDeg: dj.headingDeg }, branchY);
|
|
3249
3296
|
let start = { x: dj.x, y: dj.y, headingDeg: dj.headingDeg };
|
|
@@ -3252,13 +3299,7 @@ function docToGraph(doc, answers = {}, library = BUILT_IN_TRACK_PARTS) {
|
|
|
3252
3299
|
const e = jointAt(curve, "b");
|
|
3253
3300
|
if (e) start = { x: e.x, y: e.y, headingDeg: e.headingDeg };
|
|
3254
3301
|
}
|
|
3255
|
-
const
|
|
3256
|
-
(o) => o.id !== t.id && o.divergeTrack === branch.id && laidTurnouts.has(o.id)
|
|
3257
|
-
);
|
|
3258
|
-
const farJoint = farSw ? (() => {
|
|
3259
|
-
const f = laidTurnouts.get(farSw.id);
|
|
3260
|
-
return jointAt(f.piece, f.divergeId);
|
|
3261
|
-
})() : null;
|
|
3302
|
+
const farJoint = farJoint0;
|
|
3262
3303
|
let endX = farJoint != null ? farJoint.x : Math.max(branch.fromPos ?? t.pos, branch.toPos ?? t.pos);
|
|
3263
3304
|
let farCurve = null;
|
|
3264
3305
|
if (farJoint) {
|