Compare commits
2 Commits
4f64f045d3
...
d8e7fbe12d
Author | SHA1 | Date | |
---|---|---|---|
d8e7fbe12d | |||
8761e409b2 |
|
@ -99,6 +99,7 @@ export class LinearAnimationSegment extends AnimationSegment {
|
|||
export interface AnimationTransitionFlags {
|
||||
rotation?: boolean;
|
||||
rotationDuring?: "Actual" | "Start" | "End";
|
||||
rotationDirection?: Hand;
|
||||
hands?: boolean;
|
||||
handsDuring?: "Actual" | "None" | "Start" | "End" | Map<Hand, Offset>;
|
||||
}
|
||||
|
@ -126,20 +127,30 @@ export class TransitionAnimationSegment extends AnimationSegment {
|
|||
this.startRotation = this.startPosition.rotation;
|
||||
this.endRotation = this.endPosition.rotation;
|
||||
if (this.flags.rotation) {
|
||||
const actualStart = this.actualAnimation.interpolateRotation(0);
|
||||
const actualEnd = this.actualAnimation.interpolateRotation(1);
|
||||
let rotationDirection = flags.rotationDirection;
|
||||
|
||||
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 transitionEnd = this.actualAnimation.interpolateRotation(1 - this.endTransitionProgress);
|
||||
|
||||
if (actualEnd > actualStart) {
|
||||
if (rotationDirection === Hand.Right) {
|
||||
while (transitionStart <= this.startRotation - 180) {
|
||||
this.startRotation -= 360;
|
||||
}
|
||||
while (transitionEnd >= this.endRotation + 180) {
|
||||
this.endRotation += 360;
|
||||
}
|
||||
} else if (actualEnd < actualStart) {
|
||||
} else if (rotationDirection === Hand.Left) {
|
||||
while (transitionStart >= this.startRotation + 180) {
|
||||
this.startRotation += 360;
|
||||
}
|
||||
|
@ -148,18 +159,21 @@ export class TransitionAnimationSegment extends AnimationSegment {
|
|||
}
|
||||
}
|
||||
|
||||
// Transitions should be short adjustments, not spins.
|
||||
while (transitionStart - this.startRotation < -180) {
|
||||
this.startRotation -= 360;
|
||||
}
|
||||
while (transitionStart - this.startRotation > 180) {
|
||||
this.startRotation += 360;
|
||||
}
|
||||
while (transitionEnd - this.endRotation < -180) {
|
||||
this.endRotation -= 360;
|
||||
}
|
||||
while (transitionEnd - this.endRotation > 180) {
|
||||
this.endRotation += 360;
|
||||
if (!this.flags.rotationDirection) {
|
||||
// Transitions should be short adjustments, not spins...
|
||||
// ... unless a direction is explicitly specified.
|
||||
while (transitionStart - this.startRotation < -180) {
|
||||
this.startRotation -= 360;
|
||||
}
|
||||
while (transitionStart - this.startRotation > 180) {
|
||||
this.startRotation += 360;
|
||||
}
|
||||
while (transitionEnd - this.endRotation < -180) {
|
||||
this.endRotation -= 360;
|
||||
}
|
||||
while (transitionEnd - this.endRotation > 180) {
|
||||
this.endRotation += 360;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -884,18 +884,20 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
|
|||
if (startPos.kind === PositionKind.ShortLines) {
|
||||
if (around === CircleSide.Left || around === CircleSide.Right) {
|
||||
// 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) &&
|
||||
((byHandOrShoulder === Hand.Right)
|
||||
!== (startPos.facing === Facing.Up)
|
||||
!== (startPos.which === ShortLinesPosition.FarLeft || startPos.which === ShortLinesPosition.MiddleRight))) {
|
||||
!== startPos.which.isLeftOfSide())) {
|
||||
startWhich = startPos.which.swapOnSide()
|
||||
startingPos = {
|
||||
...startPos,
|
||||
which: startPos.which.swapOnSide()
|
||||
which: startWhich,
|
||||
};
|
||||
}
|
||||
|
||||
const endWhich = CirclePosition.fromSides(startingPos.which.leftRightSide(),
|
||||
(startingPos.which === ShortLinesPosition.FarLeft || startingPos.which === ShortLinesPosition.MiddleRight)
|
||||
startWhich.isLeftOfSide()
|
||||
!== (byHandOrShoulder === Hand.Right)
|
||||
!== (intoWavePositions === 1)
|
||||
? CircleSide.Top
|
||||
|
@ -924,9 +926,15 @@ function moveAsLowLevelMoves({ move, nextMove, startingPos, numProgessions }: {
|
|||
setOffset: startPos.setOffset,
|
||||
lineOffset: startPos.lineOffset,
|
||||
}
|
||||
|
||||
} 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,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -286,6 +286,11 @@ export class ShortLinesPosition {
|
|||
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 {
|
||||
return this.isLeft() === this.isMiddle() ? Facing.Left : Facing.Right;
|
||||
}
|
||||
|
|
|
@ -832,6 +832,7 @@ function animateLowLevelMoveWithoutSlide(move: LowLevelMove): animation.Animatio
|
|||
flags: {
|
||||
hands: true,
|
||||
rotation: true,
|
||||
rotationDirection: move.movementPattern.side,
|
||||
},
|
||||
startTransitionBeats: 0.5,
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user