generateTracks method

dynamic generateTracks(
  1. Map rawTracks
)

Implementation

generateTracks(Map rawTracks) {
  var tracks = [];

  var initialPositionVector3 = Vector3();
  var initialRotationQuaternion = Quaternion();
  var initialScaleVector3 = Vector3();

  if (rawTracks["transform"] != null) {
    rawTracks["transform"].decompose(initialPositionVector3, initialRotationQuaternion, initialScaleVector3);
  }

  var initialPosition = initialPositionVector3.toArray();
  var initialRotation = Euler().setFromQuaternion(initialRotationQuaternion, rawTracks["eulerOrder"]).toArray();
  var initialScale = initialScaleVector3.toArray();

  if (rawTracks["T"] != null && rawTracks["T"]["curves"].keys.length > 0) {
    var positionTrack =
        generateVectorTrack(rawTracks["modelName"], rawTracks["T"]["curves"], initialPosition, 'position');
    if (positionTrack != null) tracks.add(positionTrack);
  }

  if (rawTracks["R"] != null && rawTracks["R"]["curves"].keys.length > 0) {
    var rotationTrack = generateRotationTrack(rawTracks["modelName"], rawTracks["R"]["curves"], initialRotation,
        rawTracks["preRotation"], rawTracks["postRotation"], rawTracks["eulerOrder"]);
    if (rotationTrack != null) tracks.add(rotationTrack);
  }

  if (rawTracks["S"] != null && rawTracks["S"]["curves"].keys.length > 0) {
    var scaleTrack = generateVectorTrack(rawTracks["modelName"], rawTracks["S"]["curves"], initialScale, 'scale');
    if (scaleTrack != null) tracks.add(scaleTrack);
  }

  if (rawTracks["DeformPercent"] != null) {
    var morphTrack = generateMorphTrack(rawTracks);
    if (morphTrack != null) tracks.add(morphTrack);
  }

  return tracks;
}