From 6bec44d778e2251b6d02355b4aacc105e0677572 Mon Sep 17 00:00:00 2001 From: min Date: Mon, 8 Jun 2026 15:49:04 +0300 Subject: [PATCH] =?UTF-8?q?fix(lua):=20=D1=82=D1=80=D0=BE=D1=82=D1=82?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD=D0=B3=20lightingTimeUpdate=20=D0=B4=D0=BE=20?= =?UTF-8?q?250=D0=BC=D1=81=20=D0=BD=D0=B0=20shim-=D1=81=D1=82=D0=BE=D1=80?= =?UTF-8?q?=D0=BE=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Day/Night скрипт в Roblox: while true do wait(0.01); SetMinutes(+0.1) end = 100+ Hz обновлений Lighting.ClockTime. Каждое слало lightingTimeUpdate через send() из coroutine, что (вероятно) вызывает WASM access crash. Тротлинг прямо в SetMinutesAfterMidnight — не чаще раза в 250мс. Lua-сторона продолжает делать высокочастотные обновления _minutes/ClockTime (скрипт работает корректно), но в JS уходит только 4 раза в секунду. --- src/editor/engine/lua/RobloxShim.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/editor/engine/lua/RobloxShim.js b/src/editor/engine/lua/RobloxShim.js index 60122d6..5bfd169 100644 --- a/src/editor/engine/lua/RobloxShim.js +++ b/src/editor/engine/lua/RobloxShim.js @@ -910,10 +910,15 @@ export function registerRobloxShim(lua, opts) { lighting.FogColor = new RbxColor3(0.75, 0.75, 0.75); lighting._minutes = 14 * 60; lighting.GetMinutesAfterMidnight = function () { return lighting._minutes; }; + let _lastLightSent = 0; lighting.SetMinutesAfterMidnight = function (m) { lighting._minutes = (Number(m) || 0) % 1440; lighting.ClockTime = lighting._minutes / 60; - // Шлём в GameRuntime для обновления реального неба Babylon + // Тротлинг: не чаще раза в 250мс. Скрипты Day/Night обновляют это + // каждый кадр (100+ Hz), это убивает WASM. + const now = performance.now(); + if (now - _lastLightSent < 250) return; + _lastLightSent = now; send('lightingTimeUpdate', { hour: lighting.ClockTime }); }; lighting.GetMoonDirection = function () { return new RbxVector3(0, 1, 0); };