generateTracks method

dynamic generateTracks(
  1. Map rawTracks
)

Implementation

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

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

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

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

  if (rawTracks["T"] != null && rawTracks["T"]["curves"].keys.length > 0) {
    var positionTrack = this.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 = this.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 = this.generateVectorTrack(rawTracks["modelName"],
        rawTracks["S"]["curves"], initialScale, 'scale');
    if (scaleTrack != null) tracks.add(scaleTrack);
  }

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

  return tracks;
}