Fix extension loading

This commit is contained in:
2026-10-23 19:21:18 +02:00
parent b93df6e769
commit 71a8912635
4 changed files with 11 additions and 14 deletions
+8 -2
View File
@@ -165,8 +165,14 @@ namespace ReFuel.Gltf
this.material.Id = index; this.material.Id = index;
} }
// TODO: materials. if (element.TryGetProperty("targets", out JsonElement targetsElement))
// TODO: morph targets. {
foreach (JsonProperty property in materialElement.EnumerateObject())
{
//TODO: targets
//this.Targets.Add(weights);
}
}
if (element.TryGetProperty("mode", out JsonElement modeElement)) if (element.TryGetProperty("mode", out JsonElement modeElement))
{ {
+2 -2
View File
@@ -29,7 +29,7 @@ namespace ReFuel.Gltf
{ {
public abstract GltfObjectKind Kind { get; } public abstract GltfObjectKind Kind { get; }
public GltfDocument Document { get; protected set; } public GltfDocument Document { get; protected set; }
public GltfCollection Extension { get; protected set; } = new GltfCollection(); public GltfCollection Extension { get; protected set; } = new GltfCollection(true);
public GltfCollection Extras { get; protected set; } = new GltfCollection(); public GltfCollection Extras { get; protected set; } = new GltfCollection();
protected GltfObject() protected GltfObject()
@@ -49,7 +49,7 @@ namespace ReFuel.Gltf
{ {
Extras.Parse(extras); Extras.Parse(extras);
} }
if (element.TryGetProperty("extension", out JsonElement extension)) if (element.TryGetProperty("extensions", out JsonElement extension))
{ {
Extension.Parse(extension); Extension.Parse(extension);
} }
@@ -5,12 +5,10 @@ using System.Text.Json.Serialization;
namespace ReFuel.Gltf namespace ReFuel.Gltf
{ {
public class GltfSerializedExtensionProvider<T> : IGltfExtensionProvider<T> public class GltfSerializedExtensionProvider<T> : IGltfExtensionProvider
{ {
public string Name { get; } public string Name { get; }
public Type? DataType { get; } = typeof(T);
public GltfSerializedExtensionProvider(string name) public GltfSerializedExtensionProvider(string name)
{ {
Name = name; Name = name;
-7
View File
@@ -6,15 +6,8 @@ namespace ReFuel.Gltf
public interface IGltfExtensionProvider public interface IGltfExtensionProvider
{ {
string Name { get; } string Name { get; }
Type? DataType { get; }
object ParseExtensionObject(JsonElement element); object ParseExtensionObject(JsonElement element);
void WriteExtensionObject(object obj, Utf8JsonWriter writer); void WriteExtensionObject(object obj, Utf8JsonWriter writer);
} }
public interface IGltfExtensionProvider<T> : IGltfExtensionProvider
{
T ParseExtension(JsonElement element);
void WriteExtension(T value, Utf8JsonWriter writer);
}
} }