Ver código fonte

Inspector - Fix bug when canvas2d is not included in the webapp

Temechon 8 anos atrás
pai
commit
1d8f9974b1

Diferenças do arquivo suprimidas por serem muito extensas
+ 2 - 2
dist/preview release/inspector/babylon.inspector.bundle.js


+ 29 - 24
dist/preview release/inspector/babylon.inspector.js

@@ -985,30 +985,32 @@ var INSPECTOR;
         PropertyFormatter.format = function (obj, prop) {
             // Get original value;
             var value = obj[prop];
-            // PrimitiveAlignment
-            if (obj instanceof BABYLON.PrimitiveAlignment) {
-                if (prop === 'horizontal') {
-                    switch (value) {
-                        case BABYLON.PrimitiveAlignment.AlignLeft:
-                            return 'left';
-                        case BABYLON.PrimitiveAlignment.AlignRight:
-                            return 'right';
-                        case BABYLON.PrimitiveAlignment.AlignCenter:
-                            return 'center';
-                        case BABYLON.PrimitiveAlignment.AlignStretch:
-                            return 'stretch';
+            // test if type PrimitiveAlignment is available (only included in canvas2d)
+            if (BABYLON.PrimitiveAlignment) {
+                if (obj instanceof BABYLON.PrimitiveAlignment) {
+                    if (prop === 'horizontal') {
+                        switch (value) {
+                            case BABYLON.PrimitiveAlignment.AlignLeft:
+                                return 'left';
+                            case BABYLON.PrimitiveAlignment.AlignRight:
+                                return 'right';
+                            case BABYLON.PrimitiveAlignment.AlignCenter:
+                                return 'center';
+                            case BABYLON.PrimitiveAlignment.AlignStretch:
+                                return 'stretch';
+                        }
                     }
-                }
-                else if (prop === 'vertical') {
-                    switch (value) {
-                        case BABYLON.PrimitiveAlignment.AlignTop:
-                            return 'top';
-                        case BABYLON.PrimitiveAlignment.AlignBottom:
-                            return 'bottom';
-                        case BABYLON.PrimitiveAlignment.AlignCenter:
-                            return 'center';
-                        case BABYLON.PrimitiveAlignment.AlignStretch:
-                            return 'stretch';
+                    else if (prop === 'vertical') {
+                        switch (value) {
+                            case BABYLON.PrimitiveAlignment.AlignTop:
+                                return 'top';
+                            case BABYLON.PrimitiveAlignment.AlignBottom:
+                                return 'bottom';
+                            case BABYLON.PrimitiveAlignment.AlignCenter:
+                                return 'center';
+                            case BABYLON.PrimitiveAlignment.AlignStretch:
+                                return 'stretch';
+                        }
                     }
                 }
             }
@@ -2743,7 +2745,10 @@ var INSPECTOR;
             this._tabs.push(this._meshTab);
             this._tabs.push(new INSPECTOR.ShaderTab(this, this._inspector));
             this._tabs.push(new INSPECTOR.LightTab(this, this._inspector));
-            this._tabs.push(new INSPECTOR.Canvas2DTab(this, this._inspector));
+            // Add only the tab canvas2D if Canvas2D is defined
+            if (BABYLON.Canvas2D) {
+                this._tabs.push(new INSPECTOR.Canvas2DTab(this, this._inspector));
+            }
             this._tabs.push(new INSPECTOR.MaterialTab(this, this._inspector));
             this._toolBar = new INSPECTOR.Toolbar(this._inspector);
             this._build();

Diferenças do arquivo suprimidas por serem muito extensas
+ 2 - 2
dist/preview release/inspector/babylon.inspector.min.js


+ 25 - 23
inspector/src/details/PropertyLine.ts

@@ -8,29 +8,31 @@ module INSPECTOR {
         public static format(obj: any, prop:string) : string {
             // Get original value;
             let value = obj[prop];
-            // PrimitiveAlignment
-            if (obj instanceof BABYLON.PrimitiveAlignment) {
-                if (prop === 'horizontal') {
-                    switch(value) {
-                        case BABYLON.PrimitiveAlignment.AlignLeft:
-                            return 'left';
-                        case BABYLON.PrimitiveAlignment.AlignRight:
-                            return 'right';
-                        case BABYLON.PrimitiveAlignment.AlignCenter:
-                            return 'center';
-                        case BABYLON.PrimitiveAlignment.AlignStretch:
-                            return 'stretch';
-                    }
-                } else if (prop === 'vertical') {
-                    switch(value) {
-                        case BABYLON.PrimitiveAlignment.AlignTop:
-                            return 'top';
-                        case BABYLON.PrimitiveAlignment.AlignBottom:
-                            return 'bottom';
-                        case BABYLON.PrimitiveAlignment.AlignCenter:
-                            return 'center';
-                        case BABYLON.PrimitiveAlignment.AlignStretch:
-                            return 'stretch';
+            // test if type PrimitiveAlignment is available (only included in canvas2d)
+            if (BABYLON.PrimitiveAlignment) {                
+                if (obj instanceof BABYLON.PrimitiveAlignment) {
+                    if (prop === 'horizontal') {
+                        switch(value) {
+                            case BABYLON.PrimitiveAlignment.AlignLeft:
+                                return 'left';
+                            case BABYLON.PrimitiveAlignment.AlignRight:
+                                return 'right';
+                            case BABYLON.PrimitiveAlignment.AlignCenter:
+                                return 'center';
+                            case BABYLON.PrimitiveAlignment.AlignStretch:
+                                return 'stretch';
+                        }
+                    } else if (prop === 'vertical') {
+                        switch(value) {
+                            case BABYLON.PrimitiveAlignment.AlignTop:
+                                return 'top';
+                            case BABYLON.PrimitiveAlignment.AlignBottom:
+                                return 'bottom';
+                            case BABYLON.PrimitiveAlignment.AlignCenter:
+                                return 'center';
+                            case BABYLON.PrimitiveAlignment.AlignStretch:
+                                return 'stretch';
+                        }
                     }
                 }
             }

+ 4 - 1
inspector/src/tabs/TabBar.ts

@@ -30,7 +30,10 @@ module INSPECTOR {
             this._tabs.push(this._meshTab);
             this._tabs.push(new ShaderTab(this, this._inspector));
             this._tabs.push(new LightTab(this, this._inspector));
-            this._tabs.push(new Canvas2DTab(this, this._inspector));
+            // Add only the tab canvas2D if Canvas2D is defined
+            if (BABYLON.Canvas2D) {
+                this._tabs.push(new Canvas2DTab(this, this._inspector));
+            }
             this._tabs.push(new MaterialTab(this, this._inspector));
 
             this._toolBar = new Toolbar(this._inspector);