public override void Serialize(JsonWriter writer) { KeyFrameReduction(); var max = Keyframes.Select(a => a.Value).Append(float.MinValue).Max(); var min = Keyframes.Select(a => a.Value).Append(float.MaxValue).Min(); if (Math.Abs(max - min) < float.Epsilon) { max += 1; } var range = max - min; writer.WriteStartObject(); { writer.WritePropertyName("Name"); writer.WriteValue(Name); writer.WritePropertyName("Min"); writer.WriteValue(min); writer.WritePropertyName("Max"); writer.WriteValue(max); writer.WritePropertyName("Type"); writer.WriteValue(nameof(Single) + "_r16"); writer.WritePropertyName("KeysData"); writer.WriteValue(ToBase64(Keyframes.Select(a => (uint)a.Time.TotalMilliseconds))); writer.WritePropertyName("ValueData"); writer.WriteValue(ToBase64(Keyframes.Select(a => (ushort)((a.Value - min) / range * ushort.MaxValue)))); } writer.WriteEndObject(); }