ws-3d2: merge ws/3d2-dae (model/dae); registry regenerated

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
4DBugandClaude Opus 5.5 committed 2026-10-31 09:47:00 -05:00
commit b2c7ee8e6d
9 files changed
+3385

No files matched your search

+36
View File
@@ -0,0 +1,36 @@
-- tools/fixtures/_dae_encode: run by tools/fixtures/dae.py (luau CLI, repo root): decodes every Collada case with our
-- reader and encodes it with our writer (rt_<case>.dae + its image files, and rt_<case>.zae for the first cases),
-- printing "<file>\t<hex>" lines for assimp to read back.
local Dae = require("@formats/model/dae")
local Bytes = require("@formats/core/Bytes")
local Cases = require("@tests/gen/dae_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 = Dae.decode(Bytes.reader(buffer.fromstring(c.data)), { files = c.files })
if scene then
local files = {}
local dae = assert(Dae.encode(scene, { files = files, name = "rt_" .. i .. ".dae" }))
print(string.format("rt_%d.dae\t%s", i, hex(buffer.tostring(dae))))
for name, data in files do
print(name .. "\t" .. hex(if type(data) == "string" then data else buffer.tostring(data)))
end
if i <= 3 then
local zae = assert(Dae.encode(scene, { format = "zae" }))
print(string.format("rt_%d.zae\t%s", i, hex(buffer.tostring(zae))))
end
else
print("skipped " .. c.name .. ": " .. tostring(err))
end
end
+106
View File
@@ -0,0 +1,106 @@
# Collada fixtures (tools/fixtures.py): assimp's Collada test models (read from the nixpkgs assimp source at fixture
# time, never committed: test/models/Collada, licences in that folder's licence.md), glTF sample models converted to
# .dae by assimp's Collada exporter (skins, animations, cameras, textures), with reference values from `assimp info -r`
# (meshes, faces, vertices, bounds, materials, animations, cameras, lights, bones). Blender 5 has no Collada support.
# tests/gen/dae_cases.luau { name, main, data, files = { name -> bytes }, assimp, gltf? + gltfFiles? (the original
# of an assimp export: the test compares skins and animations with it) }
# tests/gen/dae_xcheck.luau our encoder's .dae of every case (tools/fixtures/_dae_encode.luau) read back by assimp:
# { name, case, assimp }
import importlib.util, os, re, subprocess
INPUTS = ["src/Formats/model/dae", "src/Formats/codecs/Xml", "tools/fixtures/_model_ref.py", "tools/fixtures/_dae_encode.luau",
"tests/fixtures/gltf"]
def ref_module(ctx):
spec = importlib.util.spec_from_file_location("_model_ref", os.path.join(ctx.root, "tools", "fixtures", "_model_ref.py"))
m = importlib.util.module_from_spec(spec)
spec.loader.exec_module(m)
return m
def assimp_src():
out = subprocess.run(["nix", "build", "nixpkgs#assimp.src", "--no-link", "--print-out-paths"], capture_output=True, check=True)
return out.stdout.decode().strip().split("\n")[-1]
def info(ctx, M, path):
a = M.assimp_info(ctx, [path], raw=True)[0]
try:
txt = ctx.nix("assimp", ["assimp", "info", path, "-r"]).decode("utf-8", "replace")
except subprocess.CalledProcessError:
return {"failed": True}
for label in ("Animations", "Cameras", "Lights", "Bones", "Materials"):
m = re.search(r"^" + label + r":\s+(\d+)", txt, re.M)
if m:
a[label.lower()] = int(m.group(1))
# assimp's root node transform (its Collada importer bakes up axis / unit conversion into it): not reported by
# `assimp info`; the test applies the conversion itself
return a
IMAGE_EXT = (".jpg", ".jpeg", ".png", ".tga", ".bmp")
def generate(ctx):
M = ref_module(ctx)
src = os.path.join(assimp_src(), "test", "models", "Collada")
cases = []
images = {f: os.path.join(src, f) for f in sorted(os.listdir(src)) if f.lower().endswith(IMAGE_EXT)}
for f in sorted(os.listdir(src)):
if not (f.lower().endswith(".dae") or f.lower().endswith(".zae")) or "_triangulate" in f:
continue # the *_triangulate files are the same models again (fixture size)
path = os.path.join(src, f)
data = open(path, "rb").read()
files = {}
text = data.decode("latin-1")
for im, ip in images.items():
if im in text:
files[im] = open(ip, "rb").read()
cases.append({"name": "assimp/" + f, "main": f, "path": path, "files": files})
# glTF samples -> assimp's Collada exporter
tmp = M.tempdir()
groot = os.path.join(ctx.root, "tests", "fixtures", "gltf")
for model, variant, main in (("SimpleSkin", "glTF", "SimpleSkin.gltf"), ("RiggedSimple", "glTF-Binary", "RiggedSimple.glb"),
("BoxTextured", "glTF", "BoxTextured.gltf"), ("AnimatedTriangle", "glTF", "AnimatedTriangle.gltf"),
("Cameras", "glTF", "Cameras.gltf"), ("BoxVertexColors", "glTF-Binary", "BoxVertexColors.glb"),
("SimpleMeshes", "glTF", "SimpleMeshes.gltf"), ("InterpolationTest", "glTF-Binary", "InterpolationTest.glb"),
("MultiUVTest", "glTF-Binary", "MultiUVTest.glb")):
d = os.path.join(groot, model, variant)
if not os.path.exists(os.path.join(d, main)):
continue
out = os.path.join(tmp, model + ".dae")
try:
ctx.nix("assimp", ["assimp", "export", os.path.join(d, main), out, "-fcollada"])
except subprocess.CalledProcessError:
continue
files = {}
text = open(out, "rb").read().decode("latin-1")
for f in os.listdir(tmp):
if f.lower().endswith(IMAGE_EXT) and f in text:
files[f] = open(os.path.join(tmp, f), "rb").read()
for f in os.listdir(d):
if f.lower().endswith(IMAGE_EXT) and f in text:
files[f] = open(os.path.join(d, f), "rb").read()
orig = {f: open(os.path.join(d, f), "rb").read() for f in sorted(os.listdir(d)) if f != main}
cases.append({"name": "assimp-export/" + model, "main": model + ".dae", "path": out, "files": files,
"gltf": open(os.path.join(d, main), "rb").read(), "gltfFiles": orig})
for c in cases:
c["assimp"] = info(ctx, M, c["path"])
c["data"] = open(c["path"], "rb").read()
del c["path"]
ctx.emit("dae_cases", cases)
# assimp reads our output
ours = M.luau_encode(ctx, "tools/fixtures/_dae_encode.luau")
xtmp = M.tempdir()
names = []
for name, data in sorted(ours.items()):
with open(os.path.join(xtmp, name), "wb") as f:
f.write(data)
if name.endswith(".dae") or name.endswith(".zae"):
names.append(name)
out = []
for n in names:
out.append({"name": n, "case": int(n.split("_")[1].split(".")[0]), "assimp": info(ctx, M, os.path.join(xtmp, n))})
ctx.emit("dae_xcheck", out)