feat: added sphere primitive

This commit is contained in:
2025-10-21 19:06:58 +03:00
parent 896f7876c1
commit 0db2cae1bb
7 changed files with 230 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
using Engine.Core;
namespace Engine.Systems.Tween;
public static class TweenSphere3DExtensions
{
private static readonly BoxedPool<Sphere3D> boxedSphere3DPool = new(2);
public static ITween TweenSphere3D(this Sphere3D initialSphere3D, ITweenManager tweenManager, float duration, Sphere3D targetSphere3D, System.Action<Sphere3D> setMethod)
{
Boxed<Sphere3D> boxedInitial = boxedSphere3DPool.Get(initialSphere3D);
Boxed<Sphere3D> boxedTarget = boxedSphere3DPool.Get(targetSphere3D);
ITween tween = tweenManager.StartTween(duration,
t => setMethod?.Invoke(
new Sphere3D(
boxedInitial.Value.Center.Lerp(boxedTarget.Value.Center, t),
boxedInitial.Value.Diameter.Lerp(boxedTarget.Value.Diameter, t)
)
)
);
tween.OnComplete(() =>
{
boxedSphere3DPool.Return(boxedInitial);
boxedSphere3DPool.Return(boxedTarget);
});
return tween;
}
}