three实现三维中国龙遨游天空体验代码
代码语言:html
所属分类:其他
代码由gemini-4-hydrogen ai生成,可能有错误,仅供参考:点击查看提示词
代码描述: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; }
html, body {
width: 100%;
height: 100%;
overflow: hidden;
background: #0a101d;
font-family: "PingFang SC", "Microsoft YaHei", "Noto Serif SC", serif;
user-select: none;
}
#canvas-container {
width: 100%;
height: 100%;
position: relative;
}
/* 古风半透明 HUD */
.hud-panel {
position: absolute;
background: linear-gradient(135deg, rgba(16, 20, 30, 0.72), rgba(28, 22, 16, 0.65));
backdrop-filter: blur(8px);
border: 1px solid rgba(228, 185, 102, 0.4);
border-radius: 8px;
color: #f5e6c8;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
pointer-events: auto;
}
#top-left {
top: 18px;
left: 20px;
padding: 14px 18px;
min-width: 240px;
}
.title {
font-size: 20px;
font-weight: bold;
letter-spacing: 3px;
color: #f2c977;
text-shadow: 0 0 12px rgba(242, 201, 119, 0.45);
margin-bottom: 8px;
display: flex;
align-items: center;
gap: 8px;
}
.stats {
font-size: 13px;
line-height: 1.75;
color: #dfd3ba;
font-family: "Consolas", "PingFang SC", monospace;
}
.stats span.val {
color: #ffd57e;
font-weight: bold;
}
.zone-badge {
display: inline-block;
margin-top: 6px;
padding: 2px 10px;
border-radius: 12px;
font-size: 12px;
background: rgba(228, 185, 102, 0.18);
border: 1px solid rgba(228, 185, 102, 0.5);
color: #ffe2a3;
}
#controls-panel {
bottom: 20px;
left: 20px;
padding: 12px 16px;
font-size: 12.5px;
line-height: 1.7;
max-width: 340px;
}
.key {
display: inline-block;
padding: 1px 6px;
margin: 0 2px;
border-radius: 4px;
background: rgba(255, 215, 130, 0.16);
border: 1px solid rgba(255, 215, 130, 0.45);
color: #ffd98e;
font-family: monospace;
font-size: 11.5px;
}
#top-right {
top: 18px;
right: 20px;
padding: 10px 14px;
display: flex;
flex-direction: column;
gap: 8px;
}
.btn {
cursor: pointer;
padding: 7px 14px;
border-radius: 6px;
border: 1px solid rgba(228, 185, 102, 0.55);
background: rgba(45, 34, 20, 0.65);
color: #ffe3a8;
font-size: 13px;
letter-spacing: 1px;
transition: all 0.2s ease;
text-align: center;
}
.btn:hover {
background: rgba(228, 185, 102, 0.28);
border-color: #ffd57e;
}
.btn.active {
background: linear-gradient(90deg, rgba(200, 140, 45, 0.7), rgba(165, 65, 35, 0.7));
color: #fff;
border-color: #ffe29a;
}
#roar-flash {
position: fixed;
inset: 0;
pointer-events: none;
background: radial-gradient(circle at center, rgba(255, 200, 90, 0.22), transparent 70%);
opacity: 0;
transition: opacity 0.25s ease;
}
</style>
<script type="importmap">
{
"imports": {
"three": "https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js"
}
}
</script>
</head>
<body>
<div id="canvas-container"></div>
<div id="roar-flash"></div>
<div id="top-left" class="hud-panel">
<div class="title">🐉 神龙巡天 · 九霄云海</div>
<div class="stats">
海拔高度:<span id="alt-val" class="val">110</span> m<br/>
飞行速度:<span id="spd-val" class="val">36</span> m/s<br/>
当前空域:<span id="zone-val" class="zone-badge">云海穿行</span>
</div>
</div>
<div id="top-right" class="hud-panel">
<button id="btn-autopilot" class="btn active">自动巡天:开启 (C)</button>
<button id="btn-dive" class="btn">俯冲掠地 (贴近山河)</button>
<button id="btn-climb" class="btn">直上九霄 (跃出云海)</button>
<button id="btn-roar" class="btn">龙吟吐息 (R)</button>
</div>
<div id="controls-panel" class="hud-panel">
<div><span class="key">W</span>/<span class="key">S</span> 或 <span class="key">↑</span>/<span class="key">↓</span> 俯冲 / 爬升(自动切换手动)</div>
<div><span class="key">A</span>/<span class="key">D</span> 或 <span class="key">←</span>/<span class="key">→</span> 左转 / 右转</div>
<div><span class="key">Shift</span> / <span class="key">Space</span> 腾云加速 | <span class="key">R</span> 龙吟吐息</div>
<div><span class="key">鼠标拖拽</span> 360°环绕视角 | <span class="key">滚轮</span> 缩放距离</div>
</div>
<script type="module">
import * as THREE from 'three';
// =========================================================================
// 1. 数学与程序化噪声工具(用于山水地形与云海分布)
// =========================================================================
function hash2(x, y) {
let h = Math.sin(x * 127.1 + y * 311.7) * 43758.5453123;
return h - Math.floor(h);
}
function valueNoise(x, y) {
const ix = Math.floor(x);
const iy = Math.floor(y);
const fx = x - ix;
const fy = y - iy;
const ux = fx * fx * (3.0 - 2.0 * fx);
const uy = fy * fy * (3.0 - 2.0 * fy);
const a = hash2(ix, iy);
const b = hash2(i.........完整代码请登录后点击上方下载按钮下载查看















网友评论0