Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.0] SpringBone Joint のJSONキー省略時にデフォルト値を補う #1443

Merged
merged 1 commit into from Dec 28, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 11 additions & 6 deletions Assets/VRM10/Runtime/IO/Vrm10Importer.cs
Expand Up @@ -587,13 +587,18 @@ async Task LoadSpringBoneAsync(IAwaitCaller awaitCaller, Vrm10Instance controlle
{
throw new IndexOutOfRangeException($"{index} > {Nodes.Count}");
}
// https://github.com/vrm-c/UniVRM/issues/1441
//
// https://github.com/vrm-c/vrm-specification/blob/master/specification/VRMC_springBone-1.0-beta/schema/VRMC_springBone.joint.schema.json
// に基づきデフォルト値を補う

// node is required
var joint = Nodes[gltfJoint.Node.Value].gameObject.AddComponent<VRM10SpringBoneJoint>();
joint.m_jointRadius = gltfJoint.HitRadius.Value;
joint.m_dragForce = gltfJoint.DragForce.Value;
joint.m_gravityDir = Vector3InvertX(gltfJoint.GravityDir);
joint.m_gravityPower = gltfJoint.GravityPower.Value;
joint.m_stiffnessForce = gltfJoint.Stiffness.Value;
// joint.m_exclude = gltfJoint.Exclude.GetValueOrDefault();
joint.m_jointRadius = gltfJoint.HitRadius.GetValueOrDefault(0.0f);
joint.m_dragForce = gltfJoint.DragForce.GetValueOrDefault(0.5f);
joint.m_gravityDir = gltfJoint.GravityDir != null ? Vector3InvertX(gltfJoint.GravityDir) : Vector3.down;
joint.m_gravityPower = gltfJoint.GravityPower.GetValueOrDefault(0.0f);
joint.m_stiffnessForce = gltfJoint.Stiffness.GetValueOrDefault(1.0f);
spring.Joints.Add(joint);
}
}
Expand Down