@willcgage/module-schematic 0.102.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 +19 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +19 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3214,7 +3214,25 @@ function docToGraph(doc, answers = {}, library = BUILT_IN_TRACK_PARTS) {
|
|
|
3214
3214
|
);
|
|
3215
3215
|
return out;
|
|
3216
3216
|
};
|
|
3217
|
-
const turnoutsOn = (trackId, hostY) =>
|
|
3217
|
+
const turnoutsOn = (trackId, hostY) => {
|
|
3218
|
+
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);
|
|
3219
|
+
const clashed = /* @__PURE__ */ new Set();
|
|
3220
|
+
for (let i = 1; i < laid.length; i += 1) {
|
|
3221
|
+
const prev = laid[i - 1];
|
|
3222
|
+
const cur = laid[i];
|
|
3223
|
+
if (cur.span.fromPos < prev.span.toPos - 1e-6) {
|
|
3224
|
+
clashed.add(prev.t.id);
|
|
3225
|
+
clashed.add(cur.t.id);
|
|
3226
|
+
const gap = Math.abs(cur.t.pos - prev.t.pos);
|
|
3227
|
+
const body = prev.span.toPos - prev.span.fromPos;
|
|
3228
|
+
notLaid.push({
|
|
3229
|
+
id: cur.t.divergeTrack,
|
|
3230
|
+
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`
|
|
3231
|
+
});
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
return laid.filter((l) => !clashed.has(l.t.id));
|
|
3235
|
+
};
|
|
3218
3236
|
const main = trackById.get(MAIN_TRACK_ID) ?? tracks.find((t) => t.role === "main");
|
|
3219
3237
|
if (!main) return refuse("this module's document has no mainline to convert");
|
|
3220
3238
|
const mains = [main, ...tracks.filter((t) => t.role === "main" && t.id !== main.id)];
|