/
RaskolnickOFF
/
3D
Обзор
Документация
Войти
/
RaskolnickOFF
/
3D
Код
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
js/debug/WeatherDebugOverlay.js
84 строки
3 KB
RaskolnickOFF
debug refactor part 2
15 июн 2026, 22:32
15 июн 2026, 22:32
f4de7c0
Код
Авторство
О чём код?
// js/debug/WeatherDebugOverlay.js // Дебаг-панель управления погодой import LIB from 'LIB'; export class WeatherDebugOverlay { constructor(timeInterval, SETTINGS, container) { this.settings = SETTINGS; if (!this.settings.debug.weather) return; this.cfg = this.settings.UI.debug; this._interval = timeInterval; this.timer = 0; this.container = container; this.rainfallCount = this.settings .weather.rain.particleCount; this.env = null; this._renderDOM(this.container); } _renderDOM(container) { if (!this.settings.debug.weather) return; const label = document.createElement('label'); const span = document.createElement('span'); this.currentWeather = span; span.textContent = this.cfg.weatherCurrent; label.append(span); const intensityLabel = document.createElement('label'); const intensitySpan = document.createElement('span'); this.currentIntensity = intensitySpan; intensitySpan.textContent = this.cfg.weatherIntensity; const intensityLine = LIB.dom.range( this.settings.debug.weatherIntensityValue, this.cfg.weatherIntensityClass, null, //id is null this.settings.debug.weatherIntensityMin, this.settings.debug.weatherIntensityMax, this.settings.debug.weatherIntensityStep ); this.intensityLine = intensityLine; const buttonsLine = LIB.dom.buttonsRow([ [this.cfg.weatherStatus.clear, 'force-clear'], [this.cfg.weatherStatus.rain, 'force-rain'], [this.cfg.weatherStatus.snow, 'force-snow'] ], null, this.cfg.weatherButtonClass); intensityLabel.append(intensitySpan, intensityLine, buttonsLine); container.append(label, intensityLabel); } update(env, acc) { if (!this.settings.debug.weather) return; this.timer += acc; if (this.timer < this._interval) return; this.timer -= this._interval; this.env = env; //Текущая погода const weather = this.env.weather; this.currentWeather.textContent = ` ${this.cfg.weatherCurrent} ${this.cfg.weatherStatus[weather]}`; // Интенсивность const intensity = this.env.weatherIntensity; this.currentIntensity.textContent = ` ${this.cfg.weatherIntensity} ${intensity.toFixed(2)} / ${this.cfg.weatherRainfall} ${this.rainfallCount}`; this.intensityLine.value = intensity; // ??? // const transition = this.env.weatherTransition; // if (transition > 0 && transition < 1) { // console.log(transition.toFixed(2)); // } } updateInterval(interval) { if (!this.settings.debug.weather) return; if (interval !== this._interval) { this.settings.debug.weatherInterval = interval; this._interval = interval; } } }