@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.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)];
|