three实现模拟三维城市可视化拖拽建筑设计工具代码
代码语言:html
所属分类:三维
代码描述:three实现模拟三维城市可视化拖拽建筑设计工具代码,内涵基本的城市三维建筑模型,例如医院、道路、别墅、写字楼,还有时间控制、天气系统等。由claude 4.5 opus生成。
代码标签: 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 {
font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
overflow: hidden;
background: #0a0a1a;
}
#canvas-container {
width: 100vw;
height: 100vh;
}
/* 顶部工具栏 */
#toolbar {
position: fixed;
top: 0;
left: 0;
right: 0;
height: 60px;
background: linear-gradient(180deg, rgba(20,20,40,0.98) 0%, rgba(20,20,40,0.95) 100%);
display: flex;
align-items: center;
padding: 0 20px;
gap: 10px;
z-index: 1000;
border-bottom: 1px solid rgba(100,150,255,0.2);
backdrop-filter: blur(10px);
}
.logo {
font-size: 1.5rem;
font-weight: bold;
background: linear-gradient(135deg, #667eea, #764ba2, #00d4ff);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
margin-right: 20px;
}
.toolbar-group {
display: flex;
gap: 5px;
padding: 5px;
background: rgba(255,255,255,0.05);
border-radius: 10px;
}
.tool-btn {
background: transparent;
border: none;
color: #aaa;
padding: 10px 15px;
border-radius: 8px;
cursor: pointer;
font-size: 13px;
transition: all 0.3s;
display: flex;
align-items: center;
gap: 6px;
}
.tool-btn:hover {
background: rgba(102,126,234,0.2);
color: #fff;
}
.tool-btn.active {
background: linear-gradient(135deg, #667eea, #764ba2);
color: #fff;
box-shadow: 0 4px 15px rgba(102,126,234,0.4);
}
.tool-btn .icon {
font-size: 1.1rem;
}
.divider {
width: 1px;
height: 30px;
background: rgba(255,255,255,0.1);
margin: 0 10px;
}
/* 左侧面板 */
#left-panel {
position: fixed;
left: 0;
top: 60px;
width: 300px;
height: calc(100vh - 60px);
background: rgba(15,15,30,0.95);
border-right: 1px solid rgba(100,150,255,0.1);
overflow-y: auto;
z-index: 100;
backdrop-filter: blur(10px);
}
.panel-section {
padding: 20px;
border-bottom: 1px solid rgba(255,255,255,0.05);
}
.panel-title {
color: #667eea;
font-size: 0.85rem;
font-weight: 600;
margin-bottom: 15px;
text-transform: uppercase;
letter-spacing: 1px;
display: flex;
align-items: center;
gap: 8px;
}
.building-grid {
display: grid;
grid-template-columns: repeat(2, 1fr);
gap: 10px;
}
.building-card {
background: linear-gradient(145deg, rgba(40,40,60,0.8), rgba(25,25,45,0.8));
border: 2px solid transparent;
border-radius: 12px;
padding: 15px;
cursor: pointer;
transition: all 0.3s;
text-align: center;
}
.building-card:hover {
border-color: rgba(102,126,234,0.5);
transform: translateY(-3px);
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.building-card.selected {
border-color: #00d4ff;
background: linear-gradient(145deg, rgba(0,212,255,0.2), rgba(102,126,234,0.2));
box-shadow: 0 0 25px rgba(0,212,255,0.3);
}
.building-card .preview {
width: 60px;
height: 60px;
margin: 0 auto 10px;
background: linear-gradient(145deg, #667eea, #764ba2);
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
font-size: 1.8rem;
}
.building-card .name {
color: #fff;
font-size: 0.85rem;
margin-bottom: 5px;
}
.building-card .info {
color: #666;
font-size: 0.7rem;
}
/* 右侧面板 */
#right-panel {
position: fixed;
right: 0;
top: 60px;
width: 320px;
height: calc(100vh - 60px);
background: rgba(15,15,30,0.95);
border-left: 1px solid rgba(100,150,255,0.1);
overflow-y: auto;
z-index: 100;
backdrop-filter: blur(10px);
}
.property-row {
margin-bottom: 15px;
}
.property-label {
color: #888;
font-size: 0.8rem;
margin-bottom: 8px;
display: block;
}
.property-slider {
width: 100%;
-webkit-appearance: none;
height: 6px;
background: rgba(255,255,255,0.1);
border-radius: 3px;
outline: none;
}
.property-slider::-webkit-slider-thumb {
-webkit-appearance: none;
width: 18px;
height: 18px;
background: linear-gradient(135deg, #667eea, #00d4ff);
border-radius: 50%;
cursor: pointer;
box-shadow: 0 2px 10px rgba(102,126,234,0.5);
}
.slider-value {
display: flex;
justify-content: space-between;
margin-top: 5px;
font-size: 0.75rem;
color: #666;
}
.slider-value .current {
color: #00d4ff;
font-weight: bold;
}
/* 天气控制 */
.weather-controls {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 8px;
}
.weather-btn {
background: rgba(255,255,255,0.05);
border: 1px solid rgba(255,255,255,0.1);
border-radius: 10px;
padding: 12px;
cursor: pointer;
transition: all 0.3s;
text-align: center;
}
.weather-btn:hover {
background: rgba(102,126,234,0.2);
border-color: rgba(102,126,234,0.5);
}
.weather-btn.active {
background: linear-gradient(135deg, rgba(102,126,234,0.3), rgba(0,212,255,0.3));
border-color: #00d4ff;
}
.weather-btn .icon {
font-size: 1.5rem;
display: block;
margin-bottom: 5px;
}
.weather-btn .label {
color: #888;
font-size: 0.7rem;
}
/* 时间控制 */
.time-control {
display: flex;
align-items: center;
gap: 15px;
padding: 15px;
background: rgba(0,0,0,0.3);
border-radius: 12px;
}
.time-display {
text-align: center;
}
.time-display .time {
font-size: 2rem;
color: #fff;
font-weight: bold;
}
.time-display .period {
color: #667eea;
font-size: 0.8rem;
}
.time-slider-container {
flex: 1;
}
/* 迷你地图 */
#minimap {
width: 100%;
height: 200px;
background: rgba(0,0,0,0.5);
border-radius: 12px;
overflow: hidden;
position: relative;
}
#minimap-canvas {
width: 100%;
height: 100%;
}
/* 状态栏 */
#status-bar {
position: fixed;
bottom: 0;
left: 300px;
right: 320px;
height: 35px;
background: rgba(15,15,30,0.95);
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 20px;
font-size: 0.8rem;
color: #666;
border-top: 1px solid rgba(255,255,255,0.05);
z-index: 100;
}
.status-item {
display: flex;
align-items: center;
gap: 8px;
}
.status-item .value {
color: #00d4ff;
}
/* 加载画面 */
#loading {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 100%);
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
z-index: 9999;
}
.loading-city {
width: 200px;
height: 100px;
position: relative;
margin-bottom: 30px;
}
.loading-building {
position: absolute;
bottom: 0;
background: linear-gradient(180deg, #667eea, #764ba2);
animation: buildUp 1.5s ease-in-out infinite;
}
.loading-building:nth-child(1) { left: 0; width: 30px; animation-delay: 0s; }
.loading-building:nth-child(2) { left: 40px; width: 25px; animation-delay: 0.2s; }
.loading-building:nth-child(3) { left: 75px; width: 40px; animation-delay: 0.4s; }
.loading-building:nth-child(4) { left: 125px; width: 35px; animation-delay: 0.6s; }
.loading-building:nth-child(5) { left: 170px; width: 30px; animation-delay: 0.8s; }
@keyframes buildUp {
0%, 100% { height: 20px; }
50% { height: 80px; }
}
.loading-text {
color: #fff;
font-size: 1.2rem;
margin-bottom: 20px;
}
.loading-bar {
width: 300px;
height: 4px;
background: rgba(255,255,255,0.1);
border-radius: 2px;
overflow: hidden;
}
.loading-progress {
height: 100%;
background: linear-gradient(90deg, #667eea, #00d4ff);
border-radius: 2px;
animation: loadProgress 2s ease-in-out forwards;
}
@keyframes loadProgress {
from { width: 0; }
to { width: 100%; }
}
/* 工具提示 */
.tooltip {
position: fixed;
background: rgba(0,0,0,0.9);
color: #fff;
padding: 8px 12px;
border-radius: 6px;
font-size: 0.8rem;
pointer-events: none;
z-index: 2000;
display: none;
}
/* 色彩选择器 */
.color-grid {
display: grid;
grid-template-columns: repeat(6, 1fr);
gap: 8px;
}
.color-option {
width: 100%;
aspect-ratio: 1;
border-radius: 8px;
cursor: pointer;
border: 3px solid transparent;
transition: all 0.3s;
}
.color-option:hover {
transform: scale(1.1);
}
.color-option.selected {
border-color: #fff;
box-shadow: 0 0 15px rgba(255,255,255,0.5);
}
/* 统计卡片 */
.stat-card {
background: linear-gradient(145deg, rgba(40,40,60,0.5), rgba(25,25,45,0.5));
border-radius: 12px;
padding: 15px;
margin-bottom: 10px;
}
.stat-card .label {
color: #666;
font-size: 0.75rem;
margin-bottom: 5px;
}
.stat-card .value {
color: #fff;
font-size: 1.5rem;
font-weight: bold;
}
.stat-card .value span {
color: #667eea;
font-size: 0.9rem;
}
/* 快捷键面板 */
#shortcuts-panel {
position: fixed;
left: 310px;
bottom: 45px;
background: rgba(15,15,30,0.95);
border-radius: 10px;
padding: 15px;
font-size: 0.75rem;
color: #666;
z-index: 100;
}
.shortcut-row {
display: flex;
justify-content: space-between;
margin: 5px 0;
}
.shortcut-key {
background: rgba(255,255,255,0.1);
padding: 2px 8px;
border-radius: 4px;
color: #fff;
font-family: monospace;
}
/* 通知 */
#notification {
position: fixed;
top: 80px;
left: 50%;
transform: translateX(-50%);
background: linear-gradient(135deg, #667eea, #764ba2);
color: #fff;
padding: 12px 30px;
border-radius: 25px;
font-size: 0.9rem;
z-index: 2000;
display: none;
animation: slideDown 0.3s ease;
}
@keyframes slideDown {
from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
/* 模态框 */
.modal-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0,0,0,0.8);
display: none;
align-items: center;
justify-content: center;
z-index: 3000;
}
.modal-overlay.active {
display: flex;
}
.modal {
background: rgba(20,20,40,0.98);
border-radius: 20px;
padding: 30px;
min-width: 450px;
border: 1px solid rgba(102,126,234,0.3);
}
.modal h2 {
color: #fff;
margin-bottom: 20px;
display: flex;
align-items: center;
gap: 10px;
}
.modal-buttons {
display: flex;
gap: 10px;
margin-top: 25px;
justify-content: flex-end;
}
.btn {
padding: 12px 25px;
border: none;
border-radius: 10px;
cursor: pointer;
font-size: 0.9rem;
transition: all 0.3s;
}
.btn-primary {
background: linear-gradient(135deg, #667eea, #764ba2);
color: #fff;
}
.btn-primary:hover {
box-shadow: 0 5px 20px rgba(102,126,234,0.5);
}
.btn-secondary {
background: rgba(255,255,255,0.1);
color: #fff;
}
/* 滚动条 */
::-webkit-scrollbar {
width: 6px;
}
::-webkit-scrollbar-track {
background: rgba(0,0,0,0.2);
}
::-webkit-scrollbar-thumb {
background: rgba(102,126,234,0.5);
border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
background: rgba(102,126,234,0.8);
}
</style>
</head>
<body>
<!-- 加载画面 -->
<div id="loading">
<div class="loading-city">
<div class="loading-building"></div>
<div class="loading-building"></div>
<div class="loading-building"></div>
<div class="loading-building"></div>
<div class="loading-building"></div>
</div>
<div class="loading-text">正在构建城市引擎...</div>
<div class="loading-bar">
<div class="loading-progress"></div>
</div>
</div>
<!-- 主画布 -->
<div id="canvas-container"></div>
<!-- 顶部工具栏 -->
<div id="toolbar">
<div class="logo">🏙️ CityBuilder Pro</div>
<div class="toolbar-group">
<button class="tool-btn active" data-tool="select" title="选择工具">
<span class="icon">🔍</span>
<span>选择</span>
</button>
<button class="tool-btn" data-tool="move" title="移动工具">
<span class="icon">✋</span>
<span>移动</span>
</button>
<button class=&quo.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0