From b820ad11bdbb0229450afc3b0d98dc3f7f78b926 Mon Sep 17 00:00:00 2001 From: min Date: Mon, 8 Jun 2026 16:05:30 +0300 Subject: [PATCH] =?UTF-8?q?feat(rbxl):=20Day/Night=20=D1=83=D1=81=D0=BA?= =?UTF-8?q?=D0=BE=D1=80=D0=B5=D0=BD=D0=B8=D0=B5=208x=20=D0=B4=D0=BB=D1=8F?= =?UTF-8?q?=20=D0=B8=D0=BC=D0=BF=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2?= =?UTF-8?q?=D0=B0=D0=BD=D0=BD=D1=8B=D1=85=20=D0=BA=D0=B0=D1=80=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Roblox Day/Night скрипт идёт wait(0.01) + 0.1 минуты = очень медленно. В оригинале это типичный паттерн, юзеру не очень видно. Ускоряем в 8x для импортированных скриптов: накопленная дельта часов от Lua-скрипта × 8 → реальный hour для setTimeOfDay. Юзер видит полный цикл день↔ночь за 10-15 секунд вместо часа. Также убрал debug-лог lightingTimeUpdate (мешал). --- src/editor/engine/GameRuntime.js | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/editor/engine/GameRuntime.js b/src/editor/engine/GameRuntime.js index 2d2f777..544de79 100644 --- a/src/editor/engine/GameRuntime.js +++ b/src/editor/engine/GameRuntime.js @@ -213,26 +213,22 @@ export class GameRuntime { } } else if (cmd === 'lightingTimeUpdate') { // Roblox Lighting:SetMinutesAfterMidnight → Babylon небо. - const now = performance.now(); - if (!this._lastLightUpdate || now - this._lastLightUpdate > 250) { - this._lastLightUpdate = now; - try { - const hour = Number(payload?.hour); - // Debug-лог (первые несколько раз) - if (!this._lightDbgCount) this._lightDbgCount = 0; - if (this._lightDbgCount < 5) { - this._lightDbgCount++; - console.log('[lightingTimeUpdate]', { payload, hour, - hasSetTimeOfDay: typeof this.scene3d?.setTimeOfDay, - hasEnvironment: !!this.scene3d?.environment }); + // Ускоряем в 8x чтобы юзер увидел переход день↔ночь + // в течение ~5 секунд после Play. + try { + const baseHour = Number(payload?.hour); + if (baseHour >= 0 && baseHour < 24) { + if (this._lightBaseHour == null) { + this._lightBaseHour = baseHour; + this._lightStartReal = performance.now(); } - if (hour >= 0 && hour < 24) { - this.scene3d?.setTimeOfDay?.(hour); - } - } catch (e) { - console.error('[lightingTimeUpdate] error:', e); + // Δigh-час относительно стартовой + const dGame = baseHour - this._lightBaseHour; + const accel = 8; + const hour = ((this._lightBaseHour + dGame * accel) % 24 + 24) % 24; + this.scene3d?.setTimeOfDay?.(hour); } - } + } catch (_) {} } else if (cmd === 'particleCreated') { // Roblox Instance.new('Sparkles') — запомнили какие // partlcle-эффекты есть у Tool. При equip покажем у руки.