vrm-0.x の仕様で、preset: unknown のときに name を preset として解釈するに対応

This commit is contained in:
ousttrue
2022-01-18 15:45:25 +09:00
parent 95fb2eba1d
commit 1fef3fcce8

View File

@@ -8,12 +8,17 @@ namespace UniVRM10
{
public static class MigrationVrmExpression
{
static ExpressionPreset ToPreset(JsonNode json)
static ExpressionPreset ToPreset(JsonNode json, string name)
{
switch (json.GetString().ToLower())
var src = json.GetString().ToLower();
if (src == "unknown")
{
case "unknown": return ExpressionPreset.custom;
// fallback
src = name.ToLower();
}
switch (src)
{
// https://github.com/vrm-c/vrm-specification/issues/185
case "neutral": return ExpressionPreset.neutral;
@@ -39,7 +44,7 @@ namespace UniVRM10
case "lookright": return ExpressionPreset.lookRight;
}
throw new NotImplementedException();
return ExpressionPreset.custom;
}
static IEnumerable<UniGLTF.Extensions.VRMC_vrm.MorphTargetBind> ToMorphTargetBinds(JsonNode json,
@@ -199,7 +204,7 @@ namespace UniVRM10
{
isBinary = isBinaryNode.GetBoolean();
}
var preset = ToPreset(blendShapeClip["presetName"]);
var preset = ToPreset(blendShapeClip["presetName"], name);
var expression = new UniGLTF.Extensions.VRMC_vrm.Expression
{
IsBinary = isBinary,