Просмотр исходного кода

real segment number and segment lost taken in account on update

jbousquie 10 лет назад
Родитель
Сommit
e151f7a715
1 измененных файлов с 41 добавлено и 2 удалено
  1. 41 2
      Babylon/Mesh/babylon.mesh.ts

+ 41 - 2
Babylon/Mesh/babylon.mesh.ts

@@ -1350,8 +1350,45 @@
             if (linesInstance) {  //  dashed lines update
                 var positionsOfLines = function(points) {
                     var positionFunction = function(positions) {
-
-                    
+                        var curvect = Vector3.Zero();
+                        var nbSeg = positions.length / 6;
+                        var lg = 0;
+                        var nb = 0;
+                        var shft = 0;
+                        var dashshft = 0;
+                        var curshft = 0;
+                        var p = 0;
+                        var i = 0;
+                        var j = 0;
+                        for (i = 0; i < points.length - 1; i++) {
+                            points[i + 1].subtractToRef(points[i], curvect);
+                            lg += curvect.length();
+                        }
+                        shft = lg / nbSeg;
+                        dashshft = (<any>linesInstance).dashSize * shft / ((<any>linesInstance).dashSize + (<any>linesInstance).gapSize);
+                        for (i = 0; i < points.length - 1; i++) {
+                            points[i + 1].subtractToRef(points[i], curvect);
+                            curvect.normalize();
+                            nb = Math.floor(curvect.length() / shft);
+                            j = 0;
+                            while (j < nb && p < positions.length) {
+                                curshft = shft * j;
+                                positions[p] = points[i].x + curshft * curvect.x;
+                                positions[p + 1] = points[i].y + curshft * curvect.y;
+                                positions[p + 2] = points[i].z + curshft * curvect.z;
+                                positions[p + 3] = points[i].x + (curshft + dashshft)* curvect.x;
+                                positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
+                                positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
+                                p += 6;
+                                j++;
+                            }
+                        }
+                        while (p < positions.length) {
+                            positions[p] = points[i].x;
+                            positions[p + 1] = points[i].y;
+                            positions[p + 2] = points[i].z;
+                            p += 3;
+                        }
                     };
                     return positionFunction;   
                 };
@@ -1363,6 +1400,8 @@
             var dashedLines = new LinesMesh(name, scene, updatable);
             var vertexData = VertexData.CreateDashedLines(points, dashSize, gapSize, dashNb);
             vertexData.applyToMesh(dashedLines, updatable);
+            (<any>dashedLines).dashSize = dashSize;
+            (<any>dashedLines).gapSize = gapSize;
             return dashedLines;
         }