private RotationAnimator CreateRotationAnimation(SplitSide splitSide, RotateableBranch rotateable, Quaternion rotationDelta, out Transformation transformation) { BlockBounds rotatedBounds = rotateable.RotatedBounds; Quaternion startRot = rotatedBounds.Rotation; Quaternion endRot = startRot * rotationDelta; rotatedBounds.SetToRotationFrom(endRot, splitSide.Pivot, rotateable.OriginalBounds); transformation = new RotateAroundPivotTransform(splitSide.Pivot, endRot); return new RotationAnimator(splitSide, startRot, endRot, rotateable); }
IEnumerator Rotate90Degrees(SplitSide splitRotation, IList<RotationAnimator> animators) { float startTime = Time.time; float deltaTime; do { deltaTime = Mathf.Clamp(Time.time - startTime, 0, 1); foreach (RotationAnimator animator in animators) { Quaternion lerpRotation = Quaternion.Lerp(animator.From, animator.To, Mathf.SmoothStep(0, 1, deltaTime)); Transformation transformation = new RotateAroundPivotTransform(splitRotation.Pivot, lerpRotation); Vector3 localPosition = transformation.Transform(new Vector3()); animator.UpdateTransform(lerpRotation, localPosition); } yield return null; } while (deltaTime < 1); _eventRegistry.Notify(new GameEvent(GameEvent.Type.RESUMED)); _readyToRot = true; }