mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-20 17:57:57 -05:00
System.Numerics.Matrix4x4 to UnityEngine.Matrix4x4
This commit is contained in:
parent
d52ec016d5
commit
22dbe1576d
|
|
@ -85,9 +85,7 @@ namespace UniGLTF
|
|||
|
||||
public static (Vector3, Quaternion, Vector3) Decompose(this Matrix4x4 m)
|
||||
{
|
||||
var s = m.ExtractScale();
|
||||
var mm = Matrix4x4.Scale(new Vector3(1.0f / s.x, 1.0f / s.y, 1.0f / s.z)) * m;
|
||||
return (mm.ExtractPosition(), mm.ExtractRotation(), s);
|
||||
return (m.ExtractPosition(), m.ExtractRotation(), m.ExtractScale());
|
||||
}
|
||||
|
||||
public static Vector2 UVVerticalFlip(this Vector2 src)
|
||||
|
|
@ -201,20 +199,9 @@ namespace UniGLTF
|
|||
return m;
|
||||
}
|
||||
|
||||
// https://forum.unity.com/threads/how-to-assign-matrix4x4-to-transform.121966/
|
||||
public static Quaternion ExtractRotation(this Matrix4x4 matrix)
|
||||
{
|
||||
Vector3 forward;
|
||||
forward.x = matrix.m02;
|
||||
forward.y = matrix.m12;
|
||||
forward.z = matrix.m22;
|
||||
|
||||
Vector3 upwards;
|
||||
upwards.x = matrix.m01;
|
||||
upwards.y = matrix.m11;
|
||||
upwards.z = matrix.m21;
|
||||
|
||||
return Quaternion.LookRotation(forward, upwards);
|
||||
return matrix.rotation;
|
||||
}
|
||||
|
||||
public static Vector3 ExtractPosition(this Matrix4x4 matrix)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user