mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-11 05:19:14 -05:00
glTFExtension
This commit is contained in:
@@ -16,7 +16,7 @@ namespace UniGLTF
|
||||
|
||||
public string GenerateDeserializerCall(string callName, string argName)
|
||||
{
|
||||
return argName;
|
||||
return $"new glTFExtension({argName})";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace UniGLTF
|
||||
/// <summary>
|
||||
/// AOT向けにシリアライザを生成する
|
||||
/// </summary>
|
||||
[MenuItem(VRM.VRMVersion.MENU + "/Generate Serializer")]
|
||||
[MenuItem(VRM.VRMVersion.MENU + "/GLTF: Generate Serializer")]
|
||||
static void GenerateSerializer()
|
||||
{
|
||||
var path = OutPath;
|
||||
|
||||
@@ -54,10 +54,7 @@ namespace UniGLTF
|
||||
{
|
||||
baseColorFactor = new float[] { 1, 0, 0, 1 },
|
||||
},
|
||||
extensions = new KeyValuePair<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("KHR_materials_unlit", new glTF_KHR_materials_unlit { }),
|
||||
}
|
||||
extensions = glTF_KHR_materials_unlit.Serialize(),
|
||||
});
|
||||
Assert.AreEqual("UniGLTF/UniUnlit", shader.name);
|
||||
}
|
||||
|
||||
@@ -237,14 +237,7 @@ namespace UniGLTF
|
||||
{
|
||||
POSITION = 0,
|
||||
},
|
||||
extras = new KeyValuePair<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>(
|
||||
"targetNames", new List<String>
|
||||
{
|
||||
"aaa",
|
||||
})
|
||||
}
|
||||
extras = gltf_mesh_extras_targetNames.Serialize("aaa"),
|
||||
};
|
||||
|
||||
var json = model.ToJson();
|
||||
|
||||
@@ -21,10 +21,7 @@ namespace UniGLTF
|
||||
roughnessFactor = 0.9f,
|
||||
metallicFactor = 0.0f,
|
||||
},
|
||||
extensions = new KeyValuePair<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>(ExtensionName, new glTF_KHR_materials_unlit()),
|
||||
},
|
||||
extensions = glTFExtension.Create(ExtensionName, "{}")
|
||||
};
|
||||
}
|
||||
|
||||
@@ -35,21 +32,20 @@ namespace UniGLTF
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m.extensions is ListTreeNode<JsonValue> 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, "{}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<JsonValue> 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
using System.Collections.Generic;
|
||||
using UniJSON;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
/// <summary>
|
||||
/// Extension または Extras に使う
|
||||
/// </summary>
|
||||
public class glTFExtension
|
||||
{
|
||||
#region for Export
|
||||
public readonly Dictionary<string, string> Serialized;
|
||||
public glTFExtension()
|
||||
{
|
||||
Serialized = new Dictionary<string, string>();
|
||||
}
|
||||
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<JsonValue> m_json;
|
||||
public glTFExtension(ListTreeNode<JsonValue> json)
|
||||
{
|
||||
m_json = json;
|
||||
}
|
||||
|
||||
public IEnumerable<KeyValuePair<ListTreeNode<JsonValue>, ListTreeNode<JsonValue>>> ObjectItems()
|
||||
{
|
||||
if (m_json.Value.ValueType == ValueNodeType.Object)
|
||||
{
|
||||
foreach (var kv in m_json.ObjectItems())
|
||||
{
|
||||
yield return kv;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d078ffd4a6179da48af7c4290beeb140
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -12,7 +12,7 @@ namespace UniGLTF
|
||||
/// * meshes[].extras.targetNames
|
||||
///
|
||||
/// </summary>
|
||||
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<string> targetNames)
|
||||
{
|
||||
foreach (var kv in mesh.extras.ObjectItems())
|
||||
{
|
||||
if (mesh.extras is ListTreeNode<JsonValue> 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<JsonValue> 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<string> 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<string> extensionsRequired = new List<string>();
|
||||
|
||||
public object extensions;
|
||||
public object extras;
|
||||
public glTFExtension extensions;
|
||||
public glTFExtension extras;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
|
||||
@@ -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<glTFAnimationSampler> samplers = new List<glTFAnimationSampler>();
|
||||
|
||||
// empty schemas
|
||||
public object extensions;
|
||||
public object extras;
|
||||
public glTFExtension extensions;
|
||||
public glTFExtension extras;
|
||||
|
||||
[Obsolete]
|
||||
public int AddChannelAndGetSampler(int nodeIndex, glTFAnimationTarget.AnimationPropertys property)
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -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>(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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
{
|
||||
|
||||
@@ -99,10 +99,10 @@ namespace UniGLTF
|
||||
[ItemJsonSchema(SkipSchemaComparison = true)]
|
||||
public List<gltfMorphTarget> targets = new List<gltfMorphTarget>();
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
@@ -40,8 +40,8 @@ namespace UniGLTF
|
||||
public int camera = -1;
|
||||
|
||||
// empty schemas
|
||||
public object extensions;
|
||||
public glTFExtension extensions;
|
||||
|
||||
public object extras;
|
||||
public glTFExtension extras;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -105,12 +105,12 @@ public static glTF Deserialize(ListTreeNode<JsonValue> 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<JsonValue> 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<JsonValue> 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<Json
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -335,12 +335,12 @@ public static glTFAccessor Deserialize_gltf_accessors_LIST(ListTreeNode<JsonValu
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -394,12 +394,12 @@ public static glTFSparse Deserialize_gltf_accessors__sparse(ListTreeNode<JsonVal
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -431,12 +431,12 @@ public static glTFSparseIndices Deserialize_gltf_accessors__sparse_indices(ListT
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -463,12 +463,12 @@ public static glTFSparseValues Deserialize_gltf_accessors__sparse_values(ListTre
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -504,12 +504,12 @@ public static glTFTexture Deserialize_gltf_textures_LIST(ListTreeNode<JsonValue>
|
||||
}
|
||||
|
||||
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<Jso
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -616,12 +616,12 @@ public static glTFImage Deserialize_gltf_images_LIST(ListTreeNode<JsonValue> 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<JsonValu
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -739,12 +739,12 @@ public static glTFPbrMetallicRoughness Deserialize_gltf_materials__pbrMetallicRo
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -771,12 +771,12 @@ public static glTFMaterialBaseColorTextureInfo Deserialize_gltf_materials__pbrMe
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -814,12 +814,12 @@ public static glTFMaterialMetallicRoughnessTextureInfo Deserialize_gltf_material
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -851,12 +851,12 @@ public static glTFMaterialNormalTextureInfo Deserialize_gltf_materials__normalTe
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -888,12 +888,12 @@ public static glTFMaterialOcclusionTextureInfo Deserialize_gltf_materials__occlu
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -920,12 +920,12 @@ public static glTFMaterialEmissiveTextureInfo Deserialize_gltf_materials__emissi
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -977,12 +977,12 @@ public static glTFMesh Deserialize_gltf_meshes_LIST(ListTreeNode<JsonValue> 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<JsonValue> 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<JsonValue> 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<JsonValue> 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<JsonVa
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1480,12 +1480,12 @@ public static glTFAnimationChannel Deserialize_gltf_animations__channels_LIST(Li
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1512,12 +1512,12 @@ public static glTFAnimationTarget Deserialize_gltf_animations__channels__target(
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1558,12 +1558,12 @@ public static glTFAnimationSampler Deserialize_gltf_animations__samplers_LIST(Li
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -1609,12 +1609,12 @@ public static glTFCamera Deserialize_gltf_cameras_LIST(ListTreeNode<JsonValue> 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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<string>();
|
||||
|
||||
if (gltfMesh.extras == null)
|
||||
{
|
||||
gltfMesh.extras = new KeyValuePair<string, object>[]{
|
||||
new KeyValuePair<string, object>("targetNames", targetNames),
|
||||
};
|
||||
}
|
||||
|
||||
var blendShapeIndexMap = new Dictionary<int, int>();
|
||||
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<string, object>[]
|
||||
{
|
||||
new KeyValuePair<string, object>("targetNames", targetNames),
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gltf_mesh_extras_targetNames.Serialize(gltfMesh, targetNames);
|
||||
|
||||
yield return (mesh, gltfMesh, blendShapeIndexMap);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,8 +58,8 @@ public class glTFSparseIndices
|
||||
public glComponentType componentType;
|
||||
|
||||
// empty schemas
|
||||
public object extensions;
|
||||
public object extras;
|
||||
public glTFExtension extensions;
|
||||
public glTFExtension extras;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<string, object>[]{
|
||||
new KeyValuePair<string, object>("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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,18 +41,12 @@ namespace VRM
|
||||
base.ParseJson(json, storage);
|
||||
|
||||
// parse VRM part
|
||||
if (GLTF.extensions != null && GLTF.extensions is ListTreeNode<JsonValue> 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user