Skip to content

Commit

Permalink
Merge pull request #113 from pattern-x/feature/move-libs
Browse files Browse the repository at this point in the history
Move fonts and draco scripts to under libs folder
  • Loading branch information
yanzexuan1 authored Aug 29, 2023
2 parents 2884756 + 21aed0e commit 59860db
Show file tree
Hide file tree
Showing 35 changed files with 178 additions and 426 deletions.
7 changes: 5 additions & 2 deletions public/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"url": "./demo/bim_3_explode.html"
}]
}, {
"title": "2D drawings",
"title": "2D drawings / PDFs",
"subMenus": [{
"title": "Upload your local dxf",
"title": "Upload your local dxf or pdf",
"url": "./demo/empty_dxf_project.html"
}, {
"title": "Rac basic sample project dwg",
Expand Down Expand Up @@ -48,6 +48,9 @@
}, {
"title": "Building 1&2",
"url": "./demo/dxf_7_building1_2.html"
}, {
"title": "Rac basic sample project pdf",
"url": "./demo/pdf_0.html"
}]
}, {
"title": "Panoramas",
Expand Down
2 changes: 1 addition & 1 deletion public/demo/bim_0.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

// draco decoder path is needed to load draco encoded models.
// gemini-viewer js sdk user maintains draco decoder code somewhere, and provides the path here.
const decoderPath = "./demo/three/js/libs/draco/gltf/";
const decoderPath = "./demo/libs/draco/gltf/";
viewer.setDracoDecoderPath(decoderPath);

viewer.loadModel(modelCfg, (event) => {
Expand Down
2 changes: 1 addition & 1 deletion public/demo/bim_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@

// draco decoder path is needed to load draco encoded models.
// gemini-viewer js sdk user maintains draco decoder code somewhere, and provides the path here.
const decoderPath = "./demo/three/js/libs/draco/gltf/";
const decoderPath = "./demo/libs/draco/gltf/";
viewer.setDracoDecoderPath(decoderPath);

viewer.loadModel(modelCfg, (event) => {
Expand Down
6 changes: 3 additions & 3 deletions public/demo/bim_2_overlay_with_dxf.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@
new SectionPlugin(viewer);

// font file is needed for loading dxf
// const fontFiles = ["./fonts/Microsoft_YaHei_Regular.typeface.json"];
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
// const fontFiles = ["./demo/libs/fonts/Microsoft_YaHei_Regular.typeface.json"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await viewer.setFont(fontFiles);

// draco decoder path is needed to load draco encoded models.
// gemini-viewer js sdk user maintains draco decoder code somewhere, and provides the path here.
const decoderPath = "./demo/three/js/libs/draco/gltf/";
const decoderPath = "./demo/libs/draco/gltf/";
viewer.setDracoDecoderPath(decoderPath);

project.models.forEach((modelCfg) => {
Expand Down
2 changes: 1 addition & 1 deletion public/demo/bim_3_explode.html
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

// draco decoder path is needed to load draco encoded models.
// gemini-viewer js sdk user maintains draco decoder code somewhere, and provides the path here.
const decoderPath = "./demo/three/js/libs/draco/gltf/";
const decoderPath = "./demo/libs/draco/gltf/";
viewer.setDracoDecoderPath(decoderPath);

viewer.loadModel(modelCfg, (event) => {
Expand Down
2 changes: 1 addition & 1 deletion public/demo/dxf_0.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
enableLayoutBar: true,
};
const viewer = new DxfViewer(viewerCfg);
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await viewer.setFont(fontFiles);
window.viewer = viewer;

Expand Down
2 changes: 1 addition & 1 deletion public/demo/dxf_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
enableLayoutBar: true,
};
const viewer = new DxfViewer(viewerCfg);
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await viewer.setFont(fontFiles);
window.viewer = viewer;

Expand Down
2 changes: 1 addition & 1 deletion public/demo/dxf_10_upload_files_to_compre.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
}
);
window.compareHelper = compareHelper;
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await compareHelper.setFont(fontFiles);

const menuConfig = getToolbarMenuConfig(compareHelper.viewer);
Expand Down
2 changes: 1 addition & 1 deletion public/demo/dxf_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
enableLayoutBar: true,
};
const viewer = new DxfViewer(viewerCfg);
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await viewer.setFont(fontFiles);
window.viewer = viewer;

Expand Down
4 changes: 2 additions & 2 deletions public/demo/dxf_3_compare_with_1_viewport.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
enableLayoutBar: true,
};
const compareHelper = new BaseDxfCompareHelper(config);
// const fontFiles = ["./fonts/Microsoft_YaHei_Regular.typeface.json"];
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
// const fontFiles = ["./demo/libs/fonts/Microsoft_YaHei_Regular.typeface.json"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await compareHelper.setFont(fontFiles);
window.compareHelper = compareHelper;

Expand Down
2 changes: 1 addition & 1 deletion public/demo/dxf_5_markups.html
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
enableLayoutBar: true,
};
const viewer = new DxfViewer(viewerCfg);
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await viewer.setFont(fontFiles);
window.viewer = viewer;

Expand Down
2 changes: 1 addition & 1 deletion public/demo/dxf_6_hotpoints.html
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
enableLayoutBar: true,
};
const viewer = new DxfViewer(viewerCfg);
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await viewer.setFont(fontFiles);
window.viewer = viewer;

Expand Down
2 changes: 1 addition & 1 deletion public/demo/dxf_7_building1_2.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
enableLayoutBar: true,
}
const viewer = new DxfViewer(viewerCfg);
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await viewer.setFont(fontFiles);
window.viewer = viewer;

Expand Down
2 changes: 1 addition & 1 deletion public/demo/dxf_8_compare_with_2_viewports.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}
);
window.compareHelper = compareHelper;
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await compareHelper.setFont(fontFiles);

new AxisGizmoPlugin(compareHelper.viewer, { ignoreZAxis: true });
Expand Down
4 changes: 2 additions & 2 deletions public/demo/empty_dxf_project.html
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,8 @@
}

const viewer = new DxfViewer(config);
// const fontFiles = ["./fonts/Microsoft_YaHei_Regular.typeface.json"];
const fontFiles = ["./fonts/hztxt.shx", "./fonts/simplex.shx", "./fonts/arial.ttf", "./fonts/Microsoft_YaHei.ttf"];
// const fontFiles = ["./demo/libs/fonts/Microsoft_YaHei_Regular.typeface.json"];
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx", "./demo/libs/fonts/arial.ttf", "./demo/libs/fonts/Microsoft_YaHei.ttf"];
await viewer.setFont(fontFiles);

window.viewer = viewer;
Expand Down
2 changes: 1 addition & 1 deletion public/demo/empty_model_project.html
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@

// draco decoder path is needed to load draco encoded models.
// gemini-viewer js sdk user maintains draco decoder code somewhere, and provides the path here.
const decoderPath = "./demo/three/js/libs/draco/gltf/";
const decoderPath = "./demo/libs/draco/gltf/";
viewer.setDracoDecoderPath(decoderPath);

// loadProjectModel
Expand Down
Binary file not shown.
115 changes: 115 additions & 0 deletions public/demo/pdf_0.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<html>

<head>
<link rel="icon" href="./demo/favicon.ico">
<link rel="stylesheet" type="text/css" href="./demo/global.css">
<link rel="stylesheet" type="text/css" href="./demo/iconfont/iconfont.css">
<link rel="stylesheet" href="./demo/settings/SettingsPanel.css">
<script src="./demo/libs/pdf/pdf.min.js"></script>
<style>
#myCanvas {
width: 100%;
height: 100%;
overflow: hidden;
}
</style>
</head>

<body>
<div id="app">
<div id="myCanvas" class="container"></div>
</div>
<script type="module">
import {
AxisGizmoPlugin,
BottomBarPlugin,
DxfViewer,
DxfViewerToolbarPlugin,
LayerManagerPlugin,
MeasurementPlugin,
PdfLoaderPlugin,
ProgressBar,
ScreenshotPlugin,
StatsPlugin,
ToolbarMenuId,
FontManager
} from "./demo/libs/gemini-viewer.esm.min.js";
import DxfSettingsPanel from './demo/settings/DxfSettingsPanel.js';

const config = {
containerId: "myCanvas",
language: "en",
enableSpinner: true,
enableProgressBar: true,
enableLayoutBar: true,
};
const viewer = new DxfViewer(config);
const fontFiles = ["./demo/libs/fonts/hztxt.shx", "./demo/libs/fonts/simplex.shx"];
await viewer.setFont(fontFiles);

const menuConfig = {
[ToolbarMenuId.Settings]: {
onActive: () => {
console.log("[Toolbar]", "Activate Settings");
if (!window.dxfSettingsPanel) {
window.dxfSettingsPanel = new DxfSettingsPanel(window.viewer);
}
window.dxfSettingsPanel.show();
},
onDeactive: () => {
console.log("[Toolbar]", "Deactivate Settings");
window.dxfSettingsPanel.hide();
},
},
[ToolbarMenuId.Layers]: {
onActive: () => {
console.log("[Toolbar]", "Activate Layers");
if (!window.layerManager) {
window.layerManager = new LayerManagerPlugin(window.viewer)
window.layerManager.addEventListener("Visibilitychange", (visible) => {
window.toolbar.setActive("Layers", visible);
});
}
window.layerManager.show();
},
onDeactive: () => {
console.log("[Toolbar]", "Deactivate Layers");
window.layerManager.hide();
},
},
};
new AxisGizmoPlugin(viewer, { ignoreZAxis: true });
new BottomBarPlugin(viewer);
new MeasurementPlugin(viewer);
new ScreenshotPlugin(viewer);
new StatsPlugin(viewer);
window.toolbar = new DxfViewerToolbarPlugin(viewer, { menuConfig });

const filename = "rac_basic_sample_project";
const modelCfg = {
modelId: "rac_basic_sample_project",
name: "rac_basic_sample_project",
src: `./demo/models/pdf/${filename}.pdf`,
merge: true,
}
const loadingProgressBar = new ProgressBar(viewer.widgetContainer);
const progressItemId = "progressItemId_0";
loadingProgressBar.addProgressItem(progressItemId);

const onProgress = (event) => {
const progress = (event.loaded * 100) / event.total;
loadingProgressBar?.updateProgress(progressItemId, "Loading", progress);
console.log(`[Demo] Loading '${modelCfg.modelId}' progress: ${progress.toFixed(1)}%`);
};
const pdfLoader = new PdfLoaderPlugin(viewer, { font: viewer.fontManager, pdfWorker: "./demo/libs/pdf/pdf.worker.min.js" });
const model = await pdfLoader.loadAsync(modelCfg, onProgress);
console.log(model);
viewer.addModel(model);
loadingProgressBar.delayRemoveProgressItem(progressItemId);

window.viewer = viewer;

</script>
</body>

</html>
44 changes: 39 additions & 5 deletions public/demo/settings/SettingsPanel.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,21 @@ input[type="checkbox"] {
cursor: pointer;
}

input[type="text"] {
border: 1px solid gray;
padding: 0 2px
}

input[type="button"] {
border: 1px solid gray;
padding: 0 2px;
margin-left: 1px;
cursor: pointer;
}

table {
width: 100%;
width: calc(100% - 10px);
margin: 5px;
}

.panel-container {
Expand All @@ -13,14 +26,15 @@ table {
width: 330px;
height: auto;
border-radius: 4px;
border: 1px solid rgba(0, 0, 0, 0.7);
background-color: rgba(255, 255, 255, 0.7);
z-index: 1000;
/* border: 1px solid rgba(0, 0, 0, 0.7); */
background-color: rgba(255, 255, 255, 0.9);
box-shadow: 1px 3px 10px 0 rgba(0,0,0,.4);
z-index: 1;
overflow: hidden;
}

.panel-container:hover {
background-color: rgba(255, 255, 255, 1);
background-color: rgba(255, 255, 255, 0.95);
}

.panel-hide {
Expand All @@ -43,6 +57,7 @@ table {
height: 40px;
border-bottom: 1px solid #ccc;
background-color: #00000022;
cursor: move;
}

.panel-body {
Expand All @@ -58,3 +73,22 @@ table {
cursor: pointer;
font-size: 0px; /* do not see the text at all */
}

.bim-setting {
list-style: none;
}

.bim-setting li {
list-style: none;
margin: 15px;
}

.bim-setting span {
display: inline-block;
margin-right: 5px;
width: 120px;
}

.bim-setting select {
border: 1px solid #000;
}
32 changes: 0 additions & 32 deletions public/demo/three/js/libs/draco/README.md

This file was deleted.

Loading

0 comments on commit 59860db

Please sign in to comment.