jbousquie 10 年之前
父節點
當前提交
7377c08f58
共有 1 個文件被更改,包括 4 次插入4 次删除
  1. 4 4
      src/Math/babylon.math.ts

+ 4 - 4
src/Math/babylon.math.ts

@@ -3619,16 +3619,17 @@
         // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
         // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
         private _normalVector(v0: Vector3, vt: Vector3, va: Vector3): Vector3 {
+            var epsilon = 0.001;
             var normal0: Vector3;
             if (va === undefined || va === null) {
                 var point: Vector3;
-                if (vt.y !== 1) {     // search for a point in the plane
+                if (!Tools.WithinEpsilon(vt.y, 1, epsilon)) {     // search for a point in the plane
                     point = new Vector3(0, -1, 0);
                 }
-                else if (vt.x !== 1) {
+                else if (!Tools.WithinEpsilon(vt.x, 1, epsilon)) {
                     point = new Vector3(1, 0, 0);
                 }
-                else if (vt.z !== 1) {
+                else if (!Tools.WithinEpsilon(vt.z, 1, epsilon)) {
                     point = new Vector3(0, 0, 1);
                 }
                 normal0 = Vector3.Cross(vt, point);
@@ -3636,7 +3637,6 @@
             else {
                 normal0 = Vector3.Cross(vt, va);
                 Vector3.CrossToRef(normal0, vt, normal0);
-                //normal0 = Vector3.Cross(normal0, vt);
             }
             normal0.normalize();
             return normal0;