Files
gemini-viewer-examples/public/demo/empty_model_project.html
2023-07-15 00:28:57 +08:00

143 lines
4.7 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<html>
<head>
<link rel="icon" href="./demo/favicon.ico" />
<link rel="stylesheet" type="text/css" href="./demo/global.css" />
<style>
#myCanvas {
width: 100%;
height: 100%;
}
.upload-btn {
margin-top: 2em;
}
.upload-btn button {
width: 0.1px;
height: 0.1px;
opacity: 0;
overflow: hidden;
position: absolute;
z-index: -1;
}
.upload-btn label {
color: #353535;
border: 0;
border-radius: 3px;
transition: ease 0.2s;
transition-property: background;
font-size: 1rem;
font-weight: 700;
text-overflow: ellipsis;
white-space: nowrap;
cursor: pointer;
display: inline-block;
overflow: hidden;
padding: 0.625rem 1.25rem;
}
.upload-btn label:hover {
background: #DDD;
}
.upload-btn svg {
width: 1em;
height: 1em;
vertical-align: middle;
fill: currentColor;
margin-top: -0.25em;
margin-right: 0.25em;
}
</style>
</head>
<body>
<div id="app">
<div id="myCanvas" class="container"></div>
</div>
<div style="position: absolute; top: 10px; opacity: 0.6; width: 100%;text-align: center;">
<div class="upload-btn" id="uploadBtn">
<button id="uploadModelFile" type="button">点此上传本地模型文件</button>
<label for="uploadModelFile" title="支持 gltf, dxf, obj, stl, fbx, ifc, dae等。只支持单模型文件不支持链接文件。也就是几何体、材质都要内嵌在单一模型文件中。">
<svg xmlns="http://www.w3.org/2000/svg" width="20" height="17" viewBox="0 0 20 17"><path d="M10 0l-5.2 4.9h3.3v5.1h3.8v-5.1h3.3l-5.2-4.9zm9.3 11.5l-3.2-2.1h-2l3.4 2.6h-3.5c-.1 0-.2.1-.2.1l-.8 2.3h-6l-.8-2.2c-.1-.1-.1-.2-.2-.2h-3.6l3.4-2.6h-2l-3.2 2.1c-.4.3-.7 1-.6 1.5l.6 3.1c.1.5.7.9 1.2.9h16.3c.6 0 1.1-.4 1.3-.9l.6-3.1c.1-.5-.2-1.2-.7-1.5z"></path></svg>
<span>Upload model</span>
</label>
</div>
</div>
<script type="module">
import {
AxisGizmoPlugin,
BimViewer,
BottomBarPlugin,
GroundShadowPlugin,
LocalModelUploader,
MeasurementPlugin,
NavCubePlugin,
SectionPlugin,
ToolbarMenuId,
} from "./demo/libs/gemini-viewer.esm.min.js";
const project = {
id: "empty_project",
name: "Empty project",
camera: {
},
models: [{
"name": "model 01",
"src": "",
"rotation": [0, 0, 0],
"scale": [1, 1, 1],
"merge": false,
"visible": false
}],
};
const viewer = new BimViewer(
{
containerId: "myCanvas",
toolbarMenuConfig: {
[ToolbarMenuId.BimTree]: { visible: false },
},
enableContextMenu: true,
},
project.camera
);
new AxisGizmoPlugin(viewer);
new BottomBarPlugin(viewer);
new GroundShadowPlugin(viewer);
new MeasurementPlugin(viewer);
new NavCubePlugin(viewer);
new SectionPlugin(viewer);
// 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/";
viewer.setDracoDecoderPath(decoderPath);
// loadProjectModel
let counter = 0; // to indicate how many models are loading
project.models.forEach((modelCfg) => {
if (modelCfg.visible === false) {
// visible is true by default
return; // only load visible ones
}
counter++;
viewer.loadModel(modelCfg, (event) => {
console.log(`[Demo] Loading model ${modelCfg.src}`);
}, (event) => {
console.error(`[Demo] Failed to load ${modelCfg.src}. " + event.message`);
}
).then(() => {
console.log(`[Demo] Loaded model ${modelCfg.src}`);
});
});
const modelUploader = new LocalModelUploader(viewer);
document.getElementById("uploadModelFile").onclick = function() {
modelUploader.openFileBrowserToUpload();
}
</script>
</body>
</html>