using Engine.Core; namespace Engine.Systems.Tween; public static class TweenQuaternionExtensions { private static readonly BoxedPool boxedQuaternionPool = new(2); public static ITween TweenQuaternion(this Quaternion initialQuaternion, ITweenManager tweenManager, float duration, Quaternion targetQuaternion, System.Action setMethod) { Boxed boxedInitial = boxedQuaternionPool.Get(initialQuaternion); Boxed boxedTarget = boxedQuaternionPool.Get(targetQuaternion); ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.SLerp(boxedTarget.Value, t))); tween.OnComplete(() => { boxedQuaternionPool.Return(boxedInitial); boxedQuaternionPool.Return(boxedTarget); }); return tween; } }