"""tools/goo: a box of goo on a table box, coarse, in seconds. The .rseq parses as the format says, it's empty before the box's start and has triangles after, and two runs write the same bytes. $RAEA_GOO/.venv/bin/python -I tools/goo/test_run.py """ import json import os import shutil import struct import subprocess import sys import tempfile from pathlib import Path HERE = Path(__file__).resolve().parent sys.path.insert(0, str(HERE)) import run # noqa: E402 def box_glb(path, lo, hi): """a closed box as a one-node glb named 'box', base colour orange""" import numpy as np x0, y0, z0 = lo x1, y1, z1 = hi p = np.array([[x0, y0, z0], [x1, y0, z0], [x1, y1, z0], [x0, y1, z0], [x0, y0, z1], [x1, y0, z1], [x1, y1, z1], [x0, y1, z1]], " 0, f"frame {k} has no triangles" assert idx.max() < len(pos) assert abs(float((nrm ** 2).sum(1).mean()) - 1) < 0.05 assert col[:, 0].mean() > col[:, 2].mean(), "the box's orange should carry" first, last = frames[start][0], frames[-1][0] assert last[:, 1].max() < first[:, 1].max() - 0.01, "the goo should slump" assert last[:, 1].min() > 0.74, "the goo should stay on the table" a, b = outs[0].read_bytes(), outs[1].read_bytes() assert a == b, "two runs wrote different bytes" st = json.loads(Path(str(outs[0]) + ".json").read_text()) assert st["objects"][0]["hideFrame"] == 12, st print(f"ok: {len(a)} bytes, top {first[:, 1].max():.3f} -> {last[:, 1].max():.3f}, {st['seconds']}s", file=sys.stderr) shutil.rmtree(d, True) if __name__ == "__main__": main()