fix: media thumbnails, product dimensions, inline 3D viewer, GLB export
Bug A: Media Library thumbnails were gray because <img src> cannot send JWT auth headers. Added useAuthBlob() hook (fetch + createObjectURL) in MediaBrowser.tsx. Also fixed publish_asset Celery task to populate product_id + cad_file_id on MediaAsset for thumbnail fallback resolution. Bug B: Product dimensions now shown in Product Details card with Ruler icon and "from CAD" label when cad_mesh_attributes.dimensions_mm exists. Bug C: Replaced 128×128 CAD thumbnail with InlineCadViewer component. Queries gltf_geometry MediaAssets, fetches GLB via auth fetch → blob URL → Three.js Canvas with OrbitControls. Falls back to thumbnail + "Load 3D Model" button. Polling when GLB generation is in progress. Bug D: trimesh was in [cad] optional extra but Dockerfile only installed [dev]. Changed to pip install -e ".[dev,cad]" — trimesh now available in backend container, GLB + Colors export works. Also added bbox extraction (STL-first numpy parsing) in render_step_thumbnail and admin "Re-extract CAD Metadata" bulk endpoint. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -87,6 +87,30 @@ def dispatch_render_with_workflow(order_line_id: str) -> dict:
|
||||
workflow_type,
|
||||
)
|
||||
|
||||
# For turntable workflows: resolve step_path + output_dir from the order line at runtime
|
||||
if workflow_type == "turntable" and ("step_path" not in params or "output_dir" not in params):
|
||||
from app.domains.products.models import CadFile as _CadFile
|
||||
from pathlib import Path as _Path
|
||||
from app.config import settings as _cfg
|
||||
_product = line.product if hasattr(line, "product") else None
|
||||
if _product is None:
|
||||
from sqlalchemy.orm import selectinload as _si
|
||||
from app.domains.orders.models import OrderLine as _OL
|
||||
_line_full = session.execute(
|
||||
select(_OL).where(_OL.id == line.id).options(_si(_OL.product))
|
||||
).scalar_one_or_none()
|
||||
_product = _line_full.product if _line_full else None
|
||||
if _product and _product.cad_file_id:
|
||||
_cad = session.execute(
|
||||
select(_CadFile).where(_CadFile.id == _product.cad_file_id)
|
||||
).scalar_one_or_none()
|
||||
if _cad and _cad.stored_path:
|
||||
params.setdefault("step_path", _cad.stored_path)
|
||||
params.setdefault(
|
||||
"output_dir",
|
||||
str(_Path(_cfg.upload_dir) / "renders" / str(line.id)),
|
||||
)
|
||||
|
||||
from app.domains.rendering.workflow_builder import dispatch_workflow
|
||||
celery_task_id = dispatch_workflow(workflow_type, order_line_id, params)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user