瀏覽代碼

Merge pull request #5450 from barroij/fixLinePicking

Fix line picking
David Catuhe 6 年之前
父節點
當前提交
73f5e8e156
共有 1 個文件被更改,包括 6 次插入4 次删除
  1. 6 4
      src/Culling/babylon.ray.ts

+ 6 - 4
src/Culling/babylon.ray.ts

@@ -385,14 +385,16 @@ module BABYLON {
             // get the difference of the two closest points
             const qtc = Tmp.Vector3[4];
             v.scaleToRef(tc, qtc);
-            const dP = Tmp.Vector3[5];
-            u.scaleToRef(sc, dP);
-            dP.addInPlace(w).subtractInPlace(qtc);  // = S1(sc) - S2(tc)
+            const qsc = Tmp.Vector3[5];
+            u.scaleToRef(sc, qsc);
+            qsc.addInPlace(w);
+            const dP = Tmp.Vector3[6];
+            qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
 
             var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold));   // return intersection result
 
             if (isIntersected) {
-                return qtc.length();
+                return qsc.length();
             }
             return -1;
         }