GLTFAnimationSampler.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. using System.Runtime.Serialization;
  2. namespace GLTFExport.Entities
  3. {
  4. [DataContract]
  5. public class GLTFAnimationSampler : GLTFProperty
  6. {
  7. public enum Interpolation
  8. {
  9. LINEAR,
  10. STEP,
  11. CATMULLROMSPLINE,
  12. CUBICSPLINE
  13. }
  14. /// <summary>
  15. /// The index of an accessor containing keyframe input values, e.g., time. That accessor must have componentType FLOAT.
  16. /// The values represent time in seconds with time[0] >= 0.0, and strictly increasing values, i.e., time[n + 1] > time[n].
  17. /// </summary>
  18. [DataMember(IsRequired = true)]
  19. public int input { get; set; }
  20. [DataMember(EmitDefaultValue = false)]
  21. public string interpolation { get; private set; }
  22. /// <summary>
  23. /// The index of an accessor containing keyframe output values.
  24. /// When targeting TRS target, the accessor.componentType of the output values must be FLOAT.
  25. /// When targeting morph weights, the accessor.componentType of the output values must be FLOAT
  26. /// or normalized integer where each output element stores values with a count equal to the number of morph targets.
  27. /// </summary>
  28. [DataMember(IsRequired = true)]
  29. public int output { get; set; }
  30. public int index;
  31. public void SetInterpolation(Interpolation interpolation)
  32. {
  33. this.interpolation = interpolation.ToString();
  34. }
  35. public GLTFAnimationSampler()
  36. {
  37. // For GLTF, default value is LINEAR
  38. // but gltf loader of BABYLON doesn't handle missing interpolation value
  39. SetInterpolation(Interpolation.LINEAR);
  40. }
  41. }
  42. }