Go to file
xiao-ke ec79612fe6 更新UI 2026-07-03 13:58:35 +08:00
2D 三视图 更新仓库 2026-06-29 17:10:32 +08:00
bambu-studio-ai 提交skill文件 2026-06-29 17:23:39 +08:00
ips 更新.3MF文件映射关系、修改了轮询间隔30s 2026-07-02 15:48:54 +08:00
static 更新UI 2026-07-03 13:58:35 +08:00
templates 更新UI 2026-07-03 13:58:35 +08:00
曦曦IP/曦曦IP 优化图片 2026-07-03 13:41:00 +08:00
.gitignore .gitignore文件 2026-06-29 17:28:49 +08:00
README.md 更新 README:完整文档覆盖两条用户路径、页面路由、架构和流水线 2026-07-01 17:12:29 +08:00
image.png 更新仓库 2026-06-29 17:10:32 +08:00
main.py 添加魔法衣橱 DIY 路径:customize → preview_diy → takeaway 2026-07-01 17:07:53 +08:00
monitor_bridge.py 更新skill的路径 2026-06-29 17:41:48 +08:00
task_state.py 更新仓库 2026-06-29 17:10:32 +08:00

README.md

IP Print Web

曦曦 IP 形象 3D 打印直连站。提供两条路径:唤醒经典(直达打印)和 魔法衣橱DIY 换装生成 3D 模型。OpenClaw Agent 通过 bambu.py.3mf 文件发送至 Bambu Lab 打印机,monitor_bridge.py 后台监控进度并通过 WebSocket 实时推送前端。

技术栈

技术
后端框架 FastAPIPython
实时通信 WebSocketFastAPI 原生 + websockets 库)
前端 原生 HTML/CSS/JavaScript多页应用无框架
打印机控制 bambu.pyLAN MQTT + FTPS 直连)
Agent 调度 OpenClaw Gateway + Agent
图像资源 曦曦IP/IP换装/ static/xixi_diy/ static/images/

快速开始

# 终端 1: OpenClaw Gateway端口 18789
openclaw gateway

# 终端 2: FastAPI端口 8000
python -m uvicorn main:app --host 0.0.0.0 --port 8000 --reload

打开 http://localhost:8000

页面路由与流程

唤醒经典(直达打印)

index.html落地页
  → select.html双路枢纽
    → select_classic.html从 /api/list-ips 动态加载 IP
      → preview_classic.html三视图预览 + 模拟加载)
        → printing_classic.html真实后端API + WebSocket + Gateway
          → finish_classic.html完成页

魔法衣橱DIY 换装)

index.html → select.html
  → customize.html选择服饰 + 配饰,实时预览合成图)
    → preview_diy.html3D 模型预览 + 模拟 2D→3D
      → takeaway.html数字凭证提取页

页面一览

模板 路由 路径
index.html / 落地页
select.html /select.html 双路枢纽(经典 / 衣橱)
select_classic.html /select_classic.html 经典 IP 选择API 动态加载)
preview_classic.html /preview_classic.html 经典三视图预览
printing_classic.html /printing_classic.html 打印执行页(真实后端)
finish_classic.html /finish_classic.html 打印完成
customize.html /customize.html 魔法衣橱换装
preview_diy.html /preview_diy.html DIY 3D 预览
takeaway.html /takeaway.html 数字凭证提取
print.html /print.html (预留)
printing.html /printing.html (预留)
finish.html /finish.html (预留)

项目结构

文件 职责
main.py FastAPI 后端 — REST API + WebSocket 代理 + 任务状态推送 + 页面路由
task_state.py 任务状态持久化(work/{task_id}_state.json
monitor_bridge.py 打印监控 — MQTT 直连轮询,写状态文件,自行设置 done/failed
ips/list.json IP 形象数据id、name、image、model、desc前端动态加载
static/gateway.js GatewayChat 类 — WebSocket 连接、RPC 通信、事件分发
static/prompt.js 打印配置常量 + buildPrintPrompt() — 构造发给 Agent 的指令
static/xixi_diy/ 魔法衣橱换装图片cloth ×10、ornament ×8、合成图 7×7
static/images/ 猫猫引导图、Logo、经典模型三视图
static/3D/ 预切片 .3mf 模型文件

架构

浏览器
  ├── /ws/gateway ──→ FastAPI 代理 ──→ OpenClaw Gateway (:18789)
  │                                       └──→ Agent 执行流水线
  ├── /ws/task/{id} ←── WebSocket 实时推送 ──→ 轮询 work/{id}_state.json
  │                              ↑
  │              monitor_bridge.py (后台 Start-Process独立运行)
  │                              ↑
  │           bambu.py print ──→ 打印机 (MQTT + FTPS)
  └── /api/generate → task_state.start_task() → 创建任务

打印流水线

Agent 执行三步(非阻塞):

  1. 发送打印文件bambu.py print <模型> --confirmed
  2. 后台启动监控Start-Process monitor_bridge.py <task_id>(立即返回,不等待)
  3. 确认监控运行set_status("printing")

monitor_bridge.py 在后台独立运行自行写入状态progress、done/failed后端 WebSocket 检测文件变化推送前端。

API

方法 路径 说明
GET / 落地页
GET /api/list-ips IP 形象列表(含 id/name/image/model/desc
POST /api/generate 创建任务,请求体 {"ip_id"}
GET /api/status/{task_id} 任务状态查询
WS /ws/gateway 浏览器 ↔ Gateway 透明代理
WS /ws/task/{task_id} 任务状态实时推送

环境要求

  • Python ≥ 3.10
  • OpenClaw CLIGateway + Agent
  • bambu-studio-ai skillbambu.py 打印机控制脚本)
  • 打印机开启 Developer Mode
pip install fastapi uvicorn pydantic websockets bambulabs-api