Files
rosetta/tools/fixtures/_3ds_encode.luau
T
4DBug a43d81538e ws-3d3: model/3ds (Autodesk 3D Studio) read + write
Meshes (smoothing-group normals, uvs, mesh matrix, per-face materials), Phong
materials with texture maps (uri), cameras, lights, the keyframer (hierarchy,
pivots, instances, dummies, position / rotation / scale / camera tracks ->
one animation). Writer: objects, materials, cameras, lights, keyframer.
Tested against assimp (test models, its 3DS exporter, and reading our files).
2026-10-31 14:19:08 -05:00

45 lines
1.4 KiB
Luau

-- tools/fixtures/_3ds_encode: run by tools/fixtures/3ds.py (luau CLI, repo root): decodes every 3DS case and every
-- glTF sample model with our readers and writes them with our 3DS writer, printing "<file>\t<hex>" lines for assimp
-- to read back. Files: case_<i>.3ds, gltf_<i>.3ds.
local ThreeDs = require("@formats/model/3ds")
local Gltf = require("@formats/model/gltf")
local Bytes = require("@formats/core/Bytes")
local Cases = require("@tests/gen/3ds_cases")
local Picks = require("@tests/gen/3ds_gltf")
local HEX = {}
for i = 0, 255 do
HEX[i] = string.format("%02x", i)
end
local function hex(b: buffer): string
local out = table.create(buffer.len(b))
for i = 0, buffer.len(b) - 1 do
out[i + 1] = HEX[buffer.readu8(b, i)]
end
return table.concat(out)
end
local function emit(name: string, scene: any)
local out, err = ThreeDs.encode(scene)
if out then
print(name .. "\t" .. hex(out))
else
print("encode failed " .. name .. ": " .. tostring(err))
end
end
for i, c in Cases do
local scene, err = ThreeDs.decode(Bytes.reader(buffer.fromstring(c.data)))
if scene then
emit(string.format("case_%d.3ds", i), scene)
else
print("skipped " .. c.name .. ": " .. tostring(err))
end
end
for i, g in Picks do
local scene = Gltf.decode(Bytes.reader(buffer.fromstring(g.data)), { files = g.files })
if scene then
emit(string.format("gltf_%d.3ds", i), scene)
end
end