three实现三维海上操控战斗机停航母甲板游戏代码

代码语言:html

所属分类:游戏

代码描述:three实现三维海上操控战斗机停航母甲板游戏代码,玩法:W/S俯仰 · A/D滚转 · Q/E偏航 · Shift加速 · Ctrl减速 · R重置

代码标签: three 三维 海上 操控 战斗机 航母 甲板 游戏 代码

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

<!DOCTYPE html>
<html lang="zh">
<head>
  <meta charset="UTF-8" />
  <title>Three.js 航母降落(白天 + 雷达 + 尾焰 + 高度预警 + 动态海面)</title>
  <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" />
  <style>
    body { margin:0; overflow:hidden; background:#87ceeb; color:#fff; font-family:system-ui,-apple-system,Segoe UI,Roboto,PingFang SC; }
    canvas { display:block; }
    #hud {
      position:absolute; left:16px; bottom:16px; z-index:10;
      background:rgba(0,0,0,.45); border:1px solid rgba(0,255,135,.5); border-radius:8px;
      padding:10px 12px; color:#00ff87; text-shadow:0 0 6px #00ff87; font-size:14px;
    }
    #msg {
      position:absolute; left:50%; top:50%; transform:translate(-50%,-50%); z-index:20;
      display:none; min-width:300px; text-align:center;
      background:rgba(0,0,0,.7); border:2px solid rgba(255,69,0,.7); border-radius:12px;
      padding:16px 22px; font-size:28px; color:#ff784a; text-shadow:0 0 10px #ff4500;
    }
    #msg.success { border-color:rgba(0,255,135,.7); color:#00ff87; text-shadow:0 0 10px #00ff87; }
    #loader {
      position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
      font-size:20px; background:#000; z-index:30;
    }
    .sub { font-size:12px; color:#ccc; margin-top:8px; }
    .hint {
      position:absolute; right:16px; bottom:16px; z-index:9; font-size:12px;
      background:rgba(0,0,0,.35); padding:8px 10px; border-radius:8px; color:#eee;
    }
    #radarWrap {
      position: absolute; right: 16px; top: 16px; z-index: 12;
      background: rgba(0,0,0,.5); padding: 10px; border-radius: 10px; border:1px solid rgba(255,255,255,.25);
      display: flex; flex-direction: column; align-items: center; gap: 6px;
    }
    #radarTitle { font-size: 12px; color: #bde0ff; }
    #radar { width: 180px; height: 180px; display: block; }
    #altWarn {
      position: absolute; left: 50%; top: 12%; transform: translateX(-50%);
      z-index: 15; padding: 8px 12px; border-radius: 8px;
      background: rgba(255,0,0,.2); border: 1px solid rgba(255,0,0,.6);
      color: #fff; font-weight: 700; letter-spacing: 1px; display: none;
      text-shadow: 0 0 6px #ff3b3b;
    }
  </style>
</head>
<body>
  <div id="hud">
    速度: <span id="spd">0</span> km/h<br/>
    高度: <span id="alt">0</span> m<br/>
    距航母: <span id="dist">0</span> km
  </div>
  <div id="msg"><div id="msgText"></div><div class="sub" id="msgSub"></div></div>
  <div id="loader">LOADING ASSETS... 0%</div>
  <div class="hint">W/S俯仰 · A/D滚转 · Q/E偏航 · Shift加速 · Ctrl减速 · R重置</div>

  <div id="radarWrap">
    <div id="radarTitle">雷达(航向向上)</div>
    <canvas id="radar" width="180" height="180"></canvas>
  </div>
  <div id="altWarn">ALTITUDE WARNING</div>

      <script type="importmap">
{
 "imports":{
    "three":"//repo.bfw.wiki/bfwrepo/js/module/three/build/164/three.module.js",
    "three/addons/":"//repo.bfw.wiki/bfwrepo/js/module/three/examples/164/jsm/"
 }
}
</script>

  <script type="module">
  import * as THREE from 'three';
  import { GLTFLoader } from 'three/addons/loaders/GLTFLoader.js';
  import { Water } from 'three/addons/objects/Water.js';

  // 全局可配置:GLB 路径(替换为你的文件地址或本地路径)
  const GLB_CARRIER_URL = '//repo.bfw.wiki/bfwrepo/threemodel/weapon/hangmu.glb';
  const GLB_JET_URL     = '//repo.bfw.wiki/bfwrepo/threemodel/airjet.glb';

  // DOM
  const hudSpd = document.getElementById('spd');
  const hudAlt = document.getElementById('alt');
  const hudDist = document.getElementById('dist');
  const msg = document.getElementById('msg');
 .........完整代码请登录后点击上方下载按钮下载查看

网友评论0