Browse Source

Add checks for extensions required to glTF loader

Gary Hsu 7 years ago
parent
commit
be08556831
1 changed files with 12 additions and 0 deletions
  1. 12 0
      loaders/src/glTF/2.0/babylon.glTFLoader.ts

+ 12 - 0
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -123,6 +123,7 @@ module BABYLON.GLTF2 {
                 this._state = GLTFLoaderState.Loading;
 
                 this._loadData(data);
+                this._checkExtensions();
 
                 const promises = new Array<Promise<void>>();
 
@@ -231,6 +232,17 @@ module BABYLON.GLTF2 {
             }
         }
 
+        private _checkExtensions(): void {
+            if (this._gltf.extensionsRequired) {
+                for (const name of this._gltf.extensionsRequired) {
+                    const extension = this._extensions[name];
+                    if (!extension || !extension.enabled) {
+                        throw new Error(`Require extension ${name} is not available`);
+                    }
+                }
+            }
+        }
+
         private _createRootNode(): ILoaderNode {
             this._rootBabylonMesh = new Mesh("__root__", this._babylonScene);
             const rootNode = { _babylonMesh: this._rootBabylonMesh } as ILoaderNode;