fix(studio): SkyboxManager.hexToRgb поддерживает короткий хекс #fff (был NaN в облаках)

skybox.clouds.color='#fff' → substring(4,6)='' → parseInt NaN → addColorStop
'rgba(255,15,NaN,0.9)' падал при load → прерывал загрузку проекта. hexToRgb
теперь расширяет #fff→#ffffff и подстраховывает NaN.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
min 2026-06-06 09:49:01 +03:00
parent 5d49cd9eeb
commit c9498b086e

View File

@ -80,11 +80,17 @@ function registerSkyShader() {
const hexToRgb = (hex) => { const hexToRgb = (hex) => {
if (Array.isArray(hex)) return hex; if (Array.isArray(hex)) return hex;
const h = String(hex || '#ffffff').replace('#', ''); let h = String(hex || '#ffffff').replace('#', '').trim();
// Короткая форма #fff → #ffffff.
if (h.length === 3) h = h[0] + h[0] + h[1] + h[1] + h[2] + h[2];
if (h.length < 6) h = (h + 'ffffff').slice(0, 6);
const r = parseInt(h.substring(0, 2), 16);
const g = parseInt(h.substring(2, 4), 16);
const b = parseInt(h.substring(4, 6), 16);
return [ return [
parseInt(h.substring(0, 2), 16) / 255, (Number.isFinite(r) ? r : 255) / 255,
parseInt(h.substring(2, 4), 16) / 255, (Number.isFinite(g) ? g : 255) / 255,
parseInt(h.substring(4, 6), 16) / 255, (Number.isFinite(b) ? b : 255) / 255,
]; ];
}; };