Parcourir la source

Inspector - fix bug with boundingbox with objects without vertices

Julian il y a 8 ans
Parent
commit
079b7c1a40

Fichier diff supprimé car celui-ci est trop grand
+ 251 - 251
dist/preview release/inspector/babylon.inspector.bundle.js


+ 36 - 36
dist/preview release/inspector/babylon.inspector.d.ts

@@ -113,7 +113,7 @@ declare module INSPECTOR {
             type: typeof BABYLON.BaseTexture;
         };
         'FontTexture': {
-            type: any;
+            type: typeof BABYLON.FontTexture;
         };
         'Sound': {
             type: typeof BABYLON.Sound;
@@ -142,23 +142,23 @@ declare module INSPECTOR {
             format: (mat: BABYLON.StandardMaterial) => string;
         };
         'PrimitiveAlignment': {
-            type: any;
+            type: typeof BABYLON.PrimitiveAlignment;
             properties: string[];
         };
         'PrimitiveThickness': {
-            type: any;
+            type: typeof BABYLON.PrimitiveThickness;
             properties: string[];
         };
         'BoundingInfo2D': {
-            type: any;
+            type: typeof BABYLON.BoundingInfo2D;
             properties: string[];
         };
         'SolidColorBrush2D': {
-            type: any;
+            type: typeof BABYLON.SolidColorBrush2D;
             properties: string[];
         };
         'GradientColorBrush2D': {
-            type: any;
+            type: typeof BABYLON.GradientColorBrush2D;
             properties: string[];
         };
         'PBRMaterial': {
@@ -166,94 +166,94 @@ declare module INSPECTOR {
             properties: string[];
         };
         'Canvas2D': {
-            type: any;
+            type: typeof BABYLON.Canvas2D;
         };
         'Canvas2DEngineBoundData': {
-            type: any;
+            type: typeof BABYLON.Canvas2DEngineBoundData;
         };
         'Ellipse2D': {
-            type: any;
+            type: typeof BABYLON.Ellipse2D;
         };
         'Ellipse2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Ellipse2DInstanceData;
         };
         'Ellipse2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Ellipse2DRenderCache;
         };
         'Group2D': {
-            type: any;
+            type: typeof BABYLON.Group2D;
         };
         'IntersectInfo2D': {
-            type: any;
+            type: typeof BABYLON.IntersectInfo2D;
         };
         'Lines2D': {
-            type: any;
+            type: typeof BABYLON.Lines2D;
         };
         'Lines2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Lines2DInstanceData;
         };
         'Lines2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Lines2DRenderCache;
         };
         'PrepareRender2DContext': {
-            type: any;
+            type: typeof BABYLON.PrepareRender2DContext;
         };
         'Prim2DBase': {
-            type: any;
+            type: typeof BABYLON.Prim2DBase;
         };
         'Prim2DClassInfo': {
-            type: any;
+            type: typeof BABYLON.Prim2DClassInfo;
         };
         'Prim2DPropInfo': {
-            type: any;
+            type: typeof BABYLON.Prim2DPropInfo;
         };
         'Rectangle2D': {
-            type: any;
+            type: typeof BABYLON.Rectangle2D;
         };
         'Rectangle2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Rectangle2DInstanceData;
         };
         'Rectangle2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Rectangle2DRenderCache;
         };
         'Render2DContext': {
-            type: any;
+            type: typeof BABYLON.Render2DContext;
         };
         'RenderablePrim2D': {
-            type: any;
+            type: typeof BABYLON.RenderablePrim2D;
         };
         'ScreenSpaceCanvas2D': {
-            type: any;
+            type: typeof BABYLON.ScreenSpaceCanvas2D;
         };
         'Shape2D': {
-            type: any;
+            type: typeof BABYLON.Shape2D;
         };
         'Shape2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Shape2DInstanceData;
         };
         'Sprite2D': {
-            type: any;
+            type: typeof BABYLON.Sprite2D;
         };
         'Sprite2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Sprite2DInstanceData;
         };
         'Sprite2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Sprite2DRenderCache;
         };
         'Text2D': {
-            type: any;
+            type: typeof BABYLON.Text2D;
         };
         'Text2DInstanceData': {
-            type: any;
+            type: typeof BABYLON.Text2DInstanceData;
         };
         'Text2DRenderCache': {
-            type: any;
+            type: typeof BABYLON.Text2DRenderCache;
         };
         'WorldSpaceCanvas2D': {
-            type: any;
+            type: typeof BABYLON.WorldSpaceCanvas2D;
         };
         'WorldSpaceCanvas2DNode': {
-            type: any;
+            type: typeof BABYLON.WorldSpaceCanvas2DNode;
         };
     };
 }

+ 3 - 1
dist/preview release/inspector/babylon.inspector.js

@@ -1237,7 +1237,9 @@ var INSPECTOR;
             var tools = [];
             tools.push(new INSPECTOR.Checkbox(this));
             tools.push(new INSPECTOR.DebugArea(this));
-            tools.push(new INSPECTOR.BoundingBox(this));
+            if (this._obj.getTotalVertices() > 0) {
+                tools.push(new INSPECTOR.BoundingBox(this));
+            }
             tools.push(new INSPECTOR.Info(this));
             return tools;
         };

Fichier diff supprimé car celui-ci est trop grand
+ 3 - 3
dist/preview release/inspector/babylon.inspector.min.js


+ 55 - 52
inspector/src/adapters/MeshAdapter.ts

@@ -1,65 +1,68 @@
 module INSPECTOR {
-    
-    export class MeshAdapter 
-        extends Adapter 
-        implements IToolVisible, IToolDebug, IToolBoundingBox, IToolInfo{
-
-        /** Keep track of the axis of the actual object */ 
-        private _axis : Array<BABYLON.Mesh> = [];
-        
-        constructor(obj:BABYLON.AbstractMesh) {
+
+    export class MeshAdapter
+        extends Adapter
+        implements IToolVisible, IToolDebug, IToolBoundingBox, IToolInfo {
+
+        /** Keep track of the axis of the actual object */
+        private _axis: Array<BABYLON.Mesh> = [];
+
+        constructor(obj: BABYLON.AbstractMesh) {
             super(obj);
         }
-        
+
         /** Returns the name displayed in the tree */
-        public id() : string {
+        public id(): string {
             let str = '';
             if (this._obj.name) {
                 str = this._obj.name;
             } // otherwise nothing displayed        
             return str;
         }
-        
+
         /** Returns the type of this object - displayed in the tree */
-        public type() : string{
+        public type(): string {
             return Helpers.GET_TYPE(this._obj);
         }
-        
+
         /** Returns the list of properties to be displayed for this adapter */
-        public getProperties() : Array<PropertyLine> {
-           let propertiesLines : Array<PropertyLine> = [];
-                
+        public getProperties(): Array<PropertyLine> {
+            let propertiesLines: Array<PropertyLine> = [];
+
             for (let dirty of PROPERTIES['Mesh'].properties) {
                 let infos = new Property(dirty, this._obj);
                 propertiesLines.push(new PropertyLine(infos));
             }
-            return propertiesLines; 
+            return propertiesLines;
         }
-        
-        public getTools() : Array<AbstractTreeTool> {
+
+        public getTools(): Array<AbstractTreeTool> {
             let tools = [];
             tools.push(new Checkbox(this));
-            tools.push(new DebugArea(this));  
-            tools.push(new BoundingBox(this));   
-            tools.push(new Info(this));   
+            tools.push(new DebugArea(this));
+            if ((this._obj as BABYLON.AbstractMesh).getTotalVertices() > 0) {
+                tools.push(new BoundingBox(this));
+            }
+
+            tools.push(new Info(this));
             return tools;
         }
-        
-        public setVisible(b:boolean) {
+
+        public setVisible(b: boolean) {
             this._obj.setEnabled(b);
             this._obj.isVisible = b;
-        }        
-        public isVisible() : boolean {
+        }
+        public isVisible(): boolean {
             return this._obj.isEnabled() && this._obj.isVisible;
         }
-        public isBoxVisible() : boolean {
+        public isBoxVisible(): boolean {
             return (this._obj as BABYLON.AbstractMesh).showBoundingBox;
         }
-        public setBoxVisible(b:boolean) {            
+        public setBoxVisible(b: boolean) {
             return (this._obj as BABYLON.AbstractMesh).showBoundingBox = b;
         }
- 
-        public debug(b:boolean) {
+
+        public debug(b: boolean) {
             // Draw axis the first time
             if (this._axis.length == 0) {
                 this._drawAxis();
@@ -71,15 +74,15 @@ module INSPECTOR {
         }
 
         /** Returns some information about this mesh */
-        public getInfo() : string {
+        public getInfo(): string {
             return `${(this._obj as BABYLON.AbstractMesh).getTotalVertices()} vertices`;
         }
-        
+
         /** Overrides super.highlight */
-        public highlight(b:boolean) {
+        public highlight(b: boolean) {
             this.actualObject.renderOutline = b;
-			this.actualObject.outlineWidth = 0.25;
-			this.actualObject.outlineColor = BABYLON.Color3.Yellow();
+            this.actualObject.outlineWidth = 0.25;
+            this.actualObject.outlineColor = BABYLON.Color3.Yellow();
         }
         /** Draw X, Y and Z axis for the actual object if this adapter.
          * Should be called only one time as it will fill this._axis
@@ -87,14 +90,14 @@ module INSPECTOR {
         private _drawAxis() {
             this._obj.computeWorldMatrix();
             var m = this._obj.getWorldMatrix();
-            
+
             // Axis
-            var x = new BABYLON.Vector3(8,0,0);
-            var y = new BABYLON.Vector3(0,8,0);
-            var z = new BABYLON.Vector3(0,0,8);
-            
+            var x = new BABYLON.Vector3(8, 0, 0);
+            var y = new BABYLON.Vector3(0, 8, 0);
+            var z = new BABYLON.Vector3(0, 0, 8);
+
             // Draw an axis of the given color
-            let _drawAxis = (color, start, end) : BABYLON.LinesMesh => {
+            let _drawAxis = (color, start, end): BABYLON.LinesMesh => {
                 let axis = BABYLON.Mesh.CreateLines("###axis###", [
                     start,
                     end
@@ -103,28 +106,28 @@ module INSPECTOR {
                 axis.renderingGroupId = 1;
                 return axis;
             };
-            
+
             // X axis
             let xAxis = _drawAxis(
-                    BABYLON.Color3.Red(), 
-                    this._obj.getAbsolutePosition(),
-                    BABYLON.Vector3.TransformCoordinates(x, m));
+                BABYLON.Color3.Red(),
+                this._obj.getAbsolutePosition(),
+                BABYLON.Vector3.TransformCoordinates(x, m));
             xAxis.position.subtractInPlace(this._obj.position);
             xAxis.parent = this._obj;
             this._axis.push(xAxis);
             // Y axis        
             let yAxis = _drawAxis(
-                    BABYLON.Color3.Green(), 
-                    this._obj.getAbsolutePosition(),
-                    BABYLON.Vector3.TransformCoordinates(y, m));
+                BABYLON.Color3.Green(),
+                this._obj.getAbsolutePosition(),
+                BABYLON.Vector3.TransformCoordinates(y, m));
             yAxis.parent = this._obj;
             yAxis.position.subtractInPlace(this._obj.position);
             this._axis.push(yAxis);
             // Z axis
             let zAxis = _drawAxis(
-                    BABYLON.Color3.Blue(), 
-                    this._obj.getAbsolutePosition(),
-                    BABYLON.Vector3.TransformCoordinates(z, m));
+                BABYLON.Color3.Blue(),
+                this._obj.getAbsolutePosition(),
+                BABYLON.Vector3.TransformCoordinates(z, m));
             zAxis.parent = this._obj;
             zAxis.position.subtractInPlace(this._obj.position);
             this._axis.push(zAxis);

+ 2 - 0
inspector/test/index.js

@@ -201,6 +201,8 @@ var Test = (function () {
 
         plane.material = materialPlane;
 
+        new BABYLON.Mesh('mesh_without_geometry', scene);
+
 
 
         var d = 50;