diff --git a/Assets/VRM10/Editor/EditorTool/VRM10LookAtEditorTool.cs b/Assets/VRM10/Editor/EditorTool/VRM10LookAtEditorTool.cs index b7917fee5..d0458b33a 100644 --- a/Assets/VRM10/Editor/EditorTool/VRM10LookAtEditorTool.cs +++ b/Assets/VRM10/Editor/EditorTool/VRM10LookAtEditorTool.cs @@ -169,7 +169,7 @@ namespace UniVRM10 Handles.DrawSolidArc(Vector3.zero, Matrix4x4.identity.GetColumn(0), Matrix4x4.identity.GetColumn(2), - pitch, + -pitch, RADIUS); } } diff --git a/Assets/VRM10/Runtime/Components/LookAt/Matrix4x4Extensions.cs b/Assets/VRM10/Runtime/Components/LookAt/Matrix4x4Extensions.cs index 682c7392a..f88b4905c 100644 --- a/Assets/VRM10/Runtime/Components/LookAt/Matrix4x4Extensions.cs +++ b/Assets/VRM10/Runtime/Components/LookAt/Matrix4x4Extensions.cs @@ -62,6 +62,11 @@ namespace UniVRM10 return (yaw, pitch); } + /// + /// yaw: 右が+ + /// pitch: 上が+ + /// という仕様。vrm-0.x から据え置き + /// public static void CalcYawPitch(this Matrix4x4 m, Vector3 target, out float yaw, out float pitch) { var z = Vector3.Dot(target, m.GetColumn(2)); @@ -71,14 +76,17 @@ namespace UniVRM10 // x+y z plane var xz = Mathf.Sqrt(x * x + z * z); var y = Vector3.Dot(target, m.GetColumn(1)); - - // 正の方向が Euler 角になるように調整 - pitch = -Mathf.Atan2(y, xz) * Mathf.Rad2Deg; + pitch = Mathf.Atan2(y, xz) * Mathf.Rad2Deg; } + /// + /// yaw: 右が+ + /// pitch: 上が+ + /// という仕様。vrm-0.x から据え置き + /// public static Quaternion YawPitchRotation(this Matrix4x4 m, float yaw, float pitch) { - return Quaternion.AngleAxis(yaw, m.GetColumn(1)) * Quaternion.AngleAxis(pitch, m.GetColumn(0)); + return Quaternion.AngleAxis(yaw, m.GetColumn(1)) * Quaternion.AngleAxis(-pitch, m.GetColumn(0)); } public static Matrix4x4 RotationToWorldAxis(this Matrix4x4 m)