refactor(P1): M1 dead code removal + M3 blender_render.py split

M1 — dead code removed:
- Delete blender-renderer/ and threejs-renderer/ source files
- Remove PIL/Pillow fallback block from step_processor.py
  (_generate_thumbnail_placeholder, _finalise_image JPG path)
- Remove stl_quality param from render_blender.py, render_still_task,
  render_turntable_task (was always "low"; hardcode deflection values)
- render_turntable_task now reads scene_linear/angular_deflection from
  system_settings (consistent with export_glb.py pipeline)

M3 — blender_render.py split from 263 → 68 lines:
- _blender_args.py: parse_args() — all 25 positional + named args
- _blender_scene_setup.py: setup_scene() — MODE A/B including USD import
- _blender_render_config.py: configure_and_render() — engine + output

Post-review fixes:
- _db_engine.dispose() after settings read in render_turntable_task
- _finalise_image() fmt param removed (always PNG; PIL never installed)
- _blender_import.py committed together with new submodules to satisfy
  import_usd_file dependency

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-12 12:54:40 +01:00
parent 393e4b92a7
commit 47b5d42bb5
10 changed files with 471 additions and 496 deletions
+12 -7
View File
@@ -57,7 +57,6 @@ def render_still_task(
output_path: str,
engine: str = "cycles",
samples: int = 256,
stl_quality: str = "low",
smooth_angle: int = 30,
cycles_device: str = "auto",
width: int = 512,
@@ -94,7 +93,6 @@ def render_still_task(
output_path=Path(output_path),
engine=engine,
samples=samples,
stl_quality=stl_quality,
smooth_angle=smooth_angle,
cycles_device=cycles_device,
width=width,
@@ -162,7 +160,6 @@ def render_turntable_task(
output_name: str = "turntable",
engine: str = "cycles",
samples: int = 64,
stl_quality: str = "low",
smooth_angle: int = 30,
cycles_device: str = "auto",
width: int = 1920,
@@ -207,10 +204,18 @@ def render_turntable_task(
scripts_dir = Path(os.environ.get("RENDER_SCRIPTS_DIR", "/render-scripts"))
turntable_script = scripts_dir / "turntable_render.py"
# GLB generation via OCC (replaces STL intermediary)
linear_deflection = 0.3 if stl_quality == "low" else 0.05
angular_deflection = 0.3 if stl_quality == "low" else 0.1
glb_path = step.parent / f"{step.stem}_{stl_quality}.glb"
# GLB generation via OCC — deflection from admin settings (scene_linear/angular_deflection)
from app.config import settings as app_settings
from sqlalchemy import create_engine as _create_engine, text as _text
from sqlalchemy.orm import Session as _Session
_db_engine = _create_engine(app_settings.database_url_sync)
with _Session(_db_engine) as _s:
_rows = _s.execute(_text("SELECT key, value FROM system_settings")).fetchall()
_sett = {r[0]: r[1] for r in _rows}
_db_engine.dispose()
linear_deflection = float(_sett.get("scene_linear_deflection", "0.1"))
angular_deflection = float(_sett.get("scene_angular_deflection", "0.1"))
glb_path = step.parent / f"{step.stem}_thumbnail.glb"
if not glb_path.exists() or glb_path.stat().st_size == 0:
occ_script = scripts_dir / "export_step_to_gltf.py"
occ_cmd = [