extractRotation method

Matrix4 extractRotation(
  1. Matrix4 m
)

Implementation

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

  final te = storage;
  final me = m.storage;

  final scaleX = 1 / _matrix4v1.setFromMatrixColumn(m, 0).length;
  final scaleY = 1 / _matrix4v1.setFromMatrixColumn(m, 1).length;
  final 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;
}