208 lines
6.6 KiB
HTML
208 lines
6.6 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>体感交互简单测试</title>
|
||
<style>
|
||
body {
|
||
font-family: Arial, sans-serif;
|
||
padding: 20px;
|
||
background-color: #f5f5f5;
|
||
}
|
||
.container {
|
||
max-width: 600px;
|
||
margin: 0 auto;
|
||
background: white;
|
||
padding: 30px;
|
||
border-radius: 10px;
|
||
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
|
||
text-align: center;
|
||
}
|
||
button {
|
||
background: #4ecdc4;
|
||
color: white;
|
||
border: none;
|
||
padding: 15px 30px;
|
||
border-radius: 5px;
|
||
cursor: pointer;
|
||
margin: 10px;
|
||
font-size: 16px;
|
||
}
|
||
button:hover {
|
||
background: #45b7aa;
|
||
}
|
||
.status {
|
||
margin: 20px 0;
|
||
padding: 15px;
|
||
border-radius: 5px;
|
||
font-weight: bold;
|
||
}
|
||
.success {
|
||
background: #d4edda;
|
||
color: #155724;
|
||
border: 1px solid #c3e6cb;
|
||
}
|
||
.error {
|
||
background: #f8d7da;
|
||
color: #721c24;
|
||
border: 1px solid #f5c6cb;
|
||
}
|
||
.loading {
|
||
background: #d1ecf1;
|
||
color: #0c5460;
|
||
border: 1px solid #bee5eb;
|
||
}
|
||
/* 体感交互容器样式 */
|
||
.box-body {
|
||
position: fixed;
|
||
top: 50%;
|
||
left: 50%;
|
||
transform: translate(-50%, -50%);
|
||
background: rgba(255, 255, 255, 0.95);
|
||
border-radius: 15px;
|
||
padding: 20px;
|
||
box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
|
||
z-index: 2000;
|
||
max-width: 500px;
|
||
text-align: center;
|
||
}
|
||
.box-body img {
|
||
max-width: 100%;
|
||
height: auto;
|
||
border-radius: 10px;
|
||
margin: 10px 0;
|
||
}
|
||
.box-body div {
|
||
margin: 10px 0;
|
||
padding: 5px;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="container">
|
||
<h1>🦾 体感交互简单测试</h1>
|
||
|
||
<p>这个页面用于测试体感交互系统的基本功能。</p>
|
||
|
||
<div id="status" class="status loading">准备测试体感交互功能...</div>
|
||
|
||
<button onclick="startBodySensation()">启动体感交互</button>
|
||
<button onclick="stopBodySensation()">停止体感交互</button>
|
||
<button onclick="checkStatus()">检查状态</button>
|
||
</div>
|
||
|
||
<!-- 体感交互容器(用于directBodySensation.js) -->
|
||
<div class="box-body" style="display: none">
|
||
<div id="bodyConnectionStatus">未连接到服务器</div>
|
||
<img id="bodyVideoFeed" src="" alt="体感检测视频" />
|
||
<div id="bodyHandStatus">等待检测...</div>
|
||
</div>
|
||
|
||
<!-- 引入体感交互脚本 -->
|
||
<script src="../js/directBodySensation.js"></script>
|
||
|
||
<script>
|
||
// 启动体感交互
|
||
function startBodySensation() {
|
||
const statusDiv = document.getElementById("status");
|
||
|
||
try {
|
||
statusDiv.className = "status loading";
|
||
statusDiv.textContent = "正在启动体感交互系统...";
|
||
|
||
// 调用体感交互启动函数
|
||
if (typeof showBody === "function") {
|
||
showBody();
|
||
statusDiv.className = "status success";
|
||
statusDiv.textContent = "✅ 体感交互系统已启动!请允许摄像头权限。";
|
||
} else {
|
||
statusDiv.className = "status error";
|
||
statusDiv.textContent = "❌ 体感交互系统未加载!";
|
||
}
|
||
} catch (error) {
|
||
statusDiv.className = "status error";
|
||
statusDiv.textContent = `❌ 启动体感交互错误: ${error.message}`;
|
||
console.error("启动体感交互错误:", error);
|
||
}
|
||
}
|
||
|
||
// 停止体感交互
|
||
function stopBodySensation() {
|
||
const statusDiv = document.getElementById("status");
|
||
|
||
try {
|
||
statusDiv.className = "status loading";
|
||
statusDiv.textContent = "正在停止体感交互系统...";
|
||
|
||
// 调用体感交互停止函数
|
||
if (typeof showBody === "function") {
|
||
showBody(); // 再次调用会切换状态
|
||
statusDiv.className = "status success";
|
||
statusDiv.textContent = "✅ 体感交互系统已停止!";
|
||
} else {
|
||
statusDiv.className = "status error";
|
||
statusDiv.textContent = "❌ 体感交互系统未加载!";
|
||
}
|
||
} catch (error) {
|
||
statusDiv.className = "status error";
|
||
statusDiv.textContent = `❌ 停止体感交互错误: ${error.message}`;
|
||
console.error("停止体感交互错误:", error);
|
||
}
|
||
}
|
||
|
||
// 检查状态
|
||
function checkStatus() {
|
||
const statusDiv = document.getElementById("status");
|
||
|
||
try {
|
||
// 检查体感交互相关元素
|
||
const bodyContainer = document.querySelector(".box-body");
|
||
const connectionStatus = document.getElementById(
|
||
"bodyConnectionStatus"
|
||
);
|
||
const videoFeed = document.getElementById("bodyVideoFeed");
|
||
const handStatus = document.getElementById("bodyHandStatus");
|
||
|
||
let statusText = `体感交互状态检查:\n`;
|
||
statusText += `- 体感交互容器: ${
|
||
bodyContainer ? "✅ 存在" : "❌ 不存在"
|
||
}\n`;
|
||
statusText += `- 连接状态元素: ${
|
||
connectionStatus ? "✅ 存在" : "❌ 不存在"
|
||
}\n`;
|
||
statusText += `- 视频显示元素: ${
|
||
videoFeed ? "✅ 存在" : "❌ 不存在"
|
||
}\n`;
|
||
statusText += `- 手势状态元素: ${
|
||
handStatus ? "✅ 存在" : "❌ 不存在"
|
||
}\n`;
|
||
|
||
if (bodyContainer && connectionStatus && videoFeed && handStatus) {
|
||
statusText += `\n✅ 所有体感交互元素都已正确添加!`;
|
||
statusDiv.className = "status success";
|
||
} else {
|
||
statusText += `\n❌ 部分体感交互元素缺失!`;
|
||
statusDiv.className = "status error";
|
||
}
|
||
|
||
statusDiv.textContent = statusText;
|
||
} catch (error) {
|
||
statusDiv.className = "status error";
|
||
statusDiv.textContent = `❌ 检查状态错误: ${error.message}`;
|
||
console.error("检查状态错误:", error);
|
||
}
|
||
}
|
||
|
||
// 页面加载完成后自动初始化
|
||
document.addEventListener("DOMContentLoaded", function () {
|
||
console.log("🦾 体感交互简单测试页面已加载");
|
||
|
||
const statusDiv = document.getElementById("status");
|
||
statusDiv.className = "status success";
|
||
statusDiv.textContent = "✅ 页面加载完成!可以开始测试体感交互功能。";
|
||
});
|
||
</script>
|
||
</body>
|
||
</html>
|