mirror of
https://github.com/ahwootech/BRUTAL.git
synced 2026-11-26 13:08:24 +01:00
21 lines
563 B
C#
21 lines
563 B
C#
using System.Text.Json;
|
|
|
|
namespace Brutal.GltfApi;
|
|
|
|
public interface IExtensionGltfObject
|
|
{
|
|
public Dictionary<string, object>? Extensions { get; }
|
|
}
|
|
|
|
public static class GltfExtensions
|
|
{
|
|
public static T? GetExtension<T>(this IExtensionGltfObject obj, string extensionName)
|
|
where T : class
|
|
{
|
|
var extensionMap = obj.Extensions;
|
|
if (extensionMap == null || !extensionMap.TryGetValue(extensionName, out var extObj))
|
|
return null;
|
|
JsonElement je = (JsonElement)extObj;
|
|
return je.Deserialize<T>();
|
|
}
|
|
}
|