Browse Source

creating solid bounding box

Ibraheem Osama 7 years ago
parent
commit
cf1db94660
1 changed files with 16 additions and 3 deletions
  1. 16 3
      src/Rendering/babylon.boundingBoxRenderer.ts

+ 16 - 3
src/Rendering/babylon.boundingBoxRenderer.ts

@@ -112,7 +112,6 @@
 
             var engine = this._scene.getEngine();
             engine.setDepthWrite(false);
-            engine.setColorWrite(false);
             this._colorShader._preBind();
 
             var boundingBox = mesh._boundingInfo.boundingBox;
@@ -125,18 +124,32 @@
                 .multiply(Matrix.Translation(median.x, median.y, median.z))
                 .multiply(boundingBox.getWorldMatrix());
 
+            // VBOs
             engine.bindBuffers(this._vertexBuffers, this._indexBuffer, <Effect>this._colorShader.getEffect());
 
+
+            // Back
+            //engine.setDepthFunctionToGreaterOrEqual();
+            this._scene.resetCachedMaterial();
+            this._colorShader.setColor4("color", this.backColor.toColor4());
+            this._colorShader.bind(worldMatrix);
+
+            // Draw order
+            engine.drawElementsType(Material.LineListDrawMode, 0, 24);
+
+
+            // Front
             engine.setDepthFunctionToLess();
             this._scene.resetCachedMaterial();
+            this._colorShader.setColor4("color", this.frontColor.toColor4());
             this._colorShader.bind(worldMatrix);
 
-            engine.drawElementsType(Material.TriangleFillMode, 0, 24);
+            // Draw order
+            engine.drawElementsType(Material.LineListDrawMode, 0, 24);
 
             this._colorShader.unbind();
             engine.setDepthFunctionToLessOrEqual();
             engine.setDepthWrite(true);
-            engine.setColorWrite(true);
         }
 
         public dispose(): void {