@flyfish-dev/cad-viewer 0.6.0 → 0.6.2
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/NOTICE +1 -1
- package/README.md +20 -6
- package/README.zh-CN.md +24 -6
- package/dist/cad-viewer.es.js +403 -392
- package/dist/cad-viewer.es.js.map +1 -1
- package/dist/cad-viewer.umd.cjs +4 -4
- package/dist/cad-viewer.umd.cjs.map +1 -1
- package/dist/types/core/types.d.ts +11 -0
- package/dist/types/core/types.d.ts.map +1 -1
- package/dist/types/loaders/dwf/DwfLoader.d.ts.map +1 -1
- package/package.json +5 -4
package/NOTICE
CHANGED
|
@@ -4,6 +4,6 @@ This project integrates third-party open-source projects for CAD parsing and ren
|
|
|
4
4
|
|
|
5
5
|
- @mlightcad/libredwg-web: DWG parsing in the browser through LibreDWG WebAssembly. License: GPL-3.0-only.
|
|
6
6
|
- dxf-parser: DXF parser for JavaScript. License: MIT.
|
|
7
|
-
- dwf-viewer: native frontend DWF/DWFx renderer for DWF 6+ ZIP containers, DWFx/OPC/XPS, WHIP/W2D 2D sheets
|
|
7
|
+
- dwf-viewer 0.6.x: native frontend DWF/DWFx/XPS renderer for DWF 6+ ZIP containers, DWFx/OPC/XPS, WHIP/W2D 2D sheets, W3D/HSF eModel content, embedded XPS fonts and optional WASM fallback. License: AGPL-3.0-only.
|
|
8
8
|
|
|
9
9
|
The combined package is distributed under AGPL-3.0-only. Keep attribution and license notices when redistributing, modifying, embedding, or using this package as part of another application.
|
package/README.md
CHANGED
|
@@ -8,10 +8,21 @@ A professional, lightweight, extensible **frontend CAD viewer** for modern brows
|
|
|
8
8
|
**Live demo:** [cad-viewer-iys.pages.dev](https://cad-viewer-iys.pages.dev)
|
|
9
9
|
**Source:** [github.com/flyfish-dev/cad-viewer](https://github.com/flyfish-dev/cad-viewer)
|
|
10
10
|
|
|
11
|
-
The project provides a clean loader architecture for **DWG**, **DXF**, **DWF**, **DWFx** and **XPS**. DWG/DXF are normalized into a common `CadDocument` and rendered through retained WebGL with a lightweight Canvas overlay; DWF/DWFx/XPS are delegated to the native `dwf-viewer` renderer for W2D, W3D/HSF eModel
|
|
11
|
+
The project provides a clean loader architecture for **DWG**, **DXF**, **DWF**, **DWFx** and **XPS**. DWG/DXF are normalized into a common `CadDocument` and rendered through retained WebGL with a lightweight Canvas overlay; DWF/DWFx/XPS are delegated to the native `dwf-viewer` renderer for WebGL-accelerated W2D and XPS/DWFx vectors, W3D/HSF eModel geometry, embedded XPS fonts and optional WASM fallback. Files are read locally in the browser; the viewer does not upload drawings to a backend.
|
|
12
12
|
|
|
13
|
-
> DWG support uses `@mlightcad/libredwg-web` / LibreDWG WebAssembly in a worker. DXF support uses JavaScript parsing plus a built-in fallback parser. DWF, DWFx and XPS support is powered by `dwf-viewer
|
|
13
|
+
> DWG support uses `@mlightcad/libredwg-web` / LibreDWG WebAssembly in a worker. DXF support uses JavaScript parsing plus a built-in fallback parser. DWF, DWFx and XPS support is powered by `dwf-viewer` 0.6.x, including DWF 6+ ZIP containers, WHIP/W2D 2D sheets, W3D/HSF 3D eModel geometry, DWFx/OPC/XPS pages, adaptive CAD line weights and an optional raster WASM fallback.
|
|
14
14
|
|
|
15
|
+
## What changed in 0.6.2
|
|
16
|
+
|
|
17
|
+
- Updated the native DWF path to `dwf-viewer` 0.6.4 for upstream DWF/DWFx bug fixes while keeping this package on its own SemVer line.
|
|
18
|
+
- Verified the exposed `CadViewer` DWF/XPS options still match the current `dwf-viewer` API.
|
|
19
|
+
|
|
20
|
+
## What changed in 0.6.1
|
|
21
|
+
|
|
22
|
+
- Updated the native DWF path to `dwf-viewer` 0.6.1.
|
|
23
|
+
- Adopted the current renderer behavior for WebGL-accelerated XPS/DWFx and W2D 2D vector rendering, W3D/HSF 3D rendering, embedded XPS font loading and optional WASM raster fallback.
|
|
24
|
+
- Exposed DWF/XPS overview tuning through `dwfLineWeightMode`, `dwfMinStrokeCssPx`, `dwfMaxOverviewStrokeCssPx`, `dwfMinTextCssPx` and `dwfMinFilledAreaCssPx`.
|
|
25
|
+
- Refreshed README, format notes, architecture notes and package metadata for the latest DWF support.
|
|
15
26
|
|
|
16
27
|
## What changed in 0.6.0
|
|
17
28
|
|
|
@@ -63,7 +74,7 @@ The project provides a clean loader architecture for **DWG**, **DXF**, **DWF**,
|
|
|
63
74
|
- **Loader registry**: DWG, DXF and DWF loaders are independent and replaceable; native-renderable loaders can mount their own optimized viewer.
|
|
64
75
|
- **DWG preview**: browser-local parsing through LibreDWG WebAssembly, executed in a Web Worker by default.
|
|
65
76
|
- **DXF preview**: JavaScript parser path with fallback support for common ASCII DXF `ENTITIES`.
|
|
66
|
-
- **DWF/DWFx/XPS preview**: powered by `dwf-viewer` for DWF ZIP packages, W2D 2D
|
|
77
|
+
- **DWF/DWFx/XPS preview**: powered by `dwf-viewer` for DWF ZIP packages, WebGL-accelerated W2D and XPS/DWFx 2D vectors, W3D/HSF eModel geometry, embedded XPS fonts, adaptive CAD line weights and raster fallback.
|
|
67
78
|
- **CAD color handling**: ACI, BYLAYER, BYBLOCK inheritance, DWG layer colors, true color, fill color, opacity and adaptive contrast.
|
|
68
79
|
- **High-performance WebGL viewport controls**: retained GPU buffers, spatial culling, zoom, pan, fit-to-view, cursor world coordinates and zoom percentage.
|
|
69
80
|
- **Professional demo UI**: drag-and-drop, compact toolbar, status strip, parse/render timing, entity summary and warnings.
|
|
@@ -247,6 +258,9 @@ const viewer = new CadViewer({
|
|
|
247
258
|
dwfPreferWebgl: true,
|
|
248
259
|
dwfPreferWasm: true,
|
|
249
260
|
dwfMaxCanvasPixels: 16_777_216,
|
|
261
|
+
dwfLineWeightMode: 'adaptive', // 'adaptive' | 'physical' | 'hairline'
|
|
262
|
+
dwfMinStrokeCssPx: 0.42,
|
|
263
|
+
dwfMinTextCssPx: 1.05,
|
|
250
264
|
onLoadProgress(progress) {},
|
|
251
265
|
onLoad(result) {},
|
|
252
266
|
onError(error) {},
|
|
@@ -275,7 +289,7 @@ CadLoaderRegistry
|
|
|
275
289
|
DwgLoader | DxfLoader | DwfLoader | custom loader
|
|
276
290
|
↓
|
|
277
291
|
DWG/DXF: CadDocument → CadWebGLRenderer | CadCanvasRenderer fallback
|
|
278
|
-
DWF/DWFx/XPS: DwfLoader.mount() → dwf-viewer native WebGL/WASM
|
|
292
|
+
DWF/DWFx/XPS: DwfLoader.mount() → dwf-viewer native WebGL vectors / 3D / WASM fallback
|
|
279
293
|
```
|
|
280
294
|
|
|
281
295
|
Each loader returns a normalized `CadDocument`:
|
|
@@ -327,8 +341,8 @@ viewer.registerLoader({
|
|
|
327
341
|
|---|---|---|
|
|
328
342
|
| DWG | `DwgLoader` | Uses LibreDWG WebAssembly. Rendering coverage depends on the entities exposed by LibreDWG conversion. |
|
|
329
343
|
| DXF | `DxfLoader` | Uses `dxf-parser` plus fallback parsing. Supports core entities, blocks/inserts, colors/layers, polylines, text, hatch boundaries and splines as preview polylines. |
|
|
330
|
-
| DWF | `DwfLoader` + `dwf-viewer` | DWF 6+ ZIP packages, WHIP/W2D 2D sheets, W3D/HSF 3D eModel pages, model tree metadata and
|
|
331
|
-
| DWFx / XPS | `DwfLoader` + `dwf-viewer` | DWFx/OPC/XPS pages with vector paths, text, images
|
|
344
|
+
| DWF | `DwfLoader` + `dwf-viewer` | DWF 6+ ZIP packages, WHIP/W2D 2D sheets, W3D/HSF 3D eModel pages, model tree metadata, WebGL rendering and optional WASM fallback. |
|
|
345
|
+
| DWFx / XPS | `DwfLoader` + `dwf-viewer` | DWFx/OPC/XPS pages with WebGL-accelerated vector paths, embedded fonts, text, images, package resources and adaptive overview line weights through the native DWF renderer. |
|
|
332
346
|
|
|
333
347
|
## Color handling
|
|
334
348
|
|
package/README.zh-CN.md
CHANGED
|
@@ -8,10 +8,21 @@
|
|
|
8
8
|
**在线 Demo:** [cad-viewer-iys.pages.dev](https://cad-viewer-iys.pages.dev)
|
|
9
9
|
**源码仓库:** [github.com/flyfish-dev/cad-viewer](https://github.com/flyfish-dev/cad-viewer)
|
|
10
10
|
|
|
11
|
-
本仓库提供面向浏览器的 loader 架构,支持 **DWG**、**DXF**、**DWF**、**DWFx** 和 **XPS**。DWG/DXF 会归一化为统一 `CadDocument` 并通过 WebGL retained-mode 渲染,文字/图片使用轻量 Canvas overlay;DWF/DWFx/XPS 交给原生 `dwf-viewer` 渲染通道处理 W2D
|
|
11
|
+
本仓库提供面向浏览器的 loader 架构,支持 **DWG**、**DXF**、**DWF**、**DWFx** 和 **XPS**。DWG/DXF 会归一化为统一 `CadDocument` 并通过 WebGL retained-mode 渲染,文字/图片使用轻量 Canvas overlay;DWF/DWFx/XPS 交给原生 `dwf-viewer` 渲染通道处理 WebGL 加速的 W2D 与 XPS/DWFx 矢量、W3D/HSF eModel、XPS 嵌入字体和可选 WASM fallback。文件在浏览器本地读取,组件不会把图纸上传到服务端。
|
|
12
12
|
|
|
13
|
-
> DWG 使用 `@mlightcad/libredwg-web` / LibreDWG WebAssembly,并默认运行在 Worker 中。DXF 使用 JavaScript 解析器并带内置 fallback。DWF、DWFx、XPS 由 `dwf-viewer` 驱动,覆盖 DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel、DWFx/OPC/XPS
|
|
13
|
+
> DWG 使用 `@mlightcad/libredwg-web` / LibreDWG WebAssembly,并默认运行在 Worker 中。DXF 使用 JavaScript 解析器并带内置 fallback。DWF、DWFx、XPS 由 `dwf-viewer` 0.6.x 驱动,覆盖 DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel、DWFx/OPC/XPS 页面、自适应 CAD 线宽和可选 raster WASM fallback。
|
|
14
14
|
|
|
15
|
+
## 0.6.2 变更
|
|
16
|
+
|
|
17
|
+
- 原生 DWF 通道升级到 `dwf-viewer` 0.6.4,包含上游 DWF/DWFx bugfix;本包继续按自身 SemVer 发布为 0.6.2。
|
|
18
|
+
- 已确认当前暴露的 `CadViewer` DWF/XPS 配置项仍与最新版 `dwf-viewer` API 匹配。
|
|
19
|
+
|
|
20
|
+
## 0.6.1 变更
|
|
21
|
+
|
|
22
|
+
- 原生 DWF 通道升级到 `dwf-viewer` 0.6.1。
|
|
23
|
+
- 同步最新 renderer 行为:WebGL 加速 XPS/DWFx 与 W2D 2D 矢量渲染、W3D/HSF 3D 渲染、XPS 嵌入字体加载和可选 WASM raster fallback。
|
|
24
|
+
- 新增 `dwfLineWeightMode`、`dwfMinStrokeCssPx`、`dwfMaxOverviewStrokeCssPx`、`dwfMinTextCssPx`、`dwfMinFilledAreaCssPx`,用于调节 DWF/XPS 总览渲染效果。
|
|
25
|
+
- 更新 README、格式说明、架构说明和 package metadata,统一最新版 DWF 支持口径。
|
|
15
26
|
|
|
16
27
|
## 0.6.0 变更
|
|
17
28
|
|
|
@@ -63,7 +74,7 @@
|
|
|
63
74
|
- **正确的 loader 架构**:DWG / DXF / DWF 独立 loader,可替换、可扩展;native-renderable loader 可以挂载自己的优化渲染器。
|
|
64
75
|
- **DWG 预览**:通过 LibreDWG WebAssembly 在浏览器本地解析,默认在 Web Worker 中执行。
|
|
65
76
|
- **DXF 预览**:JavaScript 解析,支持常见 ASCII DXF `ENTITIES`,并带 fallback parser。
|
|
66
|
-
- **DWF/DWFx/XPS 预览**:由 `dwf-viewer` 支持 DWF ZIP 包、W2D 2D
|
|
77
|
+
- **DWF/DWFx/XPS 预览**:由 `dwf-viewer` 支持 DWF ZIP 包、WebGL 加速 W2D 与 XPS/DWFx 2D 矢量、W3D/HSF eModel、XPS 嵌入字体、自适应 CAD 线宽和 raster fallback。
|
|
67
78
|
- **CAD 颜色处理**:支持 ACI、BYLAYER、BYBLOCK 继承、DWG 图层颜色、true color、填充色、透明度和自适应对比度。
|
|
68
79
|
- **WebGL 高性能交互**:GPU retained buffers、空间分桶、视口裁剪、缩放、平移、适配窗口、世界坐标、缩放百分比。
|
|
69
80
|
- **专业 Demo**:拖拽打开、紧凑工具栏、状态条、解析/渲染耗时、实体类型统计、warnings 展示。
|
|
@@ -225,6 +236,7 @@ const viewer = new CadViewer({
|
|
|
225
236
|
canvas, // 也可以传入已有 canvas
|
|
226
237
|
renderer: 'auto', // 'auto' | 'webgl' | 'canvas2d'
|
|
227
238
|
wasmPath: '/wasm', // LibreDWG WebAssembly 资源路径。Worker 场景建议使用绝对路径/URL
|
|
239
|
+
dwfWasmUrl: '/wasm/dwfv-render.wasm',
|
|
228
240
|
autoFit: true,
|
|
229
241
|
canvasOptions: {
|
|
230
242
|
background: '#05070d',
|
|
@@ -243,6 +255,12 @@ const viewer = new CadViewer({
|
|
|
243
255
|
},
|
|
244
256
|
useWorker: true, // DWG 默认开启
|
|
245
257
|
workerTimeoutMs: 0, // 0 表示不限制
|
|
258
|
+
dwfPreferWebgl: true,
|
|
259
|
+
dwfPreferWasm: true,
|
|
260
|
+
dwfMaxCanvasPixels: 16_777_216,
|
|
261
|
+
dwfLineWeightMode: 'adaptive', // 'adaptive' | 'physical' | 'hairline'
|
|
262
|
+
dwfMinStrokeCssPx: 0.42,
|
|
263
|
+
dwfMinTextCssPx: 1.05,
|
|
246
264
|
onLoadProgress(progress) {},
|
|
247
265
|
onLoad(result) {},
|
|
248
266
|
onError(error) {},
|
|
@@ -271,7 +289,7 @@ CadLoaderRegistry
|
|
|
271
289
|
DwgLoader | DxfLoader | DwfLoader | 自定义 loader
|
|
272
290
|
↓
|
|
273
291
|
DWG/DXF:CadDocument → CadWebGLRenderer | CadCanvasRenderer fallback
|
|
274
|
-
DWF/DWFx/XPS:DwfLoader.mount() → dwf-viewer native WebGL/WASM
|
|
292
|
+
DWF/DWFx/XPS:DwfLoader.mount() → dwf-viewer native WebGL 矢量 / 3D / WASM fallback
|
|
275
293
|
```
|
|
276
294
|
|
|
277
295
|
所有 loader 都输出统一的 `CadDocument`:
|
|
@@ -323,8 +341,8 @@ viewer.registerLoader({
|
|
|
323
341
|
|---|---|---|
|
|
324
342
|
| DWG | `DwgLoader` | 使用 LibreDWG WebAssembly。渲染完整度取决于 LibreDWG converter 暴露出的实体。 |
|
|
325
343
|
| DXF | `DxfLoader` | 使用 `dxf-parser` + 内置 fallback。支持基础实体、block/insert、颜色/图层、多段线、文字、hatch boundary、spline 预览。 |
|
|
326
|
-
| DWF | `DwfLoader` + `dwf-viewer` | DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel
|
|
327
|
-
| DWFx / XPS | `DwfLoader` + `dwf-viewer` | DWFx/OPC/XPS 页面,包含 vector path
|
|
344
|
+
| DWF | `DwfLoader` + `dwf-viewer` | DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel、模型树元数据、WebGL 渲染和可选 WASM fallback。 |
|
|
345
|
+
| DWFx / XPS | `DwfLoader` + `dwf-viewer` | DWFx/OPC/XPS 页面,包含 WebGL 加速 vector path、嵌入字体、文本、图片、包内资源和自适应总览线宽,通过原生 DWF 渲染器展示。 |
|
|
328
346
|
|
|
329
347
|
## 颜色处理
|
|
330
348
|
|