parseKeyframeTrack function

dynamic parseKeyframeTrack(
  1. dynamic json
)

Implementation

parseKeyframeTrack(json) {
  if (json.type == null) {
    throw ('three.KeyframeTrack: track type undefined, can not parse');
  }

  var trackType = getTrackTypeForValueTypeName(json.type);

  if (json.times == null) {
    const times = [], values = [];

    AnimationUtils.flattenJSON(json.keys, times, values, 'value');

    json.times = times;
    json.values = values;
  }

  // derived classes can define a static parse method
  // if ( trackType.parse != null ) {
  // 	return trackType.parse( json );
  // } else {
  // 	// by default, we assume a constructor compatible with the base
  // 	return new trackType( json.name, json.times, json.values, json.interpolation );
  // }

  if (trackType == "NumberKeyframeTrack") {
    return NumberKeyframeTrack(json.name, json.times, json.values, json.interpolation);
  } else if (trackType == "VectorKeyframeTrack") {
    return VectorKeyframeTrack(json.name, json.times, json.values, json.interpolation);
  } else if (trackType == "ColorKeyframeTrack") {
    return ColorKeyframeTrack(json.name, json.times, json.values, json.interpolation);
  } else if (trackType == "QuaternionKeyframeTrack") {
    return QuaternionKeyframeTrack(json.name, json.times, json.values, json.interpolation);
  } else if (trackType == "BooleanKeyframeTrack") {
    return BooleanKeyframeTrack(json.name, json.times, json.values, json.interpolation);
  } else if (trackType == "StringKeyframeTrack") {
    return StringKeyframeTrack(json.name, json.times, json.values, json.interpolation);
  } else {
    throw ("AnimationClip.parseKeyframeTrack trackType: $trackType ");
  }
}