interpolateRotations method

dynamic interpolateRotations(
  1. Map curve
)

Implementation

interpolateRotations(Map curve) {
  for (var i = 1; i < curve["values"].length; i++) {
    var initialValue = curve["values"][i - 1];
    var valuesSpan = curve["values"][i] - initialValue;

    var absoluteSpan = Math.abs(valuesSpan);

    if (absoluteSpan >= 180) {
      var numSubIntervals = absoluteSpan / 180;

      var step = valuesSpan / numSubIntervals;
      var nextValue = initialValue + step;

      var initialTime = curve["times"][i - 1];
      var timeSpan = curve["times"][i] - initialTime;
      var interval = timeSpan / numSubIntervals;
      var nextTime = initialTime + interval;

      var interpolatedTimes = [];
      var interpolatedValues = [];

      while (nextTime < curve["times"][i]) {
        interpolatedTimes.add(nextTime);
        nextTime += interval;

        interpolatedValues.add(nextValue);
        nextValue += step;
      }

      curve["times"] = inject(curve["times"], i, interpolatedTimes);
      curve["values"] = inject(curve["values"], i, interpolatedValues);
    }
  }
}