I ask myself what's the best way to store the transformations in a model class. What I came up with is to store the translation and scaling in a Vector3 and the rotation in a Matrix4.
On each update (frame) I multiply the 3 matrices (first build a Translation and Scaling Matrix) to get the world matrix. In this way I have no accumulated error.
world = translation * scaling * rotation
Another way would be to store the rotation in a quaternion but then I would have a high cost to convert to a matrix every time step. If I lerp the model I convert the rotation matrix to quaternion and then back to matrix.
For speed optimization I have a global dirty flag and one for each transformation so that I only do a matrix multiplication if necessary.
if (isDirty) {
world = translation
if (isScaled) {
world *= scaling
}
if (isRotated) {
world *= rotation
}
}
Is this a common way or is it more common to have only one Matrix4 for all transformations? And is it better to store the rotation only as quaternion? For info: Currently I'm building a CSS3D engine in Javascript but these questions are relevant for every 3D engine.