Răsfoiți Sursa

Merge pull request #1978 from gstanlo/master

glTF/2.0: Pick scene 0 as scene to load if no "scene" property is specified
Kim Kulling 7 ani în urmă
părinte
comite
604b56b96f
1 a modificat fișierele cu 7 adăugiri și 4 ștergeri
  1. 7 4
      code/glTF2Asset.inl

+ 7 - 4
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();
-
-        Ref<Scene> s = scenes.Retrieve(sceneIndex);
+        sceneIndex = scene->GetUint();
+    }
 
-        this->scene = s;
+    if (Value* scenesArray = FindArray(doc, "scenes")) {
+        if (sceneIndex < scenesArray->Size()) {
+            this->scene = scenes.Retrieve(sceneIndex);
+        }
     }
 
     // Clean up