225 lines
4.9 KiB
HTML
225 lines
4.9 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="zh-CN">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>3D Viewer Demo</title>
|
|
<style>
|
|
* {
|
|
margin: 0;
|
|
padding: 0;
|
|
box-sizing: border-box;
|
|
}
|
|
|
|
body {
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
|
|
background: #f5f5f5;
|
|
}
|
|
|
|
.container {
|
|
max-width: 1200px;
|
|
margin: 0 auto;
|
|
padding: 20px;
|
|
}
|
|
|
|
h1 {
|
|
margin-bottom: 20px;
|
|
color: #333;
|
|
}
|
|
|
|
.controls {
|
|
background: white;
|
|
padding: 20px;
|
|
border-radius: 8px;
|
|
margin-bottom: 20px;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
.controls button {
|
|
padding: 10px 20px;
|
|
margin-right: 10px;
|
|
margin-bottom: 10px;
|
|
border: none;
|
|
border-radius: 4px;
|
|
background: #007bff;
|
|
color: white;
|
|
cursor: pointer;
|
|
font-size: 14px;
|
|
}
|
|
|
|
.controls button:hover {
|
|
background: #0056b3;
|
|
}
|
|
|
|
.controls input {
|
|
padding: 8px;
|
|
margin-right: 10px;
|
|
border: 1px solid #ddd;
|
|
border-radius: 4px;
|
|
width: 400px;
|
|
}
|
|
|
|
.customization-3d-wrapper {
|
|
position: relative;
|
|
width: 100%;
|
|
height: 600px;
|
|
background: white;
|
|
border-radius: 8px;
|
|
overflow: hidden;
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
[data-3d-container] {
|
|
width: 100%;
|
|
height: 100%;
|
|
position: relative;
|
|
}
|
|
|
|
#preview-3d-viewer {
|
|
width: 100%;
|
|
height: 100%;
|
|
}
|
|
|
|
[data-3d-loading] {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
display: flex;
|
|
flex-direction: column;
|
|
align-items: center;
|
|
justify-content: center;
|
|
background: rgba(255, 255, 255, 0.95);
|
|
z-index: 10;
|
|
}
|
|
|
|
[data-3d-loading] .progress-wrapper {
|
|
width: 200px;
|
|
}
|
|
|
|
[data-3d-progress-bar] {
|
|
width: 0%;
|
|
height: 4px;
|
|
background: #007bff;
|
|
border-radius: 2px;
|
|
transition: width 0.3s;
|
|
}
|
|
|
|
[data-3d-progress-text] {
|
|
margin-top: 10px;
|
|
font-size: 14px;
|
|
color: #666;
|
|
text-align: center;
|
|
}
|
|
|
|
[data-3d-empty] {
|
|
position: absolute;
|
|
top: 0;
|
|
left: 0;
|
|
width: 100%;
|
|
height: 100%;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
color: #999;
|
|
font-size: 16px;
|
|
background: #fafafa;
|
|
}
|
|
</style>
|
|
</head>
|
|
|
|
<body>
|
|
<div class="container">
|
|
<h1>3D Viewer Demo</h1>
|
|
|
|
<div class="controls">
|
|
<div style="margin-bottom: 15px;">
|
|
<input type="text" id="modelUrl" placeholder="输入模型 URL (GLB/GLTF)"
|
|
value="https://sdk.zguiy.com/resurces/model/model.glb">
|
|
</div>
|
|
<button onclick="loadModel()">加载模型</button>
|
|
<button onclick="clearModel()">清除模型</button>
|
|
</div>
|
|
|
|
<div class="customization-3d-wrapper">
|
|
<div data-3d-container>
|
|
<div id="preview-3d-viewer"></div>
|
|
</div>
|
|
|
|
<div data-3d-loading style="display:none;">
|
|
<div class="progress-wrapper">
|
|
<div data-3d-progress-bar></div>
|
|
<div data-3d-progress-text>0%</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div data-3d-empty style="display:flex;">
|
|
暂无模型,请加载一个 3D 模型
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<!-- SDK 脚本 -->
|
|
<script src="https://sdk.zguiy.com/zt/assets/index.global.js"></script>
|
|
|
|
<!-- 3D 查看器核心 -->
|
|
<script src="customization-3d-viewer.js"></script>
|
|
|
|
<!-- 3D 交互层 -->
|
|
<script src="customization-3d-copy.js"></script>
|
|
|
|
<!-- 配置和交互脚本 -->
|
|
<script>
|
|
// 配置环境贴图
|
|
window.CUSTOMIZATION_3D_ENV_URL = 'https://sdk.zguiy.com/resurces/hdr/hdr.env';
|
|
|
|
// 配置热点
|
|
window.CUSTOMIZATION_3D_HOTSPOTS = [
|
|
{
|
|
id: "h1",
|
|
name: "卷帘门",
|
|
meshName: "Valve_01",
|
|
icon: "https://bpic.588ku.com/element_pic/20/06/30/d1046b01afc0b9586844350d131f4daf.jpg!/fw/253/quality/90/unsharp/true/compress/true",
|
|
offset: [25, 25, 0],
|
|
radius: 20,
|
|
color: "#21c7ff",
|
|
payload: { type: "valve", code: "A" },
|
|
},
|
|
];
|
|
|
|
// 热点点击回调
|
|
window.CUSTOMIZATION_3D_ON_HOTSPOT_CLICK = (detail, viewer) => {
|
|
console.log('热点被点击:', detail);
|
|
};
|
|
|
|
// 加载模型
|
|
async function loadModel() {
|
|
const modelUrl = document.getElementById('modelUrl').value.trim();
|
|
|
|
if (!modelUrl) {
|
|
alert('请输入模型 URL');
|
|
return;
|
|
}
|
|
|
|
try {
|
|
await window.Customization3DInteractions.load3DModel(modelUrl, 'demo');
|
|
} catch (err) {
|
|
console.error('模型加载错误:', err);
|
|
}
|
|
}
|
|
|
|
// 清除模型
|
|
async function clearModel() {
|
|
try {
|
|
await window.Customization3DInteractions.clear3DModel();
|
|
} catch (err) {
|
|
console.error('清除模型错误:', err);
|
|
}
|
|
}
|
|
</script>
|
|
</body>
|
|
|
|
</html>
|