dsh-cad-studio 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +87 -2
- package/assets/OrbitControls.js +1101 -0
- package/assets/three.min.js +6 -0
- package/client.js +2534 -0
- package/cordis.patch.yml +4 -0
- package/index.js +2269 -0
- package/package.json +48 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 dsh-cad-studio contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,88 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-cad-studio
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
DeepSeek Harness 的 CAD 插件:**把 FreeCAD 桥接成给 AI 用的工具**,并在 Web 右栏提供一个只读+轻交互的 3D 面板。
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
- Host 侧(`index.js`):14 个工具 + `/cad-studio/*` HTTP 路由 + `freecadcmd` 子进程桥
|
|
8
|
+
- 客户端侧(`client.js`):右栏页签「CAD 工作室」,three.js 视口 + 图标条浮层(零件 / 特征 / 选中项 / 运动 / 视图 / 模型 / 信息)
|
|
9
|
+
- 数据:`<modelsDir>/<名字>.json` 存模型工程(脚本或声明式特征 + 参数 + 20 条历史);场景网格落 `$TMPDIR/dsh-cad-studio/{state.json,scenes/*.json}`
|
|
10
|
+
|
|
11
|
+
## 能力
|
|
12
|
+
|
|
13
|
+
| 领域 | 做什么 |
|
|
14
|
+
|---|---|
|
|
15
|
+
| 建模 | `cad_studio_feature` 声明式特征(box/cylinder/sphere/cone/torus/extrude/revolve/fuse/cut/common/fillet/chamfer/shell/pattern/translate/rotate/mirror);`cad_studio_run` 跑任意 FreeCAD Python |
|
|
16
|
+
| 工程文件 | `cad_studio_doc` 存 `script` 或 `features` 两种模型;`cad_studio_features` 改一条特征→整表重算(0.2–0.6 s),失败整表回滚 |
|
|
17
|
+
| 装配 | `cad_studio_assembly` 读 manifest,`App::Link` 语义的实例位姿;零件是 STEP 文件级引用(改零件重开即跟随) |
|
|
18
|
+
| 运动 | `cad_studio_joint`(revolute/linear)+ `cad_studio_drive` + `cad_studio_explode`,面板拖滑杆看运动 |
|
|
19
|
+
| 出图 | `cad_studio_drawing` HLR → SVG(主/俯/左/等轴) |
|
|
20
|
+
| 其它 | `cad_studio_open`(STEP/STL/BREP/IGES 进来看)、`cad_studio_export`、`cad_studio_measure`、`cad_studio_env` |
|
|
21
|
+
| 自检/安装 | `cad_studio_setup`:报告 freecadcmd 是否可用、版本、包管理器与可执行命令;`action=install` 直接装 |
|
|
22
|
+
| 面板 | 多页签(上限 5,各自记住相机与配色)、点选联动、色块换色、显隐、透明度、线框、隔离、标准视图、网格/轮廓/光影开关 |
|
|
23
|
+
|
|
24
|
+
## 安装
|
|
25
|
+
|
|
26
|
+
需要本机有 `freecadcmd`(FreeCAD ≥ 0.20)。装插件不等于装 FreeCAD——它是外部程序,213 MB 左右,不随 npm 包分发。
|
|
27
|
+
|
|
28
|
+
装法二选一:
|
|
29
|
+
|
|
30
|
+
1. **让面板装**:打开右栏「CAD 工作室」→ 信息(i)→ 看到黄框点「自动安装 FreeCAD」。后端 `cad_studio_setup` 会自动识别 apt / dnf / pacman / brew 并执行(apt 需要 root)。
|
|
31
|
+
2. **自己装**:`apt install freecad`,然后在插件配置里留空 `freecadPath`(自动探测 `/usr/bin/freecadcmd` 等 5 个位置)或显式指定。
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
# 从 npm 装(推荐)
|
|
35
|
+
dsh plugin --profile web add dsh-cad-studio
|
|
36
|
+
|
|
37
|
+
# 或从源码目录装
|
|
38
|
+
dsh plugin --profile web add /path/to/dsh-cad-studio
|
|
39
|
+
# 装完重启 dsh 使 host 侧工具挂载;client 侧刷新页面即可
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
npm 包:<https://www.npmjs.com/package/dsh-cad-studio>(`dsh plugin` / DSH 插件市场按包名解析,发布到 npm 即可被装到)。
|
|
43
|
+
|
|
44
|
+
配置项(cordis 配置):
|
|
45
|
+
|
|
46
|
+
| 键 | 默认 | 说明 |
|
|
47
|
+
|---|---|---|
|
|
48
|
+
| `freecadPath` | `''`(自动探测 5 个位置) | `freecadcmd` 路径 |
|
|
49
|
+
| `timeoutMs` | `180000` | 单次脚本超时 |
|
|
50
|
+
| `modelsDir` | `''` | 模型工程目录;空 = 跟随调用会话工作区的 `cad-models/` |
|
|
51
|
+
| `autoOpen` | `'session'` | 面板何时自己占位右栏:`session` = 只有做 CAD 的会话(默认)、`always` = 每个会话、`off` = 从不(页签留在「+」菜单里) |
|
|
52
|
+
| `trustedHosts` | `[]` | 额外允许访问 `/cad-studio/*` 的主机名(本机回环默认允许) |
|
|
53
|
+
|
|
54
|
+
`autoOpen: 'session'` 的判据是宿主侧的两个信号:这个会话最近一次发布过场景(`lastSession`),或它拥有更早发布过的场景。也就是说——只有真正在这里建过模的对话,右栏才会自动让出位置;别的对话不受打扰。
|
|
55
|
+
|
|
56
|
+
## 场景 JSON 协议
|
|
57
|
+
|
|
58
|
+
```jsonc
|
|
59
|
+
{
|
|
60
|
+
"parts": [{ "id": "p1", "verts": [...], "tris": [...], "volume": 1234.5 }],
|
|
61
|
+
"instances": [{ "name": "底座", "part": "p1", "rot": [1,0,0, 0,1,0, 0,0,1], "translate": [0,0,0] }],
|
|
62
|
+
"assembly": { "id": "asm-1", "title": "运动演示", "explode": 0,
|
|
63
|
+
"joints": [{ "id": "hinge", "instance": "盖板", "type": "revolute",
|
|
64
|
+
"axis": [1,0,0], "origin": [0,0,40], "value": 0, "min": -90, "max": 90 }] }
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
`rot` 是行主序 3×3,`translate` 是 mm。几何按**逐面三角化**,平面与孔壁不共享顶点(避免法线平均出暗色扇形)。
|
|
69
|
+
|
|
70
|
+
## 开发
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
node test/harness.mjs # 133 条回归:无浏览器,stub cordis ctx 直接调工具
|
|
74
|
+
node test/stale-bridge.mjs # 热重载后旧 bridge 实例自愈
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
`test/replicate.mjs`、`scripts/*.mjs` 是我自己造场景/验证用的夹具,按需改路径。
|
|
78
|
+
|
|
79
|
+
## 已知限制
|
|
80
|
+
|
|
81
|
+
- 依赖外部 `freecadcmd`(约 213 MB),不是纯 wasm
|
|
82
|
+
- 关节只支持 revolute / linear,没有约束求解器
|
|
83
|
+
- 没有草图参数化与约束求解
|
|
84
|
+
- 工具粒度比 dsh-cad 的 34 个增量工具粗:常见活走 `feature`,特殊活写脚本
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
MIT
|