A Javascript algorithm for producing gcode from 3d models