prompter: My goal is to implement an raytracer.
What is the fastest known ray triangle intersection useful for an implementation of a raytracer? Please provide pseudocode for it if possible. assistant: The Möller-Trumbore algorithm is a commonly used and fast method for ray-triangle intersection in computer graphics and raytracing. The algorithm works by first calculating the triangle normal and determining if the ray intersects the plane that the triangle lies on. If the ray intersects the plane, the algorithm checks if the intersection point is inside the triangle by performing two edge tests.

Here's a pseudocode for the Möller-Trumbore algorithm:

function intersectTriangle(ray, triangle):
  edge1 = triangle.v2 - triangle.v1
  edge2 = triangle.v3 - triangle.v1
  h = cross(ray.direction, edge2)
  a = dot(edge1, h)
  if a > -EPSILON and a < EPSILON:
    return false  # ray is parallel to triangle
  f = 1.0 / a
  s = ray.origin - triangle.v1
  u = f * dot(s, h)
  if u < 0.0 or u > 1.0:
    return false  # intersection point is outside of triangle
  q = cross(s, edge1)
  v = f * dot(ray.direction, q)
  if v < 0.0 or u + v > 1.0:
    return false  # intersection point is outside of triangle
  t = f * dot(edge2, q)
  if t > EPSILON:
    return t  # ray intersects triangle
  else:
    return false  # ray misses triangle prompter: Cool, can you implement it in javascript? assistant: function intersectTriangle(ray, triangle):
  edge1 = triangle.v2 - triangle.v1
  edge2 = triangle.v3 - triangle.v1
  h = cross(ray.direction, edge2)
  a = dot(edge1, h)
  if a > -EPSILON && a < EPSILON:
    return false  // ray is parallel to triangle
  f = 1.0 / a
  s = ray.origin - triangle.v1
  u = f * dot(s, h)
  if u < 0.0 || u > 1.0:
    return false  // intersection point is outside of triangle
  q = cross(s, edge1)
  v = f * dot(ray.direction, q)
  if v < 0.0 || u + v > 1.0:
    return false  // intersection point is outside of triangle
  t = f * dot(edge2, q)
  if t > EPSILON:
    return t  // ray intersects triangle
  else:
    return false  // ray misses triangle
prompter: That is not JavaScript. Can you implement it using actual JavaScript.  Also, add the value for the variable EPSILON and the functions for "cross" and "dot".