Skip to content

Commit 6e4e05d

Browse files
Merge pull request #161 from GabrielDrapor/fix/book-hover-clipping
fix(shelf): pivot the hover tip-out around the trailing back corner
2 parents 286d055 + a52e64f commit 6e4e05d

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

src/components/shelf3d/BookShelf3D.tsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -771,9 +771,21 @@ function BookMesh({
771771
// Tip the book out of the row and yaw it so the cover peeks out.
772772
// This replaces the last-read emphasis too: the book settles back
773773
// onto the board and follows the ordinary hover animation.
774+
//
775+
// The yaw pivots around the trailing back corner instead of the
776+
// book's center: a center pivot sweeps that corner sideways into
777+
// the neighboring book (~0.1 units vs a 0.006 gap — visible
778+
// clipping). With the corner pinned, the rest of the book swings
779+
// forward-out in front of the row, which can't intersect anything.
780+
const theta = -0.3;
781+
const px = width / 2;
782+
const pz = -BOOK_DEPTH / 2;
783+
const offX = px - (px * Math.cos(theta) + pz * Math.sin(theta));
784+
const offZ = pz - (-px * Math.sin(theta) + pz * Math.cos(theta));
774785
ty = shelfY;
775-
tz = position[2] + 0.42;
776-
ry = -0.3;
786+
tx = position[0] + offX;
787+
tz = position[2] + 0.46 + offZ;
788+
ry = theta;
777789
}
778790

779791
g.position.x += (tx - g.position.x) * k;

0 commit comments

Comments
 (0)