コード例 #1
0
 public static Quaternion LookRotationNormal(Vector3 normal, Vector3 up = null)
 {
     if (up != Vector3.zero)
     {
         return QuaternionEx.LookRotationForcedUp(up, normal);
     }
     if (normal == Vector3.up)
     {
         return QuaternionEx.LookRotationForcedUp(Vector3.forward, normal);
     }
     if (normal == Vector3.down)
     {
         return QuaternionEx.LookRotationForcedUp(Vector3.back, normal);
     }
     if (normal.y == 0f)
     {
         return QuaternionEx.LookRotationForcedUp(Vector3.up, normal);
     }
     Vector3 vector3 = Vector3.Cross(normal, Vector3.up);
     return QuaternionEx.LookRotationForcedUp(-Vector3.Cross(normal, vector3), normal);
 }
コード例 #2
0
 public static Quaternion LookRotationGradient(Vector3 normal, Vector3 up)
 {
     return QuaternionEx.LookRotationForcedUp(Vector3.Cross(normal, (normal == Vector3.up ? Vector3.forward : Vector3.Cross(normal, Vector3.up))), up);
 }