fix(tabletop): tilt cards uniformly about the y axis
Apply the same tilt to every stacked part and rotate it about its local Y axis instead of Z. Default tilt to 1 degree when a stacking strategy is present, and arc the poker deck along the surface's bottom edge.
This commit is contained in:
@@ -46,7 +46,8 @@ describe('pointAt', () => {
|
||||
describe('stackingOffset', () => {
|
||||
it('returns no offset without a curve', () => {
|
||||
expect(stackingOffset(undefined, 0, 3)).toBe(NO_OFFSET);
|
||||
expect(stackingOffset({ limit: 5 }, 0, 3)).toBe(NO_OFFSET);
|
||||
// A stacking strategy defaults to a 1° tilt, so it's not the identity.
|
||||
expect(stackingOffset({ limit: 5 }, 0, 3)).toEqual({ x: 0, y: 0, rotation: 0, z: 0, tilt: 1 });
|
||||
});
|
||||
|
||||
it('spreads parts evenly along a straight curve', () => {
|
||||
@@ -86,12 +87,12 @@ describe('stackingOffset', () => {
|
||||
expect(offset.x).toBeCloseTo(25);
|
||||
});
|
||||
|
||||
it('tilts each part without a curve', () => {
|
||||
it('tilts every part the same amount without a curve', () => {
|
||||
const offset = stackingOffset({ tilt: 0.1 }, 2, 3);
|
||||
expect(offset).toEqual({ x: 0, y: 0, rotation: 0, z: 0, tilt: 0.2 });
|
||||
expect(offset).toEqual({ x: 0, y: 0, rotation: 0, z: 0, tilt: 0.1 });
|
||||
});
|
||||
|
||||
it('tilts parts along the curve', () => {
|
||||
it('tilts every part the same amount along the curve', () => {
|
||||
const offset = stackingOffset({ curve: 'M 0 0 L 100 0', tilt: 0.1 }, 1, 3);
|
||||
expect(offset.x).toBeCloseTo(50);
|
||||
expect(offset.tilt).toBeCloseTo(0.1);
|
||||
@@ -113,7 +114,7 @@ describe('stackingOffset', () => {
|
||||
expect(last.z).toBeCloseTo(40);
|
||||
});
|
||||
|
||||
it('returns no offset without a curve, tilt, or z ramp', () => {
|
||||
expect(stackingOffset({ limit: 5 }, 0, 3)).toBe(NO_OFFSET);
|
||||
it('returns no offset without a stacking strategy', () => {
|
||||
expect(stackingOffset(undefined, 0, 3)).toBe(NO_OFFSET);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user