-- tools/fixtures/_vrml_encode: run by tools/fixtures/vrml.py and x3d.py (luau CLI, repo root): decodes every VRML / -- X3D case and glTF sample with our readers and writes it back with our writers, printing "\t" lines for -- VTK (.wrl) and assimp (.x3d) to read back. Files: case_.wrl, gltf_.wrl, xcase_.x3d, xgltf_.x3d. local Vrml = require("@formats/model/vrml") local X3d = require("@formats/model/x3d") local Gltf = require("@formats/model/gltf") local Bytes = require("@formats/core/Bytes") local Cases = require("@tests/gen/vrml_cases") local GltfCases = require("@tests/gen/vrml_gltf") local ok, X3dCases = pcall(require, "@tests/gen/x3d_cases") 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 both(scene: any, wrl: string, x3d: string) local a = Vrml.encode(scene) if a then print(wrl .. "\t" .. hex(a)) end local b = X3d.encode(scene) if b then print(x3d .. "\t" .. hex(b)) end end for i, c in Cases do local scene = Vrml.decode(Bytes.reader(buffer.fromstring(c.data)), { files = c.files, triangulate = false }) if scene then both(scene, string.format("case_%d.wrl", i), string.format("wcase_%d.x3d", i)) end end for i, c in GltfCases do local scene = Gltf.decode(Bytes.reader(buffer.fromstring(c.data)), { files = c.files }) if scene then both(scene, string.format("gltf_%d.wrl", i), string.format("xgltf_%d.x3d", i)) end end if ok and type(X3dCases) == "table" then for i, c in X3dCases do local scene = X3d.decode(Bytes.reader(buffer.fromstring(c.data)), { files = c.files, triangulate = false }) if scene then both(scene, string.format("xcase_%d.wrl", i), string.format("xcase_%d.x3d", i)) end end end