← ClaudeAtlas

viewerlisted

多引擎网页预览(STEP/STL/GLB/URDF/G-code/DXF 实跑;PCB/SCH/SIM 占位 P3)。一句话起 server,后缀决定引擎。
baibai2013/build123d-cad · ★ 2 · Web & Frontend · score 65
Install: claude install-skill baibai2013/build123d-cad
# viewer — 多引擎网页预览 一句话起 server,后缀决定引擎。CAD 实跑(Three.js),PCB / SCH / SIM 占位待 P3 落地。 ## 用法 ```bash bash skills/viewer/scripts/start.sh /abs/path/to/<file> [workspace_root] # stdout 唯一一行: http://127.0.0.1:<port>/?engine=<cad|pcb|sch|sim>&dir=...&file=... ``` ```python from web_preview import start, snapshot url = start("/abs/path/to/hip_bracket.step") # 拿 URL 直接打开 res = snapshot("/abs/path/to/hip_bracket.step") # 无浏览器时降级出图,见 headless-fallback.md # res = {"tier":1|2|3, "kind":"url"|"png"|"json", "path":..., "fallback_reason":..., "duration_ms":...} ``` `snapshot(mode=auto)` 三档降级(P1-5 已落地):Tier 1 chromium 截图 → Tier 2 OCP/VTK PNG → Tier 3 dimensions JSON,逐级回落不静默。CLI:`python web_preview.py --mode=auto|web|snapshot|probe <file>`。 ## 后缀路由表(33 后缀 / 21 条目权威表见 `scripts/backend/router.mjs`) | 后缀 | 引擎 | 状态 | |---|---|---| | `.step .stp .brep .stl .glb .gltf .3mf` | cad | ready | | `.iges .igs .obj` | cad | P1 | | `.fcstd` | cad | P3(需 FreeCAD CLI) | | `.urdf .srdf .sdf` | cad | ready | | `.gcode .nc` | cad | ready(toolpath ribbon) | | `.dxf` | cad | ready(2D) | | `.png .jpg .jpeg .webp` | cad | ready(inline `<img>`) | | `.kicad_pcb .gbr .ger .drl .gtl .gbl` | pcb | stub(P3) | | `.kicad_sch .sch .svg` | sch | stub(P3) | | `.csv .mp4 .webm` | sim | stub(P3) | | `.json` | ambiguous | 需 `?engine=sim` 显式透传(否则 server 回 409) | 扩支持新格式 = `scripts/backend/router.mjs` 加一行 + `scripts/engines/<name>/` 放静态文件。 ## URL 协议(对外稳定接口) ``` http://127.0.0.1:<port>/?engine=<cad|pcb|sch|sim