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

+13 -5
View File
@@ -1,5 +1,5 @@
# Shared helpers for the model fixture generators (obj.py, gltf.py): reference tools through nix.
# assimp_info(ctx, paths) -> [ { meshes, materials, vertices, faces, nodes, min, max, perMesh = [ { vertices, faces } ] } ]
# assimp_info(ctx, paths, raw?) -> [ { meshes, materials, vertices, faces, nodes, min, max, perMesh = [ { vertices, faces } ] } ]
# trimesh_metrics(ctx, paths) -> [ { area, faces, bounds, volume? } ] (trimesh, process=False, every geometry merged)
# luau_encode(ctx, script) -> { name: bytes }: runs a Luau script (repo-relative, .luaurc aliases) that prints
# "<name>\t<hex>" lines: how a generator gets our encoder's output for the reference tools to read back.
@@ -8,10 +8,15 @@ import json, os, re, subprocess, tempfile, shutil
FLOAT = r"(-?[\d.]+(?:e[-+]?\d+)?|-?nan|-?inf)"
def assimp_info(ctx, paths):
def assimp_info(ctx, paths, raw=False):
# raw: `assimp info -r` (no post-processing: no joined vertices, no merged identical meshes)
out = []
for p in paths:
txt = ctx.nix("assimp", ["assimp", "info", p]).decode("utf-8", "replace")
try:
txt = ctx.nix("assimp", ["assimp", "info", p] + (["-r"] if raw else [])).decode("utf-8", "replace")
except subprocess.CalledProcessError:
out.append({"failed": True})
continue
def num(label):
m = re.search(r"^" + label + r":\s+(\d+)", txt, re.M)
@@ -33,8 +38,11 @@ TRIMESH = r"""
import json, sys, trimesh, numpy as np
res = []
for p in json.loads(sys.stdin.read()):
m = trimesh.load(p, force="mesh", process=False)
d = {"area": float(m.area), "faces": int(len(m.faces)), "bounds": [float(v) for v in np.asarray(m.bounds).ravel()] if len(m.faces) else []}
try:
m = trimesh.load(p, force="mesh", process=False)
d = {"area": float(m.area), "faces": int(len(m.faces)), "bounds": [float(v) for v in np.asarray(m.bounds).ravel()] if len(m.faces) else []}
except Exception as e:
d = {"failed": True}
res.append(d)
print(json.dumps(res))
"""