瀏覽代碼

fix : added ground scaling in the y computation

jbousquie 9 年之前
父節點
當前提交
eaa813613c
共有 1 個文件被更改,包括 5 次插入1 次删除
  1. 5 1
      src/Mesh/babylon.groundMesh.ts

+ 5 - 1
src/Mesh/babylon.groundMesh.ts

@@ -36,6 +36,8 @@
             // express x and y in the ground local system
             // express x and y in the ground local system
             x -= this.position.x;
             x -= this.position.x;
             z -= this.position.z;
             z -= this.position.z;
+            x /= this.scaling.x;
+            z /= this.scaling.z;
             if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
             if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
                 return this.position.y;
                 return this.position.y;
             }
             }
@@ -45,7 +47,7 @@
             var facet = this._getFacetAt(x, z);
             var facet = this._getFacetAt(x, z);
             var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
             var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
             // return y in the World system
             // return y in the World system
-            return y + this.position.y;
+            return y * this.scaling.y + this.position.y;
         }
         }
 
 
         /**
         /**
@@ -70,6 +72,8 @@
             // express x and y in the ground local system
             // express x and y in the ground local system
             x -= this.position.x;
             x -= this.position.x;
             z -= this.position.z;
             z -= this.position.z;
+            x /= this.scaling.x;
+            z /= this.scaling.z;
             if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
             if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
                 return;
                 return;
             }
             }