glTF exporter: fix bug export sampled animation with non 'classical' (constant/linear/bezier) interpolation

This commit is contained in:
Julien Duroure 2020-04-18 09:12:47 +02:00
parent ea5bb9d920
commit 18a0f95a84
2 changed files with 10 additions and 10 deletions

View File

@ -15,7 +15,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (1, 2, 64),
"version": (1, 2, 65),
'blender': (2, 83, 9),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -271,19 +271,19 @@ def __gather_interpolation(channels: typing.Tuple[bpy.types.FCurve],
# If only single keyframe revert to STEP
if max_keyframes < 2:
return 'STEP'
else:
blender_keyframe = [c for c in channels if c is not None][0].keyframe_points[0]
# For sampled animations: CONSTANT are STEP, other are LINEAR
return {
"BEZIER": "LINEAR",
"LINEAR": "LINEAR",
"CONSTANT": "STEP"
}[blender_keyframe.interpolation]
# If all keyframes are CONSTANT, we can use STEP.
if all(all(k.interpolation == 'CONSTANT' for k in c.keyframe_points) for c in channels if c is not None):
return 'STEP'
# Otherwise, sampled keyframes use LINEAR interpolation.
return 'LINEAR'
# Non-sampled keyframes implies that all keys are of the same type, and that the
# type is supported by glTF (because we checked in needs_baking).
blender_keyframe = [c for c in channels if c is not None][0].keyframe_points[0]
# Select the interpolation method. Any unsupported method will fallback to STEP
# Select the interpolation method.
return {
"BEZIER": "CUBICSPLINE",
"LINEAR": "LINEAR",