ws-3d: model/gltf (glTF 2.0 JSON + GLB read/write: accessors of every type incl. normalized/sparse/strided/padded matrices, PBR + KHR_materials_*, KHR_texture_transform, images kept encoded, samplers, cameras, KHR_lights_punctual, skins, animations, morph targets, KHR_mesh_quantization, extras/unknown extensions round trip); Khronos sample assets + gltfpack + assimp fixtures

This commit is contained in:
4DBug committed 2026-10-31 09:02:59 -05:00
1 parent 35891a06d1
commit 20ca5a054d
93 files changed
+5167 -5

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
-- 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
-- "<file>\t<hex>" lines for the reference tools (assimp, trimesh) to read back. Files: rt_<case>.glb, rt_<case>.gltf.
local Gltf = require("@formats/model/gltf")
local Bytes = require("@formats/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