three实现三维夜晚城市cbd高楼大厦亮灯效果代码
代码语言:html
所属分类:三维
代码描述:three实现三维夜晚城市cbd高楼大厦亮灯效果代码。gemini3生成
代码标签: three 三维 夜晚 城市 cbd 高楼 大厦 亮灯
下面为部分代码预览,完整代码请点击下载或在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 城市 CBD 夜景 (Three.js)</title>
<style>
body { margin: 0; overflow: hidden; background-color: #050505; }
#info {
position: absolute;
top: 10px;
width: 100%;
text-align: center;
color: rgba(255, 255, 255, 0.6);
font-family: 'Segoe UI', sans-serif;
pointer-events: none;
text-transform: uppercase;
letter-spacing: 2px;
font-size: 12px;
}
</style>
<!-- 引入 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>
</head>
<body>
<div id="info">Cyberpunk CBD City Generator</div>
<script type="module">
import * as THREE from 'three';
import { OrbitControls } from 'three/addons/controls/OrbitControls.js';
// --- 全局变量 ---
let scene, camera, renderer, controls;
let cityGroup, trafficGroup;
const carLights = []; // 存储车流对象以便动画
// 城市配置
const CITY_SIZE = 20; // 街区数量 (20x20)
const BLOCK_SIZE = 10; // 街区大小
const STREET_WIDTH = 4;
init();
animate();
function init() {
// 1. 场景初始化
scene = new THREE.Scene();
scene.background = new THREE.Color(0x020205); // 深夜色
scene.fog = new THREE.FogExp2(0x020205, 0.008); // 迷雾效果
camera = new THREE.PerspectiveCamera(45, window.innerWidth / window..........完整代码请登录后点击上方下载按钮下载查看
















网友评论0