Rebuild local Blender WASM environment and recovery evidence
This commit is contained in:
67
tools/web/check-wbv2-p3-002-desktop.py
Normal file
67
tools/web/check-wbv2-p3-002-desktop.py
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def action_report():
|
||||
cube = bpy.data.objects.get("WBV2P3002AnimatedCube")
|
||||
if cube is None or cube.animation_data is None or cube.animation_data.action is None:
|
||||
raise RuntimeError("ANIMATION_INVALID: animated cube Action is missing")
|
||||
action = cube.animation_data.action
|
||||
channels = []
|
||||
for layer in action.layers:
|
||||
for strip in layer.strips:
|
||||
for bag in strip.channelbags:
|
||||
for curve in bag.fcurves:
|
||||
channels.append({
|
||||
"path": curve.data_path,
|
||||
"index": curve.array_index,
|
||||
"frames": [round(float(key.co.x), 6) for key in curve.keyframe_points],
|
||||
"values": [round(float(key.co.y), 6) for key in curve.keyframe_points],
|
||||
"interpolation": [key.interpolation for key in curve.keyframe_points],
|
||||
})
|
||||
channels.sort(key=lambda value: (value["path"], value["index"]))
|
||||
return {"id": "action:" + action.name + ":object:" + cube.name, "name": action.name, "targetId": "object:" + cube.name, "channels": channels}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-wbv2-p3-002-desktop.py -- FIXTURE REPORT")
|
||||
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
|
||||
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False)
|
||||
before = action_report()
|
||||
if len(before["channels"]) != 9 or any(channel["frames"] != [1.0, 10.0, 20.0] for channel in before["channels"]):
|
||||
raise RuntimeError(f"ANIMATION_INVALID: unexpected TRS channels: {before}")
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="wbv2-p3-002-reopen-", suffix=".blend", dir=fixture.parent)
|
||||
os.close(descriptor)
|
||||
try:
|
||||
bpy.ops.wm.save_as_mainfile(filepath=temporary, check_existing=False, compress=True)
|
||||
bpy.ops.wm.open_mainfile(filepath=temporary, load_ui=False)
|
||||
after = action_report()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after:
|
||||
raise RuntimeError(f"ANIMATION_INVALID: desktop save/reopen drift: {before} != {after}")
|
||||
report = {
|
||||
"schemaVersion": 1,
|
||||
"task": "WBV2-P3-002",
|
||||
"operation": "ANIMATION_TRS_ACTION_DESKTOP",
|
||||
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
||||
"action": after,
|
||||
"saveReopen": "EXACT",
|
||||
"blenderVersion": bpy.app.version_string,
|
||||
}
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
output.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
print("wbv2-p3-002-desktop-ok action=%s channels=%d frames=1,10,20 saveReopen=exact" % (after["id"], len(after["channels"])))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user