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>大雄宝殿 · 3D 沉浸式寺庙礼佛</title>
<style>
* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; }
body {
overflow: hidden;
background: #0d0907;
font-family: "PingFang SC", "Microsoft YaHei", "STKaiti", serif;
color: #f4e4c1;
}
#canvas-container {
width: 100vw;
height: 100vh;
display: block;
}
/* 顶部信息栏 */
.hud-top {
position: fixed;
top: 18px;
left: 20px;
pointer-events: none;
z-index: 10;
text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
}
.hud-title {
font-size: 24px;
letter-spacing: 6px;
color: #ffd98e;
font-weight: bold;
}
.hud-sub {
margin-top: 6px;
font-size: 13px;
color: #d6c3a5;
letter-spacing: 1px;
line-height: 1.6;
}
.status-badge {
display: inline-block;
margin-top: 8px;
padding: 4px 12px;
background: rgba(30, 18, 12, 0.72);
border: 1px solid rgba(255, 217, 142, 0.35);
border-radius: 20px;
font-size: 12px;
color: #ffe3a8;
}
/* 右上角音频与视角面板 */
.hud-right {
position: fixed;
top: 18px;
right: 20px;
display: flex;
flex-direction: column;
gap: 8px;
z-index: 10;
}
/* 底部操作栏 */
.hud-bottom {
position: fixed;
bottom: 22px;
left: 50%;
transform: translateX(-50%);
display: flex;
flex-wrap: wrap;
justify-content: center;
gap: 10px;
padding: 12px 18px;
background: rgba(18, 11, 8, 0.78);
backdrop-filter: blur(10px);
border: 1px solid rgba(255, 210, 130, 0.28);
border-radius: 16px;
box-shadow: 0 10px 35px rgba(0, 0, 0, 0.7);
z-index: 10;
max-width: 95vw;
}
.btn {
cursor: pointer;
padding: 9px 16px;
border-radius: 10px;
border: 1px solid rgba(255, 215, 140, 0.35);
background: linear-gradient(180deg, rgba(68, 42, 24, 0.85), rgba(35, 20, 12, 0.9));
color: #f8e5be;
font-size: 13px;
letter-spacing: 1px;
transition: all 0.2s ease;
display: flex;
align-items: center;
gap: 6px;
font-family: inherit;
}
.btn:hover {
background: linear-gradient(180deg, rgba(110, 68, 32, 0.95), rgba(60, 34, 16, 0.95));
border-color: #ffd98e;
transform: translateY(-1px);
box-shadow: 0 4px 14px rgba(255, 195, 90, 0.25);
}
.btn.active {
background: linear-gradient(180deg, #b87c2a, #7d4c14);
border-color: #ffe7b3;
color: #fff8e7;
box-shadow: 0 0 16px rgba(255, 196, 88, 0.45);
}
.divider {
width: 1px;
background: rgba(255, 215, 140, 0.2);
margin: 2px 4px;
}
/* 提示浮层 */
#toast {
position: fixed;
top: 90px;
left: 50%;
transform: translateX(-50%) translateY(-10px);
padding: 8px 22px;
background: rgba(25, 14, 8, 0.85);
border: 1px solid rgba(255, 217, 142, 0.5);
border-radius: 30px;
color: #ffe6b3;
font-size: 14px;
letter-spacing: 2px;
opacity: 0;
pointer-events: none;
transition: all 0.35s ease;
z-index: 20;
}
#toast.show {
opacity: 1;
transform: translateX(-50%) translateY(0);
}
/* 初始音频激活引导 */
#audio-hint {
position: fixed;
inset: 0;
background: rgba(10, 6, 4, 0.65);
backdrop-filter: blur(4px);
display: flex;
align-items: center;
justify-content: center;
z-index: 100;
cursor: pointer;
transition: opacity 0.5s ease;
}
.hint-card {
padding: 34px 48px;
text-align: center;
background: radial-gradient(circle at top, #362012, #170d08);
border: 1px solid rgba(255, 215, 140, 0.45);
border-radius: 18px;
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.85);
}
.hint-card h1 {
font-size: 28px;
letter-spacing: 8px;
color: #ffd98e;
margin-bottom: 12px;
}
.hint-card p {
font-size: 14px;
color: #d8c2a0;
line-height: 1.8;
margin-bottom: 22px;
}
.hint-btn {
display: inline-block;
padding: 10px 30px;
border-radius: 25px;
background: linear-gradient(180deg, #c98b34, #875315);
border: 1px solid #ffe4a8;
color: #fff9ec;
font-size: 15px;
letter-spacing: 3px;
}
</style>
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.160.0/examples/jsm/"
}
}
</script>
</head>
<body>
<div id="audio-hint">
<div class="hint-card">
<h1>大 雄 宝 殿</h1>
<p>
点击进入庄严佛殿,开启实时大殿混响禅音<br />
WASD / 方向键控制行走进殿 · 鼠标拖拽环顾大殿 · 滚轮缩放
</p>
<div class="hint-btn">合十入殿</div>
</div>
</div>
<div class="hud-top">
<div class="hud-title">大 雄 宝 殿</div>
<div class="hud-sub">WASD / 方向键:行走入殿 · 鼠标:旋转/缩放视角</div>
<div class="status-badge" id="status-text">当前状态:殿外静立</div>
</div>
<div class="hud-right">
<button class="btn" id="btn-cam-mode">📷 视角:跟随香客</button>
<button class="btn" id="btn-buddha-view">🪷 瞻仰大佛特写</button>
<button class="btn" id="btn-sound-toggle">🔊 禅音:开启</button>
<button class="btn" id="btn-bell">🔔 撞响铜钟</button>
<button class="btn" id="btn-muyu">🪵 敲击木鱼</button>
<button class="btn" id="btn-auto-muyu">📿 自动诵经木鱼:关</button>
</div>
<div id="toast">南无阿弥陀佛</div>
<div class="hud-bottom">
<button class="btn" id="act-incense">🕯️ [1] 烧香祈福</button>
<button class="btn" id="act-kowtow">🙇 [2] 跪拜磕头</button>
<button class="btn" id="act-meditate">🧘 [3] 盘腿打坐</button>
<button class="btn" id="act-stand">🚶 [4] 起身行走</button>
<div class="divider"></div>
<button class="btn" id="act-enter">🏛️ 自动走入大殿</button>
</div>
<div id="canvas-container"></div>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
// =========================================================================
// 1. 寺庙声学音效引擎 (Web Audio API + 真实卷积混响)
// =========================================================================
class TempleAudioEngine {
constructor() {
this.ctx = null;
this.masterGain = null;
this.reverbNode = null;
this.enabled = true;
this.initialized = false;
this.ambientStarted = false;
this.autoMuyuTimer = null;
this.lastStepTime = 0;
}
init() {
if (this.initialized) {
if (this.ctx.state === 'suspend.........完整代码请登录后点击上方下载按钮下载查看















网友评论0