Skip to content

Commit 2884756

Browse files
authored
Merge pull request #112 from pattern-x/feature/upgrade
Upgrade gemini-viewer-threejs and update demo pages
2 parents 40cb8ea + a9216fd commit 2884756

24 files changed

+698
-721
lines changed

public/config.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,6 @@
4242
}, {
4343
"title": "Markups",
4444
"url": "./demo/dxf_5_markups.html"
45-
}, {
46-
"title": "Take screenshot via markup",
47-
"url": "./demo/dxf_9_screenshot.html"
4845
}, {
4946
"title": "Hotpoints",
5047
"url": "./demo/dxf_6_hotpoints.html"

public/demo/bim_0.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import {
2020
AxisGizmoPlugin,
2121
BimViewer,
22+
BimViewerToolbarPlugin,
23+
ContextMenuPlugin,
2224
MeasurementPlugin,
2325
NavCubePlugin,
2426
SectionPlugin,
@@ -39,10 +41,14 @@
3941
enableProgressBar: true,
4042
}
4143
const viewer = new BimViewer(viewerCfg);
42-
const toolbar = viewer.toolbar;
43-
toolbar.updateMenu(ToolbarMenuId.BimTree, { visible: false });
4444

45+
const menuConfig = {
46+
[ToolbarMenuId.Measure]: { visible: true },
47+
[ToolbarMenuId.Fullscreen]: { visible: false },
48+
};
4549
new AxisGizmoPlugin(viewer);
50+
new BimViewerToolbarPlugin(viewer, { menuConfig });
51+
new ContextMenuPlugin(viewer);
4652
new MeasurementPlugin(viewer);
4753
new NavCubePlugin(viewer);
4854
new SectionPlugin(viewer);

public/demo/bim_1.html

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@
1919
import {
2020
AxisGizmoPlugin,
2121
BimViewer,
22+
BimViewerToolbarPlugin,
2223
BottomBarPlugin,
24+
ContextMenuPlugin,
2325
GroundShadowPlugin,
2426
NavCubePlugin,
25-
ToolbarMenuId,
2627
} from "./demo/libs/gemini-viewer.esm.min.js";
2728

2829
const filename = "Duplex.gltf";
@@ -35,18 +36,14 @@
3536
const viewerCfg = {
3637
containerId: "myCanvas",
3738
language: "en",
38-
toolbarMenuConfig: {
39-
[ToolbarMenuId.Measure]: { visible: false },
40-
[ToolbarMenuId.Fullscreen]: { visible: false },
41-
[ToolbarMenuId.BimTree]: { visible: false },
42-
},
43-
enableContextMenu: true,
4439
enableProgressBar: true,
4540
}
4641
const viewer = new BimViewer(viewerCfg);
4742

4843
new AxisGizmoPlugin(viewer);
44+
new BimViewerToolbarPlugin(viewer);
4945
new BottomBarPlugin(viewer);
46+
new ContextMenuPlugin(viewer);
5047
new GroundShadowPlugin(viewer);
5148
new NavCubePlugin(viewer);
5249

public/demo/bim_2_overlay_with_dxf.html

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
import {
2020
AxisGizmoPlugin,
2121
BimViewer,
22+
BimViewerToolbarPlugin,
2223
MeasurementPlugin,
2324
NavCubePlugin,
2425
SectionPlugin,
25-
ToolbarMenuId,
2626
} from "./demo/libs/gemini-viewer.esm.min.js";
2727

2828
const project = {
@@ -50,17 +50,16 @@
5050
const viewer = new BimViewer({
5151
containerId: "myCanvas",
5252
});
53-
const toolbar = viewer.toolbar;
54-
toolbar.updateMenu(ToolbarMenuId.BimTree, { visible: false });
5553

5654
new AxisGizmoPlugin(viewer);
55+
new BimViewerToolbarPlugin(viewer);
5756
new MeasurementPlugin(viewer);
5857
new NavCubePlugin(viewer);
5958
new SectionPlugin(viewer);
6059

6160
// font file is needed for loading dxf
62-
// const fontFiles = ["./demo/three/fonts/Microsoft_YaHei_Regular.typeface.json"];
63-
const fontFiles = ["./demo/three/fonts/hztxt.shx", "./demo/three/fonts/simplex.shx"];
61+
// const fontFiles = ["./fonts/Microsoft_YaHei_Regular.typeface.json"];
62+
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
6463
await viewer.setFont(fontFiles);
6564

6665
// draco decoder path is needed to load draco encoded models.

public/demo/dxf_0.html

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
AxisGizmoPlugin,
2323
BottomBarPlugin,
2424
DxfViewer,
25+
DxfViewerToolbarPlugin,
2526
LayerManagerPlugin,
2627
MeasurementPlugin,
28+
ScreenshotPlugin,
2729
StatsPlugin,
2830
ToolbarMenuId,
2931
ViewerEvent,
@@ -39,51 +41,52 @@
3941
};
4042
const viewerCfg = {
4143
containerId: "myCanvas",
42-
enableToolbar: true,
4344
enableSpinner: true,
4445
enableProgressBar: true,
4546
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-
},
7747
};
7848
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"];
8050
await viewer.setFont(fontFiles);
8151
window.viewer = viewer;
8252

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+
};
8384
new AxisGizmoPlugin(viewer, { ignoreZAxis: true });
8485
new BottomBarPlugin(viewer);
8586
new MeasurementPlugin(viewer);
8687
new StatsPlugin(viewer);
88+
new ScreenshotPlugin(viewer);
89+
window.toolbar = new DxfViewerToolbarPlugin(viewer, { menuConfig });
8790

8891
const onProgress = (event) => {
8992
const progress = ((event.loaded * 100) / event.total).toFixed(1);
@@ -118,24 +121,24 @@
118121
type: "ArrowMarkup",
119122
id: "c6ea70a3-ddb0-4dd0-87c8-bd2491936428",
120123
lineWidth: 2,
121-
lineColor: "#ff0000",
122-
fillColor: "#ff000030",
124+
lineColor: [1, 0, 0, 1],
125+
fillColor: [1, 0, 0, 1],
123126
layoutName: "Model",
124127
points: [[-15000, -9000], [-11000, -4000]],
125128
}, {
126129
type: "RectMarkup",
127130
id: "82aba74f-7cd6-40e7-bac0-78d95a7bbecd",
128131
lineWidth: 2,
129-
lineColor: "#ff0000",
130-
fillColor: "#ff000030",
132+
lineColor: [1, 0, 0, 1],
133+
fillColor: [1, 0, 0, 1],
131134
layoutName: "Model",
132135
points: [[-7000, -1800], [-1000, -5000]],
133136
}, {
134137
type: "DotMarkup",
135138
id: "82aba74f-7cd6-40e7-bac0-78d95a7bbece",
136139
lineWidth: 2,
137-
lineColor: "#ff0000",
138-
fillColor: "#ff000030",
140+
lineColor: [1, 0, 0, 1],
141+
fillColor: [1, 0, 0, 1],
139142
layoutName: "Model",
140143
points: [[-7000, -8000]],
141144
}];

public/demo/dxf_1.html

Lines changed: 36 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@
2222
AxisGizmoPlugin,
2323
BottomBarPlugin,
2424
DxfViewer,
25+
DxfViewerToolbarPlugin,
2526
LayerManagerPlugin,
2627
MeasurementPlugin,
28+
ScreenshotPlugin,
2729
StatsPlugin,
2830
ToolbarMenuId,
2931
ViewerEvent,
@@ -39,51 +41,52 @@
3941
};
4042
const viewerCfg = {
4143
containerId: "myCanvas",
42-
enableToolbar: true,
4344
enableSpinner: true,
4445
enableProgressBar: true,
4546
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-
},
7747
};
7848
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"];
8050
await viewer.setFont(fontFiles);
8151
window.viewer = viewer;
8252

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+
};
8384
new AxisGizmoPlugin(viewer);
8485
new BottomBarPlugin(viewer);
8586
new MeasurementPlugin(viewer);
8687
new StatsPlugin(viewer);
88+
new ScreenshotPlugin(viewer);
89+
window.toolbar = new DxfViewerToolbarPlugin(viewer, { menuConfig });
8790

8891
const onProgress = (event) => {
8992
const progress = ((event.loaded * 100) / event.total).toFixed(1);

0 commit comments

Comments
 (0)