code: function getNextSearchDir( ptA, ptB, dir ){
  
          var ABdotB = ptB.normSq() - ptB.dot( ptA )
              ,ABdotA = ptB.dot( ptA ) - ptA.normSq()
              ;
  
          // if the origin is farther than either of these points
          // get the direction from one of those points to the origin
          if ( ABdotB < 0 ){
  
              return dir.clone( ptB ).negate();
  
          } else if ( ABdotA > 0 ){
  
              return dir.clone( ptA ).negate();
  
          // otherwise, use the perpendicular direction from the simplex
          } else {
  
              // dir = AB = B - A
              dir.clone( ptB ).vsub( ptA );
              // if (left handed coordinate system)
              // A cross AB < 0 then get perpendicular counterclockwise
              return dir.perp( (ptA.cross( dir ) > 0) );
          }
      }
docs: get the next search direction from two simplex points