diff --git a/modules/processes/mill/raster/3D b/modules/processes/mill/raster/3D
index aaa3a83490c6e781bd540d2fffc68e04e48f68a5..c7ed5b15dd21d5d62a6de006499b44b310e9cdf7 100644
--- a/modules/processes/mill/raster/3D
+++ b/modules/processes/mill/raster/3D
@@ -227,26 +227,50 @@ function calculate_path() {
    //
    // line loop
    //
-   var step = 1
    var ix = 0
-   var iy = 10
-   var x1 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
-   var y1 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
+   var iy = mod.height-1
+   var dx = 1
+   var dy = 0
+   //var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
+   //var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
    while (1) {
-      ix += step
-      if (ix == mod.width)
+      var ixp = ix
+      var iyp = iy
+      ix += dx
+      iy += dy
+   var line = document.createElementNS('http://www.w3.org/2000/svg','line')
+   line.setAttribute('stroke','black')
+   line.setAttribute('stroke-width',1)
+   line.setAttribute('stroke-linecap','round')
+            line.setAttribute('x1',ixp)
+            line.setAttribute('y1',iyp)
+            line.setAttribute('x2',ix)
+            line.setAttribute('y2',iy)
+   g.appendChild(line)
+      //var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
+      //var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
+      if (iy <= 0)
          break;
-      var x2 = mod.xmin+(mod.xmax-mod.xmin)*ix/(mod.width-1)
-      var y2 = mod.ymin+(mod.ymax-mod.ymin)*iy/(mod.height-1)
-      var line = document.createElementNS('http://www.w3.org/2000/svg','line')
-      line.setAttribute('stroke','black')
-      line.setAttribute('stroke-width',1)
-      line.setAttribute('stroke-linecap','round')
-      line.setAttribute('x1',x1)
-      line.setAttribute('y1',y1)
-      line.setAttribute('x2',x2)
-      line.setAttribute('y2',y2)
-      g.appendChild(line)
+      if (ix == (mod.width-1)) {
+         if (dx == 1) {
+            dx = 0
+            dy = -10
+            }
+         else {
+            dx = -1
+            dy = 0
+            }
+         }
+      else if (ix == 0) {
+         if (dx == -1) {
+            dx = 0
+            dy = -10
+            }
+         else {
+            dx = 1
+            dy = 0
+            }
+         }
       }
    mod.label.nodeValue = 'calculate'
    mod.labelspan.style.fontWeight = 'normal'