three+webrtc实现双人语音三维构建方块世界代码

代码语言:html

所属分类:三维

代码描述:three+webrtc实现双人语音三维构建方块世界代码,可二维码或链接邀请好友一起探索三维世界

代码标签: three webrtc 双人 语音 三维 构建 方块 世界 代码

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <title>小小方块世界 - 双人探险</title>
    <style>
        body { margin: 0; overflow: hidden; font-family: 'Segoe UI', Tahoma, sans-serif; user-select: none; }
        
        /* 十字准心 */
        #crosshair {
            position: absolute; top: 50%; left: 50%;
            width: 20px; height: 20px;
            background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><path d="M9 0h2v9h9v2h-9v9H9v-9H0V9h9z" fill="rgba(255,255,255,0.8)"/></svg>');
            transform: translate(-50%, -50%);
            pointer-events: none;
            mix-blend-mode: difference;
            z-index: 10;
        }

        /* 物品栏 */
        #toolbar {
            position: absolute; bottom: 20px; left: 50%; transform: translateX(-50%);
            display: flex; gap: 10px; background: rgba(0,0,0,0.5); padding: 10px; border-radius: 8px;
        }
        .slot {
            width: 40px; height: 40px; border: 3px solid #555; cursor: pointer;
            transition: transform 0.1s; position: relative;
        }
        .slot.active { border-color: white; transform: scale(1.1); box-shadow: 0 0 10px white; }
        /* 生成简单的材质预览图 */
        .slot[data-type="1"] { background: #5bac28; } /* 草 */
        .slot[data-type="2"] { background: #8b5a2b; } /* 土 */
        .slot[data-type="3"] { background: #7a7a7a; } /* 石 */
        .slot[data-type="4"] { background: #a05f2c; } /* 木 */
        .slot[data-type="5"] { background: #ffd700; } /* 金 (宝藏) */

        /* 菜单 */
        #menu {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.8); display: flex; flex-direction: column;
            align-items: center; justify-content: center; color: white; z-index: 100;
        }
        h1 { font-family: "Courier New", monospace; text-shadow: 4px 4px 0 #000; font-size: 3rem; margin-bottom: 20px; color: #5bac28; }
        .panel { background: rgba(255,255,255,0.1); padding: 30px; border-radius: 10px; text-align: center; backdrop-filter: blur(5px); }
        button {
            padding: 12px 24px; font-size: 1.2rem; cursor: pointer; border: none;
            background: #2ecc71; color: white; border-radius: 5px; margin-top: 15px;
            font-weight: bold; box-shadow: 0 4px 0 #27ae60;
        }
        button:active { transform: translateY(4px); box-shadow: none; }
        
        .status-bar {
            position: absolute; top: 10px; left: 10px; color: white; 
            text-shadow: 1px 1px 2px black.........完整代码请登录后点击上方下载按钮下载查看

网友评论0