Skip to content

Commit

Permalink
Merge pull request #584 from hiroj/fix_animationImporter_blendShape
Browse files Browse the repository at this point in the history
fix_animationImporter_blendShape
  • Loading branch information
ousttrue authored Oct 14, 2020
2 parents 7c03033 + 45193ad commit 11f256c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Assets/VRM/UniGLTF/Scripts/IO/AnimationImporter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -265,23 +265,24 @@ public static List<AnimationClip> ImportAnimationClip(ImporterContext ctx)
{
var node = ctx.GLTF.nodes[channel.target.node];
var mesh = ctx.GLTF.meshes[node.mesh];
//var primitive = mesh.primitives.FirstOrDefault();
//var targets = primitive.targets;
var primitive = mesh.primitives.FirstOrDefault();
var targets = primitive.targets;

List<string> blendShapeNames = new List<string>();
var transform = ctx.Nodes[channel.target.node];
var skinnedMeshRenderer = transform.GetComponent<SkinnedMeshRenderer>();
if (skinnedMeshRenderer == null)
List<string> targetNames;
if(primitive != null && primitive.extras != null && primitive.extras.targetNames != null && primitive.extras.targetNames.Count > 0)
{
continue;
targetNames = primitive.extras.targetNames;
}

for (int j = 0; j < skinnedMeshRenderer.sharedMesh.blendShapeCount; j++)
else if(mesh.extras != null && mesh.extras.targetNames != null && mesh.extras.targetNames.Count > 0)
{
targetNames = mesh.extras.targetNames;
}
else
{
blendShapeNames.Add(skinnedMeshRenderer.sharedMesh.GetBlendShapeName(j));
throw new Exception("glTF BlendShape Animation. targetNames invalid.");
}

var keyNames = blendShapeNames
var keyNames = targetNames
.Where(x => !string.IsNullOrEmpty(x))
.Select(x => "blendShape." + x)
.ToArray();
Expand Down

0 comments on commit 11f256c

Please sign in to comment.