Logic Graphs
A logic graph is game logic made of nodes instead of code: events start a run, exec edges put its steps in order, and value nodes work out what the steps need. You make them in the level editor's Graphs view, and a LogicGraph object in a scene runs one on the client, the server or both.

The template's NPC
The multiplayer template ships one: graphs/server-npc.graph.json. A ServerNpc in scenes/main.json is a networked entity that does nothing on its own. A LogicGraph object next to it runs server-npc on the server with the NPC as its Self, so the server walks it back and forth, and every player sees it move through the usual state sync.
{
"id": "server_npc_logic",
"type": "LogicGraph",
"name": "Server NPC logic",
"transform": { "position": [0, 0, -6], "rotation": [0, 0, 0], "scale": [1, 1, 1] },
"props": {
"graph": "server-npc",
"side": "server",
"target": "server_npc"
}
}
On Tick moves the NPC along x by dir × speed × delta and turns it the way it walks. A Branch flips dir once it's further than range from where it started. dir, speed and range are the graph's parameters.

Clicking the NPC sends CL_NPC_CLICK to the server, which passes it on to the graphs acting on that NPC as a clicked message. On Message gets it, Cooldown lets it through at most once every 10 seconds, and the template's own Say in Chat node posts a line in the chat as the NPC:

// server/src/Server.ts
channel.on(ClientCommand.CL_NPC_CLICK, (command) => {
const cmd = command as CL_NPC_CLICK
if (this.game.world.entities.items.get(cmd.npcId) instanceof ServerNpc)
sendGraphMessage('clicked', player.name ?? '', cmd.npcId)
})
Running a graph in a scene
A LogicGraph scene object loads a graph and runs it every tick. Add one with Place in scene in the Graphs view, or in the scene file:
| Prop | Default | |
|---|---|---|
graph | name for graphs/<name>.graph.json, <package>:<name> for a plugin's | |
side | 'client' | Where it runs: 'client', 'server' or 'both' |
target | this object | The id of the scene object the graph acts on as Self. Without one it moves itself, it has a transform of its own |
parameters | the graph's defaults | Values for the graph's parameters |
The editor shows it as a helper in the viewport, with the graph, where it runs and its Self in the Properties panel. A graph that runs only on the server is still built on the client, so the editor can show and move it.
The server reads graphs from the project's graphs/ directory, so give it the root option (the template does). In dev it watches that directory: saving a graph in the editor restarts it in every object running it on the server, from On Start, and a graph that doesn't run any more keeps the old version and logs why. On the client the editor does the same as you edit, and the steps light up in the Graphs view as they run.
Nodes
Steps have exec ports (white) and run in order along them. Value nodes have none: they're worked out when a step reads them, fresh for every step, so a step sees what the ones before it changed. A step's outputs keep their last value.
| Category | Nodes |
|---|---|
| Events | On Start (once), On Tick (every tick, with delta), Every (every few seconds), On Key (a key by its code, e.g. Space, KeyW; client only), On Message (a message by name, with its value) |
| Flow | Branch, Sequence (outputs 1, 2, 3 in turn), Do Once, Cooldown (sooner runs go to Blocked), Delay |
| Actions | Log (to the game's log), Send Message (to every logic graph on this side) |
| Entity | Self, Scene Object (by id), Position / Rotation / Scale, Set …, Move By / Rotate By / Grow By |
| Variables | Get Variable, Set Variable. A variable starts as the parameter of the same name, if there is one |
| Logic | Compare (<, <=, ==, !=, >=, >), And, Or, Not |
| Input | Float, Vec2, Vec3, Vec4, Color, Bool, Text, Parameter, Time |
| Math, Vector | Add, Subtract, Multiply, Divide, Min, Max, Power, Step, Sine, Cosine, Absolute, Floor, Fraction, Square Root, Negate, One Minus, Mix, Clamp, Smoothstep, Remap; Combine, Split, Length, Distance, Dot, Normalize, Cross |
Entity inputs take a scene object's id; left empty they mean Self. Math nodes work on numbers and vectors alike, component by component: a float and a vec3 give a vec3.
Comment and Group nodes do nothing when the graph runs. A comment describes a part of the graph, a group is a named box that moves the nodes in it together.
A run can't hang the game: one event runs at most 10 000 steps, then the graph logs that its exec edges probably loop.
Messages
Send Message reaches every logic graph on the same side, and their On Message nodes with that name. From code, send one with sendGraphMessage(), to every graph or only to those acting on one scene object:
import { sendGraphMessage } from '@mavonengine/core/Graph/Logic/logicGraphObject'
sendGraphMessage('alarm', 1) // every logic graph on this side
sendGraphMessage('clicked', 'Alice', npc.id) // only the graphs whose Self is npc
Messages stay on their side: a client graph doesn't hear a server graph. Send a command across and call sendGraphMessage() on the other side, as the template does for clicks.
Your own nodes
A node type is a NodeDefinition: its ports and a run for a step, or an eval for a value node. Register it on every side whose graphs use it; the editor needs it on the client to show it, even when the graph only runs on the server. This is the template's Say in Chat node:
import type { NodeDefinition } from '@mavonengine/core/Graph/NodeRegistry'
import { registerNode } from '@mavonengine/core/Graph/NodeRegistry'
export const sayInChatNode: NodeDefinition = {
type: 'chat.say',
label: 'Say in Chat',
category: 'Actions',
description: 'Post a line in the chat as the graph\'s Self',
kinds: ['logic'],
inputs: {
run: { type: 'exec', label: '' },
message: { type: 'any', label: 'Message', default: 'Hello!' },
},
outputs: {
then: { type: 'exec', label: '' },
},
run: ({ message }, { self }) => {
post?.(self?.id ?? '', String(message ?? ''))
},
}
registerNode(sayInChatNode)
| Field | |
|---|---|
type, label, category, description | Its key in graph files, and how the editor lists it |
kinds | ['logic'], ['material'] or both |
inputs, outputs | Ports by name: { type, label?, default? }. Types: float, int, bool, vec2, vec3, vec4, color, texture, string, entity, exec, plus number (any number or vector) and any |
settings | Values set on the node itself rather than connected |
eval(inputs, ctx) | A value node's outputs |
run(inputs, ctx) | A step. Return { next, outputs } to pick the exec outputs to continue from (the first by default, none for []) and set its outputs |
trigger | Makes it an event: the runtime event (start, tick, keydown, message, or your own) that runs it. Its run returns false to let an event pass |
run gets self, entity(id), parameters, values, time, variables, its own state kept between runs, after(seconds, port) to continue later, emit(name, value) and log(message).
Plugins register nodes through their context instead, keyed as <package>:<type>, see Plugins.
Subgraphs
A graph with Graph Input and Graph Output nodes is a function: it shows up as a node in other graphs of its kind, under Subgraphs, with a port for each input and output. Subgraphs hold values only, no events or steps. The editor lists them with a subgraph badge.
Graph files
Graphs are JSON files in the project's graphs/ directory, next to scenes/: graphs/<name>.graph.json, names of letters, digits, - and _. The editor saves them through the dev server, and every release ships them.
{
"version": 1,
"kind": "logic",
"name": "server-npc",
"nodes": [
{ "id": "tick", "type": "event.tick", "position": [0, 0] },
{ "id": "move", "type": "entity.addPosition", "position": [240, 0] }
],
"edges": [
{ "from": { "node": "tick", "port": "then" }, "to": { "node": "move", "port": "run" } }
],
"parameters": [
{ "name": "speed", "type": "float", "default": 1.5 }
]
}
Graphs from plugins
A plugin can ship graphs in a graphs/ directory of its package. They go by <package>:<name>, are served at /graphs/<package>/<name>.graph.json and ship in every release. The editor lists them read-only; Copy to project makes an editable copy.
Running a graph from code
import { readGraph } from '@mavonengine/core/Graph/loadGraphFile' // Node only
import { GraphRuntime } from '@mavonengine/core/Graph/Logic/GraphRuntime'
const runtime = new GraphRuntime(readGraph(root, 'server-npc'), {
self, // a GraphEntity: get/set position, rotation, scale
find: id => entityById(id),
parameters: { speed: 3 },
log: message => logger.info(message),
})
runtime.start() // On Start
runtime.update(delta) // Delays, then On Tick
runtime.message('clicked', 'Alice')
A graph with problems (unknown nodes, edges between ports that don't fit, a node that can't run in a logic graph) throws a GraphRuntimeError listing them. The editor shows the same list under Problems.
VR (WebXR)
Play a MavonEngine game in a VR headset through WebXR — camera rig, controllers, thumbstick locomotion, labels and panels in VR, and mirroring to the browser window.
Material Graphs
Node-based materials for MavonEngine — made in the level editor, compiled to three.js TSL and put on primitives, with parameters, textures, noise and subgraphs.