diff --git a/addons/io_scene_gltf2/blender/exp/animation/sampled/armature/channels.py b/addons/io_scene_gltf2/blender/exp/animation/sampled/armature/channels.py index c57795003..ce931f42d 100644 --- a/addons/io_scene_gltf2/blender/exp/animation/sampled/armature/channels.py +++ b/addons/io_scene_gltf2/blender/exp/animation/sampled/armature/channels.py @@ -70,21 +70,29 @@ def gather_armature_sampled_channels(armature_uuid, blender_action_name, if channel is not None: channels.append(channel) + bake_interpolation = get_gltf_interpolation("LINEAR") # Retrieve animation on armature object itself, if any - # If armature is baked (no animation of armature), need to use all channels if blender_action_name == armature_uuid or export_settings['gltf_animation_mode'] in ["SCENE", "NLA_TRACKS"]: - armature_channels = [] + # If armature is baked (no animation of armature), need to use all channels + armature_channels = [ + ["location", bake_interpolation], + ["rotation_quaternion", bake_interpolation], + ["scale", bake_interpolation] + ] + animated_channels = [] else: + # The armature has some channel(s) animated, checking which one(s) armature_channels = __gather_armature_object_channel( armature_uuid, bpy.data.actions[blender_action_name], export_settings) + animated_channels = armature_channels - for p in ["location", "rotation_quaternion", "scale"]: + for (p, i) in armature_channels: armature_channel = gather_sampled_object_channel( armature_uuid, p, blender_action_name, - p in [a[0] for a in armature_channels], - [c[1] for c in armature_channels if c[0] == p][0] if p in [a[0] for a in armature_channels] else "LINEAR", + p in [a[0] for a in animated_channels], + [c[1] for c in animated_channels if c[0] == p][0] if p in [a[0] for a in animated_channels] else bake_interpolation, export_settings ) diff --git a/tests/test/test.js b/tests/test/test.js index 50842b1b0..3d0774f5e 100644 --- a/tests/test/test.js +++ b/tests/test/test.js @@ -1492,16 +1492,12 @@ describe('Exporter', function () { const arma2_scale_channel = anim_armature2.channels.filter(a => asset.nodes[a.target.node].name === armature2_node.name).filter(a => a.target.path === "scale")[0]; const arma2_translation_sampler = anim_armature2.samplers[arma2_translation_channel.sampler]; - const arma2_rotation_sampler = anim_armature2.samplers[arma2_rotation_channel.sampler]; - const arma2_scale_sampler = anim_armature2.samplers[arma2_scale_channel.sampler]; + assert.ok(arma2_rotation_channel == null); + assert.ok(arma2_scale_channel == null); assert.strictEqual(arma2_translation_sampler.interpolation, "LINEAR"); - assert.strictEqual(arma2_rotation_sampler.interpolation, "STEP"); - assert.strictEqual(arma2_scale_sampler.interpolation, "STEP"); assert.strictEqual(asset.accessors[arma2_translation_sampler.input].count, 1); - assert.strictEqual(asset.accessors[arma2_rotation_sampler.input].count, 1); - assert.strictEqual(asset.accessors[arma2_scale_sampler.input].count, 1); const anim_sphere = asset.animations.filter(a => a.name === 'Sphere.001Action')[0]; @@ -1835,16 +1831,12 @@ describe('Exporter', function () { const arma2_scale_channel = anim_armature2.channels.filter(a => asset.nodes[a.target.node].name === armature2_node.name).filter(a => a.target.path === "scale")[0]; const arma2_translation_sampler = anim_armature2.samplers[arma2_translation_channel.sampler]; - const arma2_rotation_sampler = anim_armature2.samplers[arma2_rotation_channel.sampler]; - const arma2_scale_sampler = anim_armature2.samplers[arma2_scale_channel.sampler]; + assert.ok(arma2_rotation_channel == null); + assert.ok(arma2_scale_channel == null); assert.strictEqual(arma2_translation_sampler.interpolation, "LINEAR"); - assert.strictEqual(arma2_rotation_sampler.interpolation, "STEP"); - assert.strictEqual(arma2_scale_sampler.interpolation, "STEP"); assert.strictEqual(asset.accessors[arma2_translation_sampler.input].count, 1); - assert.strictEqual(asset.accessors[arma2_rotation_sampler.input].count, 1); - assert.strictEqual(asset.accessors[arma2_scale_sampler.input].count, 1); const anim_sphere = asset.animations.filter(a => a.name === 'Sphere.001Action')[0];