@@ -1183,6 +1183,9 @@ int CreateGlobalVertex(IIGameMesh mesh, BabylonAbstractMesh babylonAbstractMesh,
11831183 float [ ] weight = new float [ 4 ] { 0 , 0 , 0 , 0 } ;
11841184 int [ ] bone = new int [ 4 ] { 0 , 0 , 0 , 0 } ;
11851185 var nbBones = skin . GetNumberOfBones ( vertexIndex ) ;
1186+ // Babylon, nor GLTF do not support single bone skeleton, we may add a root node with no transform.
1187+ // this is echoing the process into BabylonExporter.Skeleton ExportBones(Skin)
1188+ var offset = skin . TotalBoneCount == 1 ? 1 : 0 ;
11861189
11871190 int currentVtxBone = 0 ;
11881191 int currentSkinBone = 0 ;
@@ -1194,7 +1197,7 @@ int CreateGlobalVertex(IIGameMesh mesh, BabylonAbstractMesh babylonAbstractMesh,
11941197 if ( boneWeight <= 0 )
11951198 continue ;
11961199
1197- bone [ currentVtxBone ] = boneIds . IndexOf ( skin . GetIGameBone ( vertexIndex , currentSkinBone ) . NodeID ) ;
1200+ bone [ currentVtxBone ] = boneIds . IndexOf ( skin . GetIGameBone ( vertexIndex , currentSkinBone ) . NodeID ) + offset ; // add optional offset
11981201 weight [ currentVtxBone ] = skin . GetWeight ( vertexIndex , currentSkinBone ) ;
11991202 ++ currentVtxBone ;
12001203 }
@@ -1227,7 +1230,7 @@ int CreateGlobalVertex(IIGameMesh mesh, BabylonAbstractMesh babylonAbstractMesh,
12271230 break ;
12281231 }
12291232
1230- bone [ currentVtxBone - 4 ] = boneIds . IndexOf ( skin . GetIGameBone ( vertexIndex , currentSkinBone ) . NodeID ) ;
1233+ bone [ currentVtxBone - 4 ] = boneIds . IndexOf ( skin . GetIGameBone ( vertexIndex , currentSkinBone ) . NodeID ) + offset ; // add optional offset
12311234 weight [ currentVtxBone - 4 ] = skin . GetWeight ( vertexIndex , currentSkinBone ) ;
12321235 ++ currentVtxBone ;
12331236 }
0 commit comments