// Right handed public static bool LookRotationToMatrix(Vector3 viewVec, Vector3 upVec, out Matrix3x3 m) { m = Matrix3x3.identity; Vector3 z = viewVec; // compute u0 float mag = z.Length(); if (mag < Mathf.Epsilon) { return(false); } z /= mag; Vector3 x = Vector3.Cross(upVec, z); mag = x.Length(); if (mag < Mathf.Epsilon) { return(false); } x /= mag; Vector3 y = Vector3.Cross(z, x); if (!Mathf.CompareApproximate(y.Length(), 1.0F)) { return(false); } m.SetOrthoNormalBasis(x, y, z); return(true); }