fix(tabletop): align cards to the stacking curve

Fix the tangent angle at the curve's start and rotate cards to follow
the curve direction. Add a stacking curve visualization shown with
surface debug.
This commit is contained in:
2026-08-10 00:40:56 +08:00
parent f12b40e82b
commit 50c6df48b5
6 changed files with 80 additions and 4 deletions
+5 -1
View File
@@ -28,7 +28,11 @@ export function PartPlacement({ pkg, placement }: { pkg: Package; placement: Pla
const anchorX = ((candidate?.x ?? route.x ?? 0) + x) * MM_TO_WORLD;
const anchorY = ((candidate?.y ?? route.y ?? 0) + y) * MM_TO_WORLD;
const anchorZ = z * MM_TO_WORLD;
const anchorRotation = ((candidate?.rotation ?? route.rotation ?? 0) + rotation) * DEG_TO_RAD;
// The curve tangent `rotation` is the direction of travel; the card's long
// edge ends up along (sinR, cosR) in the surface plane, so it aligns with
// the tangent (cosφ, sinφ) when R = 90° φ.
const anchorRotation =
((candidate?.rotation ?? route.rotation ?? 0) - rotation) * DEG_TO_RAD;
return (
<group position={[anchorX, anchorZ, anchorY]} rotation={[0, anchorRotation, 0]}>