feat: added sphere primitive
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user