29 lines
915 B
Luau
29 lines
915 B
Luau
-- tools/fixtures/_3mf_encode: run by tools/fixtures/3mf.py (luau CLI, repo root): decodes every 3MF case that lib3mf
|
|
-- reads with our reader and encodes it with our writer, printing "rt_<case>.3mf\t<hex>" lines for the reference tools
|
|
-- (lib3mf, assimp, trimesh) to read back.
|
|
local ThreeMf = require("@formats/model/3mf")
|
|
local Bytes = require("@formats/core/Bytes")
|
|
local Cases = require("@tests/gen/3mf_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.lib3mf.failed then
|
|
local scene = ThreeMf.decode(Bytes.reader(buffer.fromstring(c.data)))
|
|
if scene then
|
|
local out = assert(ThreeMf.encode(scene))
|
|
print(string.format("rt_%d.3mf\t%s", i, hex(buffer.tostring(out))))
|
|
end
|
|
end
|
|
end
|