Files
2025-10-12 14:33:16 +03:00

50 lines
1.4 KiB
C#
Executable File

using System;
using System.Text.Json;
namespace ReFuel.Gltf
{
public class GltfScene : GltfIdObject
{
public override GltfObjectKind Kind => GltfObjectKind.Scene;
public string? Name { get; set; }
public GltfRefList<GltfNode> Nodes { get; }
internal GltfScene(GltfDocument document) : base(document)
{
Nodes = new GltfRefList<GltfNode>(document.Nodes);
}
internal override void Deserialize(JsonElement element)
{
if (element.ValueKind != JsonValueKind.Object)
throw new Exception("Expected an object as an asset.");
JsonElement value;
if (element.TryGetProperty("name", out value))
Name = value.GetString();
if (element.TryGetProperty("nodes", out value))
{
if (value.ValueKind != JsonValueKind.Array)
throw new Exception("Expected nodes to be an integer array.");
foreach (JsonElement node in value.EnumerateArray())
{
if (!node.TryGetInt32(out int id))
throw new Exception("Expected a node ID in nodes array.");
Nodes.Add(id);
}
}
DeserializeCommon(element);
}
internal override void Serialize(Utf8JsonWriter writer)
{
throw new NotImplementedException();
}
}
}