Commands
CommandChannel (world.commands) is a list of named commands with a description. A command takes one object of arguments and returns data (or a promise). The inspector, the model viewer, the level editor and AI agents all use the same channel: list() says what is there, execute(name, args) runs it.
world.commands.list(); // [{ name, description }, ...]
await world.commands.execute('world.timeScale', { scale: 0.25 });
await world.commands.execute('physics.enable', { name: 'heat' });
A package registers its commands when its service or capability starts, so the list is the list of what the running game has loaded.
What exists#
| Area | Commands |
|---|---|
| World | world.info, world.pause, world.step, world.timeScale |
| Scene | scene.entities, scene.node, scene.nodes, scene.bounds, scene.stats, scene.validate, scene.exportStep, camera.get, camera.set, camera.view, view.set |
| Assets and packages | asset.list, asset.load, asset.remove, and the pkg.* commands (add, remove, validate a level package) |
| Animation | anim.list, anim.graph, anim.play, anim.stop, anim.montage, anim.set, anim.scrub |
| Physics host | physics.info, physics.enable, physics.disable, physics.configure, physics.materials, physics.bodies, body.state, body.impulse |
| Gravity and media | gravity.at, gravity.set, gravity.scale, gravity.attractor.add, gravity.attractor.remove, media.add, media.at, media.remove, wind.set, atmosphere.at |
| Strength and stretch | strength.health, strength.damage, stretch.info, cloth.pin |
| Ground and explosions | terrain.at, terrain.dig, terrain.fill, terrain.level, terrain.wet, terrain.compact, terrain.dump, explosion.detonate, explosion.info, explosion.preview |
| Heat, chemistry, nuclear | heat.add, heat.info, heat.join, heat.part.add, heat.set, heat.state, heat.step, chem.check, chem.info, chem.react, isotope.add, radiation.dose, radiation.map, reactor.rods, reactor.scram, reactor.state, nuclear.info |
| Combustion | chamber.ignite, chamber.state, chamber.vent, combustion.info, engine.start, engine.stop, engine.throttle, gun.fire, wick.add, gate.force |
| Electric and machines | circuit.add, circuit.connect, circuit.info, circuit.set, circuit.state, circuit.step, machine.info, machine.set, machine.state, machine.step, meter.read |
| Vehicles and liquids | vessel.add, vessel.info, vessel.state, vessel.fill, vessel.thrust, vessel.heat, vessel.burner, vessel.breach, vessel.blow, vessel.surface, liquid.add, liquid.info, fluid.info, reservoir.add, reservoir.state, surface.disturb, surface.height, surface.info, capillary.add, assembly.state |
| Links | link.add, link.state, link.valve, links.energy |
Each command's description and arguments come from the command itself: world.commands.list() is the authority, this table only shows where to look.
STEP export for CAD#
scene.exportStep writes the visible meshes of the running scene, or one node and its children, as a STEP file (ISO 10303-21, AP214) that CAD programs open: FreeCAD, Fusion, SolidWorks, Inventor, KOMPAS, Onshape. In the browser editor it is Viewer > Export .step...; in game code, exportStep(scene, options) from @ferret/inspector.
const r = await world.commands.execute('scene.exportStep', { node: 'engine', units: 'mm' });
// r.file 'engine.step', r.text the file, r.parts, r.solids, r.surfaces, r.triangles, r.skipped
- Arguments:
node(only this node and its children),name(the root of the assembly and the file name),units("mm", the default, or"m"; a scene unit is a metre),hidden(also disabled and invisible meshes),maxTriangles(default 2 000 000; a triangle is about 300 bytes of STEP). - What the file holds: an assembly with one part per mesh (an instance and each thin instance are parts of their own), named after the mesh, coloured by its material's base colour, in world coordinates, Z up (Babylon's x, y, z is written as x, z, y). Every triangle is a planar face: a closed piece of a mesh becomes a solid (
FACETED_BREP), an open one a surface (SHELL_BASED_SURFACE_MODEL). Faces are turned outwards. Vertices split at UV seams are welded, so a closed mesh stays closed. - What it does not hold: textures, UVs, vertex colours, lights, cameras, animation. A skinned or morphed mesh is written in its current pose. The faces are flat triangles, not the original curved surfaces: a sphere stays a polyhedron in CAD.
- Left out: overlays of the inspector, the sky (
infiniteDistance), lines, meshes without triangles, and hidden meshes unlesshiddenis set;skippedlists them.
Why it exists#
Anything a person can do in the editor or the inspector, an agent can do through the same names, and the same names are what the tests call. That is how a level is edited by commands and patches (@ferret/editor), inspected without a debugger (@ferret/inspector), and checked in an automated run.