diff --git a/public/js/webgl-book-shape-lab.js b/public/js/webgl-book-shape-lab.js index d75111f..dfe02aa 100644 --- a/public/js/webgl-book-shape-lab.js +++ b/public/js/webgl-book-shape-lab.js @@ -214,10 +214,11 @@ function rebuildBook() { const bundleCount = Math.max(4, Math.round(pageCount / 10)); const spineWidth = calculateSpineWidth(bundleCount); const leftCount = calculateLeftBundleCount(bundleCount); - const hingeX = spineWidth * 0.5 + HINGE_INSET; - const foreEdgeX = spineWidth * 0.5 + pageWidth; + const spineHalf = spineArcHalf(spineWidth); + const hingeX = spineHalf + HINGE_INSET; + const foreEdgeX = spineHalf + pageWidth; const bundleSpacing = calculateBundleSpacing(bundleCount, spineWidth, leftCount); - activeSpineHalf = spineWidth * 0.5; + activeSpineHalf = spineHalf; const lines = simulatePageLines(bundleCount, pageWidth, pageSplineLength, spineWidth, foreEdgeX, bundleSpacing, leftCount); lastLengthError = measureLineLengthError(lines, pageSplineLength); lastSpacingError = measureStackSpacingError(lines, bundleSpacing); @@ -245,7 +246,7 @@ function addCoverAssembly(pageWidth, depth, thickness, spineWidth) { } function createCoverAssemblyGeometry(pageWidth, depth, thickness, spineWidth) { - const spineHalf = spineWidth * 0.5; + const spineHalf = spineArcHalf(spineWidth); const hingeX = spineHalf + HINGE_INSET; const outerX = spineHalf + pageWidth + COVER_OVERHANG; const outerTopY = BOOK_PROFILE.tableY + thickness; @@ -339,7 +340,7 @@ function createClothSpineGeometry(depth, spineWidth) { } function spineCurvePoint(t, spineWidth) { - const radiusX = spineWidth * 0.42; + const radiusX = spineArcHalf(spineWidth); const radiusY = 0.018; const baseY = BOOK_PROFILE.tableY + BOOK_PROFILE.coverThickness + 0.002; const theta = Math.PI * (1 - THREE.MathUtils.clamp(t, 0, 1)); @@ -350,6 +351,10 @@ function spineCurvePoint(t, spineWidth) { }; } +function spineArcHalf(spineWidth) { + return spineWidth * 0.42; +} + function calculateSpineWidth(bundleCount) { const minimumWidth = 0.16; if (bundleCount <= 1) return minimumWidth; diff --git a/public/webgl-book-shape-lab.html b/public/webgl-book-shape-lab.html index f48a61b..072e778 100644 --- a/public/webgl-book-shape-lab.html +++ b/public/webgl-book-shape-lab.html @@ -74,6 +74,6 @@ 0 / 10 - +