dsh-cad 0.14.0 → 0.14.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
@@ -43,6 +43,7 @@ Cumulative downloads from the npm registry, refreshed daily by CI:
43
43
  | --- | --- |
44
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 |
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
+ | 🌗 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` |
46
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) |
47
48
  | 🏗️ Parametric modeling | Primitives, profile extrusion, **loft**, **sweep**, **revolve**, booleans, all-edge fillet/chamfer, **shell**, **draft**, **patterns** (linear/circular), transforms; profiles take **curve segments** (arcs/circles exact BRep; B-splines sampled approximation) — exact OCCT BRep, not a mesh approximation. `cad_loft` sections accept **curves** too: point loops, `{through}` splines or planar `{profile}` chains; `smooth: true` fits a **periodic B-spline** through point loops — one continuous B-spline lateral face instead of planar strips meeting at G0 creases |
48
49
  | ✏️ Named sketches | Standalone named profiles (Sketch1…) kept in the document (`cad_sketch_new` / `edit` / `list` / `delete`); extrude/revolve/sweep reference them **by name**, and `cad_sketch_edit` rewrites the definition in place + replays the log, rebuilding every dependent feature — the parametric loop. Sketches render as Onshape-style **blue curves + plane frame** in the viewport (refreshing live on edit), listed in a left-side **feature tree** (sketches + features, eye-toggle visibility, click-to-highlight bodies) over the Part tab |
@@ -230,6 +231,36 @@ cad_view(path) modeling tools (cad_create_prim, …)
230
231
  by the host module table), Z-up CAD convention, empty scene with XYZ axis labels
231
232
  and a ground grid always displayed
232
233
 
234
+ ## Theming (dark mode)
235
+
236
+ The viewer follows the host appearance automatically. DSH publishes the theme as
237
+ `color-scheme` on `<html>` plus `body[data-ds-dark-theme]`; the plugin resolves
238
+ that (falling back to `prefers-color-scheme`) and themes every surface the host
239
+ tokens cannot reach:
240
+
241
+ - the viewport slab behind the transparent WebGL canvas and 2D scenes,
242
+ - default 2D entity strokes (DXF / engineering-drawing entities),
243
+ - the Three.js ground grid, XYZ axis triad/labels, feature edges, default mesh
244
+ color and sketch overlays,
245
+ - the ViewCube face plate (canvas texture).
246
+
247
+ A theme flip restyles mounted cards and the resident panel live — no reload and
248
+ no lost camera. Engineering drawings loaded as SVG keep a white sheet; in dark
249
+ mode it is framed as paper on the dark slab instead of filling the viewport.
250
+
251
+ Hosts can override the surfaces the plugin owns; an explicit definition wins in
252
+ either theme:
253
+
254
+ | CSS variable | Applies to | Default |
255
+ | --- | --- | --- |
256
+ | `--dsh-cad-bg` | viewport background (any CSS `background` value) | light `#f5f6f8→#e9ecf0`, dark `#1b1b1c→#151517` |
257
+ | `--dsh-cad-stroke` | default 2D entity stroke | `#4c5561` light / `#c8ced6` dark |
258
+ | `--dsh-cad-paper` | drawing paper behind SVG sheets | `#ffffff` |
259
+
260
+ ```css
261
+ :root { --dsh-cad-bg: #0b0d10; } /* flat canvas in both themes */
262
+ ```
263
+
233
264
  ## Tests
234
265
 
235
266
  ```sh
package/README.zh-CN.md CHANGED
@@ -40,6 +40,7 @@ npm 官方源的累计下载量,由 CI 每日刷新:
40
40
  | --- | --- |
41
41
  | ⚙️ 单内核架构 | **occt.ts 为主建模内核**(真 BSpline、抽壳/拔模原生、质心),opencascade.js 仅作为加载失败时的降级后端;旧版的「抽壳后不可编辑」接缝消失——抽壳/拔模后可继续圆角/倒角/布尔 |
42
42
  | 🔍 CAD 查看 | STL / OBJ / STEP / IGES / BREP / DCPRT(3D),DXF / SVG(2D),右侧常驻面板交互视口(轨道旋转 / 缩放 / 线框 / 平移),对话中只留一行结果摘要 |
43
+ | 🌗 深色模式绘制面 | 所有绘制面跟随宿主主题——视口底板、DXF/工程图描边、Three.js 网格 / XYZ 轴 / 特征边 / 默认网格色 / 草图覆盖层,以及 ViewCube 面板;主题切换实时重绘已挂载的查看器。覆盖钩子:`--dsh-cad-bg`、`--dsh-cad-stroke`、`--dsh-cad-paper` |
43
44
  | 🧭 CAD 编辑器交互 | Onshape 风格 ViewCube(26 区域点击定向)、悬停/点选面与边实时测量(面积 mm² / 长度 mm)、面+边 / 面 / 线框三种渲染模式、支架 / 法兰 / 轴 BRep 示例件一键切换 |
44
45
  | 🏗️ 参数化建模 | 基本体、轮廓拉伸、**放样**、**扫掠**、**旋转体**、布尔、全边圆角/倒角、**抽壳**、**拔模**、**阵列(线性/圆周)**、变换;轮廓支持**曲线段**(圆弧/圆为精确 BRep,B 样条为采样近似)—— OCCT 精确 BRep,非网格近似 |
45
46
  | ✏️ 命名草图 | 文档中独立的可命名轮廓(Sketch1…):`cad_sketch_new` / `edit` / `list` / `delete`;拉伸/旋转/扫掠**按名字引用**,`cad_sketch_edit` 原位改写定义并全量重放,所有引用特征级联重建——参数化闭环。草图以 Onshape 式**蓝色曲线 + 平面框**在视口中实时渲染(回改即刷新),并列于零件页签左侧的**特征树**(草图 + 特征、眼睛显隐、点选高亮实体) |
@@ -208,6 +209,33 @@ cad_view(path) 建模工具(cad_create_prim 等)
208
209
  - **客户端**:esbuild 单文件 CJS 工厂(three.js 内联 ~560KB,react 由宿主模块表提供),
209
210
  Z-up CAD 惯例,带 XYZ 轴标签与地面网格的空场景常驻显示
210
211
 
212
+ ## 主题(深色模式)
213
+
214
+ 查看器自动跟随宿主外观。DSH 通过 `<html>` 上的 `color-scheme` 与
215
+ `body[data-ds-dark-theme]` 发布主题;插件据此解析(无信号时回退到
216
+ `prefers-color-scheme`),并为主题 token 覆盖不到的所有绘制面着色:
217
+
218
+ - 透明 WebGL 画布与 2D 场景背后的视口底板;
219
+ - 2D 实体默认描边(DXF / 工程图实体);
220
+ - Three.js 地面网格、XYZ 轴与轴标签、特征边、默认网格色与草图覆盖层;
221
+ - ViewCube 面板贴图(canvas 纹理)。
222
+
223
+ 主题切换会实时重绘已挂载的卡片与右侧常驻面板——无需刷新,也不丢失视角。
224
+ 以 SVG 载入的工程图仍是一张白纸:深色模式下它作为「纸」被框在深色底板上,
225
+ 而不是占满整个视口。
226
+
227
+ 宿主可覆盖插件自有的绘制面(显式定义在明暗两种主题下都优先):
228
+
229
+ | CSS 变量 | 作用 | 默认值 |
230
+ | --- | --- | --- |
231
+ | `--dsh-cad-bg` | 视口背景(任意 CSS `background` 值) | 浅色 `#f5f6f8→#e9ecf0`,深色 `#1b1b1c→#151517` |
232
+ | `--dsh-cad-stroke` | 2D 实体默认描边 | 浅色 `#4c5561` / 深色 `#c8ced6` |
233
+ | `--dsh-cad-paper` | SVG 图纸背后的纸面 | `#ffffff` |
234
+
235
+ ```css
236
+ :root { --dsh-cad-bg: #0b0d10; } /* 两种主题下都使用纯色底板 */
237
+ ```
238
+
211
239
  ## 测试
212
240
 
213
241
  ```sh