|
22 | 22 | AxisGizmoPlugin, |
23 | 23 | BottomBarPlugin, |
24 | 24 | DxfViewer, |
| 25 | + DxfViewerToolbarPlugin, |
25 | 26 | LayerManagerPlugin, |
26 | 27 | MeasurementPlugin, |
| 28 | + ScreenshotPlugin, |
27 | 29 | StatsPlugin, |
28 | 30 | ToolbarMenuId, |
29 | 31 | ViewerEvent, |
|
39 | 41 | }; |
40 | 42 | const viewerCfg = { |
41 | 43 | containerId: "myCanvas", |
42 | | - enableToolbar: true, |
43 | 44 | enableSpinner: true, |
44 | 45 | enableProgressBar: true, |
45 | 46 | enableLayoutBar: true, |
46 | | - toolbarMenuConfig: { |
47 | | - [ToolbarMenuId.Settings]: { |
48 | | - onActive: () => { |
49 | | - console.log("[Toolbar]", "Activate Settings"); |
50 | | - if (!window.dxfSettingsPanel) { |
51 | | - window.dxfSettingsPanel = new DxfSettingsPanel(window.viewer); |
52 | | - } |
53 | | - window.dxfSettingsPanel.show(); |
54 | | - }, |
55 | | - onDeactive: () => { |
56 | | - console.log("[Toolbar]", "Deactivate Settings"); |
57 | | - if (!window.dxfSettingsPanel) { |
58 | | - window.dxfSettingsPanel = new DxfSettingsPanel(window.viewer); |
59 | | - } |
60 | | - window.dxfSettingsPanel.hide(); |
61 | | - }, |
62 | | - }, |
63 | | - [ToolbarMenuId.Layers]: { |
64 | | - onActive: () => { |
65 | | - console.log("[Toolbar]", "Activate Layers"); |
66 | | - if (!window.layerManager) { |
67 | | - window.layerManager = new LayerManagerPlugin(window.viewer); |
68 | | - } |
69 | | - window.layerManager.show(); |
70 | | - }, |
71 | | - onDeactive: () => { |
72 | | - console.log("[Toolbar]", "Deactivate Layers"); |
73 | | - window.layerManager.hide(); |
74 | | - }, |
75 | | - }, |
76 | | - }, |
77 | 47 | }; |
78 | 48 | const viewer = new DxfViewer(viewerCfg); |
79 | | - const fontFiles = ["./demo/three/fonts/hztxt.shx", "./demo/three/fonts/simplex.shx"]; |
| 49 | + const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"]; |
80 | 50 | await viewer.setFont(fontFiles); |
81 | 51 | window.viewer = viewer; |
82 | 52 |
|
| 53 | + const menuConfig = { |
| 54 | + [ToolbarMenuId.Settings]: { |
| 55 | + onActive: () => { |
| 56 | + console.log("[Toolbar]", "Activate Settings"); |
| 57 | + if (!window.dxfSettingsPanel) { |
| 58 | + window.dxfSettingsPanel = new DxfSettingsPanel(window.viewer); |
| 59 | + } |
| 60 | + window.dxfSettingsPanel.show(); |
| 61 | + }, |
| 62 | + onDeactive: () => { |
| 63 | + console.log("[Toolbar]", "Deactivate Settings"); |
| 64 | + window.dxfSettingsPanel.hide(); |
| 65 | + }, |
| 66 | + }, |
| 67 | + [ToolbarMenuId.Layers]: { |
| 68 | + onActive: () => { |
| 69 | + console.log("[Toolbar]", "Activate Layers"); |
| 70 | + if (!window.layerManager) { |
| 71 | + window.layerManager = new LayerManagerPlugin(window.viewer) |
| 72 | + window.layerManager.addEventListener("Visibilitychange", (visible) => { |
| 73 | + window.toolbar.setActive("Layers", visible); |
| 74 | + }); |
| 75 | + } |
| 76 | + window.layerManager.show(); |
| 77 | + }, |
| 78 | + onDeactive: () => { |
| 79 | + console.log("[Toolbar]", "Deactivate Layers"); |
| 80 | + window.layerManager.hide(); |
| 81 | + }, |
| 82 | + }, |
| 83 | + }; |
83 | 84 | new AxisGizmoPlugin(viewer, { ignoreZAxis: true }); |
84 | 85 | new BottomBarPlugin(viewer); |
85 | 86 | new MeasurementPlugin(viewer); |
86 | 87 | new StatsPlugin(viewer); |
| 88 | + new ScreenshotPlugin(viewer); |
| 89 | + window.toolbar = new DxfViewerToolbarPlugin(viewer, { menuConfig }); |
87 | 90 |
|
88 | 91 | const onProgress = (event) => { |
89 | 92 | const progress = ((event.loaded * 100) / event.total).toFixed(1); |
|
118 | 121 | type: "ArrowMarkup", |
119 | 122 | id: "c6ea70a3-ddb0-4dd0-87c8-bd2491936428", |
120 | 123 | lineWidth: 2, |
121 | | - lineColor: "#ff0000", |
122 | | - fillColor: "#ff000030", |
| 124 | + lineColor: [1, 0, 0, 1], |
| 125 | + fillColor: [1, 0, 0, 1], |
123 | 126 | layoutName: "Model", |
124 | 127 | points: [[-15000, -9000], [-11000, -4000]], |
125 | 128 | }, { |
126 | 129 | type: "RectMarkup", |
127 | 130 | id: "82aba74f-7cd6-40e7-bac0-78d95a7bbecd", |
128 | 131 | lineWidth: 2, |
129 | | - lineColor: "#ff0000", |
130 | | - fillColor: "#ff000030", |
| 132 | + lineColor: [1, 0, 0, 1], |
| 133 | + fillColor: [1, 0, 0, 1], |
131 | 134 | layoutName: "Model", |
132 | 135 | points: [[-7000, -1800], [-1000, -5000]], |
133 | 136 | }, { |
134 | 137 | type: "DotMarkup", |
135 | 138 | id: "82aba74f-7cd6-40e7-bac0-78d95a7bbece", |
136 | 139 | lineWidth: 2, |
137 | | - lineColor: "#ff0000", |
138 | | - fillColor: "#ff000030", |
| 140 | + lineColor: [1, 0, 0, 1], |
| 141 | + fillColor: [1, 0, 0, 1], |
139 | 142 | layoutName: "Model", |
140 | 143 | points: [[-7000, -8000]], |
141 | 144 | }]; |
|
0 commit comments