three实现三维空间乐高积木游戏代码
代码语言:html
所属分类:游戏
代码描述: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>3D 乐高积木编辑器</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
overflow: hidden;
font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
background: #1a1a2e;
user-select: none;
}
#canvas-container {
width: 100vw;
height: 100vh;
display: block;
}
canvas { display: block; }
/* ===== 顶部工具栏 ===== */
#toolbar {
position: fixed;
top: 0; left: 0; right: 0;
height: 56px;
background: rgba(15, 15, 35, 0.92);
backdrop-filter: blur(12px);
border-bottom: 1px solid rgba(255,255,255,0.08);
display: flex;
align-items: center;
padding: 0 16px;
z-index: 100;
gap: 6px;
}
#toolbar .logo {
font-size: 20px;
font-weight: 800;
color: #fff;
margin-right: 20px;
letter-spacing: -0.5px;
}
#toolbar .logo span { color: #f7d731; }
.tool-group {
display: flex;
align-items: center;
gap: 4px;
padding: 0 8px;
border-right: 1px solid rgba(255,255,255,0.08);
height: 40px;
}
.tool-group:last-child { border-right: none; }
.tool-btn {
width: 38px; height: 38px;
border: none;
border-radius: 8px;
background: transparent;
color: #aab;
font-size: 18px;
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.15s;
position: relative;
}
.tool-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.tool-btn.active { background: rgba(97, 130, 255, 0.3); color: #7c9fff; }
.tool-btn .tooltip {
position: absolute;
bottom: -32px;
left: 50%;
transform: translateX(-50%);
background: rgba(0,0,0,0.85);
color: #fff;
padding: 4px 10px;
border-radius: 6px;
font-size: 11px;
white-space: nowrap;
opacity: 0;
pointer-events: none;
transition: opacity 0.15s;
}
.tool-btn:hover .tooltip { opacity: 1; }
.tool-btn .shortcut {
position: absolute;
top: 2px; right: 2px;
font-size: 8px;
color: #667;
background: rgba(0,0,0,0.3);
padding: 1px 3px;
border-radius: 3px;
}
/* ===== 左侧面板 - 砖块选择 ===== */
#brick-panel {
position: fixed;
left: 12px;
top: 68px;
width: 200px;
background: rgba(15, 15, 35, 0.92);
backdrop-filter: blur(12px);
border-radius: 14px;
border: 1px solid rgba(255,255,255,0.08);
padding: 14px;
z-index: 90;
max-height: calc(100vh - 80px);
overflow-y: auto;
}
#brick-panel::-webkit-scrollbar { width: 4px; }
#brick-panel::-webkit-scrollbar-track { background: transparent; }
#brick-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.panel-title {
font-size: 11px;
font-weight: 700;
color: #667;
text-transform: uppercase;
letter-spacing: 1.2px;
margin-bottom: 10px;
}
.brick-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 6px;
margin-bottom: 16px;
}
.brick-option {
background: rgba(255,255,255,0.05);
border: 2px solid transparent;
border-radius: 10px;
padding: 10px 6px;
cursor: pointer;
text-align: center;
transition: all 0.15s;
}
.brick-option:hover { background: rgba(255,255,255,0.1); }
.brick-option.active { border-color: #6182ff; background: rgba(97,130,255,0.15); }
.brick-option .brick-icon {
font-size: 28px;
margin-bottom: 4px;
display: block;
}
.brick-option .brick-label {
font-size: 10px;
color: #aab;
display: block;
}
/* ===== 颜色选择器 ===== */
.color-grid {
display: grid;
grid-template-columns: repeat(5, 1fr);
gap: 5px;
margin-bottom: 16px;
}
.color-swatch {
width: 100%; aspect-ratio: 1;
border-radius: 8px;
cursor: pointer;
border: 2px solid transparent;
transition: all 0.15s;
position: relative;
}
.color-swatch:hover { transform: scale(1.12); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(97,130,255,0.5); }
/* ===== 右侧信息面板 ===== */
#info-panel {
position: fixed;
right: 12px;
top: 68px;
width: 180px;
background: rgba(15, 15, 35, 0.92);
backdrop-filter: blur(12px);
border-radius: 14px;
border: 1px solid rgba(255,255,255,0.08);
padding: 14px;
z-index: 90;
}
.info-row {
display: flex;
justify-content: space-between;
align-items: center;
padding: 6px 0;
border-bottom: 1px solid rgba(255,255,255,0.05);
}
.info-row:last-child { border-bottom: none; }
.info-label { font-size: 11px; color: #667; }
.info-value { font-size: 13px; color: #dde; font-weight: 600; }
/* ===== 底部状态栏 ===== */
#statusbar {
position: fixed;
bottom: 0; left: 0; right: 0;
height: 32px;
background: rgba(15, 15, 35, 0.92);
backdrop-filter: blur(12px);
border-top: 1px solid rgba(255,255,255,0.08);
display: flex;
align-items: center;
padding: 0 16px;
z-index: 100;
gap: 20px;
}
.status-item {
font-size: 11px;
color: #667;
display: flex;
align-items: center;
gap: 6px;
}
.status-item .dot {
width: 6px; height: 6px;
border-radius: 50%;
background: #4c.........完整代码请登录后点击上方下载按钮下载查看
















网友评论0