@maqiuyao/dxf-viewer 0.2.1 → 0.2.3

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
@@ -66,6 +66,53 @@ helper.enableSyncCamera(true); // 左右相机同步
66
66
 
67
67
  对比结果会在左右两个视口上用**修订云线框 + 半透明填充**标出每处变动(新增绿 / 删除红 / 修改黄),框与内容间自动留隙。
68
68
 
69
+ ## 文本搜索
70
+
71
+ ```ts
72
+ // mode: "fuzzy"(模糊:子串/跳字匹配,默认)| "exact"(精准:整条文字完全相等)
73
+ const results = viewer.searchText("松口", { mode: "fuzzy" });
74
+ // 每项含 text、layer、handle、box(世界坐标包围盒)
75
+
76
+ viewer.focusText(results[0]); // 相机定位并高亮该文字
77
+ viewer.clearTextHighlight();
78
+ ```
79
+
80
+ 支持 TEXT / MTEXT / ATTRIB 全部文字实体(含块内属性),中文按图纸编码自动解码。
81
+
82
+ ## 实体点击事件
83
+
84
+ ```ts
85
+ import { ViewerEvent, type MouseClickInfo } from "@maqiuyao/dxf-viewer";
86
+
87
+ viewer.addEventListener(ViewerEvent.MouseClick, (info: MouseClickInfo) => {
88
+ if (!info.handle) return; // 点击空白处
89
+ const ud = info.userData;
90
+ console.log(ud.dxfType, ud.layerName, ud.textContent, ud.xdata);
91
+ });
92
+ ```
93
+
94
+ 拾取自动跳过背景平面;合并渲染架构下按命中游标反查实体,`userData` 携带 `handle` / `dxfType` / `layerName` / `textContent` / `xdata`。
95
+
96
+ ### 扩展数据(XDATA,组码 1000)
97
+
98
+ INSERT/ATTRIB 实体上的 `HLXSYSTEM_DATA` 等扩展数据已解析为 JSON 挂在 `userData.xdata`,点击即可读取业务字段(iconid / id / rid / shapeguid 等)。
99
+
100
+ ### 点击高亮
101
+
102
+ ```ts
103
+ viewer.enableClickHighlight = true; // 默认 false;开启后点击实体绘制云线框
104
+ viewer.clearClickHighlight(); // 主动清除
105
+ ```
106
+
107
+ ## 优化与完善(0.2.x)
108
+
109
+ - 修复 ATTRIB/ATTDEF 对齐组码(72/74)解析:右对齐/居中文字不再与块内图符重叠
110
+ - 中文乱码修复:`\M+XXXX` GBK 转义码正确解码
111
+ - 字体字间距优化,中文渲染更接近 AutoCAD
112
+ - 畸形 SPLINE 实体自动跳过,不再中断整图加载
113
+ - 加载进度以页面中央百分比呈现
114
+ - 文本元数据(textContent/handle/layer/dxfType)下放到叶子网格,合并后仍可搜索、拾取
115
+
69
116
  ## 字体资源
70
117
 
71
118
  DXF 文本渲染依赖 SHX/TTF 字体文件,本包**不内置**字体(版权原因)。请从你的 AutoCAD 安装目录或公开字体包中获取 `hztxt.shx`、`simplex.shx`、`@extfont2.shx` 等,放到你自己站点的可访问路径,再传给 `viewer.setFont([...])`。