@willcgage/module-schematic 0.58.0 → 0.59.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 +23 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +24 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1446,13 +1446,33 @@ function turnoutClosure(size, opts = {}) {
|
|
|
1446
1446
|
const frogSlope = 1 / N;
|
|
1447
1447
|
const k = (lead / N - g) / (lead * lead);
|
|
1448
1448
|
const switchSlope = Math.max(0, frogSlope - 2 * k * lead);
|
|
1449
|
+
const target = opts.arriveAtInches;
|
|
1450
|
+
let a = Infinity;
|
|
1451
|
+
let b = 0;
|
|
1452
|
+
if (target != null && target > g) {
|
|
1453
|
+
b = Math.max(0.01, opts.easeInches ?? lead);
|
|
1454
|
+
a = (target - g) / frogSlope - b / 2;
|
|
1455
|
+
if (a < 0) {
|
|
1456
|
+
a = 0;
|
|
1457
|
+
b = 2 * (target - g) / frogSlope;
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
const span = target != null && target > g ? lead + a + b : Infinity;
|
|
1449
1461
|
return {
|
|
1450
1462
|
lead,
|
|
1451
1463
|
switchSlope,
|
|
1452
1464
|
frogSlope,
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
offsetAt: (s) =>
|
|
1465
|
+
span,
|
|
1466
|
+
easeInches: b,
|
|
1467
|
+
offsetAt: (s) => {
|
|
1468
|
+
if (s <= lead) return switchSlope * s + k * s * s;
|
|
1469
|
+
const past = s - lead;
|
|
1470
|
+
if (past <= a) return g + frogSlope * past;
|
|
1471
|
+
if (target == null) return g + frogSlope * past;
|
|
1472
|
+
const u = Math.min(past - a, b);
|
|
1473
|
+
const eased = g + frogSlope * a + frogSlope * u - frogSlope * u * u / (2 * b);
|
|
1474
|
+
return past - a >= b ? target : eased;
|
|
1475
|
+
}
|
|
1456
1476
|
};
|
|
1457
1477
|
}
|
|
1458
1478
|
function divergeSideForHand(kind, stubDir, flipped) {
|