diff --git a/examples/edit.js b/examples/edit.js index 54311a8c42..d39a20c2e3 100644 --- a/examples/edit.js +++ b/examples/edit.js @@ -728,9 +728,10 @@ function rayPlaneIntersection2(pickRay, point, normal) { // This version of the test returns false if the ray is directed away from the plane // var collides = Vec3.dot(pickRay.direction, normal); - if (collides > 0.0) return false; - var d = -Vec3.dot(point, normal); + if (((collides > 0.0) && (d > 0.0)) || ((collides < 0.0) && (d < 0.0))) { + return false; + } var t = -(Vec3.dot(pickRay.origin, normal) + d) / collides; return Vec3.sum(pickRay.origin, Vec3.multiply(pickRay.direction, t)); diff --git a/examples/libraries/entitySelectionTool.js b/examples/libraries/entitySelectionTool.js index 3627a0a05e..1834962e77 100644 --- a/examples/libraries/entitySelectionTool.js +++ b/examples/libraries/entitySelectionTool.js @@ -2334,10 +2334,13 @@ SelectionDisplay = (function() { // If the mouse is too close to the horizon of the pick plane, stop moving var MIN_AZIMUTH = 0.02; // Radians var azimuth = translateXZTool.azimuth(pickRay.origin, pick); + if (wantDebug) { + print("Start Azimuth: " + translateXZTool.startingAzimuth + ", Azimuth: " + azimuth); + } if ((translateXZTool.startingAzimuth > 0.0 && azimuth < MIN_AZIMUTH) || - (translateXZTool.startingAzimuth < 0.0 && azimuth > MIN_AZIMUTH)) { + (translateXZTool.startingAzimuth < 0.0 && azimuth > -MIN_AZIMUTH)) { if (wantDebug) { - print("Azimuth = " + azimuth); + print("too close to horizon!"); } return; }