|
1 | | -# dxf-viewer-examples |
2 | | -Examples for viewing DXF files using Three.js. |
3 | | -- [Online examples](https://dxf.thingraph.site/) |
| 1 | +## dxf-viewer-examples |
| 2 | + |
| 3 | +Examples showing how to view **2D DXF/DWG drawings** in the browser using the `@x-viewer/core` 2D viewer engine (WebGL/Three.js based). |
| 4 | + |
| 5 | +- **Online demos**: [Online examples](https://dxf.thingraph.site/) |
4 | 6 |
|
5 | 7 | ## Run examples |
6 | | -``` |
| 8 | + |
| 9 | +```bash |
| 10 | +npm install |
7 | 11 | npm start |
8 | 12 | ``` |
9 | 13 |
|
10 | | -# dxf-viewer |
11 | | -This example project is built on a WebGL based JS SDK, which provides a Viewer2d. |
| 14 | +The dev server will start and you can open the examples in your browser. |
| 15 | + |
| 16 | +--- |
| 17 | + |
| 18 | +## About @x-viewer/core |
| 19 | + |
| 20 | +The examples in this repo are built on top of `@x-viewer/core`, focusing on the **Viewer2d** for DXF/DWG drawings. |
| 21 | +It includes DXF/DWG parsing and 2D rendering, layer control, layouts, measurements, markups and other utilities for building 2D drawing applications. |
| 22 | + |
| 23 | +### Features |
12 | 24 |
|
13 | | -### Viewer2d |
14 | | -The Viewer2d class is utilized for viewing 2D drawings and PDF. To work with DWG files, they need to be converted to DXF format first using the dwg2dxf.exe worker. The tool supports most common entity types, OLE, and regions via dwg2dxf conversion. It also supports common line types, hatch styles, and line widths. |
| 25 | +- High-performance 2D rendering: WebGL-based rendering engine built on Three.js |
| 26 | +- DXF/DWG support: Parse and render DXF/DWG files entirely in the browser without backend server |
| 27 | +- Rich 2D tools: layers, layouts, osnaps, distance/area/angle measurements, markups, comparison, screenshots, etc. |
| 28 | +- Modular architecture: Designed for extensibility and seamless integration |
| 29 | +- TypeScript: Full TypeScript support with comprehensive type definitions |
15 | 30 |
|
16 | | -### Example |
17 | | -``` typescript |
18 | | -import { Viewer2d, Viewer2dConfig, ModelConfig } from "dxf-viewer"; |
| 31 | +### Install @x-viewer/core (use in your own project) |
19 | 32 |
|
20 | | -const viewerCfg: Viewer2dConfig = { |
| 33 | +```bash |
| 34 | +npm install @x-viewer/core |
| 35 | +# or |
| 36 | +pnpm add @x-viewer/core |
| 37 | +# or |
| 38 | +yarn add @x-viewer/core |
| 39 | +``` |
| 40 | + |
| 41 | +### Quick Start – Viewer2d (DXF/DWG Viewer) |
| 42 | + |
| 43 | +```typescript |
| 44 | +import { Viewer2d } from "@x-viewer/core"; |
| 45 | + |
| 46 | +// Create a 2D viewer |
| 47 | +const viewerCfg = { |
21 | 48 | containerId: "myCanvas", |
22 | 49 | enableSpinner: true, |
23 | 50 | enableLayoutBar: true, |
24 | 51 | }; |
25 | | -const modelCfg: ModelConfig = { |
| 52 | + |
| 53 | +const modelCfg = { |
26 | 54 | modelId: "id_0", |
27 | 55 | name: "sample", |
28 | 56 | src: "http://www.abc.com/sample.dxf", |
@@ -79,3 +107,11 @@ viewer.goToHomeView(); |
79 | 107 |
|
80 | 108 | ### Contact Us |
81 | 109 | - For any inquiries or support, please contact us at [thingraph@outlook.com](mailto:thingraph@outlook.com). |
| 110 | + |
| 111 | +--- |
| 112 | + |
| 113 | +## Related Packages |
| 114 | + |
| 115 | +- `@x-viewer/core` – Core viewer engine (2D/3D) |
| 116 | +- `@x-viewer/plugins` – Extensible functionality modules |
| 117 | +- `@x-viewer/ui` – Reusable UI components |
0 commit comments