Networking
MavonEngine uses an authoritative server architecture for multiplayer. The server is the single source of truth — clients send commands, the server processes them, and broadcasts state back to clients.
Reference: The architecture is inspired by Gaffer On Games and Source Engine Multiplayer Networking.
Transport
Real-time data is sent over UDP via WebRTC using geckos.io. This gives low-latency unreliable messaging suitable for game state synchronization.
Architecture overview
Client Server
│ │
│── command (input) ──────────► │
│ │ 1) process command
│ │ 2) step physics
│ │ 3) update state
│◄── state sync (tick) ──────── │
│ │
- Client captures input and sends commands to the server
- Server queues commands in a command buffer
- On each tick, the server processes commands, steps physics, and broadcasts world state
- State is only sent to clients within the visibility radius of each entity
Shared 3D scene
Both server and client run a Three.js scene, but they serve different purposes. The client holds the full scene - detailed meshes, materials, and visual geometry. The server holds simplified hitbox meshes - lightweight geometry used exclusively for spatial queries.
This means the server can perform authoritative raycasting, hit detection, and area-of-effect checks directly against its scene without trusting client-reported positions, and without the overhead of full visual geometry.
// Server-side raycasting against hitbox meshes
const raycaster = new THREE.Raycaster()
raycaster.set(origin, direction)
const hits = raycaster.intersectObjects(game.scene.children, true)