Merge pull request #1312 from ousttrue/fix10/migrate_with_scaling

[1.0] Scale 対応
This commit is contained in:
ousttrue
2021-10-15 16:36:23 +09:00
committed by GitHub
3 changed files with 11 additions and 3 deletions

View File

@@ -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);

View File

@@ -648,12 +648,16 @@ namespace UniVRM10
public static void CreateNodes(VrmLib.Node node, GameObject parent, Dictionary<VrmLib.Node, GameObject> 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)
{

View File

@@ -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);
}