read static method

bool read(
  1. StreamReader reader,
  2. KeyFrameWithInterpolation frame
)
override

Implementation

static bool read(StreamReader reader, KeyFrameWithInterpolation frame) {
  if (!KeyFrame.read(reader, frame)) {
    return false;
  }
  int type = reader.readUint8('interpolatorType');

  InterpolationTypes? actualType = interpolationTypesLookup[type];
  actualType ??= InterpolationTypes.linear;

  switch (actualType) {
    case InterpolationTypes.hold:
      frame._interpolator = HoldInterpolator.instance;
      break;
    case InterpolationTypes.linear:
      frame._interpolator = LinearInterpolator.instance;
      break;
    case InterpolationTypes.cubic:
      {
        CubicInterpolator interpolator = CubicInterpolator();
        if (interpolator.read(reader)) {
          frame._interpolator = interpolator;
        }
        break;
      }
    default:
      frame._interpolator = HoldInterpolator.instance;
  }
  return true;
}