toji / gl-matrix

Javascript Matrix and Vector library for High Performance WebGL apps
glmatrix.net
MIT License
5.37k stars 721 forks source link

mat4 rotations #414

Open z3dev opened 3 years ago

z3dev commented 3 years ago

The mat4 implementation kind of punts on invalid rotations, i.e. an axis with a length < EPSILON.

if (len < glMatrix.EPSILON) {
    return null;
}

But is returning 'null' the correct thing to do? The calling function now has to trap these strange return values.

In the pure javascript sense, throwing an error makes more sense then returning 'null'.

In the real-world sense, doing something appropriate would make more sense. For rotate(), just return the value of the given matrix. For fromRotation(), just return the identity matrix.