Procházet zdrojové kódy

Address some issues with inspector and improved some logging

Gary Hsu před 7 roky
rodič
revize
721d736a16

+ 1 - 1
inspector/src/details/Property.ts

@@ -12,7 +12,7 @@ module INSPECTOR {
         /** The obj parent  */
         private _parentObj: any;
 
-        constructor(prop: string, obj: any, parentObj?: PropertyLine) {
+        constructor(prop: string, obj: any, parentObj?: any) {
             this._property = prop;
             this._obj = obj;
             this._parentObj = parentObj || null;

+ 2 - 2
inspector/src/tabs/GLTFTab.ts

@@ -202,7 +202,7 @@ module INSPECTOR {
             const details = new Array<PropertyLine>();
             for (const key in defaults) {
                 if (key !== "extensions") {
-                    details.push(new PropertyLine(new Property(key, defaults)));
+                    details.push(new PropertyLine(new Property(key, defaults, this._inspector.scene)));
                 }
             }
             detailsPanel.details = details;
@@ -217,7 +217,7 @@ module INSPECTOR {
             const details = new Array<PropertyLine>();
             for (const key in defaults) {
                 if (key !== "enabled") {
-                    details.push(new PropertyLine(new Property(key, defaults)));
+                    details.push(new PropertyLine(new Property(key, defaults, this._inspector.scene)));
                 }
             }
             detailsPanel.details = details;

+ 8 - 5
loaders/src/glTF/2.0/babylon.glTFLoader.ts

@@ -1402,14 +1402,16 @@ module BABYLON.GLTF2 {
                 return promise;
             }
 
+            this._parent._logOpen(`${context}`);
+
             const texture = GLTFLoader._GetProperty(`${context}/index`, this._gltf.textures, textureInfo.index);
-            const textureContext = `#/textures/${textureInfo.index}`;
+            context = `#/textures/${textureInfo.index}`;
 
             const promises = new Array<Promise<void>>();
 
-            this._parent._logOpen(`${context} ${textureContext} ${texture.name || ""}`);
+            this._parent._logOpen(`${context} ${texture.name || ""}`);
 
-            const sampler = (texture.sampler == undefined ? this._defaultSampler : GLTFLoader._GetProperty(`${textureContext}/sampler`, this._gltf.samplers, texture.sampler));
+            const sampler = (texture.sampler == undefined ? this._defaultSampler : GLTFLoader._GetProperty(`${context}/sampler`, this._gltf.samplers, texture.sampler));
             const samplerData = this._loadSampler(`#/samplers/${sampler._index}`, sampler);
 
             const deferred = new Deferred<void>();
@@ -1419,7 +1421,7 @@ module BABYLON.GLTF2 {
                 }
             }, (message, exception) => {
                 if (!this._disposed) {
-                    deferred.reject(new Error(`${textureContext}: ${(exception && exception.message) ? exception.message : message || "Failed to load texture"}`));
+                    deferred.reject(new Error(`${context}: ${(exception && exception.message) ? exception.message : message || "Failed to load texture"}`));
                 }
             });
             promises.push(deferred.promise);
@@ -1429,7 +1431,7 @@ module BABYLON.GLTF2 {
             babylonTexture.wrapV = samplerData.wrapV;
             babylonTexture.coordinatesIndex = textureInfo.texCoord || 0;
 
-            const image = GLTFLoader._GetProperty(`${textureContext}/source`, this._gltf.images, texture.source);
+            const image = GLTFLoader._GetProperty(`${context}/source`, this._gltf.images, texture.source);
             promises.push(this._loadImageAsync(`#/images/${image._index}`, image).then(blob => {
                 const dataUrl = `data:${this._rootUrl}${image.uri || `image${image._index}`}`;
                 babylonTexture.updateURL(dataUrl, blob);
@@ -1439,6 +1441,7 @@ module BABYLON.GLTF2 {
             this._parent.onTextureLoadedObservable.notifyObservers(babylonTexture);
 
             this._parent._logClose();
+            this._parent._logClose();
 
             return Promise.all(promises).then(() => {});
         }

+ 2 - 5
loaders/src/glTF/babylon.glTFFileLoader.ts

@@ -191,15 +191,12 @@ module BABYLON {
         public readonly onLogObservable = new Observable<string>();
 
         private _logIndentLevel = 0;
+        private static readonly _logSpaces = "                                ";
 
         /** @hidden */
         public _log(message: string): void {
             if (this.loggingEnabled) {
-                let spaces = "";
-                for (let i = 0; i < this._logIndentLevel; i++) {
-                    spaces += "  ";
-                }
-
+                const spaces = GLTFFileLoader._logSpaces.substr(0, this._logIndentLevel * 2);
                 this.onLogObservable.notifyObservers(`${spaces}${message}`);
                 Tools.Log(`${spaces}${message}`);
             }