diff --git a/cmd/client/input.go b/cmd/client/input.go index 4f658047..6b6cdf37 100644 --- a/cmd/client/input.go +++ b/cmd/client/input.go @@ -97,6 +97,8 @@ func (in *inputState) mouseButtonCallback(_ *glfw.Window, button glfw.MouseButto } // cursorCallback 鼠标移动:yaw/pitch 累积(渲染.md §2 主线程消费)。 +// 约定:鼠标右移 dx>0 应右转(yaw 减小——yaw=0 朝向 -Z,右转朝 +X); +// 鼠标上移 dy<0 应抬头(pitch 增大)。 func (in *inputState) cursorCallback(_ *glfw.Window, x, y float64) { in.cursorX, in.cursorY = x, y if in.firstMouse { @@ -107,7 +109,7 @@ func (in *inputState) cursorCallback(_ *glfw.Window, x, y float64) { dx, dy := x-in.lastX, y-in.lastY in.lastX, in.lastY = x, y const sens = 0.0025 - in.dyaw += dx * sens + in.dyaw -= dx * sens in.dpitch -= dy * sens } diff --git a/internal/mesh/mesh.go b/internal/mesh/mesh.go index ca4ed8a5..2f5dafcb 100644 --- a/internal/mesh/mesh.go +++ b/internal/mesh/mesh.go @@ -69,13 +69,16 @@ type faceDef struct { } // faces 六面定义(角顺序与 UV 顶点顺序一致)。 +// 绕序铁律:所有面必须为「窗口空间顺时针」(FrontFace=CW 的正面)—— +// 旧定义只有顶面是 CW,垂直面与底面是 CCW 被背面剔除, +// 表现为「立面透明的空洞、移动时面闪烁」(方格立面缺失根因)。 var faces = [6]faceDef{ {dir: [3]int32{0, 1, 0}, corners: [4][3]int32{{0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1}}}, // 顶 - {dir: [3]int32{0, -1, 0}, corners: [4][3]int32{{0, 0, 1}, {1, 0, 1}, {1, 0, 0}, {0, 0, 0}}}, // 底 - {dir: [3]int32{1, 0, 0}, corners: [4][3]int32{{1, 0, 0}, {1, 0, 1}, {1, 1, 1}, {1, 1, 0}}}, // 东(+x) - {dir: [3]int32{-1, 0, 0}, corners: [4][3]int32{{0, 0, 1}, {0, 0, 0}, {0, 1, 0}, {0, 1, 1}}}, // 西(-x) - {dir: [3]int32{0, 0, 1}, corners: [4][3]int32{{1, 0, 1}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}}}, // 南(+z) - {dir: [3]int32{0, 0, -1}, corners: [4][3]int32{{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}}, // 北(-z) + {dir: [3]int32{0, -1, 0}, corners: [4][3]int32{{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}}, // 底(反向) + {dir: [3]int32{1, 0, 0}, corners: [4][3]int32{{1, 1, 0}, {1, 1, 1}, {1, 0, 1}, {1, 0, 0}}}, // 东(+x)(反向) + {dir: [3]int32{-1, 0, 0}, corners: [4][3]int32{{0, 1, 1}, {0, 1, 0}, {0, 0, 0}, {0, 0, 1}}}, // 西(-x)(反向) + {dir: [3]int32{0, 0, 1}, corners: [4][3]int32{{1, 1, 1}, {0, 1, 1}, {0, 0, 1}, {1, 0, 1}}}, // 南(+z)(反向) + {dir: [3]int32{0, 0, -1}, corners: [4][3]int32{{0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 0}}}, // 北(-z)(反向) } // faceTexture 面方向 → 注册表纹理面名(block.Registry.Texture 参数)。 diff --git a/internal/render/overlay_gl.go b/internal/render/overlay_gl.go index 507577f4..6293bf6d 100644 --- a/internal/render/overlay_gl.go +++ b/internal/render/overlay_gl.go @@ -14,14 +14,15 @@ import ( "github.com/go-gl/gl/v3.3-core/gl" ) -// cubeFaces 单位立方体 6 面角顺序(与 mesh.faceDef 一致,CW 绕序为正面)。 +// cubeFaces 单位立方体 6 面角顺序(与 mesh.faceDef 一致, +// 窗口空间 CW 绕序为 FrontFace(CW) 的正面)。 var cubeFaces = [6][4][3]float32{ {{0, 1, 0}, {1, 1, 0}, {1, 1, 1}, {0, 1, 1}}, // 顶 - {{0, 0, 1}, {1, 0, 1}, {1, 0, 0}, {0, 0, 0}}, // 底 - {{1, 0, 0}, {1, 0, 1}, {1, 1, 1}, {1, 1, 0}}, // 东(+x) - {{0, 0, 1}, {0, 0, 0}, {0, 1, 0}, {0, 1, 1}}, // 西(-x) - {{1, 0, 1}, {0, 0, 1}, {0, 1, 1}, {1, 1, 1}}, // 南(+z) - {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}}, // 北(-z) + {{0, 0, 0}, {1, 0, 0}, {1, 0, 1}, {0, 0, 1}}, // 底(反向) + {{1, 1, 0}, {1, 1, 1}, {1, 0, 1}, {1, 0, 0}}, // 东(+x)(反向) + {{0, 1, 1}, {0, 1, 0}, {0, 0, 0}, {0, 0, 1}}, // 西(-x)(反向) + {{1, 1, 1}, {0, 1, 1}, {0, 0, 1}, {1, 0, 1}}, // 南(+z)(反向) + {{0, 1, 0}, {1, 1, 0}, {1, 0, 0}, {0, 0, 0}}, // 北(-z)(反向) } // cubeVerts 按六面 UV 构建单位立方体顶点(mesh.Vertex 格式:pos+uv+light 字节,