Level Editor
Early WIP — a level editor that loads directly from the running game instance on the page.
Opening the editor
The editor lives in @mavonengine/editor and is only loaded in development. Register it with Game.devModeHook before creating the game:
import Game from '@mavonengine/core/Game'
if (import.meta.env.DEV) {
Game.devModeHook = () => {
import('@mavonengine/editor').then(({ default: Editor }) => Editor.registerListener())
}
}
Then press . (or Insert) in the game. Projects made with mavonengine create are already set up.
The running game stays
The editor keeps the scene that is loaded and the connection to the game server, so the other players and everything else the server sends keep showing while you edit.
- The client tells the server it opened the editor. The server removes its player, stops counting it as a player and sends it every entity in the world, not only those near a player.
- If the editor opens before the game joined a server, the multiplayer template connects as a spectator, without a player of its own.
Layout
| Area | Built-in panels |
|---|---|
| Left | Scene (the active scene's objects, live entities and unsaved changes), Explorer |
| Bottom | Network (see below), Assets (loaded models and textures; drag one into the scene) |
| Right | Properties of the selected object |
The status bar shows connected game controllers; click one to open the controller debug view with its live buttons and sticks. When the server turned this tab's connection away, for example because its auth plugin wants a login, the status bar says so, with the reason in its tooltip.
Server and Plugins views
The activity bar on the left edge switches between the scene editor and two views that take its place. They are laid over the editor, so the viewport and the docks keep their state.
- Server lists every HTTP endpoint of the game server: method, path, where it comes from (engine, game or plugin), whether it only exists in development and what it does. See Describing routes.
- Plugins lists the plugins in the project's
mavonengine.json: version, target, description, license, supported engine range and readme, plus the HTTP endpoints and prefabs that come from each one. Plugins that are missing or invalid are listed with the reason. Below, the available plugins the project doesn't have yet, each with its readme and an Install button, and "Another package" to install anything else. Installing needsmavonengine devand asks first, see Installing plugins while it runs.
Network panel
The Network panel in the bottom dock shows the game socket of this tab and of the server, see network debugging:
- the packets and network events of the client or the server, filtered by kind, each with its payload;
- a timeline of them;
- the state sync: each player with the entities it is sent and its last state update, and its account when the server has an auth plugin.
When the server refused the connection, the panel says why.
It also switches on an overlay in the viewport:
- Server ghosts: a wireframe box per networked entity, where the server last said it is, with a line to where the client renders it. Green ghosts are in the newest state update, orange ones are known to this client but not in it, grey ones are sent to no player. Pick a player in the state sync table to colour the ghosts by what that player is sent.
- Sync radius: a ring around each player at the server's sync distance.
Saving scenes
Ctrl+S / Cmd+S saves the active scene to scenes/<name>.json through the dev server. The game server watches the file, reloads it and every client gets the new map. Placing a plugin prefab also adds it to the plugin's prefabs in mavonengine.json, so its assets are shipped in the release.
Custom panels
Dock your own tools next to the built-in panels. Give a React component, or a mount function to render with anything else:
import Editor from '@mavonengine/editor'
Editor.registerPanel({
id: 'my-tools',
title: 'My tools',
location: 'right', // 'left' | 'bottom' | 'right'
mount(container, editor) {
container.textContent = 'Hello from my panel'
return () => { container.textContent = '' } // cleanup
},
})
registerPanel() works before or after the editor boots and returns a function that removes the panel. Once booted, editor.addPanel() and editor.removePanel(id) do the same. Plugins get the editor in their editor(ctx) hook, see Plugins.