using Engine.Core; namespace Engine.Systems.Tween; public static class TweenVector3DExtensions { private static readonly BoxedPool boxedVector3DPool = new(2); public static ITween TweenVector3D(this Vector3D initialVector3D, ITweenManager tweenManager, float duration, Vector3D targetVector3D, System.Action setMethod) { Boxed boxedInitial = boxedVector3DPool.Get(initialVector3D); Boxed boxedTarget = boxedVector3DPool.Get(targetVector3D); ITween tween = tweenManager.StartTween(duration, t => setMethod?.Invoke(boxedInitial.Value.Lerp(boxedTarget.Value, t))); tween.OnComplete(() => { boxedVector3DPool.Return(boxedInitial); boxedVector3DPool.Return(boxedTarget); }); return tween; } }