Code/Animations/OrbitAnimation.cs
using System;
namespace BetterUI.Animations;
/// <summary>
/// Animates a component orbiting around a given center point.
/// </summary>
public class OrbitAnimation : AnimationBase
{
/// <summary>
/// The radius of the orbit.
/// </summary>
[Property]
public float OrbitRadius { get; set; } = 10f;
/// <summary>
/// The center point of the orbit.
/// </summary>
[Property]
public Vector3 OrbitCenter { get; set; } = Vector3.Zero;
protected override void OnAnimate( float t )
{
var easedTime = ApplyEasing( NormalizedTime, Easing );
var angle = easedTime * MathF.PI * 2;
var x = OrbitCenter.x + OrbitRadius * MathF.Cos( angle );
var y = OrbitCenter.y + OrbitRadius * MathF.Sin( angle );
WorldPosition = new Vector3( x, y, StartPosition.z );
}
}