Files
rosetta/tools/fixtures/_robloxmesh_encode.luau
T

31 lines
1.0 KiB
Luau

-- tools/fixtures/_robloxmesh_encode.luau: run by tools/fixtures/robloxmesh.py under the luau CLI: decodes every case of
-- tests/gen/robloxmesh and writes it back as versions 2.00 and 4.00; prints "<case>/<version> <hex>" lines for the
-- fixture's own reader.
local RobloxMesh = require("@formats/model/robloxmesh")
local Bytes = require("@formats/core/Bytes")
local Fx = require("@tests/gen/robloxmesh")
local function hex(b: buffer): string
local t = table.create(buffer.len(b))
for i = 0, buffer.len(b) - 1 do
t[i + 1] = string.format("%02x", buffer.readu8(b, i))
end
return table.concat(t)
end
for _, c in Fx.cases do
if not c.unsupported then
local scene, err = RobloxMesh.decode(Bytes.reader(buffer.fromstring(c.data)))
if not scene then
error(c.name .. ": " .. tostring(err))
end
for _, v in { "2.00", "4.00" } do
local out, e = RobloxMesh.encode(scene, { version = v } :: any)
if not out then
error(c.name .. "/" .. v .. ": " .. tostring(e))
end
print(c.name .. "/" .. v .. " " .. hex(out))
end
end
end