diff --git a/Assets/VRM10/Runtime/Components/Constraint/Vrm10ConstraintUtil.cs b/Assets/VRM10/Runtime/Components/Constraint/Vrm10ConstraintUtil.cs new file mode 100644 index 000000000..702f17d02 --- /dev/null +++ b/Assets/VRM10/Runtime/Components/Constraint/Vrm10ConstraintUtil.cs @@ -0,0 +1,18 @@ +namespace UniVRM10 +{ + public static class Vrm10ConstraintUtil + { + /// + /// 右手系と左手系を相互に変換する + /// + public static UniGLTF.Extensions.VRMC_node_constraint.AimAxis ReverseX(UniGLTF.Extensions.VRMC_node_constraint.AimAxis src) + { + switch (src) + { + case UniGLTF.Extensions.VRMC_node_constraint.AimAxis.PositiveX: return UniGLTF.Extensions.VRMC_node_constraint.AimAxis.NegativeX; + case UniGLTF.Extensions.VRMC_node_constraint.AimAxis.NegativeX: return UniGLTF.Extensions.VRMC_node_constraint.AimAxis.PositiveX; + default: return src; + } + } + } +} diff --git a/Assets/VRM10/Runtime/Components/Constraint/Vrm10ConstraintUtil.cs.meta b/Assets/VRM10/Runtime/Components/Constraint/Vrm10ConstraintUtil.cs.meta new file mode 100644 index 000000000..461a75070 --- /dev/null +++ b/Assets/VRM10/Runtime/Components/Constraint/Vrm10ConstraintUtil.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e2c7b76ebe42e9543ac52153ea9f2728 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs index af3dc02f4..bd20f8cb4 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs @@ -430,7 +430,7 @@ namespace UniVRM10 { Source = model.Nodes.IndexOf(converter.Nodes[aimConstraint.Source.gameObject]), Weight = aimConstraint.Weight, - AimAxis = aimConstraint.AimAxis, + AimAxis = Vrm10ConstraintUtil.ReverseX(aimConstraint.AimAxis), }; break; diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 1fab7d277..6aed057d5 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -701,7 +701,7 @@ namespace UniVRM10 var component = node.gameObject.AddComponent(); component.Source = Nodes[aim.Source.Value]; // required component.Weight = aim.Weight.GetValueOrDefault(1.0f); - component.AimAxis = aim.AimAxis; // required + component.AimAxis = Vrm10ConstraintUtil.ReverseX(aim.AimAxis); // required } else if (constraint.Rotation != null) {