using System;
using UniGLTF.Utils;
using UnityEngine;
namespace UniVRM10
{
[Serializable]
public struct NodeTransformBinding
{
public string RelativePath;
///
/// t = init_t + offset_t * weight
/// disable if offset_t = (0, 0, 0)
///
public Vector3 OffsetTranslation;
///
/// r = slerp(init_t, init_t * offset r, weight)
/// disable if rotation_t = (0, 0, 0, 1)
///
public Quaternion OffsetRotation;
///
/// s = lerp(init_s, blend_s, weight)
/// disalbe if blend_s = init_s. maybe(1, 1, 1)
///
public Vector3 TargetScale;
///
///
///
///
///
/// 0 to 1.0
public NodeTransformBinding(string path, in Vector3 t, in Quaternion r, in Vector3 s)
{
RelativePath = path;
OffsetTranslation = t;
OffsetRotation = r;
TargetScale = s;
}
public void Apply(Transform node, in TransformState init, float weight)
{
node.SetLocalPositionAndRotation(
init.LocalPosition + this.OffsetTranslation * weight,
Quaternion.Slerp(init.LocalRotation, init.LocalRotation * this.OffsetRotation, weight)
);
if (this.TargetScale != Vector3.zero)
{
node.localScale = Vector3.Lerp(init.LocalScale, this.TargetScale, weight);
}
}
}
}