Skip to content

Commit

Permalink
cleanup json extensions use of texcoord, add normal texture info
Browse files Browse the repository at this point in the history
  • Loading branch information
hybridherbst committed Jan 10, 2023
1 parent f3dc8ad commit 157f5b1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ public static TextureInfo DeserializeAsTexture(this JToken token, GLTFRoot root)
// Broken on il2cpp. Don't ship debug DLLs there.
System.Diagnostics.Debug.WriteLine("textureObject is " + textureObject.Type + " with a value of: " + textureObject[TextureInfo.INDEX].Type + " " + textureObject.ToString());
#endif

int indexVal = textureObject[TextureInfo.INDEX].DeserializeAsInt();
textureInfo = new TextureInfo()
{
Expand All @@ -109,11 +108,33 @@ public static TextureInfo DeserializeAsTexture(this JToken token, GLTFRoot root)
Root = root
}
};
if (textureObject.ContainsKey(TextureInfo.TEXCOORD))
{
textureInfo.TexCoord = textureObject[TextureInfo.TEXCOORD].DeserializeAsInt();
}
}

return textureInfo;
}

public static NormalTextureInfo DeserializeAsNormalTexture(this JToken token, GLTFRoot root)
{
var tex = DeserializeAsTexture(token, root);
if (tex != null)
{
var normalTex = new NormalTextureInfo() { Index = tex.Index, TexCoord = tex.TexCoord };
JObject textureObject = token as JObject;
if (textureObject.ContainsKey(NormalTextureInfo.SCALE))
{
normalTex.Scale = textureObject[NormalTextureInfo.SCALE].DeserializeAsDouble();
}

return normalTex;
}

return null;
}

public static int DeserializeAsInt(this JToken token)
{
if (token != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
using System.IO;
using GLTF.Schema;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityGLTF.Cache;
using UnityGLTF.Extensions;
using Object = UnityEngine.Object;
using WrapMode = GLTF.Schema.WrapMode;

Expand Down

0 comments on commit 157f5b1

Please sign in to comment.