feat: sharp edge pipeline V02, tessellation presets, media cache-bust, GMSH plan
Sharp Edge Pipeline V02:
- export_step_to_gltf.py: replace BRep_Tool.Polygon3D_s (returns None in XCAF) with
GCPnts_UniformAbscissa curve sampling at 0.3mm step — extracts 17,129 segment pairs
- Inject sharp_edge_pairs + sharp_threshold_deg into GLB extras (scenes[0].extras)
via binary GLB JSON-chunk patching (no extra dependency)
- export_gltf.py: read schaeffler_sharp_edge_pairs from Blender scene custom props,
apply via KD-tree to mark edges sharp=True + seam=True (OCC mm Z-up → Blender transform)
- tools/restore_sharp_marks.py: dual-pass (dihedral angle + OCC pairs), updated coordinate
transform (X, -Z, Y) * 0.001
Tessellation:
- Admin UI: Draft / Standard / Fine preset buttons with active-state highlighting
- Default angular deflection: preview 0.5→0.1 rad, production 0.2→0.05 rad
- export_glb.py: read updated defaults from system_settings
Media / Cache:
- media/service.py: get_download_url appends ?v={file_size_bytes} cache-buster
- media/router.py: Cache-Control: no-cache for all download/thumbnail endpoints
Render pipeline:
- still_render.py / turntable_render.py: shared GPU activation + camera improvements
- render_order_line.py: global render position support
- render_thumbnail.py: updated defaults
Frontend:
- InlineCadViewer: file_size_bytes-aware URL update triggers re-fetch on regeneration
- ThreeDViewer: material panel, part selection, PBR mode improvements
- Admin.tsx: tessellation preset cards, GMSH setting dropdown
- MediaBrowser, ProductDetail, OrderDetail, Orders: various UI improvements
- New: MaterialPanel, GlobalRenderPositionsPanel, StepIndicator components
- New: renderPositions.ts API client
Plans / Docs:
- plan.md: GMSH Frontal-Delaunay tessellation plan (6 tasks)
- LEARNINGS.md: OCC Polygon3D_s None issue + GCPnts fix
- .gitignore: add backend/core (core dump from root process)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,87 @@
|
||||
import type { PartMaterialEntry, PartMaterialMap } from '../../api/cad'
|
||||
|
||||
/**
|
||||
* Normalize a GLB mesh name by stripping suffixes added by the export pipeline:
|
||||
* - OCC RWGltf_CafWriter adds "_AF0", "_AF1", … for repeated assembly instances
|
||||
* - Blender adds ".001", ".002", … for name deduplication on re-import
|
||||
*
|
||||
* Mirrors the logic in render-worker/scripts/export_gltf.py (lines 107-114).
|
||||
*
|
||||
* Examples:
|
||||
* "Ring_AF3" → "Ring"
|
||||
* "Ring_AF0_AF1" → "Ring" (nested suffixes — loop until stable)
|
||||
* "Cage.001" → "Cage"
|
||||
* "Cage.001_AF2" → "Cage"
|
||||
* "KOMP_ASM_1_AF0_ASM" → "KOMP_ASM_1" (_AF0_ASM variant)
|
||||
* "GE360-HF_000_P_ASM_1_AF0_ASM" → "GE360-HF_000_P_ASM_1"
|
||||
* "PlainPart" → "PlainPart"
|
||||
*/
|
||||
export function normalizeMeshName(name: string): string {
|
||||
// Strip Blender dedup suffix (.001, .002, …)
|
||||
let n = name.replace(/\.\d{3}$/, '')
|
||||
// Strip OCC assembly-instance suffix — handles _AF0, _AF1, _AF0_ASM, _AF1_ASM patterns
|
||||
// The optional (_ASM)? group catches assembly-node variants like _AF0_ASM
|
||||
let prev = ''
|
||||
while (prev !== n) { prev = n; n = n.replace(/_AF\d+(_ASM)?$/i, '') }
|
||||
return n
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// resolvePartMaterial
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Resolve a material entry for a (already-normalized) GLB mesh name.
|
||||
*
|
||||
* OCC's GLB exporter strips certain path suffixes (_ASM_1, _1, _AF\d+_\d+)
|
||||
* that cadquery keeps when parsing the STEP topology. This means stored keys
|
||||
* from Excel-imported cad_part_materials may have extra suffixes compared to
|
||||
* the actual GLB mesh names.
|
||||
*
|
||||
* Strategy:
|
||||
* 1. Exact match: partMaterials[meshKey]
|
||||
* 2. Prefix match: find shortest stored key that starts with meshKey + '_'
|
||||
* e.g. GLB "GE360-EIN_HAELFTE" matches stored "GE360-EIN_HAELFTE_AF0_1"
|
||||
*
|
||||
* Returns undefined when no match exists.
|
||||
*/
|
||||
export function resolvePartMaterial(
|
||||
meshKey: string,
|
||||
partMaterials: PartMaterialMap,
|
||||
): PartMaterialEntry | undefined {
|
||||
// 1. Exact match
|
||||
if (partMaterials[meshKey]) return partMaterials[meshKey]
|
||||
// 2. Shortest stored key that starts with meshKey + '_'
|
||||
let bestKey: string | undefined
|
||||
for (const key of Object.keys(partMaterials)) {
|
||||
if (key.startsWith(meshKey + '_')) {
|
||||
if (!bestKey || key.length < bestKey.length) bestKey = key
|
||||
}
|
||||
}
|
||||
return bestKey ? partMaterials[bestKey] : undefined
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// convertCadPartMaterials
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Convert Product.cad_part_materials (list of {part_name, material}) to
|
||||
* the PartMaterialMap format used by the 3D viewers.
|
||||
*
|
||||
* - Skips entries with blank part_name or material
|
||||
* - Detects hex colors (starting with "#") vs library material names
|
||||
* - Normalizes part names with normalizeMeshName() so they match GLB mesh keys
|
||||
*/
|
||||
export function convertCadPartMaterials(
|
||||
items: Array<{ part_name: string; material: string }>,
|
||||
): PartMaterialMap {
|
||||
const result: PartMaterialMap = {}
|
||||
for (const item of items) {
|
||||
if (!item.part_name.trim() || !item.material.trim()) continue
|
||||
const key = normalizeMeshName(item.part_name.trim())
|
||||
const value = item.material.trim()
|
||||
result[key] = { type: value.startsWith('#') ? 'hex' : 'library', value }
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user