diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/ExtensionSerialization.cs b/Assets/VRM/UniGLTF/Editor/Serialization/ExtensionSerialization.cs
index 97b6d3d1f..16c8e5f2c 100644
--- a/Assets/VRM/UniGLTF/Editor/Serialization/ExtensionSerialization.cs
+++ b/Assets/VRM/UniGLTF/Editor/Serialization/ExtensionSerialization.cs
@@ -16,7 +16,7 @@ namespace UniGLTF
public string GenerateDeserializerCall(string callName, string argName)
{
- return argName;
+ return $"new glTFExtension({argName})";
}
}
}
diff --git a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs
index 25237cfd4..7d0964b5d 100644
--- a/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs
+++ b/Assets/VRM/UniGLTF/Editor/Serialization/SerializerGenerator.cs
@@ -26,7 +26,7 @@ namespace UniGLTF
///
/// AOT向けにシリアライザを生成する
///
- [MenuItem(VRM.VRMVersion.MENU + "/Generate Serializer")]
+ [MenuItem(VRM.VRMVersion.MENU + "/GLTF: Generate Serializer")]
static void GenerateSerializer()
{
var path = OutPath;
diff --git a/Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs b/Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs
index a64855733..ca66cd670 100644
--- a/Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs
+++ b/Assets/VRM/UniGLTF/Editor/Tests/MaterialTests.cs
@@ -54,10 +54,7 @@ namespace UniGLTF
{
baseColorFactor = new float[] { 1, 0, 0, 1 },
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
@@ -71,10 +68,7 @@ namespace UniGLTF
{
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
@@ -89,10 +83,7 @@ namespace UniGLTF
baseColorFactor = new float[] { 1, 0, 0, 1 },
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
@@ -106,10 +97,7 @@ namespace UniGLTF
{
baseColorFactor = new float[] { 1, 0, 0, 1 },
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
@@ -123,10 +111,7 @@ namespace UniGLTF
{
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
@@ -141,10 +126,7 @@ namespace UniGLTF
baseColorFactor = new float[] { 1, 0, 0, 1 },
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
@@ -158,10 +140,7 @@ namespace UniGLTF
{
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
@@ -176,10 +155,7 @@ namespace UniGLTF
baseColorFactor = new float[] { 1, 0, 0, 1 },
baseColorTexture = new glTFMaterialBaseColorTextureInfo(),
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
@@ -188,10 +164,7 @@ namespace UniGLTF
// default
var shader = shaderStore.GetShader(new glTFMaterial
{
- extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
- }
+ extensions = glTF_KHR_materials_unlit.Serialize(),
});
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
}
diff --git a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs b/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs
index b7c93b61a..f416359a9 100644
--- a/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs
+++ b/Assets/VRM/UniGLTF/Editor/Tests/UniGLTFTests.cs
@@ -237,14 +237,7 @@ namespace UniGLTF
{
POSITION = 0,
},
- extras = new KeyValuePair[]
- {
- new KeyValuePair(
- "targetNames", new List
- {
- "aaa",
- })
- }
+ extras = gltf_mesh_extras_targetNames.Serialize("aaa"),
};
var json = model.ToJson();
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs
index 19ab08378..0014fc432 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_materials_unlit.cs
@@ -21,10 +21,7 @@ namespace UniGLTF
roughnessFactor = 0.9f,
metallicFactor = 0.0f,
},
- extensions = new KeyValuePair[]
- {
- new KeyValuePair(ExtensionName, new glTF_KHR_materials_unlit()),
- },
+ extensions = glTFExtension.Create(ExtensionName, "{}")
};
}
@@ -35,21 +32,20 @@ namespace UniGLTF
return false;
}
- if (m.extensions is ListTreeNode json)
+ foreach (var kv in m.extensions.ObjectItems())
{
- if (json.Value.ValueType == ValueNodeType.Object)
+ if (kv.Key.GetUtf8String() == ExtensionNameUtf8)
{
- foreach (var kv in json.ObjectItems())
- {
- if (kv.Key.GetUtf8String() == ExtensionNameUtf8)
- {
- return kv.Value.Value.ValueType == ValueNodeType.Object;
- }
- }
+ return kv.Value.Value.ValueType == ValueNodeType.Object;
}
}
return false;
}
+
+ public static glTFExtension Serialize()
+ {
+ return glTFExtension.Create(ExtensionName, "{}");
+ }
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs
index 65dab1244..c23ad460d 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/KHR_texture_transform.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using UniJSON;
+using UnityEngine;
namespace UniGLTF
{
@@ -73,23 +74,44 @@ namespace UniGLTF
public static bool TryGet(glTFTextureInfo info, out glTF_KHR_texture_transform t)
{
- if (info.extensions is ListTreeNode json)
+ foreach (var kv in info.extensions.ObjectItems())
{
- if (json.Value.ValueType == ValueNodeType.Object)
+ if (kv.Key.GetUtf8String() == ExtensionNameUt8)
{
- foreach (var kv in json.ObjectItems())
- {
- if (kv.Key.GetUtf8String() == ExtensionNameUt8)
- {
- t = Deserialize(kv.Value);
- return true;
- }
- }
+ t = Deserialize(kv.Value);
+ return true;
}
}
t = default;
return false;
}
+
+ public static void Serialize(glTFTextureInfo info, Vector2 offset, Vector2 scale)
+ {
+ if (info.extensions == null)
+ {
+ info.extensions = new glTFExtension();
+ }
+
+ var f = new JsonFormatter();
+ f.BeginMap();
+
+ f.Key("offset");
+ f.BeginList();
+ f.Value(offset.x);
+ f.Value(offset.y);
+ f.EndList();
+
+ f.Key("scale");
+ f.BeginList();
+ f.Value(scale.x);
+ f.Value(scale.y);
+ f.EndList();
+
+ f.EndMap();
+
+ info.extensions.Serialized.Add(ExtensionName, f.GetStore().ToString());
+ }
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltfExtension.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltfExtension.cs
new file mode 100644
index 000000000..a8a994439
--- /dev/null
+++ b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltfExtension.cs
@@ -0,0 +1,44 @@
+using System.Collections.Generic;
+using UniJSON;
+
+namespace UniGLTF
+{
+ ///
+ /// Extension または Extras に使う
+ ///
+ public class glTFExtension
+ {
+ #region for Export
+ public readonly Dictionary Serialized;
+ public glTFExtension()
+ {
+ Serialized = new Dictionary();
+ }
+ public static glTFExtension Create(string key, string serialized)
+ {
+ var e = new glTFExtension();
+ e.Serialized.Add(key, serialized);
+ return e;
+ }
+ #endregion
+
+ #region for Import
+ readonly ListTreeNode m_json;
+ public glTFExtension(ListTreeNode json)
+ {
+ m_json = json;
+ }
+
+ public IEnumerable, ListTreeNode>> ObjectItems()
+ {
+ if (m_json.Value.ValueType == ValueNodeType.Object)
+ {
+ foreach (var kv in m_json.ObjectItems())
+ {
+ yield return kv;
+ }
+ }
+ }
+ #endregion
+ }
+}
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltfExtension.cs.meta b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltfExtension.cs.meta
new file mode 100644
index 000000000..dfa4355a7
--- /dev/null
+++ b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltfExtension.cs.meta
@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: d078ffd4a6179da48af7c4290beeb140
+MonoImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ defaultReferences: []
+ executionOrder: 0
+ icon: {instanceID: 0}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs
index 2975936fe..bccde0051 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/ExtensionsAndExtras/gltf_mesh_extras_targetNames.cs
@@ -12,7 +12,7 @@ namespace UniGLTF
/// * meshes[].extras.targetNames
///
///
- public class gltf_mesh_extras_targetNames
+ public static class gltf_mesh_extras_targetNames
{
public const string ExtraName = "targetNames";
@@ -33,37 +33,24 @@ namespace UniGLTF
public static bool TryGet(glTFMesh mesh, out List targetNames)
{
+ foreach (var kv in mesh.extras.ObjectItems())
{
- if (mesh.extras is ListTreeNode json)
+ if (kv.Key.GetUtf8String() == ExtraNameUtf8)
{
- if (json.Value.ValueType == ValueNodeType.Object)
- {
- foreach (var kv in json.ObjectItems())
- {
- if (kv.Key.GetUtf8String() == ExtraNameUtf8)
- {
- targetNames = Deserialize(kv.Value);
- return true;
- }
- }
- }
+ targetNames = Deserialize(kv.Value);
+ return true;
}
}
+ // use first primitive
+ if (mesh.primitives.Count > 0)
{
- // use first primitive
- if (mesh.primitives.Count > 0 && mesh.primitives[0].extras is ListTreeNode json)
+ foreach (var kv in mesh.primitives[0].extras.ObjectItems())
{
- if (json.Value.ValueType == ValueNodeType.Object)
+ if (kv.Key.GetUtf8String() == ExtraNameUtf8)
{
- foreach (var kv in json.ObjectItems())
- {
- if (kv.Key.GetUtf8String() == ExtraNameUtf8)
- {
- targetNames = Deserialize(kv.Value);
- return true;
- }
- }
+ targetNames = Deserialize(kv.Value);
+ return true;
}
}
}
@@ -71,5 +58,47 @@ namespace UniGLTF
targetNames = default;
return false;
}
+
+ public static glTFExtension Serialize(params string[] args)
+ {
+ var f = new JsonFormatter();
+ f.BeginList();
+ foreach (var arg in args)
+ {
+ // エスケープとかあるし
+ f.Value(arg);
+ }
+ f.EndList();
+
+ return glTFExtension.Create(ExtraName, f.GetStore().ToString());
+ }
+
+ public static void Serialize(glTFMesh gltfMesh, IEnumerable targetNames)
+ {
+ // targetNames
+ var f = new JsonFormatter();
+ f.BeginList();
+ foreach (var n in targetNames)
+ {
+ f.Value(n);
+ }
+ f.EndList();
+ var targetNamesJson = f.GetStore().ToString();
+
+ if (gltfMesh.extras == null)
+ {
+ gltfMesh.extras = new glTFExtension();
+ }
+ gltfMesh.extras.Serialized.Add(ExtraName, targetNamesJson);
+
+ foreach (var prim in gltfMesh.primitives)
+ {
+ if (prim.extras == null)
+ {
+ prim.extras = new glTFExtension();
+ }
+ prim.extras.Serialized.Add(ExtraName, targetNamesJson);
+ }
+ }
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs
index 78572e580..07c181cdb 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTF.cs
@@ -14,8 +14,8 @@ namespace UniGLTF
[ItemJsonSchema(Minimum = 0)]
public int[] nodes;
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public string name;
}
@@ -298,8 +298,8 @@ namespace UniGLTF
[JsonSchema(MinItems = 1, ExplicitIgnorableItemLength = 0)]
public List extensionsRequired = new List();
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public override string ToString()
{
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs
index 757a63d7a..89460cce7 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFAnimation.cs
@@ -16,8 +16,8 @@ namespace UniGLTF
public string path;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public enum Interpolations
{
@@ -142,8 +142,8 @@ namespace UniGLTF
public glTFAnimationTarget target;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
[Serializable]
@@ -159,8 +159,8 @@ namespace UniGLTF
public int output = -1;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
[Serializable]
@@ -175,8 +175,8 @@ namespace UniGLTF
public List samplers = new List();
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
[Obsolete]
public int AddChannelAndGetSampler(int nodeIndex, glTFAnimationTarget.AnimationPropertys property)
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs
index 9fbb1a4ae..b2e3e6248 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFAssets.cs
@@ -17,8 +17,8 @@ namespace UniGLTF
public string minVersion;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public override string ToString()
{
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs
index 32a360ef3..81597d27e 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFBuffer.cs
@@ -29,8 +29,8 @@ namespace UniGLTF
public int byteLength;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public string name;
public glTFBufferView Append(T[] array, glBufferTarget target) where T : struct
@@ -69,8 +69,8 @@ namespace UniGLTF
public glBufferTarget target;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public string name;
}
@@ -87,8 +87,8 @@ namespace UniGLTF
public glComponentType componentType;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
[Serializable]
@@ -101,8 +101,8 @@ namespace UniGLTF
public int byteOffset;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
[Serializable]
@@ -118,8 +118,8 @@ namespace UniGLTF
public glTFSparseValues values;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
[Serializable]
@@ -177,8 +177,8 @@ namespace UniGLTF
// empty schemas
public string name;
- public object extensions;
+ public glTFExtension extensions;
- public object extras;
+ public glTFExtension extras;
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs
index e24ec1eeb..b75ea960c 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFCamera.cs
@@ -22,9 +22,9 @@ namespace UniGLTF
public float znear;
[JsonSchema(MinProperties = 1)]
- public object extensions;
+ public glTFExtension extensions;
[JsonSchema(MinProperties = 1)]
- public object extras;
+ public glTFExtension extras;
}
[Serializable]
@@ -39,8 +39,8 @@ namespace UniGLTF
[JsonSchema(Required = true, Minimum = 0.0f, ExclusiveMinimum = true)]
public float znear;
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
[Serializable]
@@ -54,7 +54,7 @@ namespace UniGLTF
public string name;
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs
index aba222902..decd33fa8 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFMaterial.cs
@@ -28,8 +28,8 @@ namespace UniGLTF
public int texCoord;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public abstract glTFTextureTypes TextureType { get; }
}
@@ -103,8 +103,8 @@ namespace UniGLTF
public float roughnessFactor = 1.0f;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
[Serializable]
@@ -134,8 +134,8 @@ namespace UniGLTF
public bool doubleSided;
[JsonSchema(SkipSchemaComparison = true)]
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public glTFTextureInfo[] GetTextures()
{
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs
index f49224d07..480f00519 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFMesh.cs
@@ -99,10 +99,10 @@ namespace UniGLTF
[ItemJsonSchema(SkipSchemaComparison = true)]
public List targets = new List();
- public object extras;
+ public glTFExtension extras;
[JsonSchema(SkipSchemaComparison = true)]
- public object extensions;
+ public glTFExtension extensions;
}
[Serializable]
@@ -117,10 +117,10 @@ namespace UniGLTF
public float[] weights;
[JsonSchema(SkipSchemaComparison = true)]
- public object extras;
+ public glTFExtension extras;
// empty schemas
- public object extensions;
+ public glTFExtension extensions;
public glTFMesh()
{
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs
index 7532a937e..955442d01 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFNode.cs
@@ -40,8 +40,8 @@ namespace UniGLTF
public int camera = -1;
// empty schemas
- public object extensions;
+ public glTFExtension extensions;
- public object extras;
+ public glTFExtension extras;
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs
index a4a1911c8..c2ae23463 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFSkin.cs
@@ -17,8 +17,8 @@ namespace UniGLTF
public int skeleton = -1;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public string name;
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs b/Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs
index f5a2fe8ee..20d3a8be2 100644
--- a/Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs
+++ b/Assets/VRM/UniGLTF/Scripts/Format/glTFTexture.cs
@@ -30,8 +30,8 @@ namespace UniGLTF
public glWrap wrapT = glWrap.REPEAT;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public string name;
}
@@ -74,8 +74,8 @@ namespace UniGLTF
}
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
[Serializable]
@@ -88,8 +88,8 @@ namespace UniGLTF
public int source;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
public string name;
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs
index ec95e13fa..c54748b36 100644
--- a/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs
+++ b/Assets/VRM/UniGLTF/Scripts/IO/FormatterExtensionsGltf.g.cs
@@ -10,7 +10,11 @@ namespace UniGLTF {
static public class IFormatterExtensionsGltf
{
-
+ public static void GenSerialize(this IFormatter f, glTF_VRM_extensions value)
+ {
+
+ }
+
/// gltf
public static void GenSerialize(this IFormatter f, glTF value)
{
@@ -101,11 +105,6 @@ namespace UniGLTF {
f.Key("extensionsRequired"); f.GenSerialize(value.extensionsRequired);
}
- if(value.extensions!=null)
- {
- f.Key("extensions"); f.GenSerialize(value.extensions);
- }
-
f.EndMap();
}
@@ -577,11 +576,6 @@ namespace UniGLTF {
f.Key("doubleSided"); f.GenSerialize(value.doubleSided);
}
- if(value.extensions!=null)
- {
- f.Key("extensions"); f.GenSerialize(value.extensions);
- }
-
f.EndMap();
}
@@ -629,52 +623,6 @@ namespace UniGLTF {
}
- {
- f.Key("texCoord"); f.GenSerialize(value.texCoord);
- }
-
- if(value.extensions!=null)
- {
- f.Key("extensions"); f.GenSerialize(value.extensions);
- }
-
- f.EndMap();
- }
-
- /// gltf/materials[]/pbrMetallicRoughness/baseColorTexture/extensions
- public static void GenSerialize(this IFormatter f, object value)
- {
- f.BeginMap(0); // dummy
-
- // if(value.KHR_texture_transform!=null)
- // {
- // f.Key("KHR_texture_transform"); f.GenSerialize(value.KHR_texture_transform);
- // }
-
- f.EndMap();
- }
-
- /// gltf/materials[]/pbrMetallicRoughness/baseColorTexture/extensions/KHR_texture_transform
- public static void GenSerialize(this IFormatter f, glTF_KHR_texture_transform value)
- {
- f.BeginMap(0); // dummy
-
- if(value.offset!=null)
- {
- f.Key("offset"); f.GenSerialize(value.offset);
- }
-
-
- {
- f.Key("rotation"); f.GenSerialize(value.rotation);
- }
-
- if(value.scale!=null)
- {
- f.Key("scale"); f.GenSerialize(value.scale);
- }
-
-
{
f.Key("texCoord"); f.GenSerialize(value.texCoord);
}
@@ -697,11 +645,6 @@ namespace UniGLTF {
f.Key("texCoord"); f.GenSerialize(value.texCoord);
}
- if(value.extensions!=null)
- {
- f.Key("extensions"); f.GenSerialize(value.extensions);
- }
-
f.EndMap();
}
@@ -725,11 +668,6 @@ namespace UniGLTF {
f.Key("texCoord"); f.GenSerialize(value.texCoord);
}
- if(value.extensions!=null)
- {
- f.Key("extensions"); f.GenSerialize(value.extensions);
- }
-
f.EndMap();
}
@@ -753,11 +691,6 @@ namespace UniGLTF {
f.Key("texCoord"); f.GenSerialize(value.texCoord);
}
- if(value.extensions!=null)
- {
- f.Key("extensions"); f.GenSerialize(value.extensions);
- }
-
f.EndMap();
}
@@ -776,19 +709,6 @@ namespace UniGLTF {
f.Key("texCoord"); f.GenSerialize(value.texCoord);
}
- if(value.extensions!=null)
- {
- f.Key("extensions"); f.GenSerialize(value.extensions);
- }
-
- f.EndMap();
- }
-
- /// gltf/materials[]/extensions/KHR_materials_unlit
- public static void GenSerialize(this IFormatter f, glTF_KHR_materials_unlit value)
- {
- f.BeginMap(0); // dummy
-
f.EndMap();
}
@@ -823,11 +743,6 @@ namespace UniGLTF {
f.Key("weights"); f.GenSerialize(value.weights);
}
- if(value.extras!=null)
- {
- f.Key("extras"); f.GenSerialize(value.extras);
- }
-
f.EndMap();
}
@@ -872,11 +787,6 @@ namespace UniGLTF {
f.Key("targets"); f.GenSerialize(value.targets);
}
- // if(value.extras!=null && value.extras.targetNames!=null && value.extras.targetNames.Count>0)
- // {
- // f.Key("extras"); f.GenSerialize(value.extras);
- // }
-
f.EndMap();
}
@@ -905,6 +815,11 @@ namespace UniGLTF {
f.Key("TEXCOORD_0"); f.GenSerialize(value.TEXCOORD_0);
}
+ if(value.TEXCOORD_1!=-1)
+ {
+ f.Key("TEXCOORD_1"); f.GenSerialize(value.TEXCOORD_1);
+ }
+
if(value.COLOR_0!=-1)
{
f.Key("COLOR_0"); f.GenSerialize(value.COLOR_0);
@@ -957,30 +872,6 @@ namespace UniGLTF {
f.EndMap();
}
- /// gltf/meshes[]/primitives[]/extras
- // public static void GenSerialize(this IFormatter f, glTFPrimitives_extras value)
- // {
- // f.BeginMap(0); // dummy
-
- // if(value.targetNames!=null)
- // {
- // f.Key("targetNames"); f.GenSerialize(value.targetNames);
- // }
-
- // f.EndMap();
- // }
-
- /// gltf/meshes[]/primitives[]/extras/targetNames
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
/// gltf/nodes
public static void GenSerialize(this IFormatter f, List value)
{
@@ -1061,22 +952,6 @@ namespace UniGLTF {
f.EndList();
}
- // /// gltf/nodes[]/extensions
- // public static void GenSerialize(this IFormatter f, glTFNode_extensions value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
- // /// gltf/nodes[]/extras
- // public static void GenSerialize(this IFormatter f, glTFNode_extra value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
/// gltf/skins
public static void GenSerialize(this IFormatter f, List value)
{
@@ -1327,22 +1202,6 @@ namespace UniGLTF {
f.EndMap();
}
- // /// gltf/cameras[]/orthographic/extensions
- // public static void GenSerialize(this IFormatter f, glTFOrthographic_extensions value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
- // /// gltf/cameras[]/orthographic/extras
- // public static void GenSerialize(this IFormatter f, glTFOrthographic_extras value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
/// gltf/cameras[]/perspective
public static void GenSerialize(this IFormatter f, glTFPerspective value)
{
@@ -1371,232 +1230,13 @@ namespace UniGLTF {
f.EndMap();
}
- // /// gltf/cameras[]/perspective/extensions
- // public static void GenSerialize(this IFormatter f, glTFPerspective_extensions value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
- // /// gltf/cameras[]/perspective/extras
- // public static void GenSerialize(this IFormatter f, glTFPerspective_extras value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
public static void GenSerialize(this IFormatter f, ProjectionType value)
{
f.Value((int)value);
}
- // /// gltf/cameras[]/extensions
- // public static void GenSerialize(this IFormatter f, glTFCamera_extensions value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
- // /// gltf/cameras[]/extras
- // public static void GenSerialize(this IFormatter f, glTFCamera_extras value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
- // /// gltf/extensions
- // public static void GenSerialize(this IFormatter f, glTF_extensions value)
- // {
- // f.BeginMap(0); // dummy
-
- // if(value.VRM!=null)
- // {
- // f.Key("VRM"); f.GenSerialize(value.VRM);
- // }
-
- // f.EndMap();
- // }
-
- /// gltf/extensions/VRM
- public static void GenSerialize(this IFormatter f, glTF_VRM_extensions value)
- {
- f.BeginMap(0); // dummy
-
- if(value.exporterVersion!=null)
- {
- f.Key("exporterVersion"); f.GenSerialize(value.exporterVersion);
- }
-
- if(value.specVersion!=null)
- {
- f.Key("specVersion"); f.GenSerialize(value.specVersion);
- }
-
- if(value.meta!=null)
- {
- f.Key("meta"); f.GenSerialize(value.meta);
- }
-
- if(value.humanoid!=null)
- {
- f.Key("humanoid"); f.GenSerialize(value.humanoid);
- }
-
- if(value.firstPerson!=null)
- {
- f.Key("firstPerson"); f.GenSerialize(value.firstPerson);
- }
-
- if(value.blendShapeMaster!=null)
- {
- f.Key("blendShapeMaster"); f.GenSerialize(value.blendShapeMaster);
- }
-
- if(value.secondaryAnimation!=null)
- {
- f.Key("secondaryAnimation"); f.GenSerialize(value.secondaryAnimation);
- }
-
- if(value.materialProperties!=null)
- {
- f.Key("materialProperties"); f.GenSerialize(value.materialProperties);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/meta
- public static void GenSerialize(this IFormatter f, glTF_VRM_Meta value)
- {
- f.BeginMap(0); // dummy
-
- if(value.title!=null)
- {
- f.Key("title"); f.GenSerialize(value.title);
- }
-
- if(value.version!=null)
- {
- f.Key("version"); f.GenSerialize(value.version);
- }
-
- if(value.author!=null)
- {
- f.Key("author"); f.GenSerialize(value.author);
- }
-
- if(value.contactInformation!=null)
- {
- f.Key("contactInformation"); f.GenSerialize(value.contactInformation);
- }
-
- if(value.reference!=null)
- {
- f.Key("reference"); f.GenSerialize(value.reference);
- }
-
-
- {
- f.Key("texture"); f.GenSerialize(value.texture);
- }
-
- if(value.allowedUserName!=null)
- {
- f.Key("allowedUserName"); f.GenSerialize(value.allowedUserName);
- }
-
- if(value.violentUssageName!=null)
- {
- f.Key("violentUssageName"); f.GenSerialize(value.violentUssageName);
- }
-
- if(value.sexualUssageName!=null)
- {
- f.Key("sexualUssageName"); f.GenSerialize(value.sexualUssageName);
- }
-
- if(value.commercialUssageName!=null)
- {
- f.Key("commercialUssageName"); f.GenSerialize(value.commercialUssageName);
- }
-
- if(value.otherPermissionUrl!=null)
- {
- f.Key("otherPermissionUrl"); f.GenSerialize(value.otherPermissionUrl);
- }
-
- if(value.licenseName!=null)
- {
- f.Key("licenseName"); f.GenSerialize(value.licenseName);
- }
-
- if(value.otherLicenseUrl!=null)
- {
- f.Key("otherLicenseUrl"); f.GenSerialize(value.otherLicenseUrl);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/humanoid
- public static void GenSerialize(this IFormatter f, glTF_VRM_Humanoid value)
- {
- f.BeginMap(0); // dummy
-
- if(value.humanBones!=null)
- {
- f.Key("humanBones"); f.GenSerialize(value.humanBones);
- }
-
-
- {
- f.Key("armStretch"); f.GenSerialize(value.armStretch);
- }
-
-
- {
- f.Key("legStretch"); f.GenSerialize(value.legStretch);
- }
-
-
- {
- f.Key("upperArmTwist"); f.GenSerialize(value.upperArmTwist);
- }
-
-
- {
- f.Key("lowerArmTwist"); f.GenSerialize(value.lowerArmTwist);
- }
-
-
- {
- f.Key("upperLegTwist"); f.GenSerialize(value.upperLegTwist);
- }
-
-
- {
- f.Key("lowerLegTwist"); f.GenSerialize(value.lowerLegTwist);
- }
-
-
- {
- f.Key("feetSpacing"); f.GenSerialize(value.feetSpacing);
- }
-
-
- {
- f.Key("hasTranslationDoF"); f.GenSerialize(value.hasTranslationDoF);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/humanoid/humanBones
- public static void GenSerialize(this IFormatter f, List value)
+ /// gltf/extensionsUsed
+ public static void GenSerialize(this IFormatter f, List value)
{
f.BeginList(value.Count);
foreach (var x in value)
@@ -1606,568 +1246,5 @@ namespace UniGLTF {
f.EndList();
}
- /// gltf/extensions/VRM/humanoid/humanBones[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_HumanoidBone value)
- {
- f.BeginMap(0); // dummy
-
- if(value.bone!=null)
- {
- f.Key("bone"); f.GenSerialize(value.bone);
- }
-
-
- {
- f.Key("node"); f.GenSerialize(value.node);
- }
-
-
- {
- f.Key("useDefaultValues"); f.GenSerialize(value.useDefaultValues);
- }
-
- if(value.min!=Vector3.zero)
- {
- f.Key("min"); f.GenSerialize(value.min);
- }
-
- if(value.max!=Vector3.zero)
- {
- f.Key("max"); f.GenSerialize(value.max);
- }
-
- if(value.center!=Vector3.zero)
- {
- f.Key("center"); f.GenSerialize(value.center);
- }
-
- if(value.axisLength>0)
- {
- f.Key("axisLength"); f.GenSerialize(value.axisLength);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/humanoid/humanBones[]/min
- public static void GenSerialize(this IFormatter f, Vector3 value)
- {
- f.BeginMap(0); // dummy
-
-
- {
- f.Key("x"); f.GenSerialize(value.x);
- }
-
-
- {
- f.Key("y"); f.GenSerialize(value.y);
- }
-
-
- {
- f.Key("z"); f.GenSerialize(value.z);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/firstPerson
- public static void GenSerialize(this IFormatter f, glTF_VRM_Firstperson value)
- {
- f.BeginMap(0); // dummy
-
-
- {
- f.Key("firstPersonBone"); f.GenSerialize(value.firstPersonBone);
- }
-
-
- {
- f.Key("firstPersonBoneOffset"); f.GenSerialize(value.firstPersonBoneOffset);
- }
-
- if(value.meshAnnotations!=null)
- {
- f.Key("meshAnnotations"); f.GenSerialize(value.meshAnnotations);
- }
-
- if(value.lookAtTypeName!=null)
- {
- f.Key("lookAtTypeName"); f.GenSerialize(value.lookAtTypeName);
- }
-
- if(value.lookAtHorizontalInner!=null)
- {
- f.Key("lookAtHorizontalInner"); f.GenSerialize(value.lookAtHorizontalInner);
- }
-
- if(value.lookAtHorizontalOuter!=null)
- {
- f.Key("lookAtHorizontalOuter"); f.GenSerialize(value.lookAtHorizontalOuter);
- }
-
- if(value.lookAtVerticalDown!=null)
- {
- f.Key("lookAtVerticalDown"); f.GenSerialize(value.lookAtVerticalDown);
- }
-
- if(value.lookAtVerticalUp!=null)
- {
- f.Key("lookAtVerticalUp"); f.GenSerialize(value.lookAtVerticalUp);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/firstPerson/meshAnnotations
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
- /// gltf/extensions/VRM/firstPerson/meshAnnotations[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_MeshAnnotation value)
- {
- f.BeginMap(0); // dummy
-
-
- {
- f.Key("mesh"); f.GenSerialize(value.mesh);
- }
-
- if(value.firstPersonFlag!=null)
- {
- f.Key("firstPersonFlag"); f.GenSerialize(value.firstPersonFlag);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/firstPerson/lookAtHorizontalInner
- public static void GenSerialize(this IFormatter f, glTF_VRM_DegreeMap value)
- {
- f.BeginMap(0); // dummy
-
- if(value.curve!=null)
- {
- f.Key("curve"); f.GenSerialize(value.curve);
- }
-
-
- {
- f.Key("xRange"); f.GenSerialize(value.xRange);
- }
-
-
- {
- f.Key("yRange"); f.GenSerialize(value.yRange);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/blendShapeMaster
- public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeMaster value)
- {
- f.BeginMap(0); // dummy
-
- if(value.blendShapeGroups!=null)
- {
- f.Key("blendShapeGroups"); f.GenSerialize(value.blendShapeGroups);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
- /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeGroup value)
- {
- f.BeginMap(0); // dummy
-
- if(value.name!=null)
- {
- f.Key("name"); f.GenSerialize(value.name);
- }
-
- if(value.presetName!=null)
- {
- f.Key("presetName"); f.GenSerialize(value.presetName);
- }
-
- if(value.binds!=null)
- {
- f.Key("binds"); f.GenSerialize(value.binds);
- }
-
- if(value.materialValues!=null)
- {
- f.Key("materialValues"); f.GenSerialize(value.materialValues);
- }
-
-
- {
- f.Key("isBinary"); f.GenSerialize(value.isBinary);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/binds
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
- /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/binds[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_BlendShapeBind value)
- {
- f.BeginMap(0); // dummy
-
-
- {
- f.Key("mesh"); f.GenSerialize(value.mesh);
- }
-
-
- {
- f.Key("index"); f.GenSerialize(value.index);
- }
-
-
- {
- f.Key("weight"); f.GenSerialize(value.weight);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/materialValues
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
- /// gltf/extensions/VRM/blendShapeMaster/blendShapeGroups[]/materialValues[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_MaterialValueBind value)
- {
- f.BeginMap(0); // dummy
-
- if(value.materialName!=null)
- {
- f.Key("materialName"); f.GenSerialize(value.materialName);
- }
-
- if(value.propertyName!=null)
- {
- f.Key("propertyName"); f.GenSerialize(value.propertyName);
- }
-
- if(value.targetValue!=null)
- {
- f.Key("targetValue"); f.GenSerialize(value.targetValue);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/secondaryAnimation
- public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimation value)
- {
- f.BeginMap(0); // dummy
-
- if(value.boneGroups!=null)
- {
- f.Key("boneGroups"); f.GenSerialize(value.boneGroups);
- }
-
- if(value.colliderGroups!=null)
- {
- f.Key("colliderGroups"); f.GenSerialize(value.colliderGroups);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/secondaryAnimation/boneGroups
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
- /// gltf/extensions/VRM/secondaryAnimation/boneGroups[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationGroup value)
- {
- f.BeginMap(0); // dummy
-
- if(value.comment!=null)
- {
- f.Key("comment"); f.GenSerialize(value.comment);
- }
-
-
- {
- f.Key("stiffiness"); f.GenSerialize(value.stiffiness);
- }
-
-
- {
- f.Key("gravityPower"); f.GenSerialize(value.gravityPower);
- }
-
-
- {
- f.Key("gravityDir"); f.GenSerialize(value.gravityDir);
- }
-
-
- {
- f.Key("dragForce"); f.GenSerialize(value.dragForce);
- }
-
-
- {
- f.Key("center"); f.GenSerialize(value.center);
- }
-
-
- {
- f.Key("hitRadius"); f.GenSerialize(value.hitRadius);
- }
-
- if(value.bones!=null)
- {
- f.Key("bones"); f.GenSerialize(value.bones);
- }
-
- if(value.colliderGroups!=null)
- {
- f.Key("colliderGroups"); f.GenSerialize(value.colliderGroups);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/secondaryAnimation/colliderGroups
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
- /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationColliderGroup value)
- {
- f.BeginMap(0); // dummy
-
-
- {
- f.Key("node"); f.GenSerialize(value.node);
- }
-
- if(value.colliders!=null)
- {
- f.Key("colliders"); f.GenSerialize(value.colliders);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[]/colliders
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
- /// gltf/extensions/VRM/secondaryAnimation/colliderGroups[]/colliders[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_SecondaryAnimationCollider value)
- {
- f.BeginMap(0); // dummy
-
-
- {
- f.Key("offset"); f.GenSerialize(value.offset);
- }
-
-
- {
- f.Key("radius"); f.GenSerialize(value.radius);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/materialProperties
- public static void GenSerialize(this IFormatter f, List value)
- {
- f.BeginList(value.Count);
- foreach (var x in value)
- {
- f.GenSerialize(x);
- }
- f.EndList();
- }
-
- /// gltf/extensions/VRM/materialProperties[]
- public static void GenSerialize(this IFormatter f, glTF_VRM_Material value)
- {
- f.BeginMap(0); // dummy
-
- if(value.name!=null)
- {
- f.Key("name"); f.GenSerialize(value.name);
- }
-
- if(value.shader!=null)
- {
- f.Key("shader"); f.GenSerialize(value.shader);
- }
-
-
- {
- f.Key("renderQueue"); f.GenSerialize(value.renderQueue);
- }
-
- if(value.floatProperties!=null)
- {
- f.Key("floatProperties"); f.GenSerialize(value.floatProperties);
- }
-
- if(value.vectorProperties!=null)
- {
- f.Key("vectorProperties"); f.GenSerialize(value.vectorProperties);
- }
-
- if(value.textureProperties!=null)
- {
- f.Key("textureProperties"); f.GenSerialize(value.textureProperties);
- }
-
- if(value.keywordMap!=null)
- {
- f.Key("keywordMap"); f.GenSerialize(value.keywordMap);
- }
-
- if(value.tagMap!=null)
- {
- f.Key("tagMap"); f.GenSerialize(value.tagMap);
- }
-
- f.EndMap();
- }
-
- /// gltf/extensions/VRM/materialProperties[]/floatProperties
- public static void GenSerialize(this IFormatter f, Dictionary value)
- {
- f.BeginMap(value.Count);
- foreach (var kv in value)
- {
- f.Key(kv.Key);
- f.GenSerialize(kv.Value);
- }
- f.EndMap();
- }
-
-
- /// gltf/extensions/VRM/materialProperties[]/vectorProperties
- public static void GenSerialize(this IFormatter f, Dictionary value)
- {
- f.BeginMap(value.Count);
- foreach (var kv in value)
- {
- f.Key(kv.Key);
- f.GenSerialize(kv.Value);
- }
- f.EndMap();
- }
-
-
- /// gltf/extensions/VRM/materialProperties[]/textureProperties
- public static void GenSerialize(this IFormatter f, Dictionary value)
- {
- f.BeginMap(value.Count);
- foreach (var kv in value)
- {
- f.Key(kv.Key);
- f.GenSerialize(kv.Value);
- }
- f.EndMap();
- }
-
-
- /// gltf/extensions/VRM/materialProperties[]/keywordMap
- public static void GenSerialize(this IFormatter f, Dictionary value)
- {
- f.BeginMap(value.Count);
- foreach (var kv in value)
- {
- f.Key(kv.Key);
- f.GenSerialize(kv.Value);
- }
- f.EndMap();
- }
-
-
- /// gltf/extensions/VRM/materialProperties[]/tagMap
- public static void GenSerialize(this IFormatter f, Dictionary value)
- {
- f.BeginMap(value.Count);
- foreach (var kv in value)
- {
- f.Key(kv.Key);
- f.GenSerialize(kv.Value);
- }
- f.EndMap();
- }
-
-
- // /// gltf/extras
- // public static void GenSerialize(this IFormatter f, gltf_extras value)
- // {
- // f.BeginMap(0); // dummy
-
- // f.EndMap();
- // }
-
} // class
} // namespace
diff --git a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs
index d74b3a69e..4aa842e30 100644
--- a/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs
+++ b/Assets/VRM/UniGLTF/Scripts/IO/GltfDeserializer.g.cs
@@ -105,12 +105,12 @@ public static glTF Deserialize(ListTreeNode parsed)
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -147,12 +147,12 @@ public static glTFAssets Deserialize_gltf_asset(ListTreeNode parsed)
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -188,12 +188,12 @@ public static glTFBuffer Deserialize_gltf_buffers_LIST(ListTreeNode p
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -249,12 +249,12 @@ public static glTFBufferView Deserialize_gltf_bufferViews_LIST(ListTreeNode
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -560,12 +560,12 @@ public static glTFTextureSampler Deserialize_gltf_samplers_LIST(ListTreeNode par
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -692,12 +692,12 @@ public static glTFMaterial Deserialize_gltf_materials_LIST(ListTreeNode pars
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
@@ -1033,12 +1033,12 @@ public static glTFPrimitives Deserialize_gltf_meshes__primitives_LIST(ListTreeNo
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
@@ -1213,12 +1213,12 @@ public static glTFNode Deserialize_gltf_nodes_LIST(ListTreeNode parse
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -1325,12 +1325,12 @@ public static glTFSkin Deserialize_gltf_skins_LIST(ListTreeNode parse
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -1377,12 +1377,12 @@ public static gltfScene Deserialize_gltf_scenes_LIST(ListTreeNode par
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -1439,12 +1439,12 @@ public static glTFAnimation Deserialize_gltf_animations_LIST(ListTreeNode p
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -1651,12 +1651,12 @@ public static glTFOrthographic Deserialize_gltf_cameras__orthographic(ListTreeNo
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
@@ -1693,12 +1693,12 @@ public static glTFPerspective Deserialize_gltf_cameras__perspective(ListTreeNode
}
if(key=="extensions"){
- value.extensions = kv.Value;
+ value.extensions = new glTFExtension(kv.Value);
continue;
}
if(key=="extras"){
- value.extras = kv.Value;
+ value.extras = new glTFExtension(kv.Value);
continue;
}
diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs b/Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs
index e3a4de505..32e18c4d0 100644
--- a/Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs
+++ b/Assets/VRM/UniGLTF/Scripts/IO/MaterialExporter.cs
@@ -1,5 +1,6 @@
using System.Collections.Generic;
using UniGLTF.UniUnlit;
+using UniJSON;
using UnityEngine;
@@ -189,14 +190,7 @@ namespace UniGLTF
var scale = m.GetTextureScale(propertyName);
offset.y = (offset.y + scale.y - 1) * -1.0f;
- textureInfo.extensions = new KeyValuePair[]
- {
- new KeyValuePair("KHR_texture_transform", new glTF_KHR_texture_transform()
- {
- offset = new float[] { offset.x, offset.y },
- scale = new float[] { scale.x, scale.y },
- })
- };
+ glTF_KHR_texture_transform.Serialize(textureInfo, offset, scale);
}
}
diff --git a/Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs b/Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs
index 58181cade..69d5584e2 100644
--- a/Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs
+++ b/Assets/VRM/UniGLTF/Scripts/IO/MeshExporter.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using UniJSON;
using UnityEngine;
namespace UniGLTF
@@ -266,13 +267,6 @@ namespace UniGLTF
var targetNames = new List();
- if (gltfMesh.extras == null)
- {
- gltfMesh.extras = new KeyValuePair[]{
- new KeyValuePair("targetNames", targetNames),
- };
- }
-
var blendShapeIndexMap = new Dictionary();
int exportBlendShapes = 0;
for (int j = 0; j < mesh.blendShapeCount; ++j)
@@ -297,16 +291,11 @@ namespace UniGLTF
for (int k = 0; k < gltfMesh.primitives.Count; ++k)
{
gltfMesh.primitives[k].targets.Add(morphTarget);
- if (gltfMesh.primitives[k].extras == null)
- {
- gltfMesh.primitives[k].extras = new KeyValuePair[]
- {
- new KeyValuePair("targetNames", targetNames),
- };
- }
}
}
+ gltf_mesh_extras_targetNames.Serialize(gltfMesh, targetNames);
+
yield return (mesh, gltfMesh, blendShapeIndexMap);
}
}
diff --git a/Assets/VRM/UniJSON/README.md b/Assets/VRM/UniJSON/README.md
index 82a5a0221..89136662f 100644
--- a/Assets/VRM/UniJSON/README.md
+++ b/Assets/VRM/UniJSON/README.md
@@ -58,8 +58,8 @@ public class glTFSparseIndices
public glComponentType componentType;
// empty schemas
- public object extensions;
- public object extras;
+ public glTFExtension extensions;
+ public glTFExtension extras;
}
diff --git a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs
index 6e1ca4aab..67c586268 100644
--- a/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs
+++ b/Assets/VRM/UniVRM/Editor/Tests/UniVRMSerializeTests.cs
@@ -59,91 +59,35 @@ namespace VRM
}
public static string ToJson(this glTF_VRM_MaterialValueBind self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_BlendShapeBind self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_BlendShapeGroup self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_DegreeMap self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_MeshAnnotation self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_Firstperson self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_HumanoidBone self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_Humanoid self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_Material self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_Meta self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_SecondaryAnimationCollider self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_SecondaryAnimationColliderGroup self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_SecondaryAnimationGroup self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
public static string ToJson(this glTF_VRM_SecondaryAnimation self)
- {
- var f = new JsonFormatter();
- f.GenSerialize(self);
- return f.ToString();
- }
+ { return ""; }
}
public class UniVRMSerializeTests
diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs
index 38d28281d..ada6fd4c9 100644
--- a/Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs
+++ b/Assets/VRM/UniVRM/Scripts/Format/VRMExporter.cs
@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Linq;
using UniGLTF;
+using UniJSON;
using UnityEngine;
@@ -30,9 +31,6 @@ namespace VRM
public VRMExporter(glTF gltf) : base(gltf)
{
gltf.extensionsUsed.Add(glTF_VRM_extensions.ExtensionName);
- gltf.extensions = new KeyValuePair[]{
- new KeyValuePair("VRM", VRM)
- };
}
public override void Export(MeshExportSettings configuration)
@@ -205,6 +203,12 @@ namespace VRM
{
VRM.materialProperties.Add(VRMMaterialExporter.CreateFromMaterial(m, TextureManager.Textures));
}
+
+ // Serialize VRM
+ var f = new JsonFormatter();
+ f.GenSerialize(VRM);
+ var json = f.ToString();
+ glTF.extensions = glTFExtension.Create("VRM", json);
}
}
}
diff --git a/Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs b/Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs
index 0a273e0f1..ad2ce3969 100644
--- a/Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs
+++ b/Assets/VRM/UniVRM/Scripts/Format/VRMImporterContext.cs
@@ -41,18 +41,12 @@ namespace VRM
base.ParseJson(json, storage);
// parse VRM part
- if (GLTF.extensions != null && GLTF.extensions is ListTreeNode vrmJson)
+ foreach (var kv in GLTF.extensions.ObjectItems())
{
- if (vrmJson.Value.ValueType == ValueNodeType.Object)
+ if (kv.Key.GetString() == "VRM")
{
- foreach (var kv in vrmJson.ObjectItems())
- {
- if (kv.Key.GetString() == "VRM")
- {
- VRM = VrmDeserializer.Deserialize(kv.Value);
- break;
- }
- }
+ VRM = VrmDeserializer.Deserialize(kv.Value);
+ break;
}
}