feat(Building3D): 更新房间布局,移除临时坐标轴指示,优化墙体组件

This commit is contained in:
Pine
2026-08-18 05:38:13 +08:00
parent d00e9856cd
commit 1581b62154
+12 -50
View File
@@ -66,15 +66,15 @@ const ROOMS = [
{ x: [14, 16], z: [28, 32], type: 'office', zone: '加速区', no: 'A9', company: '云南大学AI+创业平台' },
{ x: [18, 21], z: [28, 32], type: 'office', zone: '加速区', no: 'A8', company: '瀚颖AI+教育信息咨询' },
{ x: [23, 26], z: [28, 32], type: 'office', zone: '加速区', no: 'A7', company: '云南廷秀文旅康养' },
{ x: [28, 31], z: [28, 32], type: 'office', zone: '加速区', no: 'A6', company: '人工智能机器人大模型训练' },
{ x: [6, 12], z: [36, 40], type: 'office', zone: '加速区', no: 'A6', company: '人工智能机器人大模型训练' }, // x: [28, 31], z: [28, 32]
{ x: [32, 43], z: [28, 32], type: 'desk', no: 'W02' },
{ x: [45, 48], z: [28, 32], type: 'lounge', no: 'L01' },
{ x: [50, 58], z: [28, 32], type: 'hallway', no: 'H04' },
// 横向过道(行33-35
{ x: [1, 58], z: [33, 35], type: 'hallway', no: 'H05' },
// ===== 下排(6 间:A1-A5 + 园区管理办公室)=====
{ x: [1, 4], z: [36, 40], type: 'office', zone: '管理', no: 'M', company: '园区管理办公室' },
{ x: [6, 12], z: [36, 40], type: 'office', zone: '加速区', no: 'A12', company: '待入驻' },
{ x: [1, 4], z: [36, 40], type: 'office', zone: '管理', no: 'M', company: '园区管理办公室' }, // x: [1, 4], z: [36, 40],
{ x: [28, 31], z: [28, 32], type: 'office', zone: '加速区', no: '', company: '' }, // x: [6, 12], z: [36, 40]
{ x: [14, 16], z: [36, 40], type: 'office', zone: '加速区', no: 'A5', company: '昆明智海银高文化科技' },
{ x: [18, 21], z: [36, 40], type: 'office', zone: '加速区', no: 'A4', company: '云南宸中低空经济' },
{ x: [23, 26], z: [36, 40], type: 'office', zone: '加速区', no: 'A3', company: '中泰研学合作' },
@@ -152,22 +152,14 @@ const cz = (z) => (z - D / 2) * U;
/* ---------- 基础组件 ---------- */
function Wall({ x, z, w, h, axis = 'z', color = WALL_COLOR, edge = WALL_EDGE, y = 0, gridLabel = '' }) {
function Wall({ x, z, w, h, axis = 'z', color = WALL_COLOR, edge = WALL_EDGE, y = 0 }) {
const size = axis === 'z' ? [w, h, T] : [T, h, w];
return (
<group position={[x, y + h / 2, z]}>
<mesh castShadow receiveShadow>
<boxGeometry args={size} />
<meshStandardMaterial color={color} roughness={0.82} metalness={0.03} />
<Edges color={edge} threshold={20} />
</mesh>
{/* 临时调试:墙面数值标签 */}
{gridLabel && (
<Html position={[0, h / 2 + 0.15, 0]} center distanceFactor={16} zIndexRange={[35, 0]} style={{ pointerEvents: 'none' }}>
<div className="wall-lab">{gridLabel}</div>
</Html>
)}
</group>
<mesh position={[x, y + h / 2, z]} castShadow receiveShadow>
<boxGeometry args={size} />
<meshStandardMaterial color={color} roughness={0.82} metalness={0.03} />
<Edges color={edge} threshold={20} />
</mesh>
);
}
@@ -592,14 +584,12 @@ function Building() {
/* ===== 4. 墙体(像素墙段精确生成,无交叉穿出) ===== */
HWALLS.forEach(([z, x0, x1], i) => {
walls.push(
<Wall key={`h_${i}`} x={cx((x0 + x1) / 2)} z={cz(z)} w={(x1 - x0 + 1) * U} h={ROOM_H} axis="z" y={FLOOR2}
gridLabel={`z=${z} x${x0}-${x1}`} />
<Wall key={`h_${i}`} x={cx((x0 + x1) / 2)} z={cz(z)} w={(x1 - x0 + 1) * U} h={ROOM_H} axis="z" y={FLOOR2} />
);
});
VWALLS.forEach(([x, z0, z1], i) => {
walls.push(
<Wall key={`v_${i}`} x={cx(x)} z={cz((z0 + z1) / 2)} w={(z1 - z0 + 1) * U} h={ROOM_H} axis="x" y={FLOOR2}
gridLabel={`x=${x} z${z0}-${z1}`} />
<Wall key={`v_${i}`} x={cx(x)} z={cz((z0 + z1) / 2)} w={(z1 - z0 + 1) * U} h={ROOM_H} axis="x" y={FLOOR2} />
);
});
@@ -637,31 +627,6 @@ function Building() {
);
}
/* ---------- 临时坐标轴指示(XYZ,用于点位沟通调试) ---------- */
function TempAxis() {
return (
<group position={[0, 0, 0]}>
{/* 三色轴:X 红 → +x,Y 绿 ↑ +y,Z 蓝 → +z(长度 6) */}
<axesHelper args={[6]} />
{/* 轴端文字标签 */}
<Html position={[6.4, 0, 0]} center distanceFactor={20} zIndexRange={[30, 0]} style={{ pointerEvents: 'none' }}>
<div className="ax-lab ax-x">+X </div>
</Html>
<Html position={[0, 6.5, 0]} center distanceFactor={20} zIndexRange={[30, 0]} style={{ pointerEvents: 'none' }}>
<div className="ax-lab ax-y">+Y </div>
</Html>
<Html position={[0, 0, 6.4]} center distanceFactor={20} zIndexRange={[30, 0]} style={{ pointerEvents: 'none' }}>
<div className="ax-lab ax-z">+Z </div>
</Html>
{/* 原点 */}
<mesh position={[0, 0, 0]}>
<sphereGeometry args={[0.18, 12, 12]} />
<meshStandardMaterial color="#f04438" />
</mesh>
</group>
);
}
/* ---------- 场景 ---------- */
export default function Building3D({ interactive = true }) {
return (
@@ -683,10 +648,7 @@ export default function Building3D({ interactive = true }) {
<Grid position={[0, -0.62, 0]} args={[80, 80]} cellSize={0.8} cellThickness={0.6} cellColor="#d3e0f0"
sectionSize={4} sectionThickness={1} sectionColor="#eef2f8" fadeDistance={40} fadeStrength={2.5} infiniteGrid />
{/* 临时坐标轴指示(原点位于模型中心,X 红 / Y 绿 / Z 蓝) */}
<TempAxis />
<OrbitControls makeDefault autoRotate={false} autoRotateSpeed={0.5} enablePan={false} enableZoom={interactive}
<OrbitControls makeDefault autoRotate={interactive} autoRotateSpeed={0.5} enablePan={false} enableZoom={interactive}
minDistance={10} maxDistance={55} maxPolarAngle={Math.PI / 2.05} minPolarAngle={Math.PI / 7} target={[0, 1.6, 0]} />
</Canvas>
</div>