three实现三维出息团圆饭与屋外烟花场景代码

代码语言:html

所属分类:三维

代码描述:three实现三维出息团圆饭与屋外烟花场景代码

代码标签: three 三维 出息 团圆饭 屋外 烟花 场景 代码

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

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>除夕团圆夜 - Three.js 场景</title>
    <style>
        body { margin: 0; overflow: hidden; background-color: #000; }
        #info {
            position: absolute;
            top: 10px;
            width: 100%;
            text-align: center;
            color: #ffd700;
            font-family: "Microsoft YaHei", sans-serif;
            font-size: 20px;
            pointer-events: none;
            z-index: 10;
            text-shadow: 2px 2px 4px #ff0000;
        }
    </style>
</head>
<body>
    <div id="info">除夕快乐 · 阖家团圆</div>
    
    <!-- 使用 ES Modules 引入 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 fireworks = [];
        const clock = new THREE.Clock();

        init();
        animate();

        function init() {
            // 1. 场景设置
            scene = new THREE.Scene();
            scene.background = new THREE.Color(0x050510); // 深夜色
            // 增加一点雾效,让窗外更有深邃感
            scene.fog = new THREE.FogExp2(0x050510, 0.005);

            // 2. 相机设置
            camera = new THREE.PerspectiveCamera(45, window.in.........完整代码请登录后点击上方下载按钮下载查看

网友评论0