-- tools/fixtures/_usda_encode: run by tools/fixtures/usda.py (luau CLI, repo root): decodes every USDA case with our -- reader and writes it back with our writer, printing "\t" lines (case_.usda + the texture files it -- references) for OpenUSD (pxr) to read back. local Usda = require("@formats/model/usda") local Bytes = require("@formats/core/Bytes") local Cases = require("@tests/gen/usda_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 if not c.expect then local scene = Usda.decode(Bytes.reader(buffer.fromstring(c.data)), { files = c.files }) if scene then local files = {} local out = assert(Usda.encode(scene, { files = files, name = "case_" .. i .. ".usda" })) print(string.format("case_%d.usda\t%s", i, hex(buffer.tostring(out)))) for name, data in files do if not string.find(name, "%.%.") and string.sub(name, 1, 1) ~= "/" then print(name .. "\t" .. hex(if type(data) == "string" then data else buffer.tostring(data))) end end end end end