Compare commits

...

2 Commits

4 changed files with 49 additions and 21 deletions

View File

@ -99,6 +99,7 @@ export class LinearAnimationSegment extends AnimationSegment {
export interface AnimationTransitionFlags { export interface AnimationTransitionFlags {
rotation?: boolean; rotation?: boolean;
rotationDuring?: "Actual" | "Start" | "End"; rotationDuring?: "Actual" | "Start" | "End";
rotationDirection?: Hand;
hands?: boolean; hands?: boolean;
handsDuring?: "Actual" | "None" | "Start" | "End" | Map<Hand, Offset>; handsDuring?: "Actual" | "None" | "Start" | "End" | Map<Hand, Offset>;
} }
@ -126,20 +127,30 @@ export class TransitionAnimationSegment extends AnimationSegment {
this.startRotation = this.startPosition.rotation; this.startRotation = this.startPosition.rotation;
this.endRotation = this.endPosition.rotation; this.endRotation = this.endPosition.rotation;
if (this.flags.rotation) { if (this.flags.rotation) {
const actualStart = this.actualAnimation.interpolateRotation(0); let rotationDirection = flags.rotationDirection;
const actualEnd = this.actualAnimation.interpolateRotation(1);
if (!flags.rotationDirection) {
const actualStart = this.actualAnimation.interpolateRotation(0);
const actualEnd = this.actualAnimation.interpolateRotation(1);
if (actualEnd > actualStart) {
rotationDirection = Hand.Right;
} else if (actualEnd < actualStart) {
rotationDirection = Hand.Left;
}
}
const transitionStart = this.actualAnimation.interpolateRotation(this.startTransitionProgress); const transitionStart = this.actualAnimation.interpolateRotation(this.startTransitionProgress);
const transitionEnd = this.actualAnimation.interpolateRotation(1 - this.endTransitionProgress); const transitionEnd = this.actualAnimation.interpolateRotation(1 - this.endTransitionProgress);
if (actualEnd > actualStart) { if (rotationDirection === Hand.Right) {
while (transitionStart <= this.startRotation - 180) { while (transitionStart <= this.startRotation - 180) {
this.startRotation -= 360; this.startRotation -= 360;
} }
while (transitionEnd >= this.endRotation + 180) { while (transitionEnd >= this.endRotation + 180) {
this.endRotation += 360; this.endRotation += 360;
} }
} else if (actualEnd < actualStart) { } else if (rotationDirection === Hand.Left) {
while (transitionStart >= this.startRotation + 180) { while (transitionStart >= this.startRotation + 180) {
this.startRotation += 360; this.startRotation += 360;
} }
@ -148,18 +159,21 @@ export class TransitionAnimationSegment extends AnimationSegment {
} }
} }
// Transitions should be short adjustments, not spins. if (!this.flags.rotationDirection) {
while (transitionStart - this.startRotation < -180) { // Transitions should be short adjustments, not spins...
this.startRotation -= 360; // ... unless a direction is explicitly specified.
} while (transitionStart - this.startRotation < -180) {
while (transitionStart - this.startRotation > 180) { this.startRotation -= 360;
this.startRotation += 360; }
} while (transitionStart - this.startRotation > 180) {
while (transitionEnd - this.endRotation < -180) { this.startRotation += 360;
this.endRotation -= 360; }
} while (transitionEnd - this.endRotation < -180) {
while (transitionEnd - this.endRotation > 180) { this.endRotation -= 360;
this.endRotation += 360; }
while (transitionEnd - this.endRotation > 180) {
this.endRotation += 360;
}
} }
} }
} }

View File

@ -884,18 +884,20 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
if (startPos.kind === PositionKind.ShortLines) { if (startPos.kind === PositionKind.ShortLines) {
if (around === CircleSide.Left || around === CircleSide.Right) { if (around === CircleSide.Left || around === CircleSide.Right) {
// Fix startPos if necessary. Needed because pass through always swaps but sometimes shouldn't. // Fix startPos if necessary. Needed because pass through always swaps but sometimes shouldn't.
let startWhich = startPos.which;
if ((startPos.facing === Facing.Up || startPos.facing === Facing.Down) && if ((startPos.facing === Facing.Up || startPos.facing === Facing.Down) &&
((byHandOrShoulder === Hand.Right) ((byHandOrShoulder === Hand.Right)
!== (startPos.facing === Facing.Up) !== (startPos.facing === Facing.Up)
!== (startPos.which === ShortLinesPosition.FarLeft || startPos.which === ShortLinesPosition.MiddleRight))) { !== startPos.which.isLeftOfSide())) {
startWhich = startPos.which.swapOnSide()
startingPos = { startingPos = {
...startPos, ...startPos,
which: startPos.which.swapOnSide() which: startWhich,
}; };
} }
const endWhich = CirclePosition.fromSides(startingPos.which.leftRightSide(), const endWhich = CirclePosition.fromSides(startingPos.which.leftRightSide(),
(startingPos.which === ShortLinesPosition.FarLeft || startingPos.which === ShortLinesPosition.MiddleRight) startWhich.isLeftOfSide()
!== (byHandOrShoulder === Hand.Right) !== (byHandOrShoulder === Hand.Right)
!== (intoWavePositions === 1) !== (intoWavePositions === 1)
? CircleSide.Top ? CircleSide.Top
@ -924,9 +926,15 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
setOffset: startPos.setOffset, setOffset: startPos.setOffset,
lineOffset: startPos.lineOffset, lineOffset: startPos.lineOffset,
} }
} else { } else {
throw new Error("Allemande from circle to short lines is unsupported."); const endWhich = startPos.which.toShortLines(intoWavePositions === 1 ? Hand.Right : Hand.Left);
endPosition = {
kind: PositionKind.ShortLines,
which: endWhich,
facing: endWhich.isLeftOfSide() === (byHandOrShoulder === Hand.Left) ? Facing.Up : Facing.Down,
setOffset: startPos.setOffset,
lineOffset: startPos.lineOffset,
}
} }
} }
} }

View File

@ -286,6 +286,11 @@ export class ShortLinesPosition {
return this.leftRightSide() === CircleSide.Left; return this.leftRightSide() === CircleSide.Left;
} }
// Of the two positions on the same leftRightSide() is this the one further to the left?
public isLeftOfSide() : boolean {
return this.enumValue === ShortLinesPositionEnum.FarLeft || this.enumValue === ShortLinesPositionEnum.MiddleRight;
}
public facingSide() : Facing.Left | Facing.Right { public facingSide() : Facing.Left | Facing.Right {
return this.isLeft() === this.isMiddle() ? Facing.Left : Facing.Right; return this.isLeft() === this.isMiddle() ? Facing.Left : Facing.Right;
} }

View File

@ -832,6 +832,7 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
flags: { flags: {
hands: true, hands: true,
rotation: true, rotation: true,
rotationDirection: move.movementPattern.side,
}, },
startTransitionBeats: 0.5, startTransitionBeats: 0.5,
}) })