Checkpoint variable page segment lengths
This commit is contained in:
@@ -73,7 +73,7 @@ const PAGE_COUNT_MIN = 40;
|
|||||||
const PAGE_COUNT_STEP = 10;
|
const PAGE_COUNT_STEP = 10;
|
||||||
const PAGE_WIDTH = 1.62;
|
const PAGE_WIDTH = 1.62;
|
||||||
const PAGE_SPLINE_LENGTH = 1.955;
|
const PAGE_SPLINE_LENGTH = 1.955;
|
||||||
const PAGE_LINE_SEGMENTS = 24;
|
const PAGE_LINE_SEGMENTS = 48;
|
||||||
const PAGE_DEPTH = 2.24;
|
const PAGE_DEPTH = 2.24;
|
||||||
const COVER_DEPTH = 2.30;
|
const COVER_DEPTH = 2.30;
|
||||||
const COVER_OVERHANG = (COVER_DEPTH - PAGE_DEPTH) * 0.5;
|
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) {
|
function simulatePageLines(bundleCount, pageWidth, pageSplineLength, spineWidth, foreEdgeX, bundleSpacing, leftCount) {
|
||||||
const lines = [];
|
const lines = [];
|
||||||
const segments = PAGE_LINE_SEGMENTS;
|
const segments = PAGE_LINE_SEGMENTS;
|
||||||
const stepLength = pageSplineLength / segments;
|
const segmentLengths = pageSegmentLengths(pageSplineLength, segments);
|
||||||
const entries = [];
|
const entries = [];
|
||||||
const spineArc = buildSpineArcSamples(spineWidth);
|
const spineArc = buildSpineArcSamples(spineWidth);
|
||||||
const rightCount = bundleCount - leftCount;
|
const rightCount = bundleCount - leftCount;
|
||||||
@@ -531,7 +531,7 @@ function simulatePageLines(bundleCount, pageWidth, pageSplineLength, spineWidth,
|
|||||||
sideEntries.forEach((entry, rank) => {
|
sideEntries.forEach((entry, rank) => {
|
||||||
const anchor = spineCurvePoint(entry.t, spineWidth);
|
const anchor = spineCurvePoint(entry.t, spineWidth);
|
||||||
const target = restingTarget(side, foreEdgeX, rank, sideEntries.length, bundleSpacing);
|
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 };
|
const line = { index: entry.index, t: entry.t, side, anchor, points, endpoint: points[points.length - 1], isHairPage: entry.isHairPage === true };
|
||||||
lines.push(line);
|
lines.push(line);
|
||||||
lowerLine = line;
|
lowerLine = line;
|
||||||
@@ -605,6 +605,16 @@ function pointAtSpineArcLength(spineArc, targetLength) {
|
|||||||
return spineCurvePoint(t, spineArc.spineWidth);
|
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) {
|
function initialPageLine(anchor, target, segments) {
|
||||||
const points = [];
|
const points = [];
|
||||||
for (let i = 0; i <= segments; i += 1) {
|
for (let i = 0; i <= segments; i += 1) {
|
||||||
@@ -626,11 +636,12 @@ function restingTarget(side, foreEdgeX, rank, sideCount, bundleSpacing) {
|
|||||||
return { x, y };
|
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 }];
|
const points = [{ x: anchor.x, y: anchor.y }];
|
||||||
let tangent = coverTangentAtX(anchor.x, side);
|
let tangent = coverTangentAtX(anchor.x, side);
|
||||||
for (let index = 1; index <= segments; index += 1) {
|
for (let index = 1; index <= segments; index += 1) {
|
||||||
const u = index / segments;
|
const u = index / segments;
|
||||||
|
const stepLength = segmentLengths[index - 1];
|
||||||
const supportTangent = lowerLine ? lineTangentAt(lowerLine.points, index) : coverTangentAtX(points[index - 1].x, side);
|
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);
|
const point = chooseClosestSupportedPoint(points[index - 1], tangent, supportTangent, target, lowerLine, index, side, stepLength, bundleCount, bundleSpacing, u);
|
||||||
points.push(point);
|
points.push(point);
|
||||||
|
|||||||
@@ -74,6 +74,6 @@
|
|||||||
<button id="fast_forward" type="button">Fast Forward</button>
|
<button id="fast_forward" type="button">Fast Forward</button>
|
||||||
<output id="flip_count">0 / 10</output>
|
<output id="flip_count">0 / 10</output>
|
||||||
</div>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
Reference in New Issue
Block a user