From 255ad03cd20cd49af0e2803b2357ca0b4d0ec18a Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 15 Oct 2021 13:28:13 +0900 Subject: [PATCH 1/3] migrate_with_scaling --- Assets/VRM10/Runtime/IO/Vrm10Storage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Storage.cs b/Assets/VRM10/Runtime/IO/Vrm10Storage.cs index fd6856238..9c356f4fb 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Storage.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Storage.cs @@ -407,7 +407,7 @@ namespace UniVRM10 { node.LocalRotation = x.rotation.ToQuaternion(); } - if (x.scale != null && x.scale.Length == 4) + if (x.scale != null && x.scale.Length == 3) { node.LocalScaling = x.scale.ToVector3(Vector3.One); } From cee27ed12bf9083b61ca81adbe93f0d7e257c2fa Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 15 Oct 2021 14:10:52 +0900 Subject: [PATCH 2/3] =?UTF-8?q?quat(0,=200,=200,=201)=20=E6=99=82=E3=81=AE?= =?UTF-8?q?=20AxisAngle?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/UniGLTF/Runtime/Extensions/NumericsExtensions.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Assets/UniGLTF/Runtime/Extensions/NumericsExtensions.cs b/Assets/UniGLTF/Runtime/Extensions/NumericsExtensions.cs index 0a123c7f5..589738ac7 100644 --- a/Assets/UniGLTF/Runtime/Extensions/NumericsExtensions.cs +++ b/Assets/UniGLTF/Runtime/Extensions/NumericsExtensions.cs @@ -49,6 +49,10 @@ namespace UniGLTF public static (Vector3, float) GetAxisAngle(this Quaternion q) { var qw = q.W; + if (qw == 1) + { + return (Vector3.UnitX, 0); + } var angle = 2 * Math.Acos(qw); var x = q.X / Math.Sqrt(1 - qw * qw); var y = q.Y / Math.Sqrt(1 - qw * qw); From 2d85419860945f740dcd05cf3ec24857a3dbbc03 Mon Sep 17 00:00:00 2001 From: ousttrue Date: Fri, 15 Oct 2021 14:44:53 +0900 Subject: [PATCH 3/3] =?UTF-8?q?CreateNodes=20=E3=81=A7=E6=AD=A3=E3=81=97?= =?UTF-8?q?=E3=81=8F=20Scale=20=E3=82=92=E5=8F=8D=E6=98=A0=E3=81=99?= =?UTF-8?q?=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Assets/VRM10/Runtime/IO/Vrm10Importer.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs index 2906b4e6c..d1de0411f 100644 --- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs +++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs @@ -648,12 +648,16 @@ namespace UniVRM10 public static void CreateNodes(VrmLib.Node node, GameObject parent, Dictionary nodes) { GameObject go = new GameObject(node.Name); - go.transform.SetPositionAndRotation(node.Translation.ToUnityVector3(), node.Rotation.ToUnityQuaternion()); nodes.Add(node, go); + + // world + go.transform.SetPositionAndRotation(node.Translation.ToUnityVector3(), node.Rotation.ToUnityQuaternion()); if (parent != null) { - go.transform.SetParent(parent.transform); + go.transform.SetParent(parent.transform, true); } + // local + go.transform.localScale = node.LocalScaling.ToUnityVector3(); if (node.Children.Count > 0) {