three+mediapipe实现摄像头识别人体左右摇摆姿势身体控制赛车移动游戏代码
代码语言:html
所属分类:游戏
代码描述:three+mediapipe实现摄像头识别人体左右摇摆姿势身体控制赛车移动游戏代码
代码标签: three mediapipe 摄像头 识别 人体 左右 摇摆 姿势 身体 控制 赛车 移动 游戏
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D体感赛车 - 左右闪避</title>
<style>
body { margin: 0; overflow: hidden; background-color: #000; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }
/* 游戏主容器 */
#canvas-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
/* 摄像头预览 - 放在中下方,做成仪表盘的感觉 */
#hud-container {
position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
width: 200px; height: 150px; z-index: 5;
border: 4px solid #00ffff;
border-radius: 10px;
background: #000;
box-shadow: 0 0 20px #00ffff;
overflow: hidden;
}
#input-video {
width: 100%; height: 100%; object-fit: cover;
transform: scaleX(-1); /* 镜像翻转,让操作符合直觉 */
}
#hud-label {
position: absolute; bottom: 0; width: 100%; text-align: center;
background: rgba(0, 255, 255, 0.5); color: #000; font-weight: bold; font-size: 12px;
}
/* 顶部 UI */
#top-ui {
position: absolute; top: 0; left: 0; width: 100%; padding: 20px;
display: flex; justify-content: space-between; box-sizing: border-box;
z-index: 10; pointer-events: none;
}
.ui-text {
color: #fff; font-size: 24px; font-weight: 800; font-style: italic;
text-shadow: 2px 2px 0px #ff00ff;
}
#status-msg { color: #ffff00; text-shadow: none; font-size: 18px; }
/* 游戏结束/开始遮罩 */
#overlay {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
background: rgba(0,0,0,0.85); z-index: 20;
display: flex; flex-direction: column; align-items: center; justify-content: center;
color: #fff; text-align: center;
}
h1 { font-size: 60.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0