diff --git a/code/glTF2/glTF2Asset.h b/code/glTF2/glTF2Asset.h index 90f56f76e..a78d6b53a 100644 --- a/code/glTF2/glTF2Asset.h +++ b/code/glTF2/glTF2Asset.h @@ -725,6 +725,7 @@ struct Mesh : public Object { std::vector primitives; std::vector weights; + std::vector targetNames; Mesh() {} diff --git a/code/glTF2/glTF2Asset.inl b/code/glTF2/glTF2Asset.inl index 93dc1867e..ed23b388a 100644 --- a/code/glTF2/glTF2Asset.inl +++ b/code/glTF2/glTF2Asset.inl @@ -1034,6 +1034,19 @@ inline void Mesh::Read(Value &pJSON_Object, Asset &pAsset_Root) { } } } + + Value *extras = FindObject(pJSON_Object, "extras"); + if (nullptr != extras ) { + if (Value* curTargetNames = FindArray(*extras, "targetNames")) { + this->targetNames.resize(curTargetNames->Size()); + for (unsigned int i = 0; i < curTargetNames->Size(); ++i) { + Value& targetNameValue = (*curTargetNames)[i]; + if (targetNameValue.IsString()) { + this->targetNames[i] = targetNameValue.GetString(); + } + } + } + } } inline void Camera::Read(Value &obj, Asset & /*r*/) { diff --git a/code/glTF2/glTF2Importer.cpp b/code/glTF2/glTF2Importer.cpp index caff630dc..87f170e31 100644 --- a/code/glTF2/glTF2Importer.cpp +++ b/code/glTF2/glTF2Importer.cpp @@ -472,6 +472,9 @@ void glTF2Importer::ImportMeshes(glTF2::Asset &r) { if (mesh.weights.size() > i) { aiAnimMesh.mWeight = mesh.weights[i]; } + if (mesh.targetNames.size() > i) { + aiAnimMesh.mName = mesh.targetNames[i]; + } } }