diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10AimConstraintEditor.cs b/Assets/VRM10/Editor/Components/Constraint/VRM10AimConstraintEditor.cs
deleted file mode 100644
index 78e1c3786..000000000
--- a/Assets/VRM10/Editor/Components/Constraint/VRM10AimConstraintEditor.cs
+++ /dev/null
@@ -1,87 +0,0 @@
-using System.Text;
-using UnityEditor;
-using UnityEngine;
-
-namespace UniVRM10
-{
- [CustomEditor(typeof(VRM10AimConstraint))]
- public class VRM10AimConstraintEditor : Editor
- {
- VRM10AimConstraint m_target;
-
- void OnEnable()
- {
- m_target = (VRM10AimConstraint)target;
- }
-
- static GUIStyle s_style;
- static GUIStyle Style
- {
- get
- {
- if (s_style == null)
- {
- s_style = new GUIStyle("box");
- }
- return s_style;
- }
- }
-
- static void DrawAimUp(Quaternion rot, Vector3 pos, Color c)
- {
- Handles.matrix = Matrix4x4.identity;
- Handles.color = c;
- // aim
- var aim = pos + rot * Vector3.forward * 0.3f;
- Handles.DrawLine(pos, aim);
- Handles.Label(aim, "aim");
- // up
- var up = pos + rot * Vector3.up * 0.3f;
- Handles.DrawLine(pos, up);
- Handles.Label(up, "up");
- }
-
- public void OnSceneGUI()
- {
- if (m_target.Source == null)
- {
- return;
- }
-
- // this to target line
- Handles.color = Color.yellow;
- Handles.DrawLine(m_target.Source.position, m_target.transform.position);
-
- var pos = m_target.transform.position;
-
- var pr = TR.FromParent(m_target.transform);
-
- if (m_target.m_src == null)
- {
- EditorGUI.BeginChangeCheck();
- TR.FromWorld(m_target.transform).Draw(0.2f);
-
- Handles.matrix = Matrix4x4.identity;
- var rot = Handles.RotationHandle(pr.Rotation * m_target.DestinationOffset, pos);
- if (EditorGUI.EndChangeCheck())
- {
- Undo.RecordObject(m_target, "Rotated RotateAt Point");
- m_target.DestinationOffset = Quaternion.Inverse(pr.Rotation) * rot;
- }
-
- DrawAimUp(rot, pos, Color.yellow);
- }
- else
- {
- var init = pr.Rotation * m_target.m_src.LocalInitial.Rotation;
- DrawAimUp(init * m_target.DestinationOffset, m_target.transform.position, Color.yellow);
- new TR(init, m_target.transform.position).Draw(0.2f);
- DrawAimUp(init * m_target.DestinationOffset * m_target.Delta, m_target.transform.position, Color.magenta);
- }
-
- // Target UPVector
- Handles.color = Color.green;
- Handles.DrawLine(m_target.transform.position, m_target.transform.position + m_target.UpVector);
- }
- }
-}
diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10AimConstraintEditor.cs.meta b/Assets/VRM10/Editor/Components/Constraint/VRM10AimConstraintEditor.cs.meta
deleted file mode 100644
index 324632787..000000000
--- a/Assets/VRM10/Editor/Components/Constraint/VRM10AimConstraintEditor.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 53c7ae04ba8deea40acc6439a2fe11cd
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10PositionConstraintEditor.cs b/Assets/VRM10/Editor/Components/Constraint/VRM10PositionConstraintEditor.cs
deleted file mode 100644
index 78e9653c5..000000000
--- a/Assets/VRM10/Editor/Components/Constraint/VRM10PositionConstraintEditor.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using System.Text;
-using UnityEditor;
-using UnityEngine;
-
-namespace UniVRM10
-{
- [CustomEditor(typeof(VRM10PositionConstraint))]
- public class VRM10PositionConstraintEditor : VRM10PositionRotationConstraintEditorBase
- {
- }
-}
diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10PositionConstraintEditor.cs.meta b/Assets/VRM10/Editor/Components/Constraint/VRM10PositionConstraintEditor.cs.meta
deleted file mode 100644
index 7abff9c34..000000000
--- a/Assets/VRM10/Editor/Components/Constraint/VRM10PositionConstraintEditor.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: d4c6d6f5f37e41e47bd02bdf1dbda864
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs b/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs
index 9250dc359..76a755f18 100644
--- a/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs
+++ b/Assets/VRM10/Editor/Components/Constraint/VRM10PostionRotationConstraintEditorBase.cs
@@ -87,7 +87,6 @@ namespace UniVRM10
var sb = new StringBuilder();
sb.AppendLine();
sb.AppendLine();
- sb.AppendLine($"source: {m_target.SourceCoordinate}");
sb.AppendLine($"{delta.x:0.00}");
sb.AppendLine($"{delta.y:0.00}");
sb.Append($"{delta.z:0.00}");
@@ -97,7 +96,6 @@ namespace UniVRM10
// show dst
{
var sb = new StringBuilder();
- sb.AppendLine($"constraint: {m_target.DestinationCoordinate}");
sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.X) ? $"freeze" : $"{delta.x:0.00}");
sb.AppendLine(m_target.FreezeAxes.HasFlag(AxisMask.Y) ? $"freeze" : $"{delta.y:0.00}");
sb.Append(m_target.FreezeAxes.HasFlag(AxisMask.Z) ? $"freeze" : $"{delta.z:0.00}");
diff --git a/Assets/VRM10/Runtime/Components/Constraint/ConstraintSource.cs b/Assets/VRM10/Runtime/Components/Constraint/ConstraintSource.cs
index c9f1cee03..f4d249b14 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/ConstraintSource.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/ConstraintSource.cs
@@ -13,15 +13,9 @@ namespace UniVRM10
public readonly TR LocalInitial;
- public TR Delta(ObjectSpace coords, Quaternion sourceRotationOffset)
+ public TR Delta(Quaternion sourceRotationOffset)
{
- switch (coords)
- {
- // case SourceCoordinates.World: return m_transform.rotation * Quaternion.Inverse(m_initial.Rotation);
- case ObjectSpace.local: return TR.FromLocal(Source) * (LocalInitial * new TR(sourceRotationOffset)).Inverse();
- case ObjectSpace.model: return TR.FromWorld(Source) * (TR.FromParent(ModelRoot) * ModelInitial * new TR(sourceRotationOffset)).Inverse();
- default: throw new NotImplementedException();
- }
+ return TR.FromLocal(Source) * (LocalInitial * new TR(sourceRotationOffset)).Inverse();
}
public ConstraintSource(Transform t, Transform modelRoot = null)
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10AimConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10AimConstraint.cs
deleted file mode 100644
index 9c7874d1a..000000000
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10AimConstraint.cs
+++ /dev/null
@@ -1,88 +0,0 @@
-using System;
-using UniGLTF.Extensions.VRMC_node_constraint;
-using UnityEngine;
-
-
-namespace UniVRM10
-{
- [DisallowMultipleComponent]
- public class VRM10AimConstraint : VRM10Constraint
- {
- ///
- /// Yaw(Y), Pitch(X) の2軸だけ
- ///
- [SerializeField]
- [EnumFlags]
- YawPitchMask m_freezeAxes = default;
- public YawPitchMask FreezeAxes
- {
- get => m_freezeAxes;
- set => m_freezeAxes = value;
- }
-
- [Header("Source")]
- [SerializeField]
- Transform m_source = default;
- public override Transform Source
- {
- get => m_source;
- set => m_source = value;
- }
-
- [Header("Destination")]
- [SerializeField]
- ObjectSpace m_destinationCoordinate = default;
-
- ///
- /// シリアライズは、Aim と Up で記録。
- /// UniVRM の Editor では Aim と Up が直交しないことを許可しない。
- ///
- [SerializeField]
- public Quaternion DestinationOffset = Quaternion.identity;
-
- Quaternion m_delta;
- public Quaternion Delta => m_delta;
-
- public Vector3 UpVector
- {
- get
- {
- switch (m_destinationCoordinate)
- {
- case ObjectSpace.model: return ModelRoot.up;
-
- case ObjectSpace.local:
- {
- if (m_src == null)
- {
- return transform.up;
- }
-
- return (TR.FromParent(transform).Rotation * m_dst.LocalInitial.Rotation) * Vector3.up;
- }
-
- default:
- throw new NotImplementedException();
- }
- }
- }
-
- public override void OnProcess()
- {
- var zAxis = (Source.position - transform.position).normalized;
- var xAxis = Vector3.Cross(UpVector, zAxis);
- var yAxis = Vector3.Cross(zAxis, xAxis);
- var m = new Matrix4x4(xAxis, yAxis, zAxis, new Vector4(0, 0, 0, 1));
- var parent = TR.FromParent(transform);
- m_delta = Quaternion.Inverse(parent.Rotation * m_src.LocalInitial.Rotation * DestinationOffset) * m.rotation;
-
- var (yaw, pitch) = Matrix4x4.Rotate(Quaternion.Inverse(m_delta)).CalcYawPitch(Vector3.forward);
- if (m_freezeAxes.HasFlag(YawPitchMask.Yaw)) yaw = 0;
- if (m_freezeAxes.HasFlag(YawPitchMask.Pitch)) pitch = 0;
-
- m_delta = Quaternion.Euler(pitch, yaw, 0);
-
- transform.rotation = parent.Rotation * m_src.LocalInitial.Rotation * Delta;
- }
- }
-}
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10AimConstraint.cs.meta b/Assets/VRM10/Runtime/Components/Constraint/VRM10AimConstraint.cs.meta
deleted file mode 100644
index 2b2331d9c..000000000
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10AimConstraint.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e1e8c3a00191fbd4db98fb47ddb80e8c
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10Constraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10Constraint.cs
index 1d6c06bcb..8b91193e9 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10Constraint.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10Constraint.cs
@@ -38,35 +38,15 @@ namespace UniVRM10
public ConstraintSource m_src;
-
- protected TR SourceInitialCoords(ObjectSpace space)
+ protected TR SourceInitialCoords()
{
- switch (space)
+ if (m_src == null)
{
- case ObjectSpace.model:
- if (m_src == null)
- {
- return new TR(ModelRoot.rotation, Source.position);
- }
- else
- {
- var r = (TR.FromParent(ModelRoot) * m_src.ModelInitial).Rotation;
- var t = (TR.FromParent(Source) * m_src.LocalInitial).Translation;
- return new TR(r, t);
- }
-
- case ObjectSpace.local:
- if (m_src == null)
- {
- return TR.FromWorld(Source);
- }
- else
- {
- return TR.FromParent(Source) * m_src.LocalInitial;
- }
-
- default:
- throw new NotImplementedException();
+ return TR.FromWorld(Source);
+ }
+ else
+ {
+ return TR.FromParent(Source) * m_src.LocalInitial;
}
}
#endregion
@@ -74,34 +54,15 @@ namespace UniVRM10
#region Destination
protected ConstraintDestination m_dst;
- protected TR DestinationInitialCoords(ObjectSpace space)
+ protected TR DestinationInitialCoords()
{
- switch (space)
+ if (m_dst == null)
{
- case ObjectSpace.model:
- if (m_dst == null)
- {
- return new TR(ModelRoot.rotation, transform.position);
- }
- else
- {
- var r = (TR.FromParent(ModelRoot) * m_dst.ModelInitial).Rotation;
- var t = (TR.FromParent(transform) * m_dst.LocalInitial).Translation;
- return new TR(r, t);
- }
-
- case ObjectSpace.local:
- if (m_dst == null)
- {
- return TR.FromWorld(transform);
- }
- else
- {
- return TR.FromParent(transform) * m_dst.LocalInitial;
- }
-
- default:
- throw new NotImplementedException();
+ return TR.FromWorld(transform);
+ }
+ else
+ {
+ return TR.FromParent(transform) * m_dst.LocalInitial;
}
}
#endregion
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs
deleted file mode 100644
index b073e790f..000000000
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-using System;
-using UniGLTF.Extensions.VRMC_node_constraint;
-using UnityEngine;
-
-namespace UniVRM10
-{
- ///
- /// 対象の初期位置と現在位置の差分(delta)を、自身の初期位置に対してWeightを乗算して加算する。
- ///
- [DisallowMultipleComponent]
- public class VRM10PositionConstraint : VRM10RotationPositionConstraintBase
- {
- public override Vector3 Delta => FreezeAxes.Freeze(m_delta.Translation) * Weight;
-
- public override TR GetSourceCurrent()
- {
- var coords = GetSourceCoords();
- if (m_src == null)
- {
- return coords;
- }
- return coords * new TR(Delta);
- }
-
- public override TR GetDstCurrent()
- {
- var coords = GetDstCoords();
- if (m_src == null)
- {
- return coords;
- }
- return coords * new TR(Delta);
- }
-
- protected override void ApplyDelta()
- {
- switch (DestinationCoordinate)
- {
- case ObjectSpace.local:
- m_dst.ApplyLocal(DestinationInitialCoords(ObjectSpace.local) * new TR(DestinationOffset) * new TR(Delta));
- break;
-
- case ObjectSpace.model:
- m_dst.ApplyModel(DestinationInitialCoords(ObjectSpace.model) * new TR(DestinationOffset) * new TR(Delta));
- break;
-
- default:
- throw new NotImplementedException();
- }
- }
- }
-}
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs.meta b/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs.meta
deleted file mode 100644
index 4105f28a1..000000000
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10PositionConstraint.cs.meta
+++ /dev/null
@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 6fec0847a81b2124c9f67575d247b1f9
-MonoImporter:
- externalObjects: {}
- serializedVersion: 2
- defaultReferences: []
- executionOrder: 0
- icon: {instanceID: 0}
- userData:
- assetBundleName:
- assetBundleVariant:
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
index dd3c0e93e..069a509d8 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationConstraint.cs
@@ -34,19 +34,7 @@ namespace UniVRM10
protected override void ApplyDelta()
{
- switch (DestinationCoordinate)
- {
- case ObjectSpace.local:
- m_dst.ApplyLocal(m_dst.LocalInitial * new TR(DestinationOffset) * new TR(Quaternion.Euler(Delta)));
- break;
-
- case ObjectSpace.model:
- m_dst.ApplyModel(DestinationInitialCoords(ObjectSpace.model) * new TR(DestinationOffset) * new TR(Quaternion.Euler(Delta)));
- break;
-
- default:
- throw new NotImplementedException();
- }
+ m_dst.ApplyLocal(m_dst.LocalInitial * new TR(DestinationOffset) * new TR(Quaternion.Euler(Delta)));
}
}
}
diff --git a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
index 732e3b7b4..af042354f 100644
--- a/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
+++ b/Assets/VRM10/Runtime/Components/Constraint/VRM10RotationPositionConstraintBase.cs
@@ -25,13 +25,6 @@ namespace UniVRM10
set => m_source = value;
}
- [SerializeField]
- ObjectSpace m_sourceCoordinate = default;
- public ObjectSpace SourceCoordinate
- {
- get => m_sourceCoordinate;
- set => m_sourceCoordinate = value;
- }
[SerializeField]
VRM10RotationOffset m_sourceOffset = VRM10RotationOffset.Identity;
@@ -46,14 +39,6 @@ namespace UniVRM10
#region Destination
[Header("Destination")]
- [SerializeField]
- ObjectSpace m_destinationCoordinate = default;
- public ObjectSpace DestinationCoordinate
- {
- get => m_destinationCoordinate;
- set => m_destinationCoordinate = value;
- }
-
[SerializeField]
public VRM10RotationOffset m_destinationOffset = VRM10RotationOffset.Identity;
@@ -71,54 +56,16 @@ namespace UniVRM10
throw new ConstraintException(ConstraintException.ExceptionTypes.NoSource);
}
- switch (SourceCoordinate)
- {
- case ObjectSpace.model:
- {
- if (ModelRoot == null)
- {
- throw new ConstraintException(ConstraintException.ExceptionTypes.NoModelWithModelSpace);
- }
- var init = SourceInitialCoords(ObjectSpace.model);
- return new TR(init.Rotation * SourceOffset, init.Translation);
- }
-
- case ObjectSpace.local:
- {
- var init = SourceInitialCoords(ObjectSpace.local);
- return new TR(init.Rotation * SourceOffset, init.Translation);
- }
-
- default:
- throw new NotImplementedException();
- }
+ var init = SourceInitialCoords();
+ return new TR(init.Rotation * SourceOffset, init.Translation);
}
public abstract TR GetSourceCurrent();
public TR GetDstCoords()
{
- switch (DestinationCoordinate)
- {
- case ObjectSpace.model:
- {
- if (ModelRoot == null)
- {
- throw new ConstraintException(ConstraintException.ExceptionTypes.NoModelWithModelSpace);
- }
- var init = DestinationInitialCoords(ObjectSpace.model);
- return new TR(init.Rotation * DestinationOffset, init.Translation);
- }
-
- case ObjectSpace.local:
- {
- var init = DestinationInitialCoords(ObjectSpace.local);
- return new TR(init.Rotation * DestinationOffset, init.Translation);
- }
-
- default:
- throw new NotImplementedException();
- }
+ var init = DestinationInitialCoords();
+ return new TR(init.Rotation * DestinationOffset, init.Translation);
}
public abstract TR GetDstCurrent();
@@ -151,7 +98,7 @@ namespace UniVRM10
public override void OnProcess()
{
- m_delta = m_src.Delta(SourceCoordinate, SourceOffset);
+ m_delta = m_src.Delta(SourceOffset);
ApplyDelta();
}
}
diff --git a/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs
index 35d8ee054..8f392b14b 100644
--- a/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs
+++ b/Assets/VRM10/Runtime/Format/Constraints/Deserializer.g.cs
@@ -79,88 +79,15 @@ public static Constraint Deserialize_Constraint(JsonNode parsed)
continue;
}
- if(key=="position"){
- value.Position = __constraint_Deserialize_Position(kv.Value);
- continue;
- }
-
if(key=="rotation"){
value.Rotation = __constraint_Deserialize_Rotation(kv.Value);
continue;
}
- if(key=="aim"){
- value.Aim = __constraint_Deserialize_Aim(kv.Value);
- continue;
- }
-
}
return value;
}
-public static PositionConstraint __constraint_Deserialize_Position(JsonNode parsed)
-{
- var value = new PositionConstraint();
-
- foreach(var kv in parsed.ObjectItems())
- {
- var key = kv.Key.GetString();
-
- if(key=="extensions"){
- value.Extensions = new glTFExtensionImport(kv.Value);
- continue;
- }
-
- if(key=="extras"){
- value.Extras = new glTFExtensionImport(kv.Value);
- continue;
- }
-
- if(key=="name"){
- value.Name = kv.Value.GetString();
- continue;
- }
-
- if(key=="source"){
- value.Source = kv.Value.GetInt32();
- continue;
- }
-
- if(key=="sourceSpace"){
- value.SourceSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
- continue;
- }
-
- if(key=="destinationSpace"){
- value.DestinationSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
- continue;
- }
-
- if(key=="freezeAxes"){
- value.FreezeAxes = __constraint__position_Deserialize_FreezeAxes(kv.Value);
- continue;
- }
-
- if(key=="weight"){
- value.Weight = kv.Value.GetSingle();
- continue;
- }
-
- }
- return value;
-}
-
-public static bool[] __constraint__position_Deserialize_FreezeAxes(JsonNode parsed)
-{
- var value = new bool[parsed.GetArrayCount()];
- int i=0;
- foreach(var x in parsed.ArrayItems())
- {
- value[i++] = x.GetBoolean();
- }
- return value;
-}
-
public static RotationConstraint __constraint_Deserialize_Rotation(JsonNode parsed)
{
var value = new RotationConstraint();
@@ -189,16 +116,6 @@ public static RotationConstraint __constraint_Deserialize_Rotation(JsonNode pars
continue;
}
- if(key=="sourceSpace"){
- value.SourceSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
- continue;
- }
-
- if(key=="destinationSpace"){
- value.DestinationSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
- continue;
- }
-
if(key=="freezeAxes"){
value.FreezeAxes = __constraint__rotation_Deserialize_FreezeAxes(kv.Value);
continue;
@@ -224,100 +141,5 @@ public static bool[] __constraint__rotation_Deserialize_FreezeAxes(JsonNode pars
return value;
}
-public static AimConstraint __constraint_Deserialize_Aim(JsonNode parsed)
-{
- var value = new AimConstraint();
-
- foreach(var kv in parsed.ObjectItems())
- {
- var key = kv.Key.GetString();
-
- if(key=="extensions"){
- value.Extensions = new glTFExtensionImport(kv.Value);
- continue;
- }
-
- if(key=="extras"){
- value.Extras = new glTFExtensionImport(kv.Value);
- continue;
- }
-
- if(key=="name"){
- value.Name = kv.Value.GetString();
- continue;
- }
-
- if(key=="source"){
- value.Source = kv.Value.GetInt32();
- continue;
- }
-
- if(key=="sourceSpace"){
- value.SourceSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
- continue;
- }
-
- if(key=="destinationSpace"){
- value.DestinationSpace = (ObjectSpace)Enum.Parse(typeof(ObjectSpace), kv.Value.GetString(), true);
- continue;
- }
-
- if(key=="aimVector"){
- value.AimVector = __constraint__aim_Deserialize_AimVector(kv.Value);
- continue;
- }
-
- if(key=="upVector"){
- value.UpVector = __constraint__aim_Deserialize_UpVector(kv.Value);
- continue;
- }
-
- if(key=="freezeAxes"){
- value.FreezeAxes = __constraint__aim_Deserialize_FreezeAxes(kv.Value);
- continue;
- }
-
- if(key=="weight"){
- value.Weight = kv.Value.GetSingle();
- continue;
- }
-
- }
- return value;
-}
-
-public static float[] __constraint__aim_Deserialize_AimVector(JsonNode parsed)
-{
- var value = new float[parsed.GetArrayCount()];
- int i=0;
- foreach(var x in parsed.ArrayItems())
- {
- value[i++] = x.GetSingle();
- }
- return value;
-}
-
-public static float[] __constraint__aim_Deserialize_UpVector(JsonNode parsed)
-{
- var value = new float[parsed.GetArrayCount()];
- int i=0;
- foreach(var x in parsed.ArrayItems())
- {
- value[i++] = x.GetSingle();
- }
- return value;
-}
-
-public static bool[] __constraint__aim_Deserialize_FreezeAxes(JsonNode parsed)
-{
- var value = new bool[parsed.GetArrayCount()];
- int i=0;
- foreach(var x in parsed.ArrayItems())
- {
- value[i++] = x.GetBoolean();
- }
- return value;
-}
-
} // GltfDeserializer
} // UniGLTF
diff --git a/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs
index 78ed8d2d2..2ba238224 100644
--- a/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs
+++ b/Assets/VRM10/Runtime/Format/Constraints/Format.g.cs
@@ -6,40 +6,6 @@ using System.Collections.Generic;
namespace UniGLTF.Extensions.VRMC_node_constraint
{
- public enum ObjectSpace
- {
- model,
- local,
-
- }
-
- public class PositionConstraint
- {
- // Dictionary object with extension-specific objects.
- public object Extensions;
-
- // Application-specific data.
- public object Extras;
-
- // The user-defined name of this object.
- public string Name;
-
- // The index of the node constrains the node.
- public int? Source;
-
- // The source node will be evaluated in this space.
- public ObjectSpace SourceSpace;
-
- // The destination node will be evaluated in this space.
- public ObjectSpace DestinationSpace;
-
- // Axes be constrained by this constraint, in X-Y-Z order.
- public bool[] FreezeAxes;
-
- // The weight of the constraint.
- public float? Weight;
- }
-
public class RotationConstraint
{
// Dictionary object with extension-specific objects.
@@ -54,12 +20,6 @@ namespace UniGLTF.Extensions.VRMC_node_constraint
// The index of the node constrains the node.
public int? Source;
- // The source node will be evaluated in this space.
- public ObjectSpace SourceSpace;
-
- // The destination node will be evaluated in this space.
- public ObjectSpace DestinationSpace;
-
// Axes be constrained by this constraint, in X-Y-Z order.
public bool[] FreezeAxes;
@@ -67,39 +27,6 @@ namespace UniGLTF.Extensions.VRMC_node_constraint
public float? Weight;
}
- public class AimConstraint
- {
- // Dictionary object with extension-specific objects.
- public object Extensions;
-
- // Application-specific data.
- public object Extras;
-
- // The user-defined name of this object.
- public string Name;
-
- // The index of the node constrains the node.
- public int? Source;
-
- // The source node will be evaluated in this space.
- public ObjectSpace SourceSpace;
-
- // The destination node will be evaluated in this space.
- public ObjectSpace DestinationSpace;
-
- // An axis which faces the direction of its source.
- public float[] AimVector;
-
- // An up axis of the constraint.
- public float[] UpVector;
-
- // Axes be constrained by this constraint, in Yaw-Pitch order.
- public bool[] FreezeAxes;
-
- // The weight of the constraint.
- public float? Weight;
- }
-
public class Constraint
{
// Dictionary object with extension-specific objects.
@@ -108,14 +35,8 @@ namespace UniGLTF.Extensions.VRMC_node_constraint
// Application-specific data.
public object Extras;
- // A constraint that links the position with a source.
- public PositionConstraint Position;
-
// A constraint that links the rotation with a source.
public RotationConstraint Rotation;
-
- // A constraint that rotates the node to face a source.
- public AimConstraint Aim;
}
public class VRMC_node_constraint
diff --git a/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs b/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs
index 26da0d390..4f533e337 100644
--- a/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs
+++ b/Assets/VRM10/Runtime/Format/Constraints/Serializer.g.cs
@@ -71,84 +71,14 @@ public static void Serialize_Constraint(JsonFormatter f, Constraint value)
(value.Extras as glTFExtension).Serialize(f);
}
- if(value.Position!=null){
- f.Key("position");
- __constraint_Serialize_Position(f, value.Position);
- }
-
if(value.Rotation!=null){
f.Key("rotation");
__constraint_Serialize_Rotation(f, value.Rotation);
}
- if(value.Aim!=null){
- f.Key("aim");
- __constraint_Serialize_Aim(f, value.Aim);
- }
-
f.EndMap();
}
-public static void __constraint_Serialize_Position(JsonFormatter f, PositionConstraint value)
-{
- f.BeginMap();
-
-
- if(value.Extensions!=null){
- f.Key("extensions");
- (value.Extensions as glTFExtension).Serialize(f);
- }
-
- if(value.Extras!=null){
- f.Key("extras");
- (value.Extras as glTFExtension).Serialize(f);
- }
-
- if(!string.IsNullOrEmpty(value.Name)){
- f.Key("name");
- f.Value(value.Name);
- }
-
- if(value.Source.HasValue){
- f.Key("source");
- f.Value(value.Source.GetValueOrDefault());
- }
-
- if(true){
- f.Key("sourceSpace");
- f.Value(value.SourceSpace.ToString());
- }
-
- if(true){
- f.Key("destinationSpace");
- f.Value(value.DestinationSpace.ToString());
- }
-
- if(value.FreezeAxes!=null&&value.FreezeAxes.Count()>=3){
- f.Key("freezeAxes");
- __constraint__position_Serialize_FreezeAxes(f, value.FreezeAxes);
- }
-
- if(value.Weight.HasValue){
- f.Key("weight");
- f.Value(value.Weight.GetValueOrDefault());
- }
-
- f.EndMap();
-}
-
-public static void __constraint__position_Serialize_FreezeAxes(JsonFormatter f, bool[] value)
-{
- f.BeginList();
-
- foreach(var item in value)
- {
- f.Value(item);
-
- }
- f.EndList();
-}
-
public static void __constraint_Serialize_Rotation(JsonFormatter f, RotationConstraint value)
{
f.BeginMap();
@@ -174,16 +104,6 @@ public static void __constraint_Serialize_Rotation(JsonFormatter f, RotationCons
f.Value(value.Source.GetValueOrDefault());
}
- if(true){
- f.Key("sourceSpace");
- f.Value(value.SourceSpace.ToString());
- }
-
- if(true){
- f.Key("destinationSpace");
- f.Value(value.DestinationSpace.ToString());
- }
-
if(value.FreezeAxes!=null&&value.FreezeAxes.Count()>=3){
f.Key("freezeAxes");
__constraint__rotation_Serialize_FreezeAxes(f, value.FreezeAxes);
@@ -209,99 +129,5 @@ public static void __constraint__rotation_Serialize_FreezeAxes(JsonFormatter f,
f.EndList();
}
-public static void __constraint_Serialize_Aim(JsonFormatter f, AimConstraint value)
-{
- f.BeginMap();
-
-
- if(value.Extensions!=null){
- f.Key("extensions");
- (value.Extensions as glTFExtension).Serialize(f);
- }
-
- if(value.Extras!=null){
- f.Key("extras");
- (value.Extras as glTFExtension).Serialize(f);
- }
-
- if(!string.IsNullOrEmpty(value.Name)){
- f.Key("name");
- f.Value(value.Name);
- }
-
- if(value.Source.HasValue){
- f.Key("source");
- f.Value(value.Source.GetValueOrDefault());
- }
-
- if(true){
- f.Key("sourceSpace");
- f.Value(value.SourceSpace.ToString());
- }
-
- if(true){
- f.Key("destinationSpace");
- f.Value(value.DestinationSpace.ToString());
- }
-
- if(value.AimVector!=null&&value.AimVector.Count()>=3){
- f.Key("aimVector");
- __constraint__aim_Serialize_AimVector(f, value.AimVector);
- }
-
- if(value.UpVector!=null&&value.UpVector.Count()>=3){
- f.Key("upVector");
- __constraint__aim_Serialize_UpVector(f, value.UpVector);
- }
-
- if(value.FreezeAxes!=null&&value.FreezeAxes.Count()>=2){
- f.Key("freezeAxes");
- __constraint__aim_Serialize_FreezeAxes(f, value.FreezeAxes);
- }
-
- if(value.Weight.HasValue){
- f.Key("weight");
- f.Value(value.Weight.GetValueOrDefault());
- }
-
- f.EndMap();
-}
-
-public static void __constraint__aim_Serialize_AimVector(JsonFormatter f, float[] value)
-{
- f.BeginList();
-
- foreach(var item in value)
- {
- f.Value(item);
-
- }
- f.EndList();
-}
-
-public static void __constraint__aim_Serialize_UpVector(JsonFormatter f, float[] value)
-{
- f.BeginList();
-
- foreach(var item in value)
- {
- f.Value(item);
-
- }
- f.EndList();
-}
-
-public static void __constraint__aim_Serialize_FreezeAxes(JsonFormatter f, bool[] value)
-{
- f.BeginList();
-
- foreach(var item in value)
- {
- f.Value(item);
-
- }
- f.EndList();
-}
-
} // class
} // namespace
diff --git a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
index 2e9ea4f71..5ffb52b55 100644
--- a/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
+++ b/Assets/VRM10/Runtime/IO/Vrm10Exporter.cs
@@ -390,18 +390,10 @@ namespace UniVRM10
UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint vrmConstraint = default;
switch (constraint)
{
- case VRM10PositionConstraint positionConstraint:
- vrmConstraint = ExportPostionConstraint(positionConstraint, model, converter);
- break;
-
case VRM10RotationConstraint rotationConstraint:
vrmConstraint = ExportRotationConstraint(rotationConstraint, model, converter);
break;
- case VRM10AimConstraint aimConstraint:
- vrmConstraint = ExportAimConstraint(aimConstraint, model, converter);
- break;
-
default:
throw new NotImplementedException();
}
@@ -424,24 +416,6 @@ namespace UniVRM10
};
}
- static UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint ExportPostionConstraint(VRM10PositionConstraint c, Model model, ModelExporter converter)
- {
- return new UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint
- {
- Constraint = new UniGLTF.Extensions.VRMC_node_constraint.Constraint
- {
- Position = new UniGLTF.Extensions.VRMC_node_constraint.PositionConstraint
- {
- Source = model.Nodes.IndexOf(converter.Nodes[c.Source.gameObject]),
- SourceSpace = c.SourceCoordinate,
- DestinationSpace = c.DestinationCoordinate,
- FreezeAxes = ToArray(c.FreezeAxes),
- Weight = c.Weight,
- }
- },
- };
- }
-
static UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint ExportRotationConstraint(VRM10RotationConstraint c, Model model, ModelExporter converter)
{
return new UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint
@@ -451,8 +425,6 @@ namespace UniVRM10
Rotation = new UniGLTF.Extensions.VRMC_node_constraint.RotationConstraint
{
Source = model.Nodes.IndexOf(converter.Nodes[c.Source.gameObject]),
- SourceSpace = c.SourceCoordinate,
- DestinationSpace = c.DestinationCoordinate,
FreezeAxes = ToArray(c.FreezeAxes),
Weight = c.Weight,
},
@@ -460,23 +432,6 @@ namespace UniVRM10
};
}
- static UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint ExportAimConstraint(VRM10AimConstraint c, Model model, ModelExporter converter)
- {
- return new UniGLTF.Extensions.VRMC_node_constraint.VRMC_node_constraint
- {
- Constraint = new UniGLTF.Extensions.VRMC_node_constraint.Constraint
- {
- Aim = new UniGLTF.Extensions.VRMC_node_constraint.AimConstraint
- {
- Source = model.Nodes.IndexOf(converter.Nodes[c.Source.gameObject]),
- // AimVector = ReverseX(c.AimVector),
- // UpVector = ReverseX(c.UpVector),
- Weight = c.Weight,
- },
- },
- };
- }
-
static UniGLTF.Extensions.VRMC_vrm.MeshAnnotation ExportMeshAnnotation(RendererFirstPersonFlags flags, Transform root, Func getIndex)
{
return new UniGLTF.Extensions.VRMC_vrm.MeshAnnotation
diff --git a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
index 8cb3afab4..9fde49ed7 100644
--- a/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
+++ b/Assets/VRM10/Runtime/IO/Vrm10Importer.cs
@@ -639,36 +639,15 @@ namespace UniVRM10
{
var constraint = ext.Constraint;
var node = Nodes[i];
- if (constraint.Position != null)
- {
- var p = constraint.Position;
- var positionConstraint = node.gameObject.AddComponent();
- positionConstraint.SourceCoordinate = p.SourceSpace;
- positionConstraint.Source = Nodes[p.Source.Value];
- positionConstraint.DestinationCoordinate = p.DestinationSpace;
- positionConstraint.FreezeAxes = FreezeAxis(p.FreezeAxes);
- positionConstraint.Weight = p.Weight.Value;
- positionConstraint.ModelRoot = Root.transform;
- }
- else if (constraint.Rotation != null)
+ if (constraint.Rotation != null)
{
var r = constraint.Rotation;
var rotationConstraint = node.gameObject.AddComponent();
- rotationConstraint.SourceCoordinate = r.SourceSpace;
rotationConstraint.Source = Nodes[r.Source.Value];
- rotationConstraint.DestinationCoordinate = r.DestinationSpace;
rotationConstraint.FreezeAxes = FreezeAxis(r.FreezeAxes);
rotationConstraint.Weight = r.Weight.Value;
rotationConstraint.ModelRoot = Root.transform;
}
- else if (constraint.Aim != null)
- {
- var a = constraint.Aim;
- var aimConstraint = node.gameObject.AddComponent();
- aimConstraint.Source = Nodes[a.Source.Value];
- // aimConstraint.AimVector = Vector3InvertX(a.AimVector);
- // aimConstraint.UpVector = Vector3InvertX(a.UpVector);
- }
}
}
diff --git a/vrm-specification b/vrm-specification
index f2d8f1582..6fb6baaf9 160000
--- a/vrm-specification
+++ b/vrm-specification
@@ -1 +1 @@
-Subproject commit f2d8f158297fc883aef9c3071ca68fbe46b03f45
+Subproject commit 6fb6baaf9b9095a84fb82c8384db36e1afeb3558