three实现三维深林瀑布马儿喝水体验代码

代码语言:html

所属分类:三维

代码描述:three实现三维深林瀑布马儿喝水体验代码

代码标签: three 三维 深林 瀑布 马儿 喝水 体验 代码

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

<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <title>三维森林瀑布与骏马生态模拟 - Three.js</title>
  <style>
    * { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
    body, html {
      width: 100%; height: 100%; overflow: hidden;
      background: #0d151c;
      font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
      color: #f0f4f8;
    }
    #canvas-container { width: 100%; height: 100%; position: fixed; inset: 0; }

    /* HUD 界面 */
    .hud-panel {
      position: fixed;
      background: rgba(12, 20, 28, 0.62);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      border: 1px solid rgba(255, 255, 255, 0.14);
      border-radius: 14px;
      padding: 14px 18px;
      box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
      pointer-events: auto;
      z-index: 10;
    }

    #status-panel { top: 18px; left: 18px; width: 290px; }
    #weather-panel { top: 18px; right: 18px; width: 260px; }
    #controls-panel {
      bottom: 18px; left: 18px;
      font-size: 12.5px; line-height: 1.7;
      color: rgba(240, 244, 248, 0.85);
    }

    .title-row {
      display: flex; align-items: center; justify-content: space-between;
      margin-bottom: 10px; font-weight: 600; font-size: 15px;
    }

    .badge {
      font-size: 11px; padding: 2px 8px; border-radius: 999px;
      background: rgba(255, 255, 255, 0.15); font-weight: 500;
    }

    .bar-label {
      display: flex; justify-content: space-between;
      font-size: 12px; margin-bottom: 5px; color: #cbd5e1;
    }

    .progress-track {
      width: 100%; height: 10px; border-radius: 999px;
      background: rgba(255, 255, 255, 0.12); overflow: hidden;
      margin-bottom: 10px;
    }

    .progress-fill {
      height: 100%; width: 100%; border-radius: 999px;
      transition: width 0.2s linear, background-color 0.3s ease;
    }

    #thirst-alert {
      display: none;
      margin-top: 6px; padding: 8px 10px; border-radius: 8px;
      background: rgba(239, 68, 68, 0.24);
      border: 1px solid rgba(248, 113, 113, 0.5);
      color: #fecaca; font-size: 12.5px; line-height: 1.45;
      animation: pulse 1.6s infinite;
    }

    #drink-prompt {
      position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
      background: rgba(14, 116, 144, 0.85);
      border: 1px solid rgba(103, 232, 249, 0.6);
      padding: 10px 22px; border-radius: 999px;
      font-size: 14px; font-weight: 600; color: #ecfeff;
      box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
      display: none; z-index: 12;
      backdrop-filter: blur(8px);
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.65; }
    }

    .btn-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
    button {
      border: 1px solid rgba(255, 255, 255, 0.18);
      background: rgba(255, 255, 255, 0.1);
      color: #f8fafc; border-radius: 8px;
      padding: 6px 10px; font-size: 12px; cursor: pointer;
      transition: all 0.2s ease;
    }
    button:hover { background: rgba(255, 255, 255, 0.22); }
    button.active {
      background: rgba(56, 189, 248, 0.35);
      border-color: rgba(56, 189, 248, 0.8);
      color: #e0f2fe;
    }

    .compass-box {
      display: flex; align-items: center; gap: 8px;
      font-size: 12px; color: #94a3b8; margin-top: 6px;
    }
    #water-arrow {
      display: inline-block; font-size: 16px; color: #38bdf8;
      transition: transform 0.1s linear;
    }

    .key {
      display: inline-block; padding: 1px 6px; margin: 0 2px;
      border-radius: 4px; background: rgba(255, 255, 255, 0.16);
      border: 1px solid rgba(255, 255, 255, 0.22);
      font-family: monospace; font-size: 11px; color: #fff;
    }

    #loading {
      position: fixed; inset: 0; background: #0b131a;
      display: flex; flex-direction: column; align-items: center; justify-content: center;
      z-index: 100; transition: opacity 0.6s ease;
    }
    #loading h2 { font-weight: 500; letter-spacing: 1px; margin-bottom: 8px; }
    #loading p { color: #94a3b8; font-size: 13px; }
  </style>

  <script type="importmap">
    {
      "imports": {
        "three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js",
        "three/addons/": "https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"
      }
    }
  </script>
</head>
<body>
  <div id="loading">
    <h2>正在构建三维森林与瀑布生态...</h2>
    <p>生成地形山脉、树木水系、气候系统与骏马模型</p>
  </div>

  <div id="canvas-container"></div>

  <!-- 左上角:马匹状态面板 -->
  <div id="status-panel" class="hud-panel">
    <div class="title-row">
      <span>🐎 骏马状态</span>
      <span id="gait-badge" class="badge">静止</span>
    </div>

    <div class="bar-label">
      <span>水分充足度</span>
      <span id="hydration-text">100%</span>
    </div>
    <div class="progress-track">
      <div id="hydration-bar" class="progress-fill" style="background: #38bdf8;"></div>
    </div>

    <div class="compass-box">
      <span id="water-arrow">➤</span>
      <span id="water-dist-text">距离最近水源: -- m</span>
    </div>

    <div class="btn-row" style="margin-top: 10px;">
      <button id="btn-autopilot">🤖 开启自动寻水</button>
      <button id="btn-make-thirsty">💧 模拟口渴</button>
    </div>

    <div id="thirst-alert">
      ⚠️ <strong>马儿口渴了!</strong><br/>
      请骑行至前方瀑布水潭或溪流旁(按 <b>E</b> 或自动饮水),或点击“自动寻水”。
    </div>
  </div>

  <!-- 右上角:天气面板 -->
  <div id="weather-panel" class="hud-panel">
    <div class="title-row">
      <span>🌦️ 随机天气系统</span>
 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0