From 08ab85ba7588e7f650605a6138a13c492367e8d9 Mon Sep 17 00:00:00 2001 From: CNCKitchen Date: Wed, 18 Mar 2026 16:41:13 +0100 Subject: [PATCH] feat: update UI labels and improve scaling parameters for better user experience --- README.md | 2 ++ index.html | 6 +++--- js/i18n.js | 4 ++-- js/main.js | 14 +++++++------- js/mapping.js | 4 ++-- js/previewMaterial.js | 4 ++-- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 169f3a4..99904c6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # STL Texturizer +**Live demo:** https://cnckitchen.github.io/stlTexturizer/ + A browser-based tool for applying surface displacement textures to STL files — no installation required. Load any `.stl` file, pick a texture, tune the parameters, and export a new displaced STL ready for slicing. diff --git a/index.html b/index.html index 0ddaa87..7adb34f 100644 --- a/index.html +++ b/index.html @@ -149,7 +149,7 @@
- +
@@ -165,7 +165,7 @@
- +
@@ -283,7 +283,7 @@

Export ⓘ

- +
diff --git a/js/i18n.js b/js/i18n.js index 3516813..194767e 100644 --- a/js/i18n.js +++ b/js/i18n.js @@ -47,7 +47,7 @@ export const TRANSLATIONS = { 'tooltips.proportionalScalingAria': 'Proportional scaling (U = V)', // Displacement section - 'sections.displacement': 'Displacement', + 'sections.displacement': 'Texture Depth', 'labels.amplitude': 'Amplitude', // Surface mask section @@ -143,7 +143,7 @@ export const TRANSLATIONS = { 'ui.loadStl': 'STL laden\u2026', // Displacement map section - 'sections.displacementMap': 'Verschiebungstextur', + 'sections.displacementMap': 'Textur', 'ui.uploadCustomMap': 'Eigene Textur hochladen', 'ui.noMapSelected': 'Keine Textur ausgew\u00e4hlt', diff --git a/js/main.js b/js/main.js index 30a357a..a228956 100644 --- a/js/main.js +++ b/js/main.js @@ -117,12 +117,12 @@ const exclSectionHeading = document.getElementById('excl-section-heading'); const exclHint = document.getElementById('excl-hint'); // ── Scale slider log helpers ────────────────────────────────────────────────── -// Slider stores 0–1000; actual scale spans 0.1–10 on a log axis. -// Middle position 500 → scale 1.0 (exact midpoint on log scale). -const _LOG_MIN = Math.log(0.1); +// Slider stores 0–1000; actual scale spans 0.05–10 on a log axis. +// Middle position 500 → scale ~0.71 (log midpoint between 0.05 and 10). +const _LOG_MIN = Math.log(0.05); const _LOG_MAX = Math.log(10); -const scaleToPos = v => Math.round((Math.log(Math.max(0.1, Math.min(10, v))) - _LOG_MIN) / (_LOG_MAX - _LOG_MIN) * 1000); -const posToScale = p => parseFloat(Math.exp(_LOG_MIN + (p / 1000) * (_LOG_MAX - _LOG_MIN)).toFixed(1)); +const scaleToPos = v => Math.round((Math.log(Math.max(0.05, Math.min(10, v))) - _LOG_MIN) / (_LOG_MAX - _LOG_MIN) * 1000); +const posToScale = p => parseFloat(Math.exp(_LOG_MIN + (p / 1000) * (_LOG_MAX - _LOG_MIN)).toFixed(2)); // ── Init ────────────────────────────────────────────────────────────────────── @@ -261,7 +261,7 @@ function wireEvents() { // Scale U — when lock is on, mirror to V const applyScaleU = (v) => { - v = Math.max(0.1, Math.min(10, v)); + v = Math.max(0.05, Math.min(10, v)); settings.scaleU = v; scaleUSlider.value = scaleToPos(v); scaleUVal.value = v; @@ -273,7 +273,7 @@ function wireEvents() { // Scale V — when lock is on, mirror to U const applyScaleV = (v) => { - v = Math.max(0.1, Math.min(10, v)); + v = Math.max(0.05, Math.min(10, v)); settings.scaleV = v; scaleVSlider.value = scaleToPos(v); scaleVVal.value = v; diff --git a/js/mapping.js b/js/mapping.js index f618c7a..4894409 100644 --- a/js/mapping.js +++ b/js/mapping.js @@ -96,8 +96,8 @@ export function computeUV(pos, normal, mode, settings, bounds) { const az = Math.abs(normal.z); let uRaw, vRaw; if (ax >= ay && ax >= az) { - uRaw = (pos.z - min.z) / md; - vRaw = (pos.y - min.y) / md; + uRaw = (pos.y - min.y) / md; + vRaw = (pos.z - min.z) / md; } else if (ay >= ax && ay >= az) { uRaw = (pos.x - min.x) / md; vRaw = (pos.z - min.z) / md; diff --git a/js/previewMaterial.js b/js/previewMaterial.js index 58202e8..22f9bea 100644 --- a/js/previewMaterial.js +++ b/js/previewMaterial.js @@ -66,7 +66,7 @@ const fragmentShader = /* glsl */` uv -= 0.5; uv = vec2(c * uv.x - s * uv.y, s * uv.x + c * uv.y); uv += 0.5; - return texture2D(displacementMap, fract(uv)).r; + return texture2D(displacementMap, uv).r; } // Height at this fragment for all projection modes. @@ -134,7 +134,7 @@ const fragmentShader = /* glsl */` // Picks the single planar projection whose axis is most aligned with the face normal. vec3 absN = abs(MN); if (absN.x >= absN.y && absN.x >= absN.z) { - return sampleMap(vec2((pos.z - boundsMin.z) / md, (pos.y - boundsMin.y) / md)); + return sampleMap(vec2((pos.y - boundsMin.y) / md, (pos.z - boundsMin.z) / md)); } else if (absN.y >= absN.x && absN.y >= absN.z) { return sampleMap(vec2((pos.x - boundsMin.x) / md, (pos.z - boundsMin.z) / md)); } else {