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:
@@ -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]}>
|
||||
|
||||
Reference in New Issue
Block a user