/
RaskolnickOFF
/
3D
Обзор
Документация
Войти
/
RaskolnickOFF
/
3D
Код
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
js/source/core/GameRuntime.js
61 строка
2 KB
RaskolnickOFF
Structure update
06 июн 2026, 03:18
06 июн 2026, 03:18
9bc1c25
Код
Авторство
О чём код?
// js/source/core/GameRuntime.js — главный цикл игры, обновление и рендеринг import { Components } from './Components.js'; export class GameRuntime { constructor({ ENGINE, EVENTBUS, PIPELINE, RENDERER, SCENE, CAMERA, SETTINGS, FPS, playerEntity, inventorySystem, rain, heightmapData, weatherSystem }) { this.engine = ENGINE; this.eventBus = EVENTBUS; this.pipeline = PIPELINE; this.renderer = RENDERER; this.scene = SCENE; this.camera = CAMERA; this.playerEntity = playerEntity; this.inventorySystem = inventorySystem; this.settings = SETTINGS; this._fpsCounter = FPS; this.rain = rain; this.weatherSystem = weatherSystem; this.heightmapData = heightmapData; this._lastTime = performance.now(); this._running = false; } start() { if (this._running) return; // Если уже запущено, ничего не делаем this._running = true; this._lastTime = performance.now(); this._tick = this._tick.bind(this); this.renderer.setAnimationLoop(this._tick); } stop() { if (!this._running) return; // Если уже остановлено, ничего не делаем this._running = false; this.renderer.setAnimationLoop(null); } _tick() { const now = performance.now(); const rawDt = (now - this._lastTime) / 1000; const dt = Math.min(rawDt, 0.05); this._lastTime = now; this.engine.update(dt); // Обновление дождя (если есть) if (this.rain && this.weatherSystem && this.playerEntity && this.renderer) { const transform = this.playerEntity.get(Components.TRANSFORM); if (transform) { this.rain.update(dt, this.weatherSystem, transform.x, transform.z, this.renderer); } } this._fpsCounter.update(this.renderer); this.renderer.render(this.scene, this.camera); } }