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>🎄 炫酷圣诞树 🎅</title>
    <style>
        * { margin: 0; padding: 0; box-sizing: border-box; }
        body { 
            overflow: hidden; 
            background: #000;
            font-family: 'Arial', sans-serif;
        }
        
        #startScreen {
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background: radial-gradient(ellipse at center, #1a0a2e 0%, #0d0015 100%);
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;
            z-index: 1000;
            transition: opacity 1s;
        }
        
        #startScreen.hidden {
            opacity: 0;
            pointer-events: none;
        }
        
        #startScreen h1 {
            font-size: 3em;
            color: #fff;
            text-shadow: 0 0 20px #ff0000, 0 0 40px #00ff00;
            margin-bottom: 30px;
            animation: glow 2s ease-in-out infinite alternate;
        }
        
        @keyframes glow {
            from { text-shadow: 0 0 20px #ff0000, 0 0 40px #00ff00; }
            to { text-shadow: 0 0 30px #00ff00, 0 0 60px #ff0000, 0 0 80px #ffff00; }
        }
        
        #startBtn {
            padding: 20px 50px;
            font-size: 1.5em;
            background: linear-gradient(45deg, #c41e3a, #228b22);
            border: 3px solid #ffd700;
            border-radius: 50px;
            color: white;
            cursor: pointer;
            transition: all 0.3s;
            box-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
        }
        
        #startBtn:hover {
            transform: scale(1.1);
            box-shadow: 0 0 50px rgba(255, 215, 0, 0.8);
        }
        
        #controls {
            position: fixed;
            bottom: 20px;
            left: 50%;
            transform: translateX(-50%);
            display: flex;
            gap: 15px;
            z-index: 100;
        }
        
        .control-btn {
            padding: 12px 25px;
            background: rgba(255, 255, 255, 0.1);
            border: 2px solid rgba(255, 255, 255, 0.3);
            border-radius: 25px;
            color: white;
            cursor: pointer;
            font-size: 1em;
            backdrop-filter: blur(10px);
            transition: all 0.3s;
        }
        
        .control-btn:hover {
            background: rgba(255, 255, 255, 0.2);
            border-color: #ffd700;
        }
        
        #info {
            position: fixed;
            top: 20px;
            left: 50%;
            transform: translateX(-50%);
            color: white;
            font-size: 1.2em;
            text-shadow: 0 0 10px rgba(0,0,0,0.8);
            z-index: 100;
            text-align: center;
        }
        
        .snowflake-icon {
            position: fixed;
            font-size: 2em;
            animation: fall linear infinite;
            pointer-events: none;
            z-index: 50;
        }
        
        @keyframes fall {
            to { transform: translateY(100vh) rotate(360deg); }
        }
    </style>
</head>
<body>
    <div id="startScreen">
        <h1>🎄 Merry Christmas 🎅</h1>
        <button id="startBtn">✨ 点击开始体验 ✨</button>
        <p style="color: #aaa; margin-top: 20px;">需要声音权限来播放音乐</p>
    </div>
    
    <div id="info">🖱️ 拖拽旋转视角 | 滚轮缩放</div>
    
    <div id="controls">
        <button class="control-btn" id="musicToggle">🔊 音乐</button>
        <button class="control-btn" id="snowToggle">❄️ 雪花</button>
        <button class="control-btn" id="autoRotate">🔄 自动旋转</button>
    </div>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r134/three.min.js"></script>
    <script>
        // ============ 全局变量 ============
        let scene, camera, renderer,.........完整代码请登录后点击上方下载按钮下载查看

网友评论0