diff --git a/code/glTF2Importer.cpp b/code/glTF2Importer.cpp index ca12d3657..94e5ca3f1 100644 --- a/code/glTF2Importer.cpp +++ b/code/glTF2Importer.cpp @@ -516,7 +516,9 @@ aiNode* ImportNode(aiScene* pScene, glTF2::Asset& r, std::vector& { Node& node = *ptr; - aiNode* ainode = new aiNode(node.name); + std::string nameOrId = node.name.empty() ? node.id : node.name; + + aiNode* ainode = new aiNode(nameOrId); if (!node.children.empty()) { ainode->mNumChildren = unsigned(node.children.size()); diff --git a/test/models/glTF2/2CylinderEngine-glTF-Binary/2CylinderEngine.glb b/test/models/glTF2/2CylinderEngine-glTF-Binary/2CylinderEngine.glb new file mode 100644 index 000000000..0e9b10568 Binary files /dev/null and b/test/models/glTF2/2CylinderEngine-glTF-Binary/2CylinderEngine.glb differ diff --git a/test/unit/utglTF2ImportExport.cpp b/test/unit/utglTF2ImportExport.cpp index c6ccde406..865159d0d 100644 --- a/test/unit/utglTF2ImportExport.cpp +++ b/test/unit/utglTF2ImportExport.cpp @@ -56,6 +56,12 @@ public: return nullptr != scene; } + virtual bool binaryImporterTest() { + Assimp::Importer importer; + const aiScene *scene = importer.ReadFile( ASSIMP_TEST_MODELS_DIR "/glTF2/2CylinderEngine-glTF-Binary/2CylinderEngine.glb", aiProcess_ValidateDataStructure); + return nullptr != scene; + } + #ifndef ASSIMP_BUILD_NO_EXPORT virtual bool exporterTest() { Assimp::Importer importer; @@ -74,6 +80,10 @@ TEST_F( utglTF2ImportExport, importglTF2FromFileTest ) { EXPECT_TRUE( importerTest() ); } +TEST_F( utglTF2ImportExport, importBinaryglTF2FromFileTest ) { + EXPECT_TRUE( binaryImporterTest() ); +} + #ifndef ASSIMP_BUILD_NO_EXPORT TEST_F( utglTF2ImportExport, exportglTF2FromFileTest ) { EXPECT_TRUE( exporterTest() );