compose method

Matrix4 compose(
  1. Vector3 position,
  2. Quaternion quaternion,
  3. Vector3 scale
)

Implementation

Matrix4 compose(Vector3 position, Quaternion quaternion, Vector3 scale) {
  var te = elements;

  var x = quaternion.x.toDouble();
  var y = quaternion.y.toDouble();
  var z = quaternion.z.toDouble();
  var w = quaternion.w.toDouble();
  var x2 = x + x, y2 = y + y, z2 = z + z;
  var xx = x * x2, xy = x * y2, xz = x * z2;
  var yy = y * y2, yz = y * z2, zz = z * z2;
  var wx = w * x2, wy = w * y2, wz = w * z2;

  var sx = scale.x, sy = scale.y, sz = scale.z;

  te[0] = (1 - (yy + zz)) * sx.toDouble();
  te[1] = (xy + wz) * sx;
  te[2] = (xz - wy) * sx;
  te[3] = 0;

  te[4] = (xy - wz) * sy;
  te[5] = (1.0 - (xx + zz)) * sy;
  te[6] = (yz + wx) * sy;
  te[7] = 0;

  te[8] = (xz + wy) * sz;
  te[9] = (yz - wx) * sz;
  te[10] = (1 - (xx + yy)) * sz.toDouble();
  te[11] = 0;

  te[12] = position.x.toDouble();
  te[13] = position.y.toDouble();
  te[14] = position.z.toDouble();
  te[15] = 1;

  return this;
}