Rendering performace on F3

This commit is contained in:
2026-10-02 21:21:19 -03:00
parent 1511338a23
commit dcaf878254
9 changed files with 426 additions and 53 deletions
+13 -6
View File
@@ -9,6 +9,7 @@ import { Camera } from "./camera.ts";
import { Options } from "./options.ts";
import { MultiPlayerGameMode } from "./game_mode.ts";
import { ClientPacketListener } from "./packet_listener.ts";
import { profiler } from "./profiler.ts";
import { GameRenderer } from "./rendering/game_renderer.ts";
import { ChatComponent } from "./gui/chat_component.ts";
import { GuiMenuScreen, GuiScreen } from "./gui/gui_screen.ts";
@@ -148,13 +149,19 @@ export class Client {
this.#pending_time += delta;
let ticks = 0;
while (this.#pending_time >= TICK_DELTA && ticks < MAX_TICKS_PER_FRAME) {
this.tick();
if (this.#stopped) {
return;
const stopped = profiler.section("ticks", () => {
while (this.#pending_time >= TICK_DELTA && ticks < MAX_TICKS_PER_FRAME) {
this.tick();
if (this.#stopped) {
return true;
}
this.#pending_time -= TICK_DELTA;
ticks += 1;
}
this.#pending_time -= TICK_DELTA;
ticks += 1;
return false;
});
if (stopped) {
return;
}
if (ticks === MAX_TICKS_PER_FRAME) {
this.#pending_time = Math.min(this.#pending_time, TICK_DELTA);