-- tools/fixtures/_gltf_encode: run by tools/fixtures/gltf.py (luau CLI, repo root): decodes every glTF case with our -- reader and encodes it with our writer as .glb and as .gltf with an external .bin and image files, printing -- "\t" lines for the reference tools (assimp, trimesh) to read back. Files: rt_.glb, rt_.gltf. local Gltf = require("@rosetta/model/gltf") local Bytes = require("@rosetta/core/Bytes") local Cases = require("@tests/gen/gltf_cases") local HEX = {} for i = 0, 255 do HEX[i] = string.format("%02x", i) end local function hex(s: string): string local out = table.create(#s) for i = 1, #s do out[i] = HEX[string.byte(s, i)] end return table.concat(out) end for i, c in Cases do local scene, err = Gltf.decode(Bytes.reader(buffer.fromstring(c.data)), { files = c.files }) if scene then local glb = assert(Gltf.encode(scene, { binary = true })) print(string.format("rt_%d.glb\t%s", i, hex(buffer.tostring(glb)))) local files = {} local gltf = assert(Gltf.encode(scene, { external = true, files = files, name = "rt_" .. i .. ".gltf" })) print(string.format("rt_%d.gltf\t%s", i, hex(buffer.tostring(gltf)))) for name, data in files do print(name .. "\t" .. hex(if type(data) == "string" then data else buffer.tostring(data))) end else print("skipped " .. c.name .. ": " .. tostring(err)) end end