From 5852a972f40abe508336944e6115206152f23f6e Mon Sep 17 00:00:00 2001 From: marti Date: Sun, 28 Dec 2025 20:12:32 +0100 Subject: [PATCH] Fix: Correct door alignment for East and West walls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Fixed wallOffset calculation for E/W walls - Both E and W walls need inverted offset due to rotation=π/2 - Local X axis points to -Z for both walls when rotated 90° - Door gaps and door meshes now perfectly aligned on all walls (N/S/E/W) - Resolves misalignment issue where E/W doors didn't match their wall gaps --- src/main.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.js b/src/main.js index b40ed5a..02c6569 100644 --- a/src/main.js +++ b/src/main.js @@ -919,15 +919,18 @@ function getDoorWorldPosition(room, door, centerX, centerZ, halfSizeX, halfSizeZ meshPos.z = doorWorldPos.z; rotation = Math.PI / 2; // Offset relativo al centro de la pared - wallOffset = doorWorldPos.z - centerZ; + // Con rotation=π/2, el eje X local apunta hacia -Z, entonces: + // offset_local = -(doorZ - centerZ) + wallOffset = -(doorWorldPos.z - centerZ); break; case 'W': // Pared Oeste: puerta alineada en Z, X en el borde oeste meshPos.x = centerX - halfSizeX; meshPos.z = doorWorldPos.z; rotation = Math.PI / 2; - // Para pared Oeste, el offset es directo (sin inversión) - wallOffset = doorWorldPos.z - centerZ; + // Con rotation=π/2, el eje X local apunta hacia -Z (igual que pared E) + // Por tanto, también necesita offset invertido + wallOffset = -(doorWorldPos.z - centerZ); break; }