diff --git a/code/glTF2Asset.inl b/code/glTF2Asset.inl index acf8cb331..5aa658f61 100644 --- a/code/glTF2Asset.inl +++ b/code/glTF2Asset.inl @@ -1216,12 +1216,15 @@ inline void Asset::Load(const std::string& pFile, bool isBinary) // Read the "scene" property, which specifies which scene to load // and recursively load everything referenced by it + unsigned int sceneIndex = 0; if (Value* scene = FindUInt(doc, "scene")) { - unsigned int sceneIndex = scene->GetUint(); + sceneIndex = scene->GetUint(); + } - Ref s = scenes.Retrieve(sceneIndex); - - this->scene = s; + if (Value* scenesArray = FindArray(doc, "scenes")) { + if (sceneIndex < scenesArray->Size()) { + this->scene = scenes.Retrieve(sceneIndex); + } } // Clean up