mirror of
https://github.com/vrm-c/UniVRM.git
synced 2026-09-07 19:38:13 -05:00
KHR_texture_basisu 拡張クラスの定義
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using UniJSON;
|
||||
|
||||
namespace UniGLTF
|
||||
{
|
||||
/// <summary>
|
||||
/// https://github.com/KhronosGroup/glTF/tree/main/extensions/2.0/Khronos/KHR_texture_basisu
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public sealed class glTF_KHR_texture_basisu
|
||||
{
|
||||
public const string ExtensionName = "KHR_texture_basisu";
|
||||
|
||||
private static readonly Utf8String ExtensionNameUt8 = Utf8String.From(ExtensionName);
|
||||
|
||||
/// <summary>
|
||||
/// glTF Id
|
||||
/// </summary>
|
||||
[JsonSchema(Minimum = 0)]
|
||||
public int source = -1;
|
||||
|
||||
public static bool TryGet(glTFTextureInfo textureInfo, out glTF_KHR_texture_basisu basisuExtension)
|
||||
{
|
||||
if (textureInfo?.extensions is glTFExtensionImport importedExtensions)
|
||||
{
|
||||
foreach (var kv in importedExtensions.ObjectItems())
|
||||
{
|
||||
if (kv.Key.GetUtf8String() == ExtensionNameUt8)
|
||||
{
|
||||
basisuExtension = Deserialize(kv.Value);
|
||||
return basisuExtension != null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
basisuExtension = default;
|
||||
return false;
|
||||
}
|
||||
|
||||
private static glTF_KHR_texture_basisu Deserialize(JsonNode json)
|
||||
{
|
||||
if (json.Value.ValueType != ValueNodeType.Object) return null;
|
||||
|
||||
foreach (var kv in json.ObjectItems())
|
||||
{
|
||||
var key = kv.Key.GetString();
|
||||
switch (key)
|
||||
{
|
||||
case nameof(source):
|
||||
var value = kv.Value.GetInt32();
|
||||
return new glTF_KHR_texture_basisu
|
||||
{
|
||||
source = value,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ed158370be0b4340b9d571c199878591
|
||||
timeCreated: 1638944458
|
||||
Reference in New Issue
Block a user