diff options
author | Lorenzo Torres <torres@sideros.org> | 2025-03-24 19:49:49 +0100 |
---|---|---|
committer | Lorenzo Torres <torres@sideros.org> | 2025-03-24 19:49:49 +0100 |
commit | 7cf43ccb8b8b1726c2697188b9138847780cd08e (patch) | |
tree | 0c667e54731b3cb1d54b277073e2b99b7c84c649 /src/rendering/gltf.zig | |
parent | 942bb3525dc162c1a9887f43f33a6e5615e70a2d (diff) |
glTF models now take buffer lengths at runtime
Diffstat (limited to 'src/rendering/gltf.zig')
-rw-r--r-- | src/rendering/gltf.zig | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/rendering/gltf.zig b/src/rendering/gltf.zig index 888191d..32a632a 100644 --- a/src/rendering/gltf.zig +++ b/src/rendering/gltf.zig @@ -157,10 +157,8 @@ pub fn parseFile(allocator: Allocator, name: []const u8) !struct { vertices: [][ const data = (try std.json.parseFromSlice(Model.JsonChunk, allocator, @constCast(all[Model.Chunk.offset .. Model.Chunk.offset + json_chunk.length]), .{ .ignore_unknown_fields = true })).value; const binary = Model.Binary{ .data = all[Model.Chunk.offset + json_chunk.length + 8 ..] }; - const vertices = try binary.readVec3(allocator, data.bufferViews.?[data.meshes.?[0].primitives.?[0].attributes.?.POSITION.?], 24); - const indices = try binary.readU16(allocator, data.bufferViews.?[data.meshes.?[0].primitives.?[0].indices.?], 36); - std.debug.print("vertices: {any}\n", .{vertices}); - std.debug.print("indices: {any}\n", .{indices}); + const vertices = try binary.readVec3(allocator, data.bufferViews.?[data.meshes.?[0].primitives.?[0].attributes.?.POSITION.?], data.accessors.?[data.meshes.?[0].primitives.?[0].attributes.?.POSITION.?].count); + const indices = try binary.readU16(allocator, data.bufferViews.?[data.meshes.?[0].primitives.?[0].indices.?], data.accessors.?[data.meshes.?[0].primitives.?[0].indices.?].count); return .{ .vertices = vertices, .indices = indices }; } |