Getting Started

Quick Start

Create your first single-player or multiplayer browser game with MavonEngine, the Three.js game engine.

Single-player setup

The minimum setup for a single-player Three.js game requires a Game instance.

import Game from '@mavonengine/core/Game'

const game = new Game([
  // Assets to load on start, see Resources
  { name: 'character', type: 'gltfModel', path: '/character.glb' },
])

Game is a singleton. Call Game.instance() to get the instance. It automatically:

  • Creates a <canvas> and appends it to the document
  • Sets up the WebGL renderer, perspective camera, and audio listener
  • Starts the render loop via requestAnimationFrame
  • Sets up the input manager (keyboard, mouse and gamepads)

Pass a Rapier world as the second argument to enable physics, see Physics.

Loading a scene and capping the frame rate

// Load scenes/main.json (lights, ground, models…)
game.openScene('main')

// Render at most 60 frames per second. 0 = no limit
game.renderer.maxFps = 60

maxFps only throttles rendering: the game tick and physics keep their own rate. It can also be changed live in the debug panel.

Multiplayer setup

For multiplayer, the server runs BaseGame headlessly and clients run Game. The quickest way is the multiplayer template:

npx @mavonengine/cli create my-game

See the Networking section for the full setup.

Development mode

Append #debug to your URL to enable the debug panel (Tweakpane) and the physics collider overlay.

http://localhost:8050/#debug

Press . to open the level editor.

Next steps