using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VRTK;

public class Translation : BaseDeformation
{
    public override string DeformationName { get; protected set; } = "Translation";
    

    public override string Description { get; set; } = "Enables moving the model";
    public override float Intensity
    {
        get
        {
            return 1;
        }
        set
        {
            // cannot change intensity of translation
        }
    }

    public override void InitializeDeformation(DeformationManager deformationManager)
    {
        DeformationManager = deformationManager;
    }


    private void Update()
    {
        if (IsDeforming)
        {
            TranslateModel(DeformationManager.GlobalLastPosition, DeformationManager.GlobalCurrentPosition);
        }
    }

    public override void AddUndoStep(UndoStack undoStack)
    {

    }

    public override void StartDeforming()
    {
        if (IsDeforming)
        {
            return;
        }

        IsDeforming = true;
    }

    public override void StopDeforming()
    {
        IsDeforming = false;
    }

    public void TranslateModel(Vector3 lastPosition, Vector3 currentPosition)
    {
        Vector3 translationVector = currentPosition - lastPosition;
        DeformationManager.ObjectToDeform.transform.Translate(translationVector,Space.World);
    }

    

}
