fix vrm-1.0 export that SkinedMeshRenderer.bones contains null

This commit is contained in:
ousttrue 2024-07-03 21:21:15 +09:00
parent 768b77b49f
commit 5ebae3b9e2
2 changed files with 23 additions and 2 deletions

View File

@ -307,7 +307,17 @@ namespace UniVRM10
skin.Root = nodes[skinnedMeshRenderer.rootBone.gameObject];
}
skin.Joints = skinnedMeshRenderer.bones.Select(x => nodes[x.gameObject]).ToList();
skin.Joints = skinnedMeshRenderer.bones.Select(x =>
{
if (x != null)
{
return nodes[x.gameObject];
}
else
{
return null;
}
}).ToList();
return skin;
}

View File

@ -93,7 +93,18 @@ namespace UniVRM10
{
gltfSkin = new glTFSkin()
{
joints = skin.Joints.Select(joint => nodes.IndexOfThrow(joint)).ToArray()
joints = skin.Joints.Select(joint =>
{
var index = nodes.IndexOf(joint);
if (index < 0)
{
return 0;
}
else
{
return index;
}
}).ToArray()
};
if (skin.InverseMatrices == null)
{