refactor: replace STL intermediary with OCC-native STEP→GLB pipeline

- export_step_to_gltf.py: STEP→GLB via RWGltf_CafWriter + BRepBuilderAPI_Transform
  (mm→m pre-scaling, XCAFDoc_ShapeTool.GetComponents_s static method)
- Blender scripts (blender_render.py, still_render.py, turntable_render.py,
  export_gltf.py, export_blend.py): import GLB instead of STL, remove _scale_mm_to_m
- step_tasks.py: add generate_gltf_production_task, remove generate_stl_cache,
  replace _bbox_from_stl with _bbox_from_glb (trimesh), auto-queue geometry GLB
  after thumbnail render
- render_blender.py: replace _stl_from_cache_or_convert with _glb_from_step,
  remove convert_step_to_stl and export_per_part_stls
- domains/rendering/tasks.py: update render_turntable_task, export_gltf/blend tasks
  to use GLB instead of STL
- cad.py: remove STL download/generate endpoints, add generate-gltf-production
- admin.py: generate-missing-stls → generate-missing-geometry-glbs
- Frontend: replace STL cache UI with GLB generate buttons, remove stl_cached field

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-07 16:49:18 +01:00
parent 3eba7b2d37
commit 95cfe0aa93
20 changed files with 809 additions and 1301 deletions
+6 -39
View File
@@ -67,30 +67,6 @@ export async function getCadObjects(cadFileId: string): Promise<CadObjects> {
return res.data
}
/**
* Download the cached STL for a CAD file as a file-save dialog.
* quality: 'low' | 'high'
* The backend returns a human-readable filename, but we derive it client-side too.
*/
export async function downloadStl(cadFileId: string, quality: 'low' | 'high', suggestedName?: string): Promise<void> {
const res = await api.get<Blob>(`/cad/${cadFileId}/stl/${quality}`, {
responseType: 'blob',
})
const url = URL.createObjectURL(res.data)
const a = document.createElement('a')
a.href = url
a.download = suggestedName ? `${suggestedName}_${quality}.stl` : `model_${quality}.stl`
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
URL.revokeObjectURL(url)
}
export async function generateStl(cadFileId: string, quality: 'low' | 'high'): Promise<{ task_id: string }> {
const res = await api.post<{ task_id: string }>(`/cad/${cadFileId}/generate-stl/${quality}`)
return res.data
}
/**
* Ask the backend to re-queue STEP processing for a CAD file (admin only).
* Returns the Celery task_id (or null if the worker is not available).
@@ -110,23 +86,14 @@ export interface GenerateGltfResponse {
cad_file_id: string
}
/**
* Queue GLB geometry export from existing STL cache (trimesh, no Blender).
* The STL low-quality cache must already exist.
*/
/** Queue geometry GLB export directly from STEP via OCC (no Blender, no STL). */
export async function generateGltfGeometry(cadFileId: string): Promise<GenerateGltfResponse> {
const res = await api.post<GenerateGltfResponse>(`/cad/${cadFileId}/generate-gltf-geometry`)
return res.data
}
export const exportGltfColored = (id: string): Promise<void> =>
api.get(`/cad/${id}/export-gltf-colored`, { responseType: 'blob' }).then(r => {
const url = URL.createObjectURL(r.data)
const a = document.createElement('a')
a.href = url
a.download = `${id}_colored.glb`
document.body.appendChild(a)
a.click()
document.body.removeChild(a)
URL.revokeObjectURL(url)
})
/** Queue production GLB export (Blender + PBR materials) from geometry GLB. */
export async function generateGltfProduction(cadFileId: string): Promise<GenerateGltfResponse> {
const res = await api.post<GenerateGltfResponse>(`/cad/${cadFileId}/generate-gltf-production`)
return res.data
}
-1
View File
@@ -55,7 +55,6 @@ export interface Product {
thumbnail_url: string | null
render_image_url: string | null
processing_status: string | null
stl_cached: string[]
cad_parsed_objects: string[] | null
cad_mesh_attributes?: {
dimensions_mm?: { x: number; y: number; z: number }