extractRotation method

Matrix4 extractRotation(
  1. Matrix4 m
)

Implementation

Matrix4 extractRotation(Matrix4 m) {
  // this method does not support reflection matrices

  var te = elements;
  var me = m.elements;

  var scaleX = 1 / _matrix4v1.setFromMatrixColumn(m, 0).length();
  var scaleY = 1 / _matrix4v1.setFromMatrixColumn(m, 1).length();
  var scaleZ = 1 / _matrix4v1.setFromMatrixColumn(m, 2).length();

  te[0] = me[0] * scaleX;
  te[1] = me[1] * scaleX;
  te[2] = me[2] * scaleX;
  te[3] = 0;

  te[4] = me[4] * scaleY;
  te[5] = me[5] * scaleY;
  te[6] = me[6] * scaleY;
  te[7] = 0;

  te[8] = me[8] * scaleZ;
  te[9] = me[9] * scaleZ;
  te[10] = me[10] * scaleZ;
  te[11] = 0;

  te[12] = 0;
  te[13] = 0;
  te[14] = 0;
  te[15] = 1;

  return this;
}