From 467842ba0bc438e926727d6a985a281e56433ec9 Mon Sep 17 00:00:00 2001 From: Georg Tomitsch Date: Fri, 5 Jun 2026 11:48:01 +0200 Subject: [PATCH] Checkpoint flip page dimensions --- public/js/webgl-book-shape-lab.js | 19 +++++-------------- public/webgl-book-shape-lab.html | 2 +- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/public/js/webgl-book-shape-lab.js b/public/js/webgl-book-shape-lab.js index 4bc25af..710c2a6 100644 --- a/public/js/webgl-book-shape-lab.js +++ b/public/js/webgl-book-shape-lab.js @@ -1027,8 +1027,8 @@ function updateActiveFlips(now) { function buildFlippingPageSurface(sourceLine, destinationLine, direction, t, pageOffset = 0) { const widthSegments = sourceLine.points.length - 1; const depthSegments = 18; - const zFront = lastBookModel.pageDepth * 0.5 + 0.018; - const zBack = -lastBookModel.pageDepth * 0.5 - 0.018; + const zFront = lastBookModel.pageDepth * 0.5; + const zBack = -lastBookModel.pageDepth * 0.5; if (t <= 0) return createRestingPageSurface(sourceLine.points, depthSegments, zFront, zBack); if (t >= 1) return createRestingPageSurface(destinationLine.points, depthSegments, zFront, zBack); @@ -1039,11 +1039,12 @@ function buildFlippingPageSurface(sourceLine, destinationLine, direction, t, pag const baseAngle = startAngle + direction * Math.PI * t; const lift = Math.sin(Math.PI * t); const curlStrength = direction * 0.48 * lift; - const sourceLengths = cumulativeLineLengths(sourceLine.points); + const sourceAnchor = sourceLine.anchor; const surface = []; for (let widthIndex = 0; widthIndex <= widthSegments; widthIndex += 1) { const u = widthIndex / widthSegments; - const radius = sourceLengths[widthIndex]; + const sourcePoint = sourceLine.points[widthIndex]; + const radius = Math.max(0, sourceSide * (sourcePoint.x - sourceAnchor.x)); const row = []; for (let depthIndex = 0; depthIndex <= depthSegments; depthIndex += 1) { const v = depthIndex / depthSegments; @@ -1066,16 +1067,6 @@ function buildFlippingPageSurface(sourceLine, destinationLine, direction, t, pag return surface; } -function cumulativeLineLengths(points) { - const lengths = [0]; - for (let index = 1; index < points.length; index += 1) { - const previous = points[index - 1]; - const current = points[index]; - lengths.push(lengths[index - 1] + Math.hypot(current.x - previous.x, current.y - previous.y)); - } - return lengths; -} - function createRestingPageSurface(points, depthSegments, zFront, zBack) { return points.map((point) => { const row = []; diff --git a/public/webgl-book-shape-lab.html b/public/webgl-book-shape-lab.html index 58e1a26..14a5fcd 100644 --- a/public/webgl-book-shape-lab.html +++ b/public/webgl-book-shape-lab.html @@ -74,6 +74,6 @@ 0 / 10 - +