feat(P2): USD Foundation — canonical part identity + material overrides
M1 — USD exporter:
- render-worker/scripts/export_step_to_usd.py (631 lines)
Full XCAF traversal, one UsdGeom.Mesh per leaf part,
schaeffler:partKey on every prim, index-space sharpEdgeVertexPairs
- render-worker/Dockerfile: usd-core>=24.11 installed (USD 0.26.3)
M2 — usd_master MediaAsset + pipeline auto-chain:
- migrations 060 (usd_master enum), 061 (3 JSONB columns),
062 (rename tessellation settings keys)
- generate_usd_master_task: runs export_step_to_usd.py, upserts
usd_master MediaAsset, writes resolved_material_assignments to CadFile
- Auto-chained from generate_gltf_geometry_task after every GLB export
- step_tasks.py shim re-exports generate_usd_master_task
M3 — scene-manifest API:
- part_key_service.py: build_scene_manifest(), generate_part_key(),
four-layer material priority resolution with provenance
- SceneManifest / PartEntry Pydantic models in products/schemas.py
- GET /api/cad/{id}/scene-manifest endpoint (graceful fallback to
parsed_objects when USD not yet generated)
- POST /api/cad/{id}/generate-usd-master endpoint
- frontend/src/api/sceneManifest.ts: fetchSceneManifest(),
triggerUsdMasterGeneration()
M4 — manual-material-overrides API:
- GET/PUT /api/cad/{id}/manual-material-overrides endpoints
- CadFile.manual_material_overrides JSONB column (migration 061)
- getManualOverrides() / saveManualOverrides() in cad.ts
M5 — ThreeDViewer partKey integration:
- export_step_to_gltf.py injects partKeyMap into GLB extras
- ThreeDViewer: partKeyMap extraction, resolvePartKey(), effectiveMaterials
merges legacy partMaterials + new manualOverrides (server-side persistence)
- MaterialPanel: dual-path save (partKey vs legacy), provenance badge,
reconciliation panel for unmatched/unassigned parts
Also:
- Admin.tsx: generate-missing-usd-masters + canonical scenes bulk actions
- ProductDetail.tsx: usd_master row in asset table
- vite-env.d.ts: fix ImportMeta.env TypeScript error
- GPUProbeResult: add timestamp/devices/render_time_s fields
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -151,3 +151,32 @@ export async function savePartMaterials(
|
||||
const res = await api.put<PartMaterialsResponse>(`/cad/${cadFileId}/part-materials`, map)
|
||||
return res.data.part_materials ?? {}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Manual material overrides (partKey-keyed, Priority 4)
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
export interface ManualMaterialOverridesResponse {
|
||||
cad_file_id: string
|
||||
manual_material_overrides: Record<string, string> | null
|
||||
}
|
||||
|
||||
/** Return the manual material overrides for a CAD file ({partKey: materialName}, empty if none). */
|
||||
export async function getManualOverrides(cadFileId: string): Promise<Record<string, string>> {
|
||||
const res = await api.get<ManualMaterialOverridesResponse>(
|
||||
`/cad/${cadFileId}/manual-material-overrides`,
|
||||
)
|
||||
return res.data.manual_material_overrides ?? {}
|
||||
}
|
||||
|
||||
/** Save manual material overrides keyed by partKey. Returns the saved map. */
|
||||
export async function saveManualOverrides(
|
||||
cadFileId: string,
|
||||
overrides: Record<string, string>,
|
||||
): Promise<Record<string, string>> {
|
||||
const res = await api.put<ManualMaterialOverridesResponse>(
|
||||
`/cad/${cadFileId}/manual-material-overrides`,
|
||||
{ overrides },
|
||||
)
|
||||
return res.data.manual_material_overrides ?? {}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ export type MediaAssetType =
|
||||
| 'stl_high'
|
||||
| 'gltf_geometry'
|
||||
| 'gltf_production'
|
||||
| 'usd_master'
|
||||
| 'blend_production'
|
||||
|
||||
// ── Media Browser (server-side filtered + paginated) ──────────────────────────
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import api from './client'
|
||||
|
||||
export interface PartEntry {
|
||||
part_key: string
|
||||
source_name: string
|
||||
prim_path: string | null
|
||||
effective_material: string | null
|
||||
assignment_provenance: 'manual' | 'auto' | 'source' | 'default'
|
||||
is_unassigned: boolean
|
||||
}
|
||||
|
||||
export interface SceneManifest {
|
||||
cad_file_id: string
|
||||
parts: PartEntry[]
|
||||
unmatched_source_rows: string[]
|
||||
unassigned_parts: string[]
|
||||
}
|
||||
|
||||
export async function fetchSceneManifest(cadFileId: string): Promise<SceneManifest> {
|
||||
const res = await api.get<SceneManifest>(`/cad/${cadFileId}/scene-manifest`)
|
||||
return res.data
|
||||
}
|
||||
|
||||
export async function triggerUsdMasterGeneration(cadFileId: string): Promise<{ status: string; task_id: string; cad_file_id: string }> {
|
||||
const res = await api.post(`/cad/${cadFileId}/generate-usd-master`)
|
||||
return res.data
|
||||
}
|
||||
@@ -206,6 +206,9 @@ export interface GPUProbeResult {
|
||||
device_type?: string | null
|
||||
error?: string | null
|
||||
probed_at?: string | null
|
||||
timestamp?: string | null
|
||||
devices?: string[] | null
|
||||
render_time_s?: number | null
|
||||
}
|
||||
|
||||
export async function getGpuProbeResult(): Promise<GPUProbeResult> {
|
||||
|
||||
Reference in New Issue
Block a user