1
This commit is contained in:
32
test_render_glb_preview.py
Normal file
32
test_render_glb_preview.py
Normal file
@@ -0,0 +1,32 @@
|
||||
import argparse
|
||||
import os
|
||||
import subprocess
|
||||
|
||||
|
||||
def render_glb_preview(glb_path, output_path):
|
||||
os.makedirs(os.path.dirname(output_path), exist_ok=True)
|
||||
|
||||
cmd = [
|
||||
"blender",
|
||||
"--background",
|
||||
"--python",
|
||||
"render_model.py",
|
||||
"--",
|
||||
glb_path,
|
||||
output_path
|
||||
]
|
||||
|
||||
result = subprocess.run(cmd, capture_output=True, text=True)
|
||||
print(result)
|
||||
if result.returncode != 0:
|
||||
raise RuntimeError(
|
||||
f"Blender render failed\nstdout:\n{result.stdout}\nstderr:\n{result.stderr}"
|
||||
)
|
||||
|
||||
return output_path
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
x = render_glb_preview(glb_path='glb_output/sample_20260316_113848_a956a189.glb',
|
||||
output_path='glb_output/static_model_image_20260316_113856_57ad56d2.png')
|
||||
print(x)
|
||||
Reference in New Issue
Block a user