@flyfish-dev/cad-viewer 0.6.0 → 0.6.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/NOTICE +1 -1
- package/README.md +15 -6
- package/README.zh-CN.md +19 -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,16 @@ 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.1
|
|
16
|
+
|
|
17
|
+
- Updated the native DWF path to `dwf-viewer` 0.6.1.
|
|
18
|
+
- 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.
|
|
19
|
+
- Exposed DWF/XPS overview tuning through `dwfLineWeightMode`, `dwfMinStrokeCssPx`, `dwfMaxOverviewStrokeCssPx`, `dwfMinTextCssPx` and `dwfMinFilledAreaCssPx`.
|
|
20
|
+
- Refreshed README, format notes, architecture notes and package metadata for the latest DWF support.
|
|
15
21
|
|
|
16
22
|
## What changed in 0.6.0
|
|
17
23
|
|
|
@@ -63,7 +69,7 @@ The project provides a clean loader architecture for **DWG**, **DXF**, **DWF**,
|
|
|
63
69
|
- **Loader registry**: DWG, DXF and DWF loaders are independent and replaceable; native-renderable loaders can mount their own optimized viewer.
|
|
64
70
|
- **DWG preview**: browser-local parsing through LibreDWG WebAssembly, executed in a Web Worker by default.
|
|
65
71
|
- **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
|
|
72
|
+
- **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
73
|
- **CAD color handling**: ACI, BYLAYER, BYBLOCK inheritance, DWG layer colors, true color, fill color, opacity and adaptive contrast.
|
|
68
74
|
- **High-performance WebGL viewport controls**: retained GPU buffers, spatial culling, zoom, pan, fit-to-view, cursor world coordinates and zoom percentage.
|
|
69
75
|
- **Professional demo UI**: drag-and-drop, compact toolbar, status strip, parse/render timing, entity summary and warnings.
|
|
@@ -247,6 +253,9 @@ const viewer = new CadViewer({
|
|
|
247
253
|
dwfPreferWebgl: true,
|
|
248
254
|
dwfPreferWasm: true,
|
|
249
255
|
dwfMaxCanvasPixels: 16_777_216,
|
|
256
|
+
dwfLineWeightMode: 'adaptive', // 'adaptive' | 'physical' | 'hairline'
|
|
257
|
+
dwfMinStrokeCssPx: 0.42,
|
|
258
|
+
dwfMinTextCssPx: 1.05,
|
|
250
259
|
onLoadProgress(progress) {},
|
|
251
260
|
onLoad(result) {},
|
|
252
261
|
onError(error) {},
|
|
@@ -275,7 +284,7 @@ CadLoaderRegistry
|
|
|
275
284
|
DwgLoader | DxfLoader | DwfLoader | custom loader
|
|
276
285
|
↓
|
|
277
286
|
DWG/DXF: CadDocument → CadWebGLRenderer | CadCanvasRenderer fallback
|
|
278
|
-
DWF/DWFx/XPS: DwfLoader.mount() → dwf-viewer native WebGL/WASM
|
|
287
|
+
DWF/DWFx/XPS: DwfLoader.mount() → dwf-viewer native WebGL vectors / 3D / WASM fallback
|
|
279
288
|
```
|
|
280
289
|
|
|
281
290
|
Each loader returns a normalized `CadDocument`:
|
|
@@ -327,8 +336,8 @@ viewer.registerLoader({
|
|
|
327
336
|
|---|---|---|
|
|
328
337
|
| DWG | `DwgLoader` | Uses LibreDWG WebAssembly. Rendering coverage depends on the entities exposed by LibreDWG conversion. |
|
|
329
338
|
| 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
|
|
339
|
+
| 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. |
|
|
340
|
+
| 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
341
|
|
|
333
342
|
## Color handling
|
|
334
343
|
|
package/README.zh-CN.md
CHANGED
|
@@ -8,10 +8,16 @@
|
|
|
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.1 变更
|
|
16
|
+
|
|
17
|
+
- 原生 DWF 通道升级到 `dwf-viewer` 0.6.1。
|
|
18
|
+
- 同步最新 renderer 行为:WebGL 加速 XPS/DWFx 与 W2D 2D 矢量渲染、W3D/HSF 3D 渲染、XPS 嵌入字体加载和可选 WASM raster fallback。
|
|
19
|
+
- 新增 `dwfLineWeightMode`、`dwfMinStrokeCssPx`、`dwfMaxOverviewStrokeCssPx`、`dwfMinTextCssPx`、`dwfMinFilledAreaCssPx`,用于调节 DWF/XPS 总览渲染效果。
|
|
20
|
+
- 更新 README、格式说明、架构说明和 package metadata,统一最新版 DWF 支持口径。
|
|
15
21
|
|
|
16
22
|
## 0.6.0 变更
|
|
17
23
|
|
|
@@ -63,7 +69,7 @@
|
|
|
63
69
|
- **正确的 loader 架构**:DWG / DXF / DWF 独立 loader,可替换、可扩展;native-renderable loader 可以挂载自己的优化渲染器。
|
|
64
70
|
- **DWG 预览**:通过 LibreDWG WebAssembly 在浏览器本地解析,默认在 Web Worker 中执行。
|
|
65
71
|
- **DXF 预览**:JavaScript 解析,支持常见 ASCII DXF `ENTITIES`,并带 fallback parser。
|
|
66
|
-
- **DWF/DWFx/XPS 预览**:由 `dwf-viewer` 支持 DWF ZIP 包、W2D 2D
|
|
72
|
+
- **DWF/DWFx/XPS 预览**:由 `dwf-viewer` 支持 DWF ZIP 包、WebGL 加速 W2D 与 XPS/DWFx 2D 矢量、W3D/HSF eModel、XPS 嵌入字体、自适应 CAD 线宽和 raster fallback。
|
|
67
73
|
- **CAD 颜色处理**:支持 ACI、BYLAYER、BYBLOCK 继承、DWG 图层颜色、true color、填充色、透明度和自适应对比度。
|
|
68
74
|
- **WebGL 高性能交互**:GPU retained buffers、空间分桶、视口裁剪、缩放、平移、适配窗口、世界坐标、缩放百分比。
|
|
69
75
|
- **专业 Demo**:拖拽打开、紧凑工具栏、状态条、解析/渲染耗时、实体类型统计、warnings 展示。
|
|
@@ -225,6 +231,7 @@ const viewer = new CadViewer({
|
|
|
225
231
|
canvas, // 也可以传入已有 canvas
|
|
226
232
|
renderer: 'auto', // 'auto' | 'webgl' | 'canvas2d'
|
|
227
233
|
wasmPath: '/wasm', // LibreDWG WebAssembly 资源路径。Worker 场景建议使用绝对路径/URL
|
|
234
|
+
dwfWasmUrl: '/wasm/dwfv-render.wasm',
|
|
228
235
|
autoFit: true,
|
|
229
236
|
canvasOptions: {
|
|
230
237
|
background: '#05070d',
|
|
@@ -243,6 +250,12 @@ const viewer = new CadViewer({
|
|
|
243
250
|
},
|
|
244
251
|
useWorker: true, // DWG 默认开启
|
|
245
252
|
workerTimeoutMs: 0, // 0 表示不限制
|
|
253
|
+
dwfPreferWebgl: true,
|
|
254
|
+
dwfPreferWasm: true,
|
|
255
|
+
dwfMaxCanvasPixels: 16_777_216,
|
|
256
|
+
dwfLineWeightMode: 'adaptive', // 'adaptive' | 'physical' | 'hairline'
|
|
257
|
+
dwfMinStrokeCssPx: 0.42,
|
|
258
|
+
dwfMinTextCssPx: 1.05,
|
|
246
259
|
onLoadProgress(progress) {},
|
|
247
260
|
onLoad(result) {},
|
|
248
261
|
onError(error) {},
|
|
@@ -271,7 +284,7 @@ CadLoaderRegistry
|
|
|
271
284
|
DwgLoader | DxfLoader | DwfLoader | 自定义 loader
|
|
272
285
|
↓
|
|
273
286
|
DWG/DXF:CadDocument → CadWebGLRenderer | CadCanvasRenderer fallback
|
|
274
|
-
DWF/DWFx/XPS:DwfLoader.mount() → dwf-viewer native WebGL/WASM
|
|
287
|
+
DWF/DWFx/XPS:DwfLoader.mount() → dwf-viewer native WebGL 矢量 / 3D / WASM fallback
|
|
275
288
|
```
|
|
276
289
|
|
|
277
290
|
所有 loader 都输出统一的 `CadDocument`:
|
|
@@ -323,8 +336,8 @@ viewer.registerLoader({
|
|
|
323
336
|
|---|---|---|
|
|
324
337
|
| DWG | `DwgLoader` | 使用 LibreDWG WebAssembly。渲染完整度取决于 LibreDWG converter 暴露出的实体。 |
|
|
325
338
|
| 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
|
|
339
|
+
| DWF | `DwfLoader` + `dwf-viewer` | DWF 6+ ZIP 包、WHIP/W2D 2D 图纸、W3D/HSF 3D eModel、模型树元数据、WebGL 渲染和可选 WASM fallback。 |
|
|
340
|
+
| DWFx / XPS | `DwfLoader` + `dwf-viewer` | DWFx/OPC/XPS 页面,包含 WebGL 加速 vector path、嵌入字体、文本、图片、包内资源和自适应总览线宽,通过原生 DWF 渲染器展示。 |
|
|
328
341
|
|
|
329
342
|
## 颜色处理
|
|
330
343
|
|