three实现三维音乐喷泉动画代码
代码语言:html
所属分类:其他
代码由deepseek-v4-pro ai生成,可能有错误,仅供参考:点击查看提示词
代码描述:三维音乐喷泉
下面为部分代码预览,完整代码请点击下载或在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>赛博朋克音乐喷泉 - Cyberpunk Music Fountain</title>
<style>
:root {
--bg: #0a0a0f;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
background: var(--bg);
overflow: hidden;
font-family: 'Courier New', monospace;
cursor: grab;
user-select: none;
-webkit-user-select: none;
height: 100vh;
width: 100vw;
}
body:active {
cursor: grabbing;
}
body.grabbing {
cursor: grabbing;
}
canvas {
display: block;
}
#overlay {
position: fixed;
bottom: 30px;
left: 50%;
transform: translateX(-50%);
z-index: 10;
pointer-events: none;
display: flex;
flex-direction: column;
align-items: center;
gap: 8px;
}
#info-panel {
background: rgba(10, 5, 20, 0.75);
border: 1px solid rgba(180, 60, 255, 0.4);
border-radius: 12px;
padding: 12px 20px;
color: #c8a0ff;
font-size: 13px;
letter-spacing: 0.08em;
text-align: center;
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
box-shadow: 0 0 30px rgba(140, 40, 220, 0.25), inset 0 0 30px rgba(140, 40, 220, 0.05);
transition: all 0.4s ease;
}
#bpm-display {
font-size: 28px;
font-weight: bold;
color: #ff66cc;
text-shadow: 0 0 20px #ff44aa, 0 0 40px #ff2288;
letter-spacing: 0.12em;
animation: pulse-bpm 0.5s ease-in-out infinite;
}
@keyframes pulse-bpm {
0%,
100% {
text-shadow: 0 0 20px #ff44aa, 0 0 40px #ff2288;
}
50% {
text-shadow: 0 0 35px #ff66cc, 0 0 70px #ff44aa, 0 0 100px #ff2288;
}
}
#beat-indicator {
display: flex;
gap: 6px;
align-items: center;
}
.beat-dot {
width: 8px;
height: 8px;
border-radius: 50%;
background: rgba(200, 150, 255, 0.4);
transition: all 0.08s ease;
}
.beat-dot.active {
background: #ff44cc;
box-shadow: 0 0 15px #ff44cc, 0 0 30px #ff2288;
transform: scale(1.6);
}
#hint {
color: rgba(180, 140, 220, 0.6);
font-size: 11px;
letter-spacing: 0.06em;
animation: fade-hint 4s ease-in-out infinite;
}
@keyframes fade-hint {
0%,
100% {
opacity: 0.4;
}
50% {
opacity: 0.8;
}
}
@media (max-width: 768px) {
#info-panel {
padding: 8px 14px;
font-size: 11px;
border-radius: 8px;
}
#bpm-display {
font-size: 22px;
}
#hint {
font-size: 10px;
}
}
</style>
</head>
<body>
<div id="overlay">
<div id="info-panel">
<div id="bpm-display">120 BPM</div>
<div id="beat-indicator">
<span class="beat-dot" id="dot0"></span>
<span class="beat-dot" id="dot1"></span>
<span class="beat-dot" id="dot2"></span>
<span class="beat-dot" id="dot3"></span>
</div>
<div id="hint">🖱 拖拽旋转 | 滚轮缩放 | 右键平移</div>
</div>
</div>
<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>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
import { Reflector } from 'three/addons/objects/Reflector.js';
// ==================== DOM 元素 ====================
const bpmDisplay = document.getElementById('bpm-display');
const beatDots = [
document.getElementById('dot0'),
document.getElementById('dot1'),
document.getElementById('dot2'),
document.getElementById('dot3'),
];
// ==================== 场景初始化 ====================
.........完整代码请登录后点击上方下载按钮下载查看















网友评论0