Skip to main content
Two ways to stamp out reusable entities:
  • Templates — a named, rich SpawnRequest (40+ optional fields: mesh, color, health, team, combat, AI, role, …) stored in a TemplateRegistry at runtime, then spawned with a position override.
  • Prefabs — a static, minimal Prefab (a Vec<ComponentData>: position/health/team/name/speed/ damage) registered in code in a PrefabRegistry. Type-safe and serializable.
Use a template for a rich, data-defined spawn you author at runtime; a prefab for a small, compiled, type-checked blueprint.
The registry must exist on your host. POST /template/create only stores the template if a TemplateRegistry resource is present — otherwise it returns ok but does not persist (and /template/spawn then reports “not found”). The minimal headless_server example registers neither a TemplateRegistry nor a PrefabRegistry, so templates/prefabs are a no-op there — the same “register the resource on your host” pattern as input bindings and Lua scripting. Register the registry on your server build to use them.

Endpoints

MethodPathDescription
POST/template/createDefine a named template (a SpawnRequest)
POST/template/spawnInstantiate a template at a position
GET/template/listList defined templates
POST/prefab/spawnSpawn a registered prefab
GET/prefab/listList registered prefabs

Example

# Define a reusable red cube, then stamp it at a position
curl -s -X POST http://localhost:3917/template/create \
  -H 'Content-Type: application/json' \
  -d '{"name":"red-cube","mesh":"cube","color":"red","health":100,"team":1}'

curl -s -X POST http://localhost:3917/template/spawn \
  -H 'Content-Type: application/json' \
  -d '{"name":"red-cube","position":[5,0,3]}'
On the stock headless server these return ok (create) / not found (spawn) because no TemplateRegistry is registered. For a richer, data-defined world without templates, a whole world can be loaded from one scenario document.

Status

  • TemplateRegistry (rich runtime templates) and PrefabRegistry (static compiled prefabs) — the types, handlers, and spawn logic are shipped.
  • 🟡 The reference headless_server example registers neither registry, so the endpoints no-op there. This is a server-wiring gap, not a missing feature.

Template & prefab endpoints

Create, spawn, and list endpoints with schemas.