Andrew V Butt Sr hace 5 años
padre
commit
e1e7dadaee
Se han modificado 1 ficheros con 3 adiciones y 2 borrados
  1. 3 2
      src/Meshes/Builders/capsuleBuilder.ts

+ 3 - 2
src/Meshes/Builders/capsuleBuilder.ts

@@ -43,7 +43,8 @@ VertexData.CreateCapsule = function(
 
     var index = 0,
     indexArray = [],
-    halfHeight = height / 2;
+    heightMinusCaps = height - (radiusTop+radiusBottom),
+    halfHeight = heightMinusCaps / 2;
 
     var x, y;
     var normal = Vector3.Zero();
@@ -104,7 +105,7 @@ VertexData.CreateCapsule = function(
         indexArray.push(indexRow);
     }
 
-    var cone_height = height + cosAlpha * radiusTop - cosAlpha * radiusBottom;
+    var cone_height = (height - radiusTop - radiusBottom) + cosAlpha * radiusTop - cosAlpha * radiusBottom;
     var slope = sinAlpha * (radiusBottom - radiusTop) / cone_height;
     for (y = 1; y <= heightSegments; y++) {
         var indexRow = [];