dsh-cad 0.14.1 → 0.15.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/README.md CHANGED
@@ -41,7 +41,7 @@ Cumulative downloads from the npm registry, refreshed daily by CI:
41
41
 
42
42
  | Capability | Description |
43
43
  | --- | --- |
44
- | ⚙️ Single-kernel architecture | **occt.ts as the primary modeling kernel** (true B-splines, native shell/draft, centroid); opencascade.js stays only as the fallback backend; the old "no editing after shell" seam is gone — fillet/chamfer/boolean keep working after shelling |
44
+ | ⚙️ Kernel chain: cadorange → occt.ts | Modeling goes through **[cadorange](https://github.com/LAU-MARS/cadorange)** (the agent-native CAD runtime wrapping the occt.ts/OCCT WASM; public API + the supported `cadorange/occt` escape hatch for meshing/HLR/wire construction); the direct occt.ts adapter stays as the fallback tier — `DSH_CAD_KERNEL` pins one explicitly (the opencascade.js tier was removed in v0.15.1, −64MB install). The old "no editing after shell" seam is gone — fillet/chamfer/boolean keep working after shelling |
45
45
  | 🔍 CAD viewing | STL / OBJ / STEP / IGES / BREP / DCPRT (3D), DXF / SVG (2D); interactive viewport in the resident right panel (orbit / zoom / wireframe / pan), with a one-line result row in the conversation |
46
46
  | 🌗 Dark-mode surfaces | Every rendered surface follows the host theme — viewport slab, DXF/drawing strokes, the Three.js grid / XYZ triad / feature edges / default mesh color / sketch overlays, and the ViewCube plate; a theme flip restyles mounted viewers live. Overrides: `--dsh-cad-bg`, `--dsh-cad-stroke`, `--dsh-cad-paper` |
47
47
  | 🧭 CAD editor interactions | Onshape-style ViewCube (26-zone click-to-orient), hover/click face & edge picking with live measurement (area mm² / length mm), Faces+Edges / Faces / Wireframe render modes, switchable BRep demo parts (bracket / flange / shaft) |
@@ -152,7 +152,7 @@ versioned URL), and the resident panel's "Part" tab tracks the latest model in r
152
152
 
153
153
  ## Connectors (roadmap)
154
154
 
155
- Modeling primarily runs on the **occt.ts kernel** (opencascade.js as the fallback backend) (OCCT in the browser —
155
+ Modeling runs on the **occt.ts kernel** via cadorange (OCCT in the browser —
156
156
  zero install). The connectors below refer to **external CAD engines** acting as
157
157
  executors for the same tool family, planned for future support:
158
158
 
@@ -174,7 +174,7 @@ backend changes only the quality of the produced geometry.
174
174
 
175
175
  ```
176
176
  cad_view(path) modeling tools (cad_create_prim, …)
177
- → import worker (occt-import-js) → modeling worker (opencascade.js WASM)
177
+ → import worker (occt-import-js) → modeling worker (occt.ts WASM via cadorange)
178
178
  → CadScene JSON (base64-f32) → exact BRep geometry + meshing
179
179
  → GET /dsh-cad/scene/<id> → in-memory binary scene (f32/u32 packed)
180
180
  → GET /dsh-cad/bin/<docId>
@@ -183,9 +183,7 @@ cad_view(path) modeling tools (cad_create_prim, …)
183
183
  ```
184
184
 
185
185
  - **Two workers**: import (occt-import-js, read-only STEP/IGES/BREP) and modeling
186
- (opencascade.js, full OCCT) are separate, both lazily started; the `_N`
187
- suffix convention of embind overloaded constructors is wrapped in
188
- `src/modeling/occt-adapter.cjs` (all verified at runtime)
186
+ (cadorange over the occt.ts wasm) are separate, both lazily started
189
187
  - **Zero-copy pipeline**: modeling scenes use zero base64 / zero large JSON arrays /
190
188
  zero per-step disk writes (disk mirror debounced 1.5s, replayed only on service
191
189
  restart); `cad_export` is the only explicit file export
@@ -193,7 +191,7 @@ cad_view(path) modeling tools (cad_create_prim, …)
193
191
  are restored by replay after a restart
194
192
  - **Drawing HLR kernel**: hidden lines run on **occt.ts** (npm dependency,
195
193
  `npm i occt.ts`) — true OCCT removal, no fallback engine, a missing kernel is
196
- a hard error. New APIs over opencascade.js: `hiddenLines()` true hidden-line
194
+ a hard error. Kernel APIs: `hiddenLines()` true hidden-line
197
195
  removal, byte-level STEP/BRep `readStep`/`readBrep`/`writeStep`/`writeBrep`
198
196
  without MEMFS, tessellation with built-in feature-edge extraction, and a
199
197
  `hasError()`/`lastError()` error contract. Geometry crosses kernels as STEP
@@ -214,17 +212,19 @@ cad_view(path) modeling tools (cad_create_prim, …)
214
212
  exponential-map rotation, radians). Solver capability is staged
215
213
  (point-distance-to-origin today) — the plumbing contract is finished and needs
216
214
  no changes as it grows
217
- - **Single-kernel architecture**: the primary modeling kernel is
218
- **occt.ts** — primitives, curve-segment profiles (TRUE B-spline
219
- interpolation), loft/sweep/revolve, booleans, fillet/chamfer, shell/draft,
220
- mirror (composed as scale(-1) + a π rotation) and centroid all live in one
221
- session; engineering-drawing HLR takes the shape directly (zero STEP hops);
222
- editing after shelling is seamless (the old hosted-body seam is deleted).
223
- opencascade.js remains as the FALLBACK backend (auto-selected when occt.ts
224
- cannot load). Assembly STEP export writes a **structured document** (occt.ts
225
- `writeStepDocument`): one root product plus one named, placed child
215
+ - **Kernel chain**: modeling goes through **cadorange** (agent-native CAD
216
+ runtime; public build123d-style API for prims/curve-segment profiles (TRUE
217
+ B-spline interpolation)/loft/sweep/revolve/booleans (cleaned by default)/
218
+ fillet/chamfer/shell/draft/native mirror/centroid, plus the supported
219
+ `cadorange/occt` escape hatch for viewer tessellation, engineering-drawing
220
+ HLR (zero STEP hops, one wasm session) and wire construction); the direct
221
+ occt.ts adapter stays as the fallback tier (`DSH_CAD_KERNEL` pins one; see
222
+ docs/cadorange-integration.md for the verb-by-verb mapping). Editing after
223
+ shelling is seamless. Assembly STEP export writes a **structured document**
224
+ (cadorange
225
+ `exportStepAssembly`): one root product plus one named, placed child
226
226
  per instance — instance separation survives the file (STL stays a single
227
- fused mesh; the fallback backend also fuses). Instance separation stays in
227
+ fused mesh). Instance separation stays in
228
228
  the assembly scene/document for the fuse paths.
229
229
  Face selection matches `describe()` plane normals (outermost along ±normal)
230
230
  - **Client**: esbuild single-file CJS factory (three.js inlined ~560KB, react provided
@@ -265,7 +265,6 @@ either theme:
265
265
 
266
266
  ```sh
267
267
  npm test # full suite: converters / modeling worker (exact volume assertions) / DCPRT round-trip / FreeCAD + Onshape executors / image profiles / binary pipeline / document persistence
268
- node test/m0-kernel-check.cjs # OCCT kernel API smoke test
269
268
  node test/route-check.mjs # JSON scene routing layer
270
269
  node test/visual/serve.mjs # browser card/tab visual verification page (http://127.0.0.1:3987)
271
270
  ```
package/README.zh-CN.md CHANGED
@@ -38,7 +38,7 @@ npm 官方源的累计下载量,由 CI 每日刷新:
38
38
 
39
39
  | 能力 | 说明 |
40
40
  | --- | --- |
41
- | ⚙️ 单内核架构 | **occt.ts 为主建模内核**(真 BSpline、抽壳/拔模原生、质心),opencascade.js 仅作为加载失败时的降级后端;旧版的「抽壳后不可编辑」接缝消失——抽壳/拔模后可继续圆角/倒角/布尔 |
41
+ | ⚙️ 内核链:cadorange → occt.ts | 建模经 **[cadorange](https://github.com/LAU-MARS/cadorange)**(agent 原生 CAD 运行时,底层 occt.ts/OCCT WASM;公共 API + 官方 `cadorange/occt` 逃生口承担网格/HLR/线构造),occt.ts 直连保留为回退层级——`DSH_CAD_KERNEL` 可显式指定(opencascade.js 档已于 v0.15.1 移除,安装体积 −64MB)。旧版的「抽壳后不可编辑」接缝消失——抽壳/拔模后可继续圆角/倒角/布尔 |
42
42
  | 🔍 CAD 查看 | STL / OBJ / STEP / IGES / BREP / DCPRT(3D),DXF / SVG(2D),右侧常驻面板交互视口(轨道旋转 / 缩放 / 线框 / 平移),对话中只留一行结果摘要 |
43
43
  | 🌗 深色模式绘制面 | 所有绘制面跟随宿主主题——视口底板、DXF/工程图描边、Three.js 网格 / XYZ 轴 / 特征边 / 默认网格色 / 草图覆盖层,以及 ViewCube 面板;主题切换实时重绘已挂载的查看器。覆盖钩子:`--dsh-cad-bg`、`--dsh-cad-stroke`、`--dsh-cad-paper` |
44
44
  | 🧭 CAD 编辑器交互 | Onshape 风格 ViewCube(26 区域点击定向)、悬停/点选面与边实时测量(面积 mm² / 长度 mm)、面+边 / 面 / 线框三种渲染模式、支架 / 法兰 / 轴 BRep 示例件一键切换 |
@@ -146,7 +146,7 @@ patch 内容以包根目录的 `cordis.patch.yml` 随包分发,安装器经同
146
146
 
147
147
  ## 连接器(规划中)
148
148
 
149
- 建模主要由 **occt.ts** 内核承担(opencascade.js 为降级后端)(浏览器内的 OCCT 内核,零安装);
149
+ 建模经 **cadorange** 跑在 **occt.ts** 内核上(浏览器内的 OCCT 内核,零安装);
150
150
  下表连接器指未来以**外部 CAD 引擎作为执行器**驱动同一工具族:
151
151
 
152
152
  | 连接器 | 套件 | 平台 | 状态 |
@@ -166,7 +166,7 @@ WebGL 显示层因此永不改变——更换后端只影响生成几何的质
166
166
 
167
167
  ```
168
168
  cad_view(path) 建模工具(cad_create_prim 等)
169
- → 导入 worker(occt-import-js) → 建模 worker(opencascade.js WASM)
169
+ → 导入 worker(occt-import-js) → 建模 worker(cadorange / occt.ts WASM)
170
170
  → CadScene JSON(base64-f32) → BRep 精确几何 + 网格化
171
171
  → GET /dsh-cad/scene/<id> → 内存二进制场景(f32/u32 打包)
172
172
  → GET /dsh-cad/bin/<docId>
@@ -174,14 +174,13 @@ cad_view(path) 建模工具(cad_create_prim 等)
174
174
  浏览器卡片 + 常驻 "3D" 页签(three.js / SVG,Z-up,XYZ 轴)
175
175
  ```
176
176
 
177
- - **两个 worker**:导入(occt-import-js,只读 STEP/IGES/BREP)与建模(opencascade.js,
178
- 完整 OCCT)分离,均惰性启动;embind 重载构造器的 `_N` 后缀约定封装在
179
- `src/modeling/occt-adapter.cjs`(全部经运行时实证)
177
+ - **两个 worker**:导入(occt-import-js,只读 STEP/IGES/BREP)与建模(cadorange
178
+ over occt.ts wasm)分离,均惰性启动
180
179
  - **直通管道**:建模场景零 base64 / 零 JSON 大数组 / 零每步落盘(磁盘镜像 1.5s 防抖,
181
180
  仅服务重启回放);`cad_export` 是唯一的显式文件导出
182
181
  - **建模文档**:`<workspace>/.dsh-cad/model.json` 操作日志,重启后重放恢复全部 body
183
182
  - **工程图消隐内核**:隐藏线由 **occt.ts**(npm 依赖,`npm i occt.ts`)执行
184
- 真实 OCCT 消隐,无替代引擎、缺失即报错。相对 opencascade.js 的新增 API:
183
+ 真实 OCCT 消隐,无替代引擎、缺失即报错。内核 API:
185
184
  `hiddenLines()` 真实消隐线、STEP/BRep 字节级 `readStep`/`readBrep`/`writeStep`/
186
185
  `writeBrep`(无需 MEMFS)、自带特征边提取的网格化、`hasError()`/`lastError()`
187
186
  错误契约。几何以 STEP 字节跨内核交换,投影线段重映射进图纸坐标系。内核 dist
@@ -197,11 +196,13 @@ cad_view(path) 建模工具(cad_create_prim 等)
197
196
  原样透出给 LLM。装配实例位姿(平移 + XYZ 欧拉度)与求解器 rigid3(平移 + 指数映射
198
197
  旋转,弧度)双向映射。求解器能力按阶段推进(当前支持点到原点距离),管道契约
199
198
  已就绪、无需随求解器成长改动
200
- - **单内核架构**:建模主内核为 **occt.ts**——prims/曲线段轮廓
201
- (真 BSpline 插值)/放样/扫掠/旋转/布尔/圆角/倒角/抽壳/拔模/镜像(scale(-1)+
202
- 旋转 π 组合)/质心全在一个会话内,工程图 HLR 直接吃 shape(零 STEP 中转),
203
- 抽壳后继续编辑无缝(旧托管接缝已删除)。opencascade.js 保留为**降级后端**
204
- (occt.ts 加载失败时自动启用)。装配体 STEP 导出为**结构化文档**(occt.ts
199
+ - **内核链**:建模经 **cadorange**(agent 原生 CAD 运行时;build123d 风格
200
+ 公共 API 承担 prims/曲线段轮廓(真 BSpline 插值)/放样/扫掠/旋转/布尔
201
+ (默认同域清理)/圆角/倒角/抽壳/拔模/原生镜像/质心,官方 `cadorange/occt`
202
+ 逃生口承担查看器网格、工程图 HLR(零 STEP 中转、单一 wasm 会话)与线构造);
203
+ occt.ts 直连保留为回退层级(`DSH_CAD_KERNEL` 可显式指定,
204
+ 动词级映射见 docs/cadorange-integration.md)。抽壳后继续编辑无缝。
205
+ 装配体 STEP 导出为**结构化文档**(cadorange
205
206
  `writeStepDocument`):一个根产品 + 每实例一个命名、带位姿的子产品——
206
207
  实例分离在文件中保留(STL 仍为单一熔合网格;降级后端同样走 fuse)。fuse
207
208
  路径下实例分离仅保留在装配场景/文档中。面选择按 `describe()` 平面法向
@@ -240,7 +241,6 @@ cad_view(path) 建模工具(cad_create_prim 等)
240
241
 
241
242
  ```sh
242
243
  npm test # 全套:转换器 / 建模 worker(体积精确断言)/ DCPRT 往返 / FreeCAD + Onshape 执行器 / 图片轮廓 / 二进制管道 / 文档持久化
243
- node test/m0-kernel-check.cjs # OCCT 内核 API 冒烟
244
244
  node test/route-check.mjs # JSON 场景路由层
245
245
  node test/visual/serve.mjs # 浏览器卡片/页签视觉验证页(http://127.0.0.1:3987)
246
246
  ```
@@ -4,5 +4,5 @@ export const BUILTIN_CONNECTOR = {
4
4
  vendor: 'dsh-cad',
5
5
  language: 'webgl',
6
6
  status: 'built-in',
7
- binding: 'opencascade.js 1.1.1 WASM worker; three.js typed-array rendering, zero install',
7
+ binding: 'cadorange/occt.ts WASM worker; three.js typed-array rendering, zero install',
8
8
  };