three+mediapipe实现摄像头识别人体跳跃蹲下控制三维空间人物避障游戏代码

代码语言:html

所属分类:游戏

代码描述:three+mediapipe实现摄像头识别人体跳跃蹲下控制三维空间人物避障游戏代码,红色的障碍物请跳跃,跳起来,绿的高的障碍物请蹲下,请全身距离摄像头2米左右控制。

代码标签: 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: #050510; font-family: 'Courier New', Courier, monospace; user-select: none; }
        
        /* 游戏画布 */
        #canvas-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }

        /* 摄像头预览 */
        #video-container {
            position: absolute; top: 20px; left: 20px; 
            width: 240px; height: 135px; z-index: 2;
            border: 2px solid #00ffff; box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
            background: #000; overflow: hidden; transform: scaleX(-1);
            opacity: 0.8; border-radius: 8px;
        }
        #input-video { width: 100%; height: 100%; object-fit: cover; }

        /* UI 信息 */
        #ui-layer {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%; 
            z-index: 3; pointer-events: none;
            display: flex; flex-direction: column; align-items: center;
        }
        #score-board { 
            margin-top: 20px; font-size: 40px; color: #fff; 
            text-shadow: 0 0 10px #ff00ff, 2px 2px 0px #000; font-weight: bold; 
            letter-spacing: 2px;
        }
        #status-bar {
            margin-top: 10px; font-size: 18px; color: #00ffff;
            background: rgba(0,0,0,0.6); padding: 5px 20px; border-radius: 20px;
            border: 1px solid rgba(0,255,255,0.3);
        }

        /* 游戏结束 / 暂停 / 加载 遮罩 */
        #overlay-screen {
            position: absolute; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 10;
            display: flex; flex-direction: column; justify-content: center; align-items: center; color: #fff;
            backdrop-filter: blur(5px);
            transition: opacity 0.3s;
        }
        .hidden { opacity: 0; pointer-events: none; }

        .spinner {
            width: 50px; height: 50px; border: 5px solid #333; border-top: 5px solid #00ffff; border-radius: 50%;
            animation: spin 1s linear infinite; margin-bottom: 20px;
        }
        @keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
        
        /* 按钮样式 */
        .cyber-btn {
            pointer-events: auto;
.........完整代码请登录后点击上方下载按钮下载查看

网友评论0