diff --git a/examples/models/models_loading_gltf.c b/examples/models/models_loading_gltf.c index 01a084069..750bd7be2 100644 --- a/examples/models/models_loading_gltf.c +++ b/examples/models/models_loading_gltf.c @@ -35,6 +35,9 @@ int main(void) // Loaf gltf model Model model = LoadModel("resources/models/gltf/robot.glb"); + unsigned int animationCount; + ModelAnimation *modelAnimations = LoadModelAnimations("resources/models/gltf/robot.glb", &animationCount); + ModelAnimation anim = modelAnimations[0]; Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position @@ -49,6 +52,7 @@ int main(void) // Update //---------------------------------------------------------------------------------- UpdateCamera(&camera); + UpdateModelAnimation(model, anim, 2); //---------------------------------------------------------------------------------- // Draw diff --git a/src/rmodels.c b/src/rmodels.c index 93686881a..0c5e68377 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -5222,6 +5222,11 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, unsigned in cgltf_options options = { 0 }; cgltf_data *data = NULL; cgltf_result result = cgltf_parse(&options, fileData, dataSize, &data); + if(result != cgltf_result_success) { + TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load glTF data", fileName); + *animCount = 0; + return NULL; + } result = cgltf_load_buffers(&options, data, fileName); if (result != cgltf_result_success) TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load animation buffers", fileName);