Floating point calculation speed

You probably should also avoid repeated calls to expensive math functions. For example, in the X-axis rotation matrix,

var cosx = Math.cos(Xrot);
var sinx = Math.sin(Xrot);
var Y1 = l1y*cosx-l1z*sinx;
var Z1 = l1z*cosx+l1y*sinx;

could be up to twice as fast as what you are doing now. It can be tempting (and more readable) to just code up the textbook equations, but if performance is an issue, think like a computer not a human.

3 Likes