Skip to content

debug

The debug utility provides a fixed on-screen display for monitoring real-time game performance (FPS/millisecond), engine metrics and network synchronization. This HUD is hidden from the user, and can be toggled on/off with the F6 key.

Debug public

Bounded to game as game.debug. Alias: game.debugType

Properties

PropertyTypeDescription
visiblebooleanIndicates if the debug overlay is currently displayed.
ticksnumberCounter for total frames processed by the renderer.
statsStatsInstance of the stats.js monitoring library.
debugElemHTMLElementThe DOM element used to display text-based metrics.
Debug HUD

The debug overlay displays the following metrics gathered from the engine:

MetricDescription
PingCurrent network latency in milliseconds.
Server/Client TimeCurrent timestamps from the server and local simulation.
Client LagThe difference between server time and client/real-client time.
StuttersCount of detected frame stutters.
FPSCurrent frames per second.
InterpolatingBoolean status of entity interpolation.
Tick Byte SizeSize of the last received network tick.
Pooled Entity CountsCount of pooled network entities and specific model entities.

Methods

init()

ts
function init(): void

Is called when the website loads. Initializes the debug system. Creates the HTML HUD element, configures the stats.js overlay, and attaches listeners to the renderer tick and keyboard input.

begin()

ts
function begin(): void

Starts the stats.js performance measurement. This should be called at the beginning of the frame.

end()

ts
function end(): void

Ends the stats.js performance measurement. This should be called at the end of the frame.

show()

ts
function show(): void

Enables the debug display and shows all associated HUD elements.

hide()

ts
function hide(): void

Disables the debug display and hides all associated HUD elements.

onRendererTick()

ts
function onRendererTick(): void

Callback triggered by the renderer. When visible, it updates the debug HUD text every 20 renderer ticks with the latest game metrics.

onKeyRelease(event)

ts
function onKeyRelease(event: KeyboardEvent): void

Listens for the release of the F6 (keyCode 117) key to toggle the visibility of the debug overlay