Path tracer in Java Script