parseKeyframeTrack function
Implementation
KeyframeTrack parseKeyframeTrack(Map<String,dynamic> json) {
if (json['type'] == null) {
throw ('THREE.KeyframeTrack: track type undefined, can not parse');
}
final trackType = getTrackTypeForValueTypeName(json['type']);
if (json['times'] == null) {
final List<num> times = [];
final List<num> values = [];
AnimationUtils.flattenJSON(json.keys.toList(), 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 ");
}
}