mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-08-28 05:44:48 -05:00
VRMVersionMenu.SplitAndWriteJson
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using UniGLTF;
|
||||
using UniJSON;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
public static class VRMVersionMenu
|
||||
@@ -43,22 +45,110 @@ namespace VRM
|
||||
AssetDatabase.Refresh();
|
||||
}
|
||||
|
||||
static string GetTitle(JsonNode node)
|
||||
{
|
||||
try
|
||||
{
|
||||
var titleNode = node["title"];
|
||||
if (titleNode.Value.ValueType == JsonValueType.String)
|
||||
{
|
||||
return titleNode.Value.GetString();
|
||||
}
|
||||
}
|
||||
catch(Exception)
|
||||
{
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
static void Traverse(JsonNode node, JsonFormatter f, UnityPath dir)
|
||||
{
|
||||
switch(node.Value.ValueType)
|
||||
{
|
||||
case JsonValueType.Array:
|
||||
f.BeginList();
|
||||
foreach(var x in node.ArrayItems)
|
||||
{
|
||||
Traverse(x, f, dir);
|
||||
}
|
||||
f.EndList();
|
||||
break;
|
||||
|
||||
case JsonValueType.Object:
|
||||
//Debug.LogFormat("title: {0}", title);
|
||||
{
|
||||
f.BeginMap();
|
||||
foreach (var kv in node.ObjectItems)
|
||||
{
|
||||
f.Key(kv.Key);
|
||||
var title = GetTitle(kv.Value);
|
||||
if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
Traverse(kv.Value, f, dir);
|
||||
}
|
||||
else
|
||||
{
|
||||
// ref
|
||||
f.BeginMap();
|
||||
f.Key("$ref");
|
||||
var fileName = string.Format("{0}.schema.json", title);
|
||||
f.Value(fileName);
|
||||
f.EndMap();
|
||||
|
||||
// new formatter
|
||||
{
|
||||
var subFormatter = new JsonFormatter(4);
|
||||
|
||||
subFormatter.BeginMap();
|
||||
foreach (var _kv in kv.Value.ObjectItems)
|
||||
{
|
||||
subFormatter.Key(_kv.Key);
|
||||
Traverse(_kv.Value, subFormatter, dir);
|
||||
}
|
||||
subFormatter.EndMap();
|
||||
|
||||
var subJson = subFormatter.ToString();
|
||||
var path = dir.Child(fileName);
|
||||
File.WriteAllText(path.FullPath, subJson, Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
f.EndMap();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
f.Value(node);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static UnityPath SplitAndWriteJson(JsonNode parsed, UnityPath dir)
|
||||
{
|
||||
var f = new JsonFormatter(4);
|
||||
Traverse(parsed, f, dir);
|
||||
var json = f.ToString();
|
||||
|
||||
var path = dir.Child("vrm.schema.json");
|
||||
Debug.LogFormat("write JsonSchema: {0}", path.FullPath);
|
||||
File.WriteAllText(path.FullPath, json, Encoding.UTF8);
|
||||
return path;
|
||||
}
|
||||
|
||||
#if VRM_DEVELOP
|
||||
[MenuItem(VRMVersion.VRM_VERSION + "/Export JsonSchema")]
|
||||
#endif
|
||||
static void ExportJsonSchema()
|
||||
{
|
||||
var dir = UnityPath.FromFullpath(Application.dataPath + "/VRM/specification/0.0/schema");
|
||||
dir.EnsureFolder();
|
||||
|
||||
var path = dir.Child("vrm.schema.json");
|
||||
|
||||
Debug.LogFormat("write SsonSchema: {0}", path.FullPath);
|
||||
var schema = JsonSchema.FromType<glTF_VRM_extensions>();
|
||||
var f = new JsonFormatter(2);
|
||||
schema.ToJson(f);
|
||||
var json = f.ToString();
|
||||
File.WriteAllText(path.FullPath, json, Encoding.UTF8);
|
||||
|
||||
var dir = UnityPath.FromFullpath(Application.dataPath + "/VRM/specification/0.0/schema");
|
||||
dir.EnsureFolder();
|
||||
|
||||
var path = SplitAndWriteJson(JsonParser.Parse(json), dir);
|
||||
|
||||
Selection.activeObject = AssetDatabase.LoadAssetAtPath<UnityEngine.Object>(path.Value);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniGLTF;
|
||||
|
||||
using UniJSON;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
@@ -33,6 +33,9 @@ namespace UniGLTF
|
||||
namespace VRM
|
||||
{
|
||||
[Serializable]
|
||||
[JsonSchema(Title = "vrm", Description = @"
|
||||
VRM extension is for 3d humanoid avatars (and models) in VR applications.
|
||||
")]
|
||||
public class glTF_VRM_extensions : JsonSerializableBase
|
||||
{
|
||||
public string exporterVersion = "UniVRM-" + VRMVersion.VERSION;
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
|
||||
using UniJSON;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
@@ -100,6 +100,7 @@ namespace VRM
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[JsonSchema(Title = "vrm.blendshapemaster")]
|
||||
public class glTF_VRM_BlendShapeMaster : UniGLTF.JsonSerializableBase
|
||||
{
|
||||
public List<glTF_VRM_BlendShapeGroup> blendShapeGroups = new List<glTF_VRM_BlendShapeGroup>();
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
|
||||
using UniJSON;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
@@ -63,6 +63,7 @@ namespace VRM
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[JsonSchema(Title = "vrm.firstperson")]
|
||||
public class glTF_VRM_Firstperson : UniGLTF.JsonSerializableBase
|
||||
{
|
||||
public int firstPersonBone = -1;
|
||||
@@ -75,7 +76,8 @@ namespace VRM
|
||||
public string lookAtTypeName = "Bone";
|
||||
public LookAtType lookAtType
|
||||
{
|
||||
get {
|
||||
get
|
||||
{
|
||||
return EnumUtil.TryParseOrDefault<LookAtType>(lookAtTypeName);
|
||||
}
|
||||
set { lookAtTypeName = value.ToString(); }
|
||||
|
||||
@@ -4,7 +4,7 @@ using System.Linq;
|
||||
using UniGLTF;
|
||||
using UnityEngine;
|
||||
using UniHumanoid;
|
||||
|
||||
using UniJSON;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
@@ -127,6 +127,7 @@ namespace VRM
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[JsonSchema(Title = "vrm.humanoid")]
|
||||
public class glTF_VRM_Humanoid : JsonSerializableBase
|
||||
{
|
||||
public List<glTF_VRM_HumanoidBone> humanBones = new List<glTF_VRM_HumanoidBone>();
|
||||
@@ -222,9 +223,9 @@ namespace VRM
|
||||
center = x.center,
|
||||
min = x.min,
|
||||
max = x.max,
|
||||
humanBone = x.vrmBone.ToHumanBodyBone(),
|
||||
humanBone = x.vrmBone.ToHumanBodyBone(),
|
||||
})
|
||||
.Where(x => x.humanBone!= HumanBodyBones.LastBone)
|
||||
.Where(x => x.humanBone != HumanBodyBones.LastBone)
|
||||
.ToArray();
|
||||
return description;
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using UniGLTF.ShaderPropExporter;
|
||||
namespace VRM
|
||||
{
|
||||
[Serializable]
|
||||
[JsonSchema(Title = "vrm.material")]
|
||||
public class glTF_VRM_Material : JsonSerializableBase
|
||||
{
|
||||
public string name;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using System;
|
||||
using UniGLTF;
|
||||
|
||||
using UniJSON;
|
||||
|
||||
namespace VRM
|
||||
{
|
||||
@@ -31,6 +31,7 @@ namespace VRM
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[JsonSchema(Title = "vrm.meta")]
|
||||
public class glTF_VRM_Meta : JsonSerializableBase
|
||||
{
|
||||
static UssageLicense FromString(string src)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UniGLTF;
|
||||
using UniJSON;
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
@@ -61,6 +62,7 @@ namespace VRM
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
[JsonSchema(Title = "vrm.secondaryanimation")]
|
||||
public class glTF_VRM_SecondaryAnimation : JsonSerializableBase
|
||||
{
|
||||
public List<glTF_VRM_SecondaryAnimationGroup> boneGroups = new List<glTF_VRM_SecondaryAnimationGroup>();
|
||||
|
||||
2
UniGLTF
2
UniGLTF
Submodule UniGLTF updated: c56f237078...9e92e665ae
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"title":"vrm.blendshapemaster",
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"blendShapeGroups":{
|
||||
"type":"array"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d7e602351f4ab24eaad71cc5d8f6945
|
||||
timeCreated: 1534850992
|
||||
licenseType: Free
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
74
specification/0.0/schema/vrm.firstperson.schema.json
Normal file
74
specification/0.0/schema/vrm.firstperson.schema.json
Normal file
@@ -0,0 +1,74 @@
|
||||
{
|
||||
"title":"vrm.firstperson",
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"firstPersonBone":{
|
||||
"type":"integer"
|
||||
},
|
||||
"firstPersonBoneOffset":{
|
||||
"type":"array"
|
||||
},
|
||||
"meshAnnotations":{
|
||||
"type":"array"
|
||||
},
|
||||
"lookAtTypeName":{
|
||||
"type":"string"
|
||||
},
|
||||
"lookAtHorizontalInner":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"curve":{
|
||||
"type":"array"
|
||||
},
|
||||
"xRange":{
|
||||
"type":"number"
|
||||
},
|
||||
"yRange":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lookAtHorizontalOuter":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"curve":{
|
||||
"type":"array"
|
||||
},
|
||||
"xRange":{
|
||||
"type":"number"
|
||||
},
|
||||
"yRange":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lookAtVerticalDown":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"curve":{
|
||||
"type":"array"
|
||||
},
|
||||
"xRange":{
|
||||
"type":"number"
|
||||
},
|
||||
"yRange":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lookAtVerticalUp":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"curve":{
|
||||
"type":"array"
|
||||
},
|
||||
"xRange":{
|
||||
"type":"number"
|
||||
},
|
||||
"yRange":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f877e4bffde37d743af5ad4414dada9f
|
||||
timeCreated: 1534850992
|
||||
licenseType: Free
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
specification/0.0/schema/vrm.humanoid.schema.json
Normal file
33
specification/0.0/schema/vrm.humanoid.schema.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"title":"vrm.humanoid",
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"humanBones":{
|
||||
"type":"array"
|
||||
},
|
||||
"armStretch":{
|
||||
"type":"number"
|
||||
},
|
||||
"legStretch":{
|
||||
"type":"number"
|
||||
},
|
||||
"upperArmTwist":{
|
||||
"type":"number"
|
||||
},
|
||||
"lowerArmTwist":{
|
||||
"type":"number"
|
||||
},
|
||||
"upperLegTwist":{
|
||||
"type":"number"
|
||||
},
|
||||
"lowerLegTwist":{
|
||||
"type":"number"
|
||||
},
|
||||
"feetSpacing":{
|
||||
"type":"number"
|
||||
},
|
||||
"hasTranslationDoF":{
|
||||
"type":"bool"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
specification/0.0/schema/vrm.humanoid.schema.json.meta
Normal file
8
specification/0.0/schema/vrm.humanoid.schema.json.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31ac48d6b0a054d47bc138b4895b9e5c
|
||||
timeCreated: 1534850992
|
||||
licenseType: Free
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
45
specification/0.0/schema/vrm.meta.schema.json
Normal file
45
specification/0.0/schema/vrm.meta.schema.json
Normal file
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"title":"vrm.meta",
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"title":{
|
||||
"type":"string"
|
||||
},
|
||||
"version":{
|
||||
"type":"string"
|
||||
},
|
||||
"author":{
|
||||
"type":"string"
|
||||
},
|
||||
"contactInformation":{
|
||||
"type":"string"
|
||||
},
|
||||
"reference":{
|
||||
"type":"string"
|
||||
},
|
||||
"texture":{
|
||||
"type":"integer"
|
||||
},
|
||||
"allowedUserName":{
|
||||
"type":"string"
|
||||
},
|
||||
"violentUssageName":{
|
||||
"type":"string"
|
||||
},
|
||||
"sexualUssageName":{
|
||||
"type":"string"
|
||||
},
|
||||
"commercialUssageName":{
|
||||
"type":"string"
|
||||
},
|
||||
"otherPermissionUrl":{
|
||||
"type":"string"
|
||||
},
|
||||
"licenseName":{
|
||||
"type":"string"
|
||||
},
|
||||
"otherLicenseUrl":{
|
||||
"type":"string"
|
||||
}
|
||||
}
|
||||
}
|
||||
8
specification/0.0/schema/vrm.meta.schema.json.meta
Normal file
8
specification/0.0/schema/vrm.meta.schema.json.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ca95771dc3d93c4a9471fc18de615a8
|
||||
timeCreated: 1534850992
|
||||
licenseType: Free
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,179 +1,28 @@
|
||||
{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"exporterVersion":{
|
||||
"type":"string"
|
||||
},
|
||||
"meta":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"title":{
|
||||
"type":"string"
|
||||
"title":"vrm",
|
||||
"description":"VRM extension is for 3d humanoid avatars (and models) in VR applications.",
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"exporterVersion":{
|
||||
"type":"string"
|
||||
},
|
||||
"version":{
|
||||
"type":"string"
|
||||
"meta":{
|
||||
"$ref":"vrm.meta.schema.json"
|
||||
},
|
||||
"author":{
|
||||
"type":"string"
|
||||
"humanoid":{
|
||||
"$ref":"vrm.humanoid.schema.json"
|
||||
},
|
||||
"contactInformation":{
|
||||
"type":"string"
|
||||
"firstPerson":{
|
||||
"$ref":"vrm.firstperson.schema.json"
|
||||
},
|
||||
"reference":{
|
||||
"type":"string"
|
||||
"blendShapeMaster":{
|
||||
"$ref":"vrm.blendshapemaster.schema.json"
|
||||
},
|
||||
"texture":{
|
||||
"type":"integer"
|
||||
"secondaryAnimation":{
|
||||
"$ref":"vrm.secondaryanimation.schema.json"
|
||||
},
|
||||
"allowedUserName":{
|
||||
"type":"string"
|
||||
},
|
||||
"violentUssageName":{
|
||||
"type":"string"
|
||||
},
|
||||
"sexualUssageName":{
|
||||
"type":"string"
|
||||
},
|
||||
"commercialUssageName":{
|
||||
"type":"string"
|
||||
},
|
||||
"otherPermissionUrl":{
|
||||
"type":"string"
|
||||
},
|
||||
"licenseName":{
|
||||
"type":"string"
|
||||
},
|
||||
"otherLicenseUrl":{
|
||||
"type":"string"
|
||||
"materialProperties":{
|
||||
"type":"array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"humanoid":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"humanBones":{
|
||||
"type":"array"
|
||||
},
|
||||
"armStretch":{
|
||||
"type":"number"
|
||||
},
|
||||
"legStretch":{
|
||||
"type":"number"
|
||||
},
|
||||
"upperArmTwist":{
|
||||
"type":"number"
|
||||
},
|
||||
"lowerArmTwist":{
|
||||
"type":"number"
|
||||
},
|
||||
"upperLegTwist":{
|
||||
"type":"number"
|
||||
},
|
||||
"lowerLegTwist":{
|
||||
"type":"number"
|
||||
},
|
||||
"feetSpacing":{
|
||||
"type":"number"
|
||||
},
|
||||
"hasTranslationDoF":{
|
||||
"type":"bool"
|
||||
}
|
||||
}
|
||||
},
|
||||
"firstPerson":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"firstPersonBone":{
|
||||
"type":"integer"
|
||||
},
|
||||
"firstPersonBoneOffset":{
|
||||
"type":"array"
|
||||
},
|
||||
"meshAnnotations":{
|
||||
"type":"array"
|
||||
},
|
||||
"lookAtTypeName":{
|
||||
"type":"string"
|
||||
},
|
||||
"lookAtHorizontalInner":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"curve":{
|
||||
"type":"array"
|
||||
},
|
||||
"xRange":{
|
||||
"type":"number"
|
||||
},
|
||||
"yRange":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lookAtHorizontalOuter":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"curve":{
|
||||
"type":"array"
|
||||
},
|
||||
"xRange":{
|
||||
"type":"number"
|
||||
},
|
||||
"yRange":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lookAtVerticalDown":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"curve":{
|
||||
"type":"array"
|
||||
},
|
||||
"xRange":{
|
||||
"type":"number"
|
||||
},
|
||||
"yRange":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"lookAtVerticalUp":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"curve":{
|
||||
"type":"array"
|
||||
},
|
||||
"xRange":{
|
||||
"type":"number"
|
||||
},
|
||||
"yRange":{
|
||||
"type":"number"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"blendShapeMaster":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"blendShapeGroups":{
|
||||
"type":"array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"secondaryAnimation":{
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"boneGroups":{
|
||||
"type":"array"
|
||||
},
|
||||
"colliderGroups":{
|
||||
"type":"array"
|
||||
}
|
||||
}
|
||||
},
|
||||
"materialProperties":{
|
||||
"type":"array"
|
||||
}
|
||||
}
|
||||
}
|
||||
12
specification/0.0/schema/vrm.secondaryanimation.schema.json
Normal file
12
specification/0.0/schema/vrm.secondaryanimation.schema.json
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"title":"vrm.secondaryanimation",
|
||||
"type":"object",
|
||||
"properties":{
|
||||
"boneGroups":{
|
||||
"type":"array"
|
||||
},
|
||||
"colliderGroups":{
|
||||
"type":"array"
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0d7fef398632ca44089cc531445bc680
|
||||
timeCreated: 1534850992
|
||||
licenseType: Free
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user