mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-05-14 06:19:47 -05:00
Merge pull request #2309 from Santarh/basisuDefaltBehaviour
load KHR_texture_basisu as default (but not implemented now)
This commit is contained in:
commit
737f8ad7fc
|
|
@ -5,7 +5,7 @@
|
|||
/// <summary>
|
||||
/// KHR_texture_basisu 拡張を考慮するかどうか。
|
||||
/// </summary>
|
||||
public bool ConsiderKhrTextureBasisu { get; set; }
|
||||
public bool ConsiderKhrTextureBasisu { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// ファイルに含まれる "全ての" テクスチャの画像が Y 軸反転しているかどうか。
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ namespace UniGLTF
|
|||
ITextureDeserializer textureDeserializer = null,
|
||||
IMaterialDescriptorGenerator materialGenerator = null)
|
||||
{
|
||||
TryValidateGltfData(data);
|
||||
Data = data;
|
||||
TextureDescriptorGenerator = new GltfTextureDescriptorGenerator(Data);
|
||||
MaterialDescriptorGenerator = materialGenerator ?? MaterialDescriptorGeneratorUtility.GetValidGltfMaterialDescriptorGenerator();
|
||||
|
|
@ -75,21 +74,6 @@ namespace UniGLTF
|
|||
"KHR_draco_mesh_compression",
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// GltfData をバリデートし、読み込み不可能な問題があれば例外を投げる
|
||||
/// </summary>
|
||||
private static void TryValidateGltfData(GltfData data)
|
||||
{
|
||||
if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu && !Application.isPlaying)
|
||||
{
|
||||
throw new UniGLTFNotSupportedException("KHR_texture_basisu is only available in play mode.");
|
||||
}
|
||||
if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu && !data.ExtensionSupportFlags.IsAllTexturesYFlipped)
|
||||
{
|
||||
throw new UniGLTFNotSupportedException("KHR_texture_basisu is only supported with all textures Y-flipped.");
|
||||
}
|
||||
}
|
||||
|
||||
#region Load. Build unity objects
|
||||
public virtual async Task<RuntimeGltfInstance> LoadAsync(IAwaitCaller awaitCaller, Func<string, IDisposable> MeasureTime = null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -238,13 +238,16 @@ namespace UniGLTF
|
|||
{
|
||||
var texture = data.GLTF.textures[textureIndex];
|
||||
|
||||
if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu &&
|
||||
glTF_KHR_texture_basisu.TryGet(texture, out var basisuExtension))
|
||||
if (glTF_KHR_texture_basisu.TryGet(texture, out var basisuExtension))
|
||||
{
|
||||
var basisuImageIndex = basisuExtension.source;
|
||||
if (basisuImageIndex >= 0 && basisuImageIndex < data.GLTF.images.Count)
|
||||
// NOTE: 実際に basisu 拡張が存在するとき、ロード設定を確認する。
|
||||
if (TryValidateBasisuLoadingSettings(data))
|
||||
{
|
||||
return basisuImageIndex;
|
||||
var basisuImageIndex = basisuExtension.source;
|
||||
if (basisuImageIndex >= 0 && basisuImageIndex < data.GLTF.images.Count)
|
||||
{
|
||||
return basisuImageIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -257,6 +260,22 @@ namespace UniGLTF
|
|||
|
||||
return default;
|
||||
}
|
||||
|
||||
private static bool TryValidateBasisuLoadingSettings(GltfData data)
|
||||
{
|
||||
if (!data.ExtensionSupportFlags.ConsiderKhrTextureBasisu) return false;
|
||||
|
||||
if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu && !Application.isPlaying)
|
||||
{
|
||||
throw new UniGLTFNotSupportedException("KHR_texture_basisu is only available in play mode.");
|
||||
}
|
||||
if (data.ExtensionSupportFlags.ConsiderKhrTextureBasisu && !data.ExtensionSupportFlags.IsAllTexturesYFlipped)
|
||||
{
|
||||
throw new UniGLTFNotSupportedException("KHR_texture_basisu is only supported with all textures Y-flipped.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static byte[] ToArray(NativeArray<byte> bytes)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user