Checkpoint variable page segment lengths

This commit is contained in:
2026-06-05 15:39:18 +02:00
parent fd608ba217
commit e88ab8c48b
2 changed files with 16 additions and 5 deletions
+15 -4
View File
@@ -73,7 +73,7 @@ const PAGE_COUNT_MIN = 40;
const PAGE_COUNT_STEP = 10;
const PAGE_WIDTH = 1.62;
const PAGE_SPLINE_LENGTH = 1.955;
const PAGE_LINE_SEGMENTS = 24;
const PAGE_LINE_SEGMENTS = 48;
const PAGE_DEPTH = 2.24;
const COVER_DEPTH = 2.30;
const COVER_OVERHANG = (COVER_DEPTH - PAGE_DEPTH) * 0.5;
@@ -489,7 +489,7 @@ function solvedStackOuterX(lines) {
function simulatePageLines(bundleCount, pageWidth, pageSplineLength, spineWidth, foreEdgeX, bundleSpacing, leftCount) {
const lines = [];
const segments = PAGE_LINE_SEGMENTS;
const stepLength = pageSplineLength / segments;
const segmentLengths = pageSegmentLengths(pageSplineLength, segments);
const entries = [];
const spineArc = buildSpineArcSamples(spineWidth);
const rightCount = bundleCount - leftCount;
@@ -531,7 +531,7 @@ function simulatePageLines(bundleCount, pageWidth, pageSplineLength, spineWidth,
sideEntries.forEach((entry, rank) => {
const anchor = spineCurvePoint(entry.t, spineWidth);
const target = restingTarget(side, foreEdgeX, rank, sideEntries.length, bundleSpacing);
const points = buildSupportSolvedLine(anchor, target, lowerLine, side, segments, stepLength, bundleCount, bundleSpacing);
const points = buildSupportSolvedLine(anchor, target, lowerLine, side, segments, segmentLengths, bundleCount, bundleSpacing);
const line = { index: entry.index, t: entry.t, side, anchor, points, endpoint: points[points.length - 1], isHairPage: entry.isHairPage === true };
lines.push(line);
lowerLine = line;
@@ -605,6 +605,16 @@ function pointAtSpineArcLength(spineArc, targetLength) {
return spineCurvePoint(t, spineArc.spineWidth);
}
function pageSegmentLengths(totalLength, segments) {
const weights = [];
for (let index = 0; index < segments; index += 1) {
const u = index / Math.max(1, segments - 1);
weights.push(0.32 + 1.68 * u * u);
}
const weightTotal = weights.reduce((sum, weight) => sum + weight, 0);
return weights.map((weight) => totalLength * weight / weightTotal);
}
function initialPageLine(anchor, target, segments) {
const points = [];
for (let i = 0; i <= segments; i += 1) {
@@ -626,11 +636,12 @@ function restingTarget(side, foreEdgeX, rank, sideCount, bundleSpacing) {
return { x, y };
}
function buildSupportSolvedLine(anchor, target, lowerLine, side, segments, stepLength, bundleCount, bundleSpacing) {
function buildSupportSolvedLine(anchor, target, lowerLine, side, segments, segmentLengths, bundleCount, bundleSpacing) {
const points = [{ x: anchor.x, y: anchor.y }];
let tangent = coverTangentAtX(anchor.x, side);
for (let index = 1; index <= segments; index += 1) {
const u = index / segments;
const stepLength = segmentLengths[index - 1];
const supportTangent = lowerLine ? lineTangentAt(lowerLine.points, index) : coverTangentAtX(points[index - 1].x, side);
const point = chooseClosestSupportedPoint(points[index - 1], tangent, supportTangent, target, lowerLine, index, side, stepLength, bundleCount, bundleSpacing, u);
points.push(point);
+1 -1
View File
@@ -74,6 +74,6 @@
<button id="fast_forward" type="button">Fast Forward</button>
<output id="flip_count">0 / 10</output>
</div>
<script type="module" src="/js/webgl-book-shape-lab.js?v=cover-segment-floor-1"></script>
<script type="module" src="/js/webgl-book-shape-lab.js?v=double-page-segments-1"></script>
</body>
</html>