mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-13 06:20:01 -05:00
Updated UniGLTF
This commit is contained in:
@@ -290,31 +290,22 @@ namespace VRM
|
||||
{
|
||||
var x = new TextureItem(context.GLTF, i);
|
||||
x.Process(context.GLTF, storage);
|
||||
context.Textures.Add(x);
|
||||
context.AddTexture(x);
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
|
||||
static IEnumerator LoadMaterials(VRMImporterContext context)
|
||||
{
|
||||
Func<int, TextureItem> getTexture = x =>
|
||||
{
|
||||
if (x < 0 || x >= context.Textures.Count)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return context.Textures[x];
|
||||
};
|
||||
|
||||
if (context.GLTF.materials == null || !context.GLTF.materials.Any())
|
||||
{
|
||||
context.AddMaterial(context.MaterialImporter.CreateMaterial(0, null, getTexture));
|
||||
context.AddMaterial(context.MaterialImporter.CreateMaterial(0, null));
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < context.GLTF.materials.Count; ++i)
|
||||
{
|
||||
context.AddMaterial(context.MaterialImporter.CreateMaterial(i, context.GLTF.materials[i], getTexture));
|
||||
context.AddMaterial(context.MaterialImporter.CreateMaterial(i, context.GLTF.materials[i]));
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
@@ -448,7 +439,7 @@ namespace VRM
|
||||
texture.Process(ctx.GLTF, ctx.Storage);
|
||||
return texture;
|
||||
})
|
||||
.ContinueWith(Scheduler.ThreadPool, x => ctx.Textures.Add(x));
|
||||
.ContinueWith(Scheduler.ThreadPool, x => ctx.AddTexture(x));
|
||||
}
|
||||
})
|
||||
.ContinueWithCoroutine(Scheduler.MainThread, () => LoadMaterials(ctx))
|
||||
|
||||
@@ -29,10 +29,11 @@ namespace VRM
|
||||
meta.Reference = gltfMeta.reference;
|
||||
meta.Title = gltfMeta.title;
|
||||
|
||||
if (gltfMeta.texture >= 0 && gltfMeta.texture < Textures.Count)
|
||||
var thumbnail = GetTexture(gltfMeta.texture);
|
||||
if (thumbnail!=null)
|
||||
{
|
||||
// ロード済み
|
||||
meta.Thumbnail = Textures[gltfMeta.texture].Texture;
|
||||
meta.Thumbnail = thumbnail.Texture;
|
||||
}
|
||||
else if (createThumbnail)
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace VRM
|
||||
public class VRMMaterialImporter : MaterialImporter
|
||||
{
|
||||
List<glTF_VRM_Material> m_materials;
|
||||
public VRMMaterialImporter(ImporterContext context, List<glTF_VRM_Material> materials) : base(new ShaderStore(context, "VRM/UnlitTexture"))
|
||||
public VRMMaterialImporter(ImporterContext context, List<glTF_VRM_Material> materials) : base(new ShaderStore(context, "VRM/UnlitTexture"), context)
|
||||
{
|
||||
m_materials = materials;
|
||||
/*
|
||||
@@ -47,7 +47,7 @@ namespace VRM
|
||||
"VRM/MToon",
|
||||
};
|
||||
|
||||
public override Material CreateMaterial(int i, glTFMaterial src, Func<int, TextureItem> getTexture)
|
||||
public override Material CreateMaterial(int i, glTFMaterial src)
|
||||
{
|
||||
var item = m_materials[i];
|
||||
var shaderName = item.shader;
|
||||
@@ -60,12 +60,12 @@ namespace VRM
|
||||
if (VRM_SHADER_NAMES.Contains(shaderName))
|
||||
{
|
||||
Debug.LogErrorFormat("shader {0} not found. set Assets/VRM/Shaders/VRMShaders to Edit - project setting - Graphics - preloaded shaders", shaderName);
|
||||
return base.CreateMaterial(i, src, getTexture);
|
||||
return base.CreateMaterial(i, src);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarningFormat("unknown shader {0}.", shaderName);
|
||||
return base.CreateMaterial(i, src, getTexture);
|
||||
return base.CreateMaterial(i, src);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ namespace VRM
|
||||
}
|
||||
foreach (var kv in item.textureProperties)
|
||||
{
|
||||
var texture = getTexture(kv.Value);
|
||||
var texture = Context.GetTexture(kv.Value);
|
||||
if (texture != null) {
|
||||
material.SetTexture(kv.Key, texture.Texture);
|
||||
}
|
||||
|
||||
2
UniGLTF
2
UniGLTF
Submodule UniGLTF updated: 3bc3985f4d...1b41b0ab30
Reference in New Issue
Block a user