33 lines
810 B
Python
Executable File
33 lines
810 B
Python
Executable File
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)
|