three实现三维新年下雪夜晚放烟花粒子文字祝福场景动画代码

代码语言:html

所属分类:三维

代码描述:three实现三维新年下雪夜晚放烟花粒子文字祝福场景动画代码

代码标签: three 三维 新年 下雪 夜晚 烟花 粒子 文字 祝福 场景 动画 代码

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

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>3D 新年烟花文字秀 - Three.js</title>
    <style>
        body { margin: 0; overflow: hidden; background-color: #000; font-family: 'Arial', sans-serif; }
        #canvas-container { width: 100vw; height: 100vh; display: block; }
        #overlay {
            position: absolute; top: 0; left: 0; width: 100%; height: 100%;
            background: rgba(0,0,0,0.6); display: flex; justify-content: center; align-items: center;
            color: white; flex-direction: column; transition: opacity 1s; z-index: 999;
        }
        #overlay h1 { font-size: 2.5rem; margin-bottom: 20px; text-shadow: 0 0 10px #ff0000; letter-spacing: 5px; }
        #overlay button {
            font-size: 1.2rem; cursor: pointer; border: 2px solid white; padding: 12px 30px;
            background: transparent; color: white; border-radius: 30px; transition: 0.3s;
        }
        #overlay button:hover { background: white; color: black; box-shadow: 0 0 15px white; }
        .hidden { opacity: 0; pointer-events: none; }
    </style>
</head>
<body>

<div id="overlay">
    <h1>✨ 2025 新年盛典 ✨</h1>
    <button id="start-btn">点火发射烟花</button>
</div>
<div id="canvas-container"></div>

<!-- 引入 Three.js -->
<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';

    // --- 全局变量 ---
    let scene, camera, renderer, controls;
    let snowSystem;
    let fireworks = [];
    let audioContext = null;
    let isAudioEnabled = false;
    let explosionLight; // 用于照亮天空的灯
    let ambientLight;

    // 文字祝福语列表
    c.........完整代码请登录后点击上方下载按钮下载查看

网友评论0