diff --git a/modules/mesh/height map b/modules/mesh/height map
index 2627d30eae0fca6aa22fff648805806b8dec2a85..bcad4bc641db5b903f620659a46b2387fb3d4172 100644
--- a/modules/mesh/height map	
+++ b/modules/mesh/height map	
@@ -408,6 +408,11 @@ function map_worker() {
          offset += 4
          offset += 2
          //
+         // check normal if needs to be drawn
+         //
+         if (((x1-x0)*(y1-y2)-(x1-x2)*(y1-y0)) >= 0)
+            continue
+         //
          // quantize image coordinates
          //
          x0 = Math.floor((w-1)*(x0-xmin)/(xmax-xmin))
@@ -417,11 +422,6 @@ function map_worker() {
          y1 = Math.floor((h-1)*(y1-ymin)/(ymax-ymin))
          y2 = Math.floor((h-1)*(y2-ymin)/(ymax-ymin))
          //
-         // check normal if needs to be drawn
-         //
-         if (((x1-x0)*(y1-y2)-(x1-x2)*(y1-y0)) >= 0)
-            continue
-         //
          // sort projection order
          //
          if (y1 > y2) {