Rebuild local Blender WASM environment and recovery evidence
This commit is contained in:
64
tools/web/check-wbv2-p2-004-desktop.py
Normal file
64
tools/web/check-wbv2-p2-004-desktop.py
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python3
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pathlib
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import bpy
|
||||
|
||||
|
||||
def report_scene():
|
||||
scene = bpy.context.scene
|
||||
cube = bpy.data.objects.get("WBV2P2004ViewportCube")
|
||||
camera = bpy.data.objects.get("WBV2P2004ViewportCamera")
|
||||
if cube is None or cube.type != "MESH" or camera is None or camera.type != "CAMERA":
|
||||
raise RuntimeError("VIEWPORT_INVALID: viewport fixture is missing cube or camera")
|
||||
return {
|
||||
"sceneId": "scene:" + scene.name,
|
||||
"cubeId": "object:" + cube.name,
|
||||
"meshId": "mesh:" + cube.data.name,
|
||||
"cameraId": "object:" + camera.name,
|
||||
"cameraDataId": "camera:" + camera.data.name,
|
||||
"cubeLocation": [round(float(value), 6) for value in cube.location],
|
||||
"cameraLocation": [round(float(value), 6) for value in camera.location],
|
||||
"cameraLensMm": round(float(camera.data.lens), 6),
|
||||
"vertexCount": len(cube.data.vertices),
|
||||
"faceCount": len(cube.data.polygons),
|
||||
}
|
||||
|
||||
|
||||
def main():
|
||||
arguments = sys.argv[sys.argv.index("--") + 1 :]
|
||||
if len(arguments) != 2:
|
||||
raise SystemExit("usage: blender -b --python check-wbv2-p2-004-desktop.py -- FIXTURE REPORT")
|
||||
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
|
||||
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=True)
|
||||
before = report_scene()
|
||||
descriptor, temporary = tempfile.mkstemp(prefix="wbv2-p2-004-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=True)
|
||||
after = report_scene()
|
||||
finally:
|
||||
pathlib.Path(temporary).unlink(missing_ok=True)
|
||||
if before != after:
|
||||
raise RuntimeError(f"VIEWPORT_INVALID: desktop save/reopen drift: {before} != {after}")
|
||||
value = {
|
||||
"schemaVersion": 1,
|
||||
"task": "WBV2-P2-004",
|
||||
"operation": "VIEWPORT_MAIN_OFFSCREEN_DESKTOP",
|
||||
"fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(),
|
||||
"scene": after,
|
||||
"saveReopen": "EXACT",
|
||||
"blenderVersion": bpy.app.version_string,
|
||||
}
|
||||
output.parent.mkdir(parents=True, exist_ok=True)
|
||||
output.write_text(json.dumps(value, indent=2, sort_keys=True) + "\n", encoding="utf-8")
|
||||
print("wbv2-p2-004-desktop-ok cube=%s camera=%s pixels=browser saveReopen=exact" % (after["cubeId"], after["cameraId"]))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user