Enhance displacement calculation and UV mapping; add gizmo visualization in viewer

This commit is contained in:
CNCKitchen
2026-03-16 21:09:12 +01:00
parent 92e7f487ce
commit 59b689c9ef
5 changed files with 114 additions and 15 deletions
+3 -3
View File
@@ -78,9 +78,9 @@ export function computeUV(pos, normal, mode, settings, bounds) {
const az = Math.abs(normal.z);
let uRaw, vRaw;
if (ax >= ay && ax >= az) {
// ±X dominant → project onto YZ
uRaw = (pos.y - min.y) / Math.max(size.y, 1e-6);
vRaw = (pos.z - min.z) / Math.max(size.z, 1e-6);
// ±X dominant → project onto ZY (U=Z, V=Y keeps texture upright on side faces)
uRaw = (pos.z - min.z) / Math.max(size.z, 1e-6);
vRaw = (pos.y - min.y) / Math.max(size.y, 1e-6);
} else if (ay >= ax && ay >= az) {
// ±Y dominant → project onto XZ
uRaw = (pos.x - min.x) / Math.max(size.x, 1e-6);