[Bf-extensions-cvs] [3e09faa3] master: glTF importer: get targetNames from extras

Julien Duroure noreply at git.blender.org
Sat Mar 16 16:14:27 CET 2019


Commit: 3e09faa3523ada8eaa1a6b3ad5e4bf606f03225c
Author: Julien Duroure
Date:   Sat Mar 16 16:13:50 2019 +0100
Branches: master
https://developer.blender.org/rBA3e09faa3523ada8eaa1a6b3ad5e4bf606f03225c

glTF importer: get targetNames from extras

This is not glTF standard, but this workaround is accepted in a few tools

===================================================================

M	io_scene_gltf2/blender/imp/gltf2_blender_mesh.py

===================================================================

diff --git a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
index 3f69a5a2..dedd59de 100755
--- a/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
+++ b/io_scene_gltf2/blender/imp/gltf2_blender_mesh.py
@@ -116,7 +116,16 @@ class BlenderMesh():
                 gltf.shapekeys[i] = None
                 continue
 
-            obj.shape_key_add(name="target_" + str(i))
+            # Check if glTF file has some extras with targetNames
+            shapekey_name = None
+            if pymesh.extras is not None:
+                if 'targetNames' in pymesh.extras.keys() and i < len(pymesh.extras['targetNames']):
+                    shapekey_name = pymesh.extras['targetNames'][i]
+
+            if shapekey_name is None:
+                shapekey_name = "target_" + str(i)
+
+            obj.shape_key_add(name=shapekey_name)
             current_shapekey_index += 1
 
             offset_idx = 0



More information about the Bf-extensions-cvs mailing list