fix: v2.2 修复 3D 截图纯色空白(墙体尺寸单位错误)
- 根因: 墙体宽度 bw=1/S*0.72 误用模型单位(≈最大边长*0.72, 数千单位) 而放置坐标是世界单位(窗体≈1), 相机被包在巨墙内只见背景色 - 改为世界单位: 上下墙覆盖窗洞±2.2x0.55, 左右墙 0.55x窗高 - 墙体不投影(避免自遮挡), 地面尺寸同步修正 - Node 验证四墙尺寸全部 ≤2.2 世界单位
This commit is contained in:
@@ -308,30 +308,34 @@ function build(drawing: DrawingData) {
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 墙体洞口 + 地面 ----
|
||||
// ---- 墙体洞口 + 地面(世界单位:窗体约 1 单位见方)----
|
||||
if (showWall.value) {
|
||||
const bw = 1 / S * 0.72, bh = 1 / S * 0.72
|
||||
const wx0 = -gw * S / 2 - 0.06, wx1 = gw * S / 2 + 0.06
|
||||
const wy0 = -gh * S / 2 - 0.04, wy1 = gh * S / 2 + 0.06
|
||||
const hw = gw * S / 2 + 0.05 // 窗洞半宽
|
||||
const hh = gh * S / 2 + 0.05 // 窗洞半高
|
||||
const side = 0.55 // 上下墙高度/左右墙宽度
|
||||
const wt = DEPTH * 3
|
||||
const wallBoxes: [number, number, number, number, number][] = [
|
||||
[wx0 - bw, wy1, bw * 2, bh], // 上
|
||||
[wx0 - bw, wy0 - bh, bw * 2, bh], // 下
|
||||
[wx0 - bw, wy0, bw, wy1 - wy0], // 左
|
||||
[wx1, wy0, bw, wy1 - wy0], // 右
|
||||
[-hw - side, hh, side * 2 + hw * 2, side], // 上
|
||||
[-hw - side, -hh - side, side * 2 + hw * 2, side], // 下
|
||||
[-hw - side, -hh, side, hh * 2], // 左
|
||||
[hw, -hh, side, hh * 2], // 右
|
||||
]
|
||||
for (const [px, py, pw, ph] of wallBoxes) {
|
||||
const m = new THREE.Mesh(new THREE.BoxGeometry(pw, ph, wt), wallMat)
|
||||
m.position.set(px + pw / 2, py + ph / 2, 0)
|
||||
m.receiveShadow = true
|
||||
m.userData.isWall = true
|
||||
sceneRoot.add(m)
|
||||
}
|
||||
const ground = new THREE.Mesh(new THREE.BoxGeometry(bw * 4, 0.02, DEPTH * 8), groundMat)
|
||||
ground.position.set(0, wy0 - 0.02, DEPTH * 2)
|
||||
const ground = new THREE.Mesh(new THREE.BoxGeometry(3, 0.02, DEPTH * 8), groundMat)
|
||||
ground.position.set(0, -hh - side - 0.02, DEPTH * 2)
|
||||
ground.receiveShadow = true
|
||||
sceneRoot.add(ground)
|
||||
}
|
||||
sceneRoot.traverse(o => { if ((o as THREE.Mesh).isMesh) { o.castShadow = true; o.receiveShadow = true } })
|
||||
sceneRoot.traverse(o => {
|
||||
const m = o as THREE.Mesh
|
||||
if (m.isMesh) { m.castShadow = !m.userData.isWall; m.receiveShadow = true }
|
||||
})
|
||||
// 玻璃不投影
|
||||
sceneRoot.traverse(o => {
|
||||
const mat = (o as THREE.Mesh).material as THREE.Material | undefined
|
||||
|
||||
Reference in New Issue
Block a user